? workflow6.patch Index: workflow.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.info,v retrieving revision 1.2.2.2 diff -u -p -r1.2.2.2 workflow.info --- workflow.info 18 Jun 2007 23:07:16 -0000 1.2.2.2 +++ workflow.info 28 Mar 2008 20:33:47 -0000 @@ -2,3 +2,4 @@ name = Workflow description = Allows the creation and assignment of arbitrary workflows to node types. package = "Workflow" +core = 6.x Index: workflow.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.install,v retrieving revision 1.7 diff -u -p -r1.7 workflow.install --- workflow.install 3 Feb 2007 22:38:48 -0000 1.7 +++ workflow.install 28 Mar 2008 20:33:48 -0000 @@ -2,264 +2,106 @@ // $Id: workflow.install,v 1.7 2007/02/03 22:38:48 mfredrickson Exp $ function workflow_install() { - $result = array(); - - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $result[] = db_query( -<< array( + 'wid' => array('type' => 'serial'), + 'name' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''), + 'tab_roles' => array('type' => 'varchar', 'length' => '60', 'not null' => TRUE, 'default' => '')), + 'primary key' => array('wid'), + ); + + $schema['workflow_type_map'] = array( + 'fields' => array( + 'type' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''), + 'wid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10')), + 'indexes' => array( + 'type' => array('type', 'wid')), + ); + + $schema['workflow_transitions'] = array( + 'fields' => array( + 'tid' => array('type' => 'serial'), + 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'target_sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'roles' => array('type' => 'varchar', 'length' => '60', 'not null' => FALSE)), + 'primary key' => array('tid'), + 'indexes' => array( + 'sid' => array('sid'), + 'target_sid' => array('target_sid')), + ); + + $schema['workflow_states'] = array( + 'fields' => array( + 'sid' => array('type' => 'serial'), + 'wid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'state' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''), + 'weight' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '4'), + 'sysid' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '4')), + 'primary key' => array('sid'), + 'indexes' => array( + 'sysid' => array('sysid'), + 'wid' => array('wid')), + ); + + $schema['workflow_scheduled_transition'] = array( + 'fields' => array( + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'old_sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'scheduled' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'comment' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE)), + 'indexes' => array( + 'nid' => array('nid')), + ); + + $schema['workflow_node_history'] = array( + 'fields' => array( + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'old_sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'stamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'comment' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE)), + 'indexes' => array( + 'nid' => array('nid', 'sid')), + ); + + $schema['workflow_node'] = array( + 'fields' => array( + 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'stamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')), + 'primary key' => array('nid'), + 'indexes' => array( + 'nid' => array('nid', 'sid')), + ); + + $schema['workflow_actions'] = array( + 'fields' => array( + 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), + 'aid' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '0'), + 'weight' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10')), + 'indexes' => array( + 'tid' => array('tid')), + ); - if (count($result) == count(array_filter($result))) { - drupal_set_message(t('The workflow module has successfully added tables to the database.')); - } - else { - drupal_set_message(t('Drupal was unable to install the database tables for the workflow module.'), 'error'); - } + return $schema; } + // Introduce workflow_node_history table so workflow_node is joinable for views.module. function workflow_update_1() { $ret = array(); - + switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': @@ -350,7 +192,7 @@ function workflow_update_3() { // Update sequence names to be cross-database compatible. function workflow_update_4() { $ret = array(); - + switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': @@ -358,16 +200,16 @@ function workflow_update_4() { $ret[] = _workflow_fix_seq('workflows', '{workflows}_wid'); $ret[] = _workflow_fix_seq('workflow_state', '{workflow_states}_sid'); $ret[] = _workflow_fix_seq('workflow_transitions', '{workflow_transitions}_tid'); - db_query('UNLOCK TABLES'); + db_query('UNLOCK TABLES'); break; } - + return $ret; } // Add stamp column in workflow_node to ease JOIN with history table. Needed for Views function workflow_update_5() { - $ret[] = update_sql("ALTER TABLE {workflow_node} ADD stamp int(10) unsigned AFTER uid"); + $ret[] = update_sql("ALTER TABLE {workflow_node} ADD stamp int(10) unsigned AFTER uid"); $sql = "SELECT MAX(stamp) AS stamp, nid FROM {workflow_node_history} GROUP BY nid"; $result = db_query($sql); while ($row = db_fetch_object($result)) { @@ -385,7 +227,7 @@ function _workflow_fix_seq($old_name, $n // Add scheduling tables function workflow_update_6() { $ret = array(); - + switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': @@ -422,6 +264,6 @@ QUERY break; } - + return $ret; } Index: workflow.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v retrieving revision 1.54.2.16 diff -u -p -r1.54.2.16 workflow.module --- workflow.module 14 Jan 2008 17:11:57 -0000 1.54.2.16 +++ workflow.module 28 Mar 2008 20:33:49 -0000 @@ -8,15 +8,15 @@ define('WORKFLOW_ARROW', '→'); /** * Implementation of hook_help(). */ -function workflow_help($section) { - switch ($section) { - case strstr($section, 'admin/build/workflow/edit'): +function workflow_help($path, $arg) { + switch ($path) { + case strstr($path, 'admin/build/workflow/edit'): return t('You are currently viewing the possible transitions to and from workflow states. The state is shown in the left column; the state to be moved to is to the right. For each transition, check the box next to the role(s) that may initiate the transition. For example, if only the hulking_editor role may move a node from Review state to the Published state, check the box next to hulking_editor. The author role is built in and refers to the user who authored the node.'); case 'admin/build/workflow/add': return t('To get started, provide a name for your workflow. This name will be used as a label when the workflow status is shown during node editing.'); - case strstr($section, 'admin/build/workflow/state'): + case strstr($path, 'admin/build/workflow/state'): return t('Enter the name for a state in your workflow. For example, if you were doing a meal workflow it may include states like shop, prepare food, eat, and clean up.'); - case strstr($section, 'admin/build/workflow/actions') && (sizeof($section) == 22): + case strstr($path, 'admin/build/workflow/actions') && (sizeof($path) == 22): return t('Use this page to set actions to happen when transitions occur. To configure actions, use the actions module.', array('@link' => url('admin/actions'))); } } @@ -31,94 +31,102 @@ function workflow_perm() { /** * Implementation of hook_menu(). */ -function workflow_menu($may_cache) { +function workflow_menu() { $items = array(); $access = user_access('administer workflow'); - if ($may_cache) { - $items[] = array('path' => 'admin/build/workflow', - 'title' => t('Workflow'), - 'access' => $access, - 'callback' => 'workflow_overview', - 'description' => t('Allows the creation and assignment of arbitrary workflows to node types.')); - - $items[] = array('path' => 'admin/build/workflow/edit', - 'title' => t('Edit workflow'), - 'type' => MENU_CALLBACK, - 'callback' => 'workflow_edit_page'); - - $items[] = array('path' => 'admin/build/workflow/list', - 'title' => t('List'), - 'weight' => -10, - 'callback' => 'workflow_page', - 'type' => MENU_DEFAULT_LOCAL_TASK); - - $items[] = array('path' => 'admin/build/workflow/add', - 'title' => t('Add workflow'), - 'weight' => -8, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('workflow_add_form'), - 'type' => MENU_LOCAL_TASK); - - $items[] = array('path' => 'admin/build/workflow/state', - 'title' => t('Add state'), - 'type' => MENU_CALLBACK, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('workflow_state_add_form')); - - $items[] = array('path' => 'admin/build/workflow/state/delete', - 'title' => t('Delete State'), - 'type' => MENU_CALLBACK, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('workflow_state_delete_form')); - - $items[] = array('path' => 'admin/build/workflow/delete', - 'title' => t('Delete workflow'), - 'type' => MENU_CALLBACK, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('workflow_delete_form')); - - $items[] = array('path' => 'admin/build/workflow/actions', - 'title' => t('Workflow actions'), - 'type' => MENU_CALLBACK, - 'callback' => 'workflow_actions_page'); - - $items[] = array('path' => 'admin/build/workflow/actions/remove', - 'title' => t('Workflow actions'), - 'type' => MENU_CALLBACK, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('workflow_actions_remove_form')); - + $items['admin/build/workflow'] = array( + 'title' => 'Workflow', + 'access' => $access, + 'page callback' => 'workflow_overview', + 'description' => 'Allows the creation and assignment of arbitrary workflows to node types.'); + + $items['admin/build/workflow/edit'] = array( + 'title' => 'Edit workflow', + 'type' => MENU_CALLBACK, + 'page callback' => 'workflow_edit_page'); + + $items['admin/build/workflow/list'] = array( + 'title' => 'List', + 'weight' => -10, + 'page callback' => 'workflow_page', + 'type' => MENU_DEFAULT_LOCAL_TASK); + + $items['admin/build/workflow/add'] = array( + 'title' => 'Add workflow', + 'weight' => -8, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('workflow_add_form'), + 'type' => MENU_LOCAL_TASK); + + $items['admin/build/workflow/state'] = array( + 'title' => 'Add state', + 'type' => MENU_CALLBACK, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('workflow_state_add_form')); + + $items['admin/build/workflow/state/delete'] = array( + 'title' => 'Delete State', + 'type' => MENU_CALLBACK, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('workflow_state_delete_form')); + + $items['admin/build/workflow/delete'] = array( + 'title' => 'Delete workflow', + 'type' => MENU_CALLBACK, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('workflow_delete_form')); + + $items['admin/build/workflow/actions'] = array( + 'title' => 'Workflow actions', + 'type' => MENU_CALLBACK, + 'page callback' => 'workflow_actions_page'); + + $items['admin/build/workflow/actions/remove'] = array( + 'title' => 'Workflow actions', + 'type' => MENU_CALLBACK, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('workflow_actions_remove_form')); + + $items["node/%node/workflow"] = array( + 'title' => 'Workflow', + 'access callback' => 'workflow_node_tab_access', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + 'weight' => 2, + 'page callback' => 'workflow_tab_page', + 'page arguments' => array(1), + ); + return $items; +} + +function workflow_node_tab_access($node = NULL) { + global $user; + $roles = array_keys($user->roles); + if ($node->uid == $user->uid) { + $roles = array_merge(array('author'), $roles); + } + $wid = workflow_get_workflow_for_type($node->type); + $workflow = db_fetch_object(db_query("SELECT * FROM {workflows} WHERE wid = %d", $wid)); + $allowed_roles = $workflow->tab_roles ? explode(',', $workflow->tab_roles) : array(); + + if (user_access('administer nodes') || array_intersect($roles, $allowed_roles)) { + return TRUE; } else { - if (arg(0) == 'node' && is_numeric(arg(1))) { - $node = node_load(arg(1)); - $wid = workflow_get_workflow_for_type($node->type); - if ($wid) { // workflow exists for this type - global $user; - $roles = array_keys($user->roles); - if ($node->uid == $user->uid) { - $roles = array_merge(array('author'), $roles); - } - $workflow = db_fetch_object(db_query("SELECT * FROM {workflows} WHERE wid = %d", $wid)); - $allowed_roles = $workflow->tab_roles ? explode(',', $workflow->tab_roles) : array(); - $items[] = array('path' => "node/$node->nid/workflow", - 'title' => t('Workflow'), - 'access' => array_intersect($roles, $allowed_roles) || user_access('administer nodes'), - 'type' => MENU_LOCAL_TASK, - 'weight' => 2, - 'callback' => 'workflow_tab_page', - 'callback arguments' => arg(1), - ); - } - } + return FALSE; } - return $items; } -function workflow_tab_page($nid) { - - $node = node_load($nid); +function workflow_theme() { + return array( + 'workflow_edit_form' => array('arguments' => array('form' => array())), + 'workflow_types_form' => array('arguments' => array('form' => array())), + 'workflow_actions_form' => array('arguments' => array('form' => array())), + ); +} + +function workflow_tab_page($node = NULL) { drupal_set_title(check_plain($node->title)); $wid = workflow_get_workflow_for_type($node->type); $states_per_page = 20; @@ -149,9 +157,9 @@ function workflow_tab_page($nid) { function workflow_tab_form(&$node, $wid, $states, $current) { $form = array(); $choices = workflow_field_choices($node); - + $min = $states[$current] == t('(creation)') ? 1 : 2; - if (count($choices) >= $min) { // bail out if user has no new target state(s) + if (count($choices) >= $min) { // bail out if user has no new target state(s) $wid = workflow_get_workflow_for_type($node->type); $name = check_plain(workflow_get_name($wid)); // see if scheduling information is present @@ -169,7 +177,7 @@ function workflow_tab_form(&$node, $wid, } workflow_node_form($form, t('Change %s state', array('%s' => $name)), $name, $current, $choices, $timestamp, $comment); - + $form['node'] = array( '#type' => 'value', '#value' => $node, @@ -180,24 +188,24 @@ function workflow_tab_form(&$node, $wid, '#value' => t('Submit') ); } - + return $form; } -function workflow_tab_form_submit($form_id, $form_values) { - $node = $form_values['node']; - +function workflow_tab_form_submit($form, &$form_state) { + $node = $form_state['values']['node']; + // mockup a node so we don't need to repeat the code for processing this - $node->workflow = $form_values['workflow']; - $node->workflow_comment = $form_values['workflow_comment']; - $node->workflow_scheduled = $form_values['workflow_scheduled']; - $node->workflow_scheduled_date = $form_values['workflow_scheduled_date']; - $node->workflow_scheduled_hour = $form_values['workflow_scheduled_hour']; - + $node->workflow = $form_state['values']['workflow']; + $node->workflow_comment = $form_state['values']['workflow_comment']; + $node->workflow_scheduled = $form_state['values']['workflow_scheduled']; + $node->workflow_scheduled_date = $form_state['values']['workflow_scheduled_date']; + $node->workflow_scheduled_hour = $form_state['values']['workflow_scheduled_hour']; + // call node save to make sure all saving properties run on this node node_save($node); - return 'node/' . $node->nid; + $form_state['redirect'] = 'node/' . $node->nid; } /** @@ -221,7 +229,7 @@ function workflow_nodeapi(&$node, $op, $ case 'load': $node->_workflow = workflow_node_current_state($node); - + // scheduling information $res = db_query('SELECT * FROM {workflow_scheduled_transition} WHERE nid = %d', $node->nid); if ($row = db_fetch_object($res)) { @@ -257,23 +265,23 @@ function workflow_nodeapi(&$node, $op, $ $nid = $node->nid; $comment = $node->workflow_comment; $old_sid = workflow_node_current_state($node); - + if ($node->workflow_scheduled_date['day'] < 10) { - $node->workflow_scheduled_date['day'] = '0' . + $node->workflow_scheduled_date['day'] = '0' . $node->workflow_scheduled_date['day']; } - + if ($node->workflow_scheduled_date['month'] < 10) { - $node->workflow_scheduled_date['month'] = '0' . + $node->workflow_scheduled_date['month'] = '0' . $node->workflow_scheduled_date['month']; } - + if (!$node->workflow_scheduled_hour) { $node->workflow_scheduled_hour = '00:00'; } - - $scheduled = $node->workflow_scheduled_date['year'] . - $node->workflow_scheduled_date['month'] . + + $scheduled = $node->workflow_scheduled_date['year'] . + $node->workflow_scheduled_date['month'] . $node->workflow_scheduled_date['day'] . ' ' . $node->workflow_scheduled_hour . 'Z'; if ($scheduled = strtotime($scheduled)) { @@ -286,11 +294,11 @@ function workflow_nodeapi(&$node, $op, $ $timezone = variable_get('date_default_timezone', 0); } $scheduled = $scheduled - $timezone; - + // clear previous entries and insert db_query("DELETE FROM {workflow_scheduled_transition} WHERE nid = $nid"); db_query('INSERT INTO {workflow_scheduled_transition} VALUES (%d, %d, %d, %d,\'%s\')', $nid, $old_sid, $sid, $scheduled, $comment); - + drupal_set_message(t("@node_title is scheduled for state change on !scheduled_date",array( "@node_title" => $node->title, "!scheduled_date" => format_date($scheduled)))); } } @@ -319,7 +327,7 @@ function workflow_node_form(&$form, $tit ); } else { - + $form['workflow'][$name] = array( '#type' => 'radios', '#title' => $title, @@ -328,7 +336,7 @@ function workflow_node_form(&$form, $tit '#parents' => array('workflow'), '#default_value' => $current ); - + // HACK: using arg to see if we're on a node add page // i have to do this because current is never creation! // scheduling from transition is major bad news @@ -352,7 +360,7 @@ function workflow_node_form(&$form, $tit 'month' => format_date($timestamp, 'custom', 'n'), 'year' => format_date($timestamp, 'custom', 'Y')), ); - + $hours = format_date($timestamp, 'custom', 'H:i'); $form['workflow']['workflow_scheduled_hour'] = array ( '#type' => 'textfield', @@ -360,7 +368,7 @@ function workflow_node_form(&$form, $tit '#default_value' => $scheduled ? $hours : NULL, ); } - + $form['workflow']['workflow_comment'] = array( '#type' => 'textarea', '#title' => t('Comment'), @@ -376,8 +384,8 @@ function workflow_node_form(&$form, $tit * @param object &$node * @return array */ -function workflow_form_alter($form_id, &$form) { - if (isset($form['type']) && $form['#base'] == 'node_form') { +function workflow_form_alter(&$form, &$form_state, $form_id) { + if (isset($form['type']) && !empty($form['#node'])) { $node = $form['#node']; $choices = workflow_field_choices($node); $wid = workflow_get_workflow_for_type($node->type); @@ -407,7 +415,7 @@ function workflow_form_alter($form_id, & '#weight' => 10, ); } - + // see if scheduling information is present if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) { global $user; @@ -443,7 +451,7 @@ function workflow_execute_transition($no $result = module_invoke_all('workflow', 'transition pre', $old_sid, $sid, $node); _workflow_write_history($node, $sid, $comment); } - $result = module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node); + $result = module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node); return; } @@ -452,11 +460,11 @@ function workflow_execute_transition($no if ($user->uid > 1 || $user->uid == 0) { // allow any state change for superuser (might be cron) $tid = workflow_get_transition_id($old_sid, $sid); if (!$tid) { - watchdog('workflow', t('Attempt to go to nonexistent transition (from %old to %new)', array('%old' => $old_sid, '%new' => $sid), WATCHDOG_ERROR)); + watchdog('workflow', 'Attempt to go to nonexistent transition (from %old to %new)', array('%old' => $old_sid, '%new' => $sid, WATCHDOG_ERROR)); return; } if (!workflow_transition_allowed($tid, array_merge(array_keys($user->roles), array('author')))) { - watchdog('workflow', t('User %user not allowed to go from state %old to %new)', array('%user' => $user->name, '%old' => $old_sid, '%new' => $sid), WATCHDOG_NOTICE)); + watchdog('workflow', 'User %user not allowed to go from state %old to %new', array('%user' => $user->name, '%old' => $old_sid, '%new' => $sid, WATCHDOG_NOTICE)); return; } } @@ -474,12 +482,12 @@ function workflow_execute_transition($no // Register state change with watchdog $state_name = db_result(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $sid)); $type = node_get_types('name', $node->type); - watchdog('workflow', t('State of @type %node_title set to @state_name', array('@type' => $type, '%node_title' => $node->title, '@state_name' => $state_name)), WATCHDOG_NOTICE, l('view', 'node/' . $node->nid)); + watchdog('workflow', 'State of @type %node_title set to @state_name', array('@type' => $type, '%node_title' => $node->title, '@state_name' => $state_name), WATCHDOG_NOTICE, l('view', 'node/' . $node->nid)); // Notify modules that transition has occurred. Actions should take place // in response to this callback, not the previous one. module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node); - + // clear any references in the scheduled listing db_query('DELETE FROM {workflow_scheduled_transition} WHERE nid = %d', $node->nid); } @@ -496,7 +504,7 @@ function action_workflow_execute_transit // then the node's new state (now it's current state) should be in $node->workflow; // otherwise the current state is placed in $node->_workflow by our nodeapi load if (!isset($node->workflow) && !isset($node->_workflow)) { - watchdog('workflow', t('Unable to get current workflow state of node %nid.', array('%nid' => $node->nid))); + watchdog('workflow', 'Unable to get current workflow state of node %nid.', array('%nid' => $node->nid)); return; } $current_state = isset($node->workflow) ? $node->workflow : $node->_workflow; @@ -519,9 +527,9 @@ function action_workflow_execute_transit } // fire the transition - watchdog('action', t('Changing workflow state of node id %id to %state', array('%id' => intval($node->nid), '%state' => check_plain($new_state_name)))); + watchdog('action', 'Changing workflow state of node id %id to %state', array('%id' => intval($node->nid), '%state' => check_plain($new_state_name))); workflow_execute_transition($node, $new_state); - watchdog('action', t('Changed workflow state of node id %id to %state', array('%id' => intval($node->nid), '%state' => check_plain($new_state_name)))); + watchdog('action', 'Changed workflow state of node id %id to %state', array('%id' => intval($node->nid), '%state' => check_plain($new_state_name))); break; case 'metadata': @@ -561,16 +569,16 @@ function workflow_field_choices($node) { $states = workflow_get_states($wid); $roles = array_keys($user->roles); $current_sid = workflow_node_current_state($node); - + // if the node author or this is a new page, give the authorship role - if (($user->uid == $node->uid && $node->uid > 0) || (arg(0) == 'node' && arg(1) == 'add')) { + if (($user->uid == $node->uid && $node->uid > 0) || (arg(0) == 'node' && arg(1) == 'add')) { $roles += array('author' => 'author'); } if ($user->uid == 1) { // if the superuser $roles = 'ALL'; } $transitions = workflow_allowable_transitions($current_sid, 'to', $roles); - + if ($current_sid == _workflow_creation_state($wid)) { // include current state if not (creation) unset($transitions[$current_sid]); } @@ -585,7 +593,7 @@ function workflow_field_choices($node) { */ function workflow_node_current_state($node) { $sid = db_result(db_query("SELECT sid FROM {workflow_node} WHERE nid=%d ", $node->nid)); - + if (!$sid) { $wid = workflow_get_workflow_for_type($node->type); $sid = _workflow_creation_state($wid); @@ -600,7 +608,7 @@ function _workflow_creation_state($wid) "wid=%d AND sysid=%d", $wid, WORKFLOW_CREATION)); $cache[$wid] = $result; } - + return $cache[$wid]; } @@ -638,7 +646,7 @@ function workflow_workflow($op, $old_sta * HTML form. * */ -function workflow_add_form($name = NULL) { +function workflow_add_form(&$form_state, $name = NULL) { $form = array(); $form['wf_name'] = array( '#type' => 'textfield', @@ -651,8 +659,8 @@ function workflow_add_form($name = NULL) return $form; } -function workflow_add_form_validate($form_id, $form_values) { - $workflow_name = $form_values['wf_name']; +function workflow_add_form_validate($form, &$form_state) { + $workflow_name = $form_state['values']['wf_name']; $workflows = array_flip(workflow_get_all()); // Make sure a nonblank workflow name is provided if ($workflow_name == '') { @@ -665,14 +673,14 @@ function workflow_add_form_validate($for } } -function workflow_add_form_submit($form_id, $form_values) { - $workflow_name = $form_values['wf_name']; - if (array_key_exists('wf_name', $form_values) && $workflow_name != '') { +function workflow_add_form_submit($form, &$form_state) { + $workflow_name = $form_state['values']['wf_name']; + if (array_key_exists('wf_name', $form_state['values']) && $workflow_name != '') { workflow_create($workflow_name); - watchdog('workflow', t('Created workflow %name', array('%name' => $workflow_name))); + watchdog('workflow', 'Created workflow %name', array('%name' => $workflow_name)); drupal_set_message(t('The workflow %name was created. You should now add states to your workflow.', array('%name' => $workflow_name)), 'warning'); - return('admin/build/workflow'); + $form_state['redirect'] = 'admin/build/workflow'; } } @@ -686,31 +694,31 @@ function workflow_add_form_submit($form_ * HTML form. * */ -function workflow_delete_form($wid, $sid = NULL) { - +function workflow_delete_form(&$form_state, $wid, $sid = NULL) { + if (isset($sid)) { return workflow_state_delete_form($wid, $sid); } - + $form = array(); $form['wid'] = array('#type' => 'value', '#value' => $wid); return confirm_form( $form, t('Are you sure you want to delete %title? All nodes that have a workflow state associated with this workflow will have those workflow states removed.', array('%title' => workflow_get_name($wid))), - $_GET['destination'] ? $_GET['destination'] : 'admin/build/workflow', + !empty($_GET['destination']) ? $_GET['destination'] : 'admin/build/workflow', t('This action cannot be undone.'), t('Delete'), t('Cancel') ); } -function workflow_delete_form_submit($form_id, $form_values) { - if ($form_values['confirm'] == 1) { - $workflow_name = workflow_get_name($form_values['wid']); - workflow_deletewf($form_values['wid']); - watchdog('workflow', t('Deleted workflow %name with all its states', array('%name' => $workflow_name))); +function workflow_delete_form_submit($form, &$form_state) { + if ($form_state['values']['confirm'] == 1) { + $workflow_name = workflow_get_name($form_state['values']['wid']); + workflow_deletewf($form_state['values']['wid']); + watchdog('workflow', 'Deleted workflow %name with all its states', array('%name' => $workflow_name)); drupal_set_message(t('The workflow %name with all its states was deleted.', array('%name' => $workflow_name))); - return('admin/build/workflow'); + $form_state['redirect'] = 'admin/build/workflow'; } } @@ -740,12 +748,12 @@ function workflow_permissions($wid) { $all[$role]['transitions'][] = array($data->state_name, WORKFLOW_ARROW, $data->target_state_name); } } - + $output = ''; $header = array(t('From'), '', t('To')); foreach ($all as $role => $value) { $output .= '

