diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/notifications/actions/save.php | 23 | ||||
-rw-r--r-- | mod/notifications/graphics/icon_notifications_email.gif | bin | 0 -> 1416 bytes | |||
-rw-r--r-- | mod/notifications/languages/en.php | 6 | ||||
-rw-r--r-- | mod/notifications/start.php | 5 | ||||
-rw-r--r-- | mod/notifications/views/default/notifications/css.php | 41 | ||||
-rw-r--r-- | mod/notifications/views/default/notifications/subscriptions/form.php | 68 | ||||
-rw-r--r-- | mod/notifications/views/default/notifications/subscriptions/forminternals.php | 340 |
7 files changed, 436 insertions, 47 deletions
diff --git a/mod/notifications/actions/save.php b/mod/notifications/actions/save.php index faee22ef6..3e50ffc11 100644 --- a/mod/notifications/actions/save.php +++ b/mod/notifications/actions/save.php @@ -1,9 +1,9 @@ <?php
/**
- * Elgg notifications plugin save action
+ * Elgg SMS Client
*
- * @package ElggNotifications
+ * @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-2009
@@ -13,17 +13,20 @@ // Restrict to logged in users
gatekeeper();
- // Get people
- $subscriptions = get_input('subscriptions');
-
- // Clear existing subscriptions
global $SESSION;
- remove_entity_relationships($SESSION['user']->guid,'notify',false);
+
+ global $NOTIFICATION_HANDLERS;
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subscriptions[$method] = get_input($method.'subscriptions');
+ remove_entity_relationships($SESSION['user']->guid,'notify' , $method, false);
+ }
// Add new ones
- if (is_array($subscriptions) && !empty($subscriptions)) {
- foreach($subscriptions as $subscription) {
- register_notification_interest($SESSION['user']->guid, $subscription);
+ foreach($subscriptions as $key => $subscription)
+ if (is_array($subscription) && !empty($subscription)) {
+ foreach($subscription as $subscriptionperson) {
+ // register_notification_interest($SESSION['user']->guid, $subscription);
+ add_entity_relationship($_SESSION['user']->guid, 'notify' . $key, $subscriptionperson);
}
}
diff --git a/mod/notifications/graphics/icon_notifications_email.gif b/mod/notifications/graphics/icon_notifications_email.gif Binary files differnew file mode 100644 index 000000000..038d6e651 --- /dev/null +++ b/mod/notifications/graphics/icon_notifications_email.gif diff --git a/mod/notifications/languages/en.php b/mod/notifications/languages/en.php index 8eb8ec834..db2d143b7 100644 --- a/mod/notifications/languages/en.php +++ b/mod/notifications/languages/en.php @@ -2,8 +2,10 @@ $english = array(
- 'notifications:subscriptions:changesettings' => 'Content subscriptions',
- 'notifications:subscriptions:description' => 'Content subscriptions allow you to be notified when one of your friends creates new content. To receive these notifications from your friends, make sure they are selected in the list below:',
+ 'notifications:subscriptions:changesettings' => 'Notifications',
+ 'notification:method:email' => 'Email',
+
+ '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:success' => 'Your subscriptions have been saved.',
diff --git a/mod/notifications/start.php b/mod/notifications/start.php index 4c8182990..22d4a0be0 100644 --- a/mod/notifications/start.php +++ b/mod/notifications/start.php @@ -20,8 +20,13 @@ if (get_context() == 'settings')
add_submenu_item(elgg_echo('notifications:subscriptions:changesettings'), $CONFIG->wwwroot . "mod/notifications/");
}
+
+ function notifications_plugin_init() {
+ extend_view('css','notifications/css');
+ }
register_elgg_event_handler('pagesetup','system','notifications_plugin_pagesetup',1000);
+ register_elgg_event_handler('init','system','notifications_plugin_init');
// Register action
global $CONFIG;
diff --git a/mod/notifications/views/default/notifications/css.php b/mod/notifications/views/default/notifications/css.php new file mode 100644 index 000000000..1c20a7b96 --- /dev/null +++ b/mod/notifications/views/default/notifications/css.php @@ -0,0 +1,41 @@ +#notificationstable td.namefield {
+ width:250px;
+ text-align: left;
+ vertical-align: middle;
+}
+#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(<?php echo $vars['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;
+}
\ No newline at end of file diff --git a/mod/notifications/views/default/notifications/subscriptions/form.php b/mod/notifications/views/default/notifications/subscriptions/form.php index 3533a6ac3..08e539e17 100644 --- a/mod/notifications/views/default/notifications/subscriptions/form.php +++ b/mod/notifications/views/default/notifications/subscriptions/form.php @@ -1,36 +1,34 @@ -<?php
-
- /**
- * Elgg notifications plugin settings form
- *
- * @package ElggNotifications
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008-2009
- * @link http://elgg.com/
- */
-
- // Get subscriptions
- $people = $vars['subscriptions'];
- if (empty($people) || !is_array($people))
- $people = array();
+<?php + + /** + * Elgg SMS Client + * + * @package ElggSMS + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2009 + * @link http://elgg.com/ + */ + + + // Echo title + echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings')); - // Echo title
- echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings'));
-
- // Display a description
-?>
- <p>
- <?php echo elgg_echo('notifications:subscriptions:description'); ?>
- </p>
-<?php
-
- // Get the friends picker and load it with our people subscriptions
- echo elgg_view('friends/picker',array(
- 'internalname' => 'subscriptions',
- 'entities' => get_user_friends($vars['user']->guid,'',9999,0),
- 'value' => $people,
- 'formtarget' => $vars['url'] . 'action/notificationsettings/save'
- ));
-
-?>
\ No newline at end of file + echo elgg_view('subscriptions/form/additions',$vars);
+ + // Display a description +?> +<div class="notification_methods"> + <p class="notification_methods_intro"> + <?php echo elgg_echo('notifications:subscriptions:description'); ?> + </p> +<?php + + echo elgg_view('input/form',array( + 'body' => elgg_view('notifications/subscriptions/forminternals'), + 'method' => 'post', + 'action' => $vars['url'] . 'action/notificationsettings/save', + )); + +?> +</div>
\ 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..122a00fb5 --- /dev/null +++ b/mod/notifications/views/default/notifications/subscriptions/forminternals.php @@ -0,0 +1,340 @@ +<?php + + // Get friends and subscriptions + $friends = get_user_friends($vars['user']->guid,'',9999,0);
+
+ global $NOTIFICATION_HANDLERS;
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+ $subsbig[$method] = get_entities_from_relationship('notify' . $method,$vars['user']->guid,false,'user','',0,'',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; + + // 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) { + + $letter = strtoupper(substr($user->name,0,1)); + if ($letter >= "0" && $letter <= "9") { + $letter = "0"; + } + if (!isset($users[$letter])) { + $users[$letter] = array(); + } + $users[$letter][$user->name] = $user; + + } + + if (!$callback) { + +?> + +<div class="friends_picker"> + +<?php + + if (isset($vars['content'])) echo $vars['content']; + + +?> + + <div id="friends_picker_placeholder<?php echo $friendspicker; ?>"> + +<?php + + } + + if (!isset($vars['replacement'])) { + + if ($formtarget) { +?> + + <script language="text/javascript"> + $(function() { // onload...do + $('#collectionMembersForm<?php echo $friendspicker; ?>').submit(function() { + var inputs = []; + $(':input', this).each(function() { + if (this.type != 'checkbox' || (this.type == 'checkbox' && this.checked != false)) { + inputs.push(this.name + '=' + escape(this.value)); + } + }); + jQuery.ajax({ + type: "POST", + data: inputs.join('&'), + url: this.action, + success: function(){ + $('a.collectionmembers<?php echo $friendspicker; ?>').click(); + } + + }); + return false; + }) + }) + + </script> + +<?php + + } + +?> +<script type="text/javascript"> + +$(document).ready(function () {
+<?php
+ 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
+ }
+?>
+ +}); +
+<?php
+ foreach($NOTIFICATION_HANDLERS as $method => $foo) {
+?>
+function adjust<?php echo $method; ?>(linkId) {
+ var obj = $(this).prev("a");
+
+ if (obj.className == "<?php echo $method; ?>toggleOff") {
+ obj.className = "<?php echo $method; ?>toggleOn";
+ } else {
+ obj.className = "<?php echo $method; ?>toggleOff";
+ }
+ return false;
+}
+function adjust<?php echo $method; ?>_alt(linkId) {
+ var obj = document.getElementById(linkId);
+
+ if (obj.className == "<?php echo $method; ?>toggleOff") {
+ obj.className = "<?php echo $method; ?>toggleOn";
+ $('#' + linkId).children("INPUT[type='checkbox']").attr('checked', true);
+ } else {
+ obj.className = "<?php echo $method; ?>toggleOff";
+ $('#' + linkId).children("INPUT[type='checkbox']").attr('checked', false);
+ }
+ return false;
+}
+<?php
+ }
+?> + +</script> + + + <div class="friendsPicker_wrapper"> + <div id="friendsPicker<?php echo $friendspicker; ?>"> + <div class="friendsPicker_container"> +<?php + + // Initialise letters + $letter = 'A'; + while (1 == 1) { +?> + <div class="panel" title="<?php echo $letter; ?>"> + <div class="wrapper"> + <h3><?php echo $letter; ?></h3> + +<?php + + if (isset($users[$letter])) { + ksort($users[$letter]); +?> + +<table id="notificationstable" cellspacing="0" cellpadding="4" border="1" 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 + + 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; +
+ $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\"> </td>";
+ $fields .= <<< END
+ <td class="{$method}togglefield">
+ <a href="#" 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++;
+ } +?> + + <tr> + <td class="namefield"><a href="<?php echo $friend->getURL(); ?>"> +<?php + echo elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny', 'override' => true)); +?> + </a><p class="namefieldlink"><a href="<?php echo $friend->getURL(); ?>"><?php echo $friend->name ?></p></td> + +<?php echo $fields; ?>
+ + <td> </td> + </tr> + + +<?php + } + } + +?> +</table> + +<?php + } + +?> + + </div> + </div> +<?php + if ($letter == 'Z') break; + $letter++; + } + +?> + </div> + </div> + </div> + +<?php + } else { + echo $vars['replacement']; + } + if (!$callback) { + +?> + + </div> +</div> + + +<?php + + } + +?> +<?php + if (!isset($vars['replacement'])) { +?> + +<script type="text/javascript"> + // initialise picker + $("div#friendsPicker<?php echo $friendspicker; ?>").friendsPicker(<?php echo $friendspicker; ?>); +</script> +<script> + $(document).ready(function () { + // manually add class to corresponding tab for panels that have content +<?php + if (sizeof($activeletters) > 0) + $chararray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + foreach($activeletters as $letter) { + $tab = strpos($chararray, $letter) + 1; +?> + $("div#friendsPickerNavigation<?php echo $friendspicker; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent"); +<?php + } + +?> + }); +</script> + +<?php + + } + +?> + + + +<div class="clearfloat"></div> +<div class="friendspicker_savebuttons"> + <input type="submit" value="<?php echo elgg_echo('save'); ?>" /> +<br /></div> + + +
\ No newline at end of file |