function workflow_hook_info in Workflow 5.2
Same name and namespace in other branches
- 8 workflow.module \workflow_hook_info()
- 7.2 workflow.module \workflow_hook_info()
- 7 workflow.module \workflow_hook_info()
Implementation of hook_hook_info(). Expose each transition as a hook.
File
- ./
workflow.module, line 2245
Code
function workflow_hook_info() {
$states = workflow_get_states();
if (!$states) {
return;
}
$trigger_page = substr($_GET['q'], 0, 28) == 'admin/build/trigger/workflow';
if ($trigger_page && ($wid = arg(4))) {
$result = db_query("SELECT tm.type, w.wid, w.name, ws.state, wt.tid, wt.sid, wt.target_sid FROM {workflow_type_map} tm LEFT JOIN {workflows} w ON tm.wid = w.wid LEFT JOIN {workflow_states} ws ON w.wid = ws.wid LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE w.wid = %d AND wt.target_sid IS NOT NULL ORDER BY tm.type, ws.weight", $wid);
}
else {
$result = db_query("SELECT tm.type, w.wid, w.name, ws.state, wt.tid, wt.sid, wt.target_sid FROM {workflow_type_map} tm LEFT JOIN {workflows} w ON tm.wid = w.wid LEFT JOIN {workflow_states} ws ON w.wid = ws.wid LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE wt.target_sid IS NOT NULL ORDER BY tm.type, ws.weight");
}
while ($data = db_fetch_object($result)) {
$pseudohooks['workflow-' . $data->type . '-' . $data->tid] = array(
'runs when' => t('When %type moves from %state to %target_state', array(
'%type' => $data->type,
'%state' => $states[$data->sid],
'%target_state' => $states[$data->target_sid],
)),
);
}
// $pseudohooks will not be set if no workflows have been assigned
// to node types.
if (isset($pseudohooks)) {
return array(
'workflow' => array(
'workflow' => $pseudohooks,
),
);
}
if ($trigger_page) {
drupal_set_message(t('No transitions have been set up. To enable the assignment of actions, edit the workflow to assign permissions for roles to do transitions. After that is completed, transitions will appear here and you will be able to assign actions to them. The workflow must also be assigned to at least one content type.'));
}
}