hosting_site.install in Hosting 5
File
site/hosting_site.install
View source
<?php
function hosting_site_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {hosting_site} (\n vid int(10) unsigned NOT NULL default '0',\n nid int(10) unsigned NOT NULL default '0',\n client int(11) NOT NULL default '0',\n db_server int(11) NOT NULL default '0',\n platform int(11) NOT NULL default '0',\n profile int(11) NOT NULL default '0',\n language VARCHAR(10) NOT NULL default 'en',\n last_cron int(10) default NULL,\n verified int(10) NOT NULL default '0',\n status tinyint NOT NULL default '0',\n PRIMARY KEY (vid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {hosting_site_backups} (\n bid int(10) unsigned NOT NULL,\n site int(10) NOT NULL default '0',\n web_server int(10) NOT NULL default '0',\n description longtext,\n filename longtext,\n timestamp int(11) default NULL,\n PRIMARY KEY (bid) \n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
}
}
function hosting_site_update_1() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_site} ADD COLUMN language VARCHAR(10) NOT NULL default 'en'");
return $ret;
}
function hosting_site_update_2() {
include_once drupal_get_path('module', 'hosting_task') . '/hosting_task.module';
$ret = array();
$result = db_query("select n.nid from {node} n left join {hosting_task} t on n.vid = t.vid where t.task_type = 'install' and t.task_status > 1 and n.type='task'");
while ($obj = db_fetch_object($result)) {
hosting_task_retry($obj->nid);
}
return $ret;
}
function hosting_site_update_3() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_site} CHANGE COLUMN status status int(11) NOT NULL default '0'");
$ret[] = update_sql("CREATE TEMPORARY TABLE {hosting_site_statuses} SELECT nid, \n (status&4) as deleted, NOT (status&2) AS disabled, status&1 AS installed FROM {hosting_site}");
$ret[] = update_sql("UPDATE {hosting_site} SET status = 0");
$ret[] = update_sql("UPDATE {hosting_site} SET status = -2 WHERE nid in (SELECT nid FROM {hosting_site_statuses} WHERE deleted > 0)");
$ret[] = update_sql("DELETE FROM {hosting_site_statuses} WHERE deleted > 0");
$ret[] = update_sql("UPDATE {hosting_site} SET status = -1 WHERE nid in (SELECT nid FROM {hosting_site_statuses} WHERE disabled > 0)");
$ret[] = update_sql("DELETE FROM {hosting_site_statuses} WHERE disabled > 0");
$ret[] = update_sql("UPDATE {hosting_site} SET status = 1 WHERE nid in (SELECT nid FROM {hosting_site_statuses} WHERE installed > 0)");
$ret[] = update_sql("DELETE FROM {hosting_site_statuses} WHERE installed > 0");
$ret[] = update_sql("DROP TABLE {hosting_site_statuses}");
return $ret;
}
function hosting_site_update_4() {
$ret = array();
$now = mktime();
$ret[] = update_sql("ALTER TABLE {hosting_site} ADD COLUMN verified int(10) NOT NULL default '0'");
db_query("UPDATE {hosting_site} SET verified=%d WHERE status=1", $now);
return $ret;
}