public function delete($ids, DatabaseTransaction $transaction = NULL) { // @todo: replace with parent. foreach ($ids as $id) { if ($state = workflow_state_load($id)) { $wid = $state->wid; db_delete('workflow_states')->condition('sid', $state->sid)->execute(); // Reset the cache for the affected workflow. workflow_reset_cache($wid); } } }
/** * Implements hook_form_BASE_FORM_ID_alter(). * * Use this hook to alter the form. * It is only suited if you only use View Page or Workflow Tab. * If you change the state on the Node Form (Edit modus), you need the hook * hook_form_alter(). See below for more info. */ function hook_form_workflow_transition_form_alter(&$form, &$form_state, $form_id) { // Get the Entity. $entity = $form['workflow']['workflow_entity']['#value']; $entity_type = $form['workflow']['workflow_entity_type']['#value']; // Use the complicated form, which is suited for all Entity types. // For nodes only: $entity_type = 'node'; $entity_bundle = $entity->type; list(, , $entity_bundle) = entity_extract_ids($entity_type, $entity); // Get the current State ID. $sid = workflow_node_current_state($entity, $entity_type, $field_name = NULL); // Get the State object, if needed. $state = workflow_state_load($sid); // Change the form, depending on the state ID. // In the upcoming version 7.x-2.4, States should have a machine_name, too. if ($entity_type == 'node' && $entity_bundle == 'MY_NODE_TYPE') { switch ($state->sid) { case '2': // Change form element, form validate and form submit for state '2'. break; case '3': // Change form element, form validate and form submit for state '3'. break; } } }