From 4766f36a4d74924f21ff329c4318ce4e069ffa04 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 3 Mar 2010 17:53:05 +0000 Subject: Pulled in the interface changes. git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/notifications/actions/groupsave.php | 44 +++ mod/notifications/actions/save.php | 42 +++ .../graphics/icon_notifications_email.gif | Bin 0 -> 1416 bytes mod/notifications/groups.php | 42 +++ mod/notifications/index.php | 39 +++ mod/notifications/languages/en.php | 29 ++ mod/notifications/manifest.xml | 10 + mod/notifications/start.php | 47 +++ .../views/default/notifications/css.php | 78 +++++ .../notifications/settings/usersettings.php | 3 + .../notifications/subscriptions/collections.php | 141 +++++++++ .../default/notifications/subscriptions/form.php | 35 +++ .../notifications/subscriptions/forminternals.php | 315 +++++++++++++++++++++ .../notifications/subscriptions/groupsform.php | 99 +++++++ .../notifications/subscriptions/jsfuncs.php | 54 ++++ .../notifications/subscriptions/personal.php | 63 +++++ 16 files changed, 1041 insertions(+) create mode 100644 mod/notifications/actions/groupsave.php create mode 100644 mod/notifications/actions/save.php create mode 100644 mod/notifications/graphics/icon_notifications_email.gif create mode 100644 mod/notifications/groups.php create mode 100644 mod/notifications/index.php create mode 100644 mod/notifications/languages/en.php create mode 100644 mod/notifications/manifest.xml create mode 100644 mod/notifications/start.php create mode 100644 mod/notifications/views/default/notifications/css.php create mode 100644 mod/notifications/views/default/notifications/settings/usersettings.php create mode 100644 mod/notifications/views/default/notifications/subscriptions/collections.php create mode 100644 mod/notifications/views/default/notifications/subscriptions/form.php create mode 100644 mod/notifications/views/default/notifications/subscriptions/forminternals.php create mode 100644 mod/notifications/views/default/notifications/subscriptions/groupsform.php create mode 100644 mod/notifications/views/default/notifications/subscriptions/jsfuncs.php create mode 100644 mod/notifications/views/default/notifications/subscriptions/personal.php (limited to 'mod/notifications') diff --git a/mod/notifications/actions/groupsave.php b/mod/notifications/actions/groupsave.php new file mode 100644 index 000000000..ca250c7fd --- /dev/null +++ b/mod/notifications/actions/groupsave.php @@ -0,0 +1,44 @@ + '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); + } + } + + system_message(elgg_echo('notifications:subscriptions:success')); + + forward($_SERVER['HTTP_REFERER']); + +?> \ No newline at end of file diff --git a/mod/notifications/actions/save.php b/mod/notifications/actions/save.php new file mode 100644 index 000000000..a4a5903f9 --- /dev/null +++ b/mod/notifications/actions/save.php @@ -0,0 +1,42 @@ + $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); + } + } + + system_message(elgg_echo('notifications:subscriptions:success')); + + forward($_SERVER['HTTP_REFERER']); + +?> \ No newline at end of file diff --git a/mod/notifications/graphics/icon_notifications_email.gif b/mod/notifications/graphics/icon_notifications_email.gif new file mode 100644 index 000000000..038d6e651 Binary files /dev/null and b/mod/notifications/graphics/icon_notifications_email.gif differ diff --git a/mod/notifications/groups.php b/mod/notifications/groups.php new file mode 100644 index 000000000..a425845cf --- /dev/null +++ b/mod/notifications/groups.php @@ -0,0 +1,42 @@ + '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('two_column_left_sidebar','',$body); + + // Draw the page + page_draw(elgg_echo('notifications:subscriptions:changesettings:groups'),$body); + +?> \ No newline at end of file diff --git a/mod/notifications/index.php b/mod/notifications/index.php new file mode 100644 index 000000000..79365842c --- /dev/null +++ b/mod/notifications/index.php @@ -0,0 +1,39 @@ + '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('two_column_left_sidebar','',$body); + + // Draw the page + page_draw(elgg_echo('notifications:subscriptions:changesettings'),$body); + +?> \ No newline at end of file diff --git a/mod/notifications/languages/en.php b/mod/notifications/languages/en.php new file mode 100644 index 000000000..05c7da86a --- /dev/null +++ b/mod/notifications/languages/en.php @@ -0,0 +1,29 @@ + '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' => 'Toggle friends collections', + 'notifications:subscriptions:collections:description' => 'To toggle settings for members of your friends collections, use the icons 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 friends collections, click here.', + + 'notifications:subscriptions:changesettings' => 'Notifications', + 'notifications:subscriptions:changesettings:groups' => 'Group notifications', + 'notification:method:email' => 'Email', + + 'notifications:subscriptions:title' => 'Notifications per user', + 'notifications:subscriptions:description' => 'To receive notifications from your friends when they create new content, find them below and select the notification method you would like to use.', + + 'notifications:subscriptions:groups:description' => 'To receive notifications when new content is added to a group you are a member of, find it below and select the notification method you would like to use.', + + 'notifications:subscriptions:success' => 'Your notifications settings have been saved.', + + ); + + add_translation("en",$english); + +?> \ No newline at end of file diff --git a/mod/notifications/manifest.xml b/mod/notifications/manifest.xml new file mode 100644 index 000000000..d76abc6ae --- /dev/null +++ b/mod/notifications/manifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/mod/notifications/start.php b/mod/notifications/start.php new file mode 100644 index 000000000..a08fe68f5 --- /dev/null +++ b/mod/notifications/start.php @@ -0,0 +1,47 @@ +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]); + } + } + + register_elgg_event_handler('pagesetup','system','notifications_plugin_pagesetup',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 diff --git a/mod/notifications/views/default/notifications/css.php b/mod/notifications/views/default/notifications/css.php new file mode 100644 index 000000000..be1ef922c --- /dev/null +++ b/mod/notifications/views/default/notifications/css.php @@ -0,0 +1,78 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ + +?> + +#notificationstable td.namefield { + width:250px; + text-align: left; + vertical-align: middle; +} +#notificationstable td.namefield p { + margin:0; + vertical-align: middle; + line-height: 1.1em; + padding:5px 0 5px 0; +} +#notificationstable td.namefield img { + padding:6px 10px 6px 3px; + float:left; +} +#notificationstable td.namefield p.namefieldlink { + margin:9px 0 0 0; +} +#notificationstable td.emailtogglefield, +#notificationstable td.smstogglefield { + width:50px; + text-align: center; + vertical-align: middle; +} +#notificationstable td.spacercolumn { + width:30px; +} +#notificationstable td { + border-bottom: 1px solid silver; +} +#notificationstable td.emailtogglefield input { + margin-right:36px; + margin-top:5px; +} +#notificationstable td.emailtogglefield a { + width:46px; + height:24px; + cursor: pointer; + display: block; + outline: none; +} +#notificationstable td.emailtogglefield a.emailtoggleOff { + background: url(mod/notifications/graphics/icon_notifications_email.gif) no-repeat right 2px; +} +#notificationstable td.emailtogglefield a.emailtoggleOn { + background: url(mod/notifications/graphics/icon_notifications_email.gif) no-repeat right -36px; +} + +.notification_collections, +.notification_personal { + margin-bottom: 25px; +} + +.settings_form .friendsPicker_container h3 { + color:#999999; + font-size:3em; + margin:0 0 20px; + text-align:left; + background: none; + border-bottom: none; +} + + + diff --git a/mod/notifications/views/default/notifications/settings/usersettings.php b/mod/notifications/views/default/notifications/settings/usersettings.php new file mode 100644 index 000000000..15c5adc7f --- /dev/null +++ b/mod/notifications/views/default/notifications/settings/usersettings.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/mod/notifications/views/default/notifications/subscriptions/collections.php b/mod/notifications/views/default/notifications/subscriptions/collections.php new file mode 100644 index 000000000..8fe49e672 --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/collections.php @@ -0,0 +1,141 @@ + + + +

