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

Diff of /contributions/modules/invite/invite.install

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

revision 1.13, Tue Sep 2 17:02:14 2008 UTC revision 1.14, Fri Oct 9 20:28:19 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: invite.install,v 1.12 2008/08/20 13:26:11 smk Exp $  // $Id: invite.install,v 1.13 2008/09/02 17:02:14 smk Exp $
3    
4    /**
5     * @file
6     * Installation file for invite module.
7     */
8    
9  /**  /**
10   * Install the initial schema.   * Install the initial schema.
# Line 164  function _invite_add_permission($rid, $p Line 169  function _invite_add_permission($rid, $p
169    }    }
170  }  }
171    
172    /**
173     * Helper function to update a variable name using role name to role id.
174     */
175    function _invite_update_role_name_to_id($variable) {
176      $result = db_query("SELECT * FROM {role} ORDER BY name ASC");
177      while ($role = db_fetch_object($result)) {
178        // Look for both a translated (D6) and untranslated (D5) variables.
179        // A translated one is newer and has therefore precendence.
180        $translated_role = str_replace(' ', '_', t($role->name));
181        $value = variable_get($variable .'_'. $translated_role, NULL);
182        if (is_null($value)) {
183          $untranslated_role = str_replace(' ', '_', $role->name);
184          $value = variable_get($variable .'_'. $untranslated_role, NULL);
185        }
186        if (!is_null($value)) {
187          variable_set($variable .'_'. $role->rid, $value);
188          db_query("DELETE FROM {variable} WHERE name IN('%s', '%s')", $variable .'_'. $translated_role, $variable .'_'. $untranslated_role);
189        }
190      }
191    }
192    
193  /**  /**
194   * Switch to token.module.   * Switch to token.module.
# Line 191  function invite_update_8() { Line 216  function invite_update_8() {
216    // Convert existing messages    // Convert existing messages
217    $result = db_query("SELECT reg_code, data FROM {invite} WHERE data <> ''");    $result = db_query("SELECT reg_code, data FROM {invite} WHERE data <> ''");
218    while ($row = db_fetch_object($result)) {    while ($row = db_fetch_object($result)) {
219      if (substr($row->message, 0, 2) == 'a:') {      if (drupal_substr($row->message, 0, 2) == 'a:') {
220        // Already serialized        // Already serialized
221        continue;        continue;
222      }      }
# Line 225  function invite_update_9() { Line 250  function invite_update_9() {
250      }      }
251      _invite_add_permission($rid, implode(', ', $perms));      _invite_add_permission($rid, implode(', ', $perms));
252    }    }
253    db_query("DELETE from {variable} WHERE name LIKE 'invite_maxmultiple_%%'");    $ret[] = update_sql("DELETE from {variable} WHERE name LIKE 'invite_maxmultiple_%%'");
254    
255    // Expiry periods changed    // Expiry periods changed
256    $expiry = variable_get('invite_expiry', 30);    $expiry = variable_get('invite_expiry', 30);
# Line 308  function invite_update_200() { Line 333  function invite_update_200() {
333    db_change_field($ret, 'invite', 'mid', 'invitee', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));    db_change_field($ret, 'invite', 'mid', 'invitee', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
334    db_change_field($ret, 'invite', 'timestamp', 'joined', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));    db_change_field($ret, 'invite', 'timestamp', 'joined', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
335    db_add_field($ret, 'invite', 'created', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));    db_add_field($ret, 'invite', 'created', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
336    db_add_field($ret, 'invite', 'cancelled', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));    db_add_field($ret, 'invite', 'canceled', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
337    db_add_field($ret, 'invite', 'resent', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));    db_add_field($ret, 'invite', 'resent', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
338    return $ret;    return $ret;
339  }  }
# Line 341  function invite_update_201() { Line 366  function invite_update_201() {
366      )      )
367    ));    ));
368    // Convert old data    // Convert old data
369    db_query("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, invitee FROM {invite} WHERE joined <> 0 AND received = 0");    $ret[] = update_sql("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, invitee FROM {invite} WHERE joined <> 0 AND received = 0");
370    // Drop old column    // Drop old column
371    db_drop_field($ret, 'invite', 'received');    db_drop_field($ret, 'invite', 'received');
372    return $ret;    return $ret;
# Line 357  function invite_update_202() { Line 382  function invite_update_202() {
382    return $ret;    return $ret;
383  }  }
384    
385    /**
386     * Update variable names to use role id instead of translated role name.
387     * @see #322748
388     */
389    function invite_update_203() {
390      $ret = array();
391      _invite_update_role_name_to_id('invite_maxnum');
392      _invite_update_role_name_to_id('invite_target_role');
393      return $ret;
394    }
395    

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.2