aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/notifications/actions/groupsave.php44
-rw-r--r--mod/notifications/actions/save.php4
-rw-r--r--mod/notifications/groups.php11
-rw-r--r--mod/notifications/languages/en.php5
-rw-r--r--mod/notifications/start.php6
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/collections.php57
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/groupsform.php9
7 files changed, 113 insertions, 23 deletions
diff --git a/mod/notifications/actions/groupsave.php b/mod/notifications/actions/groupsave.php
new file mode 100644
index 000000000..8a0ebd24b
--- /dev/null
+++ b/mod/notifications/actions/groupsave.php
@@ -0,0 +1,44 @@
+<?php
+
+ /**
+ * Elgg notifications group save
+ *
+ * @package ElggNotifications
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2009
+ * @link http://elgg.com/
+ */
+
+ // Restrict to logged in users
+ gatekeeper();
+
+ // Load important global vars
+ global $SESSION;
+ global $NOTIFICATION_HANDLERS;
+
+ // Get group memberships and condense them down to an array of guids
+ $groups = array();
+ if ($groupmemberships = get_entities_from_relationship('member',$_SESSION['user']->guid,false,'group','',0,'',9999)) {
+ foreach($groupmemberships as $groupmembership)
+ $groups[] = $groupmembership->guid;
+ }
+
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subscriptions[$method] = get_input($method.'subscriptions');
+ $personal[$method] = get_input($method.'personal');
+ $collections[$method] = get_input($method.'collections');
+ if (!empty($groups))
+ foreach($groups as $group)
+ if (in_array($group,$subscriptions[$method])) {
+ add_entity_relationship($SESSION['user']->guid,'notify'.$method,$group);
+ } else {
+ remove_entity_relationship($SESSION['user']->guid,'notify'.$method,$group);
+ }
+ }
+
+ system_message(elgg_echo('notifications:subscriptions:success'));
+
+ forward($_SERVER['HTTP_REFERER']);
+
+?> \ No newline at end of file
diff --git a/mod/notifications/actions/save.php b/mod/notifications/actions/save.php
index eba2ad8a3..6277de71a 100644
--- a/mod/notifications/actions/save.php
+++ b/mod/notifications/actions/save.php
@@ -1,9 +1,9 @@
<?php
/**
- * Elgg SMS Client
+ * Elgg notifications
*
- * @package ElggSMS
+ * @package ElggNotifications
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008-2009
diff --git a/mod/notifications/groups.php b/mod/notifications/groups.php
index 3223ec81d..733ba1d65 100644
--- a/mod/notifications/groups.php
+++ b/mod/notifications/groups.php
@@ -20,28 +20,23 @@
set_context('settings');
// Get the form
- global $SESSION;
+ global $SESSION, $CONFIG;
$people = array();
- if ($groups_ents = get_entities_from_relationship('notify',$SESSION['user']->guid,false,'group','',0,'',99999)) {
- foreach($groups_ents as $ent)
- $groups[] = $ent->guid;
- }
$groupmemberships = get_entities_from_relationship('member',$_SESSION['user']->guid,false,'group','',0,'',9999);
$body = elgg_view('input/form',array(
'body' => elgg_view('notifications/subscriptions/groupsform',array(
- 'groupsubs' => $groups,
'groups' => $groupmemberships
)),
'method' => 'post',
- 'action' => ''
+ 'action' => $CONFIG->wwwroot . 'action/notificationsettings/groupsave'
));
// Insert it into the correct canvas layout
$body = elgg_view_layout('two_column_left_sidebar','',$body);
// Draw the page
- echo page_draw(elgg_echo('notifications:subscriptions:groups'),$body);
+ echo page_draw(elgg_echo('notifications:subscriptions:changesettings:groups'),$body);
?> \ No newline at end of file
diff --git a/mod/notifications/languages/en.php b/mod/notifications/languages/en.php
index 5121d46f7..06de1599c 100644
--- a/mod/notifications/languages/en.php
+++ b/mod/notifications/languages/en.php
@@ -2,6 +2,8 @@
$english = array(
+ 'friends:all' => 'All friends',
+
'notifications:subscriptions:personal:description' => 'Receive notifications when actions are performed on your content',
'notifications:subscriptions:personal:title' => 'Personal notifications',
@@ -10,11 +12,14 @@
'notifications:subscriptions:collections:edit' => 'To edit your friends collections, click here.',
'notifications:subscriptions:changesettings' => 'Notifications',
+ 'notifications:subscriptions:changesettings:groups' => 'Group notifications',
'notification:method:email' => 'Email',
'notifications:subscriptions:title' => 'Notifications per user',
'notifications:subscriptions:description' => 'To receive notifications from your friends when they create new content, find them below and select the notification method you would like to use.',
+ 'notifications:subscriptions:groups:description' => 'To receive notifications when new content is added to a group you are a member of, find it below and select the notification method you would like to use.',
+
'notifications:subscriptions:success' => 'Your subscription settings have been saved.',
);
diff --git a/mod/notifications/start.php b/mod/notifications/start.php
index 1691872a6..cdbe78cc1 100644
--- a/mod/notifications/start.php
+++ b/mod/notifications/start.php
@@ -17,8 +17,11 @@
*/
function notifications_plugin_pagesetup() {
global $CONFIG;
- if (get_context() == 'settings')
+ if (get_context() == 'settings') {
add_submenu_item(elgg_echo('notifications:subscriptions:changesettings'), $CONFIG->wwwroot . "mod/notifications/");
+ if (is_plugin_enabled('groups'))
+ add_submenu_item(elgg_echo('notifications:subscriptions:changesettings:groups'), $CONFIG->wwwroot . "mod/notifications/groups.php");
+ }
}
function notifications_plugin_init() {
@@ -39,5 +42,6 @@
// Register action
global $CONFIG;
register_action("notificationsettings/save",false,$CONFIG->pluginspath . "notifications/actions/save.php");
+ register_action("notificationsettings/groupsave",false,$CONFIG->pluginspath . "notifications/actions/groupsave.php");
?> \ No newline at end of file
diff --git a/mod/notifications/views/default/notifications/subscriptions/collections.php b/mod/notifications/views/default/notifications/subscriptions/collections.php
index 8582069a8..41c3f76c8 100644
--- a/mod/notifications/views/default/notifications/subscriptions/collections.php
+++ b/mod/notifications/views/default/notifications/subscriptions/collections.php
@@ -1,8 +1,3 @@
-<?php
-
- if ($collections = get_user_access_collections($vars['user']->guid)) {
- global $NOTIFICATION_HANDLERS;
-?>
<script type="text/javascript">
@@ -44,7 +39,53 @@
<td>&nbsp;</td>
</tr>
<?php
+ global $NOTIFICATION_HANDLERS;
+ $members = array();
+ if ($friends = get_user_friends($vars['user']->guid,'',9999,0)) {
+ foreach($friends as $friend)
+ $members[] = $friend->guid;
+ }
+ $memberno = sizeof($members);
+ $members = implode(',',$members);
+
+?>
+ <tr>
+ <td class="namefield">
+ <p>
+ <?php echo elgg_echo('friends:all'); ?> (<?php echo $memberno; ?>)
+ </p>
+ </td>
+<?php
+
+ $fields = '';
+ $i = 0;
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ $metaname = 'collections_notifications_preferences_' . $method;
+ if ($collections_preferences = $vars['user']->$metaname) {
+ if (!empty($collections_preferences) && !is_array($collections_preferences))
+ $collections_preferences = array($collections_preferences);
+ if (is_array($collections_preferences))
+ if (in_array(0,$collections_preferences)) {
+ $collectionschecked[$method] = 'checked="checked"';
+ } else {
+ $collectionschecked[$method] = '';
+ }
+ }
+ if ($i > 0) $fields .= "<td class=\"spacercolumn\">&nbsp;</td>";
+ $fields .= <<< END
+ <td class="{$method}togglefield">
+ <a href="#" border="0" id="{$method}collections0" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections0'); setCollection([{$members}],'{$method}',0);">
+ <input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections0');" value="0" {$collectionschecked[$method]} /></a></td>
+END;
+ $i++;
+ }
+ echo $fields;
+
+?>
+ </tr>
+<?php
+ if ($collections = get_user_access_collections($vars['user']->guid)) {
foreach($collections as $collection) {
$members = get_members_of_access_collection($collection->id, true);
$memberno = sizeof($members);
@@ -92,12 +133,8 @@ END;
<?php
}
+}
?>
</table>
</div>
-<?php
-
- }
-
-?> \ No newline at end of file
diff --git a/mod/notifications/views/default/notifications/subscriptions/groupsform.php b/mod/notifications/views/default/notifications/subscriptions/groupsform.php
index 5c0ee1057..56d90c6d1 100644
--- a/mod/notifications/views/default/notifications/subscriptions/groupsform.php
+++ b/mod/notifications/views/default/notifications/subscriptions/groupsform.php
@@ -3,6 +3,11 @@
global $NOTIFICATION_HANDLERS;
foreach($NOTIFICATION_HANDLERS as $method => $foo) {
$subsbig[$method] = get_entities_from_relationship('notify' . $method,$vars['user']->guid,false,'group','',0,'',99999);
+ $tmparray = array();
+ foreach($subsbig[$method] as $tmpent) {
+ $tmparray[] = $tmpent->guid;
+ }
+ $subsbig[$method] = $tmparray;
}
?>
@@ -13,7 +18,7 @@
<?php
echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
?>
- <?php echo elgg_view_title(elgg_echo('notifications:subscriptions:groups')); ?>
+ <?php echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings:groups')); ?>
<p>
<?php
@@ -50,7 +55,7 @@
$i = 0;
foreach($NOTIFICATION_HANDLERS as $method => $foo) {
- if (in_array($group->guid,$subs[$method])) {
+ if (in_array($group->guid,$subsbig[$method])) {
$checked[$method] = 'checked="checked"';
} else {
$checked[$method] = '';