You are here

hosting_site.module in Hostmaster (Aegir) 6

File

modules/hosting/site/hosting_site.module
View source
<?php

/**
 * This site is deleted from the backend.
 */
define('HOSTING_SITE_DELETED', -2);

/**
 * This site is disabled.
 */
define('HOSTING_SITE_DISABLED', -1);

/**
 * This site is queued for creation.
 */
define('HOSTING_SITE_QUEUED', 0);

/**
 * This site is created and enabled in the backend.
 */
define('HOSTING_SITE_ENABLED', 1);
include_once 'hosting_site.nodeapi.inc';
include_once 'hosting_site.form.inc';
include_once 'hosting_site.backups.inc';

//Conditonally include site quotas
if (module_exists('hosting_quota')) {
  include_once 'hosting_site.quota.inc';
}

/**
 * Implementation of hook_menu()
 */
function hosting_site_menu() {
  $items = array();
  $items['hosting/sites'] = array(
    'title' => 'Sites',
    'description' => 'Display a list of sites',
    'page callback' => 'hosting_sites',
    'access arguments' => array(
      'view site',
    ),
  );
  $items['hosting/hosting_site_form_check'] = array(
    'page callback' => '_hosting_site_form_check',
    'type' => MENU_CALLBACK,
    'access arguments' => array(
      'access content',
    ),
  );
  $items['node/%hosting_site_node/goto_site'] = array(
    'page callback' => 'hosting_site_goto',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'node_access',
    'access arguments' => array(
      'view',
      1,
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}
function _hosting_site_form_check() {
  drupal_json(hosting_site_available_options($_POST));
  exit;
}

/**
 * Implementation of hook_load().
 *
 * @param arg
 *    Node's numeric nid
 */
function hosting_site_node_load($arg) {
  if (!is_numeric($arg)) {
    return FALSE;
  }
  if ($node = node_load($arg)) {
    if ($node->type == 'site') {
      return $node;
    }
  }
  return FALSE;
}

/**
 * Page handler for displaying list of hosted sites on front page
 */
function hosting_sites() {
  if ($list = drupal_get_form('hosting_site_list_form')) {
    return $list;
  }
  $create_site_link = l(t('Create a site now?'), 'node/add/site');
  return t("No sites have been created yet. !link", array(
    '!link' => $create_site_link,
  ));
}

/**
 * Generate a link allowing the user to log into their new site, or simply
 * go to the site front page if the link has expired.
 */
function _hosting_site_goto_link($node) {
  $cache = cache_get("hosting:site:" . $node->nid . ":login_link");
  if (user_access('create login-reset task') && !is_null($cache) && time() < $cache->data['expire']) {
    $title = t("Log in to !url", array(
      '!url' => $node->title,
    ));
  }
  else {
    $title = t("Go to !url", array(
      '!url' => $node->title,
    ));
  }
  $options['attributes']['class'] = 'hosting-goto-site-link';
  return l($title, "node/" . $node->nid . "/goto_site", $options);
}

/**
 * Menu callback to go to your site.
 *
 * This needs to be a callback because the link is only going to work once, 
 * so this will remove the link from the cache and just redirect to the site
 * not the login page.
 */
function hosting_site_goto($node) {
  $cid = "hosting:site:" . $node->nid . ":login_link";
  $cache = cache_get($cid);
  if (user_access('create login-reset task') && !is_null($cache) && time() < $cache->data['expire']) {
    $theurl = $cache->data['link'];
    cache_clear_all($cid, 'cache');
  }
  else {
    $theurl = _hosting_site_url($node);
  }
  drupal_goto($theurl);
  exit;
}

/**
 * Retrieve the port the site will be available on, so we can redirect.
 */
function hosting_site_get_port($node) {
  $platform = node_load($node->platform);
  $server = node_load($platform->web_server);
  return $server->services['http']->port;
}

/**
 * Get site's URL.
 */
function _hosting_site_url($node) {
  $schema = 'http';
  $port = null;
  $url = strtolower(trim($node->title));
  $platform = node_load($node->platform);
  $server = node_load($platform->web_server);
  if ($server->services['http']
    ->has_port()) {
    $port = $server->services['http']->port;
    if ($port == 80) {
      $port = null;
    }
  }

  /**
   * This is part of the ssl feature, but is better to implement here.
   */
  if (isset($node->ssl_enabled) && $node->ssl_enabled == 2) {

    // this is a bit of a magic number, because we cant rely on the constant being available yet.
    // 2 == Only SSL is enabled.
    $schema = 'https';
    if ($server->services['http']
      ->has_port()) {
      $port = $server->services['http']->ssl_port;
      if ($port == 443) {
        $port = null;
      }
    }
  }
  if (is_numeric($port)) {
    return "{$schema}://{$url}:{$port}";
  }
  return "{$schema}://{$url}";
}

/**
 * Implementation of hook_hosting_tasks
 */
function hosting_site_hosting_tasks() {
  $tasks = array();
  $tasks['site']['backup'] = array(
    'title' => t('Backup'),
    'description' => t('Generate a backup of this site that can be restored to at any time'),
    'dialog' => TRUE,
  );
  $tasks['site']['restore'] = array(
    'title' => t('Restore'),
    'description' => t('Restore this site to a previous backup. A new backup will be created before this is attempted.'),
    'dialog' => TRUE,
  );
  $tasks['site']['verify'] = array(
    'title' => t('Verify'),
    'description' => t('Confirm that the site has been correctly installed and regenerate all configuration files to match the hosting front end.'),
    'provision_save' => TRUE,
  );
  $tasks['site']['disable'] = array(
    'title' => t('Disable'),
    'description' => t('Disabling this site will stop it from being accessible.
         It can be enabled again later.'),
    'dialog' => TRUE,
  );
  $tasks['site']['enable'] = array(
    'title' => t('Enable'),
    'description' => t('Enabling this site will allow it to be accesible again.
         It may be disabled again if needed.'),
  );
  $tasks['site']['delete'] = array(
    'title' => t('Delete'),
    'description' => t('Deleting this site will completely remove it from the hosting system,
        but will keep the last backup available. This process can not be undone.
        Are you really sure you want to delete this site?'),
    'dialog' => TRUE,
  );
  $tasks['site']['login_reset'] = array(
    'title' => t('Reset password'),
    'description' => t('Generate a one-time login reset url for this site.'),
  );
  $tasks['site']['backup_delete'] = array(
    'title' => t('Delete backups'),
    'description' => t('Delete one or more backup files of a site.'),
    'dialog' => TRUE,
  );
  $tasks['site']['install'] = array(
    'title' => t('Install'),
    'description' => t('Install a site'),
    'hidden' => TRUE,
    'provision_save' => TRUE,
  );
  $tasks['site']['import'] = array(
    'title' => t('Import'),
    'description' => t('Import an existing site into Aegir'),
    'hidden' => TRUE,
    'provision_save' => TRUE,
  );
  return $tasks;
}

/**
 * Implementation of hook_perm
 */
function hosting_site_perm() {
  return array(
    'create site',
    'view site',
    'edit site',
    'delete site',
    'administer sites',
  );
}

/**
 * Implementation of hook_access
 */
function hosting_site_access($op, $node, $account) {
  if ($op != 'create' && hosting_feature('client')) {

    // we rely on hosting_node_grants() instead of global configuration
    return NULL;
  }
  switch ($op) {
    case 'create':
      return user_access('create site', $account);
      break;
    case 'update':
      return user_access('edit site', $account);
      break;
    case 'delete':
      return user_access('delete site', $account);
      break;
    case 'view':
      return user_access('view site', $account);
      break;
  }
}

/**
 * Returns a count of sites.
 *
 * This is used by cron and statistics to batch the number of sites that are
 * processed with each call. It is also used to generate the 'site count' per
 * platform at /hosting/platforms
 *
 * By default it only counts enabled sites.
 *
 * Optionally can include an array of site statuses by which to consider in the
 * count.
 *
 * @param $platform
 *   (optional) A platform nid to only count sites on that specific platform.
 * @param $statuses
 *   (optional) An array of site statuses (defined by their constants) by which
 *   to include such sites in the site count.
 *
 * @return
 *   The number of sites matching the specified criteria.
 */
function hosting_site_count($platform = NULL, $statuses = NULL) {
  if (is_null($statuses)) {
    $statuses = array(
      HOSTING_SITE_ENABLED,
    );
  }
  $args = array();
  $query = "SELECT count(nid) FROM {hosting_site}";
  $where = array();
  if (count($statuses)) {
    $where[] = '(status IN (' . db_placeholders($statuses) . '))';
    $args = array_merge($args, $statuses);
  }
  if (!is_null($platform)) {
    $where[] = "(platform = %d)";
    $args[] = $platform;
  }
  if (!empty($where)) {
    $query .= ' WHERE ' . implode(' AND ', $where);
  }
  return db_result(db_query($query, $args));
}

/**
 * Retrieve sites on a specific platform, with a specific status
 */
function hosting_get_sites_by_status($platform, $status) {
  $nodes = array();
  $result = db_query("SELECT nid FROM {hosting_site} WHERE platform=%d AND status = %d", $platform, $status);
  while ($nid = db_fetch_object($result)) {
    $nodes[$nid->nid] = node_load($nid->nid);
  }
  return $nodes;
}

/**
 * Retrieve a node based on the url
 */
function hosting_get_site_by_url($url) {

  // If the Aliases feature is enabled, try and get the site by its alias too
  if (hosting_feature('alias')) {
    $nid = db_result(db_query("SELECT n.nid FROM {node} n JOIN {hosting_site} h ON n.nid = h.nid LEFT JOIN {hosting_site_alias} ha ON h.vid = ha.vid WHERE (n.title = '%s' OR ha.alias = '%s') AND n.type = 'site' AND NOT (h.status = %d)", $url, $url, HOSTING_SITE_DELETED));
  }
  else {
    $nid = db_result(db_query("SELECT n.nid FROM {node} n JOIN {hosting_site} h ON n.nid = h.nid WHERE n.title='%s' AND n.type = 'site' AND NOT (h.status=%d)", $url, HOSTING_SITE_DELETED));
  }
  if ($nid) {
    return node_load($nid);
  }
  return false;
}

/**
 * Helper function to generate update a site node during import.
 *
 * @param $site_id
 *   The node ID of the existing site node to update.
 * @param $data
 *  An associative array of data to add to the site node. Keys should correspond
 *  to properties on the node object to overwrite.
 * @param $platform
 *   The node ID of the platform that the site is deployed on.
 */
function hosting_import_site($site_id, $data, $platform) {
  global $user;
  $client = node_load(HOSTING_DEFAULT_CLIENT);
  if ($data['client_name']) {
    $client = hosting_import_client($data['client_name']);
  }
  elseif ($data['client_email']) {

    // @deprecated drop this after 1.x
    $client = hosting_import_client($data['client_email']);
  }
  $site = node_load($site_id);
  $site->nid = $site_id;
  $site->uid = $client->uid;
  $site->status = 1;
  $site->site_status = 1;
  $site->platform = $platform;
  $site->no_verify = TRUE;
  $site->verified = time();
  $site->client = $client->nid;
  $site->ip_addresses = array_values($data['site_ip_addresses']);
  $site->cron_key = $data['cron_key'] ? $data['cron_key'] : '';
  $site->aliases = $data['aliases'] ? $data['aliases'] : array();
  $site->db_server = $site->db_server ? $site->db_server : HOSTING_DEFAULT_DB_SERVER;
  $site->site_language = $data['language'] ? $data['language'] : 'en';

  // Drupal 6 introduced a language field on nodes
  unset($data['language']);
  $profile = hosting_package_instance_load(array(
    'i.rid' => $platform,
    'p.short_name' => $data['profile'],
  ));
  if (!$profile) {
    $profile = hosting_package_instance_load(array(
      'i.rid' => $platform,
      'p.short_name' => 'default',
    ));
  }
  $site->profile = $profile->package_id;

  // cast site object to array, will be using various array_* functions on the data.
  $site = (array) $site;

  // Protect the fields already in the site object.
  foreach (array_keys($site) as $key) {
    unset($data[$key]);
  }

  // Load all the original node fields.
  $site = array_merge((array) node_load($site_id), $site);

  // Map the imported fields onto the node object.
  $site = array_merge($site, $data);

  // Cast back to object.
  $site = (object) $site;
  node_save($site);
}

/**
 * Define the status types of a site
 */
function _hosting_site_status($node) {
  $status = is_numeric($node) ? $node : $node->site_status;
  static $labels = array(
    HOSTING_SITE_QUEUED => "Queued",
    HOSTING_SITE_ENABLED => "Enabled",
    HOSTING_SITE_DELETED => "Deleted",
    HOSTING_SITE_DISABLED => "Disabled",
  );
  return $labels[$status];
}

/**
 * Check if a site exists in a somehow wrong way
 *
 * @see hosting_domain_allowed()
 * @deprecated
 */
function hosting_site_exists($url, $nid = null) {
  return !hosting_domain_allowed($url, array(
    'nid' => $nid,
  ));
}

/**
 * Implementation of hook_allow_domain().
 *
 * @see hosting_domain_allowed()
 */
function hosting_site_allow_domain($url, $params = array()) {
  $query = "SELECT COUNT(n.nid) FROM {node} n \n    JOIN {hosting_site} h ON n.nid = h.nid\n    WHERE type='site' AND title='%s' AND h.status <> %d ";
  $args[] = $url;
  $args[] = HOSTING_SITE_DELETED;
  if (isset($params['nid'])) {
    $query .= ' AND n.nid <> %d';
    $args[] = $params['nid'];
  }
  $result = !db_result(db_query($query, $args));
  return $result;
}
function hosting_site_task_status($nid) {
  return hosting_task_status_output('nid', $nid, 'install');
}

/**
 * Create a form for building a list of sites.
 * @TODO Add ability to filter by additional fields
 */
function hosting_site_list_form($form_state, $filter_by = NULL, $filter_value = NULL) {
  $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] : 1;

  // Step 1 - select sites
  if ($step == 1) {
    $args[] = 'site';
    $cond = '';
    if ($filter_by && $filter_value) {
      if ($filter_by == 'status') {
        $cond = ' AND s.' . $filter_by . ' & %d';
      }
      else {
        $cond = ' AND s.' . $filter_by . ' = %d';
      }
      $args[] = $filter_value;
    }
    $header = array(
      array(
        'data' => t('Site'),
        'field' => 'title',
      ),
      array(
        'data' => t('Profile'),
        'field' => 'profile',
      ),
      array(
        'data' => t('Language'),
        'field' => 'site_language',
      ),
      array(
        'data' => t('Created'),
        'field' => 'created',
        'sort' => 'desc',
      ),
    );
    $platforms = _hosting_get_platforms();
    if (sizeof($platforms) > 1) {
      $header[] = array(
        'data' => t('Platform'),
        'field' => 'platform',
      );
    }
    $sql = "SELECT n.nid, n.title, n.created, s.status as site_status, profile, s.language as site_language, platform, verified FROM {node} n left join {hosting_site} s ON n.vid=s.vid WHERE type='%s' AND s.status != -2 " . $cond;
    $sql .= tablesort_sql($header);

    // @TODO hide deleted sites
    $result = pager_query(db_rewrite_sql($sql), 25, 1, null, $args);
    $form['options'] = array(
      '#type' => 'fieldset',
      '#title' => t('Site tasks'),
      '#prefix' => '<div class="container-inline">',
      '#suffix' => '</div>',
    );
    $options = array();
    foreach (hosting_available_tasks('site') as $task => $array) {

      // At this stage we only want to handle simple tasks, the presense of a
      // specific task form means there are other options for this tasks.
      $func = 'hosting_task_' . $task . '_form';
      if (!function_exists($func) && user_access('create ' . $task . ' task')) {
        $options[$task] = $array['title'];
      }
    }
    $form['options']['task'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => 'backup',
    );
    $form['options']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add to queue'),
      '#submit' => array(
        'hosting_site_list_form_submit',
      ),
    );
    $sites = array();
    while ($node = db_fetch_object($result)) {
      $sites[$node->nid] = '';
      $form['site'][$node->nid] = array(
        '#value' => l($node->title, 'node/' . $node->nid),
      );
      $form['profile'][$node->nid] = array(
        '#value' => $node->profile ? _hosting_node_link($node->profile) : t('n/a'),
      );
      $form['language'][$node->nid] = array(
        '#value' => $node->site_language ? _hosting_language_name($node->site_language) : t('n/a'),
      );
      $form['created'][$node->nid] = array(
        '#value' => t("@interval ago", array(
          '@interval' => format_interval(time() - $node->created, 1),
        )),
      );
      if (sizeof($platforms) > 1) {
        $form['platform'][$node->nid] = array(
          '#value' => $node->platform ? _hosting_node_link($node->platform) : t('n/a'),
        );
      }
      $form['site_class'][$node->nid] = array(
        '#value' => _hosting_site_list_class($node, $node->verified),
      );
    }
    $form['sites'] = array(
      '#type' => 'checkboxes',
      '#options' => $sites,
    );
    $form['pager'] = array(
      '#value' => theme('pager', NULL, 25, 1),
    );
    $form['#theme'] = 'hosting_site_list';
    $form['#action'] = url('hosting/sites');
    return $form;
  }
  elseif ($step == 2) {
    $task = $form_state['values']['task'];
    $tasks = hosting_available_tasks('site');
    $title = array(
      'passed' => t("The following sites will be processed"),
      'failed' => t("The following sites failed validation checks and will not be processed"),
    );
    foreach (array(
      'passed',
      'failed',
    ) as $type) {
      if (sizeof($form_state['storage'][$type])) {
        foreach ($form_state['storage'][$type] as $site_id => $url) {
          $row = array(
            'data' => array(
              array(
                'data' => l($url, 'node/' . $site_id),
                'class' => 'hosting-status',
              ),
            ),
            'class' => $type == 'passed' ? 'hosting-success' : 'hosting-error',
          );
          $rows[] = $row;
        }
      }
    }
    $header = array(
      t('Site'),
    );
    $form['sites_test'] = array(
      '#value' => theme('table', $header, $rows),
    );
    if (sizeof($form_state['storage']['failed']) && sizeof($form_state['storage']['passed'])) {
      drupal_set_message(t('The task @task is not able to be performed on all the sites selected, the sites below that failed will not be added to the queue.', array(
        '@task' => $task,
      )), 'warning');
    }
    elseif (sizeof($form_state['storage']['failed'])) {
      drupal_set_message(t('The task @task is not able to be performed on any of the selected sites.', array(
        '@task' => $task,
      )), 'error');
      $form['return_link'] = array(
        '#value' => l('Return to site listing', 'hosting/sites'),
      );
      return $form;
    }
    $form['help'] = array(
      '#value' => $tasks[$task]['description'],
    );
    $question = t('Are you sure you want to perform the "@task" task on each of the following sites?', array(
      '@task' => $tasks[$task]['title'],
    ));
    return confirm_form($form, $question, 'hosting/sites', '', $tasks[$task]['title']);
  }
}

/**
 * Validate hosting_site_list form submissions.
 */
function hosting_site_list_form_validate($form, &$form_state) {
  if (isset($form_state['values']['sites'])) {
    $sites = array_filter($form_state['values']['sites']);
    if (count($sites) == 0) {
      form_set_error('', t('No sites selected.'));
    }
  }
}

/**
 * Process hosting_site_list form submissions.
 */
function hosting_site_list_form_submit($form, &$form_state) {
  $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] : 1;
  $task = $form_state['values']['task'];
  switch ($step) {
    case 1:
      $form_state['storage']['task'] = $task;

      // Verify tasks can be performed on each site.
      $tasks = hosting_available_tasks('site');

      // Filter out unchecked sites
      $sites = array_filter($form_state['values']['sites']);
      $operations = array();
      foreach ($sites as $site) {
        $operations[] = array(
          'hosting_sites_batch_process',
          array(
            $site,
            $task,
          ),
        );
      }
      if (sizeof($operations)) {
        $batch = array(
          'operations' => $operations,
          'title' => t('Processing'),
          'progress_message' => t('Evaluated @current out of @total sites.'),
          'error_message' => t('The update has encountered an error.'),
        );
        batch_set($batch);
      }
      break;
    case 2:
      $values = $form_state['values'];
      foreach ($form_state['storage']['passed'] as $site_id => $url) {
        hosting_add_task($site_id, $form_state['storage']['task'], $values['parameters']);
      }
      unset($form_state['storage']);
      $step = 0;
      drupal_set_message(t('The task @task will be applied to the selected sites and have been added to the task queue.', array(
        '@task' => $form_state['storage']['task'],
      )));
      break;
  }
  $form_state['storage']['step'] = $step + 1;
}
function hosting_sites_batch_process($site_id, $task, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
  }
  $site = node_load($site_id);
  $batch =& batch_get();
  if (hosting_task_menu_access($site, $task)) {
    $batch['form_state']['storage']['passed'][$site->nid] = $site->title;
  }
  else {
    $batch['form_state']['storage']['failed'][$site->nid] = $site->title;
  }
}

/**
 * Implementation of hook_theme().
 */
function hosting_site_theme() {
  return array(
    'hosting_site_list' => array(
      'arguments' => array(
        'form' => NULL,
      ),
    ),
  );
}

/**
 * Build the site list form.
 */
function theme_hosting_site_list($form) {

  // If there are rows in this form, then $form['site'] contains a list of
  // the title form elements.
  $has_posts = isset($form['site']) && is_array($form['site']);
  $select_header = $has_posts ? theme('table_select_header_cell') : '';
  $header = array(
    $select_header,
    array(
      'data' => t('Site'),
      'field' => 'title',
    ),
    array(
      'data' => t('Profile'),
      'field' => 'profile',
    ),
    array(
      'data' => t('Language'),
      'field' => 'site_language',
    ),
    array(
      'data' => t('Created'),
      'field' => 'created',
      'sort' => 'desc',
    ),
  );
  if (isset($form['platform'])) {
    $header[] = array(
      'data' => t('Platform'),
      'field' => 'platform',
    );
  }
  $output = '';
  $output .= drupal_render($form['options']);
  if ($has_posts) {
    foreach (element_children($form['site']) as $key) {
      $row = array();
      $row[] = drupal_render($form['sites'][$key]);
      $row[] = array(
        'data' => drupal_render($form['site'][$key]),
        'class' => 'hosting-status',
      );
      $row[] = drupal_render($form['profile'][$key]);
      $row[] = drupal_render($form['language'][$key]);
      $row[] = drupal_render($form['created'][$key]);
      if (isset($form['platform'])) {
        $row[] = drupal_render($form['platform'][$key]);
      }
      $rows[] = array(
        'data' => $row,
        'class' => drupal_render($form['site_class'][$key]),
      );
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('No sites available.'),
        'colspan' => sizeof($header),
      ),
    );
  }
  $output .= theme('table', $header, $rows, array(
    'class' => 'hosting-table',
  ));
  if ($form['pager']['#value']) {
    $output .= drupal_render($form['pager']);
  }
  $output .= drupal_render($form);
  return $output;
}

