function devel_block in Devel 5
Same name and namespace in other branches
- 6 devel.module \devel_block()
Implementation of hook_block().
File
- ./
devel.module, line 345
Code
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:
$block['subject'] = t('Switch user');
$links = devel_switch_user_list();
if (!empty($links)) {
$block['content'] = theme('item_list', $links);
$block['content'] .= drupal_get_form('devel_switch_user_form');
}
break;
case 1:
$links = array();
$block['subject'] = t('devel');
if (user_access('access devel information')) {
$links[] = l('Devel settings', 'admin/settings/devel', array(
'title' => t('Adjust module settings for devel module'),
));
$links[] = l('Empty cache', 'devel/cache/clear', array(
'title' => t('Clear the database cache tables which store page, menu, node, and variable caches.'),
), drupal_get_destination());
$links[] = l('Execute PHP Code', 'devel/php', array(
'title' => t('Execute some PHP code'),
));
$links[] = l('Run cron', 'admin/logs/status/run-cron', array(
'title' => t('Execute functions scheduled for cron runs.'),
), drupal_get_destination());
$links[] = l('Phpinfo()', 'admin/logs/status/php');
$links[] = l('Function reference', 'devel/reference', array(
'title' => t('View a list of currently defined user functions with documentation links'),
));
$links[] = l('Reinstall modules', 'devel/reinstall', array(
'title' => t('Re-run hook_install() for a given module'),
));
$links[] = l('Reset menus', 'devel/menu/reset', array(
'title' => t('Resets all menu items to their default settings'),
));
$links[] = l('Variable editor', 'devel/variable', array(
'title' => t('Edit and delete site variables'),
));
$links[] = l('Session viewer', 'devel/session', array(
'title' => t('List the contents of $_SESSION'),
));
}
if (function_exists('devel_node_access_perm') && user_access(DNA_ACCESS_VIEW)) {
// True only if devel_node_access enabled.
$links[] = l('Node access summary', 'devel/node_access/summary');
}
if ($links) {
$block['content'] = theme('item_list', $links);
}
break;
case 2:
if (user_access('execute php code')) {
$block['subject'] = t('Execute php');
$block['content'] = drupal_get_form('devel_execute_form');
}
break;
}
return $block;
}
}
}
}
}