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

Diff of /contributions/modules/workflow/workflow.module

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

revision 1.54.2.35, Tue Dec 30 04:13:34 2008 UTC revision 1.54.2.36, Fri Oct 23 15:08:26 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: workflow.module,v 1.54.2.34 2008/07/19 01:45:08 jvandyk Exp $  // $Id: workflow.module,v 1.54.2.35 2008/12/30 04:13:34 jvandyk Exp $
3    
4  define('WORKFLOW_CREATION', 1);  define('WORKFLOW_CREATION', 1);
5  define('WORKFLOW_DELETION', -1);  define('WORKFLOW_DELETION', -1);
# Line 157  function workflow_tab_page($nid) { Line 157  function workflow_tab_page($nid) {
157      $deleted_states[$data->sid] = $data->state;      $deleted_states[$data->sid] = $data->state;
158    }    }
159    $current = workflow_node_current_state($node);    $current = workflow_node_current_state($node);
160    
161    // theme_workflow_current_state() must run state through check_plain().    // theme_workflow_current_state() must run state through check_plain().
162    $output = '<p>'. t('Current state: !state', array('!state' => theme('workflow_current_state', $states[$current]))) . "</p>\n";    $output = '<p>'. t('Current state: !state', array('!state' => theme('workflow_current_state', $states[$current]))) . "</p>\n";
163    $output .= drupal_get_form('workflow_tab_form', $node, $wid, $states, $current);    $output .= drupal_get_form('workflow_tab_form', $node, $wid, $states, $current);
# Line 179  function workflow_tab_page($nid) { Line 179  function workflow_tab_page($nid) {
179      }      }
180      else {      else {
181        // Regular state.        // Regular state.
182        $state_name = check_plain($states[$history->sid]);        $state_name = $states[$history->sid];
183      }      }
184    
185      if (isset($deleted_states[$history->old_sid])) {      if (isset($deleted_states[$history->old_sid])) {
# Line 187  function workflow_tab_page($nid) { Line 187  function workflow_tab_page($nid) {
187        $footer_needed = TRUE;        $footer_needed = TRUE;
188      }      }
189      else {      else {
190        $old_state_name = check_plain($states[$history->old_sid]);        $old_state_name = $states[$history->old_sid];
191      }      }
192      $rows[] = theme('workflow_history_table_row', $history, $old_state_name, $state_name);      $rows[] = theme('workflow_history_table_row', $history, $old_state_name, $state_name);
193    }    }
194    $output .= theme('workflow_history_table', $rows, !empty($footer_needed));    $output .= theme('workflow_history_table', $rows, !empty($footer_needed));
195    $output .= theme('pager', $states_per_page);    $output .= theme('pager', $states_per_page);
196    return $output;    return $output;
197  }  }
# Line 202  function workflow_tab_page($nid) { Line 202  function workflow_tab_page($nid) {
202  function theme_workflow_history_table_row($history, $old_state_name, $state_name) {  function theme_workflow_history_table_row($history, $old_state_name, $state_name) {
203    return array(    return array(
204      format_date($history->stamp),      format_date($history->stamp),
205      $old_state_name,      check_plain(t($old_state_name)),
206      $state_name,      check_plain(t($state_name)),
207      theme('username', $history),      theme('username', $history),
208      filter_xss($history->comment, array('a', 'em', 'strong')),      filter_xss($history->comment, array('a', 'em', 'strong')),
209    );    );
# Line 224  function theme_workflow_history_table($r Line 224  function theme_workflow_history_table($r
224   * Theme the current state in the workflow history table.   * Theme the current state in the workflow history table.
225   */   */
226  function theme_workflow_current_state($state_name) {  function theme_workflow_current_state($state_name) {
227    return '<strong>'. check_plain($state_name) .'</strong>';    return '<strong>'. check_plain(t($state_name)) .'</strong>';
228  }  }
229    
230  /**  /**
231   * Theme a deleted state in the workflow history table.   * Theme a deleted state in the workflow history table.
232   */   */
233  function theme_workflow_deleted_state($state_name) {  function theme_workflow_deleted_state($state_name) {
234    return check_plain($state_name) .'*';    return check_plain(t($state_name)) .'*';
235  }  }
236    
237  /**  /**
# Line 256  function workflow_tab_form(&$node, $wid, Line 256  function workflow_tab_form(&$node, $wid,
256    // Only build form if user has possible target state(s).    // Only build form if user has possible target state(s).
257    if (count($choices) >= $min) {    if (count($choices) >= $min) {
258      $wid = workflow_get_workflow_for_type($node->type);      $wid = workflow_get_workflow_for_type($node->type);
259      $name = check_plain(workflow_get_name($wid));      $name = check_plain(t(workflow_get_name($wid)));
260      // See if scheduling information is present.      // See if scheduling information is present.
261      if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) {      if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) {
262        global $user;        global $user;
# Line 532  function workflow_form_alter($form_id, & Line 532  function workflow_form_alter($form_id, &
532        return;        return;
533      }      }
534    
535      $name = check_plain(workflow_get_name($wid));      $name = check_plain(t(workflow_get_name($wid)));
536    
537      // If the current node state is not one of the choices, autoselect first choice.      // If the current node state is not one of the choices, autoselect first choice.
538      // We know all states in $choices are states that user has permission to      // We know all states in $choices are states that user has permission to
# Line 714  function workflow_select_given_state_act Line 714  function workflow_select_given_state_act
714    $previous_workflow = '';    $previous_workflow = '';
715    $options = array();    $options = array();
716    while ($data = db_fetch_object($result)) {    while ($data = db_fetch_object($result)) {
717      $options[$data->name][$data->sid] = $data->state;      $options[$data->name][$data->sid] = check_plain(t($data->state));
718    }    }
719    $form['target_sid'] = array(    $form['target_sid'] = array(
720      '#type' => 'select',      '#type' => 'select',
# Line 742  function workflow_select_given_state_act Line 742  function workflow_select_given_state_act
742    $state_name = db_result(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $form_values['target_sid']));    $state_name = db_result(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $form_values['target_sid']));
743    return array(    return array(
744      'target_sid' => $form_values['target_sid'],      'target_sid' => $form_values['target_sid'],
745      'state_name' => $state_name,      'state_name' => check_plain(t($state_name)),
746      'force' => $form_values['force'],      'force' => $form_values['force'],
747      'workflow_comment' => $form_values['workflow_comment'],      'workflow_comment' => $form_values['workflow_comment'],
748    );    );
# Line 963  function workflow_permissions($wid) { Line 963  function workflow_permissions($wid) {
963      $wid);      $wid);
964    while ($data = db_fetch_object($result)) {    while ($data = db_fetch_object($result)) {
965      foreach (explode(',', $data->roles) as $role) {      foreach (explode(',', $data->roles) as $role) {
966        $all[$role]['transitions'][] = array($data->state_name, WORKFLOW_ARROW, $data->target_state_name);        $all[$role]['transitions'][] = array(check_plain(t($data->state_name)), WORKFLOW_ARROW, check_plain(t($data->target_state_name)));
967      }      }
968    }    }
969    
# Line 1007  function workflow_edit_form($wid) { Line 1007  function workflow_edit_form($wid) {
1007    );    );
1008    $form['basic']['wf_name'] = array(    $form['basic']['wf_name'] = array(
1009      '#type' => 'textfield',      '#type' => 'textfield',
1010      '#default_value' => $workflow->name,      '#default_value' => check_plain(t($workflow->name)),
1011      '#title' => t('Workflow Name'),      '#title' => t('Workflow Name'),
1012      '#size' => '16',      '#size' => '16',
1013      '#maxlength' => '254',      '#maxlength' => '254',
# Line 1388  function workflow_overview() { Line 1388  function workflow_overview() {
1388          'title' => t('Delete'),          'title' => t('Delete'),
1389          'href' => "admin/build/workflow/delete/$wid"),          'href' => "admin/build/workflow/delete/$wid"),
1390      );      );
1391    
1392      // Allow modules to insert their own workflow operations.      // Allow modules to insert their own workflow operations.
1393      $links = array_merge($links, module_invoke_all('workflow_operations', 'workflow', $wid));      $links = array_merge($links, module_invoke_all('workflow_operations', 'workflow', $wid));
1394    
1395      $states = workflow_get_states($wid);      $states = workflow_get_states($wid);
1396      if (!module_exists('actions')) {      if (!module_exists('actions')) {
1397        unset($links['workflow_overview_actions']);        unset($links['workflow_overview_actions']);
1398      }      }
1399    
1400      $row[] = array($name, theme('links', $links));      $row[] = array(check_plain(t($name)), theme('links', $links));
1401      $subrows = array();      $subrows = array();
1402    
1403      foreach ($states as $sid => $state_name) {      foreach ($states as $sid => $state_name) {
1404        $state_links = array();        $state_links = array();
1405        if (!workflow_is_system_state(t($state_name))) {        if (!workflow_is_system_state(check_plain(t($state_name)))) {
1406          $state_links = array(          $state_links = array(
1407            'workflow_overview_edit_state' => array(            'workflow_overview_edit_state' => array(
1408              'title' => t('Edit'),              'title' => t('Edit'),
# Line 1416  function workflow_overview() { Line 1416  function workflow_overview() {
1416        }        }
1417        // Allow modules to insert state operations.        // Allow modules to insert state operations.
1418        $state_links = array_merge($state_links, module_invoke_all('workflow_operations', 'state', $wid, $sid));        $state_links = array_merge($state_links, module_invoke_all('workflow_operations', 'state', $wid, $sid));
1419        $subrows[] = array(t($state_name), theme('links', $state_links));        $subrows[] = array(check_plain(t($state_name)), theme('links', $state_links));
1420        unset($state_links);        unset($state_links);
1421      }      }
1422    
# Line 1633  function workflow_get_all() { Line 1633  function workflow_get_all() {
1633    $workflows = array();    $workflows = array();
1634    $result = db_query("SELECT wid, name FROM {workflows} ORDER BY name ASC");    $result = db_query("SELECT wid, name FROM {workflows} ORDER BY name ASC");
1635    while ($data = db_fetch_object($result)) {    while ($data = db_fetch_object($result)) {
1636      $workflows[$data->wid] = $data->name;      $workflows[$data->wid] = check_plain(t($data->name));
1637    }    }
1638    
1639    return $workflows;    return $workflows;
# Line 1715  function workflow_get_states($wid = NULL Line 1715  function workflow_get_states($wid = NULL
1715      $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid");      $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid");
1716    }    }
1717    while ($data = db_fetch_object($result)) {    while ($data = db_fetch_object($result)) {
1718      $states[$data->sid] = $data->state;      $states[$data->sid] = check_plain(t($data->state));
1719    }    }
1720    
1721    return $states;    return $states;
# Line 1893  function workflow_allowable_transitions( Line 1893  function workflow_allowable_transitions(
1893      if ($roles == 'ALL'      if ($roles == 'ALL'
1894        || $sid == $t->state_id // Include current state for same-state transitions.        || $sid == $t->state_id // Include current state for same-state transitions.
1895        || workflow_transition_allowed($t->tid, $roles)) {        || workflow_transition_allowed($t->tid, $roles)) {
1896        $transitions[$t->state_id] = $t->state_name;        $transitions[$t->state_id] = check_plain(t($t->state_name));
1897      }      }
1898    }    }
1899    
# Line 1991  function workflow_get_roles() { Line 1991  function workflow_get_roles() {
1991      $result = db_query('SELECT * FROM {role} ORDER BY name');      $result = db_query('SELECT * FROM {role} ORDER BY name');
1992      $roles = array('author' => 'author');      $roles = array('author' => 'author');
1993      while ($data = db_fetch_object($result)) {      while ($data = db_fetch_object($result)) {
1994        $roles[$data->rid] = $data->name;        $roles[$data->rid] = check_plain($data->name);
1995      }      }
1996    }    }
1997    return $roles;    return $roles;
# Line 2103  function workflow_views_arguments() { Line 2103  function workflow_views_arguments() {
2103  function workflow_handler_filter_sid() {  function workflow_handler_filter_sid() {
2104    $result = db_query("SELECT sid, state FROM {workflow_states} ORDER BY weight, state");    $result = db_query("SELECT sid, state FROM {workflow_states} ORDER BY weight, state");
2105    while ($data = db_fetch_object($result)) {    while ($data = db_fetch_object($result)) {
2106      $states[$data->sid] = $data->state;      $states[$data->sid] = check_plain(t($data->state));
2107    }    }
2108    
2109    return $states;    return $states;
# Line 2135  function workflow_handler_arg_sid($op, & Line 2135  function workflow_handler_arg_sid($op, &
2135        return l($query->state, "$arg/$query->sid");        return l($query->state, "$arg/$query->sid");
2136      case 'title':      case 'title':
2137        $state = db_fetch_object(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $query));        $state = db_fetch_object(db_query("SELECT state FROM {workflow_states} WHERE sid = %d", $query));
2138        return $state->state;        return check_plain(t($state->state));
2139    }    }
2140  }  }
2141    

Legend:
Removed from v.1.54.2.35  
changed lines
  Added in v.1.54.2.36

  ViewVC Help
Powered by ViewVC 1.1.2