commit 69f4387ac33f9939fd02bc06509748fff37003cb
Author: andrew morton <graveltech@gmail.com>
Date:   Mon Jul 20 16:04:18 2009 -0400

    Lots of admin UI cleanups. The module and operations are now required. Removing the fieldsets since they don't really add anything and end up hiding the required status. Using the proper labels for the types so that user role's names are used rather than id.

diff --git activity.admin.inc activity.admin.inc
index 6dc765a..b3fab52 100644
--- activity.admin.inc
+++ activity.admin.inc
@@ -57,7 +57,7 @@ function activity_user_settings_submit($form, &$form_state) {
 /**
  * Menu callback to administer activity messages.
  */
-function activity_form($form_state, $arg1 = NULL, $arg2 = NULL) {
+function activity_form(&$form_state, $arg1 = NULL, $arg2 = NULL) {
   if (!empty($form_state['storage']['step'])) {
     $function = $form_state['storage']['step'];
     return $function($form_state);
@@ -204,14 +204,8 @@ function _activity_settings_actions_list_form() {
 /**
  * List of modules that implement activity_info().
  */
-function _activity_settings_form_triggers($form_state) {
+function _activity_settings_form_triggers(&$form_state) {
   $form = array();
-  $form['modules'] = array(
-    '#type' => 'fieldset',
-    '#collapsible' => FALSE,
-    '#title' => t('Available Activity Types'),
-    '#description' => t('Please choose which type of activity you would like to record.'),
-  );
 
   foreach (activity_get_module_info() as $module => $info) {
     if (!empty($info->hooks)) {
@@ -220,13 +214,15 @@ function _activity_settings_form_triggers($form_state) {
       }
     }
   }
-  $default_value = $form_state['storage']['values']['triggers']['module'];
-  $form['modules']['module'] = array(
+  $form['module'] = array(
     '#type' => 'radios',
+    '#title' => t('Available Activity Types'),
     '#options' => $options,
-    '#default_value' => $default_value,
-  );  
-  
+    '#default_value' => $form_state['storage']['values']['triggers']['module'],
+    '#required' => TRUE,
+    '#description' => t('Please choose which type of activity you would like to record.'),
+  );
+
   $form['continue'] = array(
     '#type' => 'submit',
     '#value' => 'Continue',
@@ -245,7 +241,7 @@ function _activity_settings_form_triggers($form_state) {
 /**
  * List the ops for the module selected in the _triggers step.
  */
-function _activity_settings_form_operations($form_state) {
+function _activity_settings_form_operations(&$form_state) {
   $form = array();
   $module = $form_state['storage']['values']['triggers']['module'];
   // stupid freaking special case for node - nodeapi
@@ -265,21 +261,18 @@ function _activity_settings_form_operations($form_state) {
       $ops[$module][$op] = $trigger_ops[$module][$op];
     }
     foreach ($ops as $trigger_name => $hooks) {
-      $form[$trigger_name] = array(
-        '#type' => 'fieldset',
-        '#collapsible' => FALSE,
-        '#title' => t(drupal_ucfirst(str_replace('_', ' ', $trigger_name)) .' Triggers'),
-        '#description' => t('Please choose when you would like to record a message.'),
-      );
       $options = array();
-      $default_value = isset($form_state['storage']['values']['operations']['operation']) ? $form_state['storage']['values']['operations']['operation'] : '';
       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,
       );
     }
   }
@@ -292,10 +285,10 @@ function _activity_settings_form_operations($form_state) {
     }
     $form['activity_types'] = array(
       '#type' => 'checkboxes',
-      '#title' => t('Record for the following Types'),
+      '#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'),
+      '#description' => t('If none are selected then these messages will be recorded for all.'),
     );
   }
 
@@ -344,8 +337,14 @@ function _activity_settings_form_messages(&$form_state) {
       $operation = $form_state['storage']['values']['operations']['operation'] = $row['op'];
     }
   }
+  // stupid freaking special case for node - nodeapi
+  if ($module == 'nodeapi') {
+    $module = 'node';
+  }
+  $module_info = activity_get_module_info($module);
+
   if (isset($form_state['storage']['action'])) {
-    $default_values = unserialize($parameters = $form_state['storage']['action']->parameters);
+    $default_values = unserialize($form_state['storage']['action']->parameters);
   }
   else {
     $default_values = array();
@@ -362,36 +361,28 @@ function _activity_settings_form_messages(&$form_state) {
     }
   }
   $form_state['storage']['values']['operations']['activity_types'] = $activity_types;
-  // stupid checkboxes
-  foreach ($activity_types as $type => $value) {
-    if (empty($value)) {
-      unset($activity_types[$type]);
-    }
-  }
-  
+
+  // Filter out false checkboxes.
+  $activity_types = array_filter($activity_types);
+
   if (empty($activity_types)) {
     $types = 'All';
   }
   else {
-    $types = implode(', ' , array_values($activity_types));
+    $types = implode(', ' , array_intersect_key($module_info->type_options, $activity_types));
   }
 
-  // stupid freaking special case for node - nodeapi
-  if ($module == 'nodeapi') {
-    $module = 'node';
-  }
-  
   $form['description'] = array(
     '#type' => 'textfield',
     '#title' => t('Description'),
-    '#default_value' => isset($form_state['storage']['action']) ? $form_state['storage']['action']->description : t('Record an activity message when: !module !op types !types', array('!module' => $module, '!op' => $operation, '!types' => $types)),    '#maxlength' => '254',
+    '#default_value' => isset($form_state['storage']['action']) ? $form_state['storage']['action']->description : t('Record an activity message when: !module !op types !types', array('!module' => $module, '!op' => $operation, '!types' => $types)),
+    '#maxlength' => '254',
     '#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.'),
   );
-  $info = activity_get_module_info($module);
   // @todo: extend ->objects to have a description which will fill out the
   //  #description for this form element. Remember to adjust logic everywhere
   //  ->objects is used.
-  foreach ($info->objects as $label => $type) {
+  foreach ($module_info->objects as $label => $type) {
     $clean_type = drupal_ucfirst(str_replace('_', ' ', $label));
     $form[$type .'-pattern'] = array(
       '#type' => 'textfield',
@@ -438,7 +429,7 @@ function _activity_settings_form_messages(&$form_state) {
   );
   $form['token_help']['tokens'] = array(
     '#type' => 'markup',
-    '#value' => theme('activity_token_help', array_values($info->objects)),
+    '#value' => theme('activity_token_help', array_values($module_info->objects)),
   );
 
   $form['aid'] = array(
@@ -455,7 +446,7 @@ function _activity_settings_form_messages(&$form_state) {
  * @ingroup forms
  * @see activity_actions_delete_form_submit()
  */
-function activity_actions_delete_form($form_state, $action) {
+function activity_actions_delete_form(&$form_state, $action) {
   $form['aid'] = array(
     '#type' => 'hidden',
     '#value' => $action->aid,
@@ -477,8 +468,7 @@ function activity_actions_delete_form_submit($form, &$form_state) {
   $aid = $form_state['values']['aid'];
   $action = actions_load($aid);
   actions_delete($aid);
-  $description = check_plain($action->description);
-  watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $description));
+  watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->description));
   drupal_set_message(t('Action %action was deleted', array('%action' => $description)));
   $form_state['redirect'] = 'admin/settings/activity/list';
 }
@@ -486,7 +476,7 @@ function activity_actions_delete_form_submit($form, &$form_state) {
 /**
  * Form builder to dispaly settings for activity module
  */
-function activity_settings_form($form_state = NULL) {
+function activity_settings_form(&$form_state = NULL) {
   global $db_type;
   $form['activity_expiration'] = array(
     '#type' => 'fieldset',
