You are here

function activity_admin_settings in Activity 5.3

Same name and namespace in other branches
  1. 5.4 activity.module \activity_admin_settings()
  2. 5 activity.module \activity_admin_settings()
  3. 5.2 activity.module \activity_admin_settings()
  4. 6 activity.module \activity_admin_settings()

Admin section TODO: 1) the defaults aren't available at activity render time unless this this page has been saved. This is potentially confusing since they show up in the textfields.

1 string reference to 'activity_admin_settings'
activity_menu in ./activity.module
Implementation of hook_menu().

File

./activity.module, line 96
Activity module: Allow users to see their friends' activity on the site.

Code

function activity_admin_settings() {
  if ($activity_info = activity_get_info()) {
    $form['general_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('General settings'),
      '#collapsible' => FALSE,
    );
    $form['general_settings']['activity_time_limit'] = array(
      '#type' => 'select',
      '#title' => t('Activity time limiter'),
      '#description' => t("Allows you to set a time limit for recording activity so repeated actions don't flood your activity feed. If the same action is submitted within X seconds of the last activity record of the same type from the same user then the activity is not logged."),
      '#options' => drupal_map_assoc(array(
        5,
        10,
        20,
        30,
        60,
        120,
        300,
        600,
        1800,
      ), format_interval),
      '#default_value' => variable_get('activity_time_limit', 30),
    );
    foreach ($activity_info as $module => $info) {
      if (!empty($info)) {
        $tokens = array();
        $token_list = array();
        foreach (token_get_list($module) as $name => $token_array) {
          $token_list = array_merge($token_list, $token_array);
        }
        foreach (token_get_list('activity') as $name => $token_array) {
          $token_list = array_merge($token_list, $token_array);
        }
        ksort($token_list);
        foreach ($token_list as $token => $desc) {
          $tokens[] = '[' . $token . ']: ' . $desc;
        }
        if (count($info['types'])) {
          $form[$module] = array(
            '#type' => 'fieldset',
            '#title' => t('Tokens for @name', array(
              '@name' => t($module),
            )),
            '#collapsible' => true,
            '#collapsed' => true,
            '#description' => t('Available tokens') . theme('item_list', $tokens),
          );
          if ($ops = $info['ops']) {
            if ($roles = $info['roles']) {
              foreach ($roles as $role_name => $role) {
                $form[$module][$role_name] = array(
                  '#type' => 'fieldset',
                  '#title' => t('Messages visible to the "@role_name" role.', array(
                    '@role_name' => $role['#name'],
                  )),
                  '#collapsible' => true,
                  '#collapsed' => false,
                  '#description' => $role['#description'] ? $role['#description'] : '',
                );
              }
              if ($types = $info['types']) {
                foreach ($ops as $op_name => $op) {
                  foreach ($info['types'] as $type_name => $type) {
                    foreach ($roles as $role_name => $role) {
                      $token_field = "{$module}_{$type_name}_{$op_name}_{$role_name}";
                      $form[$module][$role_name][$token_field] = array(
                        '#type' => 'textfield',
                        '#title' => $type . ': ' . $op,
                        '#default_value' => variable_get($token_field, $role['#default'] ? $role['#default'] : ''),
                      );
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    drupal_set_message('You must save this form in order for your tokens to work.');
    return system_settings_form($form);
  }
  else {
    drupal_set_message(t('No supported modules enabled. Check the !activity_section for supported modules.', array(
      '!activity_section' => l(t('Activity section'), 'admin/build/modules'),
    )));
  }
}