function workflow_update_5203 in Workflow 5.2
Same name and namespace in other branches
- 6.2 workflow.install \workflow_update_5203()
- 6 workflow.install \workflow_update_5203()
File
- ./
workflow.install, line 493
Code
function workflow_update_5203() {
$ret = array();
if (module_exists('actions')) {
$result = db_query("SELECT hook, op, aid, weight FROM {actions_assignments} WHERE hook = 'workflow'");
while ($data = db_fetch_object($result)) {
$op_parts = explode('-', $data->op);
// The ops we have to update have only two parts, e.g., workflow-35.
if (count($op_parts) == 3) {
continue;
}
$tid = $op_parts[1];
// Assign a type to this hook.
$wid = db_result(db_query("SELECT ws.wid FROM {workflow_states} ws LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE wt.tid = %d", $tid));
// Get the first node type associated with this hook (if there are multiple types,
// we can't decide between them so we take the first one).
$type = db_result(db_query("SELECT type FROM {workflow_type_map} WHERE wid = %d LIMIT 1", $wid));
$new_op = 'workflow-' . $type . '-' . $tid;
$query_result = db_query("UPDATE {actions_assignments} SET op = '%s' WHERE hook = 'workflow' AND op = '%s' AND aid = '%s' AND weight = %d", $new_op, $data->op, $data->aid, $data->weight);
$ret[] = array(
'success' => $query_result !== FALSE,
'query' => check_plain('op ' . $data->op . ' => ' . $new_op),
);
}
}
return $ret;
}