Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.205.2.31
diff -u -p -r1.205.2.31 signup.module
--- signup.module	15 Sep 2009 19:54:21 -0000	1.205.2.31
+++ signup.module	16 Sep 2009 00:23:23 -0000
@@ -381,6 +381,17 @@ function signup_menu() {
     'file' => 'node_admin.inc',
     'file path' => $path,
   );
+  $items['node/%node/signups/settings'] = array(
+    'title' => 'Settings',
+    'page callback' => 'signup_node_settings_page',
+    'page arguments' => array(1),
+    'access callback' => '_signup_menu_access',
+    'access arguments' => array(1, 'admin'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 1,
+    'file' => 'node_settings.inc',
+    'file path' => $path,
+  );
   $items['node/%node/signups/confirm'] = array(
     'page callback' => 'drupal_get_form',
     'page arguments' => array('signup_cancel_multiple_confirm', 1),
cvs diff: Diffing includes
Index: includes/node_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/node_form.inc,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 node_form.inc
--- includes/node_form.inc	8 Jan 2009 19:36:27 -0000	1.4.2.1
+++ includes/node_form.inc	16 Sep 2009 00:23:24 -0000
@@ -10,17 +10,17 @@
 /**
  * Save signup-related information when a node is created or edited.
  *
- * This is a helper function invoked via signup_nodeapi().  It ensures that
- * the currently selected signup values are properly saved into the database.
- * If the node is signup-enabled, the per-node configuration values are saved
- * to the {signup} table. If signups are disabled, the record from {signup} is
- * cleared.  If the signup administrator editing the node decided to remove
- * all signup data, all the records from the {signup_log} table for this node
- * are also removed.  This function is also responsible for testing if the
- * node * has a start time and if the autoclose period has already begun, in
- * which case signups are closed.  Finally, if the signup limit was changed
- * while editing the node, the function compares the limit against the current
- * total number of signups and opens or closes signups as appropriate.
+ * This is a helper function invoked via signup_nodeapi(). If signups are
+ * disabled, the record from {signup} (if any) is cleared. If the signup
+ * administrator editing the node decided to remove all signup data, all the
+ * records from the {signup_log} table for this node are also removed. This
+ * function is also responsible for testing if the node has a start time and
+ * if the autoclose period has already begun, in which case signups are
+ * closed. If a new node is being saved, or an existing node is updated and is
+ * newly-enabled for signups, the site-wide default signup settings are copied
+ * into a record in the {signup} table for this node so that the node is
+ * properly signup-enabled (these settings can be changed by visiting the
+ * "Settings" subtab under the "Signups" tab at node/N/signups/settings).
  *
  * @param $node
  *   The node object given to signup_nodeapi().
@@ -33,96 +33,51 @@
  * @see signup_nodeapi()
  */
 function signup_save_node($node, $op) {
-  // See if the form indicates that signups are enabled on this node.
-  if (isset($node->signup_enabled)) {
-    if ($node->signup_enabled == 1) {
-      $values = array(
-        $node->signup_forwarding_email,
-        $node->signup_send_confirmation,
-        $node->signup_confirmation_email,
-        $node->signup_close_signup_limit,
-      );
-      // 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.
-      $values[] = isset($node->signup_send_reminder) ? $node->signup_send_reminder : 0;
-      $values[] = isset($node->signup_reminder_days_before) ? $node->signup_reminder_days_before : 0;
-      $values[] = isset($node->signup_reminder_email) ? $node->signup_reminder_email : '';
-    }
-  }
-  elseif ($op == 'insert' && variable_get('signup_node_default_state_'. $node->type, 'disabled') == 'enabled_on') {
-    // The form doesn't include any information about signups, but the node
-    // type is signup-enabled. This would happen if a user without any signup
-    // admin permissions creates a node that has been signup-enabled based on
-    // the node type. In this case, we use the site-wide default signup
-    // settings.
-    $defaults = db_fetch_object(db_query("SELECT * from {signup} WHERE nid = 0"));
-    $values = array(
-      $defaults->forwarding_email,
-      $defaults->send_confirmation,
-      $defaults->confirmation_email,
-      $defaults->close_signup_limit,
-      $defaults->send_reminder,
-      $defaults->reminder_days_before,
-      $defaults->reminder_email,
-    );
-  }
-
-  if (isset($values)) {
-    // If $values is set, we need to save them to the DB.
-
-    // Before we update the DB, see if the limit is changing, so we can take
-    // appropriate action after we update to the new settings.
-    $has_signup_record = FALSE;
-    $limit_changed = FALSE;
-    if ($op == 'update') {
-      $signup = db_fetch_object(db_query("SELECT close_signup_limit, status FROM {signup} WHERE nid = %d", $node->nid));
-      if ($signup !== FALSE) {
-        $cur_limit = $signup->close_signup_limit;
-        $node->signup_status = $signup->status;
-        $has_signup_record = TRUE;
-        $limit_changed = $cur_limit != $node->signup_close_signup_limit;
-      }
-      else {
-        // Newly signup-enabled node.
-        $node->signup_status = 1;
-      }
-    }
-
-    // See if we need to update an existing record or insert a new one.
-    // Either way, we always the nid as the final value. The nid will either
-    // be used as the last column in the INSERT, or the argument to the WHERE
-    // clause for the UPDATE.
-    $values[] = $node->nid;
-    if ($has_signup_record) {
-      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);
-    }
-    else {
-      db_query("INSERT INTO {signup} (forwarding_email, send_confirmation, confirmation_email, close_signup_limit, send_reminder, reminder_days_before, reminder_email, nid) VALUES ('%s', %d, '%s', %d, %d, %d, '%s', %d)", $values);
-    }
-    if (_signup_node_completed($node) && !empty($node->signup_status)) {
-      // If this is an time-based node, and it's already past the close in
-      // advance time, and signups are still open, close them now (and don't
-      // consider the limit for changing the status).
-      signup_close_signup($node->nid);
-      drupal_set_message(t('%node_type start time is already past the signup close-in-advance time, signups now closed.', array('%node_type' => node_get_types('name', $node->type))));
-    }
-    elseif ($limit_changed) {
-      $node->signup_total = db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $node->nid));
-      _signup_check_limit($node, 'limit');
-    }
-  }
-  elseif ($op == 'update' && isset($node->signup_enabled)) {
-    // $values was not set, because signups are now disabled on this node.
+  // See if a user is editing a node and disables signups for it.
+  if ($op == 'update' && isset($node->signup_enabled)) {
     switch ($node->signup_enabled) {
       case 2: // Disabled, and delete {signup_log}, too
         db_query("DELETE FROM {signup_log} WHERE nid = %d", $node->nid);
         // No break, fall through and remove from {signup} too.
       case 0: // Disabled, but leave {signup_log} alone
         db_query("DELETE FROM {signup} WHERE nid = %d", $node->nid);
-        break;
+        // We're done.
+        return;
+    }
+  }
+
+  // If the form is configured to have signups enabled, or the form doesn't
+  // include that information at all but the node type defaults to have
+  // signups enabled (which would happen if a user without signup admin
+  // permission created a node that defaulted to have signups enabled based on
+  // the node type), see if we need to insert a new record into the {signup}
+  // table for this node using the site-wide defaults.
+  $needs_defaults = FALSE;
+  if ((isset($node->signup_enabled) && $node->signup_enabled == 1) || (!isset($node->signup_enabled) && variable_get('signup_node_default_state_'. $node->type, 'disabled') == 'enabled_on')) {
+    if ($op == 'insert') {
+      $needs_defaults = TRUE;
+    }
+    else {
+      // Updating -- see if we already have a record for this node.
+      $has_record = db_result(db_query("SELECT nid FROM {signup} WHERE nid = %d", $node->nid));
+      $needs_defaults = empty($has_record);
     }
   }
+  
+  if ($needs_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[] = $node->nid;
+    db_query("INSERT INTO {signup} (forwarding_email, send_confirmation, confirmation_email, close_signup_limit, send_reminder, reminder_days_before, reminder_email, nid) VALUES ('%s', %d, '%s', %d, %d, %d, '%s', %d)", $values);
+  }
+
+  $node = node_load($node->nid);
+  if (_signup_node_completed($node) && !empty($node->signup_status)) {
+    // If this is an time-based node, and it's already past the close in
+    // advance time (e.g. someone just changed the node start time), and
+    // signups are still open, close them now.
+    signup_close_signup($node->nid);
+    drupal_set_message(t('%node_type start time is already past the signup close-in-advance time, signups now closed.', array('%node_type' => node_get_types('name', $node->type))));
+  }
 }
 
 /**
@@ -145,13 +100,6 @@ function signup_alter_node_form(&$form, 
   $node_type = $form['type']['#value'];
 
   $signup_type_default = variable_get('signup_node_default_state_'. $node_type, 'disabled');
-  if (!empty($node) && !empty($node->nid)) {
-    $node_scheduler = _signup_get_node_scheduler($node);
-  }
-  else {
-    $node_scheduler = _signup_get_node_type_scheduler($node_type);
-  }
-  $node_has_date = $node_scheduler != 'none';
 
   // If signups are possible, and the current user either has the global
   // 'administer all signups' permission or has the 'administer signups
@@ -194,38 +142,13 @@ function signup_alter_node_form(&$form, 
     else {
       $default_option = $signup_type_default == 'enabled_on' ? 1 : 0;
     }
-    if ($default_option == 1) {
-      $hint = t('If enabled, you can control whether users may sign up by visiting the !signups tab and toggling if signups are %open or %closed for this %node_type.', array('!signups' => !empty($node) ? l(t('Signups'), 'node/'. $node->nid .'/signups') : theme('placeholder', t('Signups')), '%open' => t('open'), '%closed' => t('closed'), '%node_type' => node_get_types('name', $node_type)));
-    }
-    else {
-      $hint = '';
-    }
     // Add the form element to toggle if signups are allowed.
     $form['signup']['signup_enabled'] = array(
       '#type' => 'radios',
       '#options' => $radio_options,
       '#default_value' => $default_option,
-      '#description' => $hint .'<div class="js-hide">'. t('If disabled, all of the other signup settings will be ignored.') .'</div>',
-      '#prefix' => '<div class="signup-allow-radios">',
-      '#suffix' => '</div>',
-    );
-
-    // If JS is enabled, system.css will hide all the settings on page
-    // load if signups aren't enabled on this node.
-    $settings_class = "signup-node-settings";
-    if ($default_option != 1) {
-      $settings_class .= " js-hide";
-    }
-
-    // Add the actual settings.  We wrap this in a div to make it easy
-    // to use jQuery to hide these settings when signups are disabled.
-    drupal_add_js(drupal_get_path('module', 'signup') .'/js/node_form.js');
-    $form['signup']['node_settings'] = array(
-      '#prefix' => '<div class="'. $settings_class .'">',
-      '#suffix' => '</div>',
+      '#description' => t('If enabled, you can control whether users may sign up by visiting the !signup_admin tab and toggling if signups are %open or %closed for this %node_type. Other signup-related settings can be defined at the !signup_settings tab.', array('!signup_admin' => !empty($node->signup) ? l(t('Signups: Administer'), 'node/'. $node->nid .'/signups/admin') : theme('placeholder', t('Signups: Administer')), '!signup_settings' => !empty($node->signup) ? l(t('Signups: Settings'), 'node/'. $node->nid .'/signups/settings') : theme('placeholder', t('Signups: Settings')), '%open' => t('open'), '%closed' => t('closed'), '%node_type' => node_get_types('name', $node_type))),
     );
-    module_load_include('inc', 'signup', 'includes/node_settings');
-    $form['signup']['node_settings']['settings'] = signup_node_settings_form(array(), $node, $node_type, $node_has_date);
   }
 }
 
Index: includes/node_settings.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/node_settings.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 node_settings.inc
--- includes/node_settings.inc	20 Dec 2008 04:28:56 -0000	1.1.2.1
+++ includes/node_settings.inc	16 Sep 2009 00:23:24 -0000
@@ -21,12 +21,14 @@
  *   Boolean flag indicating if this node (or site) has signup-aware
  *   date functionality, which is required for reminder emails to be in
  *   the form.
+ * @param $include_buttons
+ *   Boolean flag indicating if the form should include its own submit buttons.
  *
  * @return
  *   The form array for the per-node signup settings.
  *
  */
