]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
merged in notifications plugin cleanup from 1.7 branch: [5962], [5978] - [5980],...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 13 May 2010 01:11:33 +0000 (01:11 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 13 May 2010 01:11:33 +0000 (01:11 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6020 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/notifications/actions/groupsave.php
mod/notifications/actions/save.php
mod/notifications/groups.php
mod/notifications/index.php
mod/notifications/languages/en.php
mod/notifications/start.php
mod/notifications/views/default/notifications/subscriptions/collections.php
mod/notifications/views/default/notifications/subscriptions/form.php
mod/notifications/views/default/notifications/subscriptions/groupsform.php
mod/notifications/views/default/notifications/subscriptions/jsfuncs.php
mod/notifications/views/default/notifications/subscriptions/personal.php

index ca250c7fd590bcef6d3e75e53af41db48e97e709..84154930ef19648508da179d571b45e0ea522229 100644 (file)
@@ -1,44 +1,41 @@
 <?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-2010
       * @link http://elgg.com/
       */
+/**
+ * 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-2010
+ * @link http://elgg.com/
+ */
 
-       // Restrict to logged in users
-               gatekeeper();
-               
-       // Load important global vars
-               global $SESSION;
-               global $NOTIFICATION_HANDLERS;
+// Load important global vars
+global $NOTIFICATION_HANDLERS;
 
-       // Get group memberships and condense them down to an array of guids
-               $groups = array();
-               if ($groupmemberships = elgg_get_entities_from_relationship(array('relationship' => 'member', 'relationship_guid' => $_SESSION['user']->guid, 'types' => 'group', 'limit' => 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);
-                                       }
+// Get group memberships and condense them down to an array of guids
+$groups = array();
+if ($groupmemberships = elgg_get_entities_from_relationship(array('relationship' => 'member', 'relationship_guid' => get_loggedin_userid(), 'types' => 'group', 'limit' => 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(get_loggedin_userid(), 'notify'.$method, $group);
+                       } else {
+                               remove_entity_relationship(get_loggedin_userid(), 'notify'.$method, $group);
+                       }
                }
-                               
-               system_message(elgg_echo('notifications:subscriptions:success'));
-               
-               forward($_SERVER['HTTP_REFERER']);
+       }
+}
+
+system_message(elgg_echo('notifications:subscriptions:success'));
 
-?>
\ No newline at end of file
+forward($_SERVER['HTTP_REFERER']);
index a4a5903f977691c05793402bc84b58fc5e48a0bf..f8b533d2348216e383d6d2945c0e68b44181f756 100644 (file)
@@ -1,42 +1,38 @@
 <?php
 
-       /**
       * Elgg notifications
-        * 
       * @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-2010
       * @link http://elgg.com/
       */
+/**
+ * Elgg notifications
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
 
-       // Restrict to logged in users
-               gatekeeper();
-               
-               global $SESSION;
-               
-               global $NOTIFICATION_HANDLERS;
-               foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-                       $subscriptions[$method] = get_input($method.'subscriptions');
-                       $personal[$method] = get_input($method.'personal');
-                       $collections[$method] = get_input($method.'collections');
-                       
-                       $metaname = 'collections_notifications_preferences_' . $method;
-                       $_SESSION['user']->$metaname = $collections[$method];
-                       set_user_notification_setting($_SESSION['user']->guid, $method, ($personal[$method] == '1') ? true : false);
-                       remove_entity_relationships($SESSION['user']->guid,'notify' . $method, false, 'user');
-               }
-               
-       // Add new ones
-               foreach($subscriptions as $key => $subscription)
-               if (is_array($subscription) && !empty($subscription)) {
-                       foreach($subscription as $subscriptionperson) {
-                               add_entity_relationship($_SESSION['user']->guid, 'notify' . $key, $subscriptionperson);
-                       }
+$user = get_loggedin_user();
+
+global $NOTIFICATION_HANDLERS;
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+       $subscriptions[$method] = get_input($method.'subscriptions');
+       $personal[$method] = get_input($method.'personal');
+       $collections[$method] = get_input($method.'collections');
+
+       $metaname = 'collections_notifications_preferences_' . $method;
+       $user->$metaname = $collections[$method];
+       set_user_notification_setting($user->guid, $method, ($personal[$method] == '1') ? true : false);
+       remove_entity_relationships($user->guid, 'notify' . $method, false, 'user');
+}
+
+// Add new ones
+foreach($subscriptions as $key => $subscription) {
+       if (is_array($subscription) && !empty($subscription)) {
+               foreach($subscription as $subscriptionperson) {
+                       add_entity_relationship($user->guid, 'notify' . $key, $subscriptionperson);
                }
-               
-               system_message(elgg_echo('notifications:subscriptions:success'));
-               
-               forward($_SERVER['HTTP_REFERER']);
+       }
+}
+
+system_message(elgg_echo('notifications:subscriptions:success'));
 
-?>
\ No newline at end of file
+forward($_SERVER['HTTP_REFERER']);
index c742f858daeea615b5a8b1a8ace351d682e3e808..d6de578327ddee96949f51477fe32e9face7291c 100644 (file)
@@ -1,42 +1,40 @@
 <?php
 
-       /**
-        * Elgg notifications plugin group index
-        * 
-        * @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-2010
-        * @link http://elgg.com/
-        */
-
-       // Load Elgg framework
-               require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
-               
-       // Ensure only logged-in users can see this page
-               gatekeeper();
-               
-       // Set the context to settings
-               set_context('settings');
-               
-       // Get the form
-               global $SESSION, $CONFIG;
-               $people = array();
-               
-               $groupmemberships = elgg_get_entities_from_relationship(array('relationship' => 'member', 'relationship_guid' => $_SESSION['user']->guid, 'types' => 'group', 'limit' => 9999));
-               
-               $body = elgg_view('input/form',array(
-                       'body' => elgg_view('notifications/subscriptions/groupsform',array(
-                                                       'groups' => $groupmemberships
-                                               )),
-                       'method' => 'post',
-                       'action' => $CONFIG->wwwroot . 'action/notificationsettings/groupsave'
-               ));
-               
-       // Insert it into the correct canvas layout
-               $body = elgg_view_layout('one_column_with_sidebar', $body);
-               
-       // Draw the page
-               page_draw(elgg_echo('notifications:subscriptions:changesettings:groups'),$body);
-               
-?>
\ No newline at end of file
+/**
+ * Elgg notifications plugin group index
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
+
+// Load Elgg framework
+require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
+
+// Ensure only logged-in users can see this page
+gatekeeper();
+
+set_page_owner(get_loggedin_userid());
+
+// Set the context to settings
+set_context('settings');
+
+// Get the form
+$people = array();
+
+$groupmemberships = elgg_get_entities_from_relationship(array('relationship' => 'member', 'relationship_guid' => get_loggedin_userid(), 'types' => 'group', 'limit' => 9999));
+
+$form_body = elgg_view('notifications/subscriptions/groupsform',array('groups' => $groupmemberships));
+$body = elgg_view('input/form',array(
+               'body' => $form_body,
+               'method' => 'post',
+               'action' => $CONFIG->wwwroot . 'action/notificationsettings/groupsave'
+));
+
+// Insert it into the correct canvas layout
+$body = elgg_view_layout('one_column_with_sidebar', $body);
+
+
+page_draw(elgg_echo('notifications:subscriptions:changesettings:groups'), $body);
index 47e4baad99d995379b472511111d1e5a80ca69fb..93741d76e1e2dec4e3b8af360c6cbaf400cbfc97 100644 (file)
@@ -1,39 +1,38 @@
 <?php
 
-       /**
-        * Elgg notifications plugin index
-        * 
-        * @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-2010
-        * @link http://elgg.com/
-        */
-
-       // Load Elgg framework
-               require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
-               
-       // Ensure only logged-in users can see this page
-               gatekeeper();
-               
-       // Set the context to settings
-               set_context('settings');
-               
-       // Get the form
-               global $SESSION;
-               $people = array();
-               if ($people_ents = elgg_get_entities_from_relationship(array('relationship' => 'notify', 'relationship_guid' => $SESSION['user']->guid, 'types' => 'user', 'limit' => 99999))) {
-                       foreach($people_ents as $ent)
-                               $people[] = $ent->guid;
-               }
-               $body = elgg_view('notifications/subscriptions/form',array(
-                                                       'people' => $people
-                                               ));
-               
-       // Insert it into the correct canvas layout
-               $body = elgg_view_layout('one_column_with_sidebar', $body);
-               
-       // Draw the page
-               page_draw(elgg_echo('notifications:subscriptions:changesettings'),$body);
-               
-?>
\ No newline at end of file
+/**
+ * Elgg notifications plugin index
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
+
+// Load Elgg framework
+require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
+
+// Ensure only logged-in users can see this page
+gatekeeper();
+
+set_page_owner(get_loggedin_userid());
+
+// Set the context to settings
+set_context('settings');
+
+// Get the form
+$people = array();
+if ($people_ents = elgg_get_entities_from_relationship(array('relationship' => 'notify', 'relationship_guid' => get_loggedin_userid(), 'types' => 'user', 'limit' => 99999))) {
+       foreach($people_ents as $ent) {
+               $people[] = $ent->guid;
+       }
+}
+
+$body = elgg_view('notifications/subscriptions/form', array('people' => $people));
+
+// Insert it into the correct canvas layout
+$body = elgg_view_layout('one_column_with_sidebar', $body);
+
+
+page_draw(elgg_echo('notifications:subscriptions:changesettings'), $body);
index 8573bbb3208c1388179e6aa418e14c02599b2986..a82013d234b2fd5c4163ff2b52adb6b3bf286f96 100644 (file)
@@ -1,29 +1,27 @@
 <?php
 
-       $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',
-       
-               'notifications:subscriptions:collections:title' => 'Friends',
-               'notifications:subscriptions:collections:description' => 'The following is an automatic collection made up of your friends. To receive updates select below. This will affect the corresponding users in the main notification settings panel at the bottom of the page. ',
-               'notifications:subscriptions:collections:edit' => 'To edit your shared access notifications, 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 (on an individual basis) 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(s) you would like to use.',
-       
-               'notifications:subscriptions:success' => 'Your notifications settings have been saved.',
-       
-       );
-                                       
-       add_translation("en",$english);
-
-?>
\ No newline at end of file
+$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',
+
+       'notifications:subscriptions:collections:title' => 'Friends',
+       'notifications:subscriptions:collections:description' => 'The following is an automatic collection made up of your friends. To receive updates select below. This will affect the corresponding users in the main notification settings panel at the bottom of the page. ',
+       'notifications:subscriptions:collections:edit' => 'To edit your shared access notifications, 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 (on an individual basis) 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(s) you would like to use.',
+
+       'notifications:subscriptions:success' => 'Your notifications settings have been saved.',
+
+);
+
+       add_translation("en", $english);
index a08fe68f58ef88cbfd39453e0ae33a1c418896c9..838a123fb5703184f1531150bf0eec57e385d731 100644 (file)
@@ -1,47 +1,75 @@
 <?php
 
-       /**
-        * Elgg notifications plugin
-        * 
-        * @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-2010
-        * @link http://elgg.com/
-        */
-
-
-       /**
-        * Notification settings page setup function
-        *
-        */
-               function notifications_plugin_pagesetup() {
-                       global $CONFIG;
-                       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() {
-                       elgg_extend_view('css','notifications/css');
-                       global $CONFIG;
-                       
-                       // Unset the default user settings hook
-                       if (isset($CONFIG->hooks['usersettings:save']['user']))
-                               foreach($CONFIG->hooks['usersettings:save']['user'] as $key => $function) {
-                                       if ($function == 'notification_user_settings_save')
-                                               unset($CONFIG->hooks['usersettings:save']['user'][$key]); 
-                               }
+/**
+ * Elgg notifications plugin
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
+
+
+function notifications_plugin_init() {
+       global $CONFIG;
+
+       elgg_extend_view('css','notifications/css');
+
+       register_page_handler('notifications', 'notifications_page_handler');
+
+       register_elgg_event_handler('pagesetup', 'system', 'notifications_plugin_pagesetup');
+
+       // Unset the default notification settings
+       unregister_plugin_hook('usersettings:save', 'user', 'notification_user_settings_save');
+       
+       // must wait until elgg_unextend_view() is merged in from 1.7 branch - if still needed
+       //elgg_unextend_view('usersettings/user', 'notifications/settings/usersettings');
+}
+
+/**
+ * Route page requests
+ *
+ * @param array $page Array of url parameters
+ */
+function notifications_page_handler($page) {
+       global $CONFIG;
+
+       // default to personal notifications
+       if (!isset($page[0])) {
+               $page[0] = 'personal';
+       }
+
+       switch ($page[0]) {
+               case 'group':
+                       require $CONFIG->pluginspath . "notifications/groups.php";
+                       break;
+               case 'personal':
+               default:
+                       require $CONFIG->pluginspath . "notifications/index.php";
+                       break;
+       }
+
+       return TRUE;
+}
+
+/**
+ * Notification settings page setup function
+ *
+ */
+function notifications_plugin_pagesetup() {
+       global $CONFIG;
+       if (get_context() == 'settings') {
+               add_submenu_item(elgg_echo('notifications:subscriptions:changesettings'), $CONFIG->wwwroot . "pg/notifications/personal");
+               if (is_plugin_enabled('groups')) {
+                       add_submenu_item(elgg_echo('notifications:subscriptions:changesettings:groups'), $CONFIG->wwwroot . "pg/notifications/group");
                }
+       }
+}
+
 
-               register_elgg_event_handler('pagesetup','system','notifications_plugin_pagesetup',1000);
-               register_elgg_event_handler('init','system','notifications_plugin_init',1000);
+register_elgg_event_handler('init', 'system', 'notifications_plugin_init', 1000);
 
-       // 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
+// Register action
+register_action("notificationsettings/save", FALSE, $CONFIG->pluginspath . "notifications/actions/save.php");
+register_action("notificationsettings/groupsave", FALSE, $CONFIG->pluginspath . "notifications/actions/groupsave.php");
index 87906bf767ba5e684a32a4e39afd625f539e39bd..d89dddb7b2d90c82d5c0cd4fe3aebb2345816710 100644 (file)
@@ -5,10 +5,10 @@
                for ( var i in members ) {
                        var checked = $('#' + method + 'collections' + id).children("INPUT[type='checkbox']").attr('checked');
                        if ($("#"+method+members[i]).children("INPUT[type='checkbox']").attr('checked') != checked) {  
-                       $("#"+method+members[i]).children("INPUT[type='checkbox']").attr('checked', checked);
-                       functioncall = 'adjust' + method + '_alt("'+method+members[i]+'");';
-                       eval(functioncall);
-               }
+                               $("#"+method+members[i]).children("INPUT[type='checkbox']").attr('checked', checked);
+                               functioncall = 'adjust' + method + '_alt("'+method+members[i]+'");';
+                               eval(functioncall);
+                       }
                } 
        }
        
        <?php echo elgg_echo('notifications:subscriptions:collections:description'); ?>
 </p>
 <table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%">
-  <tr>
-    <td>&nbsp;</td>
+       <tr>
+               <td>&nbsp;</td>
 <?php
        $i = 0; 
        global $NOTIFICATION_HANDLERS;
        foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-               if ($i > 0)
+               if ($i > 0) {
                        echo "<td class='spacercolumn'>&nbsp;</td>";
+               }
 ?>
        <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td>
 <?php
                $i++;
        }
 ?>
-    <td>&nbsp;</td>
-  </tr>
+               <td>&nbsp;</td>
+       </tr>
 <?php
-               $members = array();
-               if ($friends = get_user_friends($vars['user']->guid,'',9999,0)) {
-                       foreach($friends as $friend)
-                               $members[] = $friend->guid;
+       $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);
+       }
+       $memberno = sizeof($members);
+       $members = implode(',',$members);
 
 ?>
