aboutsummaryrefslogtreecommitdiff
path: root/mod/reportedcontent/actions/add.php
blob: 6e86c4cf6289184465bc0dcea1b310d4ae26aee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

	/**
	 * Elgg report action
	 * 
	 * @package ElggReportContent
	 */

		$title = get_input('title');
		$description = get_input('description');
		$address = get_input('address');
		$access = ACCESS_PRIVATE; //this is private and only admins can see it
		
		if ($title && $address) {
			
			$report = new ElggObject;
			$report->subtype = "reported_content";
			$report->owner_guid = $_SESSION['user']->getGUID();
		    $report->title = $title;
		    $report->address = $address;
		    $report->description = $description;
		    $report->access_id = $access;
		
    		if ($report->save()) {
     			if (!trigger_plugin_hook('reportedcontent:add', 'system', array('report'=>$report), true)) {
     				$report->delete();
     				register_error(elgg_echo('reportedcontent:failed'));
     			} else {
	    			system_message(elgg_echo('reportedcontent:success'));
	    			$report->state = "active";
     			}
    			forward($address);
    		} else {
    			register_error(elgg_echo('reportedcontent:failed'));
    			forward($address);
    		}
    		
		} else {
    		
    		register_error(elgg_echo('reportedcontent:failed'));
    	    forward($address);
    	    
	    }

?>