-function signup_node_settings_form($form_state, $node = NULL, $node_type = NULL, $has_date = FALSE) {
+function signup_node_settings_form($form_state, $node = NULL, $node_type = NULL, $has_date = FALSE, $include_buttons = FALSE) {
   if (module_exists('token')) {
     $signup_token_description = t('Supported string substitutions: %node_title, %node_url, %node_start_time, %user_name, %user_mail, %user_signup_info (additional information from the signup form), %cancel_signup_url (access to this link is denied to users without the "%cancel_own_signups" permission), and any tokens in the %replacement_tokens list.', array('%replacement_tokens' => t('Replacement tokens'), '%cancel_own_signups' => t('cancel own signups')));
   }
@@ -115,6 +117,76 @@ function signup_node_settings_form($form
   );
   $form['signup'] = array('#type' => 'hidden', '#value' => 1);
 
+  if ($include_buttons) {
+    $form['#node'] = $node;
+    $form['buttons']['submit'] = array(
+      '#type' => 'submit',
+      '#value' => t('Save configuration'),
+    );
+    $form['buttons']['reset'] = array(
+      '#type' => 'submit',
+      '#value' => t('Reset to defaults'),
+    );
+    $form['#submit'][] = 'signup_node_settings_form_submit';
+  }
+
   return $form;
 }
 
+/**
+ * Page callback for the node/N/signups/settings subtab.
+ */
+function signup_node_settings_page($node) {
+  $node_scheduler = _signup_get_node_scheduler($node);
+  $node_has_date = $node_scheduler != 'none';
+  return drupal_get_form('signup_node_settings_form', $node, $node->type, $node_has_date, TRUE);
+}
+
+/**
+ * Submit handler for the per-node signup settings form.
+ *
+ * @param $form_id
+ *   The ID of the form being submitted.
+ * @param $form_values
+ *   The constructed form values array of the submitted form.
+ */
+function signup_node_settings_form_submit($form, &$form_state) {
+  $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"));
+  }
+  else {
+    // 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.
+    $values['send_reminder'] = isset($form_state['values']['signup_send_reminder']) ? $form_state['values']['signup_send_reminder'] : 0;
+    $values['reminder_days_before'] = isset($form_state['values']['signup_reminder_days_before']) ? $form_state['values']['signup_reminder_days_before'] : 0;
+    $values['reminder_email'] = isset($form_state['values']['signup_reminder_email']) ? $form_state['values']['signup_reminder_email'] : '';
+  }
+
+  // Either way, we want to make sure we're updating the values for the
+  // 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);
+
+  // 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']) {
+    $node->signup_close_signup_limit = $form_state['values']['signup_close_signup_limit'];
+    $node->signup_total = db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $node->nid));
+    _signup_check_limit($node, 'limit');
+  }
+
+  if ($op == t('Reset to defaults')) {
+    drupal_set_message(t('The configuration options have been reset to their default values.'));
+  }
+  else {
+    drupal_set_message(t('The configuration options have been saved.'));
+  }
+}
+
cvs diff: Diffing js
Index: js/node_form.js
===================================================================
RCS file: js/node_form.js
diff -N js/node_form.js
--- js/node_form.js	15 Apr 2009 22:25:44 -0000	1.5.2.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-/* $Id: node_form.js,v 1.5.2.1 2009/04/15 22:25:44 dww Exp $ */
-
-/**
- * On a node form, if the "Allow signups" radios are set to 1
- * ('Enabled'), then show the other signup-specific settings,
- * otherwise, hide them.
- */
-Drupal.behaviors.signupShowNodeSettings = function () {
-  $('div.signup-allow-radios input[type=radio]').click(function () {
-    $('div.signup-node-settings')[['hide', 'show', 'hide'][this.value]]();
-  });
-};
cvs diff: Diffing modules
cvs diff: Diffing modules/signup_confirm_email
cvs diff: Diffing modules/signup_confirm_email/translations
cvs diff: Diffing panels
cvs diff: Diffing panels/content_types
cvs diff: Diffing theme
cvs diff: Diffing translations
cvs diff: Diffing views
cvs diff: Diffing views/handlers
cvs diff: Diffing views/plugins
