]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
cleaned up the reported content plugin
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 29 Nov 2010 00:56:55 +0000 (00:56 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 29 Nov 2010 00:56:55 +0000 (00:56 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7466 36083f99-b078-4883-b0ff-0f9b5a30f544

13 files changed:
mod/reportedcontent/actions/add.php
mod/reportedcontent/actions/archive.php
mod/reportedcontent/actions/delete.php
mod/reportedcontent/add.php [deleted file]
mod/reportedcontent/languages/en.php
mod/reportedcontent/start.php
mod/reportedcontent/views/default/admin/overview/reportedcontent.php
mod/reportedcontent/views/default/object/reported_content.php [new file with mode: 0644]
mod/reportedcontent/views/default/reportedcontent/admin_css.php [new file with mode: 0644]
mod/reportedcontent/views/default/reportedcontent/css.php
mod/reportedcontent/views/default/reportedcontent/footer_link.php
mod/reportedcontent/views/default/reportedcontent/listing.php [deleted file]
mod/reportedcontent/views/default/reportedcontent/user_report.php

index 138e66cb9c34b81d7eb527af520719f11729d6ff..7c60cdf228cdcdad18aba0de7bd3a3174aa2f1e0 100644 (file)
@@ -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);
+}
index c0169fa286be7e1d4cade85961bd7fac5c91e0ed..c41645ee2d9ee0778444d31dd3f4157bf3b33930 100644 (file)
@@ -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);
index b7d6fdaa51f08693889be5574b262606f99cdcd9..faf169223daf9f53e42fd97cc9900a327babdff6 100644 (file)
@@ -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 (file)
index 1194627..0000000
+++ /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
index afcb3af6377cfcdfdfedb00729c468d098eed82a..8c0755b92d01849af80e53d02e5ba0d5895a6aa7 100644 (file)
@@ -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);
index 09ab714061df59e2ade2be540fe79d398e75a635..815c35fe5a0bbac2dc4f2cb434944b48eb0279a4 100644 (file)
@@ -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);
+}
index a12a9a6965984f73ecb6442b6350ffc20c649b62..0cf8643a32cbc6731498dbd1982d1ae767d551ff 100644 (file)
@@ -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 (file)
index 0000000..fa809ba
--- /dev/null
@@ -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 (file)
index 0000000..82566ff
--- /dev/null
@@ -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;
+}
index 3dcdbc36b85392ceb90207e45cd331f76ca974f1..c66cd20041fdfda4a635aa2769ced2ddc0dfc614 100644 (file)
@@ -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;
        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;
-}
-
index 0e953e0b9385d205184e876722e1889166788b18..69e6f096708b6c6a7056cea8d1a003fc25859605 100644 (file)
@@ -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 (file)
index 4236894..0000000
+++ /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
index 78fcf92fd3fb97fe9a95911a13bc3cba8fa264c0..517e87c8642e88cfd3f40087fd930608a4fb3698 100644 (file)
@@ -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