diff options
Diffstat (limited to 'mod/reportedcontent/actions')
| -rw-r--r-- | mod/reportedcontent/actions/add.php | 49 | ||||
| -rw-r--r-- | mod/reportedcontent/actions/archive.php | 38 | ||||
| -rw-r--r-- | mod/reportedcontent/actions/delete.php | 41 | ||||
| -rw-r--r-- | mod/reportedcontent/actions/reportedcontent/add.php | 39 | ||||
| -rw-r--r-- | mod/reportedcontent/actions/reportedcontent/archive.php | 27 | ||||
| -rw-r--r-- | mod/reportedcontent/actions/reportedcontent/delete.php | 28 |
6 files changed, 94 insertions, 128 deletions
diff --git a/mod/reportedcontent/actions/add.php b/mod/reportedcontent/actions/add.php deleted file mode 100644 index 80f67eab4..000000000 --- a/mod/reportedcontent/actions/add.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - - /** - * Elgg report action - * - * @package ElggReportContent - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider <info@elgg.com> - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.org/ - */ - - $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); - - } - -?>
\ No newline at end of file diff --git a/mod/reportedcontent/actions/archive.php b/mod/reportedcontent/actions/archive.php deleted file mode 100644 index ca4ad2c41..000000000 --- a/mod/reportedcontent/actions/archive.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - - /** - * Elgg reported content: archive action - * - * @package ElggReportedContent - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider Ltd <info@elgg.com> - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.org/ - */ - - // Make sure we're logged in and are admin - admin_gatekeeper(); - - // Get input data - $guid = (int) get_input('item'); - - // Make sure we actually have permission to edit - $report = get_entity($guid); - if ($report->getSubtype() == "reported_content" && $report->canEdit()) { - - // change the state - if (!trigger_plugin_hook('reportedcontent:archive', 'system', array('report'=>$report), true)) { - system_message(elgg_echo("reportedcontent:notarchived")); - forward("pg/reportedcontent/"); - } - $report->state = "archived"; - - // Success message - system_message(elgg_echo("reportedcontent:archived")); - - // Forward back to the reported content page - forward("pg/reportedcontent/"); - - } - -?>
\ No newline at end of file diff --git a/mod/reportedcontent/actions/delete.php b/mod/reportedcontent/actions/delete.php deleted file mode 100644 index b2e9c7acd..000000000 --- a/mod/reportedcontent/actions/delete.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - - /** - * Elgg reported content: delete action - * - * @package ElggReportedCOntent - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider Ltd <info@elgg.com> - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.org/ - */ - - // Make sure we're logged in and are admin - admin_gatekeeper(); - - // Get input data - $guid = (int) get_input('item'); - - // Make sure we actually have permission to edit - $report = get_entity($guid); - if ($report->getSubtype() == "reported_content" && $report->canEdit()) { - - // Delete it! - if (!trigger_plugin_hook('reportedcontent:delete', '$system', array('report'=>$report), true)) { - register_error(elgg_echo("reportedcontent:notdeleted")); - forward("pg/reportedcontent/"); - } - $rowsaffected = $report->delete(); - if ($rowsaffected > 0) { - // Success message - system_message(elgg_echo("reportedcontent:deleted")); - } else { - register_error(elgg_echo("reportedcontent:notdeleted")); - } - - // Forward back to the reported content page - forward("pg/reportedcontent/"); - - } - -?>
\ No newline at end of file diff --git a/mod/reportedcontent/actions/reportedcontent/add.php b/mod/reportedcontent/actions/reportedcontent/add.php new file mode 100644 index 000000000..f0a1b05c8 --- /dev/null +++ b/mod/reportedcontent/actions/reportedcontent/add.php @@ -0,0 +1,39 @@ +<?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 = elgg_get_logged_in_user_guid(); + $report->title = $title; + $report->address = $address; + $report->description = $description; + $report->access_id = $access; + + if ($report->save()) { + if (!elgg_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); +} diff --git a/mod/reportedcontent/actions/reportedcontent/archive.php b/mod/reportedcontent/actions/reportedcontent/archive.php new file mode 100644 index 000000000..dd5c6aef1 --- /dev/null +++ b/mod/reportedcontent/actions/reportedcontent/archive.php @@ -0,0 +1,27 @@ +<?php +/** + * Elgg reported content: archive action + * + * @package ElggReportedContent + */ + +$guid = (int) get_input('guid'); + +$report = get_entity($guid); + +// Make sure we actually have permission to edit +if ($report->getSubtype() == "reported_content" && $report->canEdit()) { + + // allow another plugin to override + if (!elgg_trigger_plugin_hook('reportedcontent:archive', 'system', array('report' => $report), TRUE)) { + system_message(elgg_echo("reportedcontent:notarchived")); + forward(REFERER); + } + + // change the state + $report->state = "archived"; + + system_message(elgg_echo("reportedcontent:archived")); + + forward(REFERER); +} diff --git a/mod/reportedcontent/actions/reportedcontent/delete.php b/mod/reportedcontent/actions/reportedcontent/delete.php new file mode 100644 index 000000000..f7d4e2107 --- /dev/null +++ b/mod/reportedcontent/actions/reportedcontent/delete.php @@ -0,0 +1,28 @@ +<?php +/** + * Elgg reported content: delete action + * + * @package ElggReportedContent + */ + +$guid = (int) get_input('guid'); + +$report = get_entity($guid); + +// Make sure we actually have permission to delete +if ($report->getSubtype() == "reported_content" && $report->canEdit()) { + + // give another plugin a chance to override + if (!elgg_trigger_plugin_hook('reportedcontent:delete', 'system', array('report' => $report), TRUE)) { + register_error(elgg_echo("reportedcontent:notdeleted")); + forward(REFERER); + } + + if ($report->delete()) { + system_message(elgg_echo("reportedcontent:deleted")); + } else { + register_error(elgg_echo("reportedcontent:notdeleted")); + } + + forward(REFERER); +} |
