| 1 |
<?php |
<?php |
| 2 |
// $Id: workflow_ng.module,v 1.1.2.15.2.7 2008/07/11 08:19:46 fago Exp $ |
// $Id: workflow_ng.module,v 1.1.2.15.2.8 2008/07/29 10:48:41 fago Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Defines if an execution log should be displayed. |
* Defines if an execution log should be displayed. |
| 22 |
|
|
| 23 |
/* |
/* |
| 24 |
* Returns all defined events. |
* Returns all defined events. |
| 25 |
* |
* |
| 26 |
* @param $op |
* @param $op |
| 27 |
* Set it to 'labels' to get a list of event labels, |
* Set it to 'labels' to get a list of event labels, |
| 28 |
* otherwise you'll get the full definitions. |
* otherwise you'll get the full definitions. |
| 29 |
* @param $key |
* @param $key |
| 30 |
* If set, only return the value for this key. E.g. $op 'labels', |
* If set, only return the value for this key. E.g. $op 'labels', |
| 31 |
* with key 'example' will return the label of the event example. |
* with key 'example' will return the label of the event example. |
| 32 |
*/ |
*/ |
| 33 |
function workflow_ng_get_events($op = 'all', $key = NULL) { |
function workflow_ng_get_events($op = 'all', $key = NULL) { |
| 36 |
|
|
| 37 |
/** |
/** |
| 38 |
* Returns all defined actions. |
* Returns all defined actions. |
| 39 |
* |
* |
| 40 |
* @param $op |
* @param $op |
| 41 |
* As per workflow_ng_get_events(). |
* As per workflow_ng_get_events(). |
| 42 |
* @param $key |
* @param $key |
| 43 |
* As per workflow_ng_get_events(). |
* As per workflow_ng_get_events(). |
| 44 |
*/ |
*/ |
| 54 |
|
|
| 55 |
/** |
/** |
| 56 |
* Returns all defined conditions. |
* Returns all defined conditions. |
| 57 |
* |
* |
| 58 |
* @param $op |
* @param $op |
| 59 |
* As per workflow_ng_get_events(). |
* As per workflow_ng_get_events(). |
| 60 |
* @param $key |
* @param $key |
| 61 |
* As per workflow_ng_get_events(). |
* As per workflow_ng_get_events(). |
| 62 |
*/ |
*/ |
| 66 |
|
|
| 67 |
/* |
/* |
| 68 |
* Returns all defined configurations. |
* Returns all defined configurations. |
| 69 |
* |
* |
| 70 |
* @param $op |
* @param $op |
| 71 |
* As per workflow_ng_get_events(). |
* As per workflow_ng_get_events(). |
| 72 |
* @param $key |
* @param $key |
| 73 |
* As per workflow_ng_get_events(). |
* As per workflow_ng_get_events(). |
| 74 |
*/ |
*/ |
| 83 |
|
|
| 84 |
/** |
/** |
| 85 |
* Gathers module definitions for the given name. |
* Gathers module definitions for the given name. |
| 86 |
* Used for collecting events, configurations, actions and condtions |
* Used for collecting events, configurations, actions and condtions |
| 87 |
* from other modules. |
* from other modules. |
| 88 |
* |
* |
| 89 |
* @param $name |
* @param $name |
| 90 |
* The type of the data item to collect. This is also the name of the |
* The type of the data item to collect. This is also the name of the |
| 91 |
* invoked hook. |
* invoked hook. |
| 92 |
* @param $alter |
* @param $alter |
| 93 |
* If workflow_ng_alter() should be used to let modules alter the data |
* If workflow_ng_alter() should be used to let modules alter the data |
| 94 |
* of other modules. |
* of other modules. |
| 95 |
* @param $op |
* @param $op |
| 96 |
* Set it to 'labels' to get a list of data item labels, |
* Set it to 'labels' to get a list of data item labels, |
| 97 |
* otherwise you'll get the full definitions. |
* otherwise you'll get the full definitions. |
| 98 |
* @param $key |
* @param $key |
| 99 |
* If set, only return the value for this key. E.g. $op 'labels', |
* If set, only return the value for this key. E.g. $op 'labels', |
| 100 |
* with key 'example' will return the label of the data item example. |
* with key 'example' will return the label of the data item example. |
| 101 |
* @param |
* @param |
| 102 |
* $reset If the static cache should be reseted. Note that if set to true, |
* $reset If the static cache should be reseted. Note that if set to true, |
| 103 |
* nothing will be returned. |
* nothing will be returned. |
| 104 |
*/ |
*/ |
| 105 |
function workflow_ng_gather_data($name, $alter = FALSE, $op = 'all', $key = NULL, $reset = FALSE) { |
function workflow_ng_gather_data($name, $alter = FALSE, $op = 'all', $key = NULL, $reset = FALSE) { |
| 119 |
|
|
| 120 |
foreach ($returned as $item_name => $info) { |
foreach ($returned as $item_name => $info) { |
| 121 |
// Set the type to $name, so that element defaults can be applied later. |
// Set the type to $name, so that element defaults can be applied later. |
| 122 |
$info['#type'] = $name; |
$info['#type'] = $name; |
| 123 |
$info['#name'] = $item_name; |
$info['#name'] = $item_name; |
| 124 |
$data[$name]['labels'][$item_name] = $info['#label']; |
$data[$name]['labels'][$item_name] = $info['#label']; |
| 125 |
$data[$name]['all'][$item_name] = $info; |
$data[$name]['all'][$item_name] = $info; |
| 161 |
/** |
/** |
| 162 |
* Returns all active configurations for the event $event_name. |
* Returns all active configurations for the event $event_name. |
| 163 |
* |
* |
| 164 |
* @param $event_name |
* @param $event_name |
| 165 |
* The event name, for which the configurations should be returned. |
* The event name, for which the configurations should be returned. |
| 166 |
* @param $reset |
* @param $reset |
| 167 |
* May be set to true to clear the cache. |
* May be set to true to clear the cache. |
| 168 |
* @return |
* @return |
| 169 |
* The configured configurations for this event. |
* The configured configurations for this event. |
| 170 |
*/ |
*/ |
| 171 |
function workflow_ng_event_get_configurations($event_name = NULL, $reset = FALSE) { |
function workflow_ng_event_get_configurations($event_name = NULL, $reset = FALSE) { |
| 172 |
// We prevent a lot of queries by storing all event names with activated |
// We prevent a lot of queries by storing all event names with activated |
| 173 |
// configurations with variable_set. |
// configurations with variable_set. |
| 174 |
static $configs; |
static $configs; |
| 175 |
|
|
| 195 |
cache_set('cfg_'. $name, 'cache_workflow_ng', serialize($configs[$name])); |
cache_set('cfg_'. $name, 'cache_workflow_ng', serialize($configs[$name])); |
| 196 |
} |
} |
| 197 |
else { |
else { |
| 198 |
// Write in the variable cache, that there are no configs |
// Write in the variable cache, that there are no configs |
| 199 |
// for this event. |
// for this event. |
| 200 |
$variable_cache[$name] = array(); |
$variable_cache[$name] = array(); |
| 201 |
} |
} |
| 218 |
* Gathers the configurations and returns the configurations for the given event. |
* Gathers the configurations and returns the configurations for the given event. |
| 219 |
* This bypasses any database cache! |
* This bypasses any database cache! |
| 220 |
* |
* |
| 221 |
* @param $event_name |
* @param $event_name |
| 222 |
* The event name, for which the configurations should be returned. |
* The event name, for which the configurations should be returned. |
| 223 |
* Leave it empty, to get all configurations sorted by event. |
* Leave it empty, to get all configurations sorted by event. |
| 224 |
* @param $reset |
* @param $reset |
| 225 |
* May be set to true to clear the static cache. |
* May be set to true to clear the static cache. |
| 226 |
*/ |
*/ |
| 227 |
function workflow_ng_get_configurations_by_event($event_name = NULL, $reset = FALSE) { |
function workflow_ng_get_configurations_by_event($event_name = NULL, $reset = FALSE) { |
| 244 |
|
|
| 245 |
/** |
/** |
| 246 |
* Clear the workflow-ng cache. |
* Clear the workflow-ng cache. |
| 247 |
* |
* |
| 248 |
* @param $immediate |
* @param $immediate |
| 249 |
* If FALSE, the static cache will be kept until the next page load. |
* If FALSE, the static cache will be kept until the next page load. |
| 250 |
* Might be dangerous, so only use if you know what you are doing. |
* Might be dangerous, so only use if you know what you are doing. |
| 251 |
*/ |
*/ |
| 261 |
|
|
| 262 |
/** |
/** |
| 263 |
* Invokes configured actions/conditions for the given event. |
* Invokes configured actions/conditions for the given event. |
| 264 |
* |
* |
| 265 |
* @param $event_name |
* @param $event_name |
| 266 |
* As first param pass the event name. |
* As first param pass the event name. |
| 267 |
* @params $args |
* @params $args |
| 268 |
* Pass further arguments as defined in hook_event_info() for this event. |
* Pass further arguments as defined in hook_event_info() for this event. |
| 269 |
*/ |
*/ |
| 270 |
function workflow_ng_invoke_event() { |
function workflow_ng_invoke_event() { |
| 294 |
* Evaluates the configurations by using workflow_ng_evaluate_elements(). |
* Evaluates the configurations by using workflow_ng_evaluate_elements(). |
| 295 |
* Afterwards it cares for saving the modified arguments. |
* Afterwards it cares for saving the modified arguments. |
| 296 |
* |
* |
| 297 |
* @param $configurations |
* @param $configurations |
| 298 |
* The configurations to process. |
* The configurations to process. |
| 299 |
* @param $arguments |
* @param $arguments |
| 300 |
* An array of arguments in format as returned |
* An array of arguments in format as returned |
| 301 |
* from _workflow_ng_process_arguments(). |
* from _workflow_ng_process_arguments(). |
| 302 |
* @param $log |
* @param $log |
| 303 |
* An array of log entries. Set it to FALSE to disable logging, |
* An array of log entries. Set it to FALSE to disable logging, |
| 304 |
* otherwise initialize it with array(). |
* otherwise initialize it with array(). |
| 305 |
*/ |
*/ |
| 306 |
function workflow_ng_evaluate_configurations($configurations, &$arguments, &$log) { |
function workflow_ng_evaluate_configurations($configurations, &$arguments, &$log) { |
| 321 |
|
|
| 322 |
/** |
/** |
| 323 |
* Evaluates the elements in a recursive way. |
* Evaluates the elements in a recursive way. |
| 324 |
* The elements are a tree of configurations, conditions, actions and logical |
* The elements are a tree of configurations, conditions, actions and logical |
| 325 |
* operations (AND, OR,..). |
* operations (AND, OR,..). |
| 326 |
* |
* |
| 327 |
* Each element is executed by using workflow_ng_execute_element(). |
* Each element is executed by using workflow_ng_execute_element(). |
| 330 |
* to customize the evaluation of the children. E.g. the element 'OR' does this and |
* to customize the evaluation of the children. E.g. the element 'OR' does this and |
| 331 |
* evaluates to TRUE if at least one of its children evaluate to TRUE. |
* evaluates to TRUE if at least one of its children evaluate to TRUE. |
| 332 |
* |
* |
| 333 |
* @param $elements |
* @param $elements |
| 334 |
* An array of elements to evaluate. |
* An array of elements to evaluate. |
| 335 |
* @param $arguments |
* @param $arguments |
| 336 |
* An array of arguments in format as returned from |
* An array of arguments in format as returned from |
| 337 |
* _workflow_ng_process_arguments(). |
* _workflow_ng_process_arguments(). |
| 338 |
* @param $log |
* @param $log |
| 339 |
* An array of log entries. Set it to FALSE to disable logging, |
* An array of log entries. Set it to FALSE to disable logging, |
| 340 |
* otherwise initialize it with array(). |
* otherwise initialize it with array(). |
| 341 |
*/ |
*/ |
| 342 |
function workflow_ng_evaluate_elements(&$elements, &$arguments, &$log) { |
function workflow_ng_evaluate_elements(&$elements, &$arguments, &$log) { |
| 348 |
$result = workflow_ng_execute_element($elements, $arguments, $log); |
$result = workflow_ng_execute_element($elements, $arguments, $log); |
| 349 |
} |
} |
| 350 |
|
|
| 351 |
// We default to evaluate like an AND, which means we stop as soon as one |
// We default to evaluate like an AND, which means we stop as soon as one |
| 352 |
// element evaluates to FALSE so if the element hasn't evaluated the children, |
// element evaluates to FALSE so if the element hasn't evaluated the children, |
| 353 |
// start now. |
// start now. |
| 354 |
if ((!isset($elements['#_evaluated']) || $elements['#_evaluated'] == FALSE)) { |
if ((!isset($elements['#_evaluated']) || $elements['#_evaluated'] == FALSE)) { |
| 355 |
$elements['#_evaluated'] = TRUE; |
$elements['#_evaluated'] = TRUE; |
| 374 |
function _workflow_ng_element_sort($a, $b) { |
function _workflow_ng_element_sort($a, $b) { |
| 375 |
if (!is_array($a) || ($b['#type'] == 'action' && $a['#type'] != 'action')) { |
if (!is_array($a) || ($b['#type'] == 'action' && $a['#type'] != 'action')) { |
| 376 |
|
|
| 377 |
return -1; |
return -1; |
| 378 |
} |
} |
| 379 |
if (!is_array($b) || ($a['#type'] == 'action' && $b['#type'] != 'action')) { |
if (!is_array($b) || ($a['#type'] == 'action' && $b['#type'] != 'action')) { |
| 380 |
// Actions always sink down, element properties up. |
// Actions always sink down, element properties up. |
| 381 |
return 1; |
return 1; |
| 382 |
} |
} |
| 383 |
$a += array('#weight' => 0, '#id' => 1000); |
$a += array('#weight' => 0, '#id' => 1000); |
| 384 |
$b += array('#weight' => 0, '#id' => 1000); |
$b += array('#weight' => 0, '#id' => 1000); |
| 404 |
/* |
/* |
| 405 |
* Executes the element by invoking the element type's execution handler. |
* Executes the element by invoking the element type's execution handler. |
| 406 |
* |
* |
| 407 |
* @param $elements |
* @param $elements |
| 408 |
* An array of elements to process. |
* An array of elements to process. |
| 409 |
* @param $arguments |
* @param $arguments |
| 410 |
* An array of arguments in format as returned from |
* An array of arguments in format as returned from |
| 411 |
* _workflow_ng_process_arguments(). |
* _workflow_ng_process_arguments(). |
| 412 |
* @param $log |
* @param $log |
| 413 |
* An array of log entries. Set it to FALSE to disable logging. |
* An array of log entries. Set it to FALSE to disable logging. |
| 414 |
* @return |
* @return |
| 415 |
* The execution result, or FALSE if there is no valid execution handler. |
* The execution result, or FALSE if there is no valid execution handler. |
| 416 |
*/ |
*/ |
| 417 |
function workflow_ng_execute_element(&$element, &$arguments, &$log) { |
function workflow_ng_execute_element(&$element, &$arguments, &$log) { |
| 426 |
|
|
| 427 |
/** |
/** |
| 428 |
* Execution handler for configurations. |
* Execution handler for configurations. |
| 429 |
* |
* |
| 430 |
* We want each configuration to be evaluated, so let the following |
* We want each configuration to be evaluated, so let the following |
| 431 |
* configurations be processed by returning always TRUE. |
* configurations be processed by returning always TRUE. |
| 432 |
* |
* |
| 433 |
*/ |
*/ |
| 445 |
} |
} |
| 446 |
|
|
| 447 |
/** |
/** |
| 448 |
* Execution handler for the OR element. |
* Execution handler for the OR element. |
| 449 |
* |
* |
| 450 |
* @return |
* @return |
| 451 |
* Evaluates to TRUE if at least one children evaluate to TRUE. |
* Evaluates to TRUE if at least one children evaluate to TRUE. |
| 452 |
*/ |
*/ |
| 453 |
function workflow_ng_execute_or(&$elements, &$arguments, &$log) { |
function workflow_ng_execute_or(&$elements, &$arguments, &$log) { |
| 468 |
|
|
| 469 |
/** |
/** |
| 470 |
* Execution handler for the AND element |
* Execution handler for the AND element |
| 471 |
* |
* |
| 472 |
* @return |
* @return |
| 473 |
* Evaluates to TRUE if all children evaluate to TRUE. |
* Evaluates to TRUE if all children evaluate to TRUE. |
| 474 |
*/ |
*/ |
| 475 |
function workflow_ng_execute_and(&$elements, &$arguments, &$log) { |
function workflow_ng_execute_and(&$elements, &$arguments, &$log) { |
| 492 |
/** |
/** |
| 493 |
* Execution handler for actions. |
* Execution handler for actions. |
| 494 |
* |
* |
| 495 |
* @param $element |
* @param $element |
| 496 |
* The action's configuration element. |
* The action's configuration element. |
| 497 |
* @param $arguments |
* @param $arguments |
| 498 |
* An array of arguments in format as returned from |
* An array of arguments in format as returned from |
| 499 |
* _workflow_ng_process_arguments(). |
* _workflow_ng_process_arguments(). |
| 500 |
* @param $log |
* @param $log |
| 501 |
* An array of log entries. Set it to FALSE to disable logging. |
* An array of log entries. Set it to FALSE to disable logging. |
| 502 |
* @return |
* @return |
| 503 |
* TRUE to let workflow_ng proceed wit executing actions, |
* TRUE to let workflow_ng proceed wit executing actions, |
| 504 |
* only FALSE if $result['#halt'] is set. |
* only FALSE if $result['#halt'] is set. |
| 505 |
*/ |
*/ |
| 506 |
function workflow_ng_execute_action($element, &$arguments, &$log) { |
function workflow_ng_execute_action($element, &$arguments, &$log) { |
| 514 |
if (isset($result['#new arguments']) && $result['#new arguments']) { |
if (isset($result['#new arguments']) && $result['#new arguments']) { |
| 515 |
workflow_ng_add_new_arguments($element, $result['#new arguments'], $arguments, $log); |
workflow_ng_add_new_arguments($element, $result['#new arguments'], $arguments, $log); |
| 516 |
} |
} |
| 517 |
// An action may return altered arguments, which will be |
// An action may return altered arguments, which will be |
| 518 |
// saved automatically. |
// saved automatically. |
| 519 |
if (isset($result) && is_array($result)) { |
if (isset($result) && is_array($result)) { |
| 520 |
$reverse_map = array_flip($element['#argument map']); |
$reverse_map = array_flip($element['#argument map']); |
| 541 |
* Execution handler for conditions. |
* Execution handler for conditions. |
| 542 |
* Note: A condition may not alter arguments |
* Note: A condition may not alter arguments |
| 543 |
* |
* |
| 544 |
* @param $element |
* @param $element |
| 545 |
* The condition's configuration element. |
* The condition's configuration element. |
| 546 |
* @param $arguments |
* @param $arguments |
| 547 |
* An array of arguments in format as returned from |
* An array of arguments in format as returned from |
| 548 |
* _workflow_ng_process_arguments(). |
* _workflow_ng_process_arguments(). |
| 549 |
* @param $log |
* @param $log |
| 550 |
* An array of log entries. Set it to FALSE to disable logging. |
* An array of log entries. Set it to FALSE to disable logging. |
| 551 |
* @return |
* @return |
| 552 |
* The execution result of the condition, or if it is no valid condition FALSE. |
* The execution result of the condition, or if it is no valid condition FALSE. |
| 553 |
*/ |
*/ |
| 554 |
function workflow_ng_execute_condition($element, &$arguments, &$log) { |
function workflow_ng_execute_condition($element, &$arguments, &$log) { |
| 582 |
* Returns the execution arguments needed by the given element. |
* Returns the execution arguments needed by the given element. |
| 583 |
* It applies the #argument map and gets all needed arguments. |
* It applies the #argument map and gets all needed arguments. |
| 584 |
* |
* |
| 585 |
* @param $element |
* @param $element |
| 586 |
* The configured element, which is to be executed. |
* The configured element, which is to be executed. |
| 587 |
* @param $arguments |
* @param $arguments |
| 588 |
* An array of arguments in format as returned from |
* An array of arguments in format as returned from |
| 589 |
* _workflow_ng_process_arguments(). |
* _workflow_ng_process_arguments(). |
| 590 |
* @param $log |
* @param $log |
| 591 |
* An array of log entries. Set it to FALSE to disable logging. |
* An array of log entries. Set it to FALSE to disable logging. |
| 592 |
* @return |
* @return |
| 593 |
* If not all execution arguments are available, it returns FALSE. |
* If not all execution arguments are available, it returns FALSE. |
| 594 |
*/ |
*/ |
| 595 |
function workflow_ng_get_execution_arguments(&$element, &$arguments, &$log) { |
function workflow_ng_get_execution_arguments(&$element, &$arguments, &$log) { |
| 602 |
$reverse_map = array_flip($element['#argument map']) + drupal_map_assoc(array_keys($element_info['#arguments'])); |
$reverse_map = array_flip($element['#argument map']) + drupal_map_assoc(array_keys($element_info['#arguments'])); |
| 603 |
$element['#argument map'] = array_flip($reverse_map); |
$element['#argument map'] = array_flip($reverse_map); |
| 604 |
|
|
| 605 |
// Get the right execution arguments by applying the argument map of |
// Get the right execution arguments by applying the argument map of |
| 606 |
// this element. |
// this element. |
| 607 |
foreach ($element_info['#arguments'] as $argument_name => $info) { |
foreach ($element_info['#arguments'] as $argument_name => $info) { |
| 608 |
$event_arg_name = $reverse_map[$argument_name]; |
$event_arg_name = $reverse_map[$argument_name]; |
| 623 |
|
|
| 624 |
/** |
/** |
| 625 |
* Implementation of hook_elements(). |
* Implementation of hook_elements(). |
| 626 |
* Defines default values for all available properties of workflow_ng's |
* Defines default values for all available properties of workflow_ng's |
| 627 |
* element types. |
* element types. |
| 628 |
* |
* |
| 629 |
* Note that the #process handlers are only used by the form API, but not by |
* Note that the #process handlers are only used by the form API, but not by |
| 630 |
* workflow-ng itself. |
* workflow-ng itself. |
| 631 |
*/ |
*/ |
| 632 |
function workflow_ng_elements() { |
function workflow_ng_elements() { |
| 643 |
} |
} |
| 644 |
|
|
| 645 |
/** |
/** |
| 646 |
* Processes the arguments of an event to an array in the style as it is |
* Processes the arguments of an event to an array in the style as it is |
| 647 |
* required for workflow_ng_evaluate_elements(). |
* required for workflow_ng_evaluate_elements(). |
| 648 |
* |
* |
| 649 |
* The returned array format is like: |
* The returned array format is like: |
| 656 |
* Note that the order of the arguments will be kept, as it might be important for passing |
* Note that the order of the arguments will be kept, as it might be important for passing |
| 657 |
* the arguments to further argument loading handlers. |
* the arguments to further argument loading handlers. |
| 658 |
* |
* |
| 659 |
* @param $event |
* @param $event |
| 660 |
* The event info from the currently processed event. |
* The event info from the currently processed event. |
| 661 |
* @param $args |
* @param $args |
| 662 |
* The argument data passed with the event invocation. |
* The argument data passed with the event invocation. |
| 663 |
*/ |
*/ |
| 664 |
function _workflow_ng_process_arguments($event, $args) { |
function _workflow_ng_process_arguments($event, $args) { |
| 680 |
} |
} |
| 681 |
|
|
| 682 |
/** |
/** |
| 683 |
* Returns the needed argument, which is given by the argument name. |
* Returns the needed argument, which is given by the argument name. |
| 684 |
* This function will take care of loading further needed arguments, |
* This function will take care of loading further needed arguments, |
| 685 |
* as necessary. |
* as necessary. |
| 686 |
* |
* |
| 687 |
* @param $arguments |
* @param $arguments |
| 688 |
* The existing arguments in the format as returned from |
* The existing arguments in the format as returned from |
| 689 |
* _workflow_ng_process_arguments(). |
* _workflow_ng_process_arguments(). |
| 690 |
* @param $argument_name |
* @param $argument_name |
| 691 |
* The arguments's machine readable name. |
* The arguments's machine readable name. |
| 692 |
* @param $log |
* @param $log |
| 693 |
* An array of log entries. Set it to FALSE to disable logging. |
* An array of log entries. Set it to FALSE to disable logging. |
| 694 |
*/ |
*/ |
| 695 |
function workflow_ng_element_get_argument(&$arguments, $argument_name, &$log) { |
function workflow_ng_element_get_argument(&$arguments, $argument_name, &$log) { |
| 734 |
|
|
| 735 |
if (array_key_exists('#description', $element) && isset($info['#description'])) { |
if (array_key_exists('#description', $element) && isset($info['#description'])) { |
| 736 |
// Make sure the description is applied. |
// Make sure the description is applied. |
| 737 |
unset($element['#description']); |
unset($element['#description']); |
| 738 |
} |
} |
| 739 |
return $info; |
return $info; |
| 740 |
} |
} |
| 757 |
|
|
| 758 |
/** |
/** |
| 759 |
* A simple helping function, which eases the creation of configurations. |
* A simple helping function, which eases the creation of configurations. |
| 760 |
* Example use case: |
* Example use case: |
| 761 |
* $configuration['or'] = workflow_ng_configure('OR', $condition1, conditions2); |
* $configuration['or'] = workflow_ng_configure('OR', $condition1, conditions2); |
| 762 |
* |
* |
| 763 |
* @param $op |
* @param $op |
| 764 |
* One supported operation like 'AND', 'OR'. If ommitted the passed elements |
* One supported operation like 'AND', 'OR'. If ommitted the passed elements |
| 765 |
* will just be added to the first one. |
* will just be added to the first one. |
| 766 |
* @param $elements |
* @param $elements |
| 767 |
* The elements to configure. |
* The elements to configure. |
| 768 |
*/ |
*/ |
| 769 |
function workflow_ng_configure() { |
function workflow_ng_configure() { |
| 784 |
/** |
/** |
| 785 |
* Configures a condition for using in a configuration. |
* Configures a condition for using in a configuration. |
| 786 |
* |
* |
| 787 |
* @param $name |
* @param $name |
| 788 |
* The name of condition to create, as specified at hook_condition_info(). |
* The name of condition to create, as specified at hook_condition_info(). |
| 789 |
* @param $params |
* @param $params |
| 790 |
* An optional array of properties to add, e.g. #argument_map. |
* An optional array of properties to add, e.g. #argument_map. |
| 791 |
*/ |
*/ |
| 792 |
function workflow_ng_use_condition($name, $params = array()) { |
function workflow_ng_use_condition($name, $params = array()) { |
| 797 |
/** |
/** |
| 798 |
* Configures an action for using in a configuration. |
* Configures an action for using in a configuration. |
| 799 |
* |
* |
| 800 |
* @param $name |
* @param $name |
| 801 |
* The name of action to create, as specified at hook_action_info(). |
* The name of action to create, as specified at hook_action_info(). |
| 802 |
* @param $params |
* @param $params |
| 803 |
* An optional array of properties to add, e.g. #argument_map. |
* An optional array of properties to add, e.g. #argument_map. |
| 804 |
*/ |
*/ |
| 805 |
function workflow_ng_use_action($name, $params = array()) { |
function workflow_ng_use_action($name, $params = array()) { |
| 808 |
} |
} |
| 809 |
|
|
| 810 |
/** |
/** |
| 811 |
* Configures an element of type $type with the further properties $params |
* Configures an element of type $type with the further properties $params |
| 812 |
* for using in a configuration. |
* for using in a configuration. |
| 813 |
*/ |
*/ |
| 814 |
function workflow_ng_use_element($type, $params = array()) { |
function workflow_ng_use_element($type, $params = array()) { |
| 834 |
} |
} |
| 835 |
|
|
| 836 |
/** |
/** |
| 837 |
* Remembers the currently evaluated configurations. With this information, |
* Remembers the currently evaluated configurations. With this information, |
| 838 |
* recursion is prevented. |
* recursion is prevented. |
| 839 |
* |
* |
| 840 |
* @param $add_name |
* @param $add_name |
| 841 |
* If set to FALSE, all already processed configurations will be returned |
* If set to FALSE, all already processed configurations will be returned |
| 842 |
* Otherwise, the passed configuration name will be stored |
* Otherwise, the passed configuration name will be stored |
| 843 |
* for further lookups. |
* for further lookups. |
| 844 |
* @param $reset |
* @param $reset |
| 845 |
* Clears the saved configurations if set. |
* Clears the saved configurations if set. |
| 846 |
*/ |
*/ |
| 847 |
function workflow_ng_evaluated_configurations($add_name = FALSE, $reset = FALSE) { |
function workflow_ng_evaluated_configurations($add_name = FALSE, $reset = FALSE) { |
| 883 |
$cfg = unserialize($row->data); |
$cfg = unserialize($row->data); |
| 884 |
$configurations[$row->name] = $cfg; |
$configurations[$row->name] = $cfg; |
| 885 |
} |
} |
| 886 |
$configurations += workflow_ng_default_configuration(); |
if (function_exists('workflow_ng_default_configuration')) { |
| 887 |
|
$configurations += workflow_ng_default_configuration(); |
| 888 |
|
} |
| 889 |
return $configurations; |
return $configurations; |
| 890 |
} |
} |
| 891 |
|
|
| 892 |
/** |
/** |
| 893 |
* Shows an error message, that a module is missing. |
* Shows an error message, that a module is missing. |
| 894 |
* |
* |
| 895 |
* @param $element |
* @param $element |
| 896 |
* The element, for which the module is missing. |
* The element, for which the module is missing. |
| 897 |
* @param $configuration_name |
* @param $configuration_name |
| 898 |
* The name of the configuration of the element. |
* The name of the configuration of the element. |
| 899 |
*/ |
*/ |
| 900 |
function workflow_ng_missing_module($element, $configuration_name = NULL) { |
function workflow_ng_missing_module($element, $configuration_name = NULL) { |
| 930 |
/** |
/** |
| 931 |
* Determines if the given entity type is supported by the given info. |
* Determines if the given entity type is supported by the given info. |
| 932 |
* |
* |
| 933 |
* @param $entity_type |
* @param $entity_type |
| 934 |
* The entity type to check. |
* The entity type to check. |
| 935 |
* @param $info |
* @param $info |
| 936 |
* The information data containing the #entity property. |
* The information data containing the #entity property. |
| 937 |
*/ |
*/ |
| 938 |
function workflow_ng_is_valid_entity($entity_type, $info) { |
function workflow_ng_is_valid_entity($entity_type, $info) { |
| 958 |
|
|
| 959 |
/** |
/** |
| 960 |
* Saves a modified argument. |
* Saves a modified argument. |
| 961 |
* |
* |
| 962 |
* @param $info |
* @param $info |
| 963 |
* The argument info as specified through hook_event_info(). |
* The argument info as specified through hook_event_info(). |
| 964 |
* @param $argument_name |
* @param $argument_name |
| 965 |
* The name of the argument to save. |
* The name of the argument to save. |
| 966 |
* @param |
* @param |
| 967 |
* $value The new value of the argument. |
* $value The new value of the argument. |
| 968 |
*/ |
*/ |
| 969 |
function workflow_ng_save_argument($info, $argument_name, $value, &$log) { |
function workflow_ng_save_argument($info, $argument_name, $value, &$log) { |