diff --git a/PHP/.gitignore b/PHP/.gitignore
new file mode 100644
index 00000000..6a3db272
--- /dev/null
+++ b/PHP/.gitignore
@@ -0,0 +1,21 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
+#
+# disallow local configuration files and backup files
+Tenant/Include/Configuration.*
+Manager/Include/Configuration.*
+# but include the configuration template files
+!Tenant/Include/Configuration.inc.php.template
+!Manager/Include/Configuration.inc.php.template
+# disallow all resource bundles (which could contain proprietary content)
+Tenant/Resources/*
+# but allow common resource files that ship with ObjectFX
+!Tenant/Resources/Common
+# as well as a readme file that describes how to use resource bundles
+!Tenant/Resources/Readme.txt
+# and don't pull in sandbox stuff (which is really only for testing locally)
+Sandbox/*
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/000-Objectify.inc.php b/PHP/Common/Include/Objects/000-Objectify.inc.php
new file mode 100644
index 00000000..3c1efd09
--- /dev/null
+++ b/PHP/Common/Include/Objects/000-Objectify.inc.php
@@ -0,0 +1,51 @@
+ID) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($message) . "', ";
+ $query .= $severity . ", ";
+ $query .= "NOW(), ";
+ $query .= "'" . $MySQL->real_escape_string($_SERVER["REMOTE_ADDR"]) . "'";
+ $query .= ")";
+ $MySQL->query($query);
+
+ $msgid = $MySQL->insert_id;
+
+ foreach ($bt as $bti)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DebugMessageBacktraces (bt_MessageID, bt_FileName, bt_LineNumber) VALUES (";
+ $query .= $msgid . ", ";
+ $query .= "'" . $MySQL->real_escape_string($bti["file"]) . "', ";
+ $query .= $bti["line"];
+ $query .= ")";
+ $MySQL->query($query);
+ }
+
+ foreach ($params as $key => $value)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DebugMessageParameters (mp_MessageID, mp_Name, mp_Value) VALUES (";
+ $query .= $msgid . ", ";
+ $query .= "'" . $MySQL->real_escape_string($key) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($value) . "'";
+ $query .= ")";
+ $MySQL->query($query);
+ }
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/DataCenter.inc.php b/PHP/Common/Include/Objects/DataCenter.inc.php
new file mode 100644
index 00000000..aee27388
--- /dev/null
+++ b/PHP/Common/Include/Objects/DataCenter.inc.php
@@ -0,0 +1,140 @@
+Items = array();
+ }
+
+ public function Add($item)
+ {
+ $this->Items[] = $item;
+ }
+ public function Contains($item)
+ {
+ foreach ($this->Items as $itm)
+ {
+ if ($itm->ID == $item->ID) return true;
+ }
+ return false;
+ }
+ public function Get($item)
+ {
+ foreach ($this->Items as $itm)
+ {
+ if ($itm->ID == $item->ID) return $item;
+ }
+ return null;
+ }
+ }
+ class DataCenter
+ {
+ public $ID;
+ public $Title;
+ public $Description;
+ public $HostName;
+
+ public static function Create($title, $hostname, $description = null)
+ {
+ $item = new DataCenter();
+ $item->Title = $title;
+ $item->HostName = $hostname;
+ $item->Description = $description;
+ if ($item->Update())
+ {
+ return $item;
+ }
+ return null;
+ }
+
+ public static function GetByAssoc($values)
+ {
+ $item = new DataCenter();
+ $item->ID = $values["datacenter_ID"];
+ $item->Title = $values["datacenter_Title"];
+ $item->Description = $values["datacenter_Description"];
+ $item->HostName = $values["datacenter_HostName"];
+ return $item;
+ }
+ public static function Get($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DataCenters";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = DataCenter::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DataCenters WHERE datacenter_ID = " . $id;
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return DataCenter::GetByAssoc($values);
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+ if ($this->ID != null)
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "DataCenters SET ";
+ $query .= "datacenter_Title = '" . $MySQL->real_escape_string($this->Title) . "', ";
+ $query .= "datacenter_Description = '" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "datacenter_HostName = '" . $MySQL->real_escape_string($this->HostName) . "'";
+ $query .= " WHERE datacenter_ID = " . $this->ID;
+ }
+ else
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DataCenters (datacenter_Title, datacenter_Description, datacenter_HostName) VALUES (";
+ $query .= "'" . $MySQL->real_escape_string($this->Title) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->HostName) . "'";
+ $query .= ")";
+ }
+ $result = $MySQL->query($query);
+ if ($this->ID == null)
+ {
+ $this->ID = $MySQL->insert_id;
+ }
+ return ($MySQL->errno == 0);
+ }
+
+ public function Delete()
+ {
+ global $MySQL;
+ if ($this->ID == null) return false;
+
+ $query = "DELETE FROM " . System::$Configuration["Database.TablePrefix"] . "DataCenters WHERE datacenter_ID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($MySQL->errno != 0) return false;
+
+ return true;
+ }
+
+ public function ToJSON()
+ {
+ echo("{");
+ echo("\"ID\":" . $this->ID . ",");
+ echo("\"Title\":\"" . \JH\Utilities::JavaScriptEncode($this->Title, "\"") . "\",");
+ echo("\"Description\":\"" . \JH\Utilities::JavaScriptEncode($this->Description, "\"") . "\",");
+ echo("\"HostName\":\"" . \JH\Utilities::JavaScriptEncode($this->HostName, "\"") . "\"");
+ echo("}");
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/DataType.inc.php b/PHP/Common/Include/Objects/DataType.inc.php
new file mode 100644
index 00000000..f8f35e8c
--- /dev/null
+++ b/PHP/Common/Include/Objects/DataType.inc.php
@@ -0,0 +1,191 @@
+ID = $values["datatype_ID"];
+ $item->Name = $values["datatype_Name"];
+ $item->Description = $values["datatype_Description"];
+
+ $item->EncoderCodeBlob = $values["datatype_EncoderCodeBlob"];
+ $item->DecoderCodeBlob = $values["datatype_DecoderCodeBlob"];
+ $item->ColumnRendererCodeBlob = $values["datatype_ColumnRendererCodeBlob"];
+ $item->EditorRendererCodeBlob = $values["datatype_EditorRendererCodeBlob"];
+ return $item;
+ }
+
+ public static function Get($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DataTypes";
+ if (is_numeric($max))
+ {
+ $query .= " LIMIT " . $max;
+ }
+ $result = $MySQL->query($query);
+ $retval = array();
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = DataType::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DataTypes WHERE datatype_ID = " . $id;
+
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return DataType::GetByAssoc($values);
+ }
+
+ public static function GetByName($name)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DataTypes WHERE datatype_Name = '" . $MySQL->real_escape_string($name) . "'";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0)
+ {
+ Objectify::Log("No data type with the specified name was found.", array
+ (
+ "DataType" => $name
+ ));
+ return null;
+ }
+
+ $values = $result->fetch_assoc();
+ return DataType::GetByAssoc($values);
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+ if ($this->ID == null)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DataTypes (datatype_Name, datatype_Description, datatype_EncoderCodeBlob, datatype_DecoderCodeBlob, datatype_ColumnRendererCodeBlob, datatype_EditorRendererCodeBlob) VALUES (";
+ $query .= "'" . $MySQL->real_escape_string($this->Name) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= ($this->EncoderCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->EncoderCodeBlob) . "'") : "NULL") . ", ";
+ $query .= ($this->DecoderCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->DecoderCodeBlob) . "'") : "NULL") . ", ";
+ $query .= ($this->ColumnRendererCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->ColumnRendererCodeBlob) . "'") : "NULL") . ", ";
+ $query .= ($this->EditorRendererCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->EditorRendererCodeBlob) . "'") : "NULL");
+ $query .= ")";
+ }
+ else
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "DataTypes SET ";
+ $query .= "datatype_Name = '" . $MySQL->real_escape_string($this->Name) . "', ";
+ $query .= "datatype_Description = '" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "datatype_EncoderCodeBlob = '" . ($this->EncoderCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->EncoderCodeBlob) . "'") : "NULL") . "', ";
+ $query .= "datatype_DecoderCodeBlob = '" . ($this->DecoderCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->DecoderCodeBlob) . "'") : "NULL") . "', ";
+ $query .= "datatype_ColumnRendererCodeBlob = '" . ($this->ColumnRendererCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->ColumnRendererCodeBlob) . "'") : "NULL") . "', ";
+ $query .= "datatype_EditorRendererCodeBlob = '" . ($this->EditorRendererCodeBlob != null ? ("'" . $MySQL->real_escape_string($this->EditorRendererCodeBlob) . "'") : "NULL") . "'";
+ $query .= " WHERE datatype_ID = " . $this->ID;
+ }
+
+ $MySQL->query($query);
+ if ($MySQL->errno != 0)
+ {
+ echo($MySQL->error);
+ die();
+ return false;
+ }
+
+ if ($this->ID == null)
+ {
+ $this->ID = $MySQL->insert_id;
+ }
+ return true;
+ }
+
+ public function Encode($value)
+ {
+ if ($this->EncoderCodeBlob == null) return $value;
+ $q = '';
+ $q .= 'use Objectify\Objects\MultipleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\SingleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\TenantObject; ';
+ $q .= 'use Objectify\Objects\TenantObjectInstance; ';
+ $q .= '$x = function($input) { ' . $this->EncoderCodeBlob . ' };';
+ // trigger_error("calling EncoderCodeBlob on DataType '" . $this->Name . "'", E_USER_NOTICE);
+ eval($q);
+ return $x($value);
+ }
+ public function Decode($value)
+ {
+ if ($this->DecoderCodeBlob == null) return $value;
+ $q = '';
+ $q .= 'use Objectify\Objects\MultipleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\SingleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\TenantObject; ';
+ $q .= 'use Objectify\Objects\TenantObjectInstance; ';
+ $q .= '$x = function($input) { ' . $this->DecoderCodeBlob . ' };';
+ // trigger_error("calling DecoderCodeBlob on DataType '" . $this->Name . "'", E_USER_NOTICE);
+ eval($q);
+ return $x($value);
+ }
+
+ public function RenderColumn($value)
+ {
+ if ($this->ColumnRendererCodeBlob == null) return;
+ $q = '';
+ $q .= 'use Objectify\Objects\MultipleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\SingleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\TenantObject; ';
+ $q .= 'use Objectify\Objects\TenantObjectInstance; ';
+ $q .= '$x = function($input) { ' . $this->ColumnRendererCodeBlob . ' };';
+ // trigger_error("calling ColumnRendererCodeBlob on DataType '" . $this->Name . "'", E_USER_NOTICE);
+ eval($q);
+ $x($value);
+ }
+ public function RenderEditor($value, $name)
+ {
+ if ($this->EditorRendererCodeBlob == null) return;
+
+ $q = '';
+ $q .= 'use Objectify\Objects\MultipleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\SingleInstanceProperty; ';
+ $q .= 'use Objectify\Objects\TenantObject; ';
+ $q .= 'use Objectify\Objects\TenantObjectInstance; ';
+ $q .= '$x = function($input, $name) { ' . $this->EditorRendererCodeBlob . ' };';
+ // trigger_error("calling EditorRendererCodeBlob on DataType '" . $this->Name . "'", E_USER_NOTICE);
+
+ eval($q);
+
+ // if $x is not set, then there must have been an error in parsing so stop rendering
+ if (!isset($x)) return;
+
+ $x($value, $name);
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/Language.inc.php b/PHP/Common/Include/Objects/Language.inc.php
new file mode 100644
index 00000000..334d1ad2
--- /dev/null
+++ b/PHP/Common/Include/Objects/Language.inc.php
@@ -0,0 +1,55 @@
+ID = $values["language_ID"];
+ $item->Name = $values["language_Name"];
+ return $item;
+ }
+ public static function Get()
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "Languages";
+ $result = $MySQL->query($query);
+ $retval = array();
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $item = Language::GetByAssoc($values);
+ if ($item != null) $retval[] = $item;
+ }
+ return $retval;
+ }
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "Languages WHERE language_ID = " . $id;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count < 1) return null;
+
+ $values = $result->fetch_assoc();
+ return Language::GetByAssoc($values);
+ }
+ public static function GetCurrent()
+ {
+ return Language::GetByID(1);
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/Module.inc.php b/PHP/Common/Include/Objects/Module.inc.php
new file mode 100644
index 00000000..1c29f217
--- /dev/null
+++ b/PHP/Common/Include/Objects/Module.inc.php
@@ -0,0 +1,113 @@
+ID = $values["module_ID"];
+ $item->Title = $values["module_Title"];
+ $item->Description = $values["module_Description"];
+ $item->Enabled = $values["module_Enabled"];
+ return $item;
+ }
+ public static function Get($max = null, $tenant = null)
+ {
+ global $MySQL;
+
+ $query = "SELECT module_ID, module_Title, module_Description";
+ if ($tenant != null)
+ {
+ $query .= ", (tenantmodule_ModuleID = module_ID) AS module_Enabled";
+ }
+ else
+ {
+ $query .= ", 1 AS module_Enabled";
+ }
+ $query .= " FROM " . System::$Configuration["Database.TablePrefix"] . "Modules";
+ if ($tenant != null)
+ {
+ $query .= ", " . System::$Configuration["Database.TablePrefix"] . "TenantModules";
+ $query .= " WHERE tenantmodule_ModuleID = module_ID AND tenantmodule_TenantID = " . $tenant->ID;
+ }
+
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = Module::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ 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);
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+
+ if (is_numeric($this->ID))
+ {
+ // id is set, so update
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "Modules SET ";
+ $query .= "module_Title = '" . $MySQL->real_escape_string($this->Title) . "', ";
+ $query .= "module_Description = '" . $MySQL->real_escape_string($this->Description) . "'";
+ $query .= " WHERE module_ID = " . $this->ID;
+ }
+ else
+ {
+ // id is not set, so insert
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "Modules (module_Title, module_Description) VALUES (";
+ $query .= "'" . $MySQL->real_escape_string($this->Title) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->Description) . "'";
+ $query .= ")";
+ }
+
+ $result = $MySQL->query($query);
+ if ($MySQL->errno != 0) return false;
+
+ if (!is_numeric($this->ID))
+ {
+ // id is not set, so set it
+ $this->ID = $MySQL->insert_id;
+ }
+ return true;
+ }
+
+ public function ToJSON()
+ {
+ echo("{");
+ echo("\"ID\":" . $this->ID . ",");
+ echo("\"Title\":\"" . \JH\Utilities::JavaScriptDecode($this->Title, "\"") . "\",");
+ echo("\"Description\":\"" . \JH\Utilities::JavaScriptDecode($this->Description, "\"") . "\"");
+ echo("}");
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/ModulePage.inc.php b/PHP/Common/Include/Objects/ModulePage.inc.php
new file mode 100644
index 00000000..225fbf14
--- /dev/null
+++ b/PHP/Common/Include/Objects/ModulePage.inc.php
@@ -0,0 +1,78 @@
+ID = $values["modulepage_ID"];
+ $item->Module = Module::GetByID($values["modulepage_ModuleID"]);
+ $item->ParentPage = ModulePage::GetByID($values["modulepage_ParentPageID"]);
+ $item->URL = $values["modulepage_URL"];
+ $item->Content = $values["modulepage_Content"];
+ return $item;
+ }
+ public static function Get($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "ModulePages";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = ModulePage::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "Modules WHERE module_ID = " . $id;
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return ModulePage::GetByAssoc($values);
+ }
+
+ public function ToJSON()
+ {
+ echo("{");
+ echo("\"ID\":" . $this->ID . ",");
+ if ($this->Module == null)
+ {
+ echo("\"Module\":null,");
+ }
+ else
+ {
+ echo("\"Module\":" . $this->Module->ToJSON() . ",");
+ }
+ if ($this->ParentPage == null)
+ {
+ echo("\"ParentPage\":null,");
+ }
+ else
+ {
+ echo("\"ParentPage\":" . $this->ParentPage->ToJSON() . ",");
+ }
+ echo("\"URL\":\"" . \JH\Utilities::JavaScriptDecode($this->URL, "\"") . "\",");
+ echo("\"Content\":\"" . \JH\Utilities::JavaScriptDecode($this->Content, "\"") . "\"");
+ echo("}");
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/MultipleInstanceProperty.inc.php b/PHP/Common/Include/Objects/MultipleInstanceProperty.inc.php
new file mode 100644
index 00000000..8f3c0ed7
--- /dev/null
+++ b/PHP/Common/Include/Objects/MultipleInstanceProperty.inc.php
@@ -0,0 +1,41 @@
+mvarInstances;
+ }
+ public function AddInstance($value)
+ {
+ if ($value == null) return false;
+ foreach ($this->ValidObjects as $obj)
+ {
+ if ($obj->ID != $value->ParentObject->ID) return false;
+ }
+ $this->mvarInstances[] = $value;
+ return true;
+ }
+ public function ClearInstances()
+ {
+ $this->mvarInstances = array();
+ }
+ public function CountInstances()
+ {
+ return count($this->mvarInstances);
+ }
+
+ public $ValidObjects;
+
+ public function __construct($instances = null, $validObjects = null)
+ {
+ if ($instances == null) $instances = array();
+ $this->mvarInstances = $instances;
+
+ if ($validObjects == null) $validObjects = array();
+ $this->ValidObjects = $validObjects;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/PaymentPlan.inc.php b/PHP/Common/Include/Objects/PaymentPlan.inc.php
new file mode 100644
index 00000000..d32da618
--- /dev/null
+++ b/PHP/Common/Include/Objects/PaymentPlan.inc.php
@@ -0,0 +1,56 @@
+ID = $values["paymentplan_ID"];
+ $item->URL = $values["paymentplan_Title"];
+ $item->Description = $values["paymentplan_Description"];
+ return $item;
+ }
+ public static function Get($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "PaymentPlans";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = PaymentPlan::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "PaymentPlans WHERE paymentplan_ID = " . $id;
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return PaymentPlan::GetByAssoc($values);
+ }
+
+ public function ToJSON()
+ {
+ echo("{");
+ echo("\"ID\":" . $this->ID . ",");
+ echo("\"Title\":\"" . \JH\Utilities::JavaScriptDecode($this->Title, "\"") . "\",");
+ echo("\"Description\":\"" . \JH\Utilities::JavaScriptDecode($this->Description, "\"") . "\"");
+ echo("}");
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/SingleInstanceProperty.inc.php b/PHP/Common/Include/Objects/SingleInstanceProperty.inc.php
new file mode 100644
index 00000000..12258fb1
--- /dev/null
+++ b/PHP/Common/Include/Objects/SingleInstanceProperty.inc.php
@@ -0,0 +1,31 @@
+mvarInstance;
+ }
+ public function SetInstance($value)
+ {
+ foreach ($this->ValidObjects as $obj)
+ {
+ if ($obj->ID != $value->ParentObject->ID) return false;
+ }
+ $this->mvarInstance = $value;
+ return true;
+ }
+
+ public $ValidObjects;
+
+ public function __construct($instance = null, $validObjects = null)
+ {
+ $this->mvarInstance = $instance;
+
+ if ($validObjects == null) $validObjects = array();
+ $this->ValidObjects = $validObjects;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/Tenant.inc.php b/PHP/Common/Include/Objects/Tenant.inc.php
new file mode 100644
index 00000000..2db9cbdb
--- /dev/null
+++ b/PHP/Common/Include/Objects/Tenant.inc.php
@@ -0,0 +1,455 @@
+DataCenters = new DataCenterCollection();
+ }
+
+ public function IsExpired()
+ {
+ $date = date_create();
+ if ($this->BeginTimestamp == null)
+ {
+ $dateBegin = null;
+ }
+ else
+ {
+ $dateBegin = date_create($this->BeginTimestamp);
+ }
+ if ($this->EndTimestamp == null)
+ {
+ $dateEnd = null;
+ }
+ else
+ {
+ $dateEnd = date_create($this->EndTimestamp);
+ }
+
+ return (!(($dateBegin == null || $dateBegin <= $date) && ($dateEnd == null || $dateEnd >= $date)));
+ }
+
+ public static function Create($url, $description = null, $status = TenantStatus::Enabled, $type = null, $paymentPlan = null, $beginTimestamp = null, $endTimestamp = null, $dataCenters = null)
+ {
+ $item = new Tenant();
+ $item->URL = $url;
+ $item->Description = $description;
+ $item->Status = $status;
+ $item->Type = $type;
+ $item->PaymentPlan = $paymentPlan;
+ $item->BeginTimestamp = $beginTimestamp;
+ $item->EndTimestamp = $endTimestamp;
+
+ if ($dataCenters == null) $dataCenters = array();
+ foreach ($dataCenters as $datacenter)
+ {
+ $item->DataCenters->Add($datacenter);
+ }
+
+ if ($item->Update())
+ {
+ return $item;
+ }
+ return null;
+ }
+
+ public static function GetByAssoc($values)
+ {
+ $item = new Tenant();
+ $item->ID = $values["tenant_ID"];
+ $item->URL = $values["tenant_URL"];
+ $item->Description = $values["tenant_Description"];
+ switch ($values["tenant_Status"])
+ {
+ case 1:
+ {
+ $item->Status = TenantStatus::Enabled;
+ break;
+ }
+ case 0:
+ {
+ $item->Status = TenantStatus::Disabled;
+ break;
+ }
+ }
+ $item->Type = TenantType::GetByID($values["tenant_TypeID"]);
+ $item->PaymentPlan = PaymentPlan::GetByID($values["tenant_PaymentPlanID"]);
+ $item->BeginTimestamp = $values["tenant_BeginTimestamp"];
+ $item->EndTimestamp = $values["tenant_EndTimestamp"];
+
+
+ // get the data centers associated with this tenant
+ global $MySQL;
+ $query = "SELECT " . System::$Configuration["Database.TablePrefix"] . "DataCenters.* FROM " . System::$Configuration["Database.TablePrefix"] . "DataCenters, " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters WHERE " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters.tdc_TenantID = " . $item->ID . " AND " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters.tdc_DataCenterID = " . System::$Configuration["Database.TablePrefix"] . "DataCenters.datacenter_ID";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = DataCenter::GetByAssoc($values);
+ }
+ $item->DataCenters->Items = $retval;
+
+ return $item;
+ }
+ public static function Get($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "Tenants";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = Tenant::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "Tenants WHERE tenant_ID = " . $id;
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return Tenant::GetByAssoc($values);
+ }
+ public static function GetByURL($url)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "Tenants WHERE tenant_URL = '" . $MySQL->real_escape_string($url) . "'";
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ echo("
Initialization Failure Initialization Failure A fatal error occurred when attempting to initialize the Objectify runtime. Please make sure Objectify has been installed correctly on the server.
The Objectify runtime cannot be loaded (1001). Please contact the Web site administrator to inform them of this problem.
System information Tenant: " . $url . " Server: " . $_SERVER["HTTP_HOST"] . "
");
+ die();
+ return null;
+ }
+
+ $count = $result->num_rows;
+ if ($count == 0)
+ {
+ echo("Initialization Failure Initialization Failure A fatal error occurred when attempting to initialize the Objectify runtime. Please make sure Objectify has been installed correctly on the server.
The Objectify runtime cannot find the requested tenant (1002). Please contact the Web site administrator to inform them of this problem.
System information Tenant: " . $url . " Server: " . $_SERVER["HTTP_HOST"] . "
");
+ die();
+ return null;
+ }
+
+ $values = $result->fetch_assoc();
+ return Tenant::GetByAssoc($values);
+ }
+
+ public static function GetCurrent()
+ {
+ if (System::$TenantName == "") return null;
+ return Tenant::GetByURL(System::$TenantName);
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+ if ($this->ID != null)
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "Tenants SET ";
+ $query .= "tenant_URL = '" . $MySQL->real_escape_string($this->URL) . "', ";
+ $query .= "tenant_Description = '" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "tenant_Status = " . ($this->Status == TenantStatus::Enabled ? "1" : "0") . ", ";
+ $query .= "tenant_TypeID = " . ($this->Type != null ? $this->Type->ID : "NULL") . ", ";
+ $query .= "tenant_PaymentPlanID = " . ($this->PaymentPlan != null ? $this->PaymentPlan->ID : "NULL") . ", ";
+ $query .= "tenant_BeginTimestamp = " . ($this->BeginTimestamp != null ? ("'" . $this->BeginTimestamp . "'") : "NULL") . ", ";
+ $query .= "tenant_EndTimestamp = " . ($this->EndTimestamp != null ? ("'" . $this->EndTimestamp . "'") : "NULL");
+ $query .= " WHERE tenant_ID = " . $this->ID;
+ }
+ else
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "Tenants (tenant_URL, tenant_Description, tenant_Status, tenant_TypeID, tenant_PaymentPlanID, tenant_BeginTimestamp, tenant_EndTimestamp) VALUES (";
+ $query .= "'" . $MySQL->real_escape_string($this->URL) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= ($this->Status == TenantStatus::Enabled ? "1" : "0") . ", ";
+ $query .= ($this->Type != null ? $this->Type->ID : "NULL") . ", ";
+ $query .= ($this->PaymentPlan != null ? $this->PaymentPlan->ID : "NULL") . ", ";
+ $query .= ($this->BeginTimestamp != null ? ("'" . $this->BeginTimestamp . "'") : "NULL") . ", ";
+ $query .= ($this->EndTimestamp != null ? ("'" . $this->EndTimestamp . "'") : "NULL");
+ $query .= ")";
+ }
+
+ $result = $MySQL->query($query);
+ if ($MySQL->errno != 0) return false;
+
+ if ($this->ID == null)
+ {
+ $this->ID = $MySQL->insert_id;
+ }
+
+ // clearing the data centers
+ $query = "DELETE FROM " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters WHERE tdc_TenantID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($MySQL->errno != 0) return false;
+
+ // inserting the data centers
+ foreach ($this->DataCenters->Items as $item)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters (tdc_TenantID, tdc_DataCenterID) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= $item->ID;
+ $query .= ")";
+
+ $result = $MySQL->query($query);
+ if ($MySQL->errno != 0) return false;
+ }
+
+ return true;
+ }
+
+ public function Delete()
+ {
+ global $MySQL;
+ if ($this->ID == null) return false;
+
+ // Relationships should cause all associated tenant data to be deleted.
+ $query = "DELETE FROM " . System::$Configuration["Database.TablePrefix"] . "Tenants WHERE tenant_ID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($MySQL->errno != 0) return false;
+
+ return true;
+ }
+
+ ///
+ /// Determines if an Objectify object with the specified name exists on the current tenant.
+ ///
+ public function HasObject($name)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjects WHERE (object_TenantID IS NULL OR object_TenantID = " . $this->ID . ") AND object_Name = '" . $MySQL->real_escape_string($name) . "'";
+
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ return ($count != 0);
+ }
+
+ ///
+ /// Gets an Objectify object from the current tenant.
+ ///
+ public function GetObject($name)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjects WHERE (object_TenantID IS NULL OR object_TenantID = " . $this->ID . ") AND object_Name = '" . $MySQL->real_escape_string($name) . "'";
+
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ if ($count == 0)
+ {
+ Objectify::Log("No object with the specified name was found.", array
+ (
+ "Tenant" => $this->URL,
+ "Object" => $name
+ ));
+ return null;
+ }
+ $values = $result->fetch_assoc();
+ $object = TenantObject::GetByAssoc($values);
+ return $object;
+ }
+
+ public function CreateObject($name, $titles = null, $descriptions = null, $properties = null, $parentObject = null, $instances = null)
+ {
+ global $MySQL;
+ if ($titles == null) $titles = array($name);
+ if ($descriptions == null) $descriptions = array();
+ if ($properties == null) $properties = array();
+ if ($instances == null) $instances = array();
+
+ // do not create the object if the object with the same name already exists
+ if ($this->HasObject($name))
+ {
+ $bt = debug_backtrace();
+ trigger_error("Object '" . $name . "' already exists on tenant '" . $this->URL . "' in " . $bt[0]["file"] . "::" . $bt[0]["function"] . " on line " . $bt[0]["line"] . "; ", E_USER_WARNING);
+ return $this->GetObject($name);
+ }
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjects (object_TenantID, object_ModuleID, object_ParentObjectID, object_Name) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= "NULL" . ", ";
+ $query .= ($parentObject == null ? "NULL" : $parentObject->ID) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($name) . "', ";
+ $query .= ")";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ $id = $MySQL->insert_id;
+ $object = TenantObject::GetByID($id);
+
+ $object->SetTitles($titles);
+ $object->SetDescriptions($descriptions);
+
+ foreach ($properties as $property)
+ {
+ $object->CreateInstanceProperty($property);
+ }
+
+ foreach ($instances as $instance)
+ {
+ $object->CreateInstance($instance);
+ }
+
+ return $object;
+ }
+
+ public function CreateEnumeration($name, $description = null, $choices = null)
+ {
+ global $MySQL;
+ if ($choices == null) $choices = array();
+
+ $item = new TenantEnumeration($name, $description, $choices);
+ $item->Tenant = $this;
+ $item->Choices = $choices;
+ $item->Update();
+
+ return $item;
+ }
+
+ public function GetProperties()
+ {
+ global $MySQL;
+
+ $retval = array();
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantProperties WHERE (property_TenantID = " . $this->ID . " OR property_TenantID IS NULL)";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantProperty::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function CreateProperty($property)
+ {
+ return TenantProperty::Create($property, $this);
+ }
+
+ public function GetProperty($propertyName)
+ {
+ global $MySQL;
+
+ $retval = array();
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantProperties WHERE (property_TenantID = " . $this->ID . " OR property_TenantID IS NULL) AND property_Name = '" . $MySQL->real_escape_string($propertyName) . "'";
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to obtain a reference to a property on the tenant.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query
+ ));
+ return null;
+ }
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantProperty::GetByAssoc($values);
+ }
+
+ public function GetPropertyValue($property, $defaultValue = null)
+ {
+ global $MySQL;
+
+ // if we passed in a string to this property (because it's easier) then let's get a reference to that property
+ if (is_string($property))
+ {
+ $propname = $property;
+ $property = $this->GetProperty($property);
+ }
+
+ $query = "SELECT (CASE WHEN (propval_Value IS NULL) THEN property_DefaultValue ELSE propval_Value END) FROM " . System::$Configuration["Database.TablePrefix"] . "TenantPropertyValues, " . System::$Configuration["Database.TablePrefix"] . "TenantProperties WHERE " . System::$Configuration["Database.TablePrefix"] . "TenantProperties.property_ID = " . $property->ID . " AND " . System::$Configuration["Database.TablePrefix"] . "TenantProperties.property_ID = " . System::$Configuration["Database.TablePrefix"] . "TenantPropertyValues.propval_PropertyID";
+
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to look up a value of a property on the tenant.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query,
+ "Property" => ($property == null ? ($propname == null ? "(null)" : $propname) : (is_string($property) ? $property : $property->Name))
+ ));
+ return null;
+ }
+
+ $count = $result->num_rows;
+ if ($count == 0)
+ {
+ Objectify::Log("The property has no defined values on the specified tenant.", array
+ (
+ "Property" => ($property == null ? ($propname == null ? "(null)" : $propname) : (is_string($property) ? $property : $property->Name))
+ ), LogMessageSeverity::Warning);
+ if ($defaultValue != null) return $defaultValue;
+ return $property->DefaultValue;
+ }
+
+ $values = $result->fetch_array();
+ return $property->Decode($values[0]);
+ }
+ public function SetPropertyValue($property, $value)
+ {
+ global $MySQL;
+
+ // if we passed in a string to this property (because it's easier) then let's get a reference to that property
+ if (is_string($property))
+ {
+ $propname = $property;
+ $property = $this->GetProperty($property);
+ }
+
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "TenantPropertyValues SET propval_Value = '" . $MySQL->real_escape_string($property->Encode($value)) . "' WHERE propval_PropertyID = " . $property->ID;
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to update the value of a property on the tenant.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query,
+ "Property" => ($property == null ? ($propname == null ? "(null)" : $propname) : (is_string($property) ? $property : $property->Name))
+ ));
+ }
+ return ($MySQL->errno == 0);
+ }
+
+ public function ToJSON()
+ {
+ echo("{");
+ echo("\"ID\":" . $this->ID . ",");
+ echo("\"URL\":\"" . $this->URL . "\",");
+ echo("\"Description\":\"" . $this->Description . "\"");
+ echo("\"Status\":\"" . $this->Status . "\"");
+ echo("\"Type\":" . $this->Type->ToJSON() . "");
+ echo("\"PaymentPlan\":" . $this->PaymentPlan->ToJSON() . "");
+ echo("\"BeginTimestamp\":\"" . $this->BeginTimestamp . "\"");
+ echo("\"EndTimestamp\":\"" . $this->EndTimestamp . "\"");
+ echo("}");
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantObject.inc.php b/PHP/Common/Include/Objects/TenantObject.inc.php
new file mode 100644
index 00000000..03d04107
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantObject.inc.php
@@ -0,0 +1,529 @@
+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->Name = $values["object_Name"];
+ $item->Description = $values["object_Description"];
+ return $item;
+ }
+
+ public static function Get($max = null, $tenant = null)
+ {
+ global $MySQL;
+
+ $retval = array();
+ if ($tenant == null) $tenant = Tenant::GetCurrent();
+ if ($tenant == null) return $retval;
+
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjects WHERE object_TenantID = " . $tenant->ID;
+ if (is_numeric($max)) $query .= " LIMIT " . $max;
+
+ $result = $MySQL->query($query);
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObject::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjects WHERE object_ID = " . $id;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantObject::GetByAssoc($values);
+ }
+
+ ///
+ /// Creates an instance of this Objectify object with the specified properties.
+ ///
+ public function CreateInstance($properties)
+ {
+ if (!is_array($properties)) return false;
+
+ $inst = new TenantObjectInstance($this);
+ $inst->Update();
+
+ foreach ($properties as $instprop)
+ {
+ $inst->SetPropertyValue($instprop->Property, $instprop->Value);
+ }
+ return $inst;
+ }
+
+ public function GetPropertyValue($property, $defaultValue = null)
+ {
+ global $MySQL;
+
+ if (is_string($property))
+ {
+ $property = $this->GetProperty($property);
+ }
+ if ($property == null) return $defaultValue;
+
+ $query = "SELECT propval_Value FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectPropertyValues WHERE propval_PropertyID = " . $property->ID;
+
+ $result = $MySQL->query($query);
+ if ($result === false) return $defaultValue;
+
+ $count = $result->num_rows;
+ if ($count == 0) return $defaultValue;
+
+ $values = $result->fetch_array();
+ return $property->DataType->Decode($values[0]);
+ }
+ public function SetPropertyValue($property, $value)
+ {
+ global $MySQL;
+
+ if (is_string($property))
+ {
+ $property = $this->GetProperty($property);
+ }
+ if ($property == null) return false;
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectPropertyValues (propval_PropertyID, propval_Value) VALUES (";
+ $query .= $property->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($property->DataType->Encode($value)) . "'";
+ $query .= ")";
+ $query .= " ON DUPLICATE KEY UPDATE ";
+ $query .= "propval_PropertyID = values(propval_PropertyID), ";
+ $query .= "propval_Value = values(propval_Value)";
+
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to update a property value for the specified object.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query
+ ));
+ return false;
+ }
+
+ return true;
+ }
+
+
+ public function CreateInstanceProperty($property)
+ {
+ global $MySQL;
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceProperties (property_ObjectID, property_Name, property_Description, property_DataTypeID, property_DefaultValue, property_IsRequired) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($property->Name) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($property->Description) . "', ";
+ $query .= ($property->DataType == null ? "NULL" : $property->DataType->ID) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($property->Encode($property->DefaultValue)) . "', ";
+ $query .= ($property->Required ? "1" : "0");
+ $query .= ")";
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to create an instance property for the specified tenant object.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query
+ ));
+ return false;
+ }
+ }
+
+
+ public function CreateMethod($name, $parameters, $codeblob, $description = null, $namespaceReferences = null)
+ {
+ global $MySQL;
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethods (method_ObjectID, method_Name, method_Description, method_CodeBlob) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($name) . "', ";
+ $query .= ($description == null ? "NULL" : ("'" . $MySQL->real_escape_string($description) . "'")) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($codeblob) . "'";
+ $query .= ")";
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to create a static method for the specified tenant object.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query
+ ));
+ return false;
+ }
+
+ $method = TenantObjectMethod::GetByID($MySQL->insert_id);
+
+ if (is_array($namespaceReferences))
+ {
+ foreach ($namespaceReferences as $ref)
+ {
+ $method->AddNamespaceReference($ref);
+ }
+ }
+ return $method;
+ }
+ public function CreateInstanceMethod($name, $parameters, $codeblob, $description = null, $namespaceReferences = null)
+ {
+ global $MySQL;
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethods (method_ObjectID, method_Name, method_Description, method_CodeBlob) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($name) . "', ";
+ $query .= ($description == null ? "NULL" : ("'" . $MySQL->real_escape_string($description) . "'")) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($codeblob) . "'";
+ $query .= ")";
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to create an instance method for the specified tenant object.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query
+ ));
+ return false;
+ }
+
+ $method = TenantObjectInstanceMethod::GetByID($MySQL->insert_id);
+
+ if (is_array($namespaceReferences))
+ {
+ foreach ($namespaceReferences as $ref)
+ {
+ $method->AddNamespaceReference($ref);
+ }
+ }
+ return $method;
+ }
+
+ public function GetProperty($propertyName)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectProperties WHERE property_ObjectID = " . $this->ID . " AND property_Name = '" . $MySQL->real_escape_string($propertyName) . "'";
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantObjectProperty::GetByAssoc($values);
+ }
+ public function GetProperties($max = null)
+ {
+ global $MySQL;
+
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectProperties WHERE property_ObjectID = " . $this->ID;
+ if (is_numeric($max)) $query .= " LIMIT " . $max;
+
+ $result = $MySQL->query($query);
+ $retval = array();
+
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectProperty::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ public function GetInstanceProperty($propertyName)
+ {
+ global $MySQL;
+
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceProperties WHERE property_ObjectID = " . $this->ID . " AND property_Name = '" . $MySQL->real_escape_string($propertyName) . "'";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+ $count = $result->num_rows;
+ if ($count == 0)
+ {
+ Objectify::Log("Could not fetch the specified instance property on the object.", array
+ (
+ "Object" => $this->Name,
+ "Property" => $propertyName
+ ));
+ return null;
+ }
+
+ $values = $result->fetch_assoc();
+
+ return TenantObjectInstanceProperty::GetByAssoc($values);
+ }
+ public function GetInstanceProperties($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceProperties WHERE property_ObjectID = " . $this->ID;
+
+ $result = $MySQL->query($query);
+ $retval = array();
+
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectInstanceProperty::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function GetMethod($name)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethods WHERE method_ObjectID = " . $this->ID . " AND method_Name = '" . $MySQL->real_escape_string($name) . "'";
+ $result = $MySQL->query($query);
+
+ if ($result === false) return null;
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantObjectMethod::GetByAssoc($values);
+ }
+ public function GetMethods($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethods WHERE method_ObjectID = " . $this->ID;
+ if (is_numeric($max)) $query .= " LIMIT " . $max;
+ $result = $MySQL->query($query);
+
+ $retval = array();
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectMethod::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function GetInstanceMethod($name)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethods WHERE method_ObjectID = " . $this->ID . " AND method_Name = '" . $MySQL->real_escape_string($name) . "'";
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+
+ return TenantObjectInstanceMethod::GetByAssoc($values);
+ }
+ public function GetInstanceMethods($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethods WHERE method_ObjectID = " . $this->ID;
+ if (is_numeric($max)) $query .= " LIMIT " . $max;
+ $result = $MySQL->query($query);
+
+ $retval = array();
+ if ($result === false) return $retval;
+
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectInstanceMethod::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function CountInstances($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT COUNT(instance_ID) FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances WHERE instance_ObjectID = " . $this->ID;
+ $result = $MySQL->query($query);
+
+ if ($result === false) return 0;
+ $count = $result->num_rows;
+ if ($count == 0) return 0;
+
+ $values = $result->fetch_array();
+ return $values[0];
+ }
+
+ public function GetInstance($parameters)
+ {
+ if (!is_array($parameters))
+ {
+ Objectify::Log("No parameters were specified by which to extract a single instance of the object.", array
+ (
+ "Object" => $this->Name,
+ "Property" => $propertyName
+ ));
+ return null;
+ }
+
+ global $MySQL;
+
+ $query = "SELECT " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances.* FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances, " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceProperties, " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstancePropertyValues";
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to obtain an instance of an object on the tenant.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query
+ ));
+ return null;
+ }
+
+ $count = $result->num_rows;
+ if ($count == 0)
+ {
+ Objectify::Log("Could not obtain an instance of the object with the specified parameters.", array
+ (
+ "Object" => $this->Name,
+ "Query" => $query
+ ));
+ return null;
+ }
+
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $inst = TenantObjectInstance::GetByAssoc($values);
+ $found = true;
+ foreach ($parameters as $parameter)
+ {
+ if ($inst->GetPropertyValue($this->GetInstanceProperty($parameter->Name)) != $parameter->Value)
+ {
+ $found = false;
+ break;
+ }
+ }
+ if ($found) return $inst;
+ }
+ return null;
+ }
+
+ public function GetInstances($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances WHERE instance_ObjectID = " . $this->ID;
+ $result = $MySQL->query($query);
+ $retval = array();
+
+ if ($result === false) return $retval;
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectInstance::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function GetTitleOrName($language = null)
+ {
+ $title = $this->GetTitle($language);
+ if ($title == null) return $this->Name;
+ return $title;
+ }
+
+ public function GetTitle($language = null)
+ {
+ if ($language == null) return Language::GetCurrent();
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectTitles WHERE entry_LanguageID = " . $language->ID . " AND entry_ObjectID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return $values["entry_Value"];
+ }
+ public function SetTitle($language, $value)
+ {
+ if ($language == null) return Language::GetCurrent();
+
+ global $MySQL;
+ $query = "SELECT COUNT(*) FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectDescriptions WHERE entry_LanguageID = " . $language->ID . " AND entry_ObjectID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ $values = $result->fetch_array();
+ if (is_numeric($values[0]) && $values[0] > 0)
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "TenantObjectDescriptions SET entry_Value = '" . $MySQL->real_escape_string($value) . "' WHERE entry_LanguageID = " . $language->ID . " AND entry_ObjectID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+ }
+ else
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectDescriptions (entry_LanguageID, entry_ObjectID, entry_Value) VALUES (" . $language->ID . ", " . $this->ID . ", '" . $MySQL->real_escape_string($value) . "')";
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+ }
+ return true;
+ }
+ public function SetTitles($items)
+ {
+ foreach ($items as $item)
+ {
+ $object->SetTitle($item->Language, $item->Value);
+ }
+ }
+ public function GetDescription($language = null)
+ {
+ if ($language == null) return Language::GetCurrent();
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectDescriptions WHERE entry_LanguageID = " . $language->ID . " AND entry_ObjectID = " . $this->ID;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return $values["entry_Value"];
+ }
+ public function SetDescription($language, $value)
+ {
+ }
+ public function SetDescriptions($items)
+ {
+ foreach ($items as $item)
+ {
+ $object->SetDescription($item->Language, $item->Value);
+ }
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantObjectInstance.inc.php b/PHP/Common/Include/Objects/TenantObjectInstance.inc.php
new file mode 100644
index 00000000..97af074e
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantObjectInstance.inc.php
@@ -0,0 +1,220 @@
+ParentObject = $parentObject;
+ }
+
+ public static function GetByAssoc($values)
+ {
+ $item = new TenantObjectInstance(TenantObject::GetByID($values["instance_ObjectID"]));
+ $item->ID = $values["instance_ID"];
+ return $item;
+ }
+
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances WHERE instance_ID = " . $id;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantObjectInstance::GetByAssoc($values);
+ }
+
+ public function GetPropertyValue($property, $defaultValue = null)
+ {
+ global $MySQL;
+
+ if (is_string($property))
+ {
+ $property = $this->ParentObject->GetInstanceProperty($property);
+ }
+ if ($property == null) return $defaultValue;
+
+ $query = "SELECT propval_Value FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstancePropertyValues WHERE propval_InstanceID = " . $this->ID . " AND propval_PropertyID = " . $property->ID;
+
+ $result = $MySQL->query($query);
+ if ($result === false) return $defaultValue;
+
+ $count = $result->num_rows;
+ if ($count == 0) return $defaultValue;
+
+ $values = $result->fetch_array();
+ return $property->Decode($values[0]);
+ }
+ public function SetPropertyValue($property, $value)
+ {
+ global $MySQL;
+
+ if (is_string($property))
+ {
+ $property = $this->ParentObject->GetInstanceProperty($property);
+ }
+ if ($property == null) return false;
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstancePropertyValues (propval_InstanceID, propval_PropertyID, propval_Value) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= $property->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($property->Encode($value)) . "'";
+ $query .= ")";
+ $query .= " ON DUPLICATE KEY UPDATE ";
+ $query .= "propval_PropertyID = values(propval_PropertyID), ";
+ $query .= "propval_Value = values(propval_Value)";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ return true;
+ }
+ public function HasPropertyValue($property)
+ {
+ global $MySQL;
+
+ if ($property == null) return false;
+
+ $query = "SELECT COUNT(propval_Value) FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstancePropertyValues WHERE propval_InstanceID = " . $this->ID . " AND propval_PropertyID = " . $property->ID;
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ $count = $result->num_rows;
+ if ($count == 0) return false;
+
+ $values = $result->fetch_array();
+ return ($values[0] > 0);
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+ if ($this->ID == null)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances (instance_ObjectID) VALUES (";
+ $query .= $this->ParentObject->ID;
+ $query .= ")";
+ }
+ else
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstances SET ";
+ $query .= "instance_ObjectID = " . $this->ParentObject->ID;
+ $query .= " WHERE instance_ID = " . $this->ID;
+ }
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ if ($this->ID == null)
+ {
+ $this->ID = $MySQL->insert_id;
+ }
+ return true;
+ }
+
+ public function ToString()
+ {
+ return $this->GetPropertyValue("Name");
+ }
+ }
+ class TenantObjectInstanceProperty
+ {
+ public $ID;
+ public $ParentObject;
+ public $Name;
+ public $DataType;
+ public $DefaultValue;
+ public $Required;
+
+ ///
+ /// Determines whether this TenantObjectInstanceProperty is visible when rendered as a column in a ListView.
+ ///
+ public $ColumnVisible;
+
+ public function RenderColumn($value = null)
+ {
+ if ($this->DataType == null || $this->DataType->ColumnRendererCodeBlob == null)
+ {
+ ?>
+
+ DataType->RenderColumn($this->DefaultValue);
+ }
+ else
+ {
+ $this->DataType->RenderColumn($value);
+ }
+ }
+ }
+
+ public function Encode($value)
+ {
+ if ($this->DataType == null) return $value;
+ return $this->DataType->Encode($value);
+ }
+ public function Decode($value)
+ {
+ if ($this->DataType == null) return $value;
+ return $this->DataType->Decode($value);
+ }
+
+ public function __construct($name = null, $dataType = null, $defaultValue = null, $required = false)
+ {
+ $this->Name = $name;
+ $this->DataType = $dataType;
+ $this->DefaultValue = $defaultValue;
+ $this->Required = $required;
+ }
+
+ public static function GetByAssoc($values)
+ {
+ $item = new TenantObjectInstanceProperty();
+ $item->ID = $values["property_ID"];
+ $item->ParentObject = TenantObject::GetByID($values["property_ObjectID"]);
+ $item->Name = $values["property_Name"];
+ $item->Description = $values["property_Description"];
+ $item->DataType = DataType::GetByID($values["property_DataTypeID"]);
+ if ($item->DataType != null)
+ {
+ $item->DefaultValue = $item->DataType->Decode($values["property_DefaultValue"]);
+ }
+ $item->Required = ($values["property_IsRequired"] == 1);
+ $item->ColumnVisible = ($values["property_ColumnVisible"] == 1);
+ return $item;
+ }
+ }
+ class TenantObjectInstancePropertyValue
+ {
+ public $Property;
+ public $Value;
+
+ public function __construct($property, $value = null)
+ {
+ $this->Property = $property;
+ $this->Value = $value;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantObjectMethod.inc.php b/PHP/Common/Include/Objects/TenantObjectMethod.inc.php
new file mode 100644
index 00000000..75121963
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantObjectMethod.inc.php
@@ -0,0 +1,328 @@
+ID = $values["method_ID"];
+ $item->ParentObject = TenantObject::GetByID($values["method_ObjectID"]);
+ $item->Name = $values["method_Name"];
+ $item->Description = $values["method_Description"];
+ $item->CodeBlob = $values["method_CodeBlob"];
+ return $item;
+ }
+
+ public function AddNamespaceReference($value)
+ {
+ global $MySQL;
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethodNamespaceReferences (ns_MethodID, ns_Value) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($value) . "'";
+ $query .= ")";
+
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to add a namespace reference to the specified object method.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query,
+ "Method" => $this->Name,
+ "Object" => $this->ParentObject == null ? "(null)" : $this->ParentObject->Name
+ ));
+ return false;
+ }
+ return true;
+ }
+ public function RemoveNamespaceReference($value)
+ {
+ global $MySQL;
+ $query = "DELETE FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethodNamespaceReferences WHERE ";
+ $query .= "ns_MethodID = " . $this->ID . " AND ";
+ $query .= "ns_Value = '" . $MySQL->real_escape_string($value) . "'";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+ return true;
+ }
+ public function GetNamespaceReferences()
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethodNamespaceReferences WHERE ns_MethodID = " . $this->ID;
+ $retval = array();
+ $result = $MySQL->query($query);
+ if ($result === false) return $retval;
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectMethodNamespaceReference::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+
+ if ($this->ID == null)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethods (method_ObjectID, method_Name, method_Description, method_CodeBlob) VALUES (";
+ $query .= ($this->Tenant == null ? "NULL" : $this->Tenant->ID) . ", ";
+ $query .= ($this->ParentObject == null ? "NULL" : $this->ParentObject->ID) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($this->Name) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->CodeBlob) . "'";
+ $query .= ")";
+ }
+ else
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethods SET ";
+ $query .= "method_ObjectID = " . ($this->ParentObject == null ? "NULL" : $this->ParentObject->ID) . ", ";
+ $query .= "method_Name = '" . $MySQL->real_escape_string($this->Name) . "', ";
+ $query .= "method_Description = '" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "method_CodeBlob = '" . $MySQL->real_escape_string($this->CodeBlob) . "'";
+ $query .= " WHERE method_ID = " . $this->ID;
+ }
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ if ($this->ID == null)
+ {
+ $this->ID = $MySQL->insert_id;
+ }
+ return true;
+ }
+
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectMethods WHERE method_ID = " . $id;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantObjectMethod::GetByAssoc($values);
+ }
+
+ public function Execute($parameters = null)
+ {
+ if ($parameters == null) $parameters = array();
+
+ $func = "";
+ $nses = $this->GetNamespaceReferences();
+ foreach ($nses as $ns)
+ {
+ $func .= "use " . $ns->Value . ";\n";
+ }
+
+ $func .= "\$x = function(\$thisObject";
+ $count = count($parameters);
+ if ($count > 0) $func .= ", ";
+
+ for ($i = 0; $i < $count; $i++)
+ {
+ $parameter = $parameters[$i];
+ $func .= "\$" . $parameter->ParameterName;
+ if ($i < $count - 1)
+ {
+ $func .= ", ";
+ }
+ }
+ $func .= "){";
+ $func .= $this->CodeBlob;
+ $func .= "}; return \$x(";
+ $func .= "Objectify\\Objects\\TenantObject::GetByID(" . $this->ParentObject->ID . ")";
+ if ($count > 0) $func .= ", ";
+
+ for ($i = 0; $i < $count; $i++)
+ {
+ $parameter = $parameters[$i];
+ if (is_string($parameter->Value))
+ {
+ $func .= ("'" . $parameter->Value . "'");
+ }
+ else
+ {
+ $func .= $parameter->Value;
+ }
+ if ($i < $count - 1)
+ {
+ $func .= ", ";
+ }
+ }
+ $func .= ");";
+
+ return eval($func);
+ }
+ }
+ class TenantObjectInstanceMethod
+ {
+ public $ID;
+ public $ParentObject;
+ public $Name;
+ public $Description;
+ public $CodeBlob;
+
+ public static function GetByAssoc($values)
+ {
+ $item = new TenantObjectInstanceMethod();
+ $item->ID = $values["method_ID"];
+ $item->ParentObject = TenantObject::GetByID($values["method_ObjectID"]);
+ $item->Name = $values["method_Name"];
+ $item->Description = $values["method_Description"];
+ $item->CodeBlob = $values["method_CodeBlob"];
+ return $item;
+ }
+
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethods WHERE method_ID = " . $id;
+ $result = $MySQL->query($query);
+ if ($result === false) return null;
+
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantObjectInstanceMethod::GetByAssoc($values);
+ }
+
+ public function AddNamespaceReference($value)
+ {
+ global $MySQL;
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethodNamespaceReferences (ns_MethodID, ns_Value) VALUES (";
+ $query .= $this->ID . ", ";
+ $query .= "'" . $MySQL->real_escape_string($value) . "'";
+ $query .= ")";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+ return true;
+ }
+ public function RemoveNamespaceReference($value)
+ {
+ global $MySQL;
+ $query = "DELETE FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethodNamespaceReferences WHERE ";
+ $query .= "ns_MethodID = " . $this->ID . " AND ";
+ $query .= "ns_Value = '" . $MySQL->real_escape_string($value) . "'";
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+ return true;
+ }
+ public function GetNamespaceReferences()
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethodNamespaceReferences WHERE ns_MethodID = " . $this->ID;
+ $retval = array();
+ $result = $MySQL->query($query);
+ if ($result === false) return $retval;
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantObjectMethodNamespaceReference::GetByAssoc($values);
+ }
+ return $retval;
+ }
+
+ public function Execute($parameters)
+ {
+ if ($parameters == null) $parameters = array();
+
+ $func = "";
+ $nses = $this->GetNamespaceReferences();
+ foreach ($nses as $ns)
+ {
+ $func .= "use " . $ns->Value . ";\n";
+ }
+
+ $func .= "\$x = function(";
+ $count = count($parameters);
+ for ($i = 0; $i < $count; $i++)
+ {
+ $parameter = $parameters[$i];
+ $func .= "\$" . $parameter->ParameterName;
+ if ($i < $count - 1)
+ {
+ $func .= ", ";
+ }
+ }
+ $func .= "){";
+ $func .= $this->CodeBlob;
+ $func .= "}; return \$x(";
+ for ($i = 0; $i < $count; $i++)
+ {
+ $parameter = $parameters[$i];
+ if (is_string($parameter->Value))
+ {
+ $func .= ("'" . $parameter->Value . "'");
+ }
+ else
+ {
+ $func .= $parameter->Value;
+ }
+ if ($i < $count - 1)
+ {
+ $func .= ", ";
+ }
+ }
+ $func .= ");";
+ return eval($func);
+ }
+ }
+ class TenantObjectMethodParameter
+ {
+ public $Name;
+ public $DefaultValue;
+
+ public function __construct($name, $defaultValue = null)
+ {
+ $this->Name = $name;
+ $this->DefaultValue = $defaultValue;
+ }
+ }
+ class TenantObjectMethodParameterValue
+ {
+ public $ParameterName;
+ public $Value;
+
+ public function __construct($parameterName, $value = null)
+ {
+ $this->ParameterName = $parameterName;
+ $this->Value = $value;
+ }
+ }
+ class TenantObjectMethodNamespaceReference
+ {
+ public $ID;
+ public $Value;
+
+ public static function GetByAssoc($values)
+ {
+ $item = new TenantObjectMethodNamespaceReference();
+ $item->ID = $values["ns_ID"];
+ $item->Value = $values["ns_Value"];
+ return $item;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantObjectProperty.inc.php b/PHP/Common/Include/Objects/TenantObjectProperty.inc.php
new file mode 100644
index 00000000..bafdca96
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantObjectProperty.inc.php
@@ -0,0 +1,132 @@
+DataType == null || $this->DataType->ColumnRendererCodeBlob == null)
+ {
+ ?>
+
+ DataType->RenderColumn($this->DefaultValue);
+ }
+ else
+ {
+ $this->DataType->RenderColumn($value);
+ }
+ }
+ }
+
+ public function __construct($name, $description = null, $dataType = null, $defaultValue = null, $required = false, $enumeration = null, $requireChoiceFromEnumeration = false)
+ {
+ $this->Name = $name;
+ $this->Description = $description;
+ $this->DataType = $dataType;
+ $this->DefaultValue = $defaultValue;
+ $this->Required = $required;
+ $this->Enumeration = $enumeration;
+ $this->RequireChoiceFromEnumeration = $requireChoiceFromEnumeration;
+ }
+
+ public static function GetByAssoc($values)
+ {
+ $item = new TenantObjectProperty();
+ $item->ID = $values["property_ID"];
+ $item->Tenant = Tenant::GetByID($values["property_TenantID"]);
+ $item->ParentObject = TenantObject::GetByID($values["property_ObjectID"]);
+ $item->Name = $values["property_Name"];
+ $item->Description = $values["property_Description"];
+ $item->DataType = DataType::GetByID($values["property_DataTypeID"]);
+ $item->DefaultValue = $values["property_DefaultValue"];
+ $item->Required = ($values["property_IsRequired"] == 1);
+ $item->Enumeration = TenantEnumeration::GetByID($values["property_EnumerationID"]);
+ $item->RequireChoiceFromEnumeration = ($values["property_RequireChoiceFromEnumeration"] == 1);
+ return $item;
+ }
+
+ public function Update()
+ {
+ global $MySQL;
+
+ if ($this->ID == null)
+ {
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectProperties (property_TenantID, property_ObjectID, property_Name, property_Description, property_DataTypeID, property_DefaultValue, property_IsRequired) VALUES (";
+ $query .= ($this->Tenant == null ? "NULL" : $this->Tenant->ID) . ", ";
+ $query .= ($this->ParentObject == null ? "NULL" : $this->ParentObject->ID) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($this->Name) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= ($this->DataType == null ? "NULL" : $this->DataType->ID) . ", ";
+ $query .= $this->DefaultValue == null ? "NULL" : ("'" . $this->DefaultValue . "'") . ", ";
+ $query .= ($this->Required ? "1" : "0") . ", ";
+ }
+ else
+ {
+ $query = "UPDATE " . System::$Configuration["Database.TablePrefix"] . "TenantObjectProperties SET ";
+ $query .= "property_TenantID = " . ($this->Tenant == null ? "NULL" : $this->Tenant->ID) . ", ";
+ $query .= "property_ObjectID = " . ($this->ParentObject == null ? "NULL" : $this->ParentObject->ID) . ", ";
+ $query .= "property_Name = '" . $MySQL->real_escape_string($this->Name) . "', ";
+ $query .= "property_Description = '" . $MySQL->real_escape_string($this->Description) . "', ";
+ $query .= "property_DataTypeID = " . ($this->DataType == null ? "NULL" : $this->DataType->ID) . ", ";
+ $query .= "property_DefaultValue = " . $this->DefaultValue == null ? "NULL" : ("'" . $this->DefaultValue . "'") . ", ";
+ $query .= "property_IsRequired = " . ($this->Required ? "1" : "0") . ", ";
+ $query .= " WHERE property_ID = " . $this->ID;
+ }
+
+ $result = $MySQL->query($query);
+ if ($result === false) return false;
+
+ if ($this->ID == null)
+ {
+ $this->ID = $MySQL->insert_id;
+ }
+
+ return true;
+ }
+ }
+ class TenantObjectPropertyValue
+ {
+ public $Property;
+ public $Value;
+
+ public function __construct($property, $value)
+ {
+ $this->Property = $property;
+ $this->Value = $value;
+ }
+
+ public function Update()
+ {
+
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantProperty.inc.php b/PHP/Common/Include/Objects/TenantProperty.inc.php
new file mode 100644
index 00000000..068ba509
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantProperty.inc.php
@@ -0,0 +1,127 @@
+Name = $name;
+ $this->DataType = $dataType;
+ $this->Description = $description;
+ $this->DefaultValue = $defaultValue;
+ }
+
+ public function Decode($value)
+ {
+ if ($this->DataType == null) return $value;
+ return $this->DataType->Decode($value);
+ }
+ public function Encode($value)
+ {
+ if ($this->DataType == null) return $value;
+ return $this->DataType->Encode($value);
+ }
+
+ public function RenderColumn($value = null)
+ {
+ if ($this->DataType == null || $this->DataType->ColumnRendererCodeBlob == null)
+ {
+ if ($value == null)
+ {
+ echo($this->DefaultValue);
+ }
+ else
+ {
+ echo($value);
+ }
+ }
+ else
+ {
+ if ($value == null)
+ {
+ $this->DataType->RenderColumn($this->DefaultValue);
+ }
+ else
+ {
+ $this->DataType->RenderColumn($value);
+ }
+ }
+ }
+ public function RenderEditor($value = null, $name = null)
+ {
+ if ($name == null) $name = "Property_" . $this->ID;
+ if ($this->DataType == null || $this->DataType->ColumnRendererCodeBlob == null)
+ {
+ ?>
+
+ DataType->RenderEditor($this->DefaultValue, $name);
+ }
+ else
+ {
+ $this->DataType->RenderEditor($value, $name);
+ }
+ }
+ }
+
+ public static function GetByAssoc($values)
+ {
+ $item = new TenantProperty();
+ $item->ID = $values["property_ID"];
+ $item->Tenant = Tenant::GetByID($values["property_TenantID"]);
+ $item->Name = $values["property_Name"];
+ $item->Description = $values["property_Description"];
+ $item->DataType = DataType::GetByID($values["property_DataTypeID"]);
+ $item->DefaultValue = $item->DataType->Decode($values["property_DefaultValue"]);
+ return $item;
+ }
+
+ public static function Create($property, $tenant = null)
+ {
+ global $MySQL;
+
+ $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantProperties (property_TenantID, property_Name, property_Description, property_DataTypeID, property_DefaultValue) VALUES (";
+ $query .= ($tenant == null ? "NULL" : $tenant->ID) . ", ";
+ $query .= "'" . $MySQL->real_escape_string($property->Name) . "', ";
+ $query .= "'" . $MySQL->real_escape_string($property->Description) . "', ";
+ $query .= ($property->DataType == null ? "NULL" : $property->DataType->ID) . ", ";
+ $query .= ($property->DefaultValue == null ? "NULL" : "'" . $MySQL->real_escape_string($property->DataType->Encode($property->DefaultValue)) . "'");
+ $query .= ")";
+
+ $result = $MySQL->query($query);
+ if ($result === false)
+ {
+ Objectify::Log("Database error when trying to create a property on the tenant.", array
+ (
+ "DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")",
+ "Query" => $query,
+ "Property" => ($property == null ? ($propname == null ? "(null)" : $propname) : (is_string($property) ? $property : "#" . $property->ID))
+ ));
+ return false;
+ }
+ return true;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantQueryParameter.inc.php b/PHP/Common/Include/Objects/TenantQueryParameter.inc.php
new file mode 100644
index 00000000..6fc15147
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantQueryParameter.inc.php
@@ -0,0 +1,15 @@
+Name = $name;
+ $this->Value = $value;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantStringTableEntry.inc.php b/PHP/Common/Include/Objects/TenantStringTableEntry.inc.php
new file mode 100644
index 00000000..536bfeb8
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantStringTableEntry.inc.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/PHP/Common/Include/Objects/TenantType.inc.php b/PHP/Common/Include/Objects/TenantType.inc.php
new file mode 100644
index 00000000..9c123333
--- /dev/null
+++ b/PHP/Common/Include/Objects/TenantType.inc.php
@@ -0,0 +1,56 @@
+ID = $values["tenanttype_ID"];
+ $item->URL = $values["tenanttype_Title"];
+ $item->Description = $values["tenanttype_Description"];
+ return $item;
+ }
+ public static function Get($max = null)
+ {
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantTypes";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ $retval = array();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ $retval[] = TenantType::GetByAssoc($values);
+ }
+ return $retval;
+ }
+ public static function GetByID($id)
+ {
+ if (!is_numeric($id)) return null;
+
+ global $MySQL;
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "TenantTypes WHERE tenanttype_ID = " . $id;
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ if ($count == 0) return null;
+
+ $values = $result->fetch_assoc();
+ return TenantType::GetByAssoc($values);
+ }
+
+ public function ToJSON()
+ {
+ echo("{");
+ echo("\"ID\":" . $this->ID . ",");
+ echo("\"Title\":\"" . \JH\Utilities::JavaScriptDecode($this->Title, "\"") . "\",");
+ echo("\"Description\":\"" . \JH\Utilities::JavaScriptDecode($this->Description, "\"") . "\"");
+ echo("}");
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Images/Logo.png b/PHP/Manager/Images/Logo.png
new file mode 100644
index 00000000..d0d8cabd
Binary files /dev/null and b/PHP/Manager/Images/Logo.png differ
diff --git a/PHP/Manager/Images/Logo.xcf b/PHP/Manager/Images/Logo.xcf
new file mode 100644
index 00000000..e06b4be3
Binary files /dev/null and b/PHP/Manager/Images/Logo.xcf differ
diff --git a/PHP/Manager/Include/MasterPages/000-WebPage.inc.php b/PHP/Manager/Include/MasterPages/000-WebPage.inc.php
new file mode 100644
index 00000000..09c8d250
--- /dev/null
+++ b/PHP/Manager/Include/MasterPages/000-WebPage.inc.php
@@ -0,0 +1,23 @@
+StyleSheets[] = new WebStyleSheet("http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Workday/Main.css");
+ }
+
+ protected function BeforeContent()
+ {
+ ?>
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/000-Default/Main.inc.php b/PHP/Manager/Include/Modules/000-Default/Main.inc.php
new file mode 100644
index 00000000..9c4773d2
--- /dev/null
+++ b/PHP/Manager/Include/Modules/000-Default/Main.inc.php
@@ -0,0 +1,665 @@
+query($query);
+ if ($result->num_rows < 1) return false;
+ return true;
+ }
+
+ function CheckCredentials($admun, $admpw)
+ {
+ return ($admun == System::GetConfigurationValue("Administration.UserName") && $admpw == System::GetConfigurationValue("Administration.Password"));
+ }
+ function IsAdministrator()
+ {
+ if (!isset($_SESSION["admun"]) || !isset($_SESSION["admpw"])) return false;
+
+ $admun = $_SESSION["admun"];
+ $admpw = $_SESSION["admpw"];
+
+ return CheckCredentials($admun, $admpw);
+ }
+
+ System::$BeforeLaunchEventHandler = function($path)
+ {
+ if (!IsConfigured() && (!($path[0] == "setup")))
+ {
+ System::Redirect("~/setup");
+ return true;
+ }
+
+ if (!IsAdministrator() && (!($path[0] == "account" && $path[1] == "login.page")) && (!($path[0] == "setup")) && (!($path[0] == "favicon.ico")))
+ {
+ $path1 = implode("/", $path);
+ $_SESSION["LoginRedirectURL"] = "~/" . $path1;
+
+ System::Redirect("~/account/login.page");
+ return true;
+ }
+ return true;
+ };
+
+ System::$Modules[] = new Module("net.Objectify.TenantManager.Default", array
+ (
+ new ModulePage("", function($path)
+ {
+ $page = new WebPage();
+ $page->BeginContent();
+
+ $btng = new ButtonGroup("btng1");
+ $btng->Items[] = new ButtonGroupButton("btnDataCenters", "Data Centers", null, "~/Images/Buttons/DataCenters.png", "~/datacenter");
+ $btng->Items[] = new ButtonGroupButton("btnDataTypes", "Data Types", null, "~/Images/Buttons/DataTypes.png", "~/datatype");
+ $btng->Items[] = new ButtonGroupButton("btnTenantTypes", "Tenant Types", null, "~/Images/Buttons/TenantTypes.png", "~/tenanttype");
+ $btng->Items[] = new ButtonGroupButton("btnTenants", "Tenants", null, "~/Images/Buttons/Tenants.png", "~/tenant");
+ $btng->Items[] = new ButtonGroupButton("btnModules", "Modules", null, "~/Images/Buttons/Modules.png", "~/module");
+ $btng->Render();
+
+ $page->EndContent();
+ }),
+ new ModulePage("debug", function($path)
+ {
+ global $MySQL;
+
+ $page = new WebPage();
+ $page->BeginContent();
+ if (is_numeric($path[0]))
+ {
+ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "delete")
+ {
+ $query = "DELETE FROM " . System::GetConfigurationValue("Database.TablePrefix") . "DebugMessages WHERE message_ID = " . $path[0];
+ $result = $MySQL->query($query);
+ System::Redirect("~/debug");
+ }
+ else
+ {
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DebugMessages WHERE message_ID = " . $path[0];
+ $result = $MySQL->query($query);
+ $values = $result->fetch_assoc();
+
+ echo("Error Details ");
+ echo("" . $values["message_Content"] . "
");
+
+ echo("Parameters ");
+ echo("");
+ $query1 = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DebugMessageParameters WHERE mp_MessageID = " . $values["message_ID"];
+ $result1 = $MySQL->query($query1);
+ $count1 = $result1->num_rows;
+ echo("");
+ echo("Name ");
+ echo("Value ");
+ echo(" ");
+ for ($j = 0; $j < $count1; $j++)
+ {
+ $values1 = $result1->fetch_assoc();
+ echo("");
+ echo("");
+ echo($values1["mp_Name"]);
+ echo(" ");
+ echo("");
+ echo($values1["mp_Value"]);
+ echo(" ");
+ echo(" ");
+ }
+ echo("
");
+
+ echo("Backtrace ");
+ echo("");
+ $query1 = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DebugMessageBacktraces WHERE bt_MessageID = " . $values["message_ID"];
+ $result1 = $MySQL->query($query1);
+ $count1 = $result1->num_rows;
+ echo("");
+ echo("File name ");
+ echo("Line number ");
+ echo(" ");
+ for ($j = 0; $j < $count1; $j++)
+ {
+ $values1 = $result1->fetch_assoc();
+ echo("");
+ echo("");
+ echo($values1["bt_FileName"]);
+ echo(" ");
+ echo("");
+ echo($values1["bt_LineNumber"]);
+ echo(" ");
+ echo(" ");
+ }
+ echo("
");
+ echo("");
+ }
+ }
+ else
+ {
+ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "delete")
+ {
+ $query = "DELETE FROM " . System::GetConfigurationValue("Database.TablePrefix") . "DebugMessages";
+ $result = $MySQL->query($query);
+ System::Redirect("~/debug");
+ }
+ else
+ {
+ echo("");
+
+ echo("");
+ echo("");
+ echo("Tenant ");
+ echo("Severity ");
+ echo("Message ");
+ echo("Timestamp ");
+ echo("IP Address ");
+ echo(" ");
+
+ $query = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DebugMessages";
+ $result = $MySQL->query($query);
+ $count = $result->num_rows;
+ for ($i = 0; $i < $count; $i++)
+ {
+ $values = $result->fetch_assoc();
+ echo("");
+ echo("");
+ $tenant = Tenant::GetByID($values["message_TenantID"]);
+ if ($tenant != null)
+ {
+ echo("URL . "/") . "\">" . $tenant->URL . " ");
+ }
+ echo(" ");
+ echo("");
+ switch ($values["message_SeverityID"])
+ {
+ }
+ echo(" ");
+ echo("");
+ echo("");
+ echo($values["message_Content"]);
+ echo(" ");
+ echo(" ");
+ echo("");
+ echo($values["message_Timestamp"]);
+ echo(" ");
+ echo("");
+ echo($values["message_IPAddress"]);
+ echo(" ");
+ echo(" ");
+ }
+ echo("
");
+ }
+ }
+ $page->EndContent();
+ return true;
+ }),
+ new ModulePage("account", array
+ (
+ new ModulePage("login.page", function($path)
+ {
+ $page = new LoginPage();
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ if (isset($_POST["user_LoginID"]) && isset($_POST["user_Password"]))
+ {
+ $admun = $_POST["user_LoginID"];
+ $admpw = $_POST["user_Password"];
+
+ if (CheckCredentials($admun, $admpw))
+ {
+ $_SESSION["admun"] = $admun;
+ $_SESSION["admpw"] = $admpw;
+
+ if (isset($_SESSION["LoginRedirectURL"]))
+ {
+ System::Redirect($_SESSION["LoginRedirectURL"]);
+ }
+ else
+ {
+ System::Redirect("~/");
+ }
+ return true;
+ }
+ else
+ {
+ $page->InvalidCredentials = true;
+ }
+ }
+ }
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("logout.page", function($path)
+ {
+ $_SESSION["admun"] = null;
+ $_SESSION["admpw"] = null;
+ System::Redirect("~/");
+ return true;
+ })
+ )),
+ new ModulePage("tenant", array
+ (
+ new ModulePage("", function($path)
+ {
+ $page = new MainPage();
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("create", function($path)
+ {
+ if ($_SERVER["REQUEST_METHOD"] === "POST")
+ {
+ $tenant_URL = $_POST["tenant_URL"];
+ $tenant_Description = $_POST["tenant_Description"];
+
+ $tenant_DataCenters = array();
+ foreach ($_POST as $key => $value)
+ {
+ if (substr($key, 0, strlen("tenant_DataCenter_")) == "tenant_DataCenter_")
+ {
+ $id = substr($key, strlen("tenant_DataCenter_") + 1);
+ $tenant_DataCenters[] = DataCenter::GetByID($id);
+ }
+ }
+
+ $tenant_Status = ($_POST["tenant_Status"] == 1 ? TenantStatus::Enabled : TenantStatus::Disabled);
+ $tenant_Type = TenantType::GetByID($_POST["tenant_TypeID"]);
+ $tenant_PaymentPlan = PaymentPlan::GetByID($_POST["tenant_PaymentPlanID"]);
+ $tenant_BeginTimestamp = ($_POST["tenant_BeginTimestampValid"] == "1" ? null : $_POST["tenant_BeginTimestamp"]);
+ $tenant_EndTimestamp = ($_POST["tenant_EndTimestampValid"] == "1" ? null : $_POST["tenant_EndTimestamp"]);
+
+ $retval = Tenant::Create($tenant_URL, $tenant_Description, $tenant_Status, $tenant_Type, $tenant_PaymentPlan, $tenant_BeginTimestamp, $tenant_EndTimestamp, $tenant_DataCenters);
+
+ if ($retval == null)
+ {
+ global $MySQL;
+ echo($MySQL->error . " (" . $MySQL->errno . ")");
+ }
+ else
+ {
+ System::Redirect("~/tenant");
+ }
+ }
+ else
+ {
+ $page = new TenantPropertiesPage();
+ $page->Render();
+ return true;
+ }
+ }),
+ new ModulePage("modify", function($path)
+ {
+ if ($_SERVER["REQUEST_METHOD"] === "POST")
+ {
+ $tenant_URL = $_POST["tenant_URL"];
+
+ $tenant = Tenant::GetByURL($path[0]);
+
+ $tenant->URL = $_POST["tenant_URL"];
+ $tenant->Description = $_POST["tenant_Description"];
+ $tenant->Status = ($_POST["tenant_Status"] == 1 ? TenantStatus::Enabled : TenantStatus::Disabled);
+ $tenant->Type = TenantType::GetByID($_POST["tenant_TypeID"]);
+ $tenant->PaymentPlan = PaymentPlan::GetByID($_POST["tenant_PaymentPlanID"]);
+ $tenant->BeginTimestamp = ($_POST["tenant_BeginTimestampValid"] == "1" ? null : $_POST["tenant_BeginTimestamp"]);
+ $tenant->EndTimestamp = ($_POST["tenant_EndTimestampValid"] == "1" ? null : $_POST["tenant_EndTimestamp"]);
+
+ $retval = $tenant->Update();
+
+ if (!$retval)
+ {
+ global $MySQL;
+ echo($MySQL->error . " (" . $MySQL->errno . ")");
+ }
+ else
+ {
+ System::Redirect("~/tenant");
+ }
+ return true;
+ }
+ else
+ {
+ $page = new TenantPropertiesPage();
+ $page->Tenant = Tenant::GetByURL($path[0]);
+ $page->Render();
+ return true;
+ }
+ }),
+ new ModulePage("clone", function($path)
+ {
+ if ($_SERVER["REQUEST_METHOD"] === "POST")
+ {
+ $tenant_URL = $_POST["tenant_URL"];
+ $tenant_Description = $_POST["tenant_Description"];
+ $tenant_Status = ($_POST["tenant_Status"] == 1 ? TenantStatus::Enabled : TenantStatus::Disabled);
+ $tenant_Type = TenantType::GetByID($_POST["tenant_TypeID"]);
+ $tenant_PaymentPlan = PaymentPlan::GetByID($_POST["tenant_PaymentPlanID"]);
+ $tenant_BeginTimestamp = ($_POST["tenant_BeginTimestampValid"] == "1" ? null : $_POST["tenant_BeginTimestamp"]);
+ $tenant_EndTimestamp = ($_POST["tenant_EndTimestampValid"] == "1" ? null : $_POST["tenant_EndTimestamp"]);
+
+ $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
+ {
+ System::Redirect("~/tenant");
+ }
+ }
+ else
+ {
+ $page = new TenantPropertiesPage();
+ $page->Tenant = Tenant::GetByURL($path[0]);
+ $page->Render();
+ return true;
+ }
+ }),
+ new ModulePage("delete", function($path)
+ {
+ if ($_SERVER["REQUEST_METHOD"] === "POST")
+ {
+ if ($_POST["Confirm"] == "1")
+ {
+ $tenant = Tenant::GetByURL($path[0]);
+ if ($tenant->Delete())
+ {
+ System::Redirect("~/tenant");
+ }
+ else
+ {
+ global $MySQL;
+ echo($MySQL->error . " (" . $MySQL->errno . ")");
+ }
+ }
+ }
+ else
+ {
+ $page = new ConfirmOperationPage();
+ $page->ReturnButtonURL = "~/tenant";
+ $page->Message = "Are you sure you want to delete the tenant '" . $path[0] . "'? This action cannot be undone, and will destroy any and all data associated with that tenant.";
+ $page->Render();
+ return true;
+ }
+ }),
+ new ModulePage("manage", function($path)
+ {
+ if ($path[1] == "")
+ {
+ $tenant = Tenant::GetByURL($path[0]);
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ $properties = $tenant->GetProperties();
+ foreach ($properties as $property)
+ {
+ $tenant->SetPropertyValue($property, $_POST["Property_" . $property->ID]);
+ }
+ System::Redirect("~/tenant/manage/" . $path[0]);
+ return true;
+ }
+ else
+ {
+ $page = new TenantManagementPage();
+ $page->Tenant = $tenant;
+ $page->Render();
+ return true;
+ }
+ }
+ else
+ {
+ switch ($path[1])
+ {
+ case "modules":
+ {
+ $page = new TenantModuleManagementPage();
+ $page->Tenant = Tenant::GetByURL($path[0]);
+ $page->Module = \Objectify\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();
+ $page->CurrentTenant = $tenant;
+ $page->CurrentObject = $object;
+ $page->Render();
+ break;
+ }
+ }
+ }
+ case "methods":
+ {
+ switch ($path[4])
+ {
+ case "static":
+ {
+ $tenant = Tenant::GetByURL($path[0]);
+ $object = TenantObject::GetByID($path[2]);
+ $method = TenantObjectMethod::GetByID($path[5]);
+
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ $method->CodeBlob = $_POST["method_CodeBlob"];
+ $method->Update();
+
+ System::Redirect("~/tenant/manage/" . $tenant->URL . "/objects/" . $object->ID);
+ return true;
+ }
+
+ $page = new TenantObjectMethodManagementPage();
+ $page->CurrentTenant = $tenant;
+ $page->CurrentObject = $object;
+ $page->CurrentMethod = $method;
+ $page->Render();
+ break;
+ }
+ case "instance":
+ {
+ $page = new TenantObjectMethodManagementPage();
+ $page->CurrentTenant = Tenant::GetByURL($path[0]);
+ $page->CurrentObject = TenantObject::GetByID($path[2]);
+ $page->CurrentMethod = TenantObjectInstanceMethod::GetByID($path[5]);
+ $page->Render();
+ break;
+ }
+ }
+ break;
+ }
+ case "":
+ {
+ $tenant = Tenant::GetByURL($path[0]);
+ $object = TenantObject::GetByID($path[2]);
+
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ $count = $_POST["InstanceProperty_NewPropertyCount"];
+ for ($i = $count; $i > 0; $i--)
+ {
+ $name = $_POST["InstanceProperty_" . $i . "_Name"];
+ $dataType = DataType::GetByID($_POST["InstanceProperty_" . $i . "_DataTypeID"]);
+ $defaultValue = $_POST["InstanceProperty_" . $i . "_DefaultValue"];
+
+ $object->CreateInstanceProperty(new TenantObjectInstanceProperty($name, $dataType, $defaultValue));
+ }
+
+ System::Redirect("~/tenant/manage/" . $tenant->URL . "/objects/" . $object->ID);
+ return true;
+ }
+ else
+ {
+ $page = new TenantObjectManagementPage();
+ $page->CurrentTenant = $tenant;
+ $page->CurrentObject = $object;
+ $page->Render();
+ }
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ return true;
+ }),
+ new ModulePage("launch", function($path)
+ {
+ $tenant = Tenant::GetByURL($path[0]);
+ header("Location: http://" . $tenant->DataCenters->Items[0]->HostName . "/" . $tenant->URL);
+ })
+ )),
+ new ModulePage("module", array
+ (
+ new ModulePage("", function($path)
+ {
+ $page = new ModuleMainPage();
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("modify", function($path)
+ {
+ $module = \Objectify\Objects\Module::GetByID($path[0], true);
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ $module->Title = $_POST["module_Title"];
+ $module->Description = $_POST["module_Description"];
+ $module->Update();
+
+ System::Redirect("~/module/modify/" . $path[0]);
+ }
+ else
+ {
+ $page = new ModuleManagementPage();
+ $page->Module = $module;
+ $page->Render();
+ }
+ return true;
+ })
+ )),
+ new ModulePage("datacenter", array
+ (
+ new ModulePage("", function($path)
+ {
+ $page = new DataCenterMainPage();
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("create", function($path)
+ {
+ $datacenter = new DataCenter();
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ $datacenter->Title = $_POST["datacenter_Title"];
+ $datacenter->Description = $_POST["datacenter_Description"];
+ $datacenter->HostName = $_POST["datacenter_HostName"];
+ $datacenter->Update();
+
+ System::Redirect("~/datacenter");
+ }
+ else
+ {
+ $page = new DataCenterManagementPage();
+ $page->DataCenter = null;
+ $page->Render();
+ }
+ return true;
+ }),
+ new ModulePage("modify", function($path)
+ {
+ $datacenter = DataCenter::GetByID($path[0]);
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ $datacenter->Title = $_POST["datacenter_Title"];
+ $datacenter->Description = $_POST["datacenter_Description"];
+ $datacenter->HostName = $_POST["datacenter_HostName"];
+ $datacenter->Update();
+
+ System::Redirect("~/datacenter/modify/" . $path[0]);
+ }
+ else
+ {
+ $page = new DataCenterManagementPage();
+ $page->DataCenter = $datacenter;
+ $page->Render();
+ }
+ return true;
+ })
+ ))
+ ));
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/DefaultTenant.inc.php b/PHP/Manager/Include/Modules/001-Setup/DefaultTenant.inc.php
new file mode 100644
index 00000000..7de4a4f7
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/DefaultTenant.inc.php
@@ -0,0 +1,41 @@
+CreateProperty(new TenantProperty("ApplicationTitle", DataType::GetByName("Text"), "The title of your application. This is displayed in various areas around the site.", "My Application"));
+ $tenant->CreateProperty(new TenantProperty("ApplicationDescription", DataType::GetByName("Text"), "A short description of your application. This will appear in search results and other areas that use the HTML META description attribute.", "A versatile, modern, data-driven Web application powered by Objectify."));
+
+ // Install the resource bundles
+ $objResourceBundle = $tenant->GetObject("ResourceBundle");
+ $instRBCommon = $objResourceBundle->CreateInstance(array
+ (
+ new TenantObjectInstancePropertyValue("Name", "Common")
+ ));
+ $instRBDefault = $objResourceBundle->CreateInstance(array
+ (
+ new TenantObjectInstancePropertyValue("Name", "Default")
+ ));
+
+ $tenant->CreateProperty(new TenantProperty
+ (
+ "ResourceBundles", DataType::GetByName("MultipleInstance"), "The resource bundles that are loaded with this tenant.", new MultipleInstanceProperty
+ (
+ array($instRBDefault),
+ array($objResourceBundle)
+ )
+ ));
+
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Main.inc.php b/PHP/Manager/Include/Modules/001-Setup/Main.inc.php
new file mode 100644
index 00000000..9703f790
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Main.inc.php
@@ -0,0 +1,351 @@
+
+
+
+
+
+
+
+
+
+
+
+
+" . $FileName);
+ if ($f === false) return false;
+
+ fwrite($f, " $value)
+ {
+ $skip = false;
+ foreach ($preinstalledKeys as $pikey)
+ {
+ if ($key == $pikey)
+ {
+ $skip = true;
+ break;
+ }
+ }
+ if ($skip) continue;
+ fwrite($f, "\tSystem::\$Configuration[\"" . $key . "\"] = " . VariableToString($value) . ";\n");
+ }
+ fwrite($f, "?>\n");
+ fclose($f);
+ return true;
+ }
+ ?>
+
+
" style="height: 200px;" />
+
+
+ is configuring your initial instance. This would be a good time for a coffee break...
+
+
+Items[0]->Code . ": " . DataFX::$Errors->Items[0]->Message);
+ Message(DataFX::$Errors->Items[0]->Query);
+ return true;
+ }
+
+ // create the Users table
+ /*
+ $tables = array
+ (
+ new Table("MarketResourceBankDetails", "bankdetail_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ResourceTypeID", "INT", null, null, false),
+ new Column("Name", "VARCHAR", 50, null, false),
+ new Column("TitleSingular", "VARCHAR", 100, null, false),
+ new Column("TitlePlural", "VARCHAR", 100, null, false)
+ )),
+ new Table("Tasks", "task_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("TenantID", "INT", null, null, false),
+ new Column("Title", "VARCHAR", 100, null, false),
+ new Column("URL", "LONGTEXT", null, null, false)
+ )),
+ new Table("Themes", "theme_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("TenantID", "INT", null, null, false),
+ new Column("Name", "VARCHAR", 100, null, false),
+ new Column("Title", "VARCHAR", 100, null, false),
+ new Column("CreationUserID", "INT", null, null, false),
+ new Column("CreationTimestamp", "DATETIME", null, null, false)
+ )),
+ new Table("UserEquippedItems", "equippeditem_", array
+ (
+ new Column("UserID", "INT", null, null, false),
+ new Column("ItemID", "INT", null, null, false)
+ )),
+ new Table("UserInventoryFolders", "inventoryitem_", array
+ (
+ new Column("ID", "INT", null, null, false),
+ new Column("Title", "VARCHAR", 100, null, false),
+ new Column("ParentFolderID", "INT", null, null, true)
+ )),
+ new Table("UserInventoryItems", "inventoryitem_", array
+ (
+ new Column("UserID", "INT", null, null, false),
+ new Column("ItemID", "INT", null, null, false),
+ new Column("ParentFolderID", "INT", null, null, true)
+ )),
+ new Table("UserProfileContents", "content_", array
+ (
+ // posts by the user on their profile. can be scrolled back and forth like a journal. supports HTML!
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("TenantID", "INT", null, null, false),
+ new Column("CreationUserID", "INT", null, null, false),
+ new Column("CreationTimestamp", "DATETIME", null, null, false),
+ new Column("Content", "LONGTEXT", null, null, false)
+ )),
+ new Table("UserProfileContentFeedbacks", "feedback_", array
+ (
+ // likes and dislikes for user profile contents
+ new Column("ContentID", "INT", null, null, false),
+ new Column("FeedbackTypeID", "INT", null, null, false),
+ new Column("Comments", "VARCHAR", 200, null, false),
+ new Column("CreationUserID", "INT", null, null, false),
+ new Column("CreationTimestamp", "DATETIME", null, null, false)
+ ))
+ );
+ */
+
+ $tables = array();
+
+ $tablefilepath = dirname(__FILE__) . "/Tables/*.inc.php";
+ $tablefiles = glob($tablefilepath);
+ foreach ($tablefiles as $tablefile)
+ {
+ require($tablefile);
+ }
+
+ foreach ($tables as $table)
+ {
+ if ($table->Exists())
+ {
+ Message("Table '" . $table->Name . "' already exists, skipping creation");
+ }
+ else
+ {
+ $retval = $table->Create();
+ if ($retval)
+ {
+ Success("Created table '" . $table->Name . "'");
+ }
+ else
+ {
+ Failure("Could not create table '" . $table->Name . "'");
+ Message("Database returned error " . DataFX::$Errors->Items[0]->Code . ": " . DataFX::$Errors->Items[0]->Message);
+ Message(DataFX::$Errors->Items[0]->Query);
+ }
+ }
+ }
+
+ $tenant = Tenant::Create($_POST["Application_DefaultTenant"], "The default tenant for " . System::$Configuration["Application.Name"] . ".");
+ $tablefilepath = dirname(__FILE__) . "/TenantObjects/*.inc.php";
+ $tablefiles = glob($tablefilepath);
+ foreach ($tablefiles as $tablefile)
+ {
+ require($tablefile);
+ }
+
+ require(dirname(__FILE__) . "/DefaultTenant.inc.php");
+?>
+
+ BeginContent();
+?>
+
+
" style="height: 200px;" />
+
+
+ Please provide some information about your server to create the initial tenant. Other
+ tenants may be created and removed at any time by entering the Administrator Control Panel.
+
+
+EndContent();
+ return true;
+ },
+ function($path)
+ {
+ $enabled = false;
+ if (isset(System::$Configuration["Setup.Enabled"]))
+ {
+ $enabled = (System::$Configuration["Setup.Enabled"] == "true");
+ }
+ if (!$enabled)
+ {
+ $page = new \WebFX\WebPage();
+ $page->Title = "Configuration Error";
+ $page->BeginContent();
+ echo("This Objectify installation has not been configured. Please contact the server administrator.
");
+ $page->EndContent();
+ return false;
+ }
+ })
+ ));
+?>
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/000-DataTypes.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/000-DataTypes.inc.php
new file mode 100644
index 00000000..5ed59ae0
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/000-DataTypes.inc.php
@@ -0,0 +1,324 @@
+" . $input . "");
+EOD
+),
+ new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
+ echo("");
+EOD
+)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "CodeBlob"),
+ new RecordColumn("Description", "Allows you to enter script code with a special text editor."),
+ new RecordColumn("EncoderCodeBlob", null),
+ new RecordColumn("DecoderCodeBlob", null),
+ new RecordColumn("ColumnRendererCodeBlob", <<<'EOD'
+ echo("" . $input . "
");
+EOD
+),
+ new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
+ echo("");
+EOD
+)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "Number"),
+ new RecordColumn("Description", "Stores numeric data."),
+ new RecordColumn("EncoderCodeBlob", null),
+ new RecordColumn("DecoderCodeBlob", null),
+ new RecordColumn("ColumnRendererCodeBlob", null),
+ new RecordColumn("EditorRendererCodeBlob", null)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "Boolean"),
+ new RecordColumn("Description", "Stores a true/false or yes/no value."),
+ new RecordColumn("EncoderCodeBlob", null),
+ new RecordColumn("DecoderCodeBlob", null),
+ new RecordColumn("ColumnRendererCodeBlob", <<<'EOD'
+echo(" ");
+EOD
+),
+ new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
+echo(" ");
+EOD
+)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "Measurement"),
+ new RecordColumn("Description", "Stores measurement data, which is a double-precision floating-point number followed by a unit of measurement."),
+ new RecordColumn("EncoderCodeBlob", null),
+ new RecordColumn("DecoderCodeBlob", null),
+ new RecordColumn("ColumnRendererCodeBlob", null),
+ new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
+echo(" ");
+echo("px ");
+echo("pt ");
+echo("em ");
+echo("% ");
+echo(" ");
+EOD
+)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "DateTime"),
+ new RecordColumn("Description", "Stores a date and time value."),
+ new RecordColumn("EncoderCodeBlob", null),
+ new RecordColumn("DecoderCodeBlob", null),
+ new RecordColumn("ColumnRendererCodeBlob", null),
+ new RecordColumn("EditorRendererCodeBlob", null)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "SingleInstance"),
+ new RecordColumn("Description", "Represents a property that returns a single TenantObjectInstance object."),
+ new RecordColumn("EncoderCodeBlob", <<<'EOD'
+// $input should be a TenantObjectInstance
+if ($input == null)
+{
+ $bt = debug_backtrace();
+ trigger_error("SingleInstance::Encoder - input is null, did you mean to pass in a blank SingleInstanceProperty?, in " . $bt["file"] . "::" . $bt["function"] . " on line " . $bt["line"] . "; ", E_USER_WARNING);
+ return "";
+}
+// encode the property by simply storing the instance ID in the property value.
+$output = "";
+$count = count($input->ValidObjects);
+for ($i = 0; $i < $count; $i++)
+{
+ $output .= $input->ValidObjects[$i]->ID;
+ if ($i < $count - 1) $output .= ",";
+}
+$output .= ":";
+if ($input != null)
+{
+ if ($input->GetInstance() != null) $output .= $input->GetInstance()->ID;
+}
+return $output;
+EOD
+),
+ new RecordColumn("DecoderCodeBlob", <<<'EOD'
+// $input should be a String in the format t0,t1,t2:i0,i1,i2,i3... where tx is an ID of a TenantObject that is valid in the property and ix is an ID of a TenantObjectInstance
+// encode the property by simply storing the instance ID of each instance, separated by commas, in the property value.
+$dcb = explode(":", $input);
+$validObjects = explode(",", $dcb[0]);
+$instance = $dcb[1];
+$output = new SingleInstanceProperty();
+
+// loop through all the valid objects and add them to the MultipleInstanceProperty
+$count = count($validObjects);
+for ($i = 0; $i < $count; $i++)
+{
+ $output->ValidObjects[] = TenantObject::GetByID($validObjects[$i]);
+}
+
+// assign the instance
+$output->Instance = TenantObjectInstance::GetByID($instance);
+return $output;
+EOD
+),
+ new RecordColumn("ColumnRendererCodeBlob", <<<'EOD'
+$inst = $input->Instance;
+echo("");
+ echo("
");
+ echo("
");
+echo("
");
+EOD
+),
+ new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
+$inst = $input->Instance;
+echo("");
+EOD
+)
+ )),
+ new Record(array
+ (
+ new RecordColumn("Name", "MultipleInstance"),
+ new RecordColumn("Description", "Represents a property that returns an array of TenantObjectInstance objects."),
+ new RecordColumn("EncoderCodeBlob", <<<'EOD'
+// $input should be an array of TenantObjectInstance objects
+// encode the property by simply storing the instance ID of each instance, separated by commas, in the property value. the list of valid
+// object types is stored in the first part of the property, separated by a colon.
+if ($input == null)
+{
+ PhoenixSNS::Log("MultipleInstance::Encoder input is null - did you mean to pass in a blank MultipleInstanceProperty?");
+ return "";
+}
+
+$output = "";
+$count = count($input->ValidObjects);
+for ($i = 0; $i < $count; $i++)
+{
+ $output .= $input->ValidObjects[$i]->ID;
+ if ($i < $count - 1) $output .= ",";
+}
+$output .= ":";
+$insts = $input->GetInstances();
+$i = 0;
+$count = count($insts);
+foreach ($insts as $inst)
+{
+ $output .= $inst->ID;
+ if ($i < $count - 1) $output .= ",";
+ $i++;
+}
+return $output;
+EOD
+),
+ new RecordColumn("DecoderCodeBlob", <<<'EOD'
+// $input should be a String in the format t0,t1,t2:i0,i1,i2,i3... where tx is an ID of a TenantObject that is valid in the property and ix is an ID of a TenantObjectInstance
+// encode the property by simply storing the instance ID of each instance, separated by commas, in the property value.
+if ($input == "")
+{
+ $bt = debug_backtrace();
+ trigger_error("MultipleInstance::Decoder - input is null, did you mean to pass in a blank MultipleInstanceProperty?, in " . $bt["file"] . "::" . $bt["function"] . " on line " . $bt["line"] . "; ", E_USER_WARNING);
+ return null;
+}
+
+$dcb = explode(":", $input);
+$validObjects = explode(",", $dcb[0]);
+$instances = explode(",", $dcb[1]);
+$output = new MultipleInstanceProperty();
+
+// loop through all the valid objects and add them to the MultipleInstanceProperty
+$count = count($validObjects);
+for ($i = 0; $i < $count; $i++)
+{
+ $output->ValidObjects[] = TenantObject::GetByID($validObjects[$i]);
+}
+
+// loop through all of the instances and add them to the MultipleInstanceProperty
+$count = count($instances);
+for ($i = 0; $i < $count; $i++)
+{
+ $output->AddInstance(TenantObjectInstance::GetByID($instances[$i]));
+}
+return $output;
+EOD
+),
+ new RecordColumn("ColumnRendererCodeBlob", <<<'EOD'
+if ($input == null) return;
+if (!is_object($input) || (get_class($input) != "PhoenixSNS\\Objects\\MultipleInstanceProperty"))
+{
+ $bt = debug_backtrace();
+ trigger_error("Expected MultipleInstanceProperty, got something else in " . $bt[1]["file"] . "::" . $bt[1]["function"] . " at line " . $bt[1]["line"], E_USER_WARNING);
+ return;
+}
+$insts = $input->GetInstances();
+echo("");
+EOD
+),
+ new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
+if ($input == null) return;
+if (!is_object($input) || (get_class($input) != "PhoenixSNS\\Objects\\MultipleInstanceProperty"))
+{
+ $bt = debug_backtrace();
+ trigger_error("Expected MultipleInstanceProperty, got something else in " . $bt[1]["file"] . "::" . $bt[1]["function"] . " at line " . $bt[1]["line"], E_USER_WARNING);
+ return;
+}
+$insts = $input->GetInstances();
+echo("");
+EOD
+)
+ ))
+ ));
+ $tables[] = $tblDataTypes;
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/000-Languages.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/000-Languages.inc.php
new file mode 100644
index 00000000..04067797
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/000-Languages.inc.php
@@ -0,0 +1,20 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/000-Modules.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/000-Modules.inc.php
new file mode 100644
index 00000000..a0f4edc6
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/000-Modules.inc.php
@@ -0,0 +1,168 @@
+ForeignKeys = array
+ (
+ new TableForeignKey("ModuleID", new TableForeignKeyColumn($tblModules, $tblModules->GetColumnByName("ID")))
+ );
+ $tables[] = $tblModuleMenuItems;
+
+ $tblModuleObjects = new Table("ModuleObjects", "object_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ModuleID", "INT", null, null, true),
+ new Column("ParentObjectID", "INT", null, null, true),
+ new Column("Title", "VARCHAR", 256, null, true),
+ new Column("Description", "LONGTEXT", null, null, true)
+ ),
+ array
+ (
+ new Record(array
+ (
+ new RecordColumn("ModuleID", 7),
+ new RecordColumn("Title", "Game")
+ ))
+ ));
+ $tblModuleObjects->ForeignKeys = array
+ (
+ new TableForeignKey("ModuleID", new TableForeignKeyColumn($tblModules, $tblModules->GetColumnByName("ID"))),
+ new TableForeignKey("ParentObjectID", new TableForeignKeyColumn($tblModuleObjects, $tblModuleObjects->GetColumnByName("ID")))
+ );
+ $tables[] = $tblModuleObjects;
+
+ $tblModulePages = new Table("ModulePages", "modulepage_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ModuleID", "INT", null, null, true),
+ new Column("ParentPageID", "INT", null, null, true),
+ new Column("URL", "VARCHAR", 1024, null, true),
+ new Column("Content", "LONGTEXT", null, null, true)
+ ),
+ array
+ (
+ new Record(array
+ (
+ new RecordColumn("ModuleID", 1),
+ new RecordColumn("URL", "groups")
+ )),
+ new Record(array
+ (
+ new RecordColumn("ModuleID", 1),
+ new RecordColumn("URL", "pages")
+ )),
+ new Record(array
+ (
+ new RecordColumn("ModuleID", 1),
+ new RecordColumn("URL", "forums")
+ ))
+ ));
+ $tblModulePages->ForeignKeys = array
+ (
+ new TableForeignKey("ModuleID", new TableForeignKeyColumn($tblModules, $tblModules->GetColumnByName("ID"))),
+ new TableForeignKey("ParentPageID", new TableForeignKeyColumn($tblModulePages, $tblModulePages->GetColumnByName("ID")))
+ );
+ $tables[] = $tblModulePages;
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/001-Tenants.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/001-Tenants.inc.php
new file mode 100644
index 00000000..42797d3d
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/001-Tenants.inc.php
@@ -0,0 +1,78 @@
+UniqueKeys = array
+ (
+ new TableKey(array
+ (
+ new TableKeyColumn("URL")
+ ))
+ );
+ $tables[] = $tblTenants;
+
+ $tblTenantProperties = new Table("TenantProperties", "property_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("TenantID", "INT", null, null, true),
+ new Column("Name", "VARCHAR", 256, null, false),
+ new Column("Description", "LONGTEXT", null, null, true),
+ new Column("DataTypeID", "INT", null, null, false),
+ new Column("DefaultValue", "LONGBLOB", null, null, true)
+ ));
+ $tblTenantProperties->ForeignKeys = array
+ (
+ new TableForeignKey("TenantID", new TableForeignKeyColumn($tblTenants, "ID")),
+ new TableForeignKey("DataTypeID", new TableForeignKeyColumn($tblDataTypes, "ID"))
+ );
+ $tables[] = $tblTenantProperties;
+
+ $tblTenantPropertyValues = new Table("TenantPropertyValues", "propval_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("PropertyID", "INT", null, null, false, true, true),
+ new Column("Value", "LONGTEXT", null, null, true)
+ ));
+ $tblTenantPropertyValues->ForeignKeys = array
+ (
+ new TableForeignKey("PropertyID", new TableForeignKeyColumn($tblTenantProperties, "ID"))
+ );
+ $tables[] = $tblTenantPropertyValues;
+
+ $tblTenantModules = new Table("TenantModules", "tenantmodule_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("TenantID", "INT", null, null, false),
+ new Column("ModuleID", "INT", null, null, false)
+ ));
+ $tblTenantModules->ForeignKeys = array
+ (
+ new TableForeignKey("TenantID", new TableForeignKeyColumn($tblTenants, "ID"))
+ );
+ $tables[] = $tblTenantModules;
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/002-TenantObjects.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/002-TenantObjects.inc.php
new file mode 100644
index 00000000..481e6ae2
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/002-TenantObjects.inc.php
@@ -0,0 +1,197 @@
+ForeignKeys = array
+ (
+ new TableForeignKey("TenantID", new TableForeignKeyColumn($tblTenants, $tblTenants->GetColumnByName("ID"))),
+ new TableForeignKey("ModuleID", new TableForeignKeyColumn($tblModules, $tblModules->GetColumnByName("ID"))),
+ new TableForeignKey("ParentObjectID", new TableForeignKeyColumn($tblTenantObjects, $tblTenantObjects->GetColumnByName("ID")))
+ );
+ $tables[] = $tblTenantObjects;
+
+ $tblTenantObjectTitles = new Table("TenantObjectTitles", "entry_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false),
+ new Column("LanguageID", "INT", null, null, false),
+ new Column("Value", "LONGTEXT", null, null, false)
+ ));
+ $tblTenantObjectTitles->ForeignKeys = array
+ (
+ new TableForeignKey("ObjectID", new TableForeignKeyColumn($tblTenantObjects, $tblTenantObjects->GetColumnByName("ID"))),
+ new TableForeignKey("LanguageID", new TableForeignKeyColumn($tblLanguages, $tblLanguages->GetColumnByName("ID")))
+ );
+ $tables[] = $tblTenantObjectTitles;
+
+ $tblTenantObjectDescriptions = new Table("TenantObjectDescriptions", "entry_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false),
+ new Column("LanguageID", "INT", null, null, false),
+ new Column("Value", "LONGTEXT", null, null, false)
+ ));
+ $tblTenantObjectDescriptions->ForeignKeys = array
+ (
+ new TableForeignKey("ObjectID", new TableForeignKeyColumn($tblTenantObjects, $tblTenantObjects->GetColumnByName("ID"))),
+ new TableForeignKey("LanguageID", new TableForeignKeyColumn($tblLanguages, $tblLanguages->GetColumnByName("ID")))
+ );
+ $tables[] = $tblTenantObjectDescriptions;
+
+ // Available static properties for the objects.
+ $tblTenantObjectProperties = new Table("TenantObjectProperties", "property_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false),
+ new Column("Name", "VARCHAR", 256, null, true),
+ new Column("DataTypeID", "INT", null, null, true),
+ new Column("DefaultValue", "LONGBLOB", null, null, true),
+ new Column("IsRequired", "INT", null, 0, false),
+ new Column("EnumerationID", "INT", null, null, true),
+ new Column("RequireChoiceFromEnumeration", "INT", null, 0, false),
+ new Column("ColumnVisible", "INT", null, 0, false)
+ ));
+ $tblTenantObjectProperties->ForeignKeys = array
+ (
+ new TableForeignKey("ObjectID", new TableForeignKeyColumn($tblTenantObjects, "ID")),
+ new TableForeignKey("DataTypeID", new TableForeignKeyColumn($tblDataTypes, "ID"))
+ );
+ $tables[] = $tblTenantObjectProperties;
+
+ // Values for static properties of objects.
+ $tblTenantObjectPropertyValues = new Table("TenantObjectPropertyValues", "propval_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("PropertyID", "INT", null, null, false),
+ new Column("Value", "LONGBLOB", null, null, true)
+ ));
+ $tblTenantObjectPropertyValues->ForeignKeys = array
+ (
+ new TableForeignKey("PropertyID", new TableForeignKeyColumn($tblTenantObjectProperties, "ID"))
+ );
+ $tables[] = $tblTenantObjectPropertyValues;
+
+ // Instances of the objects.
+ $tblTenantObjectInstances = new Table("TenantObjectInstances", "instance_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false)
+ ));
+ $tblTenantObjectInstances->ForeignKeys = array
+ (
+ new TableForeignKey("ObjectID", new TableForeignKeyColumn($tblTenantObjects, "ID"))
+ );
+ $tables[] = $tblTenantObjectInstances;
+
+ // Properties of the object instances.
+ $tblTenantObjectInstanceProperties = new Table("TenantObjectInstanceProperties", "property_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false),
+ new Column("Name", "VARCHAR", 256, null, true),
+ new Column("DataTypeID", "INT", null, null, true),
+ new Column("DefaultValue", "LONGBLOB", null, null, true),
+ new Column("IsRequired", "INT", null, 0, false),
+ new Column("EnumerationID", "INT", null, null, true),
+ new Column("RequireChoiceFromEnumeration", "INT", null, 0, false),
+ new Column("ColumnVisible", "INT", null, 0, false)
+ ));
+ $tblTenantObjectInstanceProperties->ForeignKeys = array
+ (
+ new TableForeignKey("ObjectID", new TableForeignKeyColumn($tblTenantObjects, "ID")),
+ new TableForeignKey("DataTypeID", new TableForeignKeyColumn($tblDataTypes, "ID"))
+ );
+ $tables[] = $tblTenantObjectInstanceProperties;
+
+ // Values of the object instance properties.
+ $tblTenantObjectInstancePropertyValues = new Table("TenantObjectInstancePropertyValues", "propval_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("InstanceID", "INT", null, null, false),
+ new Column("PropertyID", "INT", null, null, false),
+ new Column("Value", "LONGBLOB", null, null, false)
+ ));
+ $tblTenantObjectInstancePropertyValues->PrimaryKey = new TableKey(array
+ (
+ new TableKeyColumn("InstanceID"),
+ new TableKeyColumn("PropertyID")
+ ));
+ $tblTenantObjectInstancePropertyValues->ForeignKeys = array
+ (
+ new TableForeignKey("InstanceID", new TableForeignKeyColumn($tblTenantObjectInstances, "ID")),
+ new TableForeignKey("PropertyID", new TableForeignKeyColumn($tblTenantObjectInstanceProperties, "ID"))
+ );
+ $tables[] = $tblTenantObjectInstancePropertyValues;
+
+ // Object static methods.
+ $tblTenantObjectMethods = new Table("TenantObjectMethods", "method_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false),
+ new Column("Name", "VARCHAR", 256, null, false),
+ new Column("CodeBlob", "LONGBLOB", null, null, false)
+ ));
+ $tblTenantObjectMethods->ForeignKeys = array
+ (
+ new TableForeignKey("ObjectID", new TableForeignKeyColumn($tblTenantObjects, "ID"))
+ );
+ $tables[] = $tblTenantObjectMethods;
+
+ // Object static method namespace references.
+ $tblTenantObjectMethodNamespaceReferences = new Table("TenantObjectMethodNamespaceReferences", "ns_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("MethodID", "INT", null, null, false),
+ new Column("Value", "VARCHAR", 256, null, false)
+ ));
+ $tblTenantObjectMethodNamespaceReferences->ForeignKeys = array
+ (
+ new TableForeignKey("MethodID", new TableForeignKeyColumn($tblTenantObjectMethods, "ID"))
+ );
+ $tables[] = $tblTenantObjectMethodNamespaceReferences;
+
+ // Object instance methods.
+ $tblTenantObjectInstanceMethods = new Table("TenantObjectInstanceMethods", "method_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("ObjectID", "INT", null, null, false),
+ new Column("Name", "VARCHAR", 256, null, false),
+ new Column("CodeBlob", "LONGBLOB", null, null, false)
+ ));
+ $tables[] = $tblTenantObjectInstanceMethods;
+
+ // Object static method namespace references.
+ $tblTenantObjectInstanceMethodNamespaceReferences = new Table("TenantObjectInstanceMethodNamespaceReferences", "ns_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("MethodID", "INT", null, null, false),
+ new Column("Value", "VARCHAR", 256, null, false)
+ ));
+ $tables[] = $tblTenantObjectInstanceMethodNamespaceReferences;
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/DataCenters.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/DataCenters.inc.php
new file mode 100644
index 00000000..1dad40b0
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/DataCenters.inc.php
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/DebugMessages.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/DebugMessages.inc.php
new file mode 100644
index 00000000..0e633ae6
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/DebugMessages.inc.php
@@ -0,0 +1,51 @@
+ForeignKeys = array
+ (
+ new TableForeignKey("MessageID", new TableForeignKeyColumn($tblDebugMessages, "ID"), TableForeignKeyReferenceOption::Cascade)
+ );
+ $tables[] = $tblDebugMessageBacktraces;
+
+ $tblDebugMessageParameters = new Table("DebugMessageParameters", "mp_", array
+ (
+ // $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
+ new Column("ID", "INT", null, null, false, true, true),
+ new Column("MessageID", "INT", null, null, false),
+ new Column("Name", "LONGTEXT", null, null, false),
+ new Column("Value", "LONGTEXT", null, null, true)
+ ));
+ $tblDebugMessageParameters->ForeignKeys = array
+ (
+ new TableForeignKey("MessageID", new TableForeignKeyColumn($tblDebugMessages, "ID"), TableForeignKeyReferenceOption::Cascade)
+ );
+ $tables[] = $tblDebugMessageParameters;
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/Languages.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/Languages.inc.php
new file mode 100644
index 00000000..9f30e6f8
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/Languages.inc.php
@@ -0,0 +1,213 @@
+Introduce yourself!")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "invitegroup"),
+ new RecordColumn("StringValue", "Invite this user to join a group")
+ )),
+
+ // === account/settings
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "personal"),
+ new RecordColumn("StringValue", "Personal Information")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "realname_label"),
+ new RecordColumn("StringValue", "What's your real name?")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "realname_example"),
+ new RecordColumn("StringValue", "Johnny Test")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "birthdate_label"),
+ new RecordColumn("StringValue", "When were you born?")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "birthdate_example"),
+ new RecordColumn("StringValue", "1994-03-25")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "email_label"),
+ new RecordColumn("StringValue", "What's your e-mail address?")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "email_example"),
+ new RecordColumn("StringValue", "somebody@phoenixsns.net")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "appearance"),
+ new RecordColumn("StringValue", "Appearance and Personalization")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "longname_label"),
+ new RecordColumn("StringValue", "What do you want to be called?")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "longname_example"),
+ new RecordColumn("StringValue", "Phenix the Great")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "startpage_label"),
+ new RecordColumn("StringValue", "When I log in, take me to:")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "shortname_label"),
+ new RecordColumn("StringValue", "Your site URL name:")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "shortname_example"),
+ new RecordColumn("StringValue", "phenix")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "language_label"),
+ new RecordColumn("StringValue", "Default language:")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "security"),
+ new RecordColumn("StringValue", "Security and Authentication")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "profile_visibility_label"),
+ new RecordColumn("StringValue", "Who can see my profile?")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "deactivate_account"),
+ new RecordColumn("StringValue", "Deactivate Account")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "use_with_caution"),
+ new RecordColumn("StringValue", "Please exercise great care when considering this option. Once done, it cannot be un-done.")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "deactivate_account_warning"),
+ new RecordColumn("StringValue", "Would you like to deactivate your account and lose all your items, resources, conversation history, friends, group memberships, and other site features? If so, click the link.")
+ )),
+ new Record(array
+ (
+ new RecordColumn("LanguageID", 1),
+ new RecordColumn("StringName", "deactivate_account_button"),
+ new RecordColumn("StringValue", "Yes, please deactivate my account now.")
+ ))
+ ));
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/PaymentPlans.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/PaymentPlans.inc.php
new file mode 100644
index 00000000..2f7e356f
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/PaymentPlans.inc.php
@@ -0,0 +1,24 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/SecurityPermissions.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/SecurityPermissions.inc.php
new file mode 100644
index 00000000..9cba3022
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/SecurityPermissions.inc.php
@@ -0,0 +1,126 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/TenantDataCenters.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/TenantDataCenters.inc.php
new file mode 100644
index 00000000..9a920dea
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/TenantDataCenters.inc.php
@@ -0,0 +1,23 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/TenantTypes.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/TenantTypes.inc.php
new file mode 100644
index 00000000..edb96f4c
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/TenantTypes.inc.php
@@ -0,0 +1,29 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Modules/001-Setup/Tables/Users.inc.php b/PHP/Manager/Include/Modules/001-Setup/Tables/Users.inc.php
new file mode 100644
index 00000000..683c06e5
--- /dev/null
+++ b/PHP/Manager/Include/Modules/001-Setup/Tables/Users.inc.php
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/000-LoginPage.inc.php b/PHP/Manager/Include/Pages/000-LoginPage.inc.php
new file mode 100644
index 00000000..3cbe562c
--- /dev/null
+++ b/PHP/Manager/Include/Pages/000-LoginPage.inc.php
@@ -0,0 +1,48 @@
+
+ Authentication Required
+ You must log in to view this page.
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/000-MainPage.inc.php b/PHP/Manager/Include/Pages/000-MainPage.inc.php
new file mode 100644
index 00000000..6cd5e46b
--- /dev/null
+++ b/PHP/Manager/Include/Pages/000-MainPage.inc.php
@@ -0,0 +1,116 @@
+
+ Tenant Management
+ There are tenants in total.
+
+
+ IsExpired())
+ {
+ $countExpired++;
+ }
+ else
+ {
+ $countActive++;
+ }
+ }
+ ?>
+ Active Tenants ()
+
+ Inactive Tenants ()
+
+
+ Tenant Name
+ Tenant Type
+ Data Centers
+ Payment Plan
+ Activation Date
+ Termination Date
+ Description
+ Actions
+
+ IsExpired()) continue;
+ ?>
+
+ URL)); ?>" target="_blank">URL); ?>
+ Type->Title); ?>
+ DataCenter->Title); ?>
+ PaymentPlan->Title); ?>
+ BeginTimestamp == null ? "(indefinite)" : $tenant->BeginTimestamp); ?>
+ EndTimestamp == null ? "(indefinite)" : $tenant->EndTimestamp); ?>
+ Description); ?>
+
+ URL)); ?>">Manage |
+ URL)); ?>">Edit |
+ URL)); ?>">Clone |
+ URL)); ?>">Delete
+
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/001-TenantPropertiesPage.inc.php b/PHP/Manager/Include/Pages/001-TenantPropertiesPage.inc.php
new file mode 100644
index 00000000..cfb2f2d2
--- /dev/null
+++ b/PHP/Manager/Include/Pages/001-TenantPropertiesPage.inc.php
@@ -0,0 +1,104 @@
+Tenant != null)
+ {
+ $this->Title = "Edit Tenant Configuration: " . $this->Tenant->URL;
+ }
+ else
+ {
+ $this->Title = "Create New Tenant";
+ }
+ }
+
+ protected function RenderContent()
+ {
+ ?>
+ Edit Tenant Configuration
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/002-ConfirmOperationPage.inc.php b/PHP/Manager/Include/Pages/002-ConfirmOperationPage.inc.php
new file mode 100644
index 00000000..37ee1263
--- /dev/null
+++ b/PHP/Manager/Include/Pages/002-ConfirmOperationPage.inc.php
@@ -0,0 +1,39 @@
+ReturnButtonURL = "~/";
+ }
+
+ protected function RenderContent()
+ {
+ ?>
+ Confirm Operation
+ Message); ?>
+
+
+
+ Cancel
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/003-TenantManagementPage.inc.php b/PHP/Manager/Include/Pages/003-TenantManagementPage.inc.php
new file mode 100644
index 00000000..363df834
--- /dev/null
+++ b/PHP/Manager/Include/Pages/003-TenantManagementPage.inc.php
@@ -0,0 +1,125 @@
+Title = "Manage Tenant: " . $this->Tenant->URL;
+ }
+
+ protected function RenderContent()
+ {
+ ?>
+ Tenant: Tenant->URL); ?>
+
+ TabPages[] = new TabPage("tabCustomProperties", "Custom Properties", null, null, null, function()
+ {
+ ?>
+
+
+ Tenant->GetProperties();
+ foreach ($properties as $property)
+ {
+ ?>
+
+ [+]
+ Name); ?>
+ Description); ?>
+ RenderEditor($this->Tenant->GetPropertyValue($property)); ?>
+
+
+
+ TabPages[] = new TabPage("tabEnabledModules", "Enabled Modules", null, null, null, function()
+ {
+ ?>
+ Click on a module name to configure the module on this tenant.
+
+ TabPages[] = new TabPage("tabGlobalObjects", "Global Objects", null, null, null, function()
+ {
+ ?>
+ Lists all of the objects that are available on this tenant that are not associated with a particular Module.
+
+ Render();
+ ?>
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/004-TenantModuleManagementPage.inc.php b/PHP/Manager/Include/Pages/004-TenantModuleManagementPage.inc.php
new file mode 100644
index 00000000..db81bf24
--- /dev/null
+++ b/PHP/Manager/Include/Pages/004-TenantModuleManagementPage.inc.php
@@ -0,0 +1,95 @@
+Module != null)
+ {
+ $this->Title = "Manage Tenant Module: " . $this->Module->Title . " on " . $this->Tenant->URL;
+ }
+ else
+ {
+ $this->Title = "Manage Tenant Modules: " . $this->Tenant->URL;
+ }
+ }
+
+ protected function RenderContent()
+ {
+ if ($this->Module != null)
+ {
+ ?>
+ Module: Module->Title); ?> on Tenant->URL); ?>
+ Module Configurable Properties
+
+
+ Tenant: Tenant->URL); ?>
+
+ Tenant Enabled Modules
+ Click on a module name to configure it
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/005-ModuleMainPage.inc.php b/PHP/Manager/Include/Pages/005-ModuleMainPage.inc.php
new file mode 100644
index 00000000..6a884177
--- /dev/null
+++ b/PHP/Manager/Include/Pages/005-ModuleMainPage.inc.php
@@ -0,0 +1,41 @@
+
+ Module Management
+ There are modules in total. Click a module name to configure that module.
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/006-ModuleManagementPage.inc.php b/PHP/Manager/Include/Pages/006-ModuleManagementPage.inc.php
new file mode 100644
index 00000000..212d3cc8
--- /dev/null
+++ b/PHP/Manager/Include/Pages/006-ModuleManagementPage.inc.php
@@ -0,0 +1,84 @@
+Title = "Manage Module: " . $this->Module->Title;
+ }
+
+ protected function RenderContent()
+ {
+ ?>
+ Module Management
+ Module->Title); ?>
+
+
+ Information
+
+
+ Application Menu Items
+
+
+ Title
+ Description
+ Target
+
+ Module->GetMainMenuItems();
+ foreach ($menuitems as $menuitem)
+ {
+ ?>
+
+ Title); ?>
+ Description); ?>
+ TargetURL); ?>
+
+
+
+
+ Module Pages
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/007-DataCenterMainPage.inc.php b/PHP/Manager/Include/Pages/007-DataCenterMainPage.inc.php
new file mode 100644
index 00000000..dc58d8ac
--- /dev/null
+++ b/PHP/Manager/Include/Pages/007-DataCenterMainPage.inc.php
@@ -0,0 +1,43 @@
+
+ Data Center Management
+ There are data centers in total. Click a data center name to configure that data center.
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/008-DataCenterManagementPage.inc.php b/PHP/Manager/Include/Pages/008-DataCenterManagementPage.inc.php
new file mode 100644
index 00000000..baaaf006
--- /dev/null
+++ b/PHP/Manager/Include/Pages/008-DataCenterManagementPage.inc.php
@@ -0,0 +1,48 @@
+Title = "Manage Data Center: " . $this->DataCenter->Title;
+ }
+
+ protected function RenderContent()
+ {
+ ?>
+ Data Center Management
+ DataCenter->Title); ?>
+
+
+ Information
+
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/009-TenantObjectManagementPage.inc.php b/PHP/Manager/Include/Pages/009-TenantObjectManagementPage.inc.php
new file mode 100644
index 00000000..d8ce5094
--- /dev/null
+++ b/PHP/Manager/Include/Pages/009-TenantObjectManagementPage.inc.php
@@ -0,0 +1,224 @@
+CurrentObject != null)
+ {
+ $this->Title = "Manage Tenant Object: " . $this->CurrentObject->Name . " on " . $this->CurrentTenant->URL;
+ }
+ else
+ {
+ $this->Title = "Manage Tenant Objects: " . $this->CurrentTenant->URL;
+ }
+ }
+
+ protected function RenderContent()
+ {
+ if ($this->CurrentObject != null)
+ {
+ ?>
+ Object: CurrentObject->Name); ?> on CurrentTenant->URL); ?>
+
+ TabPages[] = new TabPage("tabStaticProperties", "Static Properties", null, null, null, function()
+ {
+ ?>
+
+ TabPages[] = new TabPage("tabInstanceProperties", "Instance Properties", null, null, null, function()
+ {
+ ?>
+
+
+
+ TabPages[] = new TabPage("tabStaticMethods", "Static Methods", null, null, null, function()
+ {
+ ?>
+
+ TabPages[] = new TabPage("tabInstances", "Instances", null, null, null, function()
+ {
+ ?>
+
+
+ CurrentObject->GetInstances();
+ foreach ($instances as $instance)
+ {
+ ?>
+
+ ColumnVisible)
+ {
+ echo("");
+ $value = $instance->GetPropertyValue($property);
+ $property->RenderColumn($value);
+ echo(" ");
+ }
+ }
+ ?>
+
+
+
+ Render();
+ ?>
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/010-TenantObjectMethodManagementPage.inc.php b/PHP/Manager/Include/Pages/010-TenantObjectMethodManagementPage.inc.php
new file mode 100644
index 00000000..a9ce1253
--- /dev/null
+++ b/PHP/Manager/Include/Pages/010-TenantObjectMethodManagementPage.inc.php
@@ -0,0 +1,96 @@
+StyleSheets[] = new WebStyleSheet("http://static.alcehosting.net/dropins/CodeMirror/StyleSheets/CodeMirror.css");
+ $this->Scripts[] = new WebScript("http://static.alcehosting.net/dropins/CodeMirror/Scripts/Addons/Edit/MatchBrackets.js");
+
+ $this->Scripts[] = new WebScript("http://static.alcehosting.net/dropins/CodeMirror/Scripts/Modes/clike/clike.js");
+ $this->Scripts[] = new WebScript("http://static.alcehosting.net/dropins/CodeMirror/Scripts/Modes/php/php.js");
+ }
+
+ protected function Initialize()
+ {
+ if ($this->CurrentMethod != null)
+ {
+ $this->Title = "Manage Method: " . $this->CurrentMethod->Name . " on " . $this->CurrentObject->Name . "@" . $this->CurrentTenant->URL;
+ }
+ else
+ {
+ $this->Title = "Manage Methods for Object: " . $this->CurrentObject->Name . " on " . $this->CurrentTenant->URL;
+ }
+ }
+
+ protected function RenderContent()
+ {
+ if ($this->CurrentObject != null)
+ {
+ ?>
+ Method: CurrentMethod->Name); ?> on CurrentObject->Name); ?>@CurrentTenant->URL); ?>
+
+ Code Blob
+
+ CurrentMethod->CodeBlob); ?>
+
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/011-TenantObjectInstanceBrowsePage.inc.php b/PHP/Manager/Include/Pages/011-TenantObjectInstanceBrowsePage.inc.php
new file mode 100644
index 00000000..7d08c81e
--- /dev/null
+++ b/PHP/Manager/Include/Pages/011-TenantObjectInstanceBrowsePage.inc.php
@@ -0,0 +1,75 @@
+Title = "Browse Instances of Tenant Object: " . $this->CurrentObject->Name . " on " . $this->CurrentTenant->URL;
+ }
+
+ protected function RenderContent()
+ {
+ if ($this->CurrentObject != null)
+ {
+ ?>
+ Object: CurrentObject->Name); ?> on CurrentTenant->URL); ?>
+ Object Instances
+
+
+ CurrentObject->GetInstances();
+ foreach ($instances as $instance)
+ {
+ ?>
+
+ ColumnVisible)
+ {
+ echo("");
+ $value = $instance->GetPropertyValue($property);
+ $property->RenderColumn($value);
+ echo(" ");
+ }
+ }
+ ?>
+
+
+
+
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/012-DataTypeModifyPage.inc.php b/PHP/Manager/Include/Pages/012-DataTypeModifyPage.inc.php
new file mode 100644
index 00000000..0daabe60
--- /dev/null
+++ b/PHP/Manager/Include/Pages/012-DataTypeModifyPage.inc.php
@@ -0,0 +1,252 @@
+StyleSheets[] = new WebStyleSheet("http://static.alcehosting.net/dropins/CodeMirror/StyleSheets/CodeMirror.css");
+ $this->Scripts[] = new WebScript("http://static.alcehosting.net/dropins/CodeMirror/Scripts/Addons/Edit/MatchBrackets.js");
+
+ $this->Scripts[] = new WebScript("http://static.alcehosting.net/dropins/CodeMirror/Scripts/Modes/clike/clike.js");
+ $this->Scripts[] = new WebScript("http://static.alcehosting.net/dropins/CodeMirror/Scripts/Modes/php/php.js");
+ }
+
+ protected function Initialize()
+ {
+ if ($this->CurrentDataType != null)
+ {
+ $this->Title = "Manage Data Type: " . $this->CurrentDataType->Name;
+ }
+ else
+ {
+ $this->Title = "Manage Data Types";
+ }
+ }
+
+ protected function RenderContent()
+ {
+ if ($this->CurrentDataType != null)
+ {
+ ?>
+ Modify Data Type: CurrentDataType->Name); ?>
+ Create Data Type
+
+
+
+ CurrentDataType != null)
+ {
+ echo(" CurrentDataType->ID . "\" />");
+ }
+
+ $fv = new FormView("fv");
+ $fv->Items[] = new FormViewItemText("txtDataTypeName", "datatype_Name", "Name", $this->CurrentDataType->Name);
+ $fv->Items[0]->Required = true;
+
+ $fv->Items[] = new FormViewItemMemo("txtDataTypeDescription", "datatype_Description", "Description", $this->CurrentDataType->Description);
+ $fv->Render();
+ ?>
+ OnClientTabChanged = "tbs_OnClientTabChanged();";
+ $tbs->TabPages[] = new TabPage("tabEncoder", "Encoder", null, null, null, function()
+ {
+ ?>
+ CurrentDataType->EncoderCodeBlob); ?>
+ TabPages[] = new TabPage("tabDecoder", "Decoder", null, null, null, function()
+ {
+ ?>
+ CurrentDataType->DecoderCodeBlob); ?>
+ TabPages[] = new TabPage("tabColumnRenderer", "Column Renderer", null, null, null, function()
+ {
+ ?>
+ CurrentDataType->ColumnRendererCodeBlob); ?>
+ TabPages[] = new TabPage("tabEditorRenderer", "Editor Renderer", null, null, null, function()
+ {
+ ?>
+ CurrentDataType->EditorRendererCodeBlob); ?>
+ Render();
+ ?>
+
+
+
+
+
+ Render();
+ return true;
+ }),
+ new ModulePage("modify", function($path)
+ {
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ if (isset($_POST["datatype_ID"]))
+ {
+ $datatype = DataType::GetByID($_POST["datatype_ID"]);
+ }
+ else
+ {
+ $datatype = new DataType();
+ }
+ $datatype->Name = $_POST["datatype_Name"];
+ $datatype->Description = $_POST["datatype_Description"];
+ $datatype->EncoderCodeBlob = $_POST["datatype_EncoderCodeBlob"];
+ $datatype->DecoderCodeBlob = $_POST["datatype_DecoderCodeBlob"];
+ $datatype->ColumnRendererCodeBlob = $_POST["datatype_ColumnRendererCodeBlob"];
+ $datatype->EditorRendererCodeBlob = $_POST["datatype_EditorRendererCodeBlob"];
+ $datatype->Update();
+
+ System::Redirect("~/datatype");
+ }
+ else
+ {
+ $page = new DataTypeModifyPage();
+ $page->CurrentDataType = DataType::GetByID($path[0]);
+ $page->Render();
+ }
+ return true;
+ })
+ ))
+ ));
+?>
\ No newline at end of file
diff --git a/PHP/Manager/Include/Pages/Default.wfx b/PHP/Manager/Include/Pages/Default.wfx
deleted file mode 100644
index ffea97aa..00000000
--- a/PHP/Manager/Include/Pages/Default.wfx
+++ /dev/null
@@ -1,29 +0,0 @@
-<%@ Page ModuleName="com.universaleditor.manager.Default" URL="/" %>
-
-
- This is a test
-
-
-
-
-
- Name type:
-
-
-
- Legal
- Preferred
- Maiden
- Other
-
-
-
-
-
- Name:
-
-
-
-
-
-
diff --git a/PHP/Manager/Include/UUID.inc.php b/PHP/Manager/Include/UUID.inc.php
new file mode 100644
index 00000000..431d1e94
--- /dev/null
+++ b/PHP/Manager/Include/UUID.inc.php
@@ -0,0 +1,81 @@
+urand = @fopen ( '/dev/urandom', 'rb' );
+ }
+
+ public static function Generate()
+ {
+ $uuid = new UUID();
+ return $uuid->get();
+ }
+
+ /**
+ * @brief Generates a Universally Unique IDentifier, version 4.
+ *
+ * This function generates a truly random UUID. The built in CakePHP String::uuid() function
+ * is not cryptographically secure. You should uses this function instead.
+ *
+ * @see http://tools.ietf.org/html/rfc4122#section-4.4
+ * @see http://en.wikipedia.org/wiki/UUID
+ * @return string A UUID, made up of 32 hex digits and 4 hyphens.
+ */
+ function get() {
+
+ $pr_bits = false;
+ if (is_a ( $this, 'uuid' )) {
+ if (is_resource ( $this->urand )) {
+ $pr_bits .= @fread ( $this->urand, 16 );
+ }
+ }
+ if (! $pr_bits) {
+ $fp = @fopen ( '/dev/urandom', 'rb' );
+ if ($fp !== false) {
+ $pr_bits .= @fread ( $fp, 16 );
+ @fclose ( $fp );
+ } else {
+ // If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
+ $pr_bits = "";
+ for($cnt = 0; $cnt < 16; $cnt ++) {
+ $pr_bits .= chr ( mt_rand ( 0, 255 ) );
+ }
+ }
+ }
+ $time_low = bin2hex ( substr ( $pr_bits, 0, 4 ) );
+ $time_mid = bin2hex ( substr ( $pr_bits, 4, 2 ) );
+ $time_hi_and_version = bin2hex ( substr ( $pr_bits, 6, 2 ) );
+ $clock_seq_hi_and_reserved = bin2hex ( substr ( $pr_bits, 8, 2 ) );
+ $node = bin2hex ( substr ( $pr_bits, 10, 6 ) );
+
+ /**
+ * Set the four most significant bits (bits 12 through 15) of the
+ * time_hi_and_version field to the 4-bit version number from
+ * Section 4.1.3.
+ * @see http://tools.ietf.org/html/rfc4122#section-4.1.3
+ */
+ $time_hi_and_version = hexdec ( $time_hi_and_version );
+ $time_hi_and_version = $time_hi_and_version >> 4;
+ $time_hi_and_version = $time_hi_and_version | 0x4000;
+
+ /**
+ * Set the two most significant bits (bits 6 and 7) of the
+ * clock_seq_hi_and_reserved to zero and one, respectively.
+ */
+ $clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved );
+ $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
+ $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
+
+ return strtoupper( sprintf ( '%08s%04s%04x%04x%012s', $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node ) );
+ }
+
+ public static function format($input)
+ {
+ $output = $input;
+ $output = substr($output, 0, 8) . "-" . substr($output, 8, 4) . "-" . substr($output, 12, 4) . "-" . substr($output, 16, 4) . "-" . substr($output, 20);
+ return "{" . $output . "}";
+ }
+}
+?>
\ No newline at end of file
diff --git a/PHP/Manager/index.php b/PHP/Manager/index.php
index ee65b6a2..33eb33c3 100644
--- a/PHP/Manager/index.php
+++ b/PHP/Manager/index.php
@@ -25,6 +25,7 @@
// 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");
+ require_once("Include/UUID.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
diff --git a/PHP/TODO.txt b/PHP/TODO.txt
new file mode 100644
index 00000000..bd98ad65
--- /dev/null
+++ b/PHP/TODO.txt
@@ -0,0 +1,62 @@
+Create an object (if user has permissions):
+http://hosted1.universaleditor.com/default/o/create
+View an object:
+http://hosted1.universaleditor.com/default/o/177
+http://hosted1.universaleditor.com/default/o/177/display
+Edit an object:
+http://hosted1.universaleditor.com/default/o/177/modify
+Delete an object:
+http://hosted1.universaleditor.com/default/o/177/delete
+
+Create an object instance (if user has permissions):
+http://hosted1.universaleditor.com/default/i/create
+View an object instance:
+http://hosted1.universaleditor.com/default/i/177
+http://hosted1.universaleditor.com/default/i/177/display
+Edit an object instance:
+http://hosted1.universaleditor.com/default/i/177/modify
+Delete an object instance:
+http://hosted1.universaleditor.com/default/i/177/delete
+
+Object instance's appearance in Display mode is specified by the object's DisplayTemplate:
+
+
+
+
+
+ Instance Title); ?>
+
+
+
+
+
+
+ ...
+
+
+
+
+
+Create a task (if user has permissions):
+http://hosted1.universaleditor.com/default/t/create
+View a task's properties:
+http://hosted1.universaleditor.com/default/t/177 [ Task.DefaultAction = Display ]
+http://hosted1.universaleditor.com/default/t/177/display
+Edit a task:
+http://hosted1.universaleditor.com/default/t/177/modify
+Delete a task:
+http://hosted1.universaleditor.com/default/t/177/delete
+Execute a task:
+http://hosted1.universaleditor.com/default/t/177 [ Task.DefaultAction = Execute ]
+http://hosted1.universaleditor.com/default/t/177/execute
+Execute a task with parameters:
+http://hosted1.universaleditor.com/default/t/177/execute/[base64-encoded parameters list]
+
+Base64-encoded parameters list:
+{
+ "parameter name": "value",
+ "parameter 2 name": "value 2"
+}
+etc.
\ No newline at end of file
diff --git a/PHP/Website/.htaccess b/PHP/Tenant/.htaccess
similarity index 100%
rename from PHP/Website/.htaccess
rename to PHP/Tenant/.htaccess
diff --git a/PHP/Tenant/Include/Modules/000-Default/Main.inc.php b/PHP/Tenant/Include/Modules/000-Default/Main.inc.php
new file mode 100644
index 00000000..5b160d63
--- /dev/null
+++ b/PHP/Tenant/Include/Modules/000-Default/Main.inc.php
@@ -0,0 +1,347 @@
+query($query);
+ if ($result->num_rows < 1) return false;
+ return true;
+ }
+
+ function GetResourceBundles()
+ {
+ $ResourceBundles = array
+ (
+ new ResourceBundle("Common")
+ );
+
+ $tenant = Tenant::GetCurrent();
+
+ // References to ResourceBundle objects are stored in a MultipleInstanceProperty called "ResourceBundles" on the tenant
+ $bundles = $tenant->GetPropertyValue("ResourceBundles")->GetInstances();
+ foreach ($bundles as $bundle)
+ {
+ $ResourceBundles[] = new ResourceBundle($bundle->GetPropertyValue("Name"));
+ }
+ return $ResourceBundles;
+ }
+ function CompileStyleSheets($compile = true)
+ {
+ global $RootPath;
+ $ResourceBundles = GetResourceBundles();
+
+ $FilePaths = array();
+
+ $lesstext = "";
+ foreach ($ResourceBundles as $bundle)
+ {
+ $lesstext .= $bundle->CompileStyleSheets();
+ }
+ if ($compile)
+ {
+ try
+ {
+ $less = new \lessc();
+ $less->setFormatter("compressed");
+ $csstext = $less->compile($lesstext);
+
+ echo("/* compiled with lessphp v0.4.0 - GPLv3/MIT - http://leafo.net/lessphp */\n");
+ echo("/* for human-readable source of this file, append ?compile=false to the file name */\n");
+ echo($csstext);
+ }
+ catch (\Exception $e)
+ {
+ echo "/* " . $e->getMessage() . " */\n";
+ }
+ }
+ else
+ {
+ echo($lesstext);
+ }
+ }
+ function CompileScripts($compile = true)
+ {
+ global $RootPath;
+ $ResourceBundles = GetResourceBundles();
+
+ $FilePaths = array();
+
+ $lesstext = "";
+ foreach ($ResourceBundles as $bundle)
+ {
+ $lesstext .= $bundle->CompileScripts();
+ }
+
+ if ($compile)
+ {
+ try
+ {
+ $jstext = \JShrink\Minifier::minify($lesstext, array('flaggedComments' => false));
+
+ echo("/* compiled with JShrink v0.5.2 - BSD 3-clause - https://github.com/tedivm/JShrink */\n");
+ echo("/* for human-readable source of this file, append ?compile=false to the file name */\n");
+ echo($jstext);
+ }
+ catch (\Exception $e)
+ {
+ echo "/* " . $e->getMessage() . " */\n";
+ }
+ }
+ else
+ {
+ echo($lesstext);
+ }
+ }
+
+ function IsValidUserOrGuest()
+ {
+ $CurrentTenant = Tenant::GetCurrent();
+
+ if (!isset($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]) && !isset($_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"])) return true;
+ $user = User::GetByLoginID($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]);
+ if ($user == null) return true;
+
+ return IsAuthenticated();
+ }
+ function IsAuthenticated()
+ {
+ $CurrentTenant = Tenant::GetCurrent();
+
+ if (isset($_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]) && isset($_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"]))
+ {
+ $user = $CurrentTenant->GetObject("User")->GetMethod("ValidateCredentials")->Execute(array
+ (
+ new TenantObjectMethodParameterValue("username", $_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"]),
+ new TenantObjectMethodParameterValue("password", $_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"])
+ ));
+ return ($user != null);
+ }
+ return false;
+ }
+ function IsModuleAuthenticationRequired($path)
+ {
+ switch ($path)
+ {
+ case "dashboard":
+ case "world":
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ System::$BeforeLaunchEventHandler = function($path)
+ {
+ if ($path[0] == "images" || $path[0] == "StyleSheet.css" || $path[0] == "Script.js" || ($path[0] == "account" && ($path[1] == "login.page" || $path[1] == "register.page"))) return true;
+
+ // ensure our tenant has not expired yet
+ $tenant = Tenant::GetByURL(System::$TenantName);
+ if ($tenant == null || $tenant->IsExpired())
+ {
+ $page = new ErrorPage();
+ $page->Message = "The specified tenant does not exist. Please contact the site administrator to resolve this problem.";
+ $page->Render();
+ return false;
+ }
+
+ if (!IsConfigured() && $path[0] != "setup")
+ {
+ System::Redirect("~/setup");
+ return false;
+ }
+ if (!IsValidUserOrGuest())
+ {
+ System::Redirect("~/account/login.page");
+ return false;
+ }
+
+ if (!IsAuthenticated() && IsModuleAuthenticationRequired($path[0]))
+ {
+ System::Redirect("~/account/login.page");
+ return false;
+ }
+ return true;
+ };
+
+ System::$Modules[] = new Module("net.Objectify.Default", array
+ (
+ new ModulePage("", function($path)
+ {
+ if (IsAuthenticated())
+ {
+ $tenant = Tenant::GetCurrent();
+ $tobjUser = $tenant->GetObject("User");
+ $instUser = $tobjUser->GetMethod("GetCurrentUser")->Execute();
+
+ $propStartPage = $tobjUser->GetInstanceProperty("StartPage");
+
+ $startPageSet = $instUser->HasPropertyValue($propStartPage);
+ $startPage = $instUser->GetPropertyValue($propStartPage);
+
+ if ($startPageSet)
+ {
+ /*
+ $spi = $startPage->Instance;
+ $spio = $startPage->Instance->ParentObject;
+ $startPage = $spi->GetPropertyValue($spio->GetProperty("Value"));
+ */
+ System::Redirect($startPage);
+ }
+ else
+ {
+ System::Redirect("~/dashboard");
+ }
+ return true;
+ }
+
+ $page = new MainPage();
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("dashboard", function($path)
+ {
+ $page = new DashboardPage();
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("account", array
+ (
+ new ModulePage("login.page", function($path)
+ {
+ $CurrentTenant = Tenant::GetCurrent();
+ if ($CurrentTenant == null) return false;
+
+ $page = new LoginPage();
+ if (isset($_POST["member_username"]) && isset($_POST["member_password"]))
+ {
+ $object = $CurrentTenant->GetObject("User");
+ $inst = $object->GetMethod("ValidateCredentials")->Execute(array
+ (
+ new TenantObjectMethodParameterValue("username", $_POST["member_username"]),
+ new TenantObjectMethodParameterValue("password", $_POST["member_password"])
+ ));
+
+ if ($inst != null)
+ {
+ $_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"] = $_POST["member_username"];
+ $_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"] = $_POST["member_password"];
+
+ if (isset($_SESSION["LoginRedirectURL"]))
+ {
+ System::Redirect($_SESSION["LoginRedirectURL"]);
+ }
+ else
+ {
+ System::Redirect("~/");
+ }
+ return true;
+ }
+ else
+ {
+ $page->InvalidCredentials = true;
+ }
+ }
+ $page->Render();
+ return true;
+ }),
+ new ModulePage("logout.page", function($path)
+ {
+ $CurrentTenant = Tenant::GetCurrent();
+
+ $_SESSION["CurrentUserName[" . $CurrentTenant->ID . "]"] = null;
+ $_SESSION["CurrentPassword[" . $CurrentTenant->ID . "]"] = null;
+ System::Redirect("~/");
+ })
+ )),
+ new ModulePage("images", function($path)
+ {
+ // load images from resources object
+ global $RootPath;
+
+ $bundle = "Common";
+ $filename = implode("/", $path);
+ if (isset($path[1]))
+ {
+ if ($path[1] != "")
+ {
+ $bundle = $path[0];
+ array_shift($path);
+ $filename = implode("/", $path);
+ }
+ }
+
+ $imagePath = $RootPath . "/Resources/" . $bundle . "/Images/" . implode("/", $path);
+ if (file_exists($imagePath))
+ {
+ header("Content-Type: " . mime_content_type($imagePath));
+ readfile($imagePath);
+ return true;
+ }
+ else
+ {
+ header("HTTP/1.1 404 Not Found");
+ echo("The specified resource file was not found on this server.");
+ return false;
+ }
+ }),
+ new ModulePage("StyleSheet.css", function($path)
+ {
+ header("Content-Type: text/css");
+ $compile = true;
+ if (isset($_GET["compile"])) $compile = ($_GET["compile"] != "false");
+ $lesstext = CompileStyleSheets($compile);
+ echo($lesstext);
+ return true;
+ }),
+ new ModulePage("Script.js", function($path)
+ {
+ // load style sheet from resources object
+ header("Content-Type: text/javascript");
+ $compile = true;
+ if (isset($_GET["compile"])) $compile = ($_GET["compile"] != "false");
+ $lesstext = CompileScripts($compile);
+ echo($lesstext);
+ return true;
+ })
+ ));
+?>
\ No newline at end of file
diff --git a/PHP/Tenant/Include/Modules/000-Default/ResourceBundle.inc.php b/PHP/Tenant/Include/Modules/000-Default/ResourceBundle.inc.php
new file mode 100644
index 00000000..8cef5d27
--- /dev/null
+++ b/PHP/Tenant/Include/Modules/000-Default/ResourceBundle.inc.php
@@ -0,0 +1,192 @@
+Name = $name;
+ }
+
+ public function MakeRelativePath($filename)
+ {
+ global $RootPath;
+ if (substr($filename, 0, strlen($RootPath)) == $RootPath)
+ {
+ return "~/" . substr($filename, strlen($RootPath) + 1);
+ }
+ return $filename;
+ }
+
+ // BEGIN: function from Sven Arduwie (http://us2.php.net/manual/en/function.realpath.php#84012)
+ public function get_absolute_path($path)
+ {
+ $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
+ $parts = explode(DIRECTORY_SEPARATOR, $path);
+ $absolutes = array();
+ foreach ($parts as $part)
+ {
+ if ('.' == $part) continue;
+ if ('..' == $part)
+ {
+ array_pop($absolutes);
+ }
+ else
+ {
+ $absolutes[] = $part;
+ }
+ }
+ return implode(DIRECTORY_SEPARATOR, $absolutes);
+ }
+ // END: function from Sven Arduwie (http://us2.php.net/manual/en/function.realpath.php#84012)
+
+ public function MakeAbsolutePath($filename, $relativeTo = null)
+ {
+ global $RootPath;
+ if (strlen($filename) > 3 && substr($filename, 0, 3) == "../")
+ {
+ if ($relativeTo != null)
+ {
+ $path = $relativeTo . "/" . $filename;
+ return $this->get_absolute_path($path);
+ }
+ return $this->get_absolute_path($filename);
+ }
+ else if (strlen($filename) > 1 && substr($filename, 0, 1) == "/")
+ {
+ return $filename;
+ }
+ if ($relativeTo != null)
+ {
+ return $relativeTo . "/" . $filename;
+ }
+ return $RootPath . "/" . $filename;
+ }
+
+ public function CompileImportableFile($filename, $importedFileName = null, $preprocessorToken = "#")
+ {
+ global $RootPath;
+ $filename = $this->MakeAbsolutePath($filename, dirname($importedFileName));
+ $importedFileTitle = $this->MakeRelativePath($importedFileName);
+
+ $lesstext = "";
+ $filetitle = $this->MakeRelativePath($filename);
+ $lesstext .= "/* BEGIN FILE: " . $filetitle;
+ if ($importedFileTitle != null)
+ {
+ $lesstext .= " - IMPORTED FROM " . $importedFileTitle;
+ }
+ $lesstext .= " */\n";
+
+ if (file_exists($filename))
+ {
+ $tmp = file_get_contents($filename);
+ if ($tmp === false)
+ {
+ $lesstext .= "/* ERROR: " . $filename . " */";
+ }
+ else
+ {
+ $lesstext .= $tmp;
+ }
+ }
+ else
+ {
+ $lesstext .= "/*\n\tERROR: file does not exist\n\tFile name: \"" . $filename . "\"";
+ if ($importedFileTitle != null)
+ {
+ $lesstext .= "\n\tImported from: \"" . $importedFileTitle . "\"";
+ }
+ $lesstext .= "\n*/\n";
+ }
+ $lesstext .= "\n";
+
+ $lesslines = explode("\n", $lesstext);
+ $lesstext = "";
+
+ $j = strlen($preprocessorToken . "import ");
+ foreach ($lesslines as $lessline)
+ {
+ if (substr(trim($lessline), 0, $j) == $preprocessorToken . "import ")
+ {
+ $importfilename = trim(substr($lessline, $j));
+ $importfilename = substr($importfilename, 1, strlen($importfilename) - 3); // removes " and ";
+
+ $lesstext .= $this->CompileImportableFile($importfilename, $filename, $preprocessorToken);
+ }
+ else
+ {
+ $lesstext .= $lessline . "\n";
+ }
+ }
+
+ $lesstext .= "/* END FILE: " . $filetitle;
+ if ($importedFileTitle != null)
+ {
+ $lesstext .= " - IMPORTED FROM " . $importedFileTitle;
+ }
+ $lesstext .= " */\n\n";
+ return $lesstext;
+ }
+
+ public function CompileStyleSheets()
+ {
+ global $RootPath;
+ $StyleSheetPath = $RootPath . "/Resources/" . $this->Name . "/StyleSheets";
+ $lesstext = "";
+
+ $lesstext .= "/* BEGIN BUNDLE: " . $this->Name . " */\n";
+
+ $lesstext .= "/* include path: " . $StyleSheetPath . " - ";
+
+ $lessFiles = glob($StyleSheetPath . "/*.less");
+ $lesstext .= count($lessFiles) . " *.less files, ";
+ $cssFiles = glob($StyleSheetPath . "/*.css");
+ $lesstext .= count($cssFiles) . " *.css files";
+ $lesstext .= " */\n\n";
+
+ foreach ($lessFiles as $filename)
+ {
+ $lesstext .= $this->CompileImportableFile($filename, null, "@");
+ }
+ foreach ($cssFiles as $filename)
+ {
+ $lesstext .= $this->CompileImportableFile($filename, null, "@");
+ }
+ $lesstext .= "/* END BUNDLE: " . $this->Name . " */\n\n";
+ return $lesstext;
+ }
+
+ public function CompileScripts()
+ {
+ global $RootPath;
+ $ContentPaths = array
+ (
+ "",
+ "Controls",
+ "Objects"
+ );
+ $BasePath = $RootPath . "/Resources/" . $this->Name . "/Scripts";
+ $lesstext = "";
+
+ $lesstext .= "/* BEGIN BUNDLE: " . $this->Name . " */\n";
+ foreach ($ContentPaths as $ContentPath)
+ {
+ $truepath = $BasePath . "/" . $ContentPath;
+ $lesstext .= "/* include path: " . $truepath . " - ";
+
+ $jsfiles = glob($truepath . "/*.js");
+ $lesstext .= count($jsfiles) . " *.js files";
+ $lesstext .= " */\n\n";
+
+ foreach ($jsfiles as $filename)
+ {
+ $lesstext .= $this->CompileImportableFile($filename, null, "@");
+ }
+ }
+ $lesstext .= "/* END BUNDLE: " . $this->Name . " */\n\n";
+ return $lesstext;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/PHP/Tenant/Include/Pages/DataFormatModifyPage.html b/PHP/Tenant/Include/Pages/DataFormatModifyPage.html
deleted file mode 100644
index 041d0db1..00000000
--- a/PHP/Tenant/Include/Pages/DataFormatModifyPage.html
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
- Modify Data Format
- Slightly Mad Studios BFF archive
-
-
-
-
-
-
-
-
-
-
- Data type
- Title
-
-
- String
- Encryption key
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/PHP/Tenant/Include/Pages/DataFormatModifyPage.wfx b/PHP/Tenant/Include/Pages/DataFormatModifyPage.wfx
deleted file mode 100644
index a53817d6..00000000
--- a/PHP/Tenant/Include/Pages/DataFormatModifyPage.wfx
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
- Modify Data Format
- Slightly Mad Studios BFF archive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/PHP/Tenant/Include/Pages/EnumerationModifyPage.wfx b/PHP/Tenant/Include/Pages/EnumerationModifyPage.wfx
deleted file mode 100644
index 578c3b1b..00000000
--- a/PHP/Tenant/Include/Pages/EnumerationModifyPage.wfx
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
- Modify Enumeration
- Slightly Mad Studios BFF Encryption Mode
-
- Possible values:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/PHP/Website/index.php b/PHP/Tenant/index.php
similarity index 86%
rename from PHP/Website/index.php
rename to PHP/Tenant/index.php
index ee65b6a2..cba49567 100644
--- a/PHP/Website/index.php
+++ b/PHP/Tenant/index.php
@@ -25,6 +25,7 @@
// 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");
+ require_once("Include/UUID.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
@@ -32,6 +33,11 @@
use WebFX\System;
use WebFX\IncludeFile;
+ // Tell WebFX that this is a tenanted hosting application. This will allow us to
+ // control much of the application through Tenant Manager rather than having to
+ // continually push out code updates.
+ System::$EnableTenantedHosting = true;
+
// Tell WebFX that we are ready to launch the application. This cycles through
// all of the modules (usually you will define your main application content in
// 000-Default) and executes the first module page that corresponds to the path
diff --git a/PHP/Website/lessc.php b/PHP/Tenant/lessc.php
similarity index 100%
rename from PHP/Website/lessc.php
rename to PHP/Tenant/lessc.php
diff --git a/PHP/Website/Include/Configuration.inc.php b/PHP/Website/Include/Configuration.inc.php
deleted file mode 100644
index e69de29b..00000000
diff --git a/PHP/Website/Include/MasterPages/000-WebPage.inc.php b/PHP/Website/Include/MasterPages/000-WebPage.inc.php
deleted file mode 100644
index 6090f4a8..00000000
--- a/PHP/Website/Include/MasterPages/000-WebPage.inc.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
\ No newline at end of file
diff --git a/PHP/Website/Include/Modules/000-Default/Main.inc.php b/PHP/Website/Include/Modules/000-Default/Main.inc.php
deleted file mode 100644
index 98c7a273..00000000
--- a/PHP/Website/Include/Modules/000-Default/Main.inc.php
+++ /dev/null
@@ -1,19 +0,0 @@
-Render();
- return true;
- })
- ));
-?>
\ No newline at end of file
diff --git a/PHP/Website/Include/Pages/000-MainPage.inc.php b/PHP/Website/Include/Pages/000-MainPage.inc.php
deleted file mode 100644
index dfc0c073..00000000
--- a/PHP/Website/Include/Pages/000-MainPage.inc.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
- Welcome to Universal Editor!
-
\ No newline at end of file