diff options
Diffstat (limited to 'mod/notifications')
15 files changed, 396 insertions, 270 deletions
diff --git a/mod/notifications/actions/groupsave.php b/mod/notifications/actions/groupsave.php index f39beb665..e79dae5cc 100644 --- a/mod/notifications/actions/groupsave.php +++ b/mod/notifications/actions/groupsave.php @@ -6,27 +6,39 @@ * @package ElggNotifications */ -// Load important global vars -global $NOTIFICATION_HANDLERS; +$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(); +} // 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))) { +$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; } -} +} -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); +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(get_loggedin_userid(), 'notify'.$method, $group); + remove_entity_relationship($user->guid, 'notify'.$method, $group); } } } diff --git a/mod/notifications/actions/save.php b/mod/notifications/actions/save.php index eddda9dc6..3fe0001a3 100644 --- a/mod/notifications/actions/save.php +++ b/mod/notifications/actions/save.php @@ -6,9 +6,18 @@ * @package ElggNotifications */ -$user = get_loggedin_user(); +$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'); diff --git a/mod/notifications/groups.php b/mod/notifications/groups.php index 10e320032..973f3493c 100644 --- a/mod/notifications/groups.php +++ b/mod/notifications/groups.php @@ -1,36 +1,46 @@ <?php - /** * Elgg notifications plugin group index * * @package ElggNotifications + * + * @uses $user ElggUser */ -// Load Elgg framework -require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php'); +if (!isset($user) || !($user instanceof ElggUser)) { + $url = 'notifications/group/' . elgg_get_logged_in_user_entity()->username; + forward($url); +} -// Ensure only logged-in users can see this page -gatekeeper(); - -set_page_owner(get_loggedin_userid()); +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' => 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' => 'action/notificationsettings/groupsave' +$groupmemberships = elgg_get_entities_from_relationship(array( + 'relationship' => 'member', + 'relationship_guid' => $user->guid, + 'type' => 'group', + 'limit' => false, )); -// Insert it into the correct canvas layout -$body = elgg_view_layout('one_column_with_sidebar', array('content' => $body)); +$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(elgg_echo('notifications:subscriptions:changesettings:groups'), $body); +echo elgg_view_page($title, $body); diff --git a/mod/notifications/index.php b/mod/notifications/index.php index c162c34b3..a99622efd 100644 --- a/mod/notifications/index.php +++ b/mod/notifications/index.php @@ -1,37 +1,50 @@ <?php - /** * Elgg notifications plugin index * * @package ElggNotifications + * + * @uses $user ElggUser */ -// 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()); +if (!isset($user) || !($user instanceof ElggUser)) { + $url = 'notifications/personal/' . elgg_get_logged_in_user_entity()->username; + forward($url); +} -$js_url = elgg_view_get_simplecache_url('js', 'friendsPickerv1'); -elgg_register_js($js_url, 'friendsPicker'); +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' => get_loggedin_userid(), 'types' => 'user', 'limit' => 99999))) { +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)); - -// Insert it into the correct canvas layout -$body = elgg_view_layout('one_column_with_sidebar', array('content' => $body)); +$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(elgg_echo('notifications:subscriptions:changesettings'), $body); +echo elgg_view_page($title, $body); diff --git a/mod/notifications/languages/en.php b/mod/notifications/languages/en.php index 586d66892..0f2ba2304 100644 --- a/mod/notifications/languages/en.php +++ b/mod/notifications/languages/en.php @@ -8,12 +8,11 @@ $english = array( 'notifications:subscriptions:personal:title' => 'Personal notifications', 'notifications:subscriptions:friends:title' => 'Friends', - 'notifications:subscriptions:friends: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: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', - '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.', diff --git a/mod/notifications/manifest.xml b/mod/notifications/manifest.xml index 6ad232ea8..205476881 100644 --- a/mod/notifications/manifest.xml +++ b/mod/notifications/manifest.xml @@ -1,12 +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" /> - <field key="admin_interface" value="advanced" /> - <field key="elgg_install_state" value="enabled" /> +<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 15b079bda..b76b0aa1e 100644 --- a/mod/notifications/start.php +++ b/mod/notifications/start.php @@ -1,24 +1,23 @@ <?php - /** * Elgg notifications plugin * * @package ElggNotifications */ +elgg_register_event_handler('init', 'system', 'notifications_plugin_init'); function notifications_plugin_init() { - global $CONFIG; - elgg_extend_view('css/screen','notifications/css'); + elgg_extend_view('css/elgg','notifications/css'); - register_page_handler('notifications', 'notifications_page_handler'); + 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('usersettings/user', 'usersettings/notifications'); + 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'); @@ -26,33 +25,51 @@ function notifications_plugin_init() { // 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'); + 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) { - global $CONFIG; + + 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 $CONFIG->pluginspath . "notifications/groups.php"; + require "$base/groups.php"; break; case 'personal': - default: - require $CONFIG->pluginspath . "notifications/index.php"; + require "$base/index.php"; break; + default: + return false; } - - return TRUE; + return true; } /** @@ -60,11 +77,27 @@ function notifications_page_handler($page) { * */ function notifications_plugin_pagesetup() { - global $CONFIG; - if (elgg_get_context() == 'settings') { - add_submenu_item(elgg_echo('notifications:subscriptions:changesettings'), "pg/notifications/personal"); - if (is_plugin_enabled('groups')) { - add_submenu_item(elgg_echo('notifications:subscriptions:changesettings:groups'), "pg/notifications/group"); + 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); + + 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); } } } @@ -161,7 +194,7 @@ function notifications_update_collection_notify($event, $object_type, $returnval } if (in_array($collection_id, $collections_preferences)) { // notifications are on for this collection so we add/remove - if ($event == 'access:collections:add-user') { + 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 @@ -171,9 +204,3 @@ function notifications_update_collection_notify($event, $object_type, $returnval } } } - -elgg_register_event_handler('init', 'system', 'notifications_plugin_init', 1000); - - -elgg_register_action("notificationsettings/save", $CONFIG->pluginspath . "notifications/actions/save.php"); -elgg_register_action("notificationsettings/groupsave", $CONFIG->pluginspath . "notifications/actions/groupsave.php"); 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> </td> +<?php + + $i = 0; + foreach($NOTIFICATION_HANDLERS as $method => $foo) { + if ($i > 0) { + echo "<td class='spacercolumn'> </td>"; + } +?> + <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td> +<?php + $i++; + } +?> + <td> </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\"> </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> </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/subscriptions/collections.php b/mod/notifications/views/default/notifications/subscriptions/collections.php index 8cca13689..207b2e3b9 100644 --- a/mod/notifications/views/default/notifications/subscriptions/collections.php +++ b/mod/notifications/views/default/notifications/subscriptions/collections.php @@ -1,4 +1,12 @@ +<?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) { @@ -13,14 +21,16 @@ } </script> -<div class="notification_friends"> -<h3> - <?php echo elgg_echo('notifications:subscriptions:friends:title'); ?> -</h3> +<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%"> +<table id="notificationstable" cellspacing="0" cellpadding="4" width="100%"> <tr> <td> </td> <?php @@ -40,7 +50,7 @@ </tr> <?php $members = array(); - if ($friends = get_user_friends(get_loggedin_userid(), '', 9999, 0)) { + if ($friends = get_user_friends($user->guid, '', 9999, 0)) { foreach($friends as $friend) { $members[] = $friend->guid; } @@ -61,7 +71,7 @@ $i = 0; foreach($NOTIFICATION_HANDLERS as $method => $foo) { $metaname = 'collections_notifications_preferences_' . $method; - if ($collections_preferences = get_loggedin_user()->$metaname) { + if ($collections_preferences = $user->$metaname) { if (!empty($collections_preferences) && !is_array($collections_preferences)) { $collections_preferences = array($collections_preferences); } @@ -89,15 +99,18 @@ END; <td> </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(get_loggedin_userid())) { - foreach($collections as $collection) { + + if ($collections = get_user_access_collections($user->guid)) { + foreach ($collections as $collection) { $members = get_members_of_access_collection($collection->id, true); - $memberno = sizeof($members); - $members = implode(',', $members); + $memberno = 0; + if ($members) { + $memberno = sizeof($members); + $members = implode(',', $members); + } else { + $members = ''; + } + ?> <tr> @@ -113,7 +126,7 @@ END; $i = 0; foreach($NOTIFICATION_HANDLERS as $method => $foo) { $metaname = 'collections_notifications_preferences_' . $method; - if ($collections_preferences = get_loggedin_user()->$metaname) { + if ($collections_preferences = $user->$metaname) { if (!empty($collections_preferences) && !is_array($collections_preferences)) { $collections_preferences = array($collections_preferences); } @@ -146,7 +159,6 @@ END; } } -*/ ?> </table> </div> diff --git a/mod/notifications/views/default/notifications/subscriptions/form.php b/mod/notifications/views/default/notifications/subscriptions/form.php index 449f908a7..559354eff 100644 --- a/mod/notifications/views/default/notifications/subscriptions/form.php +++ b/mod/notifications/views/default/notifications/subscriptions/form.php @@ -1,30 +1,12 @@ <?php - /** - * Elgg SMS Client - * - * @package ElggSMS + * Elgg personal notifications + * + * @uses $vars['user'] ElggUser that owns the notification settings */ +// @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' => '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 0576bc7b9..79a7959ac 100644 --- a/mod/notifications/views/default/notifications/subscriptions/forminternals.php +++ b/mod/notifications/views/default/notifications/subscriptions/forminternals.php @@ -1,19 +1,39 @@ +<?php +/** + * Hacked up friends picker that needs to be replaced + * + * @uses $vars['user'] ElggUser + */ + +/* @var ElggUser $user */ +$user = $vars['user']; + +elgg_load_js('elgg.friendspicker'); +elgg_load_js('jquery.easing'); -<div class="notifications_per_user"> - <h3> - <?php echo elgg_echo('notifications:subscriptions:title'); ?> - </h3> +?> +<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(get_loggedin_userid(),'',9999,0); +$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' => get_loggedin_userid(), 'types' => 'user', 'limit' => 99999)); + $subsbig[$method] = elgg_get_entities_from_relationship(array( + 'relationship' => 'notify' . $method, + 'relationship_guid' => $user->guid, + 'type' => 'user', + 'limit' => false, + )); } $subs = array(); @@ -30,11 +50,11 @@ global $pickerinuse; $pickerinuse = true; $chararray = elgg_echo('friendspicker:chararray'); -// Initialise internalname -if (!isset($vars['internalname'])) { - $internalname = "friend"; +// Initialise name +if (!isset($vars['name'])) { + $name = "friend"; } else { - $internalname = $vars['internalname']; + $name = $vars['name']; } // Initialise values @@ -78,9 +98,9 @@ if (isset($vars['formtarget'])) { // Sort users by letter if (is_array($friends) && sizeof($friends)) { - foreach($friends as $user) { + foreach($friends as $friend) { - $letter = elgg_substr($user->name,0,1); + $letter = elgg_substr($friend->name,0,1); $letter = elgg_strtoupper($letter); if (!elgg_substr_count($chararray,$letter)) { $letter = "*"; @@ -88,7 +108,7 @@ if (is_array($friends) && sizeof($friends)) { if (!isset($users[$letter])) { $users[$letter] = array(); } - $users[$letter][$user->guid] = $user; + $users[$letter][$friend->guid] = $friend; } } @@ -96,7 +116,7 @@ if (!$callback) { ?> -<div class="friends-picker"> +<div class="friends-picker-main-wrapper"> <?php @@ -116,7 +136,7 @@ if (!isset($vars['replacement'])) { if ($formtarget) { ?> - +<?php //@todo JS 1.8: no ?> <script language="text/javascript"> $(function() { // onload...do $('#collectionMembersForm<?php echo $friendspicker; ?>').submit(function() { @@ -131,13 +151,13 @@ if (!isset($vars['replacement'])) { data: inputs.join('&'), url: this.action, success: function(){ - $('a.collectionmembers<?php echo $friendspicker; ?>').click(); - } + $('a.collectionmembers<?php echo $friendspicker; ?>').click(); + } }); return false; - }) - }) + }) + }) </script> @@ -171,8 +191,8 @@ if (!isset($vars['replacement'])) { ?> <table id="notificationstable" cellspacing="0" cellpadding="4" border="0" width="100%"> - <tr> - <td> </td> +<tr> + <td> </td> <?php $i = 0; foreach($NOTIFICATION_HANDLERS as $method => $foo) { @@ -185,8 +205,8 @@ if (!isset($vars['replacement'])) { $i++; } ?> - <td> </td> - </tr> + <td> </td> +</tr> <?php @@ -220,22 +240,22 @@ END; } ?> - <tr> - <td class="namefield"> +<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 ?></a> </p> </td> - + <?php echo $fields; ?> - - <td> </td> - </tr> + +<td> </td> +</tr> <?php @@ -286,13 +306,13 @@ if (!$callback) { <?php 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; ?>); </script> <script type="text/javascript"> - $(document).ready(function () { + $(function () { // manually add class to corresponding tab for panels that have content <?php if (sizeof($activeletters) > 0) { @@ -314,8 +334,4 @@ if (!isset($vars['replacement'])) { } ?> - -<div class="divider"> - <input type="submit" value="<?php echo elgg_echo('save'); ?>" /> -</div> </div> diff --git a/mod/notifications/views/default/notifications/subscriptions/groupsform.php b/mod/notifications/views/default/notifications/subscriptions/groupsform.php index bf75f5931..f1dbdcff8 100644 --- a/mod/notifications/views/default/notifications/subscriptions/groupsform.php +++ b/mod/notifications/views/default/notifications/subscriptions/groupsform.php @@ -1,102 +1,4 @@ -<?php -/** - * Elgg notifications groups subscription form - * - * @package ElggNotifications - */ +<?php -global $NOTIFICATION_HANDLERS; -foreach($NOTIFICATION_HANDLERS as $method => $foo) { - $subsbig[$method] = elgg_get_entities_from_relationship(array('relationship' => 'notify' . $method, 'relationship_guid' => get_loggedin_userid(), '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="user-settings 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> </td> -<?php - - $i = 0; - foreach($NOTIFICATION_HANDLERS as $method => $foo) { - if ($i > 0) { - echo "<td class='spacercolumn'> </td>"; - } -?> - <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td> -<?php - $i++; - } -?> - <td> </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\"> </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> </td> - </tr> -<?php - } -?> - </table> -<?php -} -?> - <input type="submit" value="<?php echo elgg_echo('save'); ?>" /> -</div> +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 d94edf9ef..ace622581 100644 --- a/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php +++ b/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php @@ -3,7 +3,7 @@ global $NOTIFICATION_HANDLERS; ?> - +<?php //@todo JS 1.8: no ?> <script type="text/javascript"> $(document).ready(function () { diff --git a/mod/notifications/views/default/notifications/subscriptions/personal.php b/mod/notifications/views/default/notifications/subscriptions/personal.php index 46c932f0b..cf05426e2 100644 --- a/mod/notifications/views/default/notifications/subscriptions/personal.php +++ b/mod/notifications/views/default/notifications/subscriptions/personal.php @@ -1,15 +1,23 @@ <?php +/** + * @uses $vars['user'] ElggUser + */ + +/* @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%"> +<table id="notificationstable" cellspacing="0" cellpadding="4" width="100%"> <tr> <td> </td> <?php @@ -38,7 +46,7 @@ foreach($NOTIFICATION_HANDLERS as $method => $foo) { $fields = ''; $i = 0; foreach($NOTIFICATION_HANDLERS as $method => $foo) { - if ($notification_settings = get_user_notification_settings(get_loggedin_userid())) { + if ($notification_settings = get_user_notification_settings($user->guid)) { if ($notification_settings->$method) { $personalchecked[$method] = 'checked="checked"'; } else { |
