You are here

function _activity_settings_form_operations in Activity 6.2

List the ops for the module selected in the _triggers step.

2 string references to '_activity_settings_form_operations'
_activity_settings_form_messages in ./activity.admin.inc
Show the text boxes according to the _triggers and _ops steps.
_activity_settings_form_triggers in ./activity.admin.inc
List of modules that implement activity_info().

File

./activity.admin.inc, line 249
activity.admin.inc Contains administrative forms for activity.module

Code

function _activity_settings_form_operations(&$form_state) {
  $form = array();
  $hook = $form_state['storage']['values']['triggers']['hook'];
  $module = activity_module_name($hook);
  foreach (call_user_func($module . '_hook_info') as $module => $trigger_ops) {

    // Compare ops with our activity_info so that we do not provide a trigger
    // that activity doesn't support (ex: nodeapi - presave)
    // @see: node_activity_info()
    $module_info = activity_get_module_info($module);
    foreach ($module_info->hooks[$hook] as $op) {
      $ops[$hook][$op] = $trigger_ops[$hook][$op];
    }
    foreach ($ops as $trigger_name => $hooks) {
      $options = array();
      foreach ($hooks as $op => $runs_when) {
        $options[$op] = $op . ': ' . $runs_when['runs when'];
      }
      $default_value = isset($form_state['storage']['values']['operations']['operation']) ? $form_state['storage']['values']['operations']['operation'] : '';
      $form[$trigger_name]['operation'] = array(
        '#type' => 'radios',
        '#title' => t(drupal_ucfirst(str_replace('_', ' ', $trigger_name)) . ' Triggers'),
        '#description' => t('Please choose when you would like to record a message.'),
        '#options' => $options,
        '#default_value' => $default_value,
        '#required' => TRUE,
      );
    }
  }
  if (!empty($module_info->type_options)) {
    if (!empty($form_state['storage']['values']['operations']['activity_types'])) {
      $default_types = $form_state['storage']['values']['operations']['activity_types'];
    }
    else {
      $default_types = array();
    }
    $form['activity_types'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Record for the following types'),
      '#options' => $module_info->type_options,
      '#default_value' => $default_types,
      '#description' => t('If none are selected then these messages will be recorded for all.'),
    );
  }
  $form['back'] = array(
    '#type' => 'submit',
    '#value' => 'Back',
  );
  $form['continue'] = array(
    '#type' => 'submit',
    '#value' => 'Continue',
  );
  $form['step_prev'] = array(
    '#type' => 'value',
    '#value' => '_activity_settings_form_triggers',
  );
  $form['this_step'] = array(
    '#type' => 'value',
    '#value' => 'operations',
  );
  $form['step_next'] = array(
    '#type' => 'value',
    '#value' => '_activity_settings_form_messages',
  );
  return $form;
}