'. t("%role may do these transitions:", array('%role' => $value['name'])) .'

'; - if ($value['transitions']) { + if (!empty($value['transitions'])) { $output .= theme('table', $header, $value['transitions']) . '

'; } else { @@ -771,7 +779,7 @@ function workflow_edit_page($wid) { return $output; } -function workflow_edit_form($wid) { +function workflow_edit_form(&$form_state, $wid) { $form = array(); #$form['#theme'] = 'workflow_edit_form'; @@ -847,7 +855,7 @@ function theme_workflow_edit_form($form) $rows[] = $row; } $output .= theme('table', $header, $rows); - + } else { $output = 'There are no states defined for this workflow.'; } @@ -856,11 +864,11 @@ function theme_workflow_edit_form($form) return $output; } -function workflow_edit_form_validate($form_id, $form_values) { - $wid = $form_values['wid']; - if (array_key_exists('wf_name', $form_values) && $form_values['wf_name'] != '') { +function workflow_edit_form_validate($form, &$form_state) { + $wid = $form_state['values']['wid']; + if (array_key_exists('wf_name', $form_state['values']) && $form_state['values']['wf_name'] != '') { // Validate: Make sure workflow name is not a duplicate - $workflow_name = $form_values['wf_name']; + $workflow_name = $form_state['values']['wf_name']; $workflows = array_flip(workflow_get_all()); if (array_key_exists($workflow_name, $workflows) && $wid != $workflows[$workflow_name]) { form_set_error('wf_name', t('A workflow with the name %name already exists. Please enter another name for this workflow.', @@ -871,11 +879,11 @@ function workflow_edit_form_validate($fo else { form_set_error('wf_name', t('Please provide a nonblank name for this workflow.')); } - + // Make sure 'author' is checked for (creation) -> [something] $creation_id = _workflow_creation_state($wid); - if (is_array($form_values['transitions'][$creation_id])) { - foreach($form_values['transitions'][$creation_id] as $to => $roles) { + if (is_array($form_state['values']['transitions'][$creation_id])) { + foreach($form_state['values']['transitions'][$creation_id] as $to => $roles) { if ($roles['author']) { $author_has_permission = true; break; @@ -888,11 +896,11 @@ function workflow_edit_form_validate($fo } } -function workflow_edit_form_submit($form_id, $form_values) { - workflow_update($form_values['wid'], $form_values['wf_name'], array_filter($form_values['tab_roles'])); - workflow_update_transitions($form_values['transitions']); +function workflow_edit_form_submit($form, &$form_state) { + workflow_update($form_state['values']['wid'], $form_state['values']['wf_name'], array_filter($form_state['values']['tab_roles'])); + workflow_update_transitions($form_state['values']['transitions']); drupal_set_message(t('The workflow was updated.')); - return('admin/build/workflow'); + $form_state['redirect'] = 'admin/build/workflow'; } /** @@ -905,10 +913,10 @@ function workflow_edit_form_submit($form * HTML form. * */ -function workflow_state_add_form($wid, $sid = NULL) { +function workflow_state_add_form(&$form_state, $wid, $sid = NULL) { $form = array(); $form['wid'] = array('#type' => 'value', '#value' => $wid); - + if (isset($sid)) { $state = workflow_get_state($sid); if (isset($state)) { @@ -943,17 +951,17 @@ function workflow_state_add_form($wid, $ return $form; } -function workflow_state_add_form_validate($form_id, $form_values) { - $state_name = $form_values['state']; - $wf_states = array_flip(workflow_get_states($form_values['wid'])); - if (array_key_exists('sid', $form_values)) { +function workflow_state_add_form_validate($form, &$form_state) { + $state_name = $form_state['values']['state']; + $wf_states = array_flip(workflow_get_states($form_state['values']['wid'])); + if (array_key_exists('sid', $form_state['values'])) { // Validate changes to existing state: // Make sure a nonblank state name is provided if ($state_name == '') { form_set_error('state', t('Please provide a nonblank name for this state.')); } // Make sure changed state name is not a duplicate - if (array_key_exists($state_name, $wf_states) && $form_values['sid'] != $wf_states[$state_name]) { + if (array_key_exists($state_name, $wf_states) && $form_state['values']['sid'] != $wf_states[$state_name]) { form_set_error('state', t('A state with the name %state already exists in this workflow. ' . 'Please enter another name for this state.', array('%state' => $state_name))); } @@ -968,18 +976,18 @@ function workflow_state_add_form_validat form_set_error('state', t('A state with the name %state already exists in this workflow. ' . 'Please enter another name for your new state.', array('%state' => $state_name))); } - } + } } -function workflow_state_add_form_submit($form_id, $form_values) { - workflow_state_save($form_values); - if (array_key_exists('sid', $form_values)) { +function workflow_state_add_form_submit($form, &$form_state) { + workflow_state_save($form_state['values']); + if (array_key_exists('sid', $form_state['values'])) { drupal_set_message(t('The workflow state was updated.')); } else { - watchdog('workflow', t('Created workflow state %name', array('%name' => $form_values['state']))); - drupal_set_message(t('The workflow state %name was created.', array('%name' => $form_values['state']))); - } - return('admin/build/workflow'); + watchdog('workflow', 'Created workflow state %name', array('%name' => $form_state['values']['state'])); + drupal_set_message(t('The workflow state %name was created.', array('%name' => $form_state['values']['state']))); + } + $form_state['redirect'] = 'admin/build/workflow'; } /** @@ -1001,7 +1009,7 @@ function workflow_state_add_form_submit( function workflow_update_transitions($transitions = array()) { // empty string is sometimes passed in instead of an array if (!$transitions) return; - + foreach ($transitions as $from => $to_data) { foreach ($to_data as $to => $role_data) { foreach ($role_data as $role => $can_do) { @@ -1026,17 +1034,24 @@ function workflow_update_transitions($tr * Int (role ID) or string ('author'). */ function workflow_transition_add_role($from, $to, $role) { + $transition = array( + 'sid' => $from, + 'target_sid' => $to, + 'roles' => $role, + ); $tid = workflow_get_transition_id($from, $to); if ($tid) { $roles = db_result(db_query("SELECT roles FROM {workflow_transitions} WHERE tid=%d", $tid)); $roles = explode(',', $roles); if (array_search($role, $roles) === FALSE) { $roles[] = $role; - db_query("UPDATE {workflow_transitions} SET roles='%s' WHERE tid=%d", implode(',', $roles), $tid); + $transition['roles'] = implode(',', $roles); + $transition['tid'] = $tid; + drupal_write_record('workflow_transitions', $transition, 'tid'); } } else { - db_query("INSERT INTO {workflow_transitions} (tid, sid, target_sid, roles) VALUES (%d, %d, %d, '%s')", db_next_id('{workflow_transitions}_tid'), $from, $to, $role); + drupal_write_record('workflow_transitions', $transition); } } @@ -1128,7 +1143,7 @@ function workflow_transition_allowed($ti function workflow_overview() { $workflows = workflow_get_all(); $row = array(); - + foreach ($workflows as $wid => $name) { $links = array( 'workflow_overview_add_state' => array( @@ -1146,13 +1161,13 @@ function workflow_overview() { ); $states = workflow_get_states($wid); - if (!(module_exists('actions') && $states)) { + if (empty($states)) { unset($links['workflow_overview_actions']); } - + $statelinks = array(); + $row[] = array($name, theme('links', $links)); $subrows = array(); - foreach ($states as $sid => $statename) { if (!workflow_is_system_state(t($statename))) { $statelinks = array( @@ -1169,12 +1184,12 @@ function workflow_overview() { $subrows[] = array(t($statename), theme('links', $statelinks)); unset ($statelinks); } - + $subheader_state = array('data' => t('State'), 'style' => 'width: 30%'); $subheader_operations = array('data' => t('Operations'), 'style' => 'width: 70%'); $subheader_style = array('style' => 'width: 100%; margin: 3px 20px 20px;'); $subtable = theme('table', array($subheader_state, $subheader_operations), $subrows, $subheader_style); - + $row[] = array(array('data' => $subtable, 'colspan' => '2')); } @@ -1228,22 +1243,22 @@ function workflow_state_delete_form($wid return confirm_form( $form, t('Are you sure you want to delete %title (and all its transitions)?', array('%title' => $states[$sid])), - $_GET['destination'] ? $_GET['destination'] : 'admin/build/workflow', + !empty($_GET['destination']) ? $_GET['destination'] : 'admin/build/workflow', t('This action cannot be undone.'), t('Delete'), t('Cancel') ); } -function workflow_state_delete_form_submit($form_id, $form_values) { - $states = workflow_get_states($form_values['wid']); - $state_name = $states[$form_values['sid']]; - if ($form_values['confirm'] == 1) { - workflow_state_delete($form_values['sid']); - watchdog('workflow', t('Deleted workflow state %name', array('%name' => $state_name))); +function workflow_state_delete_form_submit($form, &$form_state) { + $states = workflow_get_states($form_state['values']['wid']); + $state_name = $states[$form_state['values']['sid']]; + if ($form_state['values']['confirm'] == 1) { + workflow_state_delete($form_state['values']['sid']); + watchdog('workflow', 'Deleted workflow state %name', array('%name' => $state_name)); drupal_set_message(t('The workflow state %name was deleted.', array('%name' => $state_name))); } - return('admin/build/workflow'); + $form_state['redirect'] = 'admin/build/workflow'; } function workflow_types_form() { @@ -1265,7 +1280,7 @@ function workflow_types_form() { '#type' => 'item', '#value' => t('Each node type may have a separate workflow:'), ); - + foreach (node_get_types('names') as $type => $name) { $form[$type] = array( '#type' => 'select', @@ -1296,13 +1311,13 @@ function theme_workflow_types_form($form return $output . drupal_render($form); } -function workflow_types_form_submit($form_id, $form_values) { - workflow_types_save($form_values); +function workflow_types_form_submit($form, &$form_state) { + workflow_types_save($form_state['values']); drupal_set_message(t('The workflow mapping was saved.')); - return('admin/build/workflow'); + $form_state['redirect'] = 'admin/build/workflow'; } -function workflow_actions_remove_form($wid, $tid, $aid) { +function workflow_actions_remove_form(&$form_state, $wid, $tid, $aid) { $form = array(); $form['wid'] = array('#type' => 'value', '#value' => $wid); $form['tid'] = array('#type' => 'value', '#value' => $tid); @@ -1311,7 +1326,7 @@ function workflow_actions_remove_form($w $output = confirm_form( $form, t('Are you sure you want to delete the action %title?', array('%title' => $actions[$aid]['description'])), - $_GET['destination'] ? $_GET['destination'] : 'admin/build/workflow/actions/'. $wid, + !empty($_GET['destination']) ? $_GET['destination'] : 'admin/build/workflow/actions/'. $wid, t('You can add it again later if you wish.'), t('Delete'), t('Cancel') @@ -1319,23 +1334,18 @@ function workflow_actions_remove_form($w return $output; } -function workflow_actions_remove_confirm_submit($form_id, $form_values) { - if ($form_values['confirm'] == 1) { - $aid = $form_values['aid']; +function workflow_actions_remove_confirm_submit($form, &$form_state) { + if ($form_state['values']['confirm'] == 1) { + $aid = $form_state['values']['aid']; $actions = actions_actions_map(actions_get_all_actions()); - workflow_actions_remove($form_values['tid'], $aid); - watchdog('workflow', t('Action %action deleted', array('%action' => check_plain($actions[$aid])))); + workflow_actions_remove($form_state['values']['tid'], $aid); + watchdog('workflow', 'Action %action deleted', array('%action' => check_plain($actions[$aid]))); drupal_set_message(t('Action %action deleted.', array('%action' => $actions[$aid]))); - return('admin/workflow/actions/'. $form_values['wid']); + $form_state['redirect'] = 'admin/workflow/actions/'. $form_state['values']['wid']; } } function workflow_actions_page($wid) { - if (!module_exists('actions')) { - drupal_set_message(t('Before you can assign actions you must install and enable the actions module.'), 'error'); - drupal_goto('admin/build/workflow'); - } - $options = array(t('None')); foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) { $options[$action['type']][$aid] = $action['description']; @@ -1376,12 +1386,11 @@ function workflow_actions_page($wid) { return $output; } -function workflow_actions_form($wid, $tid, $available_options) { +function workflow_actions_form(&$form_state, $wid, $tid, $available_options) { $form['tid'] = array( '#type' => 'hidden', '#value' => $tid ); - $form['#multistep'] = true; // get and list the actions that are already assigned to this transition $actions_this_tid = workflow_get_actions($tid); foreach ($actions_this_tid as $aid => $act_name) { @@ -1419,31 +1428,30 @@ function theme_workflow_actions_form($fo if (isset($form['action'])) { $row[] = array(drupal_render($form['action']), drupal_render($form['submit'])); } - $output .= theme('table', array(), $row); + $output = theme('table', array(), $row); return $output . drupal_render($form); } -function workflow_actions_form_submit($form, $form_values) { - - $tid = $form_values['tid']; - $aid = actions_key_lookup($form_values['action']); +function workflow_actions_form_submit($form, &$form_state) { + $tid = $form_state['values']['tid']; + $aid = actions_function_lookup($form_state['values']['action']); workflow_actions_save($tid, $aid); // the form does weird things if we don't do a drupal_goto() $wid = arg(4); - return "admin/build/workflow/actions/$wid"; + $form_state['redirect'] = "admin/build/workflow/actions/$wid"; } -function workflow_actions_remove_form_submit($form_id, $form_values) { - if ($form_values['confirm'] == 1) { - $aid = $form_values['aid']; +function workflow_actions_remove_form_submit($form, &$form_state) { + if ($form_state['values']['confirm'] == 1) { + $aid = $form_state['values']['aid']; $actions = actions_get_all_actions(); $action = $actions[$aid]['description']; - workflow_actions_remove($form_values['tid'], $aid); - watchdog('workflow', t('Action %action deleted', array('%action' => $action))); + workflow_actions_remove($form_state['values']['tid'], $aid); + watchdog('workflow', 'Action %action deleted', array('%action' => $action)); drupal_set_message(t('Action %action deleted.', array('%action' => $action))); } - return 'admin/build/workflow/actions/'. $form_values['wid']; + $form_state['redirect'] = 'admin/build/workflow/actions/'. $form_state['values']['wid']; } /** @@ -1505,10 +1513,10 @@ function workflow_get_all() { * */ function workflow_create($name) { - $wid = db_next_id('{workflows}_wid'); - db_query("INSERT INTO {workflows} (wid, name) VALUES (%d, '%s')", $wid, $name); - workflow_state_save(array('wid' => $wid, 'state' => t('(creation)'), 'sysid' => WORKFLOW_CREATION, 'weight' => WORKFLOW_CREATION_DEFAULT_WEIGHT)); - return $wid; + $workflow = array('name' => $name); + drupal_write_record('workflows', $workflow); + workflow_state_save(array('wid' => $workflow['wid'], 'state' => t('(creation)'), 'sysid' => WORKFLOW_CREATION, 'weight' => WORKFLOW_CREATION_DEFAULT_WEIGHT)); + return $workflow['wid']; } /** @@ -1597,11 +1605,10 @@ function workflow_state_save($edit) { $edit = array_merge($defaults, $edit); if (!isset($edit['sid'])) { - $edit['sid'] = db_next_id('{workflow_states}_sid'); - db_query("INSERT INTO {workflow_states} (sid, wid, state, sysid, weight) VALUES (%d, %d, '%s', %d, %d)", $edit['sid'], $edit['wid'], $edit['state'], $edit['sysid'], $edit['weight']); + drupal_write_record('workflow_states', $edit); } else { - db_query("UPDATE {workflow_states} SET wid = %d, state = '%s', sysid = %d, weight = %d WHERE sid = %d", $edit['wid'], $edit['state'], $edit['sysid'], $edit['weight'], $edit['sid']); + drupal_write_record('workflow_states', $edit, 'sid'); } return $edit['sid']; @@ -1694,7 +1701,7 @@ function workflow_allowable_transitions( $transitions[$state_id] = $t->state_name; } } - + return $transitions; } @@ -1702,7 +1709,7 @@ function workflow_allowable_transitions( * Save mapping of workflow to node type. E.g., "the story node type * is using the Foo workflow." * - * @param $form_values + * @param $form_state['values'] */ function workflow_types_save($form_values) { $nodetypes = node_get_types(); @@ -1859,7 +1866,7 @@ function workflow_views_tables() { ), ); $tables[$table['name']] = $table; - + $table = array( 'name' => 'workflow_node_history', 'provider' => 'workflow', @@ -1872,7 +1879,7 @@ function workflow_views_tables() { 'field' => 'nid', ), 'extra' => array( - 'stamp = workflow_node.stamp' => NULL, + 'stamp = workflow_node.stamp' => NULL, ), ), "fields" => array( @@ -1949,24 +1956,24 @@ function workflow_handler_arg_sid($op, & */ function workflow_cron() { $clear_cache = FALSE; - + //if the time now is greater than the time to publish a node, publish it $nodes = db_query('SELECT * FROM {workflow_scheduled_transition} s WHERE s.scheduled > 0 AND s.scheduled < %d', time()); - + while ($row = db_fetch_object($nodes)) { $node = node_load($row->nid); - + // make sure transition is still valid if ($node->_workflow == $row->old_sid) { - // do transistion - workflow_execute_transition($node, $row->sid, $row->comment); - - watchdog('content', t('%type: scheduled transition of %title.', array('%type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); + // do transistion + workflow_execute_transition($node, $row->sid, $row->comment); + + watchdog('content', '%type: scheduled transition of %title.', array('%type' => t($node->type), '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); $clear_cache = TRUE; - + } } - + if ($clear_cache) { // clear the cache so an anonymous poster can see the node being published or unpublished cache_clear_all(); @@ -1977,44 +1984,44 @@ function workflow_cron() { * Implementation of hook_token_values() */ function workflow_token_values($type, $object = NULL) { - $values = array(); + $values = array(); switch ($type) { - - case "node": + + case "node": case 'workflow': - + $node = (object)$object; - + if ($wid = workflow_get_workflow_for_type($node->type)) { $values['workflow-name'] = workflow_get_name($wid); $states = workflow_get_states($wid); } else { break; } - - + + $result = db_query_range("SELECT h.* FROM {workflow_node_history} h WHERE nid = %d ORDER BY stamp DESC",$node->nid,0,1); - + if ($row = db_fetch_object($result)) { $account = user_load( array ('uid' => $row->uid)); - $comment = $row->comment; + $comment = $row->comment; } - - $values['workflow-current-state-name'] = $states[$row->sid]; + + $values['workflow-current-state-name'] = $states[$row->sid]; $values['workflow-old-state-name'] = $states[$row->old_sid]; - + $values['workflow-current-state-date-iso'] = date('Ymdhis',$row->stamp); $values['workflow-current-state-date-tstamp'] = $row->stamp; $values['workflow-current-state-date-formatted'] = date('M d, Y h:i:s', $row->stamp); - + $values['workflow-current-state-updating-user-name'] = $account->uid ? $account->name : variable_get('anonymous', 'Anonymous'); $values['workflow-current-state-updating-user-uid'] = $account->uid; $values['workflow-current-state-updating-user-mail'] = $account->uid ? $account->mail : ''; - + $values['workflow-current-state-log-entry'] = $row->comment; break; } - + return $values; } @@ -2022,7 +2029,7 @@ function workflow_token_values($type, $o * Implementation of hook_token_list() */ function workflow_token_list($type = 'all') { - + if ($type == 'workflow' || $type == 'node' || $type == 'all') { $tokens['workflow']['workflow-name'] = 'Name of workflow appied to this node'; $tokens['workflow']['workflow-current-state-name'] = 'Current state of content'; @@ -2030,14 +2037,14 @@ function workflow_token_list($type = 'al $tokens['workflow']['workflow-current-state-date-iso'] = 'Date of last state change (ISO)'; $tokens['workflow']['workflow-current-state-date-tstamp'] = 'Date of last state change (timestamp)'; $tokens['workflow']['workflow-current-state-date-formatted'] = 'Date of last state change (formated - M d, Y h:i:s)';; - + $tokens['workflow']['workflow-current-state-updating-user-name'] = 'Username of last state changer'; $tokens['workflow']['workflow-current-state-updating-user-uid'] = 'uid of last state changer'; $tokens['workflow']['workflow-current-state-updating-user-mail'] = 'email of last state changer'; - + $tokens['workflow']['workflow-current-state-log-entry'] = 'Last workflow comment log'; $tokens['node'] = $tokens['workflow']; } - + return $tokens; }