? .DS_Store
? .git
? 29568-2.signup.api-custom-signup-forms.patch
? 29568.signup.api-custom-signup-forms.patch
? 644808.signup.cleaner-loading-to-node.patch
? contrib/.DS_Store
? contrib/signup_conflicts/.DS_Store
? contrib/signup_ecommerce/.DS_Store
? includes/.DS_Store
? js/.DS_Store
? modules/.DS_Store
? modules/signup_basic_form
? modules/signup_basic_form.zip
? modules/signup_confirm_email/.DS_Store
? modules/signup_confirm_email/translations/.DS_Store
? panels/.DS_Store
? panels/content_types/.DS_Store
? po/.DS_Store
? theme/.DS_Store
? translations/.DS_Store
? views/.DS_Store
? views/default_views/.DS_Store
? views/handlers/.DS_Store
? views/plugins/.DS_Store
Index: INSTALL.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/INSTALL.txt,v
retrieving revision 1.15
diff -u -p -r1.15 INSTALL.txt
--- INSTALL.txt	22 Jan 2009 18:59:28 -0000	1.15
+++ INSTALL.txt	9 Dec 2009 12:50:30 -0000
@@ -14,11 +14,8 @@ the Drupal package and read the online d
 
 2. (Optional) Customize the form presented to users when signing up
    for content on your site.  Unfortuantely, there is not yet a way to
-   do this from within your site, you must modify a theme function to
-   change this form.  See the comment above "theme_signup_user_form()"
-   in the theme/signup_form.inc file.  If you want to change the form,
-   you should define your own version of theme_signup_user_form() in
-   your site's theme (e.g. as phptemplate_signup_user_form()).
+   do this from within your site, you must implement hook_signup_form_info in
+   a module to register a callback that returns form elements.
 
 
 3. Enable the signup module by navigating to:
