diff --git a/devel.module b/devel.module index f91bc299e7ee7c0353904a2878d7d0c91decea70..e819d1206f75e53c30fb75865131a954437ab06a 100644 --- a/devel.module +++ b/devel.module @@ -302,13 +302,26 @@ function devel_perm() { /** * Implementation of hook_block(). */ -function devel_block($op = 'list', $delta = 0) { +function devel_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { $blocks[0]['info'] = t('Switch user'); $blocks[1]['info'] = t('Devel'); $blocks[2]['info'] = t('Execute PHP'); return $blocks; } + else if ($op == 'configure' && $delta == 0) { + $form['devel_switch_user_list_size'] = array( + '#type' => 'textfield', + '#title' => t('Number of users to display in the list'), + '#default_value' => variable_get('devel_switch_user_list_size', 10), + '#size' => '3', + '#maxlength' => '4', + ); + return $form; + } + else if ($op == 'save' && $delta == 0) { + variable_set('devel_switch_user_list_size', $edit['devel_switch_user_list_size']); + } else if ($op == 'view') { switch ($delta) { case 0: @@ -356,14 +369,15 @@ function devel_block($op = 'list', $delta = 0) { function devel_switch_user_list() { $links = array(); if (user_access('switch users')) { + $list_size = variable_get('devel_switch_user_list_size', 10); $dest = drupal_get_destination(); - // Try to find at least 10 users that can switch. + // Try to find at least $list_size users that can switch. $roles = user_roles(1, 'switch users'); if (isset($roles[2])) { // If authenticated users have this permission, just grab - // the last 10 users, since there won't be records in + // the last $list_size users, since there won't be records in // {user_roles} and every user on the system can switch. - $users = db_query_range("SELECT DISTINCT u.uid, u.name, u.access FROM {users} u WHERE u.uid > 0 ORDER BY u.access DESC", 0, 10); + $users = db_query_range("SELECT DISTINCT u.uid, u.name, u.access FROM {users} u WHERE u.uid > 0 ORDER BY u.access DESC", 0, $list_size); } else { $where = array('u.uid = 1'); @@ -371,16 +385,16 @@ function devel_switch_user_list() { $where[] = 'r.rid IN ('. implode(',', array_keys($roles)) .')'; } $where_sql = implode(' OR ', $where); - $users = db_query_range("SELECT DISTINCT u.uid, u.name, u.access FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE $where_sql ORDER BY u.access DESC", 0, 10); + $users = db_query_range("SELECT DISTINCT u.uid, u.name, u.access FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE $where_sql ORDER BY u.access DESC", 0, $list_size); } while ($user = db_fetch_object($users)) { $links[$user->uid] = l(theme('placeholder', $user->name), 'devel/switch/'. $user->name, array('title' => t('This user can switch back.')), $dest, NULL, FALSE, TRUE); } $num_links = count($links); - if ($num_links < 10) { - // If we don't have enough, add distinct uids until we hit 10. - $users = db_query_range('SELECT uid, name, access FROM {users} WHERE uid > 0 AND uid NOT IN ('. implode(',', array_keys($links)) .') ORDER BY access DESC', 0, 10 - $num_links); - while (($user = db_fetch_object($users)) && count($links) < 10) { + if ($num_links < $list_size) { + // If we don't have enough, add distinct uids until we hit $list_size. + $users = db_query_range('SELECT uid, name, access FROM {users} WHERE uid > 0 AND uid NOT IN ('. implode(',', array_keys($links)) .') ORDER BY access DESC', 0, $list_size - $num_links); + while (($user = db_fetch_object($users)) && count($links) < $list_size) { $links[$user->uid] = l($user->name, 'devel/switch/'. $user->name, array('title' => t('Caution: this user will be unable to switch back.')), $dest); } } @@ -392,8 +406,9 @@ function devel_switch_user_form() { $form['username'] = array( '#type' => 'textfield', '#description' => t('Enter username'), + '#autocomplete_path' => 'user/autocomplete', + '#maxlength' => USERNAME_MAX_LENGTH, '#size' => 16, - '#maxlength' => 255, ); $form['submit'] = array( '#type' => 'submit', @@ -447,7 +462,7 @@ function devel_exit($destination = NULL) { if (isset($destination)) { // The page we are leaving is a drupal_goto(). Present a redirection page // so that the developer can see the intermediate query log. - if (isset($user) && user_access('access devel information') && variable_get('devel_redirect_page', 0)) { + if (isset($user) && function_exists('user_access') && user_access('access devel information') && variable_get('devel_redirect_page', 0)) { $output = t('

The user is being redirected to @destination.

', array('@destination' => $destination)); print theme('page', $output); @@ -610,10 +625,18 @@ function devel_db_query($query) { function devel_admin_settings() { $form['queries'] = array('#type' => 'fieldset', '#title' => t('Query log')); + + $description = t("Collect query info. If disabled, no query log functionality will work."); + if (extension_loaded('Zend Optimizer')) { + $description = t('You must disable the php Zend Optimizer extension in order to enable this feature. Zend Optimizer is horribly buggy and segfaults your Apache ... ', array('!url' => url('http://drupal.org/node/126098'))). $description; + } $form['queries']['dev_query'] = array('#type' => 'checkbox', '#title' => t('Collect query info'), '#default_value' => variable_get('dev_query', 0), - '#description' => t("Collect query info. If disabled, no query log functionality will work.")); + '#description' =>$description, + '#disabled' => extension_loaded('Zend Optimizer') ? TRUE : FALSE, + ); + $form['queries']['devel_query_display'] = array('#type' => 'checkbox', '#title' => t('Display query log'), '#default_value' => variable_get('devel_query_display', 0), diff --git a/macro.module b/macro.module index 56c1894a795d1bd3771c26f6ae97ad2afb4668fd..079ddcbe2979d1f51feddd017be453d90161d4fb 100644 --- a/macro.module +++ b/macro.module @@ -74,7 +74,7 @@ function macro_menu($may_cache) { * Implementation of hook_perm(). */ function macro_perm() { - return array('macro access'); + return array('administer macro settings', 'macro access'); } /**