+ +

+
+

+ + +

+ + + + $foo) { + if ($i > 0) + echo ""; +?> + + + + +guid,'',9999,0)) { + foreach($friends as $friend) + $members[] = $friend->guid; + } + $memberno = sizeof($members); + $members = implode(',',$members); + +?> + + + $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 .= ""; + $fields .= <<< END + +END; + $i++; + } + echo $fields; + +?> + + +guid)) { + foreach($collections as $collection) { + $members = get_members_of_access_collection($collection->id, true); + $memberno = sizeof($members); + $members = implode(',',$members); + +?> + + + + $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 .= ""; + $fields .= <<< END + +END; + $i++; + } + echo $fields; + +?> + + + + +
   
+

+ () +

+
  + +  
+

+ name; ?> () +

+ +
  + +  
+
diff --git a/mod/notifications/views/default/notifications/subscriptions/form.php b/mod/notifications/views/default/notifications/subscriptions/form.php new file mode 100644 index 000000000..d96d6b7a7 --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/form.php @@ -0,0 +1,35 @@ + +
+
+ elgg_view('notifications/subscriptions/personal') . + elgg_view('notifications/subscriptions/collections') . + elgg_view('notifications/subscriptions/forminternals'), + 'method' => 'post', + 'action' => $vars['url'] . 'action/notificationsettings/save', + )); + +?> +
+
\ No newline at end of file diff --git a/mod/notifications/views/default/notifications/subscriptions/forminternals.php b/mod/notifications/views/default/notifications/subscriptions/forminternals.php new file mode 100644 index 000000000..673e30cc3 --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/forminternals.php @@ -0,0 +1,315 @@ +

