aboutsummaryrefslogtreecommitdiff
path: root/mod/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'mod/notifications')
-rw-r--r--mod/notifications/actions/groupsave.php81
-rw-r--r--mod/notifications/actions/save.php77
-rw-r--r--mod/notifications/groups.php84
-rw-r--r--mod/notifications/index.php85
-rw-r--r--mod/notifications/languages/en.php51
-rw-r--r--mod/notifications/manifest.xml22
-rw-r--r--mod/notifications/start.php237
-rw-r--r--mod/notifications/views/default/forms/notificationsettings/groupsave.php111
-rw-r--r--mod/notifications/views/default/forms/notificationsettings/save.php21
-rw-r--r--mod/notifications/views/default/notifications/css.php12
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/collections.php199
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/form.php39
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/forminternals.php368
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/groupsform.php97
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/jsfuncs.php12
-rw-r--r--mod/notifications/views/default/notifications/subscriptions/personal.php102
16 files changed, 926 insertions, 672 deletions
diff --git a/mod/notifications/actions/groupsave.php b/mod/notifications/actions/groupsave.php
index ca250c7fd..e79dae5cc 100644
--- a/mod/notifications/actions/groupsave.php
+++ b/mod/notifications/actions/groupsave.php
@@ -1,44 +1,49 @@
<?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
+ */
- // Restrict to logged in users
- gatekeeper();
-
- // Load important global vars
- global $SESSION;
- global $NOTIFICATION_HANDLERS;
+$current_user = elgg_get_logged_in_user_entity();
- // 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);
- }
+$guid = (int) get_input('guid', 0);
+if (!$guid || !($user = get_entity($guid))) {
+ forward();
+}
+if (($user->guid != $current_user->guid) && !$current_user->isAdmin()) {
+ forward();
+}
+
+// Get group memberships and condense them down to an array of guids
+$groups = array();
+$options = array(
+ 'relationship' => 'member',
+ 'relationship_guid' => $user->guid,
+ 'type' => 'group',
+ 'limit' => false,
+);
+if ($groupmemberships = elgg_get_entities_from_relationship($options)) {
+ foreach($groupmemberships as $groupmembership) {
+ $groups[] = $groupmembership->guid;
+ }
+}
+
+if (!empty($groups)) {
+ global $NOTIFICATION_HANDLERS;
+ foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subscriptions[$method] = get_input($method.'subscriptions', array());
+ foreach ($groups as $group) {
+ if (in_array($group, $subscriptions[$method])) {
+ add_entity_relationship($user->guid, 'notify'.$method, $group);
+ } else {
+ remove_entity_relationship($user->guid, '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(REFERER);
diff --git a/mod/notifications/actions/save.php b/mod/notifications/actions/save.php
index a4a5903f9..3fe0001a3 100644
--- a/mod/notifications/actions/save.php
+++ b/mod/notifications/actions/save.php
@@ -1,42 +1,43 @@
<?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/
- */
-
- // 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);
- }
+/**
+ * Elgg notifications
+ *
+ * @package ElggNotifications
+ */
+
+$current_user = elgg_get_logged_in_user_entity();
+
+$guid = (int) get_input('guid', 0);
+if (!$guid || !($user = get_entity($guid))) {
+ forward();
+}
+if (($user->guid != $current_user->guid) && !$current_user->isAdmin()) {
+ forward();
+}
+
+global $NOTIFICATION_HANDLERS;
+$subscriptions = array();
+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(REFERER);
diff --git a/mod/notifications/groups.php b/mod/notifications/groups.php
index c742f858d..973f3493c 100644
--- a/mod/notifications/groups.php
+++ b/mod/notifications/groups.php
@@ -1,42 +1,46 @@
<?php
+/**
+ * Elgg notifications plugin group index
+ *
+ * @package ElggNotifications
+ *
+ * @uses $user ElggUser
+ */
- /**
- * 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
+if (!isset($user) || !($user instanceof ElggUser)) {
+ $url = 'notifications/group/' . elgg_get_logged_in_user_entity()->username;
+ forward($url);
+}
+
+elgg_set_page_owner_guid($user->guid);
+
+// Set the context to settings
+elgg_set_context('settings');
+
+$title = elgg_echo('notifications:subscriptions:changesettings:groups');
+
+elgg_push_breadcrumb(elgg_echo('settings'), "settings/user/$user->username");
+elgg_push_breadcrumb($title);
+
+// Get the form
+$people = array();
+
+$groupmemberships = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'member',
+ 'relationship_guid' => $user->guid,
+ 'type' => 'group',
+ 'limit' => false,
+));
+
+$body = elgg_view_form('notificationsettings/groupsave', array(), array(
+ 'groups' => $groupmemberships,
+ 'user' => $user,
+));
+
+$params = array(
+ 'content' => $body,
+ 'title' => $title,
+);
+$body = elgg_view_layout('one_sidebar', $params);
+
+echo elgg_view_page($title, $body);
diff --git a/mod/notifications/index.php b/mod/notifications/index.php
index 47e4baad9..a99622efd 100644
--- a/mod/notifications/index.php
+++ b/mod/notifications/index.php
@@ -1,39 +1,50 @@
<?php
+/**
+ * Elgg notifications plugin index
+ *
+ * @package ElggNotifications
+ *
+ * @uses $user ElggUser
+ */
- /**
- * 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
+if (!isset($user) || !($user instanceof ElggUser)) {
+ $url = 'notifications/personal/' . elgg_get_logged_in_user_entity()->username;
+ forward($url);
+}
+
+elgg_set_page_owner_guid($user->guid);
+
+// Set the context to settings
+elgg_set_context('settings');
+
+$title = elgg_echo('notifications:subscriptions:changesettings');
+
+elgg_push_breadcrumb(elgg_echo('settings'), "settings/user/$user->username");
+elgg_push_breadcrumb($title);
+
+// Get the form
+$people = array();
+if ($people_ents = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'notify',
+ 'relationship_guid' => $user->guid,
+ 'type' => 'user',
+ 'limit' => false,
+ ))) {
+
+ foreach($people_ents as $ent) {
+ $people[] = $ent->guid;
+ }
+}
+
+$body = elgg_view('notifications/subscriptions/form', array(
+ 'people' => $people,
+ 'user' => $user,
+));
+
+$params = array(
+ 'content' => $body,
+ 'title' => $title,
+);
+$body = elgg_view_layout('one_sidebar', $params);
+
+echo elgg_view_page($title, $body);
diff --git a/mod/notifications/languages/en.php b/mod/notifications/languages/en.php
index 8573bbb32..0f2ba2304 100644
--- a/mod/notifications/languages/en.php
+++ b/mod/notifications/languages/en.php
@@ -1,29 +1,26 @@
<?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:friends:title' => 'Friends',
+ 'notifications:subscriptions:friends:description' => 'Below are collections of your friends. Selecting a collection turns on notifications for the users in that collection.',
+ 'notifications:subscriptions:collections:edit' => 'To edit your shared access notifications, click here.',
+
+ 'notifications:subscriptions:changesettings' => 'Notifications',
+ 'notifications:subscriptions:changesettings:groups' => 'Group notifications',
+
+ '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);
diff --git a/mod/notifications/manifest.xml b/mod/notifications/manifest.xml
index d76abc6ae..205476881 100644
--- a/mod/notifications/manifest.xml
+++ b/mod/notifications/manifest.xml
@@ -1,10 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
-<plugin_manifest>
- <field key="author" value="Curverider" />
- <field key="version" value="1.7" />
- <field key="description" value="Elgg notifications plugin" />
- <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 xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>Notifications</name>
+ <author>Core developers</author>
+ <version>1.7</version>
+ <category>bundled</category>
+ <description>Elgg notifications plugin</description>
+ <website>http://www.elgg.org/</website>
+ <copyright>See COPYRIGHT.txt</copyright>
+ <license>GNU General Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+ <activate_on_install>true</activate_on_install>
</plugin_manifest>
diff --git a/mod/notifications/start.php b/mod/notifications/start.php
index a08fe68f5..b76b0aa1e 100644
--- a/mod/notifications/start.php
+++ b/mod/notifications/start.php
@@ -1,47 +1,206 @@
<?php
+/**
+ * Elgg notifications plugin
+ *
+ * @package ElggNotifications
+ */
- /**
- * 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");
- }
+elgg_register_event_handler('init', 'system', 'notifications_plugin_init');
+
+function notifications_plugin_init() {
+
+ elgg_extend_view('css/elgg','notifications/css');
+
+ elgg_register_page_handler('notifications', 'notifications_page_handler');
+
+ elgg_register_event_handler('pagesetup', 'system', 'notifications_plugin_pagesetup');
+
+ // Unset the default notification settings
+ elgg_unregister_plugin_hook_handler('usersettings:save', 'user', 'notification_user_settings_save');
+ elgg_unextend_view('forms/account/settings', 'core/settings/account/notifications');
+
+ // update notifications based on relationships changing
+ elgg_register_event_handler('delete', 'member', 'notifications_relationship_remove');
+ elgg_register_event_handler('delete', 'friend', 'notifications_relationship_remove');
+
+ // update notifications when new friend or access collection membership
+ elgg_register_event_handler('create', 'friend', 'notifications_update_friend_notify');
+ elgg_register_plugin_hook_handler('access:collections:add_user', 'collection', 'notifications_update_collection_notify');
+
+ $actions_base = elgg_get_plugins_path() . 'notifications/actions';
+ elgg_register_action("notificationsettings/save", "$actions_base/save.php");
+ elgg_register_action("notificationsettings/groupsave", "$actions_base/groupsave.php");
+}
+
+/**
+ * Route page requests
+ *
+ * @param array $page Array of url parameters
+ * @return bool
+ */
+function notifications_page_handler($page) {
+
+ gatekeeper();
+ $current_user = elgg_get_logged_in_user_entity();
+
+ // default to personal notifications
+ if (!isset($page[0])) {
+ $page[0] = 'personal';
+ }
+ if (!isset($page[1])) {
+ forward("notifications/{$page[0]}/{$current_user->username}");
+ }
+
+ $user = get_user_by_username($page[1]);
+ if (($user->guid != $current_user->guid) && !$current_user->isAdmin()) {
+ forward();
+ }
+
+ $base = elgg_get_plugins_path() . 'notifications';
+
+ // note: $user passed in
+ switch ($page[0]) {
+ case 'group':
+ require "$base/groups.php";
+ break;
+ case 'personal':
+ require "$base/index.php";
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Notification settings sidebar menu
+ *
+ */
+function notifications_plugin_pagesetup() {
+ if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) {
+
+ $user = elgg_get_page_owner_entity();
+ if (!$user) {
+ $user = elgg_get_logged_in_user_entity();
}
+
+ $params = array(
+ 'name' => '2_a_user_notify',
+ 'text' => elgg_echo('notifications:subscriptions:changesettings'),
+ 'href' => "notifications/personal/{$user->username}",
+ );
+ elgg_register_menu_item('page', $params);
- 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]);
+ if (elgg_is_active_plugin('groups')) {
+ $params = array(
+ 'name' => '2_group_notify',
+ 'text' => elgg_echo('notifications:subscriptions:changesettings:groups'),
+ 'href' => "notifications/group/{$user->username}",
+ );
+ elgg_register_menu_item('page', $params);
+ }
+ }
+}
+
+/**
+ * Update notifications when a relationship is deleted
+ *
+ * @param string $event
+ * @param string $object_type
+ * @param object $relationship
+ */
+function notifications_relationship_remove($event, $object_type, $relationship) {
+ global $NOTIFICATION_HANDLERS;
+
+ $user_guid = $relationship->guid_one;
+ $object_guid = $relationship->guid_two;
+
+ // loop through all notification types
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ remove_entity_relationship($user_guid, "notify{$method}", $object_guid);
+ }
+}
+
+/**
+ * Turn on notifications for new friends if all friend notifications is on
+ *
+ * @param string $event
+ * @param string $object_type
+ * @param object $relationship
+ */
+function notifications_update_friend_notify($event, $object_type, $relationship) {
+ global $NOTIFICATION_HANDLERS;
+
+ $user_guid = $relationship->guid_one;
+ $friend_guid = $relationship->guid_two;
+
+ $user = get_entity($user_guid);
+
+ // loop through all notification types
+ foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
+ $metaname = 'collections_notifications_preferences_' . $method;
+ $collections_preferences = $user->$metaname;
+ if ($collections_preferences) {
+ if (!empty($collections_preferences) && !is_array($collections_preferences)) {
+ $collections_preferences = array($collections_preferences);
+ }
+ if (is_array($collections_preferences)) {
+ // -1 means all friends is on - should be a define
+ if (in_array(-1, $collections_preferences)) {
+ add_entity_relationship($user_guid, 'notify' . $method, $friend_guid);
}
+ }
}
+ }
+}
- register_elgg_event_handler('pagesetup','system','notifications_plugin_pagesetup',1000);
- register_elgg_event_handler('init','system','notifications_plugin_init',1000);
+/**
+ * Update notifications for changes in access collection membership.
+ *
+ * This function assumes that only friends can belong to access collections.
+ *
+ * @param string $event
+ * @param string $object_type
+ * @param bool $returnvalue
+ * @param array $params
+ */
+function notifications_update_collection_notify($event, $object_type, $returnvalue, $params) {
+ global $NOTIFICATION_HANDLERS;
- // 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
+ // only update notifications for user owned collections
+ $collection_id = $params['collection_id'];
+ $collection = get_access_collection($collection_id);
+ $user = get_entity($collection->owner_guid);
+ if (!($user instanceof ElggUser)) {
+ return $returnvalue;
+ }
+
+ $member_guid = $params['user_guid'];
+
+ // loop through all notification types
+ foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
+ $metaname = 'collections_notifications_preferences_' . $method;
+ $collections_preferences = $user->$metaname;
+ if (!$collections_preferences) {
+ continue;
+ }
+ if (!is_array($collections_preferences)) {
+ $collections_preferences = array($collections_preferences);
+ }
+ if (in_array(-1, $collections_preferences)) {
+ // if "all friends" notify is on, we don't change any notifications
+ // since must be a friend to be in an access collection
+ continue;
+ }
+ if (in_array($collection_id, $collections_preferences)) {
+ // notifications are on for this collection so we add/remove
+ if ($event == 'access:collections:add_user') {
+ add_entity_relationship($user->guid, "notify$method", $member_guid);
+ } elseif ($event == 'access:collections:remove_user') {
+ // removing someone from an access collection is not a guarantee
+ // that they should be removed from notifications
+ //remove_entity_relationship($user->guid, "notify$method", $member_guid);
+ }
+ }
+ }
+}
diff --git a/mod/notifications/views/default/forms/notificationsettings/groupsave.php b/mod/notifications/views/default/forms/notificationsettings/groupsave.php
new file mode 100644
index 000000000..f3e5f693a
--- /dev/null
+++ b/mod/notifications/views/default/forms/notificationsettings/groupsave.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Elgg notifications groups subscription form
+ *
+ * @package ElggNotifications
+ *
+ * @uses $vars['user'] ElggUser
+ */
+
+/* @var ElggUser $user */
+$user = $vars['user'];
+
+global $NOTIFICATION_HANDLERS;
+foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subsbig[$method] = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'notify' . $method,
+ 'relationship_guid' => $user->guid,
+ 'type' => 'group',
+ 'limit' => false,
+ ));
+ $tmparray = array();
+ if ($subsbig[$method]) {
+ foreach($subsbig[$method] as $tmpent) {
+ $tmparray[] = $tmpent->guid;
+ }
+ }
+ $subsbig[$method] = $tmparray;
+}
+
+?>
+
+<div class="elgg-module elgg-module-info">
+ <div class="elgg-body">
+ <?php
+ echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
+ ?>
+ <div>
+ <?php
+ echo elgg_echo('notifications:subscriptions:groups:description');
+ ?>
+ </div>
+<?php
+
+if (isset($vars['groups']) && !empty($vars['groups'])) {
+
+?>
+ <table id="notificationstable" cellspacing="0" cellpadding="4" width="100%">
+ <tr>
+ <td>&nbsp;</td>
+<?php
+
+ $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>
+<?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>
+END;
+ $i++;
+ }
+
+?>
+ <tr>
+ <td class="namefield">
+ <div>
+ <?php echo $group->name; ?>
+ </div>
+ </td>
+ <?php echo $fields; ?>
+ <td>&nbsp;</td>
+ </tr>
+<?php
+ }
+?>
+ </table>
+<?php
+}
+ echo '<div class="elgg-foot mtm">';
+ echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $user->guid));
+ echo elgg_view('input/submit', array('value' => elgg_echo('save')));
+ echo '</div>';
+
+?>
+ </div>
+</div>
diff --git a/mod/notifications/views/default/forms/notificationsettings/save.php b/mod/notifications/views/default/forms/notificationsettings/save.php
new file mode 100644
index 000000000..9470256ca
--- /dev/null
+++ b/mod/notifications/views/default/forms/notificationsettings/save.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Personal notifications form body
+ *
+ * @uses $vars['user'] ElggUser
+ */
+
+/* @var ElggUser $user */
+$user = $vars['user'];
+
+echo elgg_view('notifications/subscriptions/personal', $vars);
+echo elgg_view('notifications/subscriptions/collections', $vars);
+echo elgg_view('notifications/subscriptions/forminternals', $vars);
+
+?>
+<div class="elgg-foot">
+<?php
+echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $user->guid));
+echo elgg_view('input/submit', array('value' => elgg_echo('save')));
+?>
+</div>
diff --git a/mod/notifications/views/default/notifications/css.php b/mod/notifications/views/default/notifications/css.php
index bd6067c85..385c55b0b 100644
--- a/mod/notifications/views/default/notifications/css.php
+++ b/mod/notifications/views/default/notifications/css.php
@@ -3,10 +3,6 @@
* Elgg notifications CSS
*
* @package notifications
- * @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/
*/
?>
@@ -70,16 +66,16 @@
outline: none;
}
#notificationstable td.emailtogglefield a.emailtoggleOff {
- background: url(<?php echo $vars['url']; ?>mod/notifications/graphics/icon_notifications_email.gif) no-repeat right 2px;
+ background: url(<?php echo elgg_get_site_url(); ?>mod/notifications/graphics/icon_notifications_email.gif) no-repeat right 2px;
}
#notificationstable td.emailtogglefield a.emailtoggleOn {
- background: url(<?php echo $vars['url']; ?>mod/notifications/graphics/icon_notifications_email.gif) no-repeat right -36px;
+ background: url(<?php echo elgg_get_site_url(); ?>mod/notifications/graphics/icon_notifications_email.gif) no-repeat right -36px;
}
#notificationstable td.sitetogglefield a.sitetoggleOff {
- background: url(<?php echo $vars['url']; ?>mod/notifications/graphics/icon_notifications_site.gif) no-repeat right 2px;
+ background: url(<?php echo elgg_get_site_url(); ?>mod/notifications/graphics/icon_notifications_site.gif) no-repeat right 2px;
}
#notificationstable td.sitetogglefield a.sitetoggleOn {
- background: url(<?php echo $vars['url']; ?>mod/notifications/graphics/icon_notifications_site.gif) no-repeat right -37px;
+ background: url(<?php echo elgg_get_site_url(); ?>mod/notifications/graphics/icon_notifications_site.gif) no-repeat right -37px;
}
.notification_friends,
.notification_personal,
diff --git a/mod/notifications/views/default/notifications/subscriptions/collections.php b/mod/notifications/views/default/notifications/subscriptions/collections.php
index 87906bf76..207b2e3b9 100644
--- a/mod/notifications/views/default/notifications/subscriptions/collections.php
+++ b/mod/notifications/views/default/notifications/subscriptions/collections.php
@@ -1,143 +1,164 @@
+<?php
+/**
+ * @uses $vars['user'] ElggUser
+ */
+
+/* @var ElggUser $user */
+$user = $vars['user'];
+//@todo JS 1.8: no ?>
<script type="text/javascript">
function setCollection(members, method, id) {
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);
+ }
}
}
</script>
-<div class="notification_friends">
-<h3>
- <?php echo elgg_echo('notifications:subscriptions:collections:title'); ?>
-</h3>
-<p class="margin_none">
- <?php echo elgg_echo('notifications:subscriptions:collections:description'); ?>
+<div class="elgg-module elgg-module-info">
+ <div class="elgg-head">
+ <h3>
+ <?php echo elgg_echo('notifications:subscriptions:friends:title'); ?>
+ </h3>
+ </div>
+<p class="margin-none">
+ <?php echo elgg_echo('notifications:subscriptions:friends:description'); ?>
</p>
-<table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%">
- <tr>
- <td>&nbsp;</td>
+<table id="notificationstable" cellspacing="0" cellpadding="4" width="100%">
+ <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($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 = $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);
+
+ if ($collections = get_user_access_collections($user->guid)) {
+ foreach ($collections as $collection) {
+ $members = get_members_of_access_collection($collection->id, true);
+ $memberno = 0;
+ if ($members) {
+ $memberno = sizeof($members);
+ $members = implode(',', $members);
+ } else {
+ $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 = $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
+ }
}
-}
-*/
?>
</table>
</div>
diff --git a/mod/notifications/views/default/notifications/subscriptions/form.php b/mod/notifications/views/default/notifications/subscriptions/form.php
index 8ad0110bf..559354eff 100644
--- a/mod/notifications/views/default/notifications/subscriptions/form.php
+++ b/mod/notifications/views/default/notifications/subscriptions/form.php
@@ -1,33 +1,12 @@
<?php
+/**
+ * Elgg personal notifications
+ *
+ * @uses $vars['user'] ElggUser that owns the notification settings
+ */
- /**
- * 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/
- */
+// @todo is this a view for extensions?
+echo elgg_view('subscriptions/form/additions', $vars);
-
- // 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',
- ));
-
-?>
-</div>
+$form_vars = array('class' => 'elgg-form-alt');
+echo elgg_view_form('notificationsettings/save', $form_vars, $vars);
diff --git a/mod/notifications/views/default/notifications/subscriptions/forminternals.php b/mod/notifications/views/default/notifications/subscriptions/forminternals.php
index 97fe77cac..79a7959ac 100644
--- a/mod/notifications/views/default/notifications/subscriptions/forminternals.php
+++ b/mod/notifications/views/default/notifications/subscriptions/forminternals.php
@@ -1,119 +1,142 @@
+<?php
+/**
+ * Hacked up friends picker that needs to be replaced
+ *
+ * @uses $vars['user'] ElggUser
+ */
+
+/* @var ElggUser $user */
+$user = $vars['user'];
-<div class="notifications_per_user">
- <h3>
- <?php echo elgg_echo('notifications:subscriptions:title'); ?>
- </h3>
+elgg_load_js('elgg.friendspicker');
+elgg_load_js('jquery.easing');
+
+?>
+<div class="elgg-module elgg-module-info">
+ <div class="elgg-head">
+ <h3>
+ <?php echo elgg_echo('notifications:subscriptions:title'); ?>
+ </h3>
+ </div>
<p>
<?php echo elgg_echo('notifications:subscriptions:description'); ?>
</p>
<?php
- // Get friends and subscriptions
- $friends = get_user_friends($vars['user']->guid,'',9999,0);
+// Get friends and subscriptions
+$friends = get_user_friends($user->guid, '', 9999, 0);
- 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' => 'user', 'limit' => 99999));
- }
+global $NOTIFICATION_HANDLERS;
+foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subsbig[$method] = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'notify' . $method,
+ 'relationship_guid' => $user->guid,
+ 'type' => 'user',
+ 'limit' => false,
+ ));
+}
- $subs = array();
- foreach($subsbig as $method => $big) {
- if (is_array($subsbig[$method]) && sizeof($subsbig[$method])) {
- foreach($subsbig[$method] as $u) { $subs[$method][] = $u->guid; }
- }
- }
-
- // Let the system know that the friends picker is in use
- global $pickerinuse;
- $pickerinuse = true;
- $chararray = elgg_echo('friendspicker:chararray');
-
- // Initialise internalname
- if (!isset($vars['internalname'])) {
- $internalname = "friend";
- } else {
- $internalname = $vars['internalname'];
+$subs = array();
+foreach($subsbig as $method => $big) {
+ if (is_array($subsbig[$method]) && sizeof($subsbig[$method])) {
+ foreach($subsbig[$method] as $u) {
+ $subs[$method][] = $u->guid;
}
+ }
+}
+
+// Let the system know that the friends picker is in use
+global $pickerinuse;
+$pickerinuse = true;
+$chararray = elgg_echo('friendspicker:chararray');
+
+// Initialise name
+if (!isset($vars['name'])) {
+ $name = "friend";
+} else {
+ $name = $vars['name'];
+}
- // Initialise values
- if (!isset($vars['value'])) {
- $vars['value'] = array();
- } else {
- if (!is_array($vars['value'])) {
- $vars['value'] = (int) $vars['value'];
- $vars['value'] = array($vars['value']);
- }
- }
-
- // Initialise whether we're calling back or not
- if (isset($vars['callback'])) {
- $callback = $vars['callback'];
- } else {
- $callback = false;
- }
+// Initialise values
+if (!isset($vars['value'])) {
+ $vars['value'] = array();
+} else {
+ if (!is_array($vars['value'])) {
+ $vars['value'] = (int) $vars['value'];
+ $vars['value'] = array($vars['value']);
+ }
+}
+
+// Initialise whether we're calling back or not
+if (isset($vars['callback'])) {
+ $callback = $vars['callback'];
+} else {
+ $callback = false;
+}
- // We need to count the number of friends pickers on the page.
- if (!isset($vars['friendspicker'])) {
- global $friendspicker;
- if (!isset($friendspicker)) $friendspicker = 0;
- $friendspicker++;
- } else {
- $friendspicker = $vars['friendspicker'];
- }
+// We need to count the number of friends pickers on the page.
+if (!isset($vars['friendspicker'])) {
+ global $friendspicker;
+ if (!isset($friendspicker)) {
+ $friendspicker = 0;
+ }
+ $friendspicker++;
+} else {
+ $friendspicker = $vars['friendspicker'];
+}
- $users = array();
- $activeletters = array();
+$users = array();
+$activeletters = array();
- // Are we displaying form tags and submit buttons?
- // (If we've been given a target, then yes! Otherwise, no.)
- if (isset($vars['formtarget'])) {
- $formtarget = $vars['formtarget'];
- } else {
- $formtarget = false;
- }
+// Are we displaying form tags and submit buttons?
+// (If we've been given a target, then yes! Otherwise, no.)
+if (isset($vars['formtarget'])) {
+ $formtarget = $vars['formtarget'];
+} else {
+ $formtarget = false;
+}
- // Sort users by letter
- if (is_array($friends) && sizeof($friends))
- foreach($friends as $user) {
-
- if (is_callable('mb_substr'))
- $letter = strtoupper(mb_substr($user->name,0,1));
- else
- $letter = strtoupper(substr($user->name,0,1));
- if (!substr_count($chararray,$letter)) {
- $letter = "*";
- }
- if (!isset($users[$letter])) {
- $users[$letter] = array();
- }
- $users[$letter][$user->name] = $user;
+// Sort users by letter
+if (is_array($friends) && sizeof($friends)) {
+ foreach($friends as $friend) {
- }
-
- if (!$callback) {
+ $letter = elgg_substr($friend->name,0,1);
+ $letter = elgg_strtoupper($letter);
+ if (!elgg_substr_count($chararray,$letter)) {
+ $letter = "*";
+ }
+ if (!isset($users[$letter])) {
+ $users[$letter] = array();
+ }
+ $users[$letter][$friend->guid] = $friend;
+ }
+}
+
+if (!$callback) {
?>
-<div class="friends_picker">
+<div class="friends-picker-main-wrapper">
<?php
- if (isset($vars['content'])) echo $vars['content'];
-
+ if (isset($vars['content'])) {
+ echo $vars['content'];
+ }
?>
- <div id="friends_picker_placeholder<?php echo $friendspicker; ?>">
+ <div id="friends-picker_placeholder<?php echo $friendspicker; ?>">
<?php
- }
+}
- if (!isset($vars['replacement'])) {
+if (!isset($vars['replacement'])) {
- if ($formtarget) {
+ if ($formtarget) {
?>
-
+<?php //@todo JS 1.8: no ?>
<script language="text/javascript">
$(function() { // onload...do
$('#collectionMembersForm<?php echo $friendspicker; ?>').submit(function() {
@@ -128,38 +151,34 @@
data: inputs.join('&'),
url: this.action,
success: function(){
- $('a.collectionmembers<?php echo $friendspicker; ?>').click();
- }
+ $('a.collectionmembers<?php echo $friendspicker; ?>').click();
+ }
});
return false;
- })
- })
+ })
+ })
</script>
<?php
- }
+ }
- echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
+ echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
?>
-
- <div class="friends_picker_wrapper">
- <div id="friends_picker<?php echo $friendspicker; ?>">
- <div class="friends_picker_container">
+ <div class="friends-picker-wrapper">
+ <div id="friends-picker<?php echo $friendspicker; ?>">
+ <div class="friends-picker-container">
<?php
// Initialise letters
- if (is_callable('mb_substr'))
- $letter = mb_substr($chararray,0,1);
- else
- $letter = substr($chararray,0,1);
- $letpos = 0;
- $chararray .= '*';
- while (1 == 1) {
+ $letter = elgg_substr($chararray,0,1);
+ $letpos = 0;
+ $chararray .= '*';
+ while (1 == 1) {
?>
<div class="panel" title="<?php echo $letter; ?>">
<div class="wrapper">
@@ -167,91 +186,100 @@
<?php
- if (isset($users[$letter])) {
- ksort($users[$letter]);
+ if (isset($users[$letter])) {
+ ksort($users[$letter]);
?>
<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>
<?php
- $i++;
- }
+ $i++;
+ }
?>
- <td>&nbsp;</td>
- </tr>
+ <td>&nbsp;</td>
+</tr>
<?php
- if (is_array($users[$letter]) && sizeof($users[$letter]) > 0)
- foreach($users[$letter] as $friend) {
- if ($friend instanceof ElggUser ) {
+ if (is_array($users[$letter]) && sizeof($users[$letter]) > 0) {
+ foreach($users[$letter] as $friend) {
+ if ($friend instanceof ElggUser ) {
- if (!in_array($letter,$activeletters))
- $activeletters[] = $letter;
+ if (!in_array($letter,$activeletters)) {
+ $activeletters[] = $letter;
+ }
- $method = array();
- $fields = '';
- $i = 0;
+ $method = array();
+ $fields = '';
+ $i = 0;
- foreach($NOTIFICATION_HANDLERS as $method => $foo) {
- if (in_array($friend->guid,$subs[$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}{$friend->guid}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}{$friend->guid}');">
- <input type="checkbox" name="{$method}subscriptions[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}{$friend->guid}');" value="{$friend->guid}" {$checked[$method]} /></a></td>
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ if (isset($subs[$method]) && in_array($friend->guid,$subs[$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}{$friend->guid}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}{$friend->guid}');">
+<input type="checkbox" name="{$method}subscriptions[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}{$friend->guid}');" value="{$friend->guid}" {$checked[$method]} /></a></td>
END;
- $i++;
- }
+ $i++;
+ }
?>
- <tr>
- <td class="namefield"><a href="<?php echo $friend->getURL(); ?>">
+<tr>
+ <td class="namefield">
+ <a href="<?php echo $friend->getURL(); ?>">
<?php
- echo elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny', 'override' => true));
+ echo elgg_view_entity_icon($friend, 'tiny', array('use_hover' => false));
?>
- </a><p class="namefieldlink"><a href="<?php echo $friend->getURL(); ?>"><?php echo $friend->name ?></p></td>
-
+ </a>
+ <p class="namefieldlink">
+ <a href="<?php echo $friend->getURL(); ?>"><?php echo $friend->name ?></a>
+ </p>
+ </td>
+
<?php echo $fields; ?>
-
- <td>&nbsp;</td>
- </tr>
+
+<td>&nbsp;</td>
+</tr>
<?php
+ }
+ }
}
- }
?>
</table>
<?php
- }
+ }
?>
</div>
</div>
<?php
- $letpos++;
- if ($letpos == strlen($chararray)) break;
- if (is_callable('mb_substr'))
- $letter = mb_substr($chararray,$letpos,1);
- else
- $letter = substr($chararray,$letpos,1);
+ $letpos++;
+ if ($letpos == elgg_strlen($chararray)) {
+ break;
}
+ $letter = elgg_substr($chararray,$letpos,1);
+ }
?>
</div>
@@ -259,10 +287,10 @@ END;
</div>
<?php
- } else {
- echo $vars['replacement'];
- }
- if (!$callback) {
+} else {
+ echo $vars['replacement'];
+}
+if (!$callback) {
?>
@@ -272,29 +300,30 @@ END;
<?php
- }
+}
?>
<?php
- if (!isset($vars['replacement'])) {
+if (!isset($vars['replacement'])) {
?>
-
+<?php //@todo JS 1.8: no ?>
<script type="text/javascript">
// initialise picker
- $("div#friends_picker<?php echo $friendspicker; ?>").friendsPicker(<?php echo $friendspicker; ?>);
+ $("div#friends-picker<?php echo $friendspicker; ?>").friendsPicker(<?php echo $friendspicker; ?>);
</script>
-<script>
- $(document).ready(function () {
+<script type="text/javascript">
+ $(function () {
// manually add class to corresponding tab for panels that have content
<?php
- if (sizeof($activeletters) > 0)
- $chararray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ if (sizeof($activeletters) > 0) {
+ $chararray .= "*";
foreach($activeletters as $letter) {
- $tab = strpos($chararray, $letter) + 1;
+ $tab = elgg_strpos($chararray, $letter) + 1;
?>
- $("div#friends_picker_navigation<?php echo $friendspicker; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent");
+ $("div#friends-picker-navigation<?php echo $friendspicker; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent");
<?php
}
+ }
?>
});
@@ -302,12 +331,7 @@ END;
<?php
- }
+}
?>
-<div class="divider">
- <input type="submit" value="<?php echo elgg_echo('save'); ?>" />
-</div>
</div>
-
- \ 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 4beefb943..f1dbdcff8 100644
--- a/mod/notifications/views/default/notifications/subscriptions/groupsform.php
+++ b/mod/notifications/views/default/notifications/subscriptions/groupsform.php
@@ -1,95 +1,4 @@
-<?php
+<?php
- 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;
- }
-
-echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings:groups')); ?>
-<div class="notification_groups margin_top">
- <?php
- echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
- ?>
-
- <p>
- <?php
-
- echo elgg_echo('notifications:subscriptions:groups:description');
-
- ?>
- </p>
-<?php
-
- if (isset($vars['groups']) && !empty($vars['groups'])) {
-
-?>
-<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)
- 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>
-<?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++;
- }
-
-?>
- <tr>
- <td class="namefield">
- <p>
- <?php echo $group->name; ?>
- </p>
- </td>
-<?php
- echo $fields;
-?>
- <td>&nbsp;</td>
- </tr>
-<?php
-
-
- }
-?>
-</table>
-<?php
- }
-
-?>
-
- <input type="submit" value="<?php echo elgg_echo('save'); ?>" />
-</div> \ No newline at end of file
+elgg_deprecated_notice("notifications/subscriptions/groupsform was moved to forms/notificationsettings/groupsave", 1.8);
+echo elgg_view('forms/notificationsettings/groupsave'); \ No newline at end of file
diff --git a/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php b/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php
index da1598dae..ace622581 100644
--- a/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php
+++ b/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php
@@ -1,21 +1,21 @@
<?php
- global $NOTIFICATION_HANDLERS;
+global $NOTIFICATION_HANDLERS;
?>
-
+<?php //@todo JS 1.8: no ?>
<script type="text/javascript">
$(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
diff --git a/mod/notifications/views/default/notifications/subscriptions/personal.php b/mod/notifications/views/default/notifications/subscriptions/personal.php
index d8ce0e97e..cf05426e2 100644
--- a/mod/notifications/views/default/notifications/subscriptions/personal.php
+++ b/mod/notifications/views/default/notifications/subscriptions/personal.php
@@ -1,63 +1,73 @@
<?php
+/**
+ * @uses $vars['user'] ElggUser
+ */
- global $NOTIFICATION_HANDLERS;
+/* @var ElggUser $user */
+$user = $vars['user'];
+
+global $NOTIFICATION_HANDLERS;
?>
<div class="notification_personal">
-<div class="notification_methods">
- <h3>
- <?php echo elgg_echo('notifications:subscriptions:personal:title'); ?>
- </h3>
+<div class="elgg-module elgg-module-info">
+ <div class="elgg-head">
+ <h3>
+ <?php echo elgg_echo('notifications:subscriptions:personal:title'); ?>
+ </h3>
+ </div>
</div>
-<table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%">
- <tr>
- <td>&nbsp;</td>
+<table id="notificationstable" cellspacing="0" cellpadding="4" width="100%">
+ <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($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