Exemplo n.º 1
0
 public static function GetByAssoc($values)
 {
     $item = new TenantEnumeration();
     $item->ID = $values["enum_ID"];
     $item->Tenant = Tenant::GetByID($values["enum_TenantID"]);
     $item->Module = Module::GetByID($values["enum_ModuleID"]);
     $item->Name = $values["enum_Name"];
     $item->Description = $values["enum_Description"];
     return $item;
 }
Exemplo n.º 2
0
 /**
  * Creates a new TenantObject object based on the given values from the database.
  * @param array $values
  * @return \PhoenixSNS\Objects\TenantObject based on the values of the fields in the given associative array
  */
 public static function GetByAssoc($values)
 {
     $item = new TenantObject();
     $item->ID = $values["object_ID"];
     $item->Tenant = Tenant::GetByID($values["object_TenantID"]);
     $item->Module = Module::GetByID($values["object_ModuleID"]);
     $item->ParentObject = TenantObject::GetByID($values["object_ParentObjectID"]);
     $item->DefaultProperty = TenantObjectProperty::GetByID($values["object_DefaultPropertyID"]);
     $item->Name = $values["object_Name"];
     return $item;
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->StyleSheets[] = new WebStyleSheet("~/StyleSheets/Main.css");
     $this->StyleSheets[] = new WebStyleSheet("http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Professional/Main.css");
     $tenants = Tenant::Get();
     $tenantsNavigationButtons = array();
     foreach ($tenants as $tenant) {
         $tenantsNavigationButtons[] = new NavigationButton("~/tenant/modify/" . $tenant->URL, $tenant->URL, null, null, null);
     }
     $this->HeaderButtons = array();
     $this->SidebarButtons = array(new NavigationSeparator("Quick Start"), new NavigationButton("~/", "Dashboard", "dashboard"), new NavigationSeparator("Management"), new NavigationButton("~/tenant", "Tenants", "th-list", null, null, count($tenants), $tenantsNavigationButtons), new NavigationButton("~/modules", "Modules", "puzzle-piece", null, null, Module::Count()), new NavigationButton("~/data-centers", "Data Centers", "building-o", null, null, DataCenter::Count()), new NavigationButton("~/payment-plans", "Payment Plans", "money", null, null, PaymentPlan::Count()), new NavigationButton("~/organizations", "Organizations", "suitcase", null, null, Organization::Count()), new NavigationButton("~/users", "Users", "users", null, null, User::Count()), new NavigationButton("~/data-types", "Data Types", "sitemap", null, null, DataType::Count()), new NavigationButton("~/tenant-types", "Tenant Types", "tenant-types", null, null, TenantType::Count()), new NavigationSeparator("Help and Support"), new NavigationButton("~/support/documentation", "Documentation", "book"), new NavigationButton("~/support/bugspray", "Report a Bug", "bug"), new NavigationButton("~/system-log", "System Log", "file-text-o"));
     $this->RenderHeader = true;
     $this->RenderSidebar = true;
 }
Exemplo n.º 4
0
    protected function RenderContent()
    {
        $modules = Module::Get();
        ?>
		<p>There are <?php 
        echo count($modules);
        ?>
 modules in total.  Click a module name to configure that module.</p>
		<?php 
        $lv = new ListView();
        $lv->Columns = array(new ListViewColumn("chTitle", "Module"), new ListViewColumn("chDescription", "Description"));
        foreach ($modules as $module) {
            $lv->Items[] = new ListViewItem(array(new ListViewItemColumn("chTitle", "<a href=\"" . System::ExpandRelativePath("~/modules/modify/" . $module->ID) . "\">" . $module->Title . "</a>"), new ListViewItemColumn("chDescription", $module->Description)));
        }
        $lv->Render();
    }
