*************** *** 1,5 **** 'admin/settings/privatemsg', - 'title' => t('Privatemsg'), - 'description' => t('Configure Privatemsg settings.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_configure'), - 'access' => user_access('administer private messages'), - ); - $items[] = array( - 'path' => 'privatemsg', - 'title' => t('Private messages'), - 'callback' => 'privatemsg_list', - 'access' => !$user->uid || $access, - 'type' => MENU_SUGGESTED_ITEM, - ); - $items[] = array( - 'path' => 'privatemsg/list', - 'title' => t('List'), - 'callback' => 'privatemsg_list', - 'callback arguments' => array(NULL), - 'access' => !$user->uid || $access, - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - $items[] = array( - 'path' => 'privatemsg/new', - 'title' => t('Compose'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_new_form'), - 'access' => $access, - 'type' => MENU_LOCAL_TASK, - 'weight' => -5, - ); - $items[] = array( - 'path' => 'privatemsg/contacts', - 'title' => t('Contacts'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_contacts_form'), - 'access' => $access, - 'type' => MENU_LOCAL_TASK, - 'weight' => 0, - ); - $items[] = array( - 'path' => 'privatemsg/folders', - 'title' => t('Manage folders'), - 'callback' => 'privatemsg_manage_folders', - 'access' => $access && $user->uid, - 'type' => MENU_LOCAL_TASK, - 'weight' => 5, - ); - $items[] = array( - 'path' => 'privatemsg/folders/movetonew', - 'title' => t('Move to new folder'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_new_folder_form'), - 'access' => user_access('create new folder') && $user->uid, - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'privatemsg/autocomplete', - 'title' => t('Privatemsg autocomplete'), - 'callback' => 'privatemsg_autocomplete', - 'access' => $access, - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'privatemsg/delete', - 'callback' => 'privatemsg_delete', - 'access' => $access && $user->uid, // No guest access - 'type' => MENU_CALLBACK - ); - } - else { - if (!isset($user->privatemsg_allow)) { - _privatemsg_user_add_defaults($user); - } - if (arg(0) == 'privatemsg' && arg(1) == 'view' && intval(arg(2)) > 0) { - $items[] = array( - 'path' => 'privatemsg/view/'. arg(2), - 'title' => t('Read message'), - 'callback' => 'privatemsg_view', - 'callback arguments' => array(intval(arg(2)), FALSE), - 'access' => $access && $user->uid, // Check access/redirect in callback - 'type' => MENU_CALLBACK, - 'weight' => -10, - ); - $items[] = array( - 'path' => 'privatemsg/view/'. arg(2) .'/read', - 'title' => t('Read message'), - 'access' => $access && $user->uid, // Check access/redirect in callback - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - $items[] = array( - 'path' => 'privatemsg/view/'. arg(2) .'/back', - 'title' => t('Back to list'), - 'callback' => 'privatemsg_back_to_list', - 'callback arguments' => array(intval(arg(2))), - 'access' => TRUE, // Check access/redirect in callback - 'type' => MENU_LOCAL_TASK, - 'weight' => 0, - ); - } - - if (arg(0) == 'privatemsg' && arg(1) == 'reply' && intval(arg(2)) > 0) { - $items[] = array( - 'path' => 'privatemsg/reply/'. arg(2), - 'title' => t('Write a reply'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_new_form'), - 'access' => $access, - 'type' => MENU_CALLBACK, - ); - } - - if (arg(0) == 'privatemsg' && arg(1) == 'new' && intval(arg(2)) > 0) { - $items[] = array( - 'path' => 'privatemsg/new/'. arg(2), - 'title' => t('Write a new message'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_new_form'), - 'access' => $access, - 'type' => MENU_CALLBACK, - ); - } - if ($user-> uid != arg(2) && arg(0) == 'privatemsg' && arg(1) == 'block' && ($account = user_load(array('uid' => arg(2))))) { - $blocked = privatemsg_user_blocked($account->uid); - $title_args = array('@user' => $account->name); - $items[] = array( - 'path' => 'privatemsg/block/'. arg(2), - 'title' => $blocked ? t('Unblock @user', $title_args) : t('Block @user', $title_args), - 'callback' => 'drupal_get_form', - 'callback arguments' => array($blocked ? 'privatemsg_unblock_user_form' : 'privatemsg_block_user_form', $account), - 'type' => MENU_CALLBACK, - ); - } - - $new = _privatemsg_get_new_messages(); - $items[] = array( - 'path' => 'privatemsg/inbox', - 'title' => variable_get('privatemsg_menu_link', t('My inbox')) . ($new ? ' ('. $new .')' : ''), - 'callback' => 'drupal_goto', - 'callback arguments' => array('privatemsg'), - 'type' => $user->uid && $user->privatemsg_allow ? MENU_DYNAMIC_ITEM : MENU_CALLBACK, - ); - - if ($new && strncmp($_GET['q'], 'privatemsg', 10) && $user->privatemsg_setmessage_notify && user_access('access private messages')) { - $m = drupal_set_message(); - if (empty($m)) { - drupal_set_message(strtr(format_plural($new, 'You have a new private message.', 'You have @count new private messages.'), array('!url' => url('privatemsg')))); - } - } - - if (arg(0) == 'privatemsg' && arg(1) == 'folders' && intval(arg(2)) > 1) { - $modify_folder = privatemsg_folder_access($user->uid, arg(2)); - if (!$modify_folder) { - drupal_goto('privatemsg/folders'); - } - - $items[] = array( - 'path' => 'privatemsg/folders/'. arg(2) .'/rename', - 'title' => t('Rename folder'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_rename_folder_form', arg(2)), - 'access' => $access, - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'privatemsg/folders/'. arg(2) .'/empty', - 'title' => t('Empty folder?'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_empty_folder_form', arg(2)), - 'access' => $access, - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'privatemsg/folders/'. arg(2) .'/delete', - 'title' => t('Delete folder?'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('privatemsg_delete_folder_form', arg(2)), - 'access' => $access, - 'type' => MENU_CALLBACK, - ); - } - if (is_numeric(arg(1)) && (arg(0) == 'privatemsg' || arg(0) == 'user') && ($user->uid == arg(1) || user_access('administer private messages'))) { - if (arg(0) == 'user' && arg(2) == 'privatemsg') { - $account = $user->uid == arg(1) ? $user : user_load(array('uid' => arg(1))); - $items[] = array( - 'path' => 'user/'. arg(1) .'/privatemsg', - 'title' => t('Privatemsg'), - 'callback' => 'privatemsg_list', - 'callback arguments' => array(arg(1)), - 'access' => $account->privatemsg_allow, - 'type' => MENU_LOCAL_TASK, - ); - } - if (arg(0) == 'privatemsg') { - if ($user->uid == arg(1)) { - $account = $user; - $title = t('Private messages'); - } - else { - $account = user_load(array('uid' => arg(1))); - $title = t('Private messages for @name', array('@name' => $account->name)); - } - $items[] = array( - 'path' => 'privatemsg/'. arg(1), - 'title' => $title, - 'callback' => 'privatemsg_list', - 'callback arguments' => array(arg(1)), - 'access' => $account->privatemsg_allow, - 'type' => MENU_CALLBACK, - ); - } - } - - drupal_add_css('./'. drupal_get_path('module', 'privatemsg') .'/privatemsg.css'); - } return $items; } --- 27,228 ---- /** * Implementation of hook_menu(). */ + function privatemsg_menu() { global $user; $items = array(); + $items['admin/settings/privatemsg'] = array( + 'title' => 'Privatemsg', + 'description' => 'Configure Privatemsg settings.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_configure'), + 'access arguments' => array('administer private messages'), + ); + $items['privatemsg'] = array( + 'title' => privatemsg_get_inbox_title(), + 'title callback' => 'privatemsg_get_inbox_title', + 'page callback' => 'privatemsg_list', + 'page arguments' => array(NULL), + 'access callback' => 'privatemsg_special_access1', + 'type' => MENU_SUGGESTED_ITEM, + ); + $items['privatemsg/list'] = array( + 'title' => privatemsg_get_inbox_title(), + 'page callback' => 'privatemsg_list', + 'page arguments' => array(NULL), + 'access callback' => 'privatemsg_special_access1', + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + $items['privatemsg/new'] = array( + 'title' => 'Compose', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_new_form'), + 'access arguments' => array('administer private messages'), + 'type' => MENU_LOCAL_TASK, + 'weight' => -5, + ); + $items['privatemsg/contacts'] = array( + 'title' => 'Contacts', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_contacts_form'), + 'access arguments' => array('administer private messages'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 0, + ); + $items['privatemsg/folders'] = array( + 'title' => 'Manage folders', + 'page callback' => 'privatemsg_manage_folders', + 'access callback' => 'privatemsg_special_access2', + 'type' => MENU_LOCAL_TASK, + 'weight' => 5, + ); + $items['privatemsg/folders/movetonew'] = array( + 'title' => 'Move to new folder', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_new_folder_form'), + 'access callback' => 'privatemsg_special_access3', + 'type' => MENU_CALLBACK, + ); + $items['privatemsg/autocomplete'] = array( + 'title' => 'Privatemsg autocomplete', + 'page callback' => 'privatemsg_autocomplete', + 'access arguments' => array('administer private messages'), + 'type' => MENU_CALLBACK, + ); + $items['privatemsg/delete'] = array( + 'page callback' => 'privatemsg_delete', + 'access callback' => 'privatemsg_special_access2', + 'type' => MENU_CALLBACK, + ); + + + $items['privatemsg/view/%privatemsg'] = array( + 'title' => 'Read message', + 'page callback' => 'privatemsg_view', + 'page arguments' => array(2, FALSE), + 'access callback' => 'privatemsg_special_access2', + 'type' => MENU_CALLBACK, + 'weight' => -10, + ); + $items['privatemsg/view/%privatemsg/read'] = array( + 'title' => 'Read message', + 'access callback' => 'privatemsg_special_access2', + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + $items['privatemsg/view/%/back'] = array( + 'title' => 'Back to list', + 'page callback' => 'privatemsg_back_to_list', + 'page arguments' => array(2), + 'access callback' => 'privatemsg_return_true', + 'type' => MENU_LOCAL_TASK, + 'weight' => 0, + ); + + $items['privatemsg/reply/%'] = array( + 'title' => 'Write a reply', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_new_form', 2), + 'access arguments' => array('administer private messages'), + 'type' => MENU_CALLBACK, + ); + $items['privatemsg/reply/%/write'] = array( + 'title' => 'Write a reply', + 'access arguments' => array('administer private messages'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + $items['privatemsg/reply/%/cancel'] = array( + 'title' => 'Cancel reply', + 'page callback' => 'privatemsg_cancel_reply', + 'page arguments' => array(2), + 'access callback' => 'privatemsg_special_access2', + 'type' => MENU_LOCAL_TASK, + 'weight' => 0, + ); + + $items['privatemsg/new/%'] = array( + 'title' => 'Write a new message', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_new_form'), + 'access arguments' => array('administer private messages'), + 'type' => MENU_CALLBACK, + ); + $items['privatemsg/new/%/write'] = array( + 'title' => 'Write a new message', + 'access arguments' => array('administer private messages'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + $items['privatemsg/new/%/cancel'] = array( + 'title' => 'Cancel message', + 'page callback' => 'drupal_goto', + 'page arguments' => array('privatemsg'), + 'access callback' => 'privatemsg_special_access2', + 'type' => MENU_LOCAL_TASK, + 'weight' => 0, + ); + + $items['privatemsg/block/%user'] = array( + 'title callback' => 'privatemsg_get_block_title', + 'title arguments' => array(2), + 'page callback' => 'privatemsg_get_block_form', + 'page arguments' => array(2), + 'type' => MENU_CALLBACK, + ); + + $items['privatemsg/inbox'] = array( + 'title callback' => 'privatemsg_get_inbox_title', + 'title arguments' => array(), + 'page callback' => 'drupal_goto', + 'page arguments' => array('privatemsg'), + 'type' => MENU_CALLBACK, + ); + + $items['privatemsg/folders/%/rename'] = array( + 'title' => 'Rename folder', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_rename_folder_form', 2), + 'access callback' => 'privatemsg_administer_folder_permission', + 'access arguments' => array(2), + 'type' => MENU_CALLBACK, + ); + $items['privatemsg/folders/%/empty'] = array( + 'title' => 'Empty folder?', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_empty_folder_form', 2), + 'access callback' => 'privatemsg_administer_folder_permission', + 'access arguments' => array(2), + 'type' => MENU_CALLBACK, + ); + $items['privatemsg/folders/%/delete'] = array( + 'title' => 'Delete folder?', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('privatemsg_delete_folder_form', 2), + 'access callback' => 'privatemsg_administer_folder_permission', + 'access arguments' => array(2), + 'type' => MENU_CALLBACK, + ); + + $items['user/%user/privatemsg'] = array( + 'title' => 'Privatemsg', + 'page callback' => 'privatemsg_list', + 'page arguments' => array(1), + 'access callback' => 'privatemsg_special_access6', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + ); + $items['privatemsg/%user'] = array( + 'title callback' => 'privatemsg_get_title', + 'title arguments' => array(1), + 'page callback' => 'privatemsg_list', + 'page arguments' => array(1), + 'access callback' => 'privatemsg_special_access6', + 'access arguments' => array(1), + 'type' => MENU_CALLBACK, + ); return $items; } *************** *** 869,874 **** $extra_folders[$folder['fid']] = $folder['name']; } } if (user_access('create new folder')) { $extra_folders['new'] = t('New folder...'); } --- 853,859 ---- $extra_folders[$folder['fid']] = $folder['name']; } } + if (user_access('create new folder')) { $extra_folders['new'] = t('New folder...'); } *************** *** 964,980 **** ); } if ($del == 1) { $form['selected']['actions'] = $actions; } - // Control to move messages to a new folder. Display only for inbox and - // custom folders. - if ((arg(1) == NULL || arg(1) == 'list') && count($extra_folders) > 0 && $current_folder != PRIVATEMSG_FOLDER_RECYCLE_BIN && $current_folder != PRIVATEMSG_FOLDER_SENT) { - // Do not display the recycle bin in the move to folder drop down as the - // delete button is already available. - unset($extra_folders[PRIVATEMSG_FOLDER_RECYCLE_BIN]); - $form['selected']['folder'] = array( '#prefix' => '