| 1 |
<?php |
<?php |
| 2 |
// $Id: rules.admin.inc,v 1.1.2.49 2008/08/29 12:07:30 fago Exp $ |
// $Id: rules.admin.inc,v 1.1.2.50 2008/08/30 08:06:28 fago Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file Rules Admin UI |
* @file Rules Admin UI |
| 275 |
drupal_set_message(t("The rule %label has been updated.", array('%label' => $rule_ref['#label']))); |
drupal_set_message(t("The rule %label has been updated.", array('%label' => $rule_ref['#label']))); |
| 276 |
} |
} |
| 277 |
|
|
| 278 |
/* |
/** |
| 279 |
* Returns the form for the add operation |
* Returns the form for the add operation |
| 280 |
* This handles adding conditions and actions |
* This handles adding conditions and actions |
| 281 |
* |
* |
| 295 |
$element =& $form_state['element']; |
$element =& $form_state['element']; |
| 296 |
$element += array('#id' => NULL); |
$element += array('#id' => NULL); |
| 297 |
|
|
| 298 |
|
// Due to adding storage during the form build, the form will be rebuilt |
| 299 |
|
// immediately. So be sure to increase the step only out of a #submit callback. |
| 300 |
|
// Also see http://drupal.org/node/302240. |
| 301 |
|
|
| 302 |
if ($form_state['step'] == 0) { |
if ($form_state['step'] == 0) { |
| 303 |
if (isset($parent_id) && is_array($parent = $proxy->get_element(intval($parent_id)))) { |
if (isset($parent_id) && is_array($parent = $proxy->get_element(intval($parent_id)))) { |
| 304 |
if (function_exists($function = 'rules_admin_form_add_'. $element['#type'])) { |
if (function_exists($function = 'rules_admin_form_add_'. $element['#type'])) { |
|
$form_state['step']++; |
|
| 305 |
$form_state['parent_id'] = intval($parent_id); |
$form_state['parent_id'] = intval($parent_id); |
| 306 |
_rules_element_defaults($parent); |
_rules_element_defaults($parent); |
| 307 |
return $function($form_state, $element, $parent); |
$form = $function($form_state, $element, $parent); |
| 308 |
|
rules_admin_form_pack_storage($form, $form_state); |
| 309 |
|
return $form; |
| 310 |
} |
} |
| 311 |
} |
} |
| 312 |
} |
} |
| 313 |
else { |
else { |
| 314 |
if (function_exists($function = 'rules_admin_form_edit_'. $type)) { |
if (function_exists($function = 'rules_admin_form_edit_'. $type)) { |
| 315 |
$form_state['step']++; |
$form = $function($form_state, $element); |
| 316 |
return $function($form_state, $element); |
rules_admin_form_pack_storage($form, $form_state); |
| 317 |
|
return $form; |
| 318 |
} |
} |
| 319 |
} |
} |
| 320 |
} |
} |
| 338 |
'#type' => 'submit', |
'#type' => 'submit', |
| 339 |
'#weight' => 10, |
'#weight' => 10, |
| 340 |
'#value' => t('Forward'), |
'#value' => t('Forward'), |
| 341 |
'#submit' => array('rules_admin_form_add_submit', 'rules_admin_form_pack_storage'), |
'#submit' => array('rules_admin_form_unpack_storage', 'rules_admin_form_add_submit'), |
| 342 |
); |
); |
| 343 |
return $form; |
return $form; |
| 344 |
} |
} |
| 361 |
'#type' => 'submit', |
'#type' => 'submit', |
| 362 |
'#weight' => 10, |
'#weight' => 10, |
| 363 |
'#value' => t('Forward'), |
'#value' => t('Forward'), |
| 364 |
'#submit' => array('rules_admin_form_add_submit', 'rules_admin_form_pack_storage'), |
'#submit' => array('rules_admin_form_unpack_storage', 'rules_admin_form_add_submit'), |
| 365 |
); |
); |
| 366 |
return $form; |
return $form; |
| 367 |
} |
} |
| 395 |
|
|
| 396 |
function rules_admin_form_add_submit($form, &$form_state) { |
function rules_admin_form_add_submit($form, &$form_state) { |
| 397 |
$form_state['element']['#name'] = $form_state['values']['name']; |
$form_state['element']['#name'] = $form_state['values']['name']; |
| 398 |
|
$form_state['step']++; |
| 399 |
rules_init_element_info($form_state['element']); |
rules_init_element_info($form_state['element']); |
| 400 |
} |
} |
| 401 |
|
|
| 414 |
/** |
/** |
| 415 |
* Use this when the current form is or might be not the first step of the form. |
* Use this when the current form is or might be not the first step of the form. |
| 416 |
* It puts the variables out of storage on their usual place. |
* It puts the variables out of storage on their usual place. |
|
* Note: We can't use the storage place everywhere, as it would result in unnecessary form rebuilds |
|
|
* when building the form initially. |
|
| 417 |
*/ |
*/ |
| 418 |
function rules_admin_form_unpack_storage($form, &$form_state) { |
function rules_admin_form_unpack_storage($form, &$form_state) { |
| 419 |
foreach (array('proxy', 'step', 'element', 'parent_id') as $key) { |
foreach (array('proxy', 'step', 'element', 'parent_id') as $key) { |