? flag_events.patch
Index: flag.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/Attic/flag.inc,v
retrieving revision 1.1.2.30.2.17
diff -u -p -r1.1.2.30.2.17 flag.inc
--- flag.inc	3 Nov 2009 03:09:05 -0000	1.1.2.30.2.17
+++ flag.inc	4 Nov 2009 15:19:19 -0000
@@ -186,6 +186,7 @@ class flag_flag {
    */
   function options() {
     $options = array(
+      'events' => array('flag', 'unflag'),
       'flag_short' => '',
       'flag_long' => '',
       'flag_message' => '',
@@ -206,6 +207,7 @@ class flag_flag {
 
     // Allow other modules to change the flag options.
     drupal_alter('flag_options', $this, $options);
+    dsm($options);
     return $options;
   }
 
@@ -236,6 +238,7 @@ class flag_flag {
     foreach ($form_values as $field => $value) {
       $this->$field = $value;
     }
+    // @todo: events
     // But checkboxes need some massaging:
     $this->roles['flag'] = array_values(array_filter($this->roles['flag']));
     $this->roles['unflag'] = array_values(array_filter($this->roles['unflag']));
@@ -568,7 +571,6 @@ class flag_flag {
       }
       if ($flagged) {
         $fcid = $this->_unflag($content_id, $uid, $sid);
-        module_invoke_all('flag', 'unflag', $this, $content_id, $account, $fcid);
       }
     }
     elseif ($action == 'flag') {
@@ -577,9 +579,9 @@ class flag_flag {
       }
       if (!$flagged) {
         $fcid = $this->_flag($content_id, $uid, $sid);
-        module_invoke_all('flag', 'flag', $this, $content_id, $account, $fcid);
       }
     }
+    module_invoke_all('flag', $action, $this, $content_id, $account, $fcid);
 
     return TRUE;
   }
Index: includes/flag.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/includes/Attic/flag.admin.inc,v
retrieving revision 1.1.4.2.2.9
diff -u -p -r1.1.4.2.2.9 flag.admin.inc
--- includes/flag.admin.inc	3 Nov 2009 02:10:45 -0000	1.1.4.2.2.9
+++ includes/flag.admin.inc	4 Nov 2009 15:19:20 -0000
@@ -245,56 +245,40 @@ function flag_form(&$form_state, $name, 
     '#type' => 'fieldset',
     '#title' => t('Messages'),
   );
-
-  $form['messages']['flag_short'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Flag link text'),
-    '#default_value' => $flag->flag_short,
-    '#description' => t('The text for the "flag this" link for this flag.'),
-    '#required' => TRUE,
-    '#access' => empty($flag->locked['flag_short']),
-  );
-
-  $form['messages']['flag_long'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Flag link description'),
-    '#default_value' => $flag->flag_long,
-    '#description' => t('The description of the "flag this" link. Usually displayed on mouseover.'),
-    '#access' => empty($flag->locked['flag_long']),
-  );
-
-  $form['messages']['flag_message'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Flagged message'),
-    '#default_value' => $flag->flag_message,
-    '#description' => t('Message displayed after flagging content. If JavaScript is enabled, it will be displayed below the link. If not, it will be displayed in the message area.'),
-    '#access' => empty($flag->locked['flag_message']),
-  );
-
-  $form['messages']['unflag_short'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Unflag link text'),
-    '#default_value' => $flag->unflag_short,
-    '#description' => t('The text for the "unflag this" link for this flag.'),
-    '#required' => TRUE,
-    '#access' => empty($flag->locked['unflag_short']),
-  );
-
-  $form['messages']['unflag_long'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Unflag link description'),
-    '#default_value' => $flag->unflag_long,
-    '#description' => t('The description of the "unflag this" link. Usually displayed on mouseover.'),
-    '#access' => empty($flag->locked['unflag_long']),
-  );
-
-  $form['messages']['unflag_message'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Unflagged message'),
-    '#default_value' => $flag->unflag_message,
-    '#description' => t('Message displayed after content has been unflagged. If JavaScript is enabled, it will be displayed below the link. If not, it will be displayed in the message area.'),
-    '#access' => empty($flag->locked['unflag_message']),
-  );
+  dsm($flag);
+  if (!isset($flag->events)) {
+    $flag->events = array('flag', 'unflag');
+  }
+  
+  $form['events'] = array(
+    '#type' => 'value',
+    '#value' => $flag->events,
+  );
+  
+  foreach ($flag->events as $event) {
+    $form['messages'][$event .'_short'] = array(
+      '#type' => 'textfield',
+      '#title' => t('!event link text', array('!event' => $event)),
+      '#default_value' => isset($flag->{$event .'_short'}) ? $flag->{$event .'_short'} : '',
+      '#description' => t('The text for the "!event this" link for this flag.', array('!event' => $event)),
+      '#required' => TRUE,
+      '#access' => empty($flag->locked[$event .'_short']),
+    );
+    $form['messages'][$event .'_long'] = array(
+      '#type' => 'textfield',
+      '#title' => t('!event link description', array('!event' => $event)),
+      '#default_value' => isset($flag->{$event .'_long'}) ? $flag->{$event .'_long'} : '',
+      '#description' => t('The description of the "!event this" link. Usually displayed on mouseover.', array('!event' => $event)),
+      '#access' => empty($flag->locked[$event .'_long']),
+    );
+    $form['messages'][$event .'_message'] = array(
+      '#type' => 'textfield',
+      '#title' => t('!event message', array('!event' => $event)), // -ed won't always work here
+      '#default_value' => isset($flag->{$event .'_confirmation'}) ? $flag->{$event .'_confirmation'} : '',
+      '#description' => t('Message displayed after !event content. If JavaScript is enabled, it will be displayed below the link. If not, it will be displayed in the message area."', array('!event' => $event .'ing')), // -ing should work fairly universally
+      '#access' => empty($flag->locked[$event .'_message']),
+    );
+  }
 
   if (module_exists('token')) {
     $form['messages']['token_help'] = array(
@@ -440,15 +424,13 @@ function flag_form_validate($form, &$for
   $form_values = $form_state['values'];
 
   if ($form_values['link_type'] == 'confirm') {
-    if (empty($form_values['flag_confirmation'])) {
-      form_set_error('flag_confirmation', t('A flag confirmation message is required when using the confirmation link type.'));
-    }
-    if (empty($form_values['unflag_confirmation'])) {
-      form_set_error('unflag_confirmation', t('An unflag confirmation message is required when using the confirmation link type.'));
+    foreach ($form_values['events'] as $event) {
+      if (empty($form_values[$event .'_confirmation'])) {
+        form_set_error($event .'_confirmation', t('The !event confirmation message is required when using the confirmation link type.', array('!event' => $event)));
+      }
     }
   }
 
-
   $flag = $form['#flag'];
   $flag->form_input($form_values);
   $errors = $flag->validate();
