function workflow_token_values in Workflow 5.2
Same name and namespace in other branches
- 5 workflow.module \workflow_token_values()
- 6.2 workflow.module \workflow_token_values()
- 6 workflow.module \workflow_token_values()
Implementation of hook_token_values().
File
- ./
workflow.module, line 2176
Code
function workflow_token_values($type, $object = NULL) {
$values = array();
switch ($type) {
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;
}
$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 ? check_plain($account->name) : variable_get('anonymous', 'Anonymous');
$values['workflow-current-state-updating-user-uid'] = $account->uid;
$values['workflow-current-state-updating-user-mail'] = $account->uid ? check_plain($account->mail) : '';
$values['workflow-current-state-log-entry'] = filter_xss($row->comment, array(
'a',
'em',
'strong',
));
break;
}
return $values;
}