summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Great Git Migration2008-02-28 01:48:35 (GMT)
committerThe Great Git Migration2008-02-28 01:48:35 (GMT)
commitc0d1e46db36c69ee8503dfe1082edf2dfdb45172 (patch)
tree3f6361e285bb99629246c4717be9fc23156933a5
parentdf69e87a8a4886e3518aee019e44d9de5fa5e30a (diff)
This commit was manufactured as part of Drupal's Great Git Migration to5.x-0.2
create tag 'DRUPAL-5--0-2'. Sprout from DRUPAL-5 2008-01-23 16:49:37 UTC moshe weitzman <weitzman@cyrve.com> '#210651 by salvis. Explain realm = 'all'' Cherrypick from DRUPAL-5 2008-02-28 01:48:34 UTC moshe weitzman <weitzman@cyrve.com> '#126098 zend optimizer segfaults PHP during db_query backtrace (white screen of death)': devel.module macro.module
-rw-r--r--devel.module47
-rw-r--r--macro.module2
2 files changed, 36 insertions, 13 deletions
diff --git a/devel.module b/devel.module
index f91bc29..e819d12 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('<p>The user is being redirected to <a href="@destination">@destination</a>.</p>', 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 <a href="!url">horribly buggy and segfaults your Apache</a> ... ', 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 56c1894..079ddcb 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');
}
/**