source: sipes/modules_contrib/workflow/workflow.rules_forms.inc @ 8a8efa8

stableversion-3.0
Last change on this file since 8a8efa8 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100644
File size: 3.1 KB
Línea 
1<?php
2// $Id: workflow.rules_forms.inc,v 1.1.2.2 2010/10/25 01:56:45 jvandyk Exp $
3
4/**
5 * @file
6 * Contains configuration forms for workflow rules integration.
7 */
8
9/**
10 * Configuration form for check transition condition.
11 */
12function workflow_check_transition_form($settings, &$form) {
13  $options = array();
14  $options['ANY'] = t('Any state');
15  foreach (workflow_get_all() as $wid => $workflow) {
16    $options[$workflow] = array();
17    foreach (workflow_get_states($wid) as $sid => $state) {
18      $options[$workflow][$sid] = $state;
19    }
20  }
21  $form['settings']['from_state'] = array(
22    '#type' => 'select',
23    '#title' => t('From State'),
24    '#options' => $options,
25    '#multiple'=> TRUE,
26    '#default_value' => isset($settings['from_state']) ? $settings['from_state'] : array(),
27    '#required' => TRUE,
28  );
29  $form['settings']['to_state'] = array(
30    '#type' => 'select',
31    '#title' => t('To State'),
32    '#options' => $options,
33    '#multiple'=> TRUE,
34    '#default_value' => isset($settings['to_state']) ? $settings['to_state'] : array(),
35    '#required' => TRUE,
36  );
37}
38
39/**
40 * Label callback for check transition condition.
41 */
42function workflow_check_transition_label($settings, $argument_labels) {
43    if (in_array('ANY', $settings['from_state'])) $settings['from_state'] = array('ANY');
44    if (in_array('ANY', $settings['to_state'])) $settings['to_state'] = array('ANY');
45    $from = array();
46    $to = array();
47   foreach ($settings['from_state'] as $state) {
48    if ($state != 'ANY') {
49        $fromtemp = workflow_get_state($state);
50        $from[] = $fromtemp['state'];
51    } else {
52        $from[] = t('Any state');
53    }
54  }
55  foreach ($settings['to_state'] as $state) {
56    if ($state != 'ANY') {
57        $totemp = workflow_get_state($state);
58        $to[] = $totemp['state'];
59    } else {
60        $to[] = t('Any state');
61    }
62  }
63  return t('Check workflow transition from @from to @to', array('@from' => implode(', ',$from), '@to' => implode(', ',$to)));
64}
65
66/**
67 * Configuration form for check state condition.
68 */
69function workflow_check_state_form($settings, &$form) {
70  $options = array();
71  $options['ANY'] = t('Any state');
72  foreach (workflow_get_all() as $wid => $workflow) {
73    $options[$workflow] = array();
74    foreach (workflow_get_states($wid) as $sid => $state) {
75      $options[$workflow][$sid] = $state;
76    }
77  }
78  $form['settings']['state'] = array(
79    '#type' => 'select',
80    '#title' => t('State'),
81    '#options' => $options,
82    '#multiple'=> TRUE,
83    '#default_value' => isset($settings['state']) ? $settings['state'] : array(),
84    '#required' => TRUE,
85  );
86}
87
88/**
89 * Label callback for check state condition.
90 */
91function workflow_check_state_label($settings, $argument_labels) {
92  if (in_array('ANY', $settings['state'])) {
93    $settings['state'] = array('ANY');
94  }
95  $states = array();
96  foreach ($settings['state'] as $state) {
97    if ($state != 'ANY') {
98        $temp = workflow_get_state($state);
99        $states[] = $temp['state'];
100    } else {
101        $states[] = t('Any state');
102    }
103  }
104  return t('Check if content workflow state is @state', array('@state' => implode(', ',$states)));
105}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.