protected function _allowed_values_string($wid = 0)
 {
     $lines = array();
     $states = WorkflowState::getStates($wid);
     $previous_wid = -1;
     foreach ($states as $state) {
         // Only show enabled states.
         if ($state->status) {
             // Show a Workflow name between Workflows, if more then 1 in the list.
             if ($wid == 0 && $previous_wid != $state->wid) {
                 $previous_wid = $state->wid;
                 $lines[] = $state->name . "'s states: ";
             }
             $label = t($state->label());
             $states[$state->sid] = check_plain($label);
             $lines[] = $state->sid . ' | ' . check_plain($label);
         }
     }
     return implode("\n", $lines);
 }
 /**
  * Get all states in the system, with options to filter, only where a workflow exists.
  *
  * May return more then one State, since a name is not (yet) an UUID.
  */
 public static function getStatesByName($name, $wid)
 {
     foreach ($states = WorkflowState::getStates($wid) as $state) {
         if ($name != $state->getName()) {
             unset($states[$state->sid]);
         }
     }
     return $states;
 }
Exemple #3
0
 /**
  * Gets all states for a given workflow.
  *
  * @param mixed $all
  *   Indicates to which states to return.
  *   - TRUE = all, including Creation and Inactive;
  *   - FALSE = only Active states, not Creation;
  *   - 'CREATION' = only Active states, including Creation.
  *
  * @return array
  *   An array of WorkflowState objects.
  */
 public function getStates($all = FALSE, $reset = FALSE)
 {
     if ($this->states === NULL || $reset) {
         $this->states = $this->wid ? WorkflowState::getStates($this->wid, $reset) : array();
     }
     // Do not unset, but add to array - you'll remove global objects otherwise.
     $states = array();
     foreach ($this->states as $state) {
         if ($all === TRUE) {
             $states[$state->sid] = $state;
         } elseif ($all === FALSE && ($state->isActive() && !$state->isCreationState())) {
             $states[$state->sid] = $state;
         } elseif ($all == 'CREATION' && ($state->isActive() || $state->isCreationState())) {
             $states[$state->sid] = $state;
         }
     }
     return $states;
 }
 /**
  * Gets all states for a given workflow.
  *
  * @param bool $all
  *   Indicates to return all (TRUE) or active (FALSE) states of a workflow.
  *
  * @return array $states
  *   An array of WorkflowState objects.
  */
 public function getStates($all = FALSE)
 {
     $states = WorkflowState::getStates($this->wid);
     if (!$all) {
         foreach ($states as $state) {
             if (!$state->isActive() && !$state->isCreationState()) {
                 unset($states[$state->sid]);
             }
         }
     }
     return $states;
 }