Completed
Push — 2.3 ( e6f9d2...a69256 )
by Jeroen
09:57 queued 11s
created

reportedcontent/actions/reportedcontent/add.php (1 issue)

Labels
Severity
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
It seems like elgg_normalize_site_url($address) can also be of type false; however, parameter $location of forward() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

14
	forward(/** @scrutinizer ignore-type */ elgg_normalize_site_url($address));
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