View source
<?php
include_once 'includes/total_control_workflow.default_views.inc';
function total_control_workflow_perm() {
return array(
'have total workflow control',
);
}
function total_control_workflow_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools') {
return 'plugins_workflow/' . $plugin;
}
}
function total_control_workflow_menu_alter(&$items) {
$states = workflow_get_states();
$count = 1;
foreach ($states as $sid => $state_name) {
$num = db_result(db_query("SELECT count(*) FROM {workflow_node} WHERE sid = %d", $sid));
$items['admin/dashboard/workflow/' . $sid]['weight'] = $count;
$items['admin/dashboard/workflow/' . $sid]['title'] = $items['admin/dashboard/workflow/' . $sid]['title'] . ' (' . $num . ')';
$count++;
}
}
function total_control_workflow_form_alter(&$form, $form_state, $form_id) {
if ('workflow_state_add_form' == $form_id) {
$form['#submit'][] = '_total_control_workflow_views_add_display';
}
if ('workflow_state_delete_form' == $form_id) {
$form['#submit'][] = '_total_control_workflow_views_delete_display';
}
}
function _total_control_workflow_views_add_display($form, &$form_state) {
$sid = $form_state['values']['sid'];
$weight = $form_state['values']['weight'];
$state = $form_state['values']['state'];
$view = views_get_view('control_workflow');
if ($form['sid']['#value']) {
menu_rebuild();
}
else {
$handler = $view
->new_display('panel_pane', 'Pane: ' . $state, 'panel_pane_tcw_sid_' . $sid);
$handler
->override_option('filters', array(
'sid' => array(
'operator' => 'in',
'value' => array(
$sid => $sid,
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'sid_op',
'label' => 'Current State',
'use_operator' => 0,
'identifier' => 'sid',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'sid',
'table' => 'workflow_node',
'field' => 'sid',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
));
$handler
->override_option('title', $state . ' Summary');
$handler
->override_option('pane_title', 'State: ' . $state);
$handler
->override_option('pane_description', t('Items in state: ') . $state);
$handler
->override_option('pane_category', array(
'name' => 'Admin Dashboard',
'weight' => '0',
));
$handler
->override_option('allow', array(
'use_pager' => FALSE,
'items_per_page' => FALSE,
'offset' => FALSE,
'link_to_view' => FALSE,
'more_link' => FALSE,
'path_override' => FALSE,
'title_override' => FALSE,
'exposed_form' => FALSE,
));
$handler
->override_option('argument_input', array());
$handler
->override_option('link_to_view', 0);
$handler
->override_option('inherit_panels_path', 0);
$handler = $view
->new_display('page', 'Page: ' . $state, 'page_tcw_sid_' . $sid);
$handler
->override_option('fields', array(
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'name' => array(
'label' => 'Author',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
'sid_1' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'sid_1',
'table' => 'workflow_node_history',
'field' => 'sid',
'relationship' => 'none',
),
'sid' => array(
'label' => '',
'alter' => array(
'alter_text' => 1,
'text' => '-> [sid]',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'sid',
'table' => 'workflow_node',
'field' => 'sid',
'relationship' => 'none',
),
'stamp' => array(
'label' => '',
'alter' => array(
'alter_text' => 1,
'text' => '@ [stamp]',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'date_format' => 'small',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'stamp',
'table' => 'workflow_node_history',
'field' => 'stamp',
'relationship' => 'none',
),
'edit_node' => array(
'label' => 'Edit',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'text' => 'edit',
'exclude' => 0,
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
));
$handler
->override_option('filters', array(
'sid' => array(
'operator' => 'in',
'value' => array(
$sid => $sid,
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'sid_op',
'label' => 'Current State',
'use_operator' => 0,
'identifier' => 'sid',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'sid',
'table' => 'workflow_node',
'field' => 'sid',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
'type' => array(
'operator' => 'in',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'type_op',
'identifier' => 'type',
'label' => 'Content Type',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'keys' => array(
'operator' => 'optional',
'value' => '',
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'keys_op',
'identifier' => 'keys',
'label' => 'Search:',
'optional' => 1,
'remember' => 0,
),
'id' => 'keys',
'table' => 'search_index',
'field' => 'keys',
'relationship' => 'none',
),
'uid' => array(
'operator' => 'in',
'value' => '',
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'uid_op',
'identifier' => 'uid',
'label' => 'Author',
'optional' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'uid',
'table' => 'users',
'field' => 'uid',
'relationship' => 'none',
),
));
$handler
->override_option('title', 'state page');
$handler
->override_option('items_per_page', 30);
$handler
->override_option('style_plugin', 'table');
$handler
->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'title' => 'title',
'sid_1' => 'sid_1',
'sid' => 'sid',
'stamp' => 'stamp',
),
'info' => array(
'title' => array(
'sortable' => 1,
'separator' => '',
),
'sid_1' => array(
'sortable' => 1,
'separator' => '',
),
'sid' => array(
'sortable' => 0,
'separator' => '',
),
'stamp' => array(
'sortable' => 1,
'separator' => '',
),
),
'default' => '-1',
));
$handler
->override_option('path', 'admin/dashboard/workflow/' . $sid);
$handler
->override_option('menu', array(
'type' => 'tab',
'title' => $state,
'description' => '',
'weight' => '0',
'name' => 'navigation',
));
$handler
->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));
}
$view
->save();
menu_rebuild();
return;
}
function _total_control_workflow_views_delete_display($form, &$form_state) {
$sid = $form_state['values']['sid'];
$view = views_get_view('control_workflow');
unset($view->display['panel_pane_tcw_sid_' . $sid]);
$view
->save();
return;
}