Documentation is available at host.php
- <?php
- class midgard_admin_sitewizard_host {
- var $_host;
- var $_empty_style;
- var $_attachment_page;
- var $_sitegroup;
- var $name;
- var $port;
- var $prefix;
- var $root;
- var $owner;
- var $style;
- function midgard_admin_sitewizard_host($id = false, $sitegroup = 0) {
- if ($id) {
- $this->_host = mgd_get_host($id);
- } else {
- $this->_host = false;
- }
- $this->_empty_style = mgd_get_object_by_guid("3c92dd79d80e88fce424a324e1096580");
- $this->_attachment_page = mgd_get_object_by_guid('a93523b8d13b1190fc562ffdabe08f44');
- if ($sitegroup) {
- $this->_sitegroup = mgd_get_sitegroup($sitegroup);
- $this->owner = $sitegroup->admingroup;
- } else {
- $this->_sitegroup = 0;
- $this->owner = 0;
- }
- $this->name = "";
- $this->port = 0;
- $this->prefix = "";
- $this->root = null;
- $this->style = $this->_empty_style->id;
- }
- function create() {
- $this->_get_template_settings();
- $host = mgd_get_host();
- $host->name = $this->name;
- $host->port = $this->port;
- $host->prefix = $this->prefix;
- $host->owner = $this->owner;
- $host->style = $this->style;
- $host->root = $this->root;
- $host->online = true;
- $host->auth = false;
- if ($this->_check_against_overlap()) {
- $host_created = $host->create();
- if ($host_created) {
- $host = mgd_get_host($host_created);
- if ($this->_sitegroup != $_MIDGARD["sitegroup"]) {
- $host->setsitegroup($this->_sitegroup->id);
- }
- $this->_create_attachment_host();
- return $host->id;
- }
- } else {
- return false;
- }
- }
- function _get_template_settings() {
- // Check for settings in the root page
- $root_page = mgd_get_page($this->root);
- // Allow application to define style
- // Needed for applications like OpenPSA
- $custom_style = $root_page->parameter("midgard.admin.sitewizard","custom_style");
- if ($custom_style) {
- $style = mgd_get_object_by_guid($custom_style);
- $this->style = $style->id;
- }
- }
- function _check_against_overlap() {
- $wizard_host = mgd_get_host($_MIDGARD["host"]);
- if ($this->name == $wizard_host->name && $this->prefix == $wizard_host->prefix) {
- return false;
- }
- // TODO: check for overlap with other Midgard hosts
- return true;
- }
- function _attachment_host_found() {
- // Check if attachment host exists
- $attachment_host_found = false;
- $hosts = mgd_list_hosts();
- if ($hosts) {
- while ($hosts->fetch()) {
- if ($hosts->name == $this->name && $hosts->prefix == "/attachment/".$this->_sitegroup->guid() && ($hosts->port == $this->port || $hosts->port == 0)) {
- return true;
- }
- }
- }
- return false;
- }
- function _create_attachment_host() {
- if (!$this->_attachment_host_found()) {
- // Create Aegir-style attachment host
- // TODO: we will eventually be able to switch to Midgard's built-in attachment server
- $attachment_host = mgd_get_host();
- $attachment_host->name = $this->name;
- $attachment_host->port = $this->port;
- $attachment_host->prefix = "/attachment/".$this->_sitegroup->guid();
- $attachment_host->owner = $this->owner;
- $attachment_host->root = $this->_attachment_page->id;
- $attachment_host->style = $this->_empty_style->id;
- $attachment_host->online = true;
- $attachment_host->auth = false;
- $attachment_host_created = $attachment_host->create();
- if ($attachment_host_created) {
- $attachment_host = mgd_get_host($attachment_host_created);
- if ($this->_sitegroup != $_MIDGARD["sitegroup"]) {
- $attachment_host->setsitegroup($this->_sitegroup->id);
- }
- return $attachment_host->id;
- }
- }
- return false;
- }
- }
- ?>
Documentation generated on Mon, 21 Nov 2005 18:16:10 +0100 by phpDocumentor 1.3.0RC3