View source
<?php
function hosting_site_schema() {
$schema['hosting_site'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'client' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'db_server' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'platform' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'profile' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'language' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => 'en',
),
'last_cron' => array(
'type' => 'int',
'not null' => FALSE,
),
'cron_key' => array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 80,
'default' => '',
),
'verified' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'vid',
),
);
$schema['hosting_site_backups'] = array(
'fields' => array(
'bid' => array(
'type' => 'serial',
'not null' => TRUE,
),
'site' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'web_server' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'description' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'filename' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'size' => array(
'type' => 'int',
'not null' => FALSE,
),
'timestamp' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'primary key' => array(
'bid',
),
);
return $schema;
}
function hosting_site_install() {
drupal_install_schema('hosting_site');
}
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 = time();
$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;
}
function hosting_site_update_5() {
$ret = array();
db_drop_primary_key($ret, 'hosting_site_backups');
db_field_set_no_default($ret, 'hosting_site_backups', 'bid');
db_change_field($ret, 'hosting_site_backups', 'bid', 'bid', array(
'type' => 'serial',
'not null' => TRUE,
), array(
'primary key' => array(
'bid',
),
));
return $ret;
}
function hosting_site_update_6() {
$ret = array();
db_add_field($ret, 'hosting_site', 'port', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
return $ret;
}
function hosting_site_update_6001() {
$ret = array();
db_add_field($ret, 'hosting_site', 'ssl', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
return $ret;
}
function hosting_site_update_6002() {
$ret = array();
db_add_field($ret, 'hosting_site', 'ssl_redirect', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
return $ret;
}
function hosting_site_update_6003() {
$ret = array();
return $ret;
}
function hosting_site_update_6004() {
return array();
}
function hosting_site_update_6005() {
$ret = array();
db_drop_field($ret, "hosting_site", "port");
return $ret;
}
function hosting_site_update_6006() {
$ret = array();
db_drop_field($ret, "hosting_site", "`ssl`");
db_drop_field($ret, "hosting_site", "ssl_redirect");
return $ret;
}
function hosting_site_update_6007() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {hosting_site_backups} ADD COLUMN size INT");
return $ret;
}
function hosting_site_update_6008() {
$ret = array();
db_add_field($ret, 'hosting_site', 'cron_key', array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 80,
'default' => '',
));
return $ret;
}
function hosting_site_update_6009() {
$result = db_query("SELECT nid FROM {hosting_site} WHERE status=1");
while ($site = db_fetch_object($result)) {
hosting_add_task($site->nid, 'verify');
}
return $ret;
}