| 1 |
<?php |
<?php |
| 2 |
// $Id: alt_login.install,v 1.4 2007/02/27 22:51:58 thehunmonkgroup Exp $ |
// $Id: alt_login.install,v 1.5 2007/02/28 19:23:42 thehunmonkgroup Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 6 |
*/ |
*/ |
| 7 |
function alt_login_install() { |
function alt_login_install() { |
| 8 |
switch ($GLOBALS['db_type']) { |
$ret = drupal_install_schema('alt_login'); |
|
case 'mysql': |
|
|
case 'mysqli': |
|
|
$query1 = db_query("CREATE TABLE {alt_login} ( |
|
|
uid INT(11) NOT NULL, |
|
|
alt_login varchar(60) NOT NULL default '', |
|
|
PRIMARY KEY (uid) |
|
|
) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); |
|
|
break; |
|
|
case 'pgsql': |
|
|
$query1 = db_query("CREATE TABLE {alt_login} ( |
|
|
uid serial CHECK (uid >= 0), |
|
|
alt_login varchar(60) NOT NULL default '', |
|
|
PRIMARY KEY (uid) |
|
|
)"); |
|
|
break; |
|
|
} |
|
| 9 |
|
|
| 10 |
if ($query1) { |
$failed = array(); |
| 11 |
drupal_set_message(t('The Alternate Login module was installed successfully.')); |
foreach ($ret as $query) { |
| 12 |
|
if (!$query['success']) { |
| 13 |
|
$failed[] = $query['query']; |
| 14 |
|
} |
| 15 |
|
} |
| 16 |
|
if (empty($failed)) { |
| 17 |
|
drupal_set_message(t('Alternate login module installed successfully.')); |
| 18 |
} |
} |
| 19 |
else { |
else { |
| 20 |
drupal_set_message(t('There was an error installing the Alternate Login database tables--they may need to be installed manually.'), 'error'); |
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'); |
| 21 |
} |
} |
| 22 |
} |
} |
| 23 |
|
|
| 24 |
/** |
/** |
| 25 |
|
* Implementation of hook_schema(). |
| 26 |
|
*/ |
| 27 |
|
function alt_login_schema() { |
| 28 |
|
|
| 29 |
|
$schema['alt_login'] = array( |
| 30 |
|
'description' => t('Storage table for alternate user login names.'), |
| 31 |
|
'fields' => array( |
| 32 |
|
'uid' => array( |
| 33 |
|
'description' => t('The uid of the user.'), |
| 34 |
|
'type' => 'int', |
| 35 |
|
'not null' => TRUE, |
| 36 |
|
'default' => 0, |
| 37 |
|
), |
| 38 |
|
'alt_login' => array( |
| 39 |
|
'description' => t('The alternate login name for the user.'), |
| 40 |
|
'type' => 'varchar', |
| 41 |
|
'length' => 60, |
| 42 |
|
'not null' => TRUE, |
| 43 |
|
'default' => '', |
| 44 |
|
), |
| 45 |
|
), |
| 46 |
|
'primary key' => array('uid'), |
| 47 |
|
); |
| 48 |
|
|
| 49 |
|
return $schema; |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
/** |
| 53 |
* Implementation of hook_update_1(). |
* Implementation of hook_update_1(). |
| 54 |
* |
* |
| 55 |
*/ |
*/ |
| 71 |
* Implementation of hook_uninstall(). |
* Implementation of hook_uninstall(). |
| 72 |
*/ |
*/ |
| 73 |
function alt_login_uninstall() { |
function alt_login_uninstall() { |
|
if (db_table_exists('alt_login')) { |
|
|
$query1 = db_query('DROP TABLE {alt_login}'); |
|
|
} |
|
|
variable_del('alt_login_user_registration'); |
|
| 74 |
|
|
| 75 |
if ($query1) { |
// Drop tables. |
| 76 |
drupal_set_message(t('The Alternate Login module has been uninstalled successfully.')); |
drupal_uninstall_schema('alt_login'); |
| 77 |
} |
|
| 78 |
else { |
// Drop variables. |
| 79 |
drupal_set_message(t('There was an error uninstalling the Alternate Login database tables.'), 'error'); |
$variables = array( |
| 80 |
|
'alt_login_user_registration', |
| 81 |
|
); |
| 82 |
|
foreach ($variables as $variable) { |
| 83 |
|
variable_del($variable); |
| 84 |
} |
} |
| 85 |
|
|
| 86 |
|
drupal_set_message(t('Alternate login module uninstalled successfully.')); |
| 87 |
} |
} |