You are here

function activity_admin_settings in Activity 5

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

Admin section

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

File

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

Code

function activity_admin_settings() {
  $includes = file_scan_directory(drupal_get_path('module', 'activity') . '/includes', '.*', array(
    'CVS',
  ), 'activity_include_module');
  foreach ($includes as $include) {
    $modules[] = module_invoke($include->name, 'activity_info');
  }
  if (!empty($modules)) {
    foreach ($modules as $module) {
      if (!empty($module)) {
        switch (arg(3)) {
          case 'tokens':
            if (variable_get('activity_' . $module['name'] . '_module', 0) == 1) {
              $output = "";
              foreach ($module['tokens'] as $token => $desc) {
                $output .= '[' . $token . ']: <span style="font-weight: normal">' . $desc . '</span><br/>';
              }
              $form['activity_' . $module['name'] . '_token'] = array(
                '#type' => 'fieldset',
                '#title' => $module['name'],
                '#collapsible' => true,
                '#collapsed' => true,
                '#description' => '<div class="messages" style="float:right"><h4>Available Tokens</h4>' . $output . '</div>',
              );
              foreach ($module['ops'] as $op) {
                foreach ($module['types'] as $type => $name) {
                  if (variable_get('activity_' . $module['name'] . '_' . $type, 0) == 1) {
                    $form['activity_' . $module['name'] . '_token']['activity_' . $module['name'] . '_' . $op . '_' . $type . '_token'] = array(
                      '#type' => 'textfield',
                      '#title' => t($op . ' ' . $name),
                      '#default_value' => variable_get('activity_' . $module['name'] . '_' . $op . '_' . $type . '_token', ''),
                    );
                  }
                }
                if (empty($module['types'])) {
                  $form['activity_' . $module['name'] . '_token']['activity_' . $module['name'] . '_' . $op . '_token'] = array(
                    '#type' => 'textfield',
                    '#title' => t($op),
                    '#default_value' => variable_get('activity_' . $module['name'] . '_' . $op . '_token', ''),
                  );
                }
              }
            }
            break;
          default:
            $form['activity_message_limit'] = array(
              '#type' => 'textfield',
              '#title' => 'Message Limit',
              '#description' => t('Set a limit for how many messages display on the activity display.'),
              '#default_value' => variable_get('activity_message_limit', 20),
            );
            $form['activity_' . $module['name']] = array(
              '#type' => 'fieldset',
              '#title' => $module['name'],
              '#collapsible' => true,
              '#collapsed' => false,
            );
            $form['activity_' . $module['name']]['activity_' . $module['name'] . '_module'] = array(
              '#type' => 'checkbox',
              '#title' => $module['name'],
              '#default_value' => variable_get('activity_' . $module['name'] . '_module', 0),
              '#description' => t('Check to enable activity tracking for this module.'),
            );
            if (!empty($module['types'])) {
              $form['activity_' . $module['name']]['activity_' . $module['name'] . '_type'] = array(
                '#type' => 'fieldset',
                '#title' => t('activity types'),
                '#collapsible' => true,
                '#collapsed' => true,
                '#description' => t('Check to enable activity tracking for this type of activity.'),
              );
              foreach ($module['types'] as $type => $name) {
                $form['activity_' . $module['name']]['activity_' . $module['name'] . '_type']['activity_' . $module['name'] . '_' . $type] = array(
                  '#type' => 'checkbox',
                  '#title' => $name,
                  '#default_value' => variable_get('activity_' . $module['name'] . '_' . $type, 0),
                );
              }
            }
            break;
        }
      }
    }
  }
  else {
    $form = array();
    drupal_set_message('No supported modules enabled. Check the activity/includes folder for supported modules.');
  }
  return system_settings_form($form);
}