diff --git a/t.patch b/t.patch deleted file mode 100644 index 7fc9227..0000000 --- a/t.patch +++ /dev/null @@ -1,102 +0,0 @@ -diff --git a/workflow.module b/workflow.module -index aa5fa3d..c8e0469 100644 ---- a/workflow.module -+++ b/workflow.module -@@ -218,27 +218,12 @@ function workflow_node_load($nodes, $types) { - * Implements hook_node_insert(). - */ - function workflow_node_insert($node) { -+dpm(__FUNCTION__); - // Skip if there are no workflows. - if ($workflow = workflow_get_workflow_type_map_by_type($node->type)) { -- // If the state is not specified, use first valid state. -- // For example, a new node must move from (creation) to some -- // initial state. -- if (empty($node->workflow)) { -- $choices = workflow_field_choices($node); -- if ($choices) { -- $keys = array_keys($choices); -- $sid = array_shift($keys); -- } -- else { -- // This should never happen, but it did during testing. -- drupal_set_message(t('There are no workflow states available. Please notify your site administrator.'), 'error'); -- return; -- } -- } -- if (!isset($sid)) { -- $sid = $node->workflow; -- } -- // And make the transition. -+ // Get new state from value of workflow form field, stored in $node->workflow. -+ $sid = isset($node->workflow) ? $node->workflow : workflow_get_default_state($node, $sid); -+ // Make the transition. - workflow_transition($node, $sid); - } - } -@@ -247,12 +232,12 @@ function workflow_node_insert($node) { - * Implements hook_node_update(). - */ - function workflow_node_update($node) { -+dpm(__FUNCTION__); - // Skip if there are no workflows. - if ($workflow = workflow_get_workflow_type_map_by_type($node->type)) { - // Get new state from value of workflow form field, stored in $node->workflow. -- if (!isset($sid)) { -- $sid = $node->workflow; -- } -+ $sid = isset($node->workflow) ? $node->workflow : workflow_get_default_state($node, $sid); -+ // Make the transition. - workflow_transition($node, $sid); - } - } -@@ -261,6 +246,7 @@ function workflow_node_update($node) { - * Implements hook_node_delete(). - */ - function workflow_node_delete($node) { -+dpm(__FUNCTION__); - $node->workflow_stamp = REQUEST_TIME; - // Delete the association of node to state. - workflow_delete_workflow_node_by_nid($node->nid); -@@ -406,6 +392,41 @@ function workflow_transition($node, $sid, $force = FALSE) { - } - - /** -+ * Gets the first valid state if a node doesn't have one, yet. -+ * param -+ * @param $node -+ * @param $sid -+ * An integer; the initial state ID. Should be 0. -+ * -+ * @return -+ * An integer; the new state ID. -+ */ -+function workflow_get_default_state($node, $sid) { -+ // Skip is a state is already set. -+ if ($sid) { -+ return $sid; -+ } -+ else { -+ // Skip if there are no workflows. -+ if ($workflow = workflow_get_workflow_type_map_by_type($node->type)) { -+ // If the state is not specified, use first valid state. -+ // For example, a new node must move from (creation) to some -+ // initial state. -+ $choices = workflow_field_choices($node); -+ if ($choices) { -+ $keys = array_keys($choices); -+ $sid = array_shift($keys); -+ } -+ else { -+ // This should never happen, but it did during testing. -+ drupal_set_message(t('There are no workflow states available. Please notify your site administrator.'), 'error'); -+ return; -+ } -+ } -+ } -+} -+ -+/** - * Theme the current workflow state. - */ - function theme_workflow_current_state($variables) {