+ +

+

+ +

+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)); + } + + $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']; + } + + // 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']; + } + + $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; + } + + // 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; + + } + + if (!$callback) { + +?> + +
+ + + +
+ + + + + + + + +
+
+
+ +
+
+

+ + + + + + + $foo) { + if ($i > 0) + echo ""; +?> + + + + + + 0) + foreach($users[$letter] as $friend) { + if ($friend instanceof ElggUser ) { + + if (!in_array($letter,$activeletters)) + $activeletters[] = $letter; + + $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 .= ""; + $fields .= <<< END + +END; + $i++; + } +?> + + + + + + + + + + + +
   
  + +
+ $friend, 'size' => 'tiny', 'override' => true)); +?> +  
+ + + +
+
+ +
+
+
+ + + +
+
+ + + + + + + + + + + + +
+
+ +
+ + + \ 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 new file mode 100644 index 000000000..cf7f44906 --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/groupsform.php @@ -0,0 +1,99 @@ + $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; + } + +?> + +
+
+ + + +

+ +

+ + + + + $foo) { + if ($i > 0) + echo ""; +?> + + + + + $foo) { + if (in_array($group->guid,$subsbig[$method])) { + $checked[$method] = 'checked="checked"'; + } else { + $checked[$method] = ''; + } + if ($i > 0) $fields .= ""; + $fields .= <<< END + +END; + $i++; + } + +?> + + + + + + +
   
  + +
+

+ name; ?> +

+
 
+ + + +
+
\ 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 new file mode 100644 index 000000000..da1598dae --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/jsfuncs.php @@ -0,0 +1,54 @@ + + + \ 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 new file mode 100644 index 000000000..6779fde73 --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/personal.php @@ -0,0 +1,63 @@ + +
+
+

+ +

+
+ + + + $foo) { + if ($i > 0) + echo ""; +?> + + + + + + + + $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 .= ""; + $fields .= <<< END + +END; + $i++; + } + echo $fields; + +?> + + + +
   
+

+ +

+ +
  + +  
+
\ No newline at end of file -- cgit v1.2.3