aboutsummaryrefslogtreecommitdiff
path: root/mod/reportedcontent
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-29 00:56:55 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-29 00:56:55 +0000
commit855b008013aad0426ab0332b040bddb033bb6af9 (patch)
tree70c137e5c9a9c916bb9f8172daf3bd0483895bf6 /mod/reportedcontent
parent71dc8cbf9eecb4de149bc96bb5758b866116b1c8 (diff)
downloadelgg-855b008013aad0426ab0332b040bddb033bb6af9.tar.gz
elgg-855b008013aad0426ab0332b040bddb033bb6af9.tar.bz2
cleaned up the reported content plugin
git-svn-id: http://code.elgg.org/elgg/trunk@7466 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/reportedcontent')
-rw-r--r--mod/reportedcontent/actions/add.php74
-rw-r--r--mod/reportedcontent/actions/archive.php2
-rw-r--r--mod/reportedcontent/actions/delete.php2
-rw-r--r--mod/reportedcontent/add.php31
-rw-r--r--mod/reportedcontent/languages/en.php79
-rw-r--r--mod/reportedcontent/start.php46
-rw-r--r--mod/reportedcontent/views/default/admin/overview/reportedcontent.php9
-rw-r--r--mod/reportedcontent/views/default/object/reported_content.php79
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/admin_css.php38
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/css.php37
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/footer_link.php4
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/listing.php42
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/user_report.php2
13 files changed, 240 insertions, 205 deletions
diff --git a/mod/reportedcontent/actions/add.php b/mod/reportedcontent/actions/add.php
index 138e66cb9..7c60cdf22 100644
--- a/mod/reportedcontent/actions/add.php
+++ b/mod/reportedcontent/actions/add.php
@@ -1,45 +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
- /**
- * Elgg report action
- *
- * @package ElggReportContent
- */
+if ($title && $address) {
- $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 = get_loggedin_userid();
- $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);
- }
-
+ $report = new ElggObject;
+ $report->subtype = "reported_content";
+ $report->owner_guid = get_loggedin_userid();
+ $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 {
-
- register_error(elgg_echo('reportedcontent:failed'));
- forward($address);
-
- }
+ system_message(elgg_echo('reportedcontent:success'));
+ $report->state = "active";
+ }
+ forward($address);
+ } else {
+ register_error(elgg_echo('reportedcontent:failed'));
+ forward($address);
+ }
+} else {
-?> \ No newline at end of file
+ register_error(elgg_echo('reportedcontent:failed'));
+ forward($address);
+}
diff --git a/mod/reportedcontent/actions/archive.php b/mod/reportedcontent/actions/archive.php
index c0169fa28..c41645ee2 100644
--- a/mod/reportedcontent/actions/archive.php
+++ b/mod/reportedcontent/actions/archive.php
@@ -6,7 +6,7 @@
*/
// Get input data
-$guid = (int) get_input('item');
+$guid = (int) get_input('guid');
// Make sure we actually have permission to edit
$report = get_entity($guid);
diff --git a/mod/reportedcontent/actions/delete.php b/mod/reportedcontent/actions/delete.php
index b7d6fdaa5..faf169223 100644
--- a/mod/reportedcontent/actions/delete.php
+++ b/mod/reportedcontent/actions/delete.php
@@ -6,7 +6,7 @@
*/
// Get input data
-$guid = (int) get_input('item');
+$guid = (int) get_input('guid');
// Make sure we actually have permission to edit
$report = get_entity($guid);
diff --git a/mod/reportedcontent/add.php b/mod/reportedcontent/add.php
deleted file mode 100644
index 1194627f1..000000000
--- a/mod/reportedcontent/add.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Elgg reported content send report page
- *
- * @package ElggReportedContent
- */
-
-// Start engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// You need to be logged in for this one
-gatekeeper();
-
-// Get the current page's owner
-$page_owner = elgg_get_page_owner();
-if ($page_owner === false || is_null($page_owner)) {
- $page_owner = get_loggedin_user();
- set_page_owner($page_owner->getGUID());
-}
-
-$area2 .= elgg_view_title(elgg_echo('reportedcontent:this'), false);
-$area2 .= elgg_view('reportedcontent/form');
-$area3 .= elgg_echo('reportedcontent:warning');
-
-$params = array(
- 'content' => $area2,
- 'sidebar' => $area3
-);
-$body = elgg_view_layout('one_column_with_sidebar', $params);
-
-echo elgg_view_page(elgg_echo('reportedcontent:this'), $body); \ No newline at end of file
diff --git a/mod/reportedcontent/languages/en.php b/mod/reportedcontent/languages/en.php
index afcb3af63..8c0755b92 100644
--- a/mod/reportedcontent/languages/en.php
+++ b/mod/reportedcontent/languages/en.php
@@ -1,43 +1,40 @@
<?php
- /**
- * Elgg reported content plugin language pack
- *
- * @package ElggReportedContent
- */
+/**
+ * Elgg reported content plugin language pack
+ *
+ * @package ElggReportedContent
+ */
- $english = array(
-
- /**
- * Menu items and titles
- */
-
- 'item:object:reported_content' => 'Reported items',
- 'reportedcontent' => 'Reported content',
- 'reportedcontent:this' => 'Report this',
- 'reportedcontent:none' => 'There is no reported content',
- 'reportedcontent:report' => 'Report to admin',
- 'reportedcontent:title' => 'Page title',
- 'reportedcontent:deleted' => 'The reported content has been deleted',
- 'reportedcontent:notdeleted' => 'We were not able to delete that report',
- 'reportedcontent:delete' => 'Delete report',
- 'reportedcontent:areyousure' => 'Are you sure you want to delete?',
- 'reportedcontent:archive' => 'Archive report',
- 'reportedcontent:archived' => 'The report has been archived',
- 'reportedcontent:visit' => 'Visit reported item',
- 'reportedcontent:by' => 'Report by',
- 'reportedcontent:objecttitle' => 'Object title',
- 'reportedcontent:objecturl' => 'Object url',
- 'reportedcontent:reason' => 'Reason for report',
- 'reportedcontent:description' => 'Why are you reporting this?',
- 'reportedcontent:address' => 'Location of the item',
- 'reportedcontent:success' => 'Your report has been sent to the site admin',
- 'reportedcontent:failing' => 'Your report could not be sent',
- 'reportedcontent:report' => 'Report this',
- 'reportedcontent:moreinfo' => 'More info',
-
- 'reportedcontent:failed' => 'Sorry, the attempt to report this content has failed.',
- 'reportedcontent:notarchived' => 'We were not able to archive that report',
- );
-
- add_translation("en",$english);
-?> \ No newline at end of file
+$english = array(
+
+ 'item:object:reported_content' => 'Reported items',
+ 'reportedcontent' => 'Reported content',
+ 'reportedcontent:this' => 'Report this',
+ 'reportedcontent:this:tooltip' => 'Report this page to an administrator',
+ 'reportedcontent:none' => 'There is no reported content',
+ 'reportedcontent:report' => 'Report to admin',
+ 'reportedcontent:title' => 'Page title',
+ 'reportedcontent:deleted' => 'The reported content has been deleted',
+ 'reportedcontent:notdeleted' => 'We were not able to delete that report',
+ 'reportedcontent:delete' => 'Delete report',
+ 'reportedcontent:areyousure' => 'Are you sure you want to delete?',
+ 'reportedcontent:archive' => 'Archive report',
+ 'reportedcontent:archived' => 'The report has been archived',
+ 'reportedcontent:visit' => 'Visit reported item',
+ 'reportedcontent:by' => 'Report by',
+ 'reportedcontent:objecttitle' => 'Object title',
+ 'reportedcontent:objecturl' => 'Object url',
+ 'reportedcontent:reason' => 'Reason for report',
+ 'reportedcontent:description' => 'Why are you reporting this?',
+ 'reportedcontent:address' => 'Location of the item',
+ 'reportedcontent:success' => 'Your report has been sent to the site admin',
+ 'reportedcontent:failing' => 'Your report could not be sent',
+ 'reportedcontent:report' => 'Report this',
+ 'reportedcontent:moreinfo' => 'More info',
+ 'reportedcontent:instructions' => 'This report will be sent to the administrators of this site for review.',
+
+ 'reportedcontent:failed' => 'Sorry, the attempt to report this content has failed.',
+ 'reportedcontent:notarchived' => 'We were not able to archive that report',
+);
+
+add_translation("en", $english);
diff --git a/mod/reportedcontent/start.php b/mod/reportedcontent/start.php
index 09ab71406..815c35fe5 100644
--- a/mod/reportedcontent/start.php
+++ b/mod/reportedcontent/start.php
@@ -5,15 +5,20 @@
* @package ElggReportedContent
*/
+elgg_register_event_handler('init','system','reportedcontent_init');
+
/**
- * Initialise the Reported content and set up the menus.
- *
+ * Initialize the plugin
*/
function reportedcontent_init() {
global $CONFIG;
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('reportedcontent', 'reportedcontent_page_handler');
+
// Extend CSS
- elgg_extend_view('css', 'reportedcontent/css');
+ elgg_extend_view('css/elgg', 'reportedcontent/css');
+ elgg_extend_view('css/admin', 'reportedcontent/admin_css');
// Extend context menu and footer with report content link
if (isloggedin()) {
@@ -21,13 +26,36 @@ function reportedcontent_init() {
elgg_extend_view('footer/links', 'reportedcontent/footer_link');
}
+ // Add admin menu item
elgg_add_admin_submenu_item('reportedcontent', elgg_echo('reportedcontent'), 'overview');
- //register action
- elgg_register_action('reportedcontent/add', "{$CONFIG->pluginspath}reportedcontent/actions/add.php");
- elgg_register_action('reportedcontent/delete', "{$CONFIG->pluginspath}reportedcontent/actions/delete.php", 'admin');
- elgg_register_action('reportedcontent/archive', "{$CONFIG->pluginspath}reportedcontent/actions/archive.php", 'admin');
+ // Register actions
+ $action_path = "{$CONFIG->pluginspath}reportedcontent/actions";
+ elgg_register_action('reportedcontent/add', "$action_path/add.php");
+ elgg_register_action('reportedcontent/delete', "$action_path/delete.php", 'admin');
+ elgg_register_action('reportedcontent/archive', "$action_path/archive.php", 'admin');
}
-// Initialise Reported Content
-elgg_register_event_handler('init','system','reportedcontent_init');
+/**
+ * Reported content page handler
+ *
+ * Serves the add report page
+ *
+ * @param array $page Array of page routing elements
+ */
+function reportedcontent_page_handler($page) {
+ // only logged in users can report things
+ gatekeeper();
+
+ $content .= elgg_view_title(elgg_echo('reportedcontent:this'));
+ $content .= elgg_view('reportedcontent/form');
+ $sidebar .= elgg_echo('reportedcontent:instructions');
+
+ $params = array(
+ 'content' => $content,
+ 'sidebar' => $sidebar
+ );
+ $body = elgg_view_layout('one_column_with_sidebar', $params);
+
+ echo elgg_view_page(elgg_echo('reportedcontent:this'), $body);
+}
diff --git a/mod/reportedcontent/views/default/admin/overview/reportedcontent.php b/mod/reportedcontent/views/default/admin/overview/reportedcontent.php
index a12a9a696..0cf8643a3 100644
--- a/mod/reportedcontent/views/default/admin/overview/reportedcontent.php
+++ b/mod/reportedcontent/views/default/admin/overview/reportedcontent.php
@@ -1,16 +1,17 @@
<?php
/**
- * Elgg Reported content
+ * Elgg Reported content admin page
*
* @package ElggReportedContent
*/
$title = elgg_view_title(elgg_echo('reportedcontent'));
-$reported = elgg_get_entities(array('types' => 'object', 'subtypes' => 'reported_content', 'limit' => 9999));
-$list = elgg_view("reportedcontent/listing", array('entity' => $reported));
+$list = elgg_list_entities(array('types' => 'object', 'subtypes' => 'reported_content'));
+if (!$list) {
+ $list = '<p class="margin_top">' . elgg_echo('reportedcontent:none') . '</p>';
+}
-// Display main admin menu
$body = <<<__HTML
$title
$list
diff --git a/mod/reportedcontent/views/default/object/reported_content.php b/mod/reportedcontent/views/default/object/reported_content.php
new file mode 100644
index 000000000..fa809bae6
--- /dev/null
+++ b/mod/reportedcontent/views/default/object/reported_content.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Elgg reported content object view
+ *
+ * @package ElggReportContent
+ */
+
+$report = $vars['entity'];
+$reporter = $report->getOwnerEntity();
+
+$archive_url = elgg_get_site_url() . "action/reportedcontent/archive?guid=$report->guid";
+$delete_url = elgg_get_site_url() . "action/reportedcontent/delete?guid=$report->guid";
+
+//find out if the report is current or archive
+if ($report->state == 'archived') {
+ $reportedcontent_background = "archived_report";
+} else {
+ $reportedcontent_background = "active_report";
+}
+
+?>
+
+<div class="admin_settings reported_content <?php echo $reportedcontent_background; ?>">
+ <div class="clearfix controls">
+<?php
+ if ($report->state != 'archived') {
+ $params = array(
+ 'href' => $archive_url,
+ 'text' => elgg_echo('reportedcontent:archive'),
+ 'is_action' => true,
+ 'class' => 'action_button',
+ );
+ echo elgg_view('output/url', $params);
+ }
+ $params = array(
+ 'href' => $delete_url,
+ 'text' => elgg_echo('reportedcontent:delete'),
+ 'is_action' => true,
+ 'class' => 'action_button disabled',
+ );
+ echo elgg_view('output/url', $params);
+?>
+ </div>
+ <p>
+ <b><?php echo elgg_echo('reportedcontent:by'); ?>:</b>
+ <?php echo elgg_view('output/url', array(
+ 'href' => $reporter->getURL(),
+ 'text' => $reporter->name
+ ));
+ ?>,
+ <?php echo elgg_view_friendly_time($report->time_created); ?>
+ </p>
+ <p>
+ <b><?php echo elgg_echo('reportedcontent:objecttitle'); ?>:</b>
+ <?php echo $report->title; ?>
+ <br />
+ <?php echo elgg_view('output/url', array(
+ 'href' => '#',
+ 'text' => elgg_echo('reportedcontent:moreinfo'),
+ 'class' => 'details_link',
+ 'onclick' => "elgg_slide_toggle(this, '.reported_content', '.reported_content_more{$report->getGUID()}'); return false;"
+ ));
+ ?>
+ </p>
+ <div class="details hidden reported_content_more<?php echo $report->getGUID();?>">
+ <p>
+ <b><?php echo elgg_echo('reportedcontent:objecturl'); ?>:</b>
+ <?php echo elgg_view('output/url', array(
+ 'href' => $report->address,
+ 'text' => elgg_echo('reportedcontent:visit')
+ ));
+ ?>
+ </p>
+ <p>
+ <b><?php echo elgg_echo('reportedcontent:reason'); ?>:</b>
+ <?php echo $report->description; ?>
+ </p>
+ </div>
+</div>
diff --git a/mod/reportedcontent/views/default/reportedcontent/admin_css.php b/mod/reportedcontent/views/default/reportedcontent/admin_css.php
new file mode 100644
index 000000000..82566ff3a
--- /dev/null
+++ b/mod/reportedcontent/views/default/reportedcontent/admin_css.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Elgg reported content admin CSS
+ *
+ * @package ElggReportContent
+ */
+?>
+
+/* REPORTED CONTENT */
+.admin_settings.reported_content {
+ margin:5px 0 0 0;
+ padding:5px 7px 3px 9px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+}
+.admin_settings.reported_content p {
+ margin:0;
+}
+.active_report {
+ border:1px solid #D3322A;
+ background:#F7DAD8;
+}
+.archived_report {
+ border:1px solid #666666;
+ background:#dedede;
+}
+.admin_settings.reported_content .controls {
+ float:right;
+ margin:14px 5px 0 0;
+}
+.admin_settings.reported_content a.action_button {
+ display:inline;
+ float:right;
+ margin-left:15px;
+}
+.admin_settings.reported_content .details_link {
+ cursor: pointer;
+}
diff --git a/mod/reportedcontent/views/default/reportedcontent/css.php b/mod/reportedcontent/views/default/reportedcontent/css.php
index 3dcdbc36b..c66cd2004 100644
--- a/mod/reportedcontent/views/default/reportedcontent/css.php
+++ b/mod/reportedcontent/views/default/reportedcontent/css.php
@@ -1,12 +1,14 @@
<?php
/**
* Elgg reported content CSS
+ *
+ * Footer link CSS
*
- * @package reportedcontent
+ * @package ElggReportContent
*/
?>
-/* link in footer */
+/* Reported Content */
#report_this {
text-align: left;
float:left;
@@ -16,34 +18,3 @@
padding:0 0 4px 20px;
background: url(<?php echo elgg_get_site_url(); ?>mod/reportedcontent/graphics/icon_reportthis.gif) no-repeat left top;
}
-/* admin area */
-.admin_settings.reported_content {
- margin:5px 0 0 0;
- padding:5px 7px 3px 9px;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
-}
-.admin_settings.reported_content p {
- margin:0;
-}
-.active_report {
- border:1px solid #D3322A;
- background:#F7DAD8;
-}
-.archived_report {
- border:1px solid #666666;
- background:#dedede;
-}
-.admin_settings.reported_content .controls {
- float:right;
- margin:14px 5px 0 0;
-}
-.admin_settings.reported_content a.action_button {
- display:inline;
- float:right;
- margin-left:15px;
-}
-.admin_settings.reported_content .details_link {
- cursor: pointer;
-}
-
diff --git a/mod/reportedcontent/views/default/reportedcontent/footer_link.php b/mod/reportedcontent/views/default/reportedcontent/footer_link.php
index 0e953e0b9..69e6f0967 100644
--- a/mod/reportedcontent/views/default/reportedcontent/footer_link.php
+++ b/mod/reportedcontent/views/default/reportedcontent/footer_link.php
@@ -5,10 +5,10 @@
* @package ElggReportContent
*/
-$title = elgg_echo('reportedcontent:this:title');
+$title = elgg_echo('reportedcontent:this:tooltip');
$text = elgg_echo('reportedcontent:this');
?>
<div id="report_this">
- <a href="javascript:location.href='<?php echo elgg_get_site_url(); ?>mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)" title="<?php echo $title; ?>"><?php echo $text; ?></a>
+ <a href="javascript:location.href='<?php echo elgg_get_site_url(); ?>pg/reportedcontent/add/?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)" title="<?php echo $title; ?>"><?php echo $text; ?></a>
</div>
diff --git a/mod/reportedcontent/views/default/reportedcontent/listing.php b/mod/reportedcontent/views/default/reportedcontent/listing.php
deleted file mode 100644
index 4236894c2..000000000
--- a/mod/reportedcontent/views/default/reportedcontent/listing.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * Elgg report content listing
- *
- * @package ElggReportContent
- */
-
-if($vars['entity']){
- $id = 0;
- foreach($vars['entity'] as $report){
-
- // increment our id counter
- $id++;
-
- //get the user making the report
- $user = get_user($report->owner_guid)->name;
- $user_url = get_user($report->owner_guid)->getURL();
-
- //find out if the report is current or archive
- if($report->state == 'archived'){
- $reportedcontent_background = "archived_report";
- }else{
- $reportedcontent_background = "active_report";
- }
-
- echo "<div class='admin_settings reported_content {$reportedcontent_background}'>";
- echo "<div class='clearfix controls'>";
- if($report->state != 'archived')
- echo "<a class='action_button' href=\"" . elgg_add_action_tokens_to_url(elgg_get_site_url() . "action/reportedcontent/archive?item={$report->guid}") . "\">" . elgg_echo('reportedcontent:archive') . "</a>";
- echo "<a class='action_button disabled' href=\"" . elgg_add_action_tokens_to_url(elgg_get_site_url() . "action/reportedcontent/delete?item={$report->guid}") . "\" onclick=\"return confirm('" . elgg_echo('reportedcontent:areyousure') . "')\">" . elgg_echo('reportedcontent:delete') . "</a></div>";
- echo "<p><b>" . elgg_echo('reportedcontent:by') . ": </b><a href=\"{$user_url}\">" . $user . "</a>, " . elgg_view_friendly_time($report->time_created) . "</p>";
- echo "<p><b>" . elgg_echo('reportedcontent:objecttitle') . ": </b>" . $report->title;
- echo "<br /><a onclick=\"elgg_slide_toggle(this,'.reported_content','.container{$id}');\" class='details_link'>" . elgg_echo('reportedcontent:moreinfo') . "</a></p>";
- echo "<div class='details container{$id} hidden'>";
- echo "<p><b>" . elgg_echo('reportedcontent:objecturl') . ": </b><a href=\"{$report->address}\">" . elgg_echo('reportedcontent:visit') . "</a></p>";
- echo "<p><b>" . elgg_echo('reportedcontent:reason') . ": </b>" .$report->description . "</p>";
- echo "</div></div>";
- }
-
-} else {
- echo "<p class='margin_top'>".elgg_echo('reportedcontent:none')."</p>";
-} \ No newline at end of file
diff --git a/mod/reportedcontent/views/default/reportedcontent/user_report.php b/mod/reportedcontent/views/default/reportedcontent/user_report.php
index 78fcf92fd..517e87c86 100644
--- a/mod/reportedcontent/views/default/reportedcontent/user_report.php
+++ b/mod/reportedcontent/views/default/reportedcontent/user_report.php
@@ -1,5 +1,5 @@
<li class="user_menu_profile">
<?php
- echo "<a class='report_this' href=\"javascript:location.href='". elgg_get_site_url() . "mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">" . elgg_echo('reportedcontent:report') . "</a>";
+ echo "<a class='report_this' href=\"javascript:location.href='". elgg_get_site_url() . "pg/reportedcontent/add/?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">" . elgg_echo('reportedcontent:report') . "</a>";
?>
</li> \ No newline at end of file