-  <tr>
-    <td class="namefield">
-       <p>
-               <?php echo elgg_echo('friends:all'); ?> (<?php echo $memberno; ?>)
-       </p>
-    </td>
+       <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))
+       $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(-1,$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 border="0" id="{$method}collections-1" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections-1'); setCollection([{$members}],'{$method}',-1);">
-                           <input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections-1');" value="-1" {$collectionschecked[$method]} /></a></td>
-END;
-                       $i++;
                }
-               echo $fields;
+               if ($i > 0) {
+                       $fields .= "<td class='spacercolumn'>&nbsp;</td>";
+               }
+               $fields .= <<< END
+                       <td class="{$method}togglefield">
+                       <a border="0" id="{$method}collections-1" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections-1'); setCollection([{$members}],'{$method}',-1);">
+                       <input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections-1');" value="-1" {$collectionschecked[$method]} /></a></td>
+END;
+               $i++;
+       }
+       echo $fields;
 
 ?>
-       <td>&nbsp;</td>
-  </tr>
+               <td>&nbsp;</td>
+       </tr>
 <?php
 /*
        @todo
        collections removed from notifications - they are no longer used and will be replaced with shared access collections
        
        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);
-               $members = implode(',',$members);
+               foreach($collections as $collection) {
+                       $members = get_members_of_access_collection($collection->id, true);
+                       $memberno = sizeof($members);
+                       $members = implode(',', $members);
 
 ?>
-  <tr>
-    <td class="namefield">
-       <p>
-               <?php echo $collection->name; ?> (<?php echo $memberno; ?>)
-       </p>
-       
-    </td>
-    
+       <tr>
+               <td class="namefield">
+                       <p>
+                               <?php echo $collection->name; ?> (<?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($collection->id,$collections_preferences)) {
-                                       $collectionschecked[$method] = 'checked="checked"';
-                               } else {
-                                       $collectionschecked[$method] = '';
+                       $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($collection->id,$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 border="0" id="{$method}collections{$collection->id}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections{$collection->id}'); setCollection([{$members}],'{$method}',{$collection->id});">
-                           <input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections{$collection->id}');" value="{$collection->id}" {$collectionschecked[$method]} /></a></td>
+                               if ($i > 0) {
+                                       $fields .= "<td class='spacercolumn'>&nbsp;</td>";
+                               }
+                               $fields .= <<< END
+                                       <td class="{$method}togglefield">
+                                       <a border="0" id="{$method}collections{$collection->id}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}collections{$collection->id}'); setCollection([{$members}],'{$method}',{$collection->id});">
+                                       <input type="checkbox" name="{$method}collections[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}collections{$collection->id}');" value="{$collection->id}" {$collectionschecked[$method]} /></a></td>
 END;
-                       $i++;
-               }
-               echo $fields;
+                               $i++;
+                       }
+                       echo $fields;
 
 ?>
-  
-    <td>&nbsp;</td>
-  </tr>
+
+               <td>&nbsp;</td>
+       </tr>
 <?php
 
+               }
        }
-}
 
 */
 ?>