Exemplo n.º 5
0
 /**
  * Gets the JSON representation of this object for use in AJAX calls.
  * @return string The JSON representation of this object.
  */
 public function ToJSON()
 {
     $json = "";
     $json .= "{";
     $json .= "\"ID\":" . $this->ID . ",";
     if ($this->Module == null) {
         $json .= "\"Module\":null,";
     } else {
         $json .= "\"Module\":" . $this->Module->ToJSON() . ",";
     }
     if ($this->ParentPage == null) {
         $json .= "\"ParentPage\":null,";
     } else {
         $json .= "\"ParentPage\":" . $this->ParentPage->ToJSON() . ",";
     }
     $json .= "\"URL\":\"" . \JH\Utilities::JavaScriptDecode($this->URL, "\"") . "\",";
     $json .= "\"Content\":\"" . \JH\Utilities::JavaScriptDecode($this->Content, "\"") . "\"";
     $json .= "}";
     return $json;
 }
    protected function RenderContent()
    {
        if ($this->Module != null) {
            ?>
			<h1>Module: <?php 
            echo $this->Module->Title;
            ?>
 on <?php 
            echo $this->Tenant->URL;
            ?>
</h1>
			<h2>Module Configurable Properties</h2>
			<table style="width: 100%;">
				<tr id="Property_Header">
					<th style="width: 32px;"><a href="#" onclick="AddPropertyBelow('Header');" title="Add Below">[+]</a></th>
					<th style="width: 256px;">Property</th>
					<th>Value</th>
				</tr>
				<?php 
            /*
            	$properties = $this->Module->GetProperties();
            	foreach ($properties as $property)
            	{
            		?>
            		<tr id="Property_<?php echo($property->ID); ?>">
            			<td style="width: 32px;"><a href="#" onclick="AddPropertyBelow('<?php echo($property->ID); ?>');" title="Add Below">[+]</a></td>
            			<td><?php echo($property->Title); ?></td>
            			<td><input style="width: 100%;" type="text" id="txtProperty_<?php echo($property->ID); ?>" name="Property_<?php echo($property->ID); ?>" value="<?php echo($this->Tenant->GetPropertyValue($property)); ?>" /></td>
            		</tr>
            		<?php
            	}
            */
            ?>
			</table>
			<?php 
        } else {
            ?>
				<h1>Tenant: <?php 
            echo $this->Tenant->URL;
            ?>
</h1>
				<?php 
        }
        ?>
			<h2>Tenant Enabled Modules</h2>
			<p>Click on a module name to configure it</p>
			<table style="width: 100%;">
				<tr>
					<th style="width: 128px;">Module</th>
					<th>Description</th>
				</tr>
				<?php 
        $modules = Module::Get(null, $this->Tenant);
        foreach ($modules as $module) {
            ?>
						<tr>
							<td><input id="chkModule_<?php 
            echo $module->ID;
            ?>
" type="checkbox"<?php 
            if ($module->Enabled) {
                echo " checked=\"checked\"";
            }
            ?>
 /> <a href="<?php 
            echo System::ExpandRelativePath("~/tenant/modify/" . $this->Tenant->URL . "/modules/" . $module->ID);
            ?>
"><?php 
            echo $module->Title;
            ?>
</a></td>
							<td><?php 
            echo $module->Description;
            ?>
</td>
						</tr>
						<?php 
        }
        ?>
			</table>
			<?php 
    }
    protected function RenderContent()
    {
        ?>
			<form method="POST" onsubmit="return form_OnSubmit();">
				<?php 
        $tbs = new TabContainer("tbsTabs");
        $tbs->TabPages[] = new TabPage("tabGeneralInformation", "General Information", null, null, null, function () {
            $fv = new FormView();
            $fv->Items[] = new FormViewItemText("txtTenantURL", "tenant_URL", "Name", $this->Tenant->URL);
            $fvTenantTypes = array();
            $tenanttypes = TenantType::Get();
            foreach ($tenanttypes as $tenanttype) {
                $fvTenantType = new FormViewItemChoiceValue($tenanttype->Title, $tenanttype->ID);
                $fvTenantType->Selected = $this->Tenant != null && $this->Tenant->Type != null && $tenanttype->ID == $this->Tenant->Type->ID;
                $fvTenantTypes[] = $fvTenantType;
            }
            $fv->Items[] = new FormViewItemChoice("cboTenantType", "tenant_TypeID", "Type", null, $fvTenantTypes);
            $fv->Items[] = new FormViewItemBoolean("chkStatus", "tenant_Status", "Status", $this->Tenant->Status == TenantStatus::Enabled);
            $fvDataCenters = array();
            $datacenters = DataCenter::Get();
            foreach ($datacenters as $datacenter) {
                $fvDataCenter = new FormViewItemChoiceValue($datacenter->Title, $datacenter->ID);
                $fvDataCenter->Selected = $this->Tenant != null && $this->Tenant->DataCenters->Contains($datacenter);
                $fvDataCenters[] = $fvDataCenter;
            }
            $fv->Items[] = new FormViewItemChoice("cboDataCenter", "tenant_DataCenterIDs", "Data centers", null, $fvDataCenters, true);
            $fvPaymentPlans = array();
            $paymentplans = PaymentPlan::Get();
            foreach ($paymentplans as $paymentplan) {
                $fvPaymentPlan = new FormViewItemChoiceValue($paymentplan->Title, $paymentplan->ID);
                $fvPaymentPlan->Selected = $this->Tenant != null && $this->Tenant->PaymentPlan != null && $paymentplan->ID == $this->Tenant->PaymentPlan->ID;
                $fvPaymentPlans[] = $fvPaymentPlan;
            }
            $fv->Items[] = new FormViewItemChoice("cboPaymentPlan", "tenant_PaymentPlanID", "Payment plan", null, $fvPaymentPlans);
            $fv->Items[] = new FormViewItemDateTime("txtActivationDate", "tenant_BeginTimestamp", "Activation date", $this->Tenant != null ? $this->Tenant->BeginTimestamp : null, true);
            $fv->Items[] = new FormViewItemDateTime("txtTerminationDate", "tenant_EndTimestamp", "Termination date", $this->Tenant != null ? $this->Tenant->EndTimestamp : null, true);
            $fv->Items[] = new FormViewItemMemo("txtDescription", "tenant_Description", "Description", $this->Tenant->Description);
            $fv->Render();
        });
        $path = System::GetVirtualPath();
        if ($path[1] != "clone") {
            $tbs->TabPages[] = new TabPage("tabCustomProperties", "Custom Properties", null, null, null, function () {
                $lv = new ListView();
                $lv->Width = "100%";
                $lv->EnableAddRemoveRows = true;
                $lv->Columns = array(new ListViewColumn("lvcProperty", "Property"), new ListViewColumn("lvcDescription", "Description"), new ListViewColumn("lvcValue", "Value"));
                $properties = $this->Tenant->GetProperties();
                foreach ($properties as $property) {
                    $lv->Items[] = new ListViewItem(array(new ListViewItemColumn("lvcProperty", $property->Name), new ListViewItemColumn("lvcDescription", $property->Description), new ListViewItemColumn("lvcValue", null, null, function ($property) {
                        $property->DataType->RenderEditor($this->Tenant->GetPropertyValue($property), "Property_" . $property->ID);
                    }, $property)));
                }
                $lv->Render();
            });
            $tbs->TabPages[] = new TabPage("tabEnabledModules", "Enabled Modules", null, null, null, function () {
                $lv = new ListView();
                $lv->Width = "100%";
                $lv->EnableRowCheckBoxes = true;
                $lv->Columns = array(new ListViewColumn("lvcModule", "Module"), new ListViewColumn("lvcDescription", "Description"));
                $modules = Module::Get(null);
                foreach ($modules as $module) {
                    $item = new ListViewItem(array(new ListViewItemColumn("lvcModule", "<a href=\"" . System::ExpandRelativePath("~/tenant/modify/" . $this->Tenant->URL . "/modules/" . $module->ID . "\">" . $module->Title . "</a>", $module->Title)), new ListViewItemColumn("lvcDescription", $module->Description)));
                    $item->Checked = $this->Tenant->HasModule($module);
                    $lv->Items[] = $item;
                }
                $lv->Render();
            });
            $tbs->TabPages[] = new TabPage("tabGlobalObjects", "Global Objects", null, null, null, function () {
                $lv = new ListView();
                $lv->Width = "100%";
                $lv->EnableAddRemoveRows = true;
                $lv->Columns = array(new ListViewColumn("lvcObject", "Object"), new ListViewColumn("lvcDescription", "Description"), new ListViewColumn("lvcInstances", "Instances"));
                $objects = TenantObject::Get(null, $this->Tenant);
                foreach ($objects as $object) {
                    $lv->Items[] = new ListViewItem(array(new ListViewItemColumn("lvcObject", $object->Name), new ListViewItemColumn("lvcDescription", $object->Description), new ListViewItemColumn("lvcInstances", "<a href=\"" . System::ExpandRelativePath("~/tenant/modify/" . $this->Tenant->URL . "/objects/" . $object->ID . "/instances") . "\">" . $object->CountInstances() . "</a>")));
                }
                $lv->Render();
            });
        }
        $tbs->SelectedTab = $tbs->TabPages[0];
        $tbs->Render();
        ?>
				<div class="Buttons">
					<input class="Button Default" type="submit" value="Save Changes" />
					<a class="Button" onclick="return nav('/tenant');" href="<?php 
        echo System::ExpandRelativePath("~/tenant");
        ?>
">Cancel</a>
				</div>
			</form>
			<script type="text/javascript">
			var TenantManagementPageMode =
			{
				"Create": 1,
				"Modify": 2
			}
			<?php 
        if ($this->Mode == TenantManagementPageMode::Create) {
            echo "var Mode = TenantManagementPageMode.Create;";
        } else {
            if ($this->Mode == TenantManagementPageMode::Modify) {
                echo "var Mode = TenantManagementPageMode.Modify;";
            }
        }
        ?>
			function form_OnSubmit()
			{
				if (Mode == TenantManagementPageMode.Create)
				{
					var xhr = new XMLHttpRequest();
					var tenantName = document.getElementById('txtTenantURL').value;
					
					xhr.open("GET", "/API/Tenant.php?action=exists&q=" + tenantName, false);
					xhr.send(null);
					
					var obj = JSON.parse(xhr.responseText);
					if (obj.result == "success" && obj.exists)
					{
						Notification.Show("Tenant '" + tenantName + "' already exists", "Please specify a unique tenant name", "Error");
						return false;
					}
				}
				
				Notification.Show("Changes were saved successfully", "Taking you back to the Tenant Management page", "Success");
				return true;
			}
			</script>
			<?php 
    }
