--- workflow.module.org 2005-06-06 21:44:40.000000000 -0700 +++ workflow.module 2005-06-07 00:52:18.000000000 -0700 @@ -200,6 +200,14 @@ } /** + * Implementation of hook_node_grants() + */ +function workflow_node_grants($user, $op) { + return array('workflow_uid' => array($user->uid) ); +} + + +/** * Implementation of hook_workflow() */ function workflow_workflow($op, $old_state, $new_state, $node) { @@ -336,6 +344,42 @@ $output = workflow_actions_form($wid, $edit); break; + + // CRG: Create a new link. Done when there were no links from 'creation' state discouvered + // - Workflow ID (wid) + // - Target for creation id of this workflow (sid) + // Bugs/Limitations: + // - If this is manually built, or another creation link for this wid is done before this is fired, then two creation links would exist and that + // would get very confusing! + case 'creation_link': + $wid = $arg3; + $sid = $arg4; + + // Get creation state for this workflow + $result = db_fetch_object(db_query("SELECT sid FROM {workflow_states} WHERE wid = %d AND sysid = %d", $wid, WORKFLOW_CREATION)); + if(! $result) { + drupal_set_message(t("The creation state cannot be linked. The 'creation' state does not exist. This is an unexpected system error. The easiest recovery is to delete your workflow and re-create it, or directly modify the SQL tables. Sorry ... ")); + } else { + db_query("INSERT INTO {workflow_transitions} (tid, sid, target_sid) VALUES (%d, %d, %d)", db_next_id('workflow_transitions'), $result->sid, $sid); + drupal_set_message(t("The creation state was linked")); + } + drupal_goto('admin/workflow'); + break; + + // CRG: Change the creation state transition + // - Transition ID (tid) + // - Target for creation id of this workflow (sid) + // Bugs/Limitations: + // - Does not detect if the transitions have changed since the URL was built. In this case the message would be lying. + case 'creation_move': + $tid = $arg3; + $sid = $arg4; + + db_query("UPDATE {workflow_transitions} set target_sid = %d where tid = %d", $sid, $tid); + drupal_set_message(t("The creation state was moved")); + drupal_goto('admin/workflow'); + break; + default: if ($edit['update']) { workflow_types_save($edit); @@ -372,6 +416,10 @@ if ($states) { $cell = ''; + + // CRG: Locate id of target for creation (if any) + $creation_target = db_fetch_object(db_query("SELECT target_sid, tid FROM {workflow_transitions} as wt, {workflow_states} as ws WHERE ws.wid = %d AND ws.sysid = %d AND wt.sid = ws.sid", $data->wid, WORKFLOW_CREATION)); + foreach ($states as $sid => $state) { if (!workflow_is_system_state($state)) { $cell .= "
| " . $state; @@ -379,8 +427,24 @@ if (count($states) > 2) { $cell .= ' (' . l(t('transitions'), "admin/workflow/transition/$data->wid/$sid") . ')'; } - $cell .= " | "; - $cell .= l(t('delete'), "admin/workflow/delete/$data->wid/$sid") . " |