| 1 |
<?php |
<?php |
| 2 |
// $Id: alt_login.install,v 1.5 2007/02/28 19:23:42 thehunmonkgroup Exp $ |
// $Id: alt_login.install,v 1.6 2007/11/26 00:07:35 thehunmonkgroup Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_install(). |
* @file |
| 6 |
|
* Install, update and uninstall functions for the alt_login module. |
| 7 |
*/ |
*/ |
|
function alt_login_install() { |
|
|
$ret = drupal_install_schema('alt_login'); |
|
|
|
|
|
$failed = array(); |
|
|
foreach ($ret as $query) { |
|
|
if (!$query['success']) { |
|
|
$failed[] = $query['query']; |
|
|
} |
|
|
} |
|
|
if (empty($failed)) { |
|
|
drupal_set_message(t('Alternate login module installed successfully.')); |
|
|
} |
|
|
else { |
|
|
drupal_set_message(t('Table installation for the Alternate login module was unsuccessful. The following queries failed: !queries', array('!queries' => theme('item_list', $failed))), 'error'); |
|
|
} |
|
|
} |
|
| 8 |
|
|
| 9 |
/** |
/** |
| 10 |
* Implementation of hook_schema(). |
* Implementation of hook_schema(). |
| 12 |
function alt_login_schema() { |
function alt_login_schema() { |
| 13 |
|
|
| 14 |
$schema['alt_login'] = array( |
$schema['alt_login'] = array( |
| 15 |
'description' => t('Storage table for alternate user login names.'), |
'description' => 'Storage table for alternate user login names.', |
| 16 |
'fields' => array( |
'fields' => array( |
| 17 |
'uid' => array( |
'uid' => array( |
| 18 |
'description' => t('The uid of the user.'), |
'description' => 'The uid of the user.', |
| 19 |
'type' => 'int', |
'type' => 'int', |
| 20 |
'not null' => TRUE, |
'not null' => TRUE, |
| 21 |
'default' => 0, |
'default' => 0, |
| 22 |
), |
), |
| 23 |
'alt_login' => array( |
'alt_login' => array( |
| 24 |
'description' => t('The alternate login name for the user.'), |
'description' => 'The alternate login name for the user.', |
| 25 |
'type' => 'varchar', |
'type' => 'varchar', |
| 26 |
'length' => 60, |
'length' => 60, |
| 27 |
'not null' => TRUE, |
'not null' => TRUE, |
| 29 |
), |
), |
| 30 |
), |
), |
| 31 |
'primary key' => array('uid'), |
'primary key' => array('uid'), |
| 32 |
|
'foreign keys' => array( |
| 33 |
|
'uid' => array('user' => 'uid'), |
| 34 |
|
), |
| 35 |
); |
); |
| 36 |
|
|
| 37 |
return $schema; |
return $schema; |
| 38 |
} |
} |
| 39 |
|
|
| 40 |
/** |
/** |
|
* Implementation of hook_update_1(). |
|
|
* |
|
|
*/ |
|
|
function alt_login_update_1() { |
|
|
$ret = array(); |
|
|
// Getting rid of alt_login var from users data column. |
|
|
$users = db_query('SELECT uid FROM {users}'); |
|
|
while ($user = db_fetch_object($users)) { |
|
|
$data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $user->uid))); |
|
|
unset($data['alt_login']); |
|
|
$data = serialize($data); |
|
|
db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", $data, $user->uid); |
|
|
} |
|
|
|
|
|
return $ret; |
|
|
} |
|
|
|
|
|
/** |
|
| 41 |
* Implementation of hook_uninstall(). |
* Implementation of hook_uninstall(). |
| 42 |
*/ |
*/ |
| 43 |
function alt_login_uninstall() { |
function alt_login_uninstall() { |
|
|
|
|
// Drop tables. |
|
|
drupal_uninstall_schema('alt_login'); |
|
|
|
|
| 44 |
// Drop variables. |
// Drop variables. |
| 45 |
$variables = array( |
$variables = array( |
| 46 |
'alt_login_user_registration', |
'alt_login_user_registration', |
| 48 |
foreach ($variables as $variable) { |
foreach ($variables as $variable) { |
| 49 |
variable_del($variable); |
variable_del($variable); |
| 50 |
} |
} |
|
|
|
|
drupal_set_message(t('Alternate login module uninstalled successfully.')); |
|
| 51 |
} |
} |
| 52 |
|
|