/[drupal]/contributions/modules/node_invite/node_invite.install
ViewVC logotype

Diff of /contributions/modules/node_invite/node_invite.install

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

revision 1.9.2.2, Thu Sep 3 00:17:30 2009 UTC revision 1.9.2.3, Fri Sep 18 15:56:22 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: node_invite.install,v 1.9.2.1 2009/09/02 05:43:38 hadsie Exp $  // $Id: node_invite.install,v 1.9.2.2 2009/09/03 00:17:30 hadsie Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 156  function node_invite_update_6003() { Line 156  function node_invite_update_6003() {
156    );    );
157    
158    // Now that we have the new column... populate it.    // Now that we have the new column... populate it.
   $hashes = array();  
159    $invites = db_query('SELECT iid, email_invitee, sent FROM {node_invites}');    $invites = db_query('SELECT iid, email_invitee, sent FROM {node_invites}');
160    while ($invite = db_fetch_object($invites)) {    while ($invite = db_fetch_object($invites)) {
161      $hash = md5($invite->email_invitee . $invite->sent);      $hash = md5($invite->email_invitee . $invite->sent);
# Line 167  function node_invite_update_6003() { Line 166  function node_invite_update_6003() {
166    return $ret;    return $ret;
167  }  }
168    
169    /**
170     * Add more invitee data to the database
171     */
172    function node_invite_update_6004() {
173      $ret = array();
174      db_add_field($ret, 'node_invites', 'name_invitee',
175        array(
176          'description' => t('Recipient name'),
177          'type' => 'varchar',
178          'length' => 255,
179          'default' => '',
180        )
181      );
182      db_add_field($ret, 'node_invites', 'uid_invitee',
183        array(
184          'description' => t('The UID of the recipient'),
185          'type'    => 'int',
186          'unsigned'  => TRUE,
187          'default' => 0,
188        )
189      );
190    
191      // Now that we have our new columns, we need to split up the old email_invitee
192      // column
193      $invites = db_query('SELECT iid, email_invitee FROM {node_invites}');
194      while ($invite = db_fetch_object($invites)) {
195        $matches = array();
196        if (preg_match('/^(.*) <(.*)>$/', $invite->email_invitee, $matches)) {
197          $email = $matches[2];
198          $ret[] = update_sql(
199            "UPDATE {node_invites} SET email_invitee = '$email', name_invitee = '$matches[1]' WHERE iid = $invite->iid");
200        }
201        else {
202          $email = $invite->email_invitee;
203        }
204        // Find and update existing users' UIDs
205        if ($uid = db_result(db_query('SELECT uid FROM {users} WHERE mail = "%s"', $email))) {
206          $ret[] = update_sql(
207            "UPDATE {node_invites} SET uid_invitee = $uid WHERE iid = $invite->iid");
208        }
209      }
210      return $ret;
211    }
212    
213  function node_invite_uninstall() {  function node_invite_uninstall() {
214    drupal_uninstall_schema('node_invite');    drupal_uninstall_schema('node_invite');
215    variable_del('node_invite_node_types');    variable_del('node_invite_node_types');

Legend:
Removed from v.1.9.2.2  
changed lines
  Added in v.1.9.2.3

  ViewVC Help
Powered by ViewVC 1.1.2