aboutsummaryrefslogtreecommitdiff
path: root/mod/river_privacy
diff options
context:
space:
mode:
Diffstat (limited to 'mod/river_privacy')
-rw-r--r--mod/river_privacy/CHANGES.txt7
-rw-r--r--mod/river_privacy/README.md4
-rw-r--r--mod/river_privacy/languages/ca.php7
-rw-r--r--mod/river_privacy/languages/en.php13
-rw-r--r--mod/river_privacy/manifest.xml17
-rw-r--r--mod/river_privacy/start.php30
-rw-r--r--mod/river_privacy/views/default/plugins/river_privacy/settings.php17
-rw-r--r--mod/river_privacy/views_override/default/page/components/list.php89
8 files changed, 184 insertions, 0 deletions
diff --git a/mod/river_privacy/CHANGES.txt b/mod/river_privacy/CHANGES.txt
new file mode 100644
index 000000000..df26e881d
--- /dev/null
+++ b/mod/river_privacy/CHANGES.txt
@@ -0,0 +1,7 @@
+== Version History ==
+
+x.x:
+
+1.0 (05/19/2012):
+
+- Initial Release \ No newline at end of file
diff --git a/mod/river_privacy/README.md b/mod/river_privacy/README.md
new file mode 100644
index 000000000..7e20e27bd
--- /dev/null
+++ b/mod/river_privacy/README.md
@@ -0,0 +1,4 @@
+River-Privacy-1.8.x
+===================
+
+Makes non-object oriented river items private - eg. friendship creation \ No newline at end of file
diff --git a/mod/river_privacy/languages/ca.php b/mod/river_privacy/languages/ca.php
new file mode 100644
index 000000000..50f508e75
--- /dev/null
+++ b/mod/river_privacy/languages/ca.php
@@ -0,0 +1,7 @@
+<?php
+$language = array (
+ 'river_privacy' => 'Privacitat de l\'activitat',
+ 'river_privacy:hide_old:description' => 'Només els objectes que es creen després de l\'activació d\'aquesta extensió seran privats. Aquesta opció pot permetre els antics objectes d\'ocultar-se - això funciona en el moment de mostrar-los, i pot afectar a la visualització (per exemple, s\'espera mostrar 20 elements, però només 15 són visibles perquè 5 d\'ells els filtra aquesta extensió)',
+ 'river_privacy:hide_old:label' => 'Ocultar activitat antiga?',
+);
+add_translation("ca", $language); \ No newline at end of file
diff --git a/mod/river_privacy/languages/en.php b/mod/river_privacy/languages/en.php
new file mode 100644
index 000000000..f0cfde2a1
--- /dev/null
+++ b/mod/river_privacy/languages/en.php
@@ -0,0 +1,13 @@
+<?php
+
+$english = array(
+ 'river_privacy' => "River Privacy",
+ 'river_privacy:hide_old:description' => "Only items that are created after this plugin is enabled
+ will be set to private. This setting can allow old items to be hidden - this is done at
+ display time, so it may affect layout (eg. 20 items are expected to be shown, but only 15 are
+ visible because 5 of them are filtered out by this plugin).
+ Note that new items created will be private regardless of this setting, this setting is only for old items.",
+ 'river_privacy:hide_old:label' => "Hide old river entries?",
+);
+
+add_translation("en",$english);
diff --git a/mod/river_privacy/manifest.xml b/mod/river_privacy/manifest.xml
new file mode 100644
index 000000000..dbd08da35
--- /dev/null
+++ b/mod/river_privacy/manifest.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>River Privacy</name>
+ <author>Matt Beckett (matt@clever-name.com)</author>
+ <version>1.8.0</version>
+ <description>Sets non-object oriented river items to private access (eg. friend relationships)</description>
+ <website>http://landing.athabascau.ca</website>
+ <copyright>(C) Matt Beckett, 2012</copyright>
+ <license>GNU Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+
+ <category>privacy</category>
+ <activate_on_install>true</activate_on_install>
+</plugin_manifest>
diff --git a/mod/river_privacy/start.php b/mod/river_privacy/start.php
new file mode 100644
index 000000000..b836ded52
--- /dev/null
+++ b/mod/river_privacy/start.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * River Privacy
+ * Makes non-object oriented river entries private
+ * eg. friendships
+ */
+
+function river_privacy_init(){
+ if(elgg_get_plugin_setting('hide_old_items', 'river_privacy') != 'no'){
+ elgg_set_view_location('page/components/list', elgg_get_plugins_path() . 'river_privacy/views_override/');
+ }
+
+ // set the river item to private if it's not an object
+ elgg_register_plugin_hook_handler('creating', 'river', 'river_privacy_creating_river');
+}
+
+
+//
+// hook called before river creation
+// return associative array of parameters to create the river entry
+function river_privacy_creating_river($hook, $type, $returnvalue, $params){
+ if($returnvalue['type'] != 'object'){
+ $returnvalue['access_id'] = ACCESS_PRIVATE;
+ }
+
+ return $returnvalue;
+}
+
+elgg_register_event_handler('init', 'system', 'river_privacy_init'); \ No newline at end of file
diff --git a/mod/river_privacy/views/default/plugins/river_privacy/settings.php b/mod/river_privacy/views/default/plugins/river_privacy/settings.php
new file mode 100644
index 000000000..661416261
--- /dev/null
+++ b/mod/river_privacy/views/default/plugins/river_privacy/settings.php
@@ -0,0 +1,17 @@
+<?php
+
+$options = array(
+ 'name' => 'params[hide_old_items]',
+ 'value' => $vars['entity']->hide_old_items ? $vars['entity']->hide_old_items : 'yes',
+ 'options_values' => array(
+ 'yes' => elgg_echo('option:yes'),
+ 'no' => elgg_echo('option:no'),
+ ),
+);
+
+echo elgg_echo('river_privacy:hide_old:label') . "<br>";
+echo elgg_view('input/dropdown', $options);
+
+echo "<br><br>" . elgg_echo('river_privacy:hide_old:description');
+
+echo "<br><br>"; \ No newline at end of file
diff --git a/mod/river_privacy/views_override/default/page/components/list.php b/mod/river_privacy/views_override/default/page/components/list.php
new file mode 100644
index 000000000..b5a78406d
--- /dev/null
+++ b/mod/river_privacy/views_override/default/page/components/list.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * View a list of items
+ *
+ * @package Elgg
+ *
+ * @uses $vars['items'] Array of ElggEntity or ElggAnnotation objects
+ * @uses $vars['offset'] Index of the first list item in complete list
+ * @uses $vars['limit'] Number of items per page
+ * @uses $vars['count'] Number of items in the complete list
+ * @uses $vars['base_url'] Base URL of list (optional)
+ * @uses $vars['pagination'] Show pagination? (default: true)
+ * @uses $vars['position'] Position of the pagination: before, after, or both
+ * @uses $vars['full_view'] Show the full view of the items (default: false)
+ * @uses $vars['list_class'] Additional CSS class for the <ul> element
+ * @uses $vars['item_class'] Additional CSS class for the <li> elements
+ */
+
+$items = $vars['items'];
+$offset = elgg_extract('offset', $vars);
+$limit = elgg_extract('limit', $vars);
+$count = elgg_extract('count', $vars);
+$base_url = elgg_extract('base_url', $vars, '');
+$pagination = elgg_extract('pagination', $vars, true);
+$offset_key = elgg_extract('offset_key', $vars, 'offset');
+$position = elgg_extract('position', $vars, 'after');
+
+// remove non-object items for anyone who's not the subject
+if(is_array($items) && ($items[0] instanceof ElggRiverItem)){
+ foreach($items as $key => $item){
+ if($item->type != 'object' && $item->subject_guid != elgg_get_logged_in_user_guid()){
+ unset($items[$key]);
+ }
+ }
+}
+
+// reset key values
+if ($items)
+ $items = array_merge(array(), $items);
+else
+ $items = array();
+
+$list_class = 'elgg-list';
+if (isset($vars['list_class'])) {
+ $list_class = "$list_class {$vars['list_class']}";
+}
+
+$item_class = 'elgg-item';
+if (isset($vars['item_class'])) {
+ $item_class = "$item_class {$vars['item_class']}";
+}
+
+$html = "";
+$nav = "";
+
+if ($pagination && $count) {
+ $nav .= elgg_view('navigation/pagination', array(
+ 'base_url' => $base_url,
+ 'offset' => $offset,
+ 'count' => $count,
+ 'limit' => $limit,
+ 'offset_key' => $offset_key,
+ ));
+}
+
+if (is_array($items) && count($items) > 0) {
+ $html .= "<ul class=\"$list_class\">";
+ foreach ($items as $item) {
+ if (elgg_instanceof($item)) {
+ $id = "elgg-{$item->getType()}-{$item->getGUID()}";
+ } else {
+ $id = "item-{$item->getType()}-{$item->id}";
+ }
+ $html .= "<li id=\"$id\" class=\"$item_class\">";
+ $html .= elgg_view_list_item($item, $vars);
+ $html .= '</li>';
+ }
+ $html .= '</ul>';
+}
+
+if ($position == 'before' || $position == 'both') {
+ $html = $nav . $html;
+}
+
+if ($position == 'after' || $position == 'both') {
+ $html .= $nav;
+}
+
+echo $html;