index 8ad0110bf0b883f4be62b443c034675fddbefc06..d4f243e20dcfb0df9efc8c0caaa1435bc9fdb63a 100644 (file)
@@ -1,33 +1,34 @@
 <?php
 
-       /**
       * Elgg SMS Client
       
       * @package ElggSMS
       * @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/
       */
+/**
+ * Elgg SMS Client
+ * 
+ * @package ElggSMS
+ * @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/
+ */
 
 
-       // Echo title
-               echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings'));
-               
-               echo elgg_view('subscriptions/form/additions',$vars);
-               
-       // Display a description
+// Echo title
+       echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings'));
+       
+       echo elgg_view('subscriptions/form/additions',$vars);
+       
+// Display a description
 ?>
 <div class="user_settings notifications">
 <?php
 
-       echo elgg_view('input/form',array(
-                       'body' =>       elgg_view('notifications/subscriptions/personal') .
-                                               elgg_view('notifications/subscriptions/collections') .
-                                               elgg_view('notifications/subscriptions/forminternals'),
-                       'method' => 'post',
-                       'action' => $vars['url'] . 'action/notificationsettings/save',
-               ));
+
+echo elgg_view('input/form',array(
+               'body' =>       elgg_view('notifications/subscriptions/personal') .
+                                       elgg_view('notifications/subscriptions/collections') .
+                                       elgg_view('notifications/subscriptions/forminternals'),
+               'method' => 'post',
+               'action' => $vars['url'] . 'action/notificationsettings/save',
+       ));
 
 ?>
 </div>
