/[drupal]/contributions/modules/node_invite/node_invite.rsvp.inc
ViewVC logotype

Diff of /contributions/modules/node_invite/node_invite.rsvp.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Tue Sep 1 19:00:13 2009 UTC revision 1.2.2.1, Wed Sep 2 07:35:01 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: node_invite.rsvp.inc,v 1.2 2009/09/01 19:00:13 hadsie Exp $
3  /**  /**
4   * @file   * @file
5   * Provides the invite rsvp response form.   * Provides the invite rsvp response form.
6   */   */
7    
 function node_invite_rsvp($form_state, $node, $iid) {  
   // this form is probably being accessed by anonymous users.  
8    
9    // make sure that iid is a number.  function node_invite_rsvp($form_state, $node, $invite) {
10    if ( !intval($iid) ) {    // this form is probably being accessed by anonymous users.
     drupal_set_message("$iid is not a number. This form should only be called with a invite-id as the 3rd argument in the URL.", 'error');  
     return;  
   }  
11    
12    $q = db_query("SELECT * FROM {node_invites} WHERE nid = %d AND iid = %d", $node->nid, $iid);    if ($node->nid != $invite->nid) {
   $invite = db_fetch_array( $q );  
   if ( !$invite ) {  
13      drupal_set_message(t("This URL is invalid (iid/nid mismatch)"), 'error');      drupal_set_message(t("This URL is invalid (iid/nid mismatch)"), 'error');
14      return;      return;
15    }    }
16    
17    $account = user_load($invite['uid_inviter']);    $account = user_load($invite->uid_inviter);
18    $node->invite_specific_info = array(    $node->invite_specific_info = array(
19      'node-invite-iid' => $invite['iid'],      'node-invite-iid' => $invite->iid,
20      'node-invite-recip-name' => $invite['email_invitee'],      'node-invite-recip-name' => $invite->email_invitee,
21      'node-invite-recip-mail' => $invite['email_invitee'],      'node-invite-recip-mail' => $invite->email_invitee,
22      'inviter-name' => $account->name,      'inviter-name' => $account->name,
23      'inviter-mail' => $account->mail,      'inviter-mail' => $account->mail,
24    );    );
25    
   $page_title = token_replace(  
     variable_get('node_invite_rsvp_page_title', NODE_INVITE_RSVP_PAGE_TITLE),  
     'node',  
     $node  
   );  
   drupal_set_title($page_title);  
   
26    $form['intro'] = array(    $form['intro'] = array(
27      '#value' => token_replace(      '#value' => token_replace(
28        variable_get('node_invite_rsvp_page_intro', NODE_INVITE_RSVP_PAGE_INTRO),        variable_get('node_invite_rsvp_page_intro', NODE_INVITE_RSVP_PAGE_INTRO),
# Line 90  function node_invite_rsvp($form_state, $ Line 76  function node_invite_rsvp($form_state, $
76    );    );
77    
78    // hidden vars for tracking    // hidden vars for tracking
79    $form['nid'] = array(    $form['node'] = array(
80      '#type' => 'value',      '#type' => 'value',
81      '#value' => $node->nid      '#value' => $node,
82    );    );
83    $form['iid'] = array(    $form['invite'] = array(
84      '#type' => 'value',      '#type' => 'value',
85      '#value' => $iid,      '#value' => $invite,
86    );    );
87    
88    return $form;    return $form;
# Line 104  function node_invite_rsvp($form_state, $ Line 90  function node_invite_rsvp($form_state, $
90    
91  function node_invite_rsvp_validate($form, &$form_state) {  function node_invite_rsvp_validate($form, &$form_state) {
92    if (intval(variable_get('node_invite_rsvp_email', '0'))) {    if (intval(variable_get('node_invite_rsvp_email', '0'))) {
93      if (!valid_email_address($form_state['values']['email'])) {      $email = $form_state['values']['email'];
94        // email is not valid.... regardless of whether or not it matches.  send them bck.      if (!valid_email_address($email)) {
95        form_set_error('email', $form_state['values']['email'] . ' is not valid. Please try again.');        // email is not valid.... regardless of whether or not it matches.
96          // send them back.
97          form_set_error('email', t("$email is not a valid email. Please try again."));
98      }      }
99      else {      else {
100        $email = db_result(db_query("SELECT email_invitee FROM {node_invites} WHERE iid = %d AND nid = %d", $form_state['values']['iid'], $form_state['values']['nid']));        $invite = $form_state['values']['invite'];
101        if ($form_state['values']['email'] != $email) {        if ($email != $invite->email_invitee) {
102          form_set_error('email', $form_state['values']['email'] . ' is not the address to which this invite was sent.  Please use the <i>exact</i> email to which this invite was sent.');          form_set_error('email', t("$email is not the address to which this invite was sent.  Please use the <i>exact</i> email to which this invite was sent."));
103        }        }
104      }      }
105    }    }
106  }  }
107    
108  function node_invite_rsvp_submit($form, &$form_state) {  function node_invite_rsvp_submit($form, &$form_state) {
109    db_query("UPDATE {node_invites} SET status = '%s', acted_upon = %d, notes_invitee = '%s' WHERE iid = %d", $form_state['values']['op'], time(), $form_state['values']['comments'], $form_state['values']['iid']);    $invite = $form_state['values']['invite'];
110      db_query("UPDATE {node_invites} SET status = '%s', acted_upon = %d, notes_invitee = '%s' WHERE iid = %d", $form_state['values']['op'], time(), $form_state['values']['comments'], $invite->iid);
111    
112    $node = node_load($form_state['values']['nid']);    $node = $form_state['values']['node'];
113    $admin_notify_setting = variable_get('node_invite_nots_admin', 'site_admin_all');    $admin_notify_setting = variable_get('node_invite_nots_admin', 'site_admin_all');
114    if ($admin_notify_setting == 'site_admin_all') {    if ($admin_notify_setting == 'site_admin_all') {
115      /*      /*
# Line 200  function node_invite_rsvp_submit($form, Line 189  function node_invite_rsvp_submit($form,
189        $node        $node
190      );      );
191      $from = $GLOBALS['conf']['site_mail'];      $from = $GLOBALS['conf']['site_mail'];
192      $to = db_result(db_query("SELECT u.mail FROM {users} u JOIN {node_invites} ni ON u.uid = ni.uid_inviter WHERE iid = %d", $form_state['values']['iid']));      $to = db_result(db_query("SELECT u.mail FROM {users} u JOIN {node_invites} ni ON u.uid = ni.uid_inviter WHERE iid = %d", $invite->iid));
193      $subject = token_replace(      $subject = token_replace(
194        variable_get('node_invite_notify_inviter_notify_subject', NODE_INVITE_NOTIFY_INVITER_NOTIFY_SUBJECT),        variable_get('node_invite_notify_inviter_notify_subject', NODE_INVITE_NOTIFY_INVITER_NOTIFY_SUBJECT),
195        'node',        'node',
# Line 227  function node_invite_rsvp_submit($form, Line 216  function node_invite_rsvp_submit($form,
216      );      );
217    }    }
218    
219    // redirect to the node.    $form_state['redirect'] = 'node/' . $node->nid;
   drupal_goto('node/' . $form_state['values']['nid']);  
220  }  }
221    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.2.2.1

  ViewVC Help
Powered by ViewVC 1.1.2