Index: signup_status.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup_status/signup_status.module,v
retrieving revision 1.8
diff -u -p -r1.8 signup_status.module
--- signup_status.module	23 Jan 2009 14:00:14 -0000	1.8
+++ signup_status.module	24 Jan 2009 23:46:39 -0000
@@ -14,22 +14,6 @@ define('SIGNUP_STATUS_MANAGE_PERMISSION'
 // Core API hooks
 
 /**
- * Implementation of hook_init().
- */
-function signup_status_init() {
-  foreach (signup_status_codes() as $cid => $code) {
-    eval('
-      function signup_status_change_status_to_'. $cid .'($signup) {
-        $cid = '. $cid .';
-        $codes = signup_status_codes();
-        db_query("UPDATE {signup_log} SET status = %d WHERE sid = %d", $cid, $signup->sid);
-        watchdog(\'action\', "Set status of %signup_label to %status_name.", array(\'%signup_label\' => $signup->label, \'%status_name\' => $codes[$cid][\'name\']));
-      }
-   ');
-  }
-}
-
-/**
  * Implementation of hook_perm().
  */
 function signup_status_perm() {
@@ -84,15 +68,13 @@ function signup_status_menu() {
  * Implementation of hook_action_info().
  */
 function signup_status_action_info() {
-  $info = array();
-  foreach (signup_status_codes() as $cid => $code) {
-    $info['signup_status_change_status_to_'. $cid] = array(
+  return array(
+    'signup_status_alter_action' => array(
       'type' => 'signup',
-      'description' => t('Change signup status to !status', array('!status' => $code['name'])),
-      'configurable' => FALSE,
-    );
-  }
-  return $info;
+      'description' => t('Alter signup status'),
+      'configurable' => TRUE,
+    ),
+  );
 }
 
 /**
@@ -126,6 +108,52 @@ function signup_status_views_api() {
 }
 
 //////////////////////////////////////////////////////////////////////////////
+// Actions integration
+
+/**
+ * Perform the action to alter the signup status of a given signup.
+ */
+function signup_status_alter_action(&$signup, $context) {
+  $status_codes = signup_status_codes();
+  $signup->status = $context['signup_status'];
+  db_query("UPDATE {signup_log} SET status = %d WHERE sid = %d", $signup->status, $signup->sid);
+  watchdog('action', 'Set status of %signup_label to %status_name.', array('%signup_label' => $signup->label, '%status_name' => $status_codes[$signup->status]['name']));
+}
+
+/**
+ * Create the configuration form to select which signup status to use.
+ */
+function signup_status_alter_action_form($context) {
+  $options = array();
+  foreach (signup_status_codes() as $cid => $code) {
+    $options[$cid] = $code['name'];
+  }
+  $form['signup_status'] = array(
+    '#type' => 'select',
+    '#title' => t('Signup status'),
+    '#options' => $options,
+  );
+  return $form;
+}
+
+/**
+ * Validate the form to select which signup status to use for the alter action.
+ */
+function signup_status_alter_action_validate($form, $form_state) {
+  if ($form_state['values']['signup_status'] == 0) {
+    form_set_error('signup_status', t('You must select a status.'));
+  }
+}
+
+/**
+ * Submit handler for the form to select which signup status to use.
+ */
+function signup_status_alter_action_submit($form, $form_state) {
+  return array('signup_status' => $form_state['values']['signup_status']);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
 // Signup form altering
 
 /**
