Same name and namespace in other branches
  1. 7.x modules/system/system.admin.inc \system_actions_configure()

Menu callback. Create the form for configuration of a single action.

We provide the "Description" field. The rest of the form is provided by the action. We then provide the Save button. Because we are combining unknown form elements with the action configuration form, we use actions_ prefix on our elements.

Parameters

$action: md5 hash of action ID or an integer. If it's an md5 hash, we are creating a new instance. If it's an integer, we're editing an existing instance.

Return value

Form definition.

See also

system_actions_configure_validate()

system_actions_configure_submit()

1 string reference to 'system_actions_configure'
system_menu in modules/system/system.module
Implementation of hook_menu().

File

modules/system/system.module, line 1504
Configuration system that lets administrators modify the workings of the site.

Code

function system_actions_configure($form_state, $action = NULL) {
  if ($action === NULL) {
    drupal_goto('admin/settings/actions');
  }
  $actions_map = actions_actions_map(actions_list());
  $edit = array();

  // Numeric action denotes saved instance of a configurable action;
  // else we are creating a new action instance.
  if (is_numeric($action)) {
    $aid = $action;

    // Load stored parameter values from database.
    $data = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $aid));
    $edit['actions_description'] = $data->description;
    $edit['actions_type'] = $data->type;
    $function = $data->callback;
    $action = md5($data->callback);
    $params = unserialize($data->parameters);
    if ($params) {
      foreach ($params as $name => $val) {
        $edit[$name] = $val;
      }
    }
  }
  else {
    $function = $actions_map[$action]['callback'];
    $edit['actions_description'] = $actions_map[$action]['description'];
    $edit['actions_type'] = $actions_map[$action]['type'];
  }
  $form['actions_description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#default_value' => $edit['actions_description'],
    '#maxlength' => '255',
    '#description' => t('A unique description for this advanced action. This description will be displayed in the interface of modules that integrate with actions, such as Trigger module.'),
    '#weight' => -10,
  );
  $action_form = $function . '_form';
  $form = array_merge($form, $action_form($edit));
  $form['actions_type'] = array(
    '#type' => 'value',
    '#value' => $edit['actions_type'],
  );
  $form['actions_action'] = array(
    '#type' => 'hidden',
    '#value' => $action,
  );

  // $aid is set when configuring an existing action instance.
  if (isset($aid)) {
    $form['actions_aid'] = array(
      '#type' => 'hidden',
      '#value' => $aid,
    );
  }
  $form['actions_configured'] = array(
    '#type' => 'hidden',
    '#value' => '1',
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 13,
  );
  return $form;
}