From f1230a2c6b8bf0586447e4f9bad2089b7cc3b8bf Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 12 Aug 2008 21:25:57 +0000 Subject: report content added as a core plugin. Still needs a couple of bits wired up. git-svn-id: https://code.elgg.org/elgg/trunk@1867 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/reportedcontent/actions/add.php | 43 +++++++++++++ mod/reportedcontent/add.php | 36 +++++++++++ mod/reportedcontent/index.php | 29 +++++++++ mod/reportedcontent/languages/en.php | 37 +++++++++++ mod/reportedcontent/manifest.xml | 9 +++ mod/reportedcontent/start.php | 66 ++++++++++++++++++++ .../views/default/reportedcontent/form.php | 71 ++++++++++++++++++++++ .../views/default/reportedcontent/listing.php | 24 ++++++++ .../views/default/reportedcontent/user_report.php | 6 ++ 9 files changed, 321 insertions(+) create mode 100644 mod/reportedcontent/actions/add.php create mode 100644 mod/reportedcontent/add.php create mode 100644 mod/reportedcontent/index.php create mode 100644 mod/reportedcontent/languages/en.php create mode 100644 mod/reportedcontent/manifest.xml create mode 100644 mod/reportedcontent/start.php create mode 100644 mod/reportedcontent/views/default/reportedcontent/form.php create mode 100644 mod/reportedcontent/views/default/reportedcontent/listing.php create mode 100644 mod/reportedcontent/views/default/reportedcontent/user_report.php diff --git a/mod/reportedcontent/actions/add.php b/mod/reportedcontent/actions/add.php new file mode 100644 index 000000000..bfb5fcfb3 --- /dev/null +++ b/mod/reportedcontent/actions/add.php @@ -0,0 +1,43 @@ + + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + $title = get_input('title'); + $description = get_input('description'); + $address = get_input('address'); + $access = 0; //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()) { + system_message(elgg_echo('reportedcontent:success')); + 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/add.php b/mod/reportedcontent/add.php new file mode 100644 index 000000000..3fdca2e83 --- /dev/null +++ b/mod/reportedcontent/add.php @@ -0,0 +1,36 @@ + + * @copyright Curverider Ltd 2008 + * @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 + echo 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..3ce08e8b6 --- /dev/null +++ b/mod/reportedcontent/index.php @@ -0,0 +1,29 @@ + $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..83621afc4 --- /dev/null +++ b/mod/reportedcontent/languages/en.php @@ -0,0 +1,37 @@ + 'Reported content', + 'reportedcontent:this' => 'Report this', + 'reportedcontent:none' => 'There is no reported content', + 'reportedcontent:report' => 'Report to admin', + 'reportedcontent:title' => 'Page title', + 'reportedcontent:delete' => 'Delete it', + 'reportedcontent:archive' => 'Archive it', + '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', + + ); + + 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..43a10c072 --- /dev/null +++ b/mod/reportedcontent/manifest.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/mod/reportedcontent/start.php b/mod/reportedcontent/start.php new file mode 100644 index 000000000..e8c9614cd --- /dev/null +++ b/mod/reportedcontent/start.php @@ -0,0 +1,66 @@ +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"); + +?> \ No newline at end of file diff --git a/mod/reportedcontent/views/default/reportedcontent/form.php b/mod/reportedcontent/views/default/reportedcontent/form.php new file mode 100644 index 000000000..64a06bb63 --- /dev/null +++ b/mod/reportedcontent/views/default/reportedcontent/form.php @@ -0,0 +1,71 @@ + + * @copyright Curverider Ltd 2008 + * @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 = 0; + $shares = array(); + $owner = $vars['user']; + +?> + +
+ +

+ +

+

+ +

+

+ +

+

+ +

+ +
\ No newline at end of file diff --git a/mod/reportedcontent/views/default/reportedcontent/listing.php b/mod/reportedcontent/views/default/reportedcontent/listing.php new file mode 100644 index 000000000..1976d0946 --- /dev/null +++ b/mod/reportedcontent/views/default/reportedcontent/listing.php @@ -0,0 +1,24 @@ +owner_guid)->name; + $user_url = get_user($report->owner_guid)->getURL(); + + echo "
"; + echo "

" . elgg_echo('reportedcontent:by') . ": " . $user . ", " . friendly_time($report->time_created) . "

"; + echo "

" . elgg_echo('reportedcontent:objecttitle') . ": " . $report->title . "

"; + echo "

" . elgg_echo('reportedcontent:objecturl') . ": address}\">" . $report->address . "

"; + echo "

" . elgg_echo('reportedcontent:reason') . ": " .$report->description . "

"; + echo "

[" . elgg_echo('reportedcontent:archive') . "] - [" . elgg_echo('reportedcontent:delete') . "]

"; + echo elgg_view_comments($report); + echo "
"; + + } + + } + +?> \ 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 new file mode 100644 index 000000000..6077ca620 --- /dev/null +++ b/mod/reportedcontent/views/default/reportedcontent/user_report.php @@ -0,0 +1,6 @@ + +

+wwwroot . "mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">" . elgg_echo('reportedcontent:report') . ""; +?> +

\ No newline at end of file -- cgit v1.2.3