You are here

function workflow_extensions_token_values in Workflow Extensions 6

Same name and namespace in other branches
  1. 7 workflow_extensions.module \workflow_extensions_token_values()

Implementation of hook_token_values().

Returning [workflow-state-age] for both node and workflow contexts as there seems to be an issue with using Workflow state as the data type argument in a Rule set. Such a Rule set won't show as available in a scheduled triggered rule. The Content (ie node) data type must be used instead.

File

./workflow_extensions.module, line 497
UI-related improvements to the Workflow module and tokens for Rules.

Code

function workflow_extensions_token_values($context, $object = NULL) {
  $values = array();
  switch ($context) {
    case 'node':
    case 'workflow':
      if (isset($object)) {
        $node = (object) $object;
        if (module_exists('workflow')) {
          $stamp = db_result(db_query_range("SELECT stamp FROM {workflow_node_history} WHERE nid = %d ORDER BY stamp DESC", $node->nid, 0, 1));
          $values['workflow-state-age'] = $stamp ? time() - $stamp : 0;
        }
        $values['mod-since-seconds'] = $node->changed ? time() - $node->changed : 0;
      }
      break;
  }
  return $values;
}