Commit 99db616f authored by fmitchell's avatar fmitchell
Browse files

Issue #1528968 by Shawn_Smiley: Provide hooks for altering the workflow tab content

parent 050f2b89
7.x-2.x
--------------
#1528968: Provide hooks for altering the workflow tab content
#1562058: No check for no existing states in State Flow
#1562044: No check for no Node bundles in State Flow
#1616704: Check existence of 'draft' state on hook_node_update
......
......@@ -39,6 +39,91 @@ function hook_state_flow_machine_type_alter(&$machine_type, $node) {
$machine_type = 'state_flow_test';
}
/**
* Implements hook_state_flow_events_page_alter().
*
* Allows altering the render array for the workflow tab prior to being output.
*
* @param $data
* The render array for the page content.
*
* @param $node
* The node that the workflow page is being rendered for.
*
* @param $events
* The available events/actions for the current workflow state.
*/
function hook_state_flow_events_page_alter(&$data, $node, $events) {
// Remove the version number
unset($data['content']['current_revision']['current_revision_vid']);
}
/**
* Implements hook_state_flow_draft_table_alter().
*
* Allows altering the content of the Drafts table on the workflow tab
* prior to rendering.
*
* @param $table
* The render array for the drafts table.
*
* @param $node
* The node that the workflow page is being rendered for.
*
* @param $states
* An array of all of the revisions and workflow states for the node.
*/
function hook_state_flow_draft_table_alter(&$table, $node, $states) {
// Remove the VID column header.
unset($table['header'][0]);
// Remove the vid column.
foreach ($table['rows'] as $row_num => $row) {
unset($table['rows'][$row_num][0]);
}
}
/**
* Implements hook_state_flow_others_table_alter().
*
* Allows altering the content of the Other Revisions table on the workflow tab
* prior to rendering.
*
* @param $table
* The render array for the others table.
*
* @param $node
* The node that the workflow page is being rendered for.
*
* @param $states
* An array of all of the revisions and workflow states for the node.
*/
function hook_state_flow_others_table_alter(&$table, $node, $states) {
// Remove the vid column header.
unset($table['header'][0]);
// Remove the vid column.
foreach ($table['rows'] as $row_num => $row) {
unset($table['rows'][$row_num][0]);
}
}
/**
* Implements hook_state_flow_others_table_alter().
*
* Allows altering the content of the workflow history table on the workflow tab
* prior to rendering.
*
* @param $table
* The render array for the history table.
*
* @param $node
* The node that the workflow page is being rendered for.
*/
function hook_state_flow_history_table_alter(&$table, $node) {
}
/**
* Define a new workflow for a node type
*/
......@@ -75,4 +160,12 @@ class StateFlowTest extends StateFlow {
}
return FALSE;
}
}
\ No newline at end of file
/**
* Override what event is used to skip directly to publish
*
*/
public function skip_to_publish() {
return 'immediate publish';
}
}
......@@ -108,6 +108,11 @@ function state_flow_events($node) {
);
}
// Give other modules a chance to modify the table data.
drupal_alter('state_flow_draft_table', $drafts_table, $node, $states);
drupal_alter('state_flow_others_table', $others_table, $node, $states);
drupal_alter('state_flow_history_table', $history_table, $node);
// Set the title for this page
drupal_set_title(t('Workflow for %title', array('%title' => $node->title)), PASS_THROUGH);
......@@ -168,6 +173,10 @@ function state_flow_events($node) {
);
}
// Allow other modules to modify the output of the workflow tab
// before it is rendered.
drupal_alter('state_flow_events_page', $output, $node, $events);
return $output;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment