? dif
? patches-1.1.2.18.tgz
? patches-1.1.2.22
? patches-1.1.2.22.tgz
cvs diff: Diffing .
Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.1.2.24
diff -u -F^f -r1.1.2.24 signup.module
--- signup.module	2 Feb 2006 20:58:53 -0000	1.1.2.24
+++ signup.module	3 Feb 2006 09:51:42 -0000
@@ -110,7 +110,7 @@ function signup_cron() {
 
     //loop through the results, calling the event closing function
     while ($signup = db_fetch_object($result)) {
-      signup_close_signup($signup->nid, $cron = 'yes');
+      _signup_close_signup($signup->nid);
     }
   }
 }
@@ -158,6 +158,11 @@ function signup_menu($may_cache) {
     $items[] = array('path' => 'admin/signup/conflict_detail', 'title' => t('conflict detail'),
         'callback' => 'signup_conflict_detail', 'access' => $access,
         'type' => MENU_LOCAL_TASK);
+    $items[] = array('path' => 'admin/signup/closed_events',
+                     'title' => t('closed events'),
+                     'callback' => 'signup_admin_closed',
+                     'access' => $access, 'type' => MENU_LOCAL_TASK,
+                     'weight' => -9);
 
     //user signup callbacks
     $items[] = array('path' => 'signup', 'access' => TRUE, 'type' => MENU_CALLBACK, 'callback' => 'signup_user_signup');
@@ -165,7 +170,10 @@ function signup_menu($may_cache) {
     'callback' => 'signup_user_schedule');
 
     //close signup callback
-    $items[] = array('path' => 'closesignup', 'access' => TRUE, 'type' => MENU_CALLBACK, 'callback' => 'signup_close_signup');
+    $items[] = array('path' => 'closesignup', 'access' => TRUE, 'type' => MENU_CALLBACK, 'callback' => 'signup_close_signup_link');
+
+    //open signup callback
+    $items[] = array('path' => 'opensignup', 'access' => TRUE, 'type' => MENU_CALLBACK, 'callback' => 'signup_open_signup_link');
   } else {
 
     //if it's a signup event, then put in a signup tab
@@ -401,9 +409,37 @@ function signup_nodeapi(&$node, $op, $ar
  * @ingroup signup_callback
  */
 function signup_admin_page() {
+  _signup_admin_helper( 'open' );
+}
+
+
+/**
+ * Callback function for generating page for viewing (and reopening)
+ * closed signups
+ * @ingroup signup_callback
+ */
+function signup_admin_closed() {
+  _signup_admin_helper( 'closed' );
+}
+
 
+/**
+ * Since there are two nearly identical tabs in the admin/signup
+ * world, one for viewing open events (with a link to close them) and
+ * one for viewing closed events (with a link to open them), all the
+ * underlying code is basically the same except 3 minor changes.  so,
+ * this function implements the real work, and just decides what to 
+ * do based on the argument it is given.
+ * @ingroup signup_internal
+ */
+function _signup_admin_helper( $type ) {
   $output = '';
-  drupal_set_title(t('Signups'));
+
+  if ($type == 'open') {
+    drupal_set_title(t('Signups'));
+  } else {
+    drupal_set_title(t('Closed Signups'));
+  }
 
   //tests for optional support of event.module
   $_EVENT = module_exist('event');
@@ -423,8 +459,13 @@ function signup_admin_page() {
   //pull all open signup nodes, and start the creation of the table
   $sql = "SELECT n.title, n.nid$event_select, COUNT(*) AS count FROM
           {signup_log} s_l INNER JOIN {node} n INNER JOIN {signup} s
-          ON n.nid = s.nid AND s.nid = s_l.nid$event_join
-          WHERE s.completed = 0 GROUP BY n.nid";
+          ON n.nid = s.nid AND s.nid = s_l.nid$event_join";
+  if ($type == 'open') {
+    $sql .= " WHERE s.completed = 0";
+  } else {
+    $sql .= " WHERE s.completed = 1";
+  }
+  $sql .= " GROUP BY n.nid";
   $sql .= tablesort_sql($header);
   $result = pager_query($sql, 25);
 
@@ -438,14 +479,24 @@ function signup_admin_page() {
     }
     $row[] = l(check_plain($signup_event->title), "node/$signup_event->nid");
     $row[] = $signup_event->count;
-    $row[] = l(t('View Signups'), "node/$signup_event->nid/signups") .'<br>'. l(t('Close Event'),
-      "closesignup/$signup_event->nid");
+    $op_links = l(t('View Signups'), "node/$signup_event->nid/signups");
+    $op_links .= '<br>';
+    if ($type == 'open') {
+      $op_links .= l(t('Close Event'), "closesignup/$signup_event->nid");
+    } else {
+      $op_links .= l(t('Open Event'), "opensignup/$signup_event->nid");
+    }
+    $row[] = $op_links; 
     $rows[] = $row;
   }
-  $output .= theme('table', $header, $rows);
-  $pager = theme('pager', NULL, 25, 0, tablesort_pager());
-  if (!empty($pager)) {
-    $output .= $pager;
+  if (count($rows)) {
+    $output .= theme('table', $header, $rows);
+    $pager = theme('pager', NULL, 25, 0, tablesort_pager());
+    if (!empty($pager)) {
+      $output .= $pager;
+    }
+  } else {
+    $output = "<h4>No " . $type . " events</h4>";
   }
   print theme('page', $output);
 }
@@ -466,18 +517,45 @@ function signup_cancel_signup($uid, $nid
 
 
 /**
- * Callback function for closing signups
+ * Helper method for closing signups
+ * @ingroup signup_internal
+ */
+function _signup_close_signup($nid) {
+  //close the specified node for signups
+  db_query("UPDATE {signup} SET completed = 1 WHERE nid = %d", $nid);
+}
+
+
+/**
+ * Callback function for opening signups via a link in the admin tables
  * @ingroup signup_callback
  */
-function signup_close_signup($nid, $cron = 'no') {
+function signup_close_signup_link($nid) {
+  _signup_close_signup($nid);
+  drupal_goto('admin/signup');
+}
 
-  //close the specified node for signups, and head back to the admin/signup page if it's not a cron task
-  db_query("UPDATE {signup} SET completed = 1 WHERE nid = %d", $nid);
-  if ($cron == 'no') {
-    drupal_goto('admin/signup');
-  }
+
+/**
+ * Helper method for opening signups
+ * @ingroup signup_internal
+ */
+function _signup_open_signup($nid) {
+  //open the specified node for signups
+  db_query("UPDATE {signup} SET completed = 0 WHERE nid = %d", $nid);
 }
 
+
+/**
+ * Callback function for opening signups via a link in the admin tables
+ * @ingroup signup_callback
+ */
+function signup_open_signup_link($nid) {
+  _signup_open_signup($nid);
+  drupal_goto('admin/signup/closed_events');
+}
+
+
 /**
  * Callback function for generating a detail report of signup conflicts
  * @ingroup signup_callback
@@ -535,6 +613,7 @@ function signup_conflict_summary() {
   print theme('page', $output);
 }
 
+
 /**
  * Prints the settings page under admin/setttings/signup
  * @ingroup signup_callback
@@ -635,10 +714,42 @@ function signup_user_signup() {
  */
 function signup_user_signups_form($node) {
 
+  $op = $_POST['op'];
+
+  switch ($op) {
+    case t('Open Signups'):
+      _signup_open_signup($node->nid);
+      drupal_goto(url("node/$node->nid/signups"));
+      break;  
+
+    case t('Close Signups'):
+      _signup_close_signup($node->nid);
+      drupal_goto(url("node/$node->nid/signups"));
+      break;  
+  }
+
+  $output = "<h1>" . check_plain($node->title) . "</h1>";
+
+  // first see signups have already been closed for this node, and if
+  // so, print out something about that along with a button to re-open
+  // signups... 
+  $ctrl_row = array();
+  if ($node->signup_completed) {
+    $ctrl_row[] = array( t('Signups <b>closed</b> for this event'), 
+                         form(form_submit(t('Open Signups')), 'post',
+                              url("node/$node->nid/signups")) );
+  } else {
+    $ctrl_row[] = array( t('Signups <b>open</b> for this event'),
+                         form(form_submit(t('Close Signups')), 'post',
+                              url("node/$node->nid/signups")) );
+  }
+  $output .= '<br/>';
+  $output .= theme('table', NULL, $ctrl_row);
+  $output .= '<br/>';
+
   //pull all user signed up for this event, and start table creation
   $result = db_query("SELECT u.uid, u.name, s.signup_time, s.form_data FROM {signup_log} s INNER JOIN {users} u ON
     u.uid = s.uid WHERE s.nid =%d", $node->nid);
-  $output = "<h1>" . check_plain($node->title) . "</h1>";
   $header = array(array('data' => t('%d individual(s) signed up', array('%d' => db_num_rows($result))), 'colspan' => 3));
   $rows = array();
 
cvs diff: Diffing contrib
cvs diff: Diffing contrib/signup_ecommerce
cvs diff: Diffing po
