? uesr_list-other_menu.patch Index: user_list.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/user_list/user_list.module,v retrieving revision 1.20 diff -u -p -r1.20 user_list.module --- user_list.module 23 Dec 2008 18:41:11 -0000 1.20 +++ user_list.module 25 Jun 2010 18:06:33 -0000 @@ -1,5 +1,5 @@ User lists may be displayed alphabetically, beginning with A-Z, by newest, or as a list of users who have posted content of a certain type.

Go to !admin to change the global settings for user lists, and to !block to configure specific user listing blocks if desired. Note that all blocks provided by this module are appended with "User List:", so they may be differentiated by similar blocks provided by other modules.

Note that you must enable access to the user listings with the \'access user lists\' permission at !access, which controls viewing both blocks and pages. If enabled and allowed, the main user listing page may be viewed at !user_list.

', - array('!admin' => l('admin/settings/user_list', 'admin/settings/user_list'), '!block' => l('admin/build/block', 'admin/build/block'), '!access' => l('admin/user/permissions', 'admin/user/permissions'), '!user_list' => l('userlist', 'userlist')) + array('!admin' => l('admin/settings/user_list', 'admin/settings/user_list'), '!block' => l('admin/build/block', 'admin/build/block'), '!access' => l('admin/user/permissions', 'admin/user/permissions'), '!user_list' => l($userlist_path, $userlist_path)) ); } } @@ -78,6 +79,7 @@ function _user_list($op = 'all', $number else if ($op == 'content') { $types = variable_get('user_list_content_types', array()); } + if (drupal_strlen($op) == 1 && variable_get('user_list_alpha_listing', TRUE)) { $result = pager_query("SELECT u.uid, u.name FROM {users} u WHERE u.status <> 0 AND u.access <> 0 AND LOWER(u.name) LIKE '%s%%' ORDER BY u.name ASC", $number, $element_override, NULL, drupal_strtolower($op)); if ($include_more_link) { @@ -114,9 +116,9 @@ function _user_list($op = 'all', $number } else if ($op == 'other' && variable_get('user_list_alpha_listing', TRUE)) { $header = t('Users Not in A-Z'); - $result = pager_query("SELECT u.uid, u.name FROM {users} u WHERE (LOWER(u.name) < 'a' OR LOWER(u.name) > 'z') AND u.status <> 0 AND u.access <> 0 ORDER BY u.name ASC", $number, $element_override); + $result = pager_query("SELECT u.uid, u.name FROM {users} u WHERE (LOWER(SUBSTRING(u.name,1,1)) < 'a' OR LOWER(SUBSTRING(u.name,1,1)) > 'z') AND u.status <> 0 AND u.access <> 0 ORDER BY u.name ASC", $number, $element_override); if ($include_more_link) { - $count = db_result(db_query("SELECT COUNT(u.uid) FROM {users} u WHERE (LOWER(u.name) < 'a' OR LOWER(u.name) > 'z') AND u.status <> 0 AND u.access <> 0")); + $count = db_result(db_query("SELECT COUNT(u.uid) FROM {users} u WHERE (LOWER(SUBSTRING(u.name,1,1)) < 'a' OR LOWER(SUBSTRING(u.name,1,1)) > 'z') AND u.status <> 0 AND u.access <> 0")); } $empty_msg = t('There are currently no users with usernames not beginning with A-Z.'); } @@ -134,24 +136,29 @@ function _user_list($op = 'all', $number if ($include_more_link) { $include_more_link = ($count > $number ? $include_more_link : NULL); } - $output .= theme('user_list_list', $op, ($default_header === NULL ? $header : $default_header), $users, ($default_empty_msg === NULL ? $empty_msg : $default_empty_msg), $paginated, $number, $element_override, $include_more_link, $embedded_menu); + $output = theme('user_list_list', $op, ($default_header === NULL ? $header : $default_header), $users, ($default_empty_msg === NULL ? $empty_msg : $default_empty_msg), $paginated, $number, $element_override, $include_more_link, $embedded_menu); return $output; } function _user_list_page() { - if (arg(1) == 'content') { - return _user_list(arg(1), NULL, TRUE, FALSE, NULL, NULL, arg(2)); + $userlist_path = variable_get('user_list_menu_path', 'userlist'); + $elements = explode("/", $userlist_path); + $argnum = count($elements); + if (arg($argnum) == 'content') { + return _user_list(arg($argnum), NULL, TRUE, FALSE, NULL, NULL, arg($argnum+1)); } - else if (arg(1) == 'roles') { - return _user_list(arg(1), NULL, TRUE, FALSE, NULL, NULL, NULL, NULL, FALSE, NULL, arg(2)); + else if (arg($argnum) == 'roles') { + return _user_list(arg($argnum), NULL, TRUE, FALSE, NULL, NULL, NULL, NULL, FALSE, NULL, arg($argnum+1)); } - return _user_list(arg(1)); + return _user_list(arg($argnum)); } /** * Implementation of hook_menu(). */ function user_list_menu() { + $path = variable_get('user_list_menu_path', 'userlist'); + $items['admin/settings/user_list'] = array( 'title' => 'User list', 'description' => 'Change the format and types of user lists that appear on the site.', @@ -161,14 +168,14 @@ function user_list_menu() { 'type' => MENU_NORMAL_ITEM, ); if (variable_get('user_list_provide_page', TRUE)) { - $items['userlist'] = array( + $items[$path] = array( 'title' => 'User list', 'access arguments' => array('access user lists'), 'page callback' => '_user_list_page', 'type' => MENU_NORMAL_ITEM, ); if (variable_get('user_list_provide_menu', FALSE)) { - $items['userlist/all'] = array( + $items[$path.'/all'] = array( 'title' => 'all', 'access arguments' => array('access user lists'), 'page callback' => '_user_list_page', @@ -176,7 +183,7 @@ function user_list_menu() { 'weight' => -3, ); if (variable_get('user_list_newest', TRUE)) { - $items['userlist/newest'] = array( + $items[$path.'/newest'] = array( 'title' => 'newest', 'access arguments' => array('access user lists'), 'page callback' => '_user_list_page', @@ -188,7 +195,7 @@ function user_list_menu() { $letter = 'a'; do { $title = (variable_get('user_list_alpha_listing_caps', FALSE) ? drupal_strtoupper($letter) : $letter); - $items['userlist/'. $letter] = array( + $items[$path.'/'. $letter] = array( 'title' => '@letter', 'title arguments' => array('@letter' => $title), 'access arguments' => array('access user lists'), @@ -196,7 +203,7 @@ function user_list_menu() { 'type' => MENU_LOCAL_TASK, ); } while ($letter++ < 'z'); - $items['userlist/other'] = array( + $items[$path.'/other'] = array( 'title' => 'other', 'access arguments' => array('access user lists'), 'page callback' => '_user_list_page', @@ -206,7 +213,7 @@ function user_list_menu() { } foreach (variable_get('user_list_content_types', array()) as $type) { if ($name = node_get_types('name', $type)) { - $items['userlist/content/'. $type] = array( + $items[$path.'/content/'. $type] = array( 'title' => $name, 'access arguments' => array('access user lists'), 'page callback' => '_user_list_page', @@ -217,7 +224,7 @@ function user_list_menu() { } foreach (variable_get('user_list_role_types', array()) as $type) { if (_user_list_get_roles('base', $type)) { - $items['userlist/roles/'. $type] = array( + $items[$path.'/roles/'. $type] = array( 'title' => _user_list_get_roles('name', $type), 'access arguments' => array('access user lists'), 'page callback' => '_user_list_page', @@ -233,6 +240,7 @@ function user_list_menu() { function user_list_admin_settings() { $form = array(); + $userlist_path = variable_get('user_list_menu_path', 'userlist'); $form['user_list_default_number'] = array( '#type' => 'select', @@ -265,7 +273,7 @@ function user_list_admin_settings() { '#type' => 'checkbox', '#title' => t('Provide Alphabetical Listings'), '#default_value' => variable_get('user_list_alpha_listing', TRUE), - '#description' => t('If checked, then you may view users whose usernames begin with a specific letter of the alphabet, such as !a, !m, and !other for other than A-Z.', array('!a' => l('userlist/a', 'userlist/a'), '!m' => l('userlist/m', 'userlist/m'), '!other' => l('userlist/other', 'userlist/other'))), + '#description' => t('If checked, then you may view users whose usernames begin with a specific letter of the alphabet, such as !a, !m, and !other for other than A-Z.', array('!a' => l($userlist_path.'/a', $userlist_path.'/a'), '!m' => l($userlist_path.'/m', $userlist_path.'/m'), '!other' => l($userlist_path.'/other', $userlist_path.'/other'))), ); $form['user_list_types']['alpha_options']['user_list_alpha_listing_caps'] = array( '#type' => 'checkbox', @@ -290,7 +298,7 @@ function user_list_admin_settings() { '#default_value' => variable_get('user_list_content_types', array()), '#options' => $options, '#multiple' => TRUE, - '#description' => t('Select the node types you wish to allow user lists for. For instance, you may have a list of users who have written at least one blog entry at !blog, or who have contributed at least one image at !image.', array('!blog' => l('userlist/content/blog', 'userlist/content/blog'), '!image' => l('userlist/content/image', 'userlist/content/image'))), + '#description' => t('Select the node types you wish to allow user lists for. For instance, you may have a list of users who have written at least one blog entry at !blog, or who have contributed at least one image at !image.', array('!blog' => l($userlist_path.'/content/blog', $userlist_path.'/content/blog'), '!image' => l($userlist_path.'/content/image', $userlist_path.'/content/image'))), ); $form['user_list_types']['role_options'] = array( @@ -306,7 +314,7 @@ function user_list_admin_settings() { '#default_value' => variable_get('user_list_role_types', array()), '#options' => $options, '#multiple' => TRUE, - '#description' => t('Select the roles you wish to allow user lists for. For instance, you may have a list of users who are of the %role role at !role_dest. NOTE: Spaces in role names are converted to underscore, but does not affect the role table.', array('%role' => current($options), '!role_dest' => l('userlist/roles/'. current($options), 'userlist/roles/'. current($options)))), + '#description' => t('Select the roles you wish to allow user lists for. For instance, you may have a list of users who are of the %role role at !role_dest. NOTE: Spaces in role names are converted to underscore, but does not affect the role table.', array('%role' => current($options), '!role_dest' => l($userlist_path.'/roles/'. current($options), $userlist_path.'/roles/'. current($options)))), ); $form['user_list_menu_settings'] = array( @@ -319,7 +327,8 @@ function user_list_admin_settings() { '#type' => 'checkbox', '#title' => t('Provide User Listing Page'), '#default_value' => variable_get('user_list_provide_page', TRUE), - '#description' => t('If checked, a user listing page will be provided, along with an item in the menu (which may be renamed, moved, or disabled at !admin_menu). Note that when enabled, the profile module also provides a basic user listing page with the same title of \'user list\', although its path is different and it is not listed in the menu by default. This module\'s path is !userlist, while that of the profile module is !profile.', array('!admin_menu' => l('admin/build/menu', 'admin/build/menu'), '!userlist' => l('userlist', 'userlist'), '!profile' => l('profile', 'profile'))), + '#description' => t('If checked, a user listing page will be provided, along with an item in the menu (which may be renamed, moved, or disabled at !admin_menu). Note that when enabled, the profile module also provides a basic user listing page with the same title of \'user list\', although its path is different and it is not listed in the menu by default. This module\'s path is !userlist, while that of the profile module is !profile.', array('!admin_menu' => l('admin/build/menu', 'admin/build/menu'), '!userlist' => l($userlist_path, $userlist_path), + '!profile' => l('profile', 'profile'))), ); $form['user_list_menu_settings']['user_list_embed_menu'] = array( '#type' => 'checkbox', @@ -333,6 +342,12 @@ function user_list_admin_settings() { '#default_value' => variable_get('user_list_provide_menu', FALSE), '#description' => t('If checked, a menu tab will be displayed on the user list page. Note that if the alphabetical listings are provided, this menu tab will be quite long (at least 28 available options), and will most certainly require custom theming. Customizing the theme for menu tabs in Drupal 4.7 is a tricky prospect, so unless you require this functionality and are prepared to do the custom work, it is suggested you leave this item disabled and enable the embedded menu instead, which comes with a more manageable theme and is easier to customize.'), ); + $form['user_list_menu_settings']['user_list_menu_path'] = array( + '#type' => 'textfield', + '#title' => t('Menu path'), + '#default_value' => $userlist_path, + '#description' => t('Choose the menu path you want userlist to use.'), + ); menu_rebuild(); return system_settings_form($form); } @@ -407,33 +422,34 @@ function user_list_block($op = 'list', $ break; case 'view': if (user_access('access user lists')) { + $userlist_path = variable_get('user_list_menu_path', 'userlist'); $number = variable_get('user_list_block_number_'. $delta, variable_get('user_list_default_number', 10)); $include_more = variable_get('user_list_block_more_'. $delta, TRUE); $embed_menu = variable_get('user_list_block_embed_'. $delta, FALSE); if ($delta == 'all') { if ($include_more) { - $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), 'userlist'); + $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), $userlist_path); } $block['subject'] = variable_get('user_list_block_header_'. $delta, t('All Users')); $block['content'] = _user_list('all', $number, FALSE, $include_more, '', NULL, NULL, $embed_menu, TRUE); } else if ($delta == 'newest') { if ($include_more) { - $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), 'userlist/newest'); + $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), $userlist_path.'/newest'); } $block['subject'] = variable_get('user_list_block_header_'. $delta, t('Recent Users')); $block['content'] = _user_list('newest', $number, FALSE, $include_more, '', NULL, NULL, $embed_menu, TRUE); } else if (in_array($delta, variable_get('user_list_content_types', array()))) { if ($include_more) { - $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), 'userlist/content/'. $delta); + $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), $userlist_path.'/content/'. $delta); } $block['subject'] = variable_get('user_list_block_header_'. $delta, t('Users who have contributed at least one @content', array('@content' => node_get_types('name', $delta)))); $block['content'] = _user_list('content', $number, FALSE, $include_more, '', NULL, $delta, $embed_menu, TRUE); } else if (in_array($delta, variable_get('user_list_role_types', array()))) { if ($include_more) { - $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), 'userlist/roles/'. $delta); + $include_more = l(variable_get('user_list_block_more_msg_'. $delta, t('View More')), $userlist_path.'/roles/'. $delta); } $block['subject'] = variable_get('user_list_block_header_'. $delta, t('Users of the %role role', array('%role' => _user_list_get_roles('name', $delta)))); $block['content'] = _user_list('roles', $number, FALSE, $include_more, '', NULL, NULL, $embed_menu, TRUE, NULL, $delta); @@ -444,13 +460,14 @@ function user_list_block($op = 'list', $ } function _user_list_embedded_menu($args = array()) { + $userlist_path = variable_get('user_list_menu_path', 'userlist'); $items['all'] = array( - 'path' => 'userlist', + 'path' => $userlist_path, 'title' => t('all'), ); if (variable_get('user_list_newest', TRUE)) { $items['newest'] = array( - 'path' => 'userlist/newest', + 'path' => $userlist_path.'/newest', 'title' => t('newest'), ); } @@ -459,7 +476,7 @@ function _user_list_embedded_menu($args do { $title = (variable_get('user_list_alpha_listing_caps', FALSE) ? drupal_strtoupper($letter) : $letter); $items[$letter] = array( - 'path' => 'userlist/'. $letter, + 'path' => $userlist_path.'/'. $letter, 'title' => t('@letter', array('@letter' => $title)), ); if ($args[1] == $letter) { @@ -468,7 +485,7 @@ function _user_list_embedded_menu($args } } while ($letter++ < 'z'); $items['other'] = array( - 'path' => 'userlist/other', + 'path' => $userlist_path.'/other', 'title' => t('other'), ); if ($args[1] == 'other') { @@ -479,7 +496,7 @@ function _user_list_embedded_menu($args foreach (variable_get('user_list_content_types', array()) as $type) { if ($name = node_get_types('type', $type)) { $items[$type] = array( - 'path' => 'userlist/content/'. $type, + 'path' => $userlist_path.'/content/'. $type, 'title' => $name->name, ); if ($args[1] == 'content' && $args[2] == $type) { @@ -491,7 +508,7 @@ function _user_list_embedded_menu($args foreach (variable_get('user_list_role_types', array()) as $type) { if (_user_list_get_roles('base', $type)) { $items[$type] = array( - 'path' => 'userlist/roles/'. $type, + 'path' => $userlist_path.'/roles/'. $type, 'title' => _user_list_get_roles('name', $type), ); if ($args[1] == 'roles' && $args[2] == $type) { @@ -500,7 +517,7 @@ function _user_list_embedded_menu($args } } } - if (!$active) { + if (!isset($active)) { $items['all']['active'] = TRUE; $active = 'all'; } @@ -521,14 +538,16 @@ function user_list_theme() { function theme_user_list_menu($items) { drupal_add_css(drupal_get_path('module', 'user_list') .'/user_list.css'); + $output = ''; foreach ($items as $item) { - $output .= '
  • '. l(t($item['title']), $item['path']) ."
  • \n"; + $output .= '
  • '. l(t($item['title']), $item['path']) ."
  • \n"; } return "
    \n
    '; } function theme_user_list_list($op = '', $header = '', $users = array(), $empty_msg = 'There are currently no users in this category to list.', $paginated = FALSE, $number = 10, $element = 0, $include_more = NULL, $embedded_menu = '') { drupal_add_css(drupal_get_path('module', 'user_list') .'/user_list.css'); + $output = ''; $output .= "
    \n"; if ($header) { $output .= '

    '. $header ."

    \n "; @@ -591,7 +610,9 @@ function _user_list_get_roles($op = 'get } else if ($op == 'name') { $roles = db_fetch_object($result); - return $roles->name; + if (isset($roles->name)) { + return $roles->name; + } } } else {