myworkbench.inc in Workbench 7
File
plugins/page_manager/tasks/myworkbench.inc
View source
<?php
function workbench_myworkbench_page_manager_tasks() {
return array(
'task type' => 'page',
'title' => t('My Workbench'),
'admin title' => t('The Workbench landing page.'),
'admin description' => t('When enabled, this overrides the default Workbench page for <em>admin/workbench</em>. If no variant is selected, the default "My Workbench" will be shown. See http://drupal.org/node/1226174 for more information.'),
'admin path' => 'admin/workbench',
'hook menu alter' => 'workbench_myworkbench_menu_alter',
'handler type' => 'context',
'disabled' => variable_get('workbench_myworkbench_disabled', TRUE),
'enable callback' => 'workbench_myworkbench_enable',
);
}
function workbench_myworkbench_menu_alter(&$items, $task) {
if (variable_get('workbench_myworkbench_disabled', TRUE)) {
return;
}
$callback = $items['admin/workbench']['page callback'];
if ($callback == 'workbench_content' || variable_get('page_manager_override_anyway', FALSE)) {
$items['admin/workbench']['page callback'] = 'workbench_myworkbench';
$items['admin/workbench']['file path'] = $task['path'];
$items['admin/workbench']['file'] = $task['file'];
}
else {
if (!empty($GLOBALS['page_manager_enabling_workbench'])) {
drupal_set_message(t('Page manager module is unable to enable Workbench because some other module already has overridden with %callback.', array(
'%callback' => $callback,
)), 'warning');
}
return;
}
}
function workbench_myworkbench() {
$task = page_manager_get_task('myworkbench');
ctools_include('context');
ctools_include('context-task-handler');
$output = ctools_context_handler_render($task, '', array(), array());
if ($output !== FALSE) {
return $output;
}
module_load_include('inc', 'workbench', 'workbench.pages');
$function = 'workbench_content';
foreach (module_implements('page_manager_override') as $module) {
$call = $module . '_page_manager_override';
if (($rc = $call('workbench')) && function_exists($rc)) {
$function = $rc;
break;
}
}
return $function();
}
function workbench_myworkbench_enable($cache, $status) {
variable_set('workbench_myworkbench_disabled', $status);
if (!$status) {
$GLOBALS['page_manager_enabling_workbench'] = TRUE;
}
}