function signup_install in Signup 5.2
Same name and namespace in other branches
- 5 signup.install \signup_install()
- 6.2 signup.install \signup_install()
- 6 signup.install \signup_install()
- 7 signup.install \signup_install()
Implementation of hook_install().
This will automatically install the database tables for the Signup module for both the MySQL and PostgreSQL databases.
If you are using another database, you will have to install the tables by hand, using the queries below as a reference.
Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing, and will need to be removed.
File
- ./
signup.install, line 17
Code
function signup_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$q1 = db_query("CREATE TABLE IF NOT EXISTS {signup} (\n nid int(10) unsigned NOT NULL default '0',\n forwarding_email varchar(64) NOT NULL default '',\n send_confirmation int(2) NOT NULL default '0',\n confirmation_email longtext NOT NULL,\n send_reminder int(2) NOT NULL default '0',\n reminder_days_before int(4) unsigned NOT NULL default '0',\n reminder_email longtext NOT NULL,\n close_in_advance_time int(10) unsigned NOT NULL default '0',\n close_signup_limit int(10) unsigned NOT NULL default '0',\n status int(2) NOT NULL default '1',\n PRIMARY KEY (nid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
$q2 = db_query("CREATE TABLE IF NOT EXISTS {signup_log} (\n uid int(10) unsigned NOT NULL default '0',\n nid int(10) unsigned NOT NULL default '0',\n anon_mail varchar(255) NOT NULL default '',\n signup_time int(10) unsigned NOT NULL default '0',\n form_data longtext NOT NULL,\n KEY uid (uid),\n KEY nid (nid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
$q3 = signup_insert_default_signup_info();
if ($q1 && $q2 && $q3) {
$created = TRUE;
}
break;
case 'pgsql':
$q1 = db_query("CREATE TABLE {signup} (\n nid SERIAL,\n forwarding_email text NOT NULL default '',\n send_confirmation integer NOT NULL default '0',\n confirmation_email text NOT NULL default '',\n send_reminder integer NOT NULL default '0',\n reminder_days_before integer NOT NULL default '0',\n reminder_email text NOT NULL default '',\n close_in_advance_time integer NOT NULL default '0',\n close_signup_limit integer NOT NULL default '0',\n status integer NOT NULL default '1',\n PRIMARY KEY (nid)\n );");
$q2 = db_query("CREATE TABLE {signup_log} (\n uid integer NOT NULL default '0',\n nid integer NOT NULL default '0',\n anon_mail text NOT NULL default '',\n signup_time integer NOT NULL default '0',\n form_data text NOT NULL default ''\n );");
$q3 = db_query("CREATE INDEX {signup_log}_uid_idx ON {signup_log}(uid);");
$q4 = db_query("CREATE INDEX {signup_log}_nid_idx ON {signup_log}(nid);");
$q5 = signup_insert_default_signup_info();
if ($q1 && $q2 && $q3 && $q4 && $q5) {
$created = TRUE;
}
break;
}
if ($created) {
drupal_set_message(t('Signup module installed successfully.'));
}
else {
drupal_set_message(t('Table installation for the Signup module was unsuccessful. The tables may need to be installed by hand. See the signup.install file for a list of the installation queries.'), 'error');
}
}