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 | |||
12 | $fail = function () use ($address) { |
||
13 | register_error(elgg_echo('reportedcontent:failed')); |
||
14 | forward(elgg_normalize_site_url($address)); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
15 | }; |
||
16 | |||
17 | if (!$title || !$address) { |
||
18 | $fail(); |
||
19 | } |
||
20 | |||
21 | $report = new ElggObject; |
||
22 | $report->subtype = "reported_content"; |
||
23 | $report->owner_guid = elgg_get_logged_in_user_guid(); |
||
24 | $report->title = $title; |
||
25 | $report->address = $address; |
||
26 | $report->description = $description; |
||
27 | $report->access_id = $access; |
||
28 | |||
29 | if (!$report->save()) { |
||
30 | $fail(); |
||
31 | } |
||
32 | |||
33 | if (!elgg_trigger_plugin_hook('reportedcontent:add', 'system', array('report' => $report), true)) { |
||
34 | $report->delete(); |
||
35 | $fail(); |
||
36 | } |
||
37 | |||
38 | system_message(elgg_echo('reportedcontent:success')); |
||
39 | $report->state = "active"; |
||
40 | forward($address); |
||
41 |