Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.205.2.9
diff -u -p -r1.205.2.9 signup.module
--- signup.module	14 Jan 2009 17:36:17 -0000	1.205.2.9
+++ signup.module	16 Jan 2009 01:06:09 -0000
@@ -157,6 +157,7 @@ function signup_theme() {
       'arguments' => array(
         'signup_data' => NULL,
         'cancel_signup_form' => '',
+        'edit_signup_link' => '',
       ),
     ),
     'signup_custom_data_table' => array(
@@ -350,6 +351,16 @@ function signup_menu() {
     'file' => 'signup_cancel.inc',
     'file path' => $path,
   );
+  $items['signup/edit/%signup_menu'] = array(
+    'title' => 'Edit signup',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('signup_edit_form', 2),
+    'access callback' => '_signup_edit_menu_access',
+    'access arguments' => array(2),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'signup_edit_form.inc',
+    'file path' => $path,
+  );
 
   $items['admin/content/signup'] = array(
     'description' => 'View all signup-enabled posts, and open or close signups on them.',
@@ -509,6 +520,33 @@ function _signup_user_menu_access($accou
 }
 
 /**
+ * Menu loader callback to load a project node.
+ */
+function signup_menu_load($sid) {
+  if (!is_numeric($sid)) {
+    return FALSE;
+  }
+  $signup = signup_load_signup($sid);
+  if (empty($signup)) {
+    return FALSE;
+  }
+  return $signup;
+}
+
+function _signup_edit_menu_access($signup) {
+  global $user;
+  if (user_access('edit own signups') && !empty($user->uid) && ($user->uid == $signup->uid)) {
+    return TRUE;
+  }
+  // Check admin powers for this signup.
+  $node = node_load($signup->nid);
+  if (_signup_menu_access($node, 'admin')) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
  * Menu callback to handle the default tab at node/N/signups
  *
  * This tests the user's permission to see what tab they should really see.
@@ -567,6 +605,7 @@ function signup_perm() {
     'sign up for content',
     'cancel signups',
     'cancel own signups',
+    'edit own signups',
     'view all signups',
     'administer all signups',
     'administer signups for own content',
@@ -857,8 +896,10 @@ function signup_object_info() {
  */ 
 function signup_load_signup($sid) {
   $signup = db_fetch_object(db_query("SELECT sl.*, n.title, u.name FROM {signup_log} sl INNER JOIN {node} n ON sl.nid = n.nid INNER JOIN {users} u ON sl.uid = u.uid WHERE sl.sid = %d", $sid));
-  // This label is escaped by VBO, so it needs to be plain text, not HTML.
-  $signup->label = t("!user signup for '!title'", array('!user' => $signup->name, '!title' => $signup->title));
+  if (!empty($signup)) {
+    // This label is escaped by VBO, so it needs to be plain text, not HTML.
+    $signup->label = t("!user signup for '!title'", array('!user' => $signup->name, '!title' => $signup->title));
+  }
   return $signup;
 }
 
cvs diff: Diffing includes
Index: includes/node_output.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/includes/node_output.inc,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 node_output.inc
--- includes/node_output.inc	14 Jan 2009 18:11:21 -0000	1.1.2.4
+++ includes/node_output.inc	16 Jan 2009 01:06:09 -0000
@@ -202,7 +202,15 @@ function _signup_print_current_signup($n
     $cancel_signup_form = drupal_get_form('signup_cancel_form', $signup_info->sid);
   }
 
+  // See if the user should get a link to edit their signup.
+  $edit_signup_link = '';
+  if (user_access('edit own signups')) {
+    $url = "signup/edit/$signup_info->sid";
+    $link_options['query'] = drupal_get_destination();
+    $edit_signup_link = l(t('Edit signup'), $url, $link_options);
+  }
+
   // Hand off everything to the theme function for actual HTML generation.
-  return theme('signup_current_signup', $signup_data, $cancel_signup_form);
+  return theme('signup_current_signup', $signup_data, $cancel_signup_form, $edit_signup_link);
 }
 
Index: includes/signup_edit_form.inc
===================================================================
RCS file: includes/signup_edit_form.inc
diff -N includes/signup_edit_form.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/signup_edit_form.inc	16 Jan 2009 01:06:10 -0000
@@ -0,0 +1,71 @@
+<?php
+// $Id$
+
+
+/**
+ * @file
+ * Code for the form to edit existing signups.
+ */
+
+/**
+ * Build the form for editing existing signups.
+ */
+function signup_edit_form($form_state, $signup) {
+  global $user;
+  $form = array();
+
+  $form['#signup'] = $signup;
+
+  // Build the themed signup form for this site and include that.
+  $node = node_load($signup->nid);
+  $site_form = theme('signup_user_form', $node);
+  $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;
+    }
+  }
+  $form += $site_form;
+
+  $form['buttons'] = array();
+  $form['buttons']['update'] = array(
+    '#type' => 'submit',
+    '#value' => t('Update'),
+    '#submit' => array('signup_edit_form_update_submit'),
+  );
+  $cancel_own = user_access('cancel own signups') && !empty($user->uid) && $user->uid == $signup->uid;
+  $admin = _signup_menu_access($node, 'admin');
+  if ($cancel_own || $admin) {
+    $form['buttons']['cancel'] = array(
+      '#type' => 'submit',
+      '#value' => t('Cancel signup'),
+      '#submit' => array('signup_edit_form_cancel_submit'),
+    );
+  }
+  return $form;
+}
+
+/**
+ * Submit callback when updating an existing signup.
+ */
+function signup_edit_form_update_submit($form, $form_state) {
+  $signup_info = array();
+  if (!empty($form_state['values']['signup_form_data'])) {
+    $signup_info = $form_state['values']['signup_form_data'];
+  }
+  /// @TODO invoke a hook?
+  /// @TODO should we have a "signup_update_time" field and update that, too?
+  db_query("UPDATE {signup_log} SET form_data = '%s' WHERE sid = %d", serialize($signup_info), $form['#signup']->sid);
+  drupal_set_message(t('Updated signup information'));
+}
+
+/**
+ * Submit callback to cancel the signup when editing an existing signup.
+ */
+function signup_edit_form_cancel_submit($form, $form_state) {
+  signup_cancel_signup($form['#signup']->sid);
+}
+
cvs diff: Diffing js
cvs diff: Diffing panels
cvs diff: Diffing panels/content_types
cvs diff: Diffing theme
Index: theme/node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/theme/node.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 node.inc
--- theme/node.inc	7 Jan 2009 00:55:05 -0000	1.1.2.1
+++ theme/node.inc	16 Jan 2009 01:06:10 -0000
@@ -68,13 +68,18 @@ function theme_signup_node_output_header
  *   'custom_data' - Array containing the user's custom signup data.
  * @param $cancel_signup_form
  *   Optional HTML for a "Cancel signup" button if the user is allowed.
+ * @param $edit_signup_link
+ *   Optional HTML for a link to edit the signup if the user is allowed.
  *
  * @return
  *   Themed output containing the user's current signup information.
  */
-function theme_signup_current_signup($signup_data, $cancel_signup_form = '') {
+function theme_signup_current_signup($signup_data, $cancel_signup_form = '', $edit_signup_link = '') {
   $output = theme('signup_custom_data_table', $signup_data['custom_data']);
+  $output .= '<div class="container-inline">';
+  $output .= $edit_signup_link;
   $output .= $cancel_signup_form;
+  $output .= '</div>';
   return $output;
 }
 
cvs diff: Diffing translations
cvs diff: Diffing views
Index: views/signup.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/views/signup.views.inc,v
retrieving revision 1.4.2.5
diff -u -p -r1.4.2.5 signup.views.inc
--- views/signup.views.inc	14 Jan 2009 17:36:18 -0000	1.4.2.5
+++ views/signup.views.inc	16 Jan 2009 01:06:10 -0000
@@ -274,6 +274,14 @@ function signup_views_data() {
     ),
   );
 
+  $data['signup_log']['edit_link'] = array(
+    'title' => t('User: Edit signup link'),
+    'field' => array(
+      'handler' => 'signup_handler_field_signup_edit_link',
+      'help' => t('Link to edit this particular signup.'),
+    ),
+  );
+
   return $data;
 }
 
@@ -292,6 +300,9 @@ function signup_views_handlers() {
       'signup_handler_argument_signup_user_uid' => array(
         'parent' => 'views_handler_argument_numeric',
       ),
+      'signup_handler_field_signup_edit_link' => array(
+        'parent' => 'views_handler_field_node_link',
+      ),
       'signup_handler_field_signup_node_link' => array(
         'parent' => 'views_handler_field_node_link',
       ),
cvs diff: Diffing views/handlers
Index: views/handlers/signup_handler_field_signup_edit_link.inc
===================================================================
RCS file: views/handlers/signup_handler_field_signup_edit_link.inc
diff -N views/handlers/signup_handler_field_signup_edit_link.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/handlers/signup_handler_field_signup_edit_link.inc	16 Jan 2009 01:06:10 -0000
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+
+/**
+ * Field handler to generate a link to edit a given signup.
+ */
+class signup_handler_field_signup_edit_link extends views_handler_field_node_link {
+  function construct() {
+    parent::construct();
+    $this->additional_fields['sid'] = array('table' => 'signup_log', 'field' => 'sid');
+    $this->additional_fields['uid'] = array('table' => 'signup_log', 'field' => 'uid');
+  }
+
+  function render($values) {
+    global $user;
+
+    // Check access to edit this signup.
+    $signup = new StdClass();
+    $signup->sid = $values->{$this->aliases['sid']};
+    $signup->nid = $values->{$this->aliases['nid']};
+    $signup->uid = $values->{$this->aliases['uid']};
+    if (!_signup_edit_menu_access($signup)) {
+      return;
+    }
+
+    // If we made it this far, generate the actual link.
+    $text = !empty($this->options['text']) ? $this->options['text'] : t('Edit signup');
+    $url = "signup/edit/$signup->sid";
+    $link_options['query'] = drupal_get_destination();
+    return l($text, $url, $link_options);
+  }
+}
+
cvs diff: Diffing views/plugins