/**
 * Define the classes that correspond to the site status.
 * @see _hosting_site_status()
 */
function _hosting_site_list_class($node, $verified = null) {
  $status = is_numeric($node) ? $node : $node->site_status;
  static $classes = array(
    HOSTING_SITE_QUEUED => "hosting-queue",
    HOSTING_SITE_ENABLED => "hosting-success",
    HOSTING_SITE_DELETED => "hosting-error",
    HOSTING_SITE_DISABLED => "hosting-error",
  );
  if ($status == HOSTING_SITE_ENABLED && !$verified) {
    return 'hosting-warning';
  }
  return $classes[$status];
}

/**
 * Views integration
 */
function hosting_site_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'hosting_site'),
  );
}
function hosting_site_preprocess_views_view_table(&$variables) {
  $view = $variables['view'];
  if ($view->plugin_name == 'hosting_site_list') {
    foreach ($view->result as $num => $result) {
      if (isset($result->hosting_site_status) && isset($result->hosting_site_verified)) {
        $variables['row_classes'][$num][] = _hosting_site_list_class($result->hosting_site_status, $result->hosting_site_verified);
      }
    }
  }
  $variables['class'] .= " hosting-table";
}

Functions

Namesort descending Description
hosting_get_sites_by_status Retrieve sites on a specific platform, with a specific status
hosting_get_site_by_url Retrieve a node based on the url
hosting_import_site Helper function to generate update a site node during import.
hosting_sites Page handler for displaying list of hosted sites on front page
hosting_sites_batch_process
hosting_site_access Implementation of hook_access
hosting_site_allow_domain Implementation of hook_allow_domain().
hosting_site_count Returns a count of sites.
hosting_site_exists Check if a site exists in a somehow wrong way
hosting_site_get_port Retrieve the port the site will be available on, so we can redirect.
hosting_site_goto Menu callback to go to your site.
hosting_site_hosting_tasks Implementation of hook_hosting_tasks
hosting_site_list_form Create a form for building a list of sites. @TODO Add ability to filter by additional fields
hosting_site_list_form_submit Process hosting_site_list form submissions.
hosting_site_list_form_validate Validate hosting_site_list form submissions.
hosting_site_menu Implementation of hook_menu()
hosting_site_node_load Implementation of hook_load().
hosting_site_perm Implementation of hook_perm
hosting_site_preprocess_views_view_table
hosting_site_task_status
hosting_site_theme Implementation of hook_theme().
hosting_site_views_api Views integration
theme_hosting_site_list Build the site list form.
_hosting_site_form_check
_hosting_site_goto_link Generate a link allowing the user to log into their new site, or simply go to the site front page if the link has expired.
_hosting_site_list_class Define the classes that correspond to the site status.
_hosting_site_status Define the status types of a site
_hosting_site_url Get site's URL.

Constants

Namesort descending Description
HOSTING_SITE_DELETED This site is deleted from the backend.
HOSTING_SITE_DISABLED This site is disabled.
HOSTING_SITE_ENABLED This site is created and enabled in the backend.
HOSTING_SITE_QUEUED This site is queued for creation.