You are here

class hostingService_http_pack in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 web_pack/hosting_web_pack.service.inc \hostingService_http_pack
  2. 7.3 web_pack/hosting_web_pack.service.inc \hostingService_http_pack

Hierarchy

Expanded class hierarchy of hostingService_http_pack

File

web_pack/hosting_web_pack.service.inc, line 9

View source
class hostingService_http_pack extends hostingService_http {
  public $type = 'pack';
  public $name = 'Web Pack';
  function view(&$render) {
    $render['master_servers'] = array(
      '#type' => 'item',
      '#title' => t('Master web servers'),
      '#markup' => theme('item_list', array(
        'items' => array_map('_hosting_node_link', array_intersect_key($this->master_servers, hosting_get_servers('http'))),
      )),
    );
    $render['slave_servers'] = array(
      '#type' => 'item',
      '#title' => t('Slave web servers'),
      '#markup' => theme('item_list', array(
        'items' => array_map('_hosting_node_link', array_intersect_key($this->slave_servers, hosting_get_servers('http'))),
      )),
    );
  }
  function form(&$form) {
    parent::form($form);
    $servers = hosting_get_servers('http');
    if (isset($this->server->nid)) {
      unset($servers[$this->server->nid]);
    }
    $form['master_servers'] = array(
      '#title' => t('Master servers'),
      '#type' => 'checkboxes',
      '#options' => $servers,
      '#default_value' => isset($this->master_servers) ? $this->master_servers : array(),
    );
    $form['slave_servers'] = array(
      '#title' => t('Slave servers'),
      '#type' => 'checkboxes',
      '#options' => $servers,
      '#default_value' => isset($this->slave_servers) ? $this->slave_servers : array(),
    );
  }
  function load() {
    parent::load();
    $ssl_enabled = TRUE;
    $master_servers = array();
    $slave_servers = array();
    $result = db_query('SELECT web_server_nid, type FROM {hosting_web_pack} WHERE vid = :vid', array(
      ':vid' => $this->server->vid,
    ));
    while ($web_server = $result
      ->fetch()) {
      if ($web_server->type == 'master') {
        $master_servers[] = $web_server->web_server_nid;
      }
      else {
        $slave_servers[] = $web_server->web_server_nid;
      }
      $server = node_load($web_server->web_server_nid);
      $ssl_enabled = $ssl_enabled && $server->services['http']->ssl_enabled;
    }
    $this->ssl_enabled = $ssl_enabled;
    $this
      ->setValues(array(
      'master_servers' => drupal_map_assoc($master_servers),
    ));
    $this
      ->setValues(array(
      'slave_servers' => drupal_map_assoc($slave_servers),
    ));
  }
  function insert() {
    parent::insert();
    foreach (array_filter($this->master_servers) as $web_server) {
      $record = array(
        'nid' => $this->server->nid,
        'vid' => $this->server->vid,
        'web_server_nid' => $web_server,
        'type' => 'master',
      );
      drupal_write_record('hosting_web_pack', $record);
    }
    foreach (array_filter($this->slave_servers) as $web_server) {
      $record = array(
        'nid' => $this->server->nid,
        'vid' => $this->server->vid,
        'web_server_nid' => $web_server,
        'type' => 'slave',
      );
      drupal_write_record('hosting_web_pack', $record);
    }
  }
  function delete() {
    parent::delete();
    db_delete('hosting_web_pack')
      ->condition('nid', $this->server->nid)
      ->execute();
  }
  function delete_revision() {
    parent::delete_revision();
    db_delete('hosting_web_pack')
      ->condition('vid', $this->server->vid)
      ->execute();
  }
  function context_options($task_type, $ref_type, &$task) {
    parent::context_options($task_type, $ref_type, $task);
    $task->context_options['master_web_servers'] = implode(',', array_values(array_map('hosting_context_name', array_intersect_key($this->master_servers, hosting_get_servers('http')))));
    $task->context_options['slave_web_servers'] = implode(',', array_values(array_map('hosting_context_name', array_intersect_key($this->slave_servers, hosting_get_servers('http')))));
  }
  function context_import($context) {
    $master_servers = $slave_server = array();
    foreach ($context->master_web_servers as $master_server_context) {
      $nid = hosting_context_nid($master_server_context);
      $master_servers[$nid] = $nid;
    }
    $this->master_servers = $master_servers;
    foreach ($context->slave_web_servers as $slave_server_context) {
      $nid = hosting_context_nid($slave_server_context);
      $slave_servers[$nid] = $nid;
    }
    $this->slave_servers = $slave_servers;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
hostingService::$available public property
hostingService::$has_port protected property 3
hostingService::$has_restart_cmd protected property 5
hostingService::$server public property
hostingService::$server_node public property
hostingService::default_port public function 3
hostingService::default_restart_cmd public function 5
hostingService::getName public function Returns human readable name for this service.
hostingService::has_port public function 3
hostingService::mergeData protected function
hostingService::provisionProperties function Return service properties to Provision CLI. 2
hostingService::save public function
hostingService::setValues public function
hostingService::update public function 3
hostingService::validate public function 2
hostingService::__construct function
hostingService_http::$service public property Overrides hostingService::$service
hostingService_http::$ssl_enabled public property
hostingService_http_pack::$name public property Overrides hostingService::$name
hostingService_http_pack::$type public property Overrides hostingService::$type
hostingService_http_pack::context_import function Overrides hostingService::context_import
hostingService_http_pack::context_options function Overrides hostingService::context_options
hostingService_http_pack::delete function Overrides hostingService::delete
hostingService_http_pack::delete_revision function Overrides hostingService::delete_revision
hostingService_http_pack::form function Overrides hostingService::form
hostingService_http_pack::insert function Overrides hostingService::insert
hostingService_http_pack::load function Overrides hostingService::load
hostingService_http_pack::view function Overrides hostingService::view