/[drupal]/contributions/modules/workflow_named_transitions/workflow_named_transitions.module
ViewVC logotype

Diff of /contributions/modules/workflow_named_transitions/workflow_named_transitions.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Mon Sep 8 15:31:51 2008 UTC revision 1.2, Tue Dec 23 06:11:02 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: workflow_named_transitions.module,v 1.1 2008/09/08 15:31:51 deekayen Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 13  Line 13 
13   *   *
14   * @return array   * @return array
15   */   */
16  function workflow_named_transitions_menu($may_cache) {  function workflow_named_transitions_menu() {
17    $items = array();    $items = array();
18    
19    if ($may_cache) {    $items['admin/build/workflow/labels'] = array(
20        'title' => 'Edit labels',
21      $items[] = array(      'access callback' => 'user_access',
22        'path' => 'admin/build/workflow/labels',      'access arguments' => array('administer workflow'),
23        'title' => t('Edit labels'),      'page callback' => 'workflow_named_transitions_edit_labels_page',
24        'access' => user_access('administer workflow'),      'type' => MENU_LOCAL_TASK
25        'type' => MENU_LOCAL_TASK,    );
26        'callback' => 'workflow_named_transitions_edit_labels_page'    $items['admin/build/workflow/labels/%'] = array(
27      );      'title' => 'Edit labels',
28    }      'access callback' => 'user_access',
29    else {      'access arguments' => array('administer workflow'),
30        'page callback' => 'drupal_get_form',
31      $workflow = arg(4);      'page arguments' => array('workflow_named_transitions_edit_labels_form', 4),
32      if (!empty($workflow)) {      'type' => MENU_LOCAL_TASK
33        $items[] = array(    );
         'path' => 'admin/build/workflow/labels/'. arg(4),  
         'title' => t('Edit labels'),  
         'access' => user_access('administer workflow'),  
         'type' => MENU_LOCAL_TASK,  
         'callback' => 'drupal_get_form',  
         'callback arguments' => array('workflow_named_transitions_edit_labels_form', arg(4))  
       );  
     }  
   }  
34    
35    return $items;    return $items;
36  }  }
# Line 54  function workflow_named_transitions_edit Line 45  function workflow_named_transitions_edit
45    $workflows = workflow_get_all();    $workflows = workflow_get_all();
46    
47    foreach ($workflows as $workflow_id => $workflow_name) {    foreach ($workflows as $workflow_id => $workflow_name) {
48      $output .= '<br />'. l("Edit workflow '$workflow_name' labels", "admin/build/workflow/labels/$workflow_id");      $output .= '<br />'. l(t("Edit workflow '@workflow_name' labels", array('@workflow_name' => $workflow_name)), "admin/build/workflow/labels/$workflow_id");
49    }    }
50    
51    return $output;    return $output;
# Line 67  function workflow_named_transitions_edit Line 58  function workflow_named_transitions_edit
58   *   *
59   * @return array   * @return array
60   */   */
61  function workflow_named_transitions_edit_labels_form($workflow) {  function workflow_named_transitions_edit_labels_form($request, $workflow) {
62    if (!is_numeric($workflow)) {    if (!is_numeric($workflow)) {
63      drupal_set_message(t('Improper worklow ID provided.'), 'error');      drupal_set_message(t('Improper worklow ID provided.'), 'error');
64      watchdog('workflow_named_transitions', t('Improper worklow ID provided.'), WATCHDOG_NOTICE);      watchdog('workflow_named_transitions', 'Improper worklow ID provided.');
65      drupal_goto('admin/build/workflow/labels');      drupal_goto('admin/build/workflow/labels');
66    }    }
67    
# Line 104  function workflow_named_transitions_edit Line 95  function workflow_named_transitions_edit
95  }  }
96    
97  /**  /**
98     * Implementation of hook_theme().
99     *
100     * @return unknown
101     */
102    function workflow_named_transitions_theme() {
103      return array(
104        'workflow_named_transitions_edit_labels_form' => array(
105          'arguments' => array('form' => NULL)
106        )
107      );
108    }
109    
110    /**
111   * Formats the label form into two column table rows. The transition is   * Formats the label form into two column table rows. The transition is
112   * the first table cell, followed by the label field. Otherwise, the   * the first table cell, followed by the label field. Otherwise, the
113   * default display would be a form field with the transition as the FAPI   * default display would be a form field with the transition as the FAPI
# Line 117  function theme_workflow_named_transition Line 121  function theme_workflow_named_transition
121    // doing something with element_children() might be a better way    // doing something with element_children() might be a better way
122    // than this foreach looping methods    // than this foreach looping methods
123    foreach ($form as $starting_state => $transitions) {    foreach ($form as $starting_state => $transitions) {
124      if ($form[$starting_state]['#type'] == 'fieldset') {      if (isset($form[$starting_state]['#type']) && $form[$starting_state]['#type'] == 'fieldset') {
125        $rows = array();        $rows = array();
126        foreach ($transitions as $tid => $item) {        foreach ($transitions as $tid => $item) {
127          if (is_numeric($tid)) {          if (is_numeric($tid)) {
# Line 144  function theme_workflow_named_transition Line 148  function theme_workflow_named_transition
148   *   *
149   * @see workflow_named_transitions_edit_labels_form()   * @see workflow_named_transitions_edit_labels_form()
150   */   */
151  function workflow_named_transitions_edit_labels_form_submit($form_id, $form_values) {  function workflow_named_transitions_edit_labels_form_submit($form, &$form_state) {
152    foreach ($form_values as $tid => $label) {    foreach ($form_state['values'] as $tid => $label) {
153      if (!empty($tid) && $label != '') {      if (!empty($tid) && $label != '') {
154        db_query("REPLACE INTO {workflow_named_transitions} (tid, label) VALUES (%d, '%s')", $tid, $label, $tid, $label);        db_query("REPLACE INTO {workflow_named_transitions} (tid, label) VALUES (%d, '%s')", $tid, $label, $tid, $label);
155      }      }
# Line 185  function workflow_named_transitions_get_ Line 189  function workflow_named_transitions_get_
189   *   *
190   * Modifies the generic state labels that the workflow module added to the form.   * Modifies the generic state labels that the workflow module added to the form.
191   */   */
192  function workflow_named_transitions_form_alter($form_id, &$form) {  function workflow_named_transitions_form_alter(&$form, $form_state, $form_id) {
193    
194    
195    if (isset($form['workflow']) && is_array($form['workflow'])) {    if (isset($form['workflow']) && is_array($form['workflow'])) {
196      // if no nid, use sysid == 1 from workflow_states for each wid      // if no nid, use sysid == 1 from workflow_states for each wid

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2