aboutsummaryrefslogtreecommitdiff
path: root/mod/notifications/start.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/notifications/start.php')
-rw-r--r--mod/notifications/start.php83
1 files changed, 55 insertions, 28 deletions
diff --git a/mod/notifications/start.php b/mod/notifications/start.php
index 307cfa936..b76b0aa1e 100644
--- a/mod/notifications/start.php
+++ b/mod/notifications/start.php
@@ -1,58 +1,75 @@
<?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','notifications/css');
+ elgg_extend_view('css/elgg','notifications/css');
- register_page_handler('notifications', 'notifications_page_handler');
+ elgg_register_page_handler('notifications', 'notifications_page_handler');
- register_elgg_event_handler('pagesetup', 'system', 'notifications_plugin_pagesetup');
+ elgg_register_event_handler('pagesetup', 'system', 'notifications_plugin_pagesetup');
// Unset the default notification settings
- unregister_plugin_hook('usersettings:save', 'user', 'notification_user_settings_save');
- elgg_unextend_view('usersettings/user', 'notifications/settings/usersettings');
+ 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
- register_elgg_event_handler('delete', 'member', 'notifications_relationship_remove');
- register_elgg_event_handler('delete', 'friend', 'notifications_relationship_remove');
+ 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
- register_elgg_event_handler('create', 'friend', 'notifications_update_friend_notify');
- register_plugin_hook('access:collections:add_user', 'collection', 'notifications_update_collection_notify');
+ 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) {
- 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 (get_context() == 'settings') {
- add_submenu_item(elgg_echo('notifications:subscriptions:changesettings'), elgg_get_site_url() . "pg/notifications/personal");
- if (is_plugin_enabled('groups')) {
- add_submenu_item(elgg_echo('notifications:subscriptions:changesettings:groups'), elgg_get_site_url() . "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);
}
}
}
@@ -171,9 +204,3 @@ function notifications_update_collection_notify($event, $object_type, $returnval
}
}
}
-
-register_elgg_event_handler('init', 'system', 'notifications_plugin_init', 1000);
-
-
-register_action("notificationsettings/save", FALSE, $CONFIG->pluginspath . "notifications/actions/save.php");
-register_action("notificationsettings/groupsave", FALSE, $CONFIG->pluginspath . "notifications/actions/groupsave.php");