| 1 |
<?php |
<?php |
| 2 |
// $Id: notify.install,v 1.3 2006/07/20 21:49:21 robroy Exp $ |
// $Id: notify.install,v 1.4.4.2 2008/08/27 14:07:15 matt2000 Exp $ |
| 3 |
|
|
| 4 |
/** |
function notify_schema() { |
| 5 |
* Implementation of hook_install() |
$schema['notify'] = array( |
| 6 |
*/ |
'fields' => array( |
| 7 |
function notify_install() { |
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'), |
| 8 |
switch ($GLOBALS['db_type']) { |
'status' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '2'), |
| 9 |
case 'mysql': |
'node' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '2'), |
| 10 |
case 'mysqli': |
'comment' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '2'), |
| 11 |
$created = db_query("CREATE TABLE IF NOT EXISTS {notify} ( |
'attempts' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '4'), |
| 12 |
uid INT(10) UNSIGNED NOT NULL DEFAULT '0', |
'teasers' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'disp-width' => '4'), |
| 13 |
status TINYINT(2) NOT NULL DEFAULT '0', |
), |
| 14 |
node TINYINT(2) NOT NULL DEFAULT '0', |
'primary key' => array('uid'), |
| 15 |
comment TINYINT(2) NOT NULL DEFAULT '0', |
|
| 16 |
attempts TINYINT(4) NOT NULL DEFAULT '0', |
); |
|
teasers TINYINT(4) NOT NULL DEFAULT '0', |
|
|
PRIMARY KEY (uid) |
|
|
) /*!40100 DEFAULT CHARACTER SET utf8 */;"); |
|
|
break; |
|
|
|
|
|
case 'pgsql': |
|
|
$created = db_query("CREATE TABLE {notify} ( |
|
|
uid integer NOT NULL DEFAULT '0', |
|
|
status integer NOT NULL DEFAULT '0', |
|
|
node integer NOT NULL DEFAULT '0', |
|
|
comment integer NOT NULL DEFAULT '0', |
|
|
attempts integer NOT NULL DEFAULT '0', |
|
|
teasers integer NOT NULL DEFAULT '0', |
|
|
PRIMARY KEY (uid) |
|
|
);"); |
|
|
break; |
|
|
} |
|
| 17 |
|
|
| 18 |
if ($created) { |
return $schema; |
| 19 |
drupal_set_message(t('Notify module installed successfully.')); |
} |
|
} |
|
|
else { |
|
|
drupal_set_message(t('Table installation for the Notify module was unsuccessful. The tables may need to be installed by hand.'), 'error'); |
|
|
} |
|
| 20 |
|
|
| 21 |
// Set the module weight so that the cron job will be executed after |
function notify_install() { |
| 22 |
// scheduler if it is installed. |
// Create my tables. |
| 23 |
$weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'scheduler'")); |
drupal_install_schema('notify'); |
|
$weight += 10; |
|
|
db_query("UPDATE {system} SET weight = %d WHERE name = 'notify'", $weight); |
|
| 24 |
} |
} |
| 25 |
|
|
| 26 |
/** |
function notify_uninstall() { |
| 27 |
* Alter weight of notify to run after scheduler. |
// Drop my tables. |
| 28 |
*/ |
drupal_uninstall_schema('notify'); |
|
function notify_update_1() { |
|
|
$ret = array(); |
|
|
$weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'scheduler'")); |
|
|
$weight += 10; |
|
|
// update_sql() doesn't take other parameters, but this is safe, since $weight |
|
|
// is guaranteed to be an integer. |
|
|
$ret[] = update_sql("UPDATE {system} SET weight = $weight WHERE name = 'notify'"); |
|
|
return $ret; |
|
| 29 |
} |
} |