Index: signup.api.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.api.php,v
retrieving revision 1.5
diff -u -p -r1.5 signup.api.php
--- signup.api.php	19 Sep 2009 01:42:52 -0000	1.5
+++ signup.api.php	9 Dec 2009 12:50:30 -0000
@@ -8,6 +8,35 @@
  */
 
 /**
+ * Hook to define forms available to signups to insert into the signup form.
+ *
+ * Forms should be provided by callback functions as a FormAPI array.
+ * The callback should have the following signature:
+ *   function my_callback(&$form_state, $node, $signup_type = 'auth')
+ * See signup_basic_form_form for an example.
+ * The values submitted to the form elements defined by this form will be 
+ * serialized and stored in the {signup_log} table as 'form_data'.
+ *
+ * @return
+ *   An array of possible forms, keyed by a unique ID. Each value is itself an 
+ *   array of data, with the following key-value pairs:
+ *     - 'label': (required) The human-readable name of the form.
+ *     - 'description': (required) Extra information about the form.
+ *     - 'callback': (required) The name of a function.
+ *
+ * @see signup_basic_form_form.
+ */
+function hook_signup_form_info() {
+  return array(
+    'basic' => array(
+      'label' => 'Basic form',
+      'description' => 'Collects name and phone number.',
+      'callback' => 'signup_basic_form_form',
+    ),  
+  );
+}
+
+/**
  * Hook to alter signup data before a signup is inserted or updated.
  *
  * @param $signup
@@ -80,7 +109,7 @@ function hook_signup_update($signup) {
  *
  * This hook allows other modules to inject information into the custom signup
  * data for each signup.  The array is merged with the values of any custom
- * fields from theme_signup_user_form(), serialized, and stored in the
+ * fields from hook_signup_form_info(), serialized, and stored in the
  * {signup_log} database table.
  *
  * @param $node
@@ -94,7 +123,7 @@ function hook_signup_update($signup) {
  *   should be human-readable (and wrapped in t() to allow translation).
  *
  * @see signup_sign_up_user()
- * @see theme_signup_user_form()
+ * @see hook_signup_form_info()
  */
 function hook_signup_sign_up($node, $account) {
   return array(
Index: signup.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.install,v
retrieving revision 1.30
diff -u -p -r1.30 signup.install
--- signup.install	19 Sep 2009 01:42:52 -0000	1.30
+++ signup.install	9 Dec 2009 12:50:30 -0000
@@ -16,6 +16,13 @@ function signup_schema() {
         'not null' => TRUE,
         'default' => 0,
       ),
+      'form_panes' => array(
+        'description' => t('Serialized array of form panes and weights to use for user signups. Associative array of the form $pane_id => $weight.'),
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'default' => '',
+      ),
       'forwarding_email' => array(
         'description' => t('Email address to send signup notifications to.'),
         'type' => 'varchar',
@@ -117,7 +124,7 @@ function signup_schema() {
         'default' => 0,
       ),
       'form_data' => array(
-        'description' => t('Serialized string of additional signup form values.  See theme_signup_user_form() from theme/signup.theme for more information.'),
+        'description' => t('Serialized string of additional signup form values.  See hook_signup_form_info() for more information.'),
         'type' => 'text',
         'size' => 'big',
         'not null' => TRUE,
@@ -179,10 +186,10 @@ function signup_uninstall() {
  * settings for new signup-enabled nodes.
  */
 function signup_insert_default_signup_info() {
-  return db_query("INSERT INTO {signup} (nid, forwarding_email,
+  return db_query("INSERT INTO {signup} (nid, form, forwarding_email,
     send_confirmation, confirmation_email,
     send_reminder, reminder_days_before, reminder_email,
-    close_in_advance_time, close_signup_limit, status) VALUES (0, '',
+    close_in_advance_time, close_signup_limit, status) VALUES (0, 'basic', '',
     1, 'Enter your default confirmation email message here',
     1, 1, 'Enter your default reminder email message here',
     0, 0, 1)");
@@ -482,3 +489,20 @@ function signup_update_6003() {
   return $ret;
 }
 
+/**
+ * Add the 'form' field to the {signup} table.
+ */
+function signup_update_6200() {
+  $ret = array();
+  $field = array(
+    'description' => t('Serialized array of form panes and weights to use for user signups. Associative array of the form $pane_id => $weight.'),
+    'type' => 'varchar',
+    'length' => 64,
+    'not null' => TRUE,
+    'default' => '',
+    'initial' => '',
+  );
+  db_add_field($ret, 'signup', 'form_panes', $field);
+  return $ret;
+}
+
Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.242
diff -u -p -r1.242 signup.module
--- signup.module	8 Oct 2009 00:01:24 -0000	1.242
+++ signup.module	9 Dec 2009 12:50:31 -0000
@@ -151,13 +151,6 @@ function signup_theme() {
         'node' => NULL,
       ),
     ),
-    'signup_user_form' => array(
-      'file' => 'signup_form.inc',
-      'path' => $path,
-      'arguments' => array(
-        'node' => NULL,
-      ),
-    ),
     'signup_anonymous_username' => array(
       'file' => 'signup_form.inc',
       'path' => $path,
@@ -173,6 +166,11 @@ function signup_theme() {
         'view' => NULL,
       ),
     ),
+    'signup_node_settings_form_panes' => array(
+      'file' => 'node_settings.inc',
+      'path' => drupal_get_path('module', 'signup') . '/includes',
+      'arguments' => array('form'),
+    ),
   );
 }
 
@@ -763,11 +761,13 @@ function signup_nodeapi(&$node, $op, $te
         $node->signup_reminder_days_before = $signup->reminder_days_before;
         $node->signup_reminder_email = $signup->reminder_email;
         $node->signup_close_signup_limit = $signup->close_signup_limit;
+        $node->signup_form_panes = $signup->form_panes;        
         $node->signup_status = $signup->status;
         if ($node->nid) {
           $node->signup_total = db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $node->nid));
           $node->signup_effective_total = db_result(db_query("SELECT SUM(count_towards_limit) FROM {signup_log} WHERE nid = %d", $node->nid));
         }
+        $node->signup_form_panes = unserialize($node->signup_form_panes);
       }
       else {
         $node->signup = 0;
Index: includes/node_settings.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/node_settings.inc,v
retrieving revision 1.5
diff -u -p -r1.5 node_settings.inc
--- includes/node_settings.inc	21 Sep 2009 05:23:02 -0000	1.5
+++ includes/node_settings.inc	9 Dec 2009 12:50:31 -0000
@@ -46,6 +46,57 @@ function signup_node_settings_form($form
     $node->signup_reminder_days_before = $result->reminder_days_before;
     $node->signup_reminder_email = $result->reminder_email;
     $node->signup_close_signup_limit = $result->close_signup_limit;
+    $node->signup_form_panes = $result->form_panes;
+  }
+  //dsm($node->signup_form_panes);
+  
+  // Get information about all potential form panes from modules that 
+  // implement hook_signup_form_info.
+  $signup_form_pane_info = module_invoke_all('signup_form_info');
+  
+  // Put in weights from either saved settings or for panes not enabled on this 
+  // node a default heavy weight of 10.
+  foreach ($signup_form_pane_info as $id => $signup_form_pane) {
+    $signup_form_pane_info[$id]['weight'] = isset($node->signup_form_panes[$id]) ? $node->signup_form_panes[$id] : 10;
+  }
+  // Sort the list by weight so it appears correctly in the UI.
+  uasort($signup_form_pane_info, '_singup_cmp_weight'); 
+  //dsm($signup_form_pane_info);
+  
+  // The label and the theme function for the form panes table.
+  $form['signup_form_panes'] = array(
+    // This gets a label on the whole table; not sure this is the best approach though.
+    // Improvements welcome.
+    '#type' => 'item',
+    '#title' => t('Signup form panes'),
+    '#tree' => TRUE,
+    '#theme' => 'signup_node_settings_form_panes',
+  );
+  
+  foreach ($signup_form_pane_info as $id => $signup_form_pane) {
+    $form['signup_form_panes'][$id]['enabled'] = array(
+      '#type' => 'checkbox',
+      '#default_value' => isset($node->signup_form_panes[$id]),
+      // Don't set the #title: we want it in a separate column. 
+    );
+    $form['signup_form_panes'][$id]['label'] = array(
+      '#value' => $signup_form_pane['label'],
+    );
+    $form['signup_form_panes'][$id]['description'] = array(
+      '#value' => $signup_form_pane['description'],
+    );
+    $form['signup_form_panes'][$id]['weight'] = array(
+      '#type' => 'weight',
+      '#delta' => 10,      
+      '#default_value' => $signup_form_pane['weight'],
+      '#attributes' => array(
+        'class' => "signup-pane-weight",
+      ),
+    );
+  }
+  // Unset weight item if only 1 element
+  if (count($signup_form_pane_info) == 1) {
+    unset($form['signup_form_panes'][$id]['weight']);
   }
 
   $form['signup_forwarding_email'] = array(
@@ -145,6 +196,60 @@ function signup_node_settings_page($node
 }
 
 /**
+ * Helper function to sort signup panes by their weight key.
+ */
+function _singup_cmp_weight($a, $b) {
+  return $a['weight'] - $b['weight'];
+}
+
+/**
+ * Theme function for the panes table in the node settings form.
+ */
+function theme_signup_node_settings_form_panes($form) {
+  // Based on taxonomy.admin.inc
+  foreach (element_children($form) as $key) {
+    $row = array();
+    $row[] = drupal_render($form[$key]['enabled']);
+    if (isset($form[$key]['weight'])) {
+      $form[$key]['weight']['#attributes']['class'] = 'signup-pane-weight';
+      $row[] = drupal_render($form[$key]['weight']);
+    }
+    $row[] = drupal_render($form[$key]['label']);
+    $row[] = drupal_render($form[$key]['description']);
+    
+    $rows[] = array(
+      'data' => $row,
+      'class' => 'draggable',
+    );
+  }
+  // A message if there are no rows.
+  // @todo: figure out why the form label doesn't show in this case.
+  if (!count($rows)) {
+    $rows[] = array(
+      array(
+        'data' => 'No form panes are available.',
+        'colspan' => 3,
+      )
+    );
+  }
+  
+  $header[] = 'Enabled';
+  if (isset($form[$key]['weight'])) {
+    $header[] = 'Weight';
+  }
+  $header[] = 'Name';
+  $header[] = 'Description';
+  
+  if (isset($form[$key]['weight'])) {  
+    drupal_add_tabledrag('signup-node-settings-panes', 'order', 'sibling', 'signup-pane-weight');
+  }
+    
+  $output = drupal_render($form); // ???
+  $output .=  theme('table', $header, $rows, array('id' => 'signup-node-settings-panes'));
+  return $output;
+}
+
+/**
  * Submit handler for the per-node signup settings form.
  *
  * @param $form_id
@@ -156,13 +261,31 @@ function signup_node_settings_form_submi
   $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
   if ($op == t('Reset to defaults')) {
     // If we're resetting, we just want to grab the site-wide defaults.
-    $values = db_fetch_array(db_query("SELECT forwarding_email, send_confirmation, confirmation_email, close_signup_limit, send_reminder, reminder_days_before, reminder_email FROM {signup} WHERE nid = 0"));
+    $values = db_fetch_array(db_query("SELECT form_panes, forwarding_email, send_confirmation, confirmation_email, close_signup_limit, send_reminder, reminder_days_before, reminder_email FROM {signup} WHERE nid = 0"));
   }
   else {
+    // Serialize all the settings for form panes as $pane_id => weight.
+    //dsm($form_state['values']['signup_form_panes']);
+    foreach ($form_state['values']['signup_form_panes'] as $pane_id => $form_state_values_panes) {
+      if ($form_state_values_panes['enabled']) {
+        $signup_panes[$pane_id] = $form_state_values_panes['weight'];
+      }
+    }
+    // Give a singleton pane a weight value, arbitrarily set to 0.
+    if (count($form_state['values']['signup_form_panes']) == 1 && isset($signup_panes)) {
+      $signup_panes[$pane_id] = 0;
+    }
+    // Sort by weight, preserve keys.
+    asort($signup_panes);
+    // Serialize the array of setting for storage.
+    $values['form_panes'] = serialize($signup_panes);
+    //dsm($signup_panes);
+    
     // Populate $values from $form_state.
     foreach (array('forwarding_email', 'send_confirmation', 'confirmation_email', 'close_signup_limit') as $setting) {
       $values[$setting] = $form_state['values']["signup_$setting"];
     }
+   
     // If we're dealing with a node that doesn't have a start time, these
     // fields are missing from the signup settings form, so we can't assume
     // they're defined.
@@ -175,7 +298,7 @@ function signup_node_settings_form_submi
   // current node, not nid 0...
   $node = $form['#node'];
   $values[] = $node->nid;
-  db_query("UPDATE {signup} SET forwarding_email = '%s', send_confirmation = %d, confirmation_email = '%s', close_signup_limit = %d, send_reminder = %d, reminder_days_before = %d, reminder_email = '%s' WHERE nid = %d", $values);
+  db_query("UPDATE {signup} SET form_panes = '%s', forwarding_email = '%s', send_confirmation = %d, confirmation_email = '%s', close_signup_limit = %d, send_reminder = %d, reminder_days_before = %d, reminder_email = '%s' WHERE nid = %d", $values);
 
   // See if the limit changed, and if so, take any necessary action.
   if ($node->signup_close_signup_limit != $form_state['values']['signup_close_signup_limit']) {
Index: includes/signup_edit_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/signup_edit_form.inc,v
retrieving revision 1.7
diff -u -p -r1.7 signup_edit_form.inc
--- includes/signup_edit_form.inc	19 Sep 2009 00:31:56 -0000	1.7
+++ includes/signup_edit_form.inc	9 Dec 2009 12:50:31 -0000
@@ -85,23 +85,32 @@ function signup_edit_form($form_state, $
     );
   }
 
-  // Build the themed signup form for this site and include that.
-  $site_form = theme('signup_user_form', $node);
+  // Build the extra signup form for this site and include that.
+  if ($node->signup_form != 'none') {
+    // @todo this doesn't work at all right now 
+    // but can't even figure out where this form is used!
+    $signup_form_data = module_invoke_all('signup_form_info');
+    if (isset($signup_form_data[$node->signup_form])) {
+      $callback = $signup_form_data[$node->signup_form]['callback'];
+      $custom_form = $callback($form_state, $node, $signup_type);
+    }
+  }
   $form_data = unserialize($signup->form_data);
 
   // This is sort of a hack, but we don't support nested arrays for the custom
   // signup form anyway, so it works for now.  Obviously all this will change
   // with signup_fields and friends, but for now it works.
   foreach ($form_data as $key => $value) {
-    if (!empty($site_form['signup_form_data'][$key])) {
-      $site_form['signup_form_data'][$key]['#default_value'] = $value;
+    if (!empty($custom_form['signup_form_data'][$key])) {
+      // @todo!!! oops. what do we do about signup_form_data key name???
+      $custom_form['signup_form_data'][$key]['#default_value'] = $value;
       if (!$can_edit) {
         // If they can't edit, mark all the fields as disabled.
-        $site_form['signup_form_data'][$key]['#disabled'] = TRUE;
+        $custom_form['signup_form_data'][$key]['#disabled'] = TRUE;
       }
     }
   }
-  $form['elements'] += $site_form;
+  $form['elements'] += $custom_form;
 
   // Add the appropriate buttons based on permissions.
   if ($can_edit) {
Index: includes/signup_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/signup_form.inc,v
retrieving revision 1.2
diff -u -p -r1.2 signup_form.inc
--- includes/signup_form.inc	20 Dec 2008 06:31:22 -0000	1.2
+++ includes/signup_form.inc	9 Dec 2009 12:50:31 -0000
@@ -75,18 +75,26 @@ function signup_form(&$form_state, $node
     $signup_form += $admin_form;
   }
 
-  // Build the themed signup form for this site and include that.
-  $signup_themed_form = theme('signup_user_form', $node);
-
-  if ($signup_type == 'admin') {
-    // Special case hack for the default signup form, where the current
-    // username is being filled in as the default for the 'Name' field.
-    if (!empty($signup_themed_form['signup_form_data']['Name']['#default_value'])) {
-      unset($signup_themed_form['signup_form_data']['Name']['#default_value']);
+  // Insert the form components provided by other modules.
+  if (isset($node->signup_form_panes)) {
+    //dsm($node->signup_form_panes);
+    $signup_form_pane_info = module_invoke_all('signup_form_info');
+    // Add each pane to the form. The node settings are stored in the weighted
+    // order so there is no need for further sorting here.
+    foreach ($node->signup_form_panes as $pane_id => $weight) {
+      if (isset($signup_form_pane_info[$pane_id])) {
+        $callback = $signup_form_pane_info[$pane_id]['callback'];
+        // Each pane goes into its own form element with #tree set
+        // to protect form values from clashing.
+        $signup_form[$pane_id] = array(
+          '#tree' => TRUE,
+        );
+        $signup_form[$pane_id] += $callback($form_state, $node, $signup_type);
+      }
     }
   }
-  $signup_form += $signup_themed_form;
-
+  dsm($signup_form);
+  
   $form['collapse']['signup_user_form'] = $signup_form;
   $form['collapse']['submit'] = array(
     '#type' => 'submit',
Index: theme/signup_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/theme/signup_form.inc,v
retrieving revision 1.5
diff -u -p -r1.5 signup_form.inc
--- theme/signup_form.inc	22 Jan 2009 18:59:29 -0000	1.5
+++ theme/signup_form.inc	9 Dec 2009 12:50:31 -0000
@@ -44,7 +44,7 @@
  *
  * @see theme_signup_anonymous_username()
  */
-function theme_signup_user_form($node) {
+function REMOVEME_theme_signup_user_form($node) {
   global $user;
   $form = array();
 
@@ -75,9 +75,9 @@ function theme_signup_user_form($node) {
 /**
  * Returns the value to use for the user name for anonymous signups.
  *
- * WARNING: If you implemented your own version of theme_signup_form_data()
- * that changed or removed the custom 'Name' field and your site
- * allows anonymous signups, you will need to modify this, too.
+ * WARNING: If you are using a custom signup form other than the basic one
+ * supplied with this module, you will need to alter this function to work
+ * correctly.
  *
  * This value is used for the %user_name email token for anonymous users, and
  * also to identify a particular anonymous signup in various places in the UI.
@@ -96,8 +96,8 @@ function theme_signup_anonymous_username
   // supplied email address, in which case, you should uncomment this:
   //return $email;
 
-  // WARNING: This line is only valid if you left the 'Name' field in
-  // your site's version of theme_signup_user_form().
+  // WARNING: This line is only valid if you are using the basic custom form
+  // or if your own custom form has a 'Name' field.
   return $form_data['Name'];
 }
 
