add.php 912 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Elgg report action
  4. *
  5. * @package ElggReportContent
  6. */
  7. $title = get_input('title');
  8. $description = get_input('description');
  9. $address = get_input('address');
  10. $access = ACCESS_PRIVATE; //this is private and only admins can see it
  11. $fail = function () use ($address) {
  12. register_error(elgg_echo('reportedcontent:failed'));
  13. forward($address);
  14. };
  15. if (!$title || !$address) {
  16. $fail();
  17. }
  18. $report = new ElggObject;
  19. $report->subtype = "reported_content";
  20. $report->owner_guid = elgg_get_logged_in_user_guid();
  21. $report->title = $title;
  22. $report->address = $address;
  23. $report->description = $description;
  24. $report->access_id = $access;
  25. if (!$report->save()) {
  26. $fail();
  27. }
  28. if (!elgg_trigger_plugin_hook('reportedcontent:add', 'system', array('report' => $report), true)) {
  29. $report->delete();
  30. $fail();
  31. }
  32. system_message(elgg_echo('reportedcontent:success'));
  33. $report->state = "active";
  34. forward($address);