aboutsummaryrefslogtreecommitdiff
path: root/mod/reportedcontent
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-03 17:53:05 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-03 17:53:05 +0000
commit4766f36a4d74924f21ff329c4318ce4e069ffa04 (patch)
tree969b84632f2a8b0db79788a8a6db8e41d63e5cb4 /mod/reportedcontent
parent57a217fd6b708844407486046a1faa23b46cac08 (diff)
downloadelgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.gz
elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.bz2
Pulled in the interface changes.
git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/reportedcontent')
-rw-r--r--mod/reportedcontent/actions/add.php49
-rw-r--r--mod/reportedcontent/actions/archive.php38
-rw-r--r--mod/reportedcontent/actions/delete.php41
-rw-r--r--mod/reportedcontent/add.php36
-rw-r--r--mod/reportedcontent/index.php32
-rw-r--r--mod/reportedcontent/languages/en.php47
-rw-r--r--mod/reportedcontent/manifest.xml10
-rw-r--r--mod/reportedcontent/start.php69
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/css.php91
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/form.php74
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/listing.php43
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/owner_block.php9
-rw-r--r--mod/reportedcontent/views/default/reportedcontent/user_report.php6
13 files changed, 545 insertions, 0 deletions
diff --git a/mod/reportedcontent/actions/add.php b/mod/reportedcontent/actions/add.php
new file mode 100644
index 000000000..76cefa4c8
--- /dev/null
+++ b/mod/reportedcontent/actions/add.php
@@ -0,0 +1,49 @@
+<?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) {
+
+ $entity = new ElggObject;
+ $entity->subtype = "reported_content";
+ $entity->owner_guid = $_SESSION['user']->getGUID();
+ $entity->title = $title;
+ $entity->address = $address;
+ $entity->description = $description;
+ $entity->access_id = $access;
+
+ if ($entity->save()) {
+ if (!trigger_plugin_hook('reportedcontent:add', $reported->type, array('entity'=>$reported), true)) {
+ $entity->delete();
+ register_error(elgg_echo('reportedcontent:failed'));
+ } else {
+ system_message(elgg_echo('reportedcontent:success'));
+ $entity->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
new file mode 100644
index 000000000..a550abc2a
--- /dev/null
+++ b/mod/reportedcontent/actions/archive.php
@@ -0,0 +1,38 @@
+<?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
+ $reported = get_entity($guid);
+ if ($reported->getSubtype() == "reported_content" && $reported->canEdit()) {
+
+ // change the state
+ if (!trigger_plugin_hook('reportedcontent:archive', $reported->type, array('entity'=>$reported), true)) {
+ system_message(elgg_echo("reportedcontent:notarchived"));
+ forward("pg/reportedcontent/");
+ }
+ $reported->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
new file mode 100644
index 000000000..cff42b025
--- /dev/null
+++ b/mod/reportedcontent/actions/delete.php
@@ -0,0 +1,41 @@
+<?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
+ $reported = get_entity($guid);
+ if ($reported->getSubtype() == "reported_content" && $reported->canEdit()) {
+
+ // Delete it!
+ if (!trigger_plugin_hook('reportedcontent:delete', $reported->type, array('entity'=>$reported), true)) {
+ register_error(elgg_echo("reportedcontent:notdeleted"));
+ forward("pg/reportedcontent/");
+ }
+ $rowsaffected = $reported->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/add.php b/mod/reportedcontent/add.php
new file mode 100644
index 000000000..02892b4eb
--- /dev/null
+++ b/mod/reportedcontent/add.php
@@ -0,0 +1,36 @@
+<?php
+
+ /**
+ * Elgg reported content send report page
+ *
+ * @package ElggReportedContent
+ * @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/
+ */
+
+ // 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 = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($page_owner->getGUID());
+ }
+
+ $area2 .= elgg_view_title(elgg_echo('reportedcontent:this'), false);
+
+ $area2 .= elgg_view('reportedcontent/form');
+
+ // Format page
+ $body = elgg_view_layout('two_column_left_sidebar', '', $area2);
+
+ // Draw it
+ page_draw(elgg_echo('reportedcontent:add'),$body);
+
+?> \ No newline at end of file
diff --git a/mod/reportedcontent/index.php b/mod/reportedcontent/index.php
new file mode 100644
index 000000000..45c49866b
--- /dev/null
+++ b/mod/reportedcontent/index.php
@@ -0,0 +1,32 @@
+<?php
+ /**
+ * Elgg Reported content
+ *
+ * @package ElggReportedContent
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ admin_gatekeeper();
+ set_context('admin');
+ // Set admin user for user block
+ set_page_owner($_SESSION['guid']);
+
+
+ $title = elgg_view_title(elgg_echo('reportedcontent'));
+
+ $reported = elgg_get_entities(array('types' => 'object', 'subtypes' => 'reported_content', 'limit' => 9999));
+
+ $area2 = elgg_view("reportedcontent/listing", array('entity' => $reported));
+
+ if(!$reported)
+ $reported = elgg_echo("reportedcontent:none");
+
+// Display main admin menu
+ page_draw(elgg_echo('reportedcontent'),elgg_view_layout("two_column_left_sidebar", '', $title . $area2));
+
+?> \ No newline at end of file
diff --git a/mod/reportedcontent/languages/en.php b/mod/reportedcontent/languages/en.php
new file mode 100644
index 000000000..00cc73e0e
--- /dev/null
+++ b/mod/reportedcontent/languages/en.php
@@ -0,0 +1,47 @@
+<?php
+ /**
+ * Elgg reported content plugin language pack
+ *
+ * @package ElggReportedContent
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
+
+ $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 it',
+ 'reportedcontent:areyousure' => 'Are you sure you want to delete?',
+ 'reportedcontent:archive' => 'Archive it',
+ '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
diff --git a/mod/reportedcontent/manifest.xml b/mod/reportedcontent/manifest.xml
new file mode 100644
index 000000000..1d127cde3
--- /dev/null
+++ b/mod/reportedcontent/manifest.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Curverider" />
+ <field key="version" value="1.7" />
+ <field key="description" value="Adds the option for users to report content and for admins to check it out." />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008-2010" />
+ <field key="licence" value="GNU Public License version 2" />
+ <field key="elgg_version" value="2010030101" />
+</plugin_manifest>
diff --git a/mod/reportedcontent/start.php b/mod/reportedcontent/start.php
new file mode 100644
index 000000000..d8ee7369e
--- /dev/null
+++ b/mod/reportedcontent/start.php
@@ -0,0 +1,69 @@
+<?php
+ /**
+ * Elgg Reported content.
+ *
+ * @package ElggReportedContent
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Initialise the Reported content and set up the menus.
+ *
+ */
+ 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');
+
+ // Extend context menu and owner_block with report content link
+ if (isloggedin()) {
+ elgg_extend_view('profile/menu/links','reportedcontent/user_report');
+ elgg_extend_view('owner_block/extend', 'reportedcontent/owner_block');
+ }
+ }
+
+ /**
+ * Adding the reported content to the admin menu
+ *
+ */
+ function reportedcontent_pagesetup()
+ {
+ if (get_context() == 'admin' && isadminloggedin()) {
+ global $CONFIG;
+ add_submenu_item(elgg_echo('reportedcontent'), $CONFIG->wwwroot . 'pg/reportedcontent/');
+ }
+ }
+
+ /**
+ * Reported content page handler
+ *
+ * @param array $page Array of page elements, forwarded by the page handling mechanism
+ */
+ function reportedcontent_page_handler($page)
+ {
+ global $CONFIG;
+
+ // only interested in one page for now
+ include($CONFIG->pluginspath . "reportedcontent/index.php");
+ }
+
+
+
+ // Initialise Reported Content
+ register_elgg_event_handler('init','system','reportedcontent_init');
+ register_elgg_event_handler('pagesetup','system','reportedcontent_pagesetup');
+
+ //register action
+ register_action('reportedcontent/add',false,$CONFIG->pluginspath . "reportedcontent/actions/add.php");
+ register_action('reportedcontent/delete',false,$CONFIG->pluginspath . "reportedcontent/actions/delete.php");
+ register_action('reportedcontent/archive',false,$CONFIG->pluginspath . "reportedcontent/actions/archive.php");
+
+?> \ No newline at end of file
diff --git a/mod/reportedcontent/views/default/reportedcontent/css.php b/mod/reportedcontent/views/default/reportedcontent/css.php
new file mode 100644
index 000000000..061a5e5f6
--- /dev/null
+++ b/mod/reportedcontent/views/default/reportedcontent/css.php
@@ -0,0 +1,91 @@
+<?php
+
+ /**
+ * Elgg reported content CSS
+ *
+ * @package reportedcontent
+ * @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/
+ */
+
+?>
+/* ***************************************
+PAGE-OWNER BLOCK
+*************************************** */
+#owner_block_report_this {
+ padding:5px 0 0 0;
+}
+#owner_block_report_this a {
+ font-size: 90%;
+ color:#999999;
+ padding:0 0 4px 20px;
+ background: url(<?php echo $vars['url']; ?>_graphics/icon_reportthis.gif) no-repeat left top;
+}
+#owner_block_report_this a:hover {
+ color: #0054a7;
+}
+
+/* ***************************************
+ ADMIN AREA - REPORTED CONTENT
+*************************************** */
+.reportedcontent_content {
+ margin:0 0 5px 0;
+ padding:0 7px 4px 10px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+}
+.reportedcontent_content p.reportedcontent_detail,
+.reportedcontent_content p {
+ margin:0;
+}
+.active_report {
+ border:1px solid #D3322A;
+ background:#F7DAD8;
+}
+.archived_report {
+ border:1px solid #666666;
+ background:#dedede;
+}
+a.archive_report_button {
+ float:right;
+ font: 12px/100% Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ color: #ffffff;
+ background:#4690d6;
+ border: 1px solid #4690d6;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ width: auto;
+ padding: 4px;
+ margin:15px 0 0 20px;
+ cursor: pointer;
+}
+a.archive_report_button:hover {
+ background: #0054a7;
+ border: 1px solid #0054a7;
+ text-decoration: none;
+}
+a.delete_report_button {
+ float:right;
+ font: 12px/100% Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ color: #ffffff;
+ background:#999999;
+ border: 1px solid #999999;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ width: auto;
+ padding: 4px;
+ margin:15px 0 0 20px;
+ cursor: pointer;
+}
+a.delete_report_button:hover {
+ background: #333333;
+ border: 1px solid #333333;
+ text-decoration:none;
+}
+.reportedcontent_content .collapsible_box {
+ background: white;
+}
diff --git a/mod/reportedcontent/views/default/reportedcontent/form.php b/mod/reportedcontent/views/default/reportedcontent/form.php
new file mode 100644
index 000000000..73fbd5c93
--- /dev/null
+++ b/mod/reportedcontent/views/default/reportedcontent/form.php
@@ -0,0 +1,74 @@
+<?php
+
+ /**
+ * Elgg report content plugin form
+ *
+ * @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/
+ */
+
+ $guid = 0;
+ $title = get_input('title',"");
+ $description = "";
+ $address = get_input('address',"");
+ if ($address == "previous")
+ $address = $_SERVER['HTTP_REFERER'];
+ $tags = array();
+ $access_id = ACCESS_PRIVATE;
+ $shares = array();
+ $owner = $vars['user'];
+
+?>
+<div class="contentWrapper">
+ <form action="<?php echo $vars['url']; ?>action/reportedcontent/add" method="post">
+ <?php echo elgg_view('input/securitytoken'); ?>
+
+ <p>
+ <label>
+ <?php echo elgg_echo('reportedcontent:title'); ?>
+ <?php
+
+ echo elgg_view('input/text',array(
+ 'internalname' => 'title',
+ 'value' => $title,
+ ));
+
+ ?>
+ </label>
+ </p>
+ <p>
+ <label>
+ <?php echo elgg_echo('reportedcontent:address'); ?>
+ <?php
+
+ echo elgg_view('input/url',array(
+ 'internalname' => 'address',
+ 'value' => $address,
+ ));
+
+ ?>
+ </label>
+ </p>
+ <p class="longtext_editarea">
+ <label>
+ <?php echo elgg_echo('reportedcontent:description'); ?>
+ <br />
+ <?php
+
+ echo elgg_view('input/longtext',array(
+ 'internalname' => 'description',
+ 'value' => $description,
+ ));
+
+ ?>
+ </label>
+ </p>
+ <p>
+ <input type="submit" value="<?php echo elgg_echo('reportedcontent:report'); ?>" />
+ </p>
+
+ </form>
+</div>
diff --git a/mod/reportedcontent/views/default/reportedcontent/listing.php b/mod/reportedcontent/views/default/reportedcontent/listing.php
new file mode 100644
index 000000000..5d3d3d997
--- /dev/null
+++ b/mod/reportedcontent/views/default/reportedcontent/listing.php
@@ -0,0 +1,43 @@
+
+<?php
+
+ echo "<div class=\"contentWrapper\">";
+
+ if($vars['entity']){
+
+ foreach($vars['entity'] as $report){
+
+ //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=\"reportedcontent_content {$reportedcontent_background}\">";
+ echo "<p class=\"reportedcontent_detail\">";
+ if($report->state != 'archived') {
+ $url = elgg_add_action_tokens_to_url($vars['url'] . "action/reportedcontent/archive?item=" . $report->guid );
+ echo "<a class=\"archive_report_button\" href=\"$url\">" . elgg_echo('reportedcontent:archive') . "</a>";
+ }
+ $url = elgg_add_action_tokens_to_url($vars['url'] . "action/reportedcontent/delete?item=" . $report->guid);
+ echo "<a class=\"delete_report_button\" href=\"$url\" onclick=\"return confirm('" . elgg_echo('reportedcontent:areyousure') . "')\">" . elgg_echo('reportedcontent:delete') . "</a></p>";
+
+ echo "<p class=\"reportedcontent_detail\"><b>" . elgg_echo('reportedcontent:by') . ": </b><a href=\"{$user_url}\">" . $user . "</a>, " . friendly_time($report->time_created) . "</p>";
+ echo "<p class=\"reportedcontent_detail\"><b>" . elgg_echo('reportedcontent:objecttitle') . ": </b>" . $report->title . "</p>";
+ echo "<p class=\"reportedcontent_detail\"><b>" . elgg_echo('reportedcontent:objecturl') . ": </b><a href=\"{$report->address}\">" . elgg_echo('reportedcontent:visit') . "</a></p>";
+ echo "<p><a class=\"collapsibleboxlink\">" . elgg_echo('reportedcontent:moreinfo') . "</a></p>";
+ echo "<div class=\"collapsible_box\">";
+ echo "<p class=\"reportedcontent_detail\"><b>" . elgg_echo('reportedcontent:reason') . ": </b>" .$report->description . "</p>";
+ echo "</div></div>";
+
+
+ }
+
+ }
+ echo "</div>";
+?>
diff --git a/mod/reportedcontent/views/default/reportedcontent/owner_block.php b/mod/reportedcontent/views/default/reportedcontent/owner_block.php
new file mode 100644
index 000000000..3624a86d2
--- /dev/null
+++ b/mod/reportedcontent/views/default/reportedcontent/owner_block.php
@@ -0,0 +1,9 @@
+<?php
+
+$label = elgg_echo('reportedcontent:report');
+$url = "'" . $vars['url'] . "mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)";
+
+?>
+<div id="owner_block_report_this">
+<a href="javascript:location.href=<?php echo $url; ?>"><?php echo $label ?></a>
+</div>
diff --git a/mod/reportedcontent/views/default/reportedcontent/user_report.php b/mod/reportedcontent/views/default/reportedcontent/user_report.php
new file mode 100644
index 000000000..ee6c7cbf8
--- /dev/null
+++ b/mod/reportedcontent/views/default/reportedcontent/user_report.php
@@ -0,0 +1,6 @@
+
+<p class="user_menu_profile">
+<?php
+ echo "<a href=\"javascript:location.href='". $CONFIG->wwwroot . "mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">" . elgg_echo('reportedcontent:report') . "</a>";
+?>
+</p> \ No newline at end of file