'publishing/author', 'title' => t('author dashboard'), 'callback' => 'publishing_author_page', 'access' => user_access('publishing author'), ); $items[] = array( 'path' => 'publishing/editor', 'title' => t('editor dashboard'), 'callback' => 'publishing_editor_page', 'access' => user_access('publishing editor'), ); } return $items; } /** * Provide a page for an author to see a list of drafts, a list of articles * back for review. The dashboard is highly customizable and should be * tailored to your individual needs. Task lists are a good one, and * links to an author forum for collaboration are another good one. */ function publishing_author_page() { // get all node types that can be added. You probably want to just // tailor this list to things that matter to authors, since this // will get crud like project issues and forums and other stuff // if you have that. /* foreach (node_get_types() as $type => $name) { if (module_invoke(node_get_base($type), 'access', 'create', $type)) { $menu_items[] = l("Submit $name", "node/add/$type", array('title' => t('Add a new %s.', array('%s' => $name)))); } } */ $menu_items[] = l(t('Submit article'), 'node/add/story'); $menu = theme('dashboard_component', theme('item_list', $menu_items), t('Author Menu'), 'menu'); $drafts = views_build_view('block', views_get_view('publishing_bystate_mine'), array(PUBLISHING_WORKFLOW_DRAFT), false, 10); $rework = views_build_view('block', views_get_view('publishing_bystate_mine'), array(PUBLISHING_WORKFLOW_REWORK), false, 10); $review = views_build_view('block', views_get_view('publishing_bystate_mine'), array(PUBLISHING_WORKFLOW_REVIEW), false, 10); $left = $menu . theme('dashboard_component', $drafts, t('My Drafts'), 'drafts'); $right = theme('dashboard_component', $rework, t('Back for Rework'), 'rework'); $right .= theme('dashboard_component', $review, t('Up for Review'), 'review'); return theme('dashboard', 'author', $left, $right); } function publishing_editor_page() { // get all node types that can be added. You probably want to just // tailor this list to things that matter to authors, since this // will get crud like project issues and forums and other stuff // if you have that. /* foreach (node_get_types() as $type => $name) { if (module_invoke(node_get_base($type), 'access', 'create', $type)) { $menu_items[] = l("Submit $name", "node/add/$type", array('title' => t('Add a new %s.', array('%s' => $name)))); } } */ $menu = theme('dashboard_component', theme('item_list', $menu_items), t('Author Menu'), 'menu'); $drafts = views_build_view('block', views_get_view('publishing_bystate'), array(PUBLISHING_WORKFLOW_DRAFT), false, 10); $rework = views_build_view('block', views_get_view('publishing_bystate'), array(PUBLISHING_WORKFLOW_REWORK), false, 10); $review = views_build_view('block', views_get_view('publishing_bystate'), array(PUBLISHING_WORKFLOW_REVIEW), false, 20); $right = theme('dashboard_component', $drafts, t('All Drafts'), 'drafts'); $right .= theme('dashboard_component', $rework, t('Back for Rework'), 'rework'); $left = theme('dashboard_component', $review, t('Up for Review'), 'review'); return theme('dashboard', 'author', $left, $right); } /** * hunmonk's module dependency check: see http://drupal.org/node/54463 */ function publishing_ui_form_alter($form_id, &$form) { if ($form_id == 'system_modules' && !$_POST) { publishing_ui_system_module_validate($form); } } /** * hunmonk's module dependency check: see http://drupal.org/node/54463 */ function publishing_ui_system_module_validate(&$form) { $module = 'publishing'; $dependencies = array('views', 'actions', 'workflow', 'dashboard'); foreach ($dependencies as $dependency) { if (!in_array($dependency, $form['status']['#default_value'])) { $missing_dependency = TRUE; $missing_dependency_list[] = $dependency; } } if (in_array($module, $form['status']['#default_value']) && isset($missing_dependency)) { db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = '%s'", $module); $key = array_search($module, $form['status']['#default_value']); unset($form['status']['#default_value'][$key]); drupal_set_message(t('The module %module was deactivated--it requires the following disabled/non-existant modules to function properly: %dependencies', array('%module' => $module, '%dependencies' => implode(', ', $missing_dependency_list))), 'error'); } } /** * Provide our default views. */ function publishing_views_default_views() { $view = new stdClass(); $view->name = 'publishing_bystate_mine'; $view->description = t('Lists nodes in the given workflow state for the logged in user.'); $view->page = TRUE; $view->page_title = '%1s'; $view->page_header = ''; $view->page_header_format = '1'; $view->page_empty = t('No articles.'); $view->page_empty_format = '1'; $view->page_type = 'teaser'; $view->url = 'publishing/mine'; $view->use_pager = TRUE; $view->nodes_per_page = '10'; $view->block = TRUE; $view->block_title = '%1s'; $view->block_header = ''; $view->block_header_format = '1'; $view->block_type = 'list'; $view->nodes_per_block = '10'; $view->block_more = '1'; $view->block_use_page_header = FALSE; $view->block_use_page_empty = TRUE; $view->menu_title = t('My workflows'); $view->sort = array ( array ( 'tablename' => 'node', 'field' => 'created', 'sortorder' => 'DESC', 'options' => '', ), ); $view->argument = array ( array ( 'type' => 'workflow_state', 'argdefault' => '4', 'title' => 'Wprkflow States', 'options' => '', ), ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => '', 'handler' => 'views_handler_field_nodelink', ), array ( 'tablename' => 'node', 'field' => 'created', 'label' => '', 'handler' => 'views_handler_field_date_small', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'currentuid', 'operator' => '=', 'options' => '', 'value' => '***CURRENT_USER***', ), ); $view->requires = array(node); $views[$view->name] = $view; $view = new stdClass(); $view->name = 'publishing_bystate'; $view->description = t('Lists nodes in the given workflow state.'); $view->access = array ( ); $view->page = TRUE; $view->page_title = '%1s'; $view->page_header = ''; $view->page_header_format = '1'; $view->page_empty = t('No articles.'); $view->page_empty_format = '1'; $view->page_type = 'teaser'; $view->url = 'publishing/all'; $view->use_pager = TRUE; $view->nodes_per_page = '10'; $view->block = TRUE; $view->block_title = '%1s'; $view->block_header = ''; $view->block_header_format = '1'; $view->block_type = 'list'; $view->nodes_per_block = '10'; $view->block_more = '1'; $view->block_use_page_header = FALSE; $view->block_use_page_empty = TRUE; $view->menu_title = t('workflows'); $view->sort = array ( array ( 'tablename' => 'node', 'field' => 'created', 'sortorder' => 'DESC', 'options' => '', ), ); $view->argument = array ( array ( 'type' => 'workflow_state', 'argdefault' => '4', 'title' => 'Wprkflow States', 'options' => '', ), ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => '', 'handler' => 'views_handler_field_nodelink', ), array ( 'tablename' => 'node', 'field' => 'created', 'label' => '', 'handler' => 'views_handler_field_date_small', ), array ( 'tablename' => 'users', 'field' => 'name', 'label' => '', ), ); $view->filter = array ( ); $view->requires = array(node, users); $views[$view->name] = $view; return $views; }