You are here

function rules_ui_form_execute_rules_config in Rules 7.2

Configuration form to directly execute a rules configuration.

1 string reference to 'rules_ui_form_execute_rules_config'
RulesUIController::config_menu in ui/ui.controller.inc
Generates menu items to manipulate rules configurations.

File

ui/ui.forms.inc, line 117
Rules User Interface forms.

Code

function rules_ui_form_execute_rules_config($form, &$form_state, $rules_config, $base_path) {

  // Only components can be executed.
  if (!$rules_config instanceof RulesTriggerableInterface) {
    RulesPluginUI::$basePath = $base_path;

    // Create either the appropriate action or condition element.
    $element = rules_plugin_factory($rules_config instanceof RulesActionInterface ? 'action' : 'condition', 'component_' . $rules_config->name);
    $form['exec_help'] = array(
      '#prefix' => '<p>',
      '#markup' => t('This form allows you to manually trigger the execution of the @plugin "%label". If this component requires any parameters, input the suiting execution arguments below.', array(
        '@plugin' => $rules_config
          ->plugin(),
        '%label' => $rules_config
          ->label(),
      )),
      '#suffix' => '</p>',
    );
    $element
      ->form($form, $form_state);

    // For conditions hide the option to negate them.
    if (isset($form['negate'])) {
      $form['negate']['#access'] = FALSE;
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Execute'),
      '#weight' => 20,
    );

    // Re-use the validation callback, which will also populate the action with
    // the configuration settings in the form.
    $form['#validate'] = array(
      'rules_ui_form_rules_config_validate',
    );
    return $form;
  }
  drupal_not_found();
  exit;
}