<?php // We need to get the root path of the Web site. It's usually something like // /var/www/yourdomain.com. global $RootPath; $RootPath = dirname(__FILE__) . "/.."; // Now that we have defined the root path, load the WebFX content (which also // include_once's the modules and other WebFX-specific stuff) require_once "WebFX/WebFX.inc.php"; // Bring in the WebFX\System and WebFX\IncludeFile classes so we can simply refer // to them (in this file only) as "System" and "IncludeFile", respectively, from // now on use WebFX\System; use WebFX\IncludeFile; use PhoenixSNS\Objects\Tenant; if ($_GET["action"] == "exists") { $query = $_GET["q"]; if (Tenant::Exists($query)) { echo "{ \"result\": \"success\", \"exists\": true }"; return; } echo "{ \"result\": \"success\", \"exists\": false }"; }
$tenant_URL = $_POST["tenant_URL"]; $tenant_Description = $_POST["tenant_Description"]; $tenant_Status = isset($_POST["tenant_Status"]) ? TenantStatus::Enabled : TenantStatus::Disabled; $tenant_Type = TenantType::GetByID($_POST["tenant_TypeID"]); $tenant_PaymentPlan = PaymentPlan::GetByID($_POST["tenant_PaymentPlanID"]); if (isset($_POST["tenant_BeginTimestampValid"])) { $tenant_BeginTimestamp = $_POST["tenant_BeginTimestampValid"] == "on" ? null : $_POST["tenant_BeginTimestamp"]; } else { $tenant_BeginTimestamp = $_POST["tenant_BeginTimestamp"]; } if (isset($_POST["tenant_EndTimestampValid"])) { $tenant_EndTimestamp = $_POST["tenant_EndTimestampValid"] == "on" ? null : $_POST["tenant_EndTimestamp"]; } else { $tenant_EndTimestamp = $_POST["tenant_EndTimestamp"]; } if (Tenant::Exists($tenant_URL)) { $page = new ErrorPage(); $page->Message = "The tenant '" . $tenant_URL . "' already exists."; $page->ReturnButtonURL = "~/tenant"; $page->RenderHeader = true; $page->RenderSidebar = true; $page->Render(); return true; } $retval = Tenant::Create($tenant_URL, $tenant_Description, $tenant_Status, $tenant_Type, $tenant_PaymentPlan, $tenant_BeginTimestamp, $tenant_EndTimestamp); if ($retval == null) { global $MySQL; echo $MySQL->error . " (" . $MySQL->errno . ")"; } else { $sourceTenant->CopyTo($retval); System::Redirect("~/tenant");