Exemplo n.º 8
0
 /**
  * Retrieves a single Module with the given ID.
  * @param int $id The ID of the Module to return
  * @param boolean $forAllTenants True if the Module should be a global module; false if it should be a tenant-specific module
  * @return NULL|\Module The Module with the given ID, or NULL if no Module with the given ID was found
  */
 public static function GetByID($id, $forAllTenants = false)
 {
     if (!is_numeric($id)) {
         return null;
     }
     global $MySQL;
     $query = "SELECT module_ID, module_Title, module_Description FROM " . System::$Configuration["Database.TablePrefix"] . "Modules WHERE module_ID = " . $id;
     if (!$forAllTenants) {
         $query = "SELECT module_ID, module_Title, module_Description FROM " . System::$Configuration["Database.TablePrefix"] . "Modules, " . System::$Configuration["Database.TablePrefix"] . "TenantModules WHERE tenantmodule_ModuleID = module_ID AND tenantmodule_TenantID = " . $CurrentTenant->ID . " AND module_ID = " . $id;
     }
     $result = $MySQL->query($query);
     $count = $result->num_rows;
     if ($count == 0) {
         return null;
     }
     $values = $result->fetch_assoc();
     return Module::GetByAssoc($values);
 }
Exemplo n.º 9
0
             System::Redirect("~/tenant");
         }
         return true;
     } else {
         $page = new TenantManagementPage();
         $page->Mode = TenantManagementPageMode::Modify;
         $page->Tenant = $tenant;
         $page->Render();
         return true;
     }
 } else {
     switch ($path[1]) {
         case "modules":
             $page = new TenantModuleManagementPage();
             $page->Tenant = Tenant::GetByURL($path[0]);
             $page->Module = \PhoenixSNS\Objects\Module::GetByID($path[2]);
             $page->Render();
             break;
         case "objects":
             if ($path[2] == "") {
                 // $page = new TenantObjectBrowsePage();
                 // $page->CurrentTenant = Tenant::GetByURL($path[0]);
                 // $page->Render();
             } else {
                 switch ($path[3]) {
                     case "instances":
                         switch ($path[4]) {
                             case "":
                                 $tenant = Tenant::GetByURL($path[0]);
                                 $object = TenantObject::GetByID($path[2]);
                                 $page = new TenantObjectInstanceBrowsePage();