--- og_notifications/og_notifications.module +++ og_notifications/og_notifications.module @@ -12,37 +12,40 @@ /** * Implementation of hook_menu_() */ -function og_notifications_menu($may_cache) { - global $user; // we need the user to to build some urls +function og_notifications_menu() { $items = array(); - if (!$may_cache) { - if ($user->uid && arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'notifications' && ($user->uid == arg(1) || user_access('administer notifications'))) { - $account = ($user->uid == arg(1)) ? $user : user_load(array('uid' => arg(1))); - $items[] = array( - 'path' => 'user/'. $account->uid .'/notifications/group', - 'access' => user_access('subscribe to content in groups'), - 'title' => 'Groups', - 'callback' => 'drupal_get_form', - 'callback arguments' => array('og_notifications_user_page', $account), - 'type' => MENU_LOCAL_TASK, - 'weight' => 10 - ); - $items[] = array( - 'path' => 'user/'. $account->uid .'/notifications/grouptype', - 'access' => user_access('subscribe to content in groups'), - 'title' => 'Groups', - 'callback' => 'og_notifications_grouptype_user_page', - 'callback arguments' => array($account), - 'type' => MENU_CALLBACK - ); - } - } + $items['user/%user/notifications/group'] = array( + 'title' => 'Groups', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('og_notifications_user_page', 1), + 'access callback' => 'og_notifications_access_user', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'weight' => 10 + ); + $items['/user/%user/notifications/grouptype'] = array( + 'title' => 'Groups', + 'page callback' => 'og_notifications_grouptype_user_page', + 'page arguments' => array(1), + 'access callback' => 'og_notifications_access_user', + 'access arguments' => array(1), + 'type' => MENU_CALLBACK + ); return $items; } /** + * Menu access callback for user subscriptions + */ +function og_notifications_access_user($account) { + global $user; + return $account->uid && + ($user->uid == $account->uid && user_access('subscribe to content in groups') || user_access('administer notifications')); +} + +/** * Implementation of hook_perm() */ function og_notifications_perm() { @@ -52,7 +55,7 @@ function og_notifications_perm() { /** * Implementation of hook_form_alter(). */ -function og_notifications_form_alter($form_id, &$form) { +function og_notifications_form_alter(&$form, &$form_state, $form_id) { switch ($form_id) { case 'notifications_content_settings_form': $form['group'] = array(