index fa002b9daba2d2e34b83d0a3a1e85d794901f07c..edb9c587c99bfdadb628c1e31f75fb4ef339b4fc 100644 (file)
 <?php
+/**
+ * Elgg notifications groups subscription form
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
 
-       global $NOTIFICATION_HANDLERS;
-       foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-               $subsbig[$method] = elgg_get_entities_from_relationship(array('relationship' => 'notify' . $method, 'relationship_guid' => $vars['user']->guid, 'types' => 'group', 'limit' => 99999));
-               $tmparray = array();
-               if ($subsbig[$method]) {
-                       foreach($subsbig[$method] as $tmpent) {
-                               $tmparray[] = $tmpent->guid;
-                       }
+global $NOTIFICATION_HANDLERS;
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+       $subsbig[$method] = elgg_get_entities_from_relationship(array('relationship' => 'notify' . $method, 'relationship_guid' => $vars['user']->guid, 'types' => 'group', 'limit' => 99999));
+       $tmparray = array();
+       if ($subsbig[$method]) {
+               foreach($subsbig[$method] as $tmpent) {
+                       $tmparray[] = $tmpent->guid;
                }
-               $subsbig[$method] = $tmparray;
        }
+       $subsbig[$method] = $tmparray;
+}
+
+echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings:groups'));
+?>
 
-echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings:groups')); ?>
 <div class="user_settings margin_top">
+
+       <?php
+               echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
+       ?>
+       
+       <p>
                <?php
-                       echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
-               ?>
-               
-               <p>
-                       <?php
 
-                               echo elgg_echo('notifications:subscriptions:groups:description');
-                       
-                       ?>
-               </p>
+                       echo elgg_echo('notifications:subscriptions:groups:description');
+               
+               ?>
+       </p>
 <?php
 
-               if (isset($vars['groups']) && !empty($vars['groups'])) {
-                       
+if (isset($vars['groups']) && !empty($vars['groups'])) {
+
 ?>
-<table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%">
-  <tr>
-    <td>&nbsp;</td>
+       <table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%">
+               <tr>
+                       <td>&nbsp;</td>
 <?php
-       global $NOTIFICATION_HANDLERS;
+
        $i = 0; 
        foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-               if ($i > 0)
+               if ($i > 0) {
                        echo "<td class='spacercolumn'>&nbsp;</td>";
+               }
 ?>
-       <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td>
+                       <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td>
 <?php
                $i++;
        }
 ?>
-    <td>&nbsp;</td>
-  </tr>
-<?php  
-                       foreach($vars['groups'] as $group) {
-                               
-                               $fields = '';
-                               $i = 0;
-                               
-                               foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-                                       if (in_array($group->guid,$subsbig[$method])) {
-                                               $checked[$method] = 'checked="checked"';
-                                       } else {
-                                               $checked[$method] = '';
-                                       }
-                                       if ($i > 0) $fields .= "<td class=\"spacercolumn\">&nbsp;</td>";
-                                       $fields .= <<< END
-                                           <td class="{$method}togglefield">
-                                           <a border="0" id="{$method}{$group->guid}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}{$group->guid}');">
-                                           <input type="checkbox" name="{$method}subscriptions[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}{$group->guid}');" value="{$group->guid}" {$checked[$method]} /></a></td>
+                       <td>&nbsp;</td>
+               </tr>
+<?php
+       foreach($vars['groups'] as $group) {
+               
+               $fields = '';
+               $i = 0;
+               
+               foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+                       if (in_array($group->guid,$subsbig[$method])) {
+                               $checked[$method] = 'checked="checked"';
+                       } else {
+                               $checked[$method] = '';
+                       }
+                       if ($i > 0) {
+                               $fields .= "<td class=\"spacercolumn\">&nbsp;</td>";
+                       }
+                       $fields .= <<< END
+                               <td class="{$method}togglefield">
+                               <a border="0" id="{$method}{$group->guid}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}{$group->guid}');">
+                               <input type="checkbox" name="{$method}subscriptions[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}{$group->guid}');" value="{$group->guid}" {$checked[$method]} /></a></td>
 END;
-                                       $i++;
-                               }
-                               
+                       $i++;
+               }
+       
 ?>
-       <tr>
-               <td class="namefield">
-               <p>
-                       <?php echo $group->name; ?>
-               </p>
-           </td>
+               <tr>
+                       <td class="namefield">
+                               <p>
+                                       <?php echo $group->name; ?>
+                               </p>
+                       </td>
 <?php
-                               echo $fields;
+               echo $fields;
 ?>
-               <td>&nbsp;</td>
-       </tr>
+                       <td>&nbsp;</td>
+               </tr>
 <?php
-       
-                               
-                       }
+       }
 ?>
-</table>
+       </table>
 <?php
-               }
-
+}
 ?>
-
-               <input type="submit" value="<?php echo elgg_echo('save'); ?>" />
-</div>
\ No newline at end of file
+       <input type="submit" value="<?php echo elgg_echo('save'); ?>" />
+</div>
index da1598daef661a7bcae4b729ba6bbf73a9fbc957..d94edf9ef0ec3ce8c9b509e57730fd62568eeff3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-       global $NOTIFICATION_HANDLERS;
+global $NOTIFICATION_HANDLERS;
 
 ?> 
 
@@ -8,14 +8,14 @@
 
 $(document).ready(function () {
 <?php 
-       foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
 ?>
        $('input[type=checkbox]:checked').parent("a.<?php echo $method; ?>toggleOff").each(function(){
                $(this).removeClass('<?php echo $method; ?>toggleOff').addClass('<?php echo $method; ?>toggleOn');
        });
        
 <?php
-       }
+}
 ?>
 
 });
@@ -23,7 +23,7 @@ $(document).ready(function () {
        clickflag = 0;
 
 <?php 
-       foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
 ?>
 function adjust<?php echo $method; ?>(linkId) {
        var obj = $(this).prev("a");
@@ -48,7 +48,7 @@ function adjust<?php echo $method; ?>_alt(linkId) {
        return false;
 }
 <?php
-       }
+}
 ?>
 
 </script>
\ No newline at end of file
index d8ce0e97ead3f15b7091ac17ae1931bbc1b2f0ad..e70207aa3c2a293d83e187ab62099372ec5cae8f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-       global $NOTIFICATION_HANDLERS;
+global $NOTIFICATION_HANDLERS;
 
 ?>
 <div class="notification_personal">
        </h3>
 </div>
 <table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%">
-  <tr>
-    <td>&nbsp;</td>
+       <tr>
+               <td>&nbsp;</td>
 <?php
-       $i = 0; 
-       foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-               if ($i > 0)
-                       echo "<td class='spacercolumn'>&nbsp;</td>";
+$i = 0; 
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+       if ($i > 0) {
+               echo "<td class='spacercolumn'>&nbsp;</td>";
+       }
 ?>
-       <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td>
+               <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td>
 <?php
-               $i++;
-       }
+       $i++;
+}
 ?>
-    <td>&nbsp;</td>
-  </tr>
-  <tr>
-    <td class="namefield">
-       <p>
-               <?php echo elgg_echo('notifications:subscriptions:personal:description') ?>
-       </p>
-       
-    </td>
-    
+               <td>&nbsp;</td>
+       </tr>
+       <tr>
+               <td class="namefield">
+                       <p>
+                               <?php echo elgg_echo('notifications:subscriptions:personal:description') ?>
+                       </p>
+               </td>
+
 <?php
 
-               $fields = '';
-               $i = 0;
-               foreach($NOTIFICATION_HANDLERS as $method => $foo) {
-                       if ($notification_settings = get_user_notification_settings($vars['user']->guid)) {
-                               if ($notification_settings->$method) {
-                                       $personalchecked[$method] = 'checked="checked"';
-                               } else {
-                                       $personalchecked[$method] = '';
-                               }
-                       }
-                       if ($i > 0) $fields .= "<td class='spacercolumn'>&nbsp;</td>";
-                       $fields .= <<< END
-                           <td class="{$method}togglefield">
-                           <a  border="0" id="{$method}personal" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}personal');">
-                           <input type="checkbox" name="{$method}personal" id="{$method}checkbox" onclick="adjust{$method}('{$method}personal');" value="1" {$personalchecked[$method]} /></a></td>
-END;
-                       $i++;
+$fields = '';
+$i = 0;
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+       if ($notification_settings = get_user_notification_settings($vars['user']->guid)) {
+               if ($notification_settings->$method) {
+                       $personalchecked[$method] = 'checked="checked"';
+               } else {
+                       $personalchecked[$method] = '';
                }
-               echo $fields;
+       }
+       if ($i > 0) {
+               $fields .= "<td class='spacercolumn'>&nbsp;</td>";
+       }
+       $fields .= <<< END
+               <td class="{$method}togglefield">
+               <a  border="0" id="{$method}personal" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}personal');">
+               <input type="checkbox" name="{$method}personal" id="{$method}checkbox" onclick="adjust{$method}('{$method}personal');" value="1" {$personalchecked[$method]} /></a></td>
+END;
+       $i++;
+}
+echo $fields;
 
 ?>
-  
-    <td>&nbsp;</td>
-  </tr>
+
+               <td>&nbsp;</td>
+       </tr>
 </table>
 </div>
\ No newline at end of file