You are here

hosting_platform.install in Hostmaster (Aegir) 6

Install, update and uninstall for the Platforms module.

File

modules/hosting/platform/hosting_platform.install
View source
<?php

/**
 * @file
 *   Install, update and uninstall for the Platforms module.
 */

/**
 * Implementation of hook_schema().
 */
function hosting_platform_schema() {
  $schema['hosting_platform'] = 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,
      ),
      'publish_path' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
      ),
      'makefile' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
      ),
      'web_server' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'release_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'verified' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'vid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function hosting_platform_install() {

  // Create tables.
  drupal_install_schema('hosting_platform');
}

/**
 * Re-synch all platform to correctly set up the
 * master url, so redirects on disabled sites will
 * work correctly.
 */
function hosting_platform_update_1() {
  include_once drupal_get_path('module', 'hosting_task') . '/hosting_task.module';
  $ret = array();
  $result = db_query("SELECT nid FROM {node} WHERE type='platform' AND status=1");
  while ($platform = db_fetch_object($result)) {
    hosting_add_task($platform->nid, 'synch');
  }
  return $ret;
}

/**
 * no-op - this was replaced by hosting_update_6002()
 */
function hosting_platform_update_6000() {

  // this update was moved to hosting_update_6002()
  return array();
}

// Add a status field to platforms so we can Delete tasks on them
function hosting_platform_update_6001() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {hosting_platform} ADD COLUMN status int(11) NOT NULL default '1'");
  return $ret;
}

/**
 * Move the new menu item to the primary navigation
 */
function hosting_platform_update_6002() {
  $ret = array();
  install_include(array(
    'menu',
  ));
  $menu_name = variable_get('menu_primary_links_source', 'primary-links');
  $items = install_menu_get_items('hosting/platforms');
  $item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $items[0]['mlid']));
  $item['menu_name'] = $menu_name;
  $item['customized'] = 1;
  $item['options'] = unserialize($item['options']);
  install_menu_update_menu_item($item);
  hosting_menu_rebuild();
  return $ret;
}

/**
 * Add the 'makefile' column.
 */
function hosting_platform_update_6003() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {hosting_platform} ADD COLUMN makefile TEXT NOT NULL");
  return $ret;
}
function hosting_platform_update_6004() {
  if (!variable_get('hosting_platform_update_6004_run', false)) {
    $result = db_query("SELECT n.nid, n.title FROM {node} n LEFT JOIN {hosting_platform} p ON p.nid=n.nid WHERE p.status <> -2 AND n.type='platform'");
    while ($object = db_fetch_object($result)) {
      $records[$object->nid] = 'platform_' . preg_replace("/[!\\W]/", "", $object->title);
    }
    foreach ($records as $nid => $name) {
      hosting_context_register($nid, $name);
    }
    variable_set('hosting_platform_update_6004_run', true);
  }
}

Functions

Namesort descending Description
hosting_platform_install Implementation of hook_install().
hosting_platform_schema Implementation of hook_schema().
hosting_platform_update_1 Re-synch all platform to correctly set up the master url, so redirects on disabled sites will work correctly.
hosting_platform_update_6000 no-op - this was replaced by hosting_update_6002()
hosting_platform_update_6001
hosting_platform_update_6002 Move the new menu item to the primary navigation
hosting_platform_update_6003 Add the 'makefile' column.
hosting_platform_update_6004