? flag_events-admin.inc.patch
? flag_events-flag.inc.patch
? 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 06:58:33 -0000
@@ -236,6 +236,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 +569,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 +577,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;
   }
@@ -1062,6 +1062,7 @@ class flag_node extends flag_flag {
       'access_author' => '',
       'i18n' => 0,
     );
+    $options = module_invoke_all('flag_default_options', 'node', $options);
     return $options;
   }
 
@@ -1261,6 +1262,7 @@ class flag_comment extends flag_flag  {
       'access_author' => '',
       'show_on_comment' => TRUE,
     );
+    $options = module_invoke_all('flag_default_options', 'comment', $options);
     return $options;
   }
 
@@ -1396,6 +1398,7 @@ class flag_user extends flag_flag {
       'show_on_profile' => TRUE,
       'access_uid' => '',
     );
+    $options = module_invoke_all('flag_default_options', 'user', $options);
     return $options;
   }
 
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 06:58:34 -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']),
-  );
+  
+  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(
@@ -439,12 +423,9 @@ function flag_form(&$form_state, $name, 
 function flag_form_validate($form, &$form_state) {
   $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)));
     }
   }
 
