Merge branch 'master' of github.com:alcexhim/UniversalEditor
This commit is contained in:
commit
5cfd85fcee
21
PHP/.gitignore
vendored
Normal file
21
PHP/.gitignore
vendored
Normal file
@ -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/*
|
||||
51
PHP/Common/Include/Objects/000-Objectify.inc.php
Normal file
51
PHP/Common/Include/Objects/000-Objectify.inc.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
\Enum::Create("Objectify\\Objects\\LogMessageSeverity", "Notice", "Warning", "Error");
|
||||
|
||||
class Objectify
|
||||
{
|
||||
public static function Log($message, $params = null, $severity = LogMessageSeverity::Error)
|
||||
{
|
||||
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
if ($params == null) $params = array();
|
||||
|
||||
global $MySQL;
|
||||
|
||||
$tenant = Tenant::GetCurrent();
|
||||
|
||||
$query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "DebugMessages (message_TenantID, message_Content, message_SeverityID, message_Timestamp, message_IPAddress) VALUES (";
|
||||
$query .= ($tenant == null ? "NULL" : $tenant->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
140
PHP/Common/Include/Objects/DataCenter.inc.php
Normal file
140
PHP/Common/Include/Objects/DataCenter.inc.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class DataCenterCollection
|
||||
{
|
||||
public $Items;
|
||||
public function __construct()
|
||||
{
|
||||
$this->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("}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
191
PHP/Common/Include/Objects/DataType.inc.php
Normal file
191
PHP/Common/Include/Objects/DataType.inc.php
Normal file
@ -0,0 +1,191 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class DataType
|
||||
{
|
||||
public $ID;
|
||||
public $Name;
|
||||
public $Description;
|
||||
|
||||
public $EncoderCodeBlob;
|
||||
public $DecoderCodeBlob;
|
||||
public $ColumnRendererCodeBlob;
|
||||
public $EditorRendererCodeBlob;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new DataType();
|
||||
$item->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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
55
PHP/Common/Include/Objects/Language.inc.php
Normal file
55
PHP/Common/Include/Objects/Language.inc.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
class Language
|
||||
{
|
||||
public $ID;
|
||||
public $Name;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new Language();
|
||||
$item->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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
113
PHP/Common/Include/Objects/Module.inc.php
Normal file
113
PHP/Common/Include/Objects/Module.inc.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
// \Enum::Create("Objectify\\Objects\\ModuleStatus", "Enabled", "Disabled");
|
||||
|
||||
class Module
|
||||
{
|
||||
public $ID;
|
||||
public $Title;
|
||||
public $Description;
|
||||
public $Enabled;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new Module();
|
||||
$item->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("}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
78
PHP/Common/Include/Objects/ModulePage.inc.php
Normal file
78
PHP/Common/Include/Objects/ModulePage.inc.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
// \Enum::Create("Objectify\\Objects\\ModuleStatus", "Enabled", "Disabled");
|
||||
|
||||
class ModulePage
|
||||
{
|
||||
public $ID;
|
||||
public $Module;
|
||||
public $ParentPage;
|
||||
public $URL;
|
||||
public $Content;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new ModulePage();
|
||||
$item->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("}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
41
PHP/Common/Include/Objects/MultipleInstanceProperty.inc.php
Normal file
41
PHP/Common/Include/Objects/MultipleInstanceProperty.inc.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
class MultipleInstanceProperty
|
||||
{
|
||||
private $mvarInstances;
|
||||
public function GetInstances()
|
||||
{
|
||||
return $this->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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
56
PHP/Common/Include/Objects/PaymentPlan.inc.php
Normal file
56
PHP/Common/Include/Objects/PaymentPlan.inc.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class PaymentPlan
|
||||
{
|
||||
public $ID;
|
||||
public $Title;
|
||||
public $Description;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new PaymentPlan();
|
||||
$item->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("}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
31
PHP/Common/Include/Objects/SingleInstanceProperty.inc.php
Normal file
31
PHP/Common/Include/Objects/SingleInstanceProperty.inc.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
class SingleInstanceProperty
|
||||
{
|
||||
private $mvarInstance;
|
||||
public function GetInstance()
|
||||
{
|
||||
return $this->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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
455
PHP/Common/Include/Objects/Tenant.inc.php
Normal file
455
PHP/Common/Include/Objects/Tenant.inc.php
Normal file
@ -0,0 +1,455 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
\Enum::Create("Objectify\\Objects\\TenantStatus", "Enabled", "Disabled");
|
||||
|
||||
class Tenant
|
||||
{
|
||||
public $ID;
|
||||
public $URL;
|
||||
public $Description;
|
||||
public $Status;
|
||||
public $Type;
|
||||
public $DataCenters;
|
||||
public $PaymentPlan;
|
||||
public $BeginTimestamp;
|
||||
public $EndTimestamp;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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("<html><head><title>Initialization Failure</title></head><body><h1>Initialization Failure</h1><p>A fatal error occurred when attempting to initialize the Objectify runtime. Please make sure Objectify has been installed correctly on the server.</p><p>The Objectify runtime cannot be loaded (1001). Please contact the Web site administrator to inform them of this problem.</p><hr /><h3>System information</h3><table><tr><td>Tenant:</td><td>" . $url . "</td></tr><tr><td>Server: </td><td>" . $_SERVER["HTTP_HOST"] . "</td></tr></table></body></html>");
|
||||
die();
|
||||
return null;
|
||||
}
|
||||
|
||||
$count = $result->num_rows;
|
||||
if ($count == 0)
|
||||
{
|
||||
echo("<html><head><title>Initialization Failure</title></head><body><h1>Initialization Failure</h1><p>A fatal error occurred when attempting to initialize the Objectify runtime. Please make sure Objectify has been installed correctly on the server.</p><p>The Objectify runtime cannot find the requested tenant (1002). Please contact the Web site administrator to inform them of this problem.</p><hr /><h3>System information</h3><table><tr><td>Tenant:</td><td>" . $url . "</td></tr><tr><td>Server: </td><td>" . $_SERVER["HTTP_HOST"] . "</td></tr></table></body></html>");
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if an Objectify object with the specified name exists on the current tenant.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an Objectify object from the current tenant.
|
||||
/// </summary>
|
||||
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("}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
529
PHP/Common/Include/Objects/TenantObject.inc.php
Normal file
529
PHP/Common/Include/Objects/TenantObject.inc.php
Normal file
@ -0,0 +1,529 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class TenantObject
|
||||
{
|
||||
public $ID;
|
||||
public $Tenant;
|
||||
public $Module;
|
||||
public $ParentObject;
|
||||
public $Name;
|
||||
public $Description;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new TenantObject();
|
||||
$item->ID = $values["object_ID"];
|
||||
$item->Tenant = Tenant::GetByID($values["object_TenantID"]);
|
||||
$item->Module = Module::GetByID($values["object_ModuleID"]);
|
||||
$item->ParentObject = TenantObject::GetByID($values["object_ParentObjectID"]);
|
||||
$item->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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of this Objectify object with the specified properties.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
220
PHP/Common/Include/Objects/TenantObjectInstance.inc.php
Normal file
220
PHP/Common/Include/Objects/TenantObjectInstance.inc.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
class TenantObjectInstance
|
||||
{
|
||||
public $ID;
|
||||
public $ParentObject;
|
||||
|
||||
public function __construct($parentObject)
|
||||
{
|
||||
$this->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;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this TenantObjectInstanceProperty is visible when rendered as a column in a ListView.
|
||||
/// </summary>
|
||||
public $ColumnVisible;
|
||||
|
||||
public function RenderColumn($value = null)
|
||||
{
|
||||
if ($this->DataType == null || $this->DataType->ColumnRendererCodeBlob == null)
|
||||
{
|
||||
?>
|
||||
<input style="width: 100%;" type="text" id="txtProperty_<?php echo($this->ID); ?>" name="Property_<?php echo($this->ID); ?>" value="<?php
|
||||
if ($value == null)
|
||||
{
|
||||
echo($this->DefaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($value);
|
||||
}
|
||||
?>" />
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($value == null)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
328
PHP/Common/Include/Objects/TenantObjectMethod.inc.php
Normal file
328
PHP/Common/Include/Objects/TenantObjectMethod.inc.php
Normal file
@ -0,0 +1,328 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class TenantObjectMethod
|
||||
{
|
||||
public $ID;
|
||||
public $ParentObject;
|
||||
public $Name;
|
||||
public $Description;
|
||||
public $CodeBlob;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new TenantObjectMethod();
|
||||
$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 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
132
PHP/Common/Include/Objects/TenantObjectProperty.inc.php
Normal file
132
PHP/Common/Include/Objects/TenantObjectProperty.inc.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
class TenantObjectProperty
|
||||
{
|
||||
public $ID;
|
||||
public $Tenant;
|
||||
public $ParentObject;
|
||||
|
||||
public $Name;
|
||||
public $Description;
|
||||
public $DataType;
|
||||
public $DefaultValue;
|
||||
public $Required;
|
||||
public $Enumeration;
|
||||
public $RequireChoiceFromEnumeration;
|
||||
|
||||
public function RenderColumn($value = null)
|
||||
{
|
||||
if ($this->DataType == null || $this->DataType->ColumnRendererCodeBlob == null)
|
||||
{
|
||||
?>
|
||||
<input style="width: 100%;" type="text" id="txtProperty_<?php echo($property->ID); ?>" name="Property_<?php echo($property->ID); ?>" value="<?php
|
||||
if ($value == null)
|
||||
{
|
||||
echo($this->DefaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($value);
|
||||
}
|
||||
?>" />
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($value == null)
|
||||
{
|
||||
$this->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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
127
PHP/Common/Include/Objects/TenantProperty.inc.php
Normal file
127
PHP/Common/Include/Objects/TenantProperty.inc.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class TenantProperty
|
||||
{
|
||||
public $ID;
|
||||
public $Tenant;
|
||||
public $Name;
|
||||
public $Description;
|
||||
public $DataType;
|
||||
public $DefaultValue;
|
||||
|
||||
public function __construct($name = null, $dataType = null, $description = null, $defaultValue = null)
|
||||
{
|
||||
$this->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)
|
||||
{
|
||||
?>
|
||||
<input style="width: 100%;" type="text" id="<?php echo($name); ?>" name="<?php echo($name); ?>" value="<?php
|
||||
if ($value == null)
|
||||
{
|
||||
echo($this->DefaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($value);
|
||||
}
|
||||
?>" />
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($value == null)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
15
PHP/Common/Include/Objects/TenantQueryParameter.inc.php
Normal file
15
PHP/Common/Include/Objects/TenantQueryParameter.inc.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
class TenantQueryParameter
|
||||
{
|
||||
public $Name;
|
||||
public $Value;
|
||||
|
||||
public function __construct($name, $value)
|
||||
{
|
||||
$this->Name = $name;
|
||||
$this->Value = $value;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
|
||||
class TenantStringTableEntry
|
||||
{
|
||||
}
|
||||
?>
|
||||
56
PHP/Common/Include/Objects/TenantType.inc.php
Normal file
56
PHP/Common/Include/Objects/TenantType.inc.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace Objectify\Objects;
|
||||
use WebFX\System;
|
||||
|
||||
class TenantType
|
||||
{
|
||||
public $ID;
|
||||
public $Title;
|
||||
public $Description;
|
||||
|
||||
public static function GetByAssoc($values)
|
||||
{
|
||||
$item = new TenantType();
|
||||
$item->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("}");
|
||||
}
|
||||
}
|
||||
?>
|
||||
BIN
PHP/Manager/Images/Logo.png
Normal file
BIN
PHP/Manager/Images/Logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
BIN
PHP/Manager/Images/Logo.xcf
Normal file
BIN
PHP/Manager/Images/Logo.xcf
Normal file
Binary file not shown.
23
PHP/Manager/Include/MasterPages/000-WebPage.inc.php
Normal file
23
PHP/Manager/Include/MasterPages/000-WebPage.inc.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\MasterPages;
|
||||
|
||||
use WebFX\WebStyleSheet;
|
||||
use WebFX\System;
|
||||
|
||||
class WebPage extends \WebFX\WebPage
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->StyleSheets[] = new WebStyleSheet("http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Workday/Main.css");
|
||||
}
|
||||
|
||||
protected function BeforeContent()
|
||||
{
|
||||
?>
|
||||
<div style="text-align: right;"><a href="<?php echo(System::ExpandRelativePath("~/account/logout.page")); ?>">Log Out</a></div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
665
PHP/Manager/Include/Modules/000-Default/Main.inc.php
Normal file
665
PHP/Manager/Include/Modules/000-Default/Main.inc.php
Normal file
@ -0,0 +1,665 @@
|
||||
<?php
|
||||
use WebFX\System;
|
||||
use WebFX\Module;
|
||||
use WebFX\ModulePage;
|
||||
|
||||
use WebFX\Controls\ButtonGroup;
|
||||
use WebFX\Controls\ButtonGroupButton;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
use Objectify\Tenant\Pages\LoginPage;
|
||||
use Objectify\Tenant\Pages\MainPage;
|
||||
use Objectify\Tenant\Pages\ModuleMainPage;
|
||||
use Objectify\Tenant\Pages\ModuleManagementPage;
|
||||
|
||||
use Objectify\Tenant\Pages\TenantPropertiesPage;
|
||||
use Objectify\Tenant\Pages\TenantManagementPage;
|
||||
use Objectify\Tenant\Pages\TenantModuleManagementPage;
|
||||
|
||||
use Objectify\Tenant\Pages\TenantObjectManagementPage;
|
||||
|
||||
use Objectify\Tenant\Pages\TenantObjectInstanceBrowsePage;
|
||||
|
||||
use Objectify\Tenant\Pages\DataCenterMainPage;
|
||||
use Objectify\Tenant\Pages\DataCenterManagementPage;
|
||||
|
||||
use Objectify\Tenant\Pages\TenantObjectMethodManagementPage;
|
||||
|
||||
use Objectify\Tenant\Pages\ConfirmOperationPage;
|
||||
|
||||
use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\DataType;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObject;
|
||||
use Objectify\Objects\TenantObjectMethod;
|
||||
use Objectify\Objects\TenantObjectInstanceMethod;
|
||||
use Objectify\Objects\TenantObjectInstanceProperty;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
use Objectify\Objects\TenantObjectMethodParameterValue;
|
||||
|
||||
function IsConfigured()
|
||||
{
|
||||
if (!(
|
||||
isset(System::$Configuration["Database.ServerName"]) &&
|
||||
isset(System::$Configuration["Database.DatabaseName"]) &&
|
||||
isset(System::$Configuration["Database.UserName"]) &&
|
||||
isset(System::$Configuration["Database.Password"]) &&
|
||||
isset(System::$Configuration["Database.TablePrefix"])
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
global $MySQL;
|
||||
$query = "SHOW TABLES LIKE '" . System::$Configuration["Database.TablePrefix"] . "Tenants'";
|
||||
$result = $MySQL->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("<h1>Error Details</h1>");
|
||||
echo("<p>" . $values["message_Content"] . "</p>");
|
||||
|
||||
echo("<h2>Parameters</h2>");
|
||||
echo("<table class=\"ListView\">");
|
||||
$query1 = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DebugMessageParameters WHERE mp_MessageID = " . $values["message_ID"];
|
||||
$result1 = $MySQL->query($query1);
|
||||
$count1 = $result1->num_rows;
|
||||
echo("<tr>");
|
||||
echo("<th>Name</th>");
|
||||
echo("<th>Value</th>");
|
||||
echo("</tr>");
|
||||
for ($j = 0; $j < $count1; $j++)
|
||||
{
|
||||
$values1 = $result1->fetch_assoc();
|
||||
echo("<tr>");
|
||||
echo("<td>");
|
||||
echo($values1["mp_Name"]);
|
||||
echo("</td>");
|
||||
echo("<td>");
|
||||
echo($values1["mp_Value"]);
|
||||
echo("</td>");
|
||||
echo("</tr>");
|
||||
}
|
||||
echo("</table>");
|
||||
|
||||
echo("<h2>Backtrace</h2>");
|
||||
echo("<table class=\"ListView\">");
|
||||
$query1 = "SELECT * FROM " . System::$Configuration["Database.TablePrefix"] . "DebugMessageBacktraces WHERE bt_MessageID = " . $values["message_ID"];
|
||||
$result1 = $MySQL->query($query1);
|
||||
$count1 = $result1->num_rows;
|
||||
echo("<tr>");
|
||||
echo("<th>File name</th>");
|
||||
echo("<th>Line number</th>");
|
||||
echo("</tr>");
|
||||
for ($j = 0; $j < $count1; $j++)
|
||||
{
|
||||
$values1 = $result1->fetch_assoc();
|
||||
echo("<tr>");
|
||||
echo("<td>");
|
||||
echo($values1["bt_FileName"]);
|
||||
echo("</td>");
|
||||
echo("<td>");
|
||||
echo($values1["bt_LineNumber"]);
|
||||
echo("</td>");
|
||||
echo("</tr>");
|
||||
}
|
||||
echo("</table>");
|
||||
echo("<div class=\"Buttons\">");
|
||||
echo("<form method=\"post\">");
|
||||
echo("<input type=\"hidden\" name=\"action\" value=\"delete\" />");
|
||||
echo("<input type=\"submit\" value=\"Delete Message\" />");
|
||||
echo("<a class=\"Button\" href=\"" . System::ExpandRelativePath("~/debug") . "\">Back to Messages</a>");
|
||||
echo("</form>");
|
||||
echo("</div>");
|
||||
}
|
||||
}
|
||||
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("<form method=\"post\">");
|
||||
echo("<input type=\"hidden\" name=\"action\" value=\"delete\" />");
|
||||
echo("<input type=\"submit\" value=\"Clear Messages\" />");
|
||||
echo("</form>");
|
||||
|
||||
echo("<table class=\"ListView\">");
|
||||
echo("<tr>");
|
||||
echo("<th>Tenant</th>");
|
||||
echo("<th>Severity</th>");
|
||||
echo("<th>Message</th>");
|
||||
echo("<th>Timestamp</th>");
|
||||
echo("<th>IP Address</th>");
|
||||
echo("</tr>");
|
||||
|
||||
$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("<tr>");
|
||||
echo("<td>");
|
||||
$tenant = Tenant::GetByID($values["message_TenantID"]);
|
||||
if ($tenant != null)
|
||||
{
|
||||
echo("<a href=\"" . System::ExpandRelativePath("~/tenant/manage/" . $tenant->URL . "/") . "\">" . $tenant->URL . "</a>");
|
||||
}
|
||||
echo("</td>");
|
||||
echo("<td>");
|
||||
switch ($values["message_SeverityID"])
|
||||
{
|
||||
}
|
||||
echo("</td>");
|
||||
echo("<td>");
|
||||
echo("<a href=\"" . System::ExpandRelativePath("~/debug/" . $values["message_ID"]) . "\">");
|
||||
echo($values["message_Content"]);
|
||||
echo("</a>");
|
||||
echo("</td>");
|
||||
echo("<td>");
|
||||
echo($values["message_Timestamp"]);
|
||||
echo("</td>");
|
||||
echo("<td>");
|
||||
echo($values["message_IPAddress"]);
|
||||
echo("</td>");
|
||||
echo("</tr>");
|
||||
}
|
||||
echo("</table>");
|
||||
}
|
||||
}
|
||||
$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;
|
||||
})
|
||||
))
|
||||
));
|
||||
?>
|
||||
41
PHP/Manager/Include/Modules/001-Setup/DefaultTenant.inc.php
Normal file
41
PHP/Manager/Include/Modules/001-Setup/DefaultTenant.inc.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
use Objectify\Objects\DataType;
|
||||
|
||||
use Objectify\Objects\MultipleInstanceProperty;
|
||||
use Objectify\Objects\SingleInstanceProperty;
|
||||
|
||||
use Objectify\Objects\TenantProperty;
|
||||
|
||||
use Objectify\Objects\TenantObjectProperty;
|
||||
use Objectify\Objects\TenantObjectInstanceProperty;
|
||||
use Objectify\Objects\TenantObjectInstancePropertyValue;
|
||||
use Objectify\Objects\TenantObjectMethodParameter;
|
||||
use Objectify\Objects\TenantQueryParameter;
|
||||
|
||||
use Objectify\Objects\TenantEnumerationChoice;
|
||||
|
||||
// Set up the basic configuration
|
||||
$tenant->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)
|
||||
)
|
||||
));
|
||||
|
||||
?>
|
||||
351
PHP/Manager/Include/Modules/001-Setup/Main.inc.php
Normal file
351
PHP/Manager/Include/Modules/001-Setup/Main.inc.php
Normal file
@ -0,0 +1,351 @@
|
||||
<?php
|
||||
namespace Objectify\Modules;
|
||||
|
||||
use WebFX\Controls\ButtonGroup;
|
||||
use WebFX\Controls\ButtonGroupButton;
|
||||
use WebFX\Controls\ButtonGroupButtonAlignment;
|
||||
|
||||
use WebFX\Controls\Panel;
|
||||
|
||||
use Objectify\Objects\Tenant;
|
||||
|
||||
use Objectify\Objects\User;
|
||||
use Objectify\Objects\UserProfileVisibility;
|
||||
use Objectify\Objects\UserPresenceStatus;
|
||||
|
||||
use WebFX\System;
|
||||
use WebFX\Module;
|
||||
use WebFX\ModulePage;
|
||||
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
use WebFX\WebPage;
|
||||
use Objectify\Pages\ErrorPage;
|
||||
|
||||
System::$Modules[] = new Module("net.objectify.Setup", array
|
||||
(
|
||||
new ModulePage("setup", function($path)
|
||||
{
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST")
|
||||
{
|
||||
function Success($taskname)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td style="background-color: #AAFFAA;"><?php echo($taskname); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
function Message($taskname)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td style="background-color: #AACCFF;"><?php echo($taskname); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
function Failure($taskname)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td style="background-color: #FFAAAA;"><?php echo($taskname); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
function VariableToString($value)
|
||||
{
|
||||
if (is_string($value))
|
||||
{
|
||||
return "\"" . $value . "\"";
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function SaveConfiguration()
|
||||
{
|
||||
global $RootPath;
|
||||
$FileName = $RootPath . "/Include/Configuration.inc.php";
|
||||
$f = fopen($FileName, "w");
|
||||
Message("Configuration file path is<br />" . $FileName);
|
||||
if ($f === false) return false;
|
||||
|
||||
fwrite($f, "<?php\n");
|
||||
fwrite($f, "\tuse WebFX\\System;\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\t// Whether we should enable users to run the setup application\n");
|
||||
fwrite($f, "\tSystem::\$Configuration[\"Setup.Enabled\"] = false;\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\t// The base path of the Web site\n");
|
||||
fwrite($f, "\tSystem::\$Configuration[\"Application.BasePath\"] = \"" . System::$Configuration["Application.BasePath"] . "\";\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\t// The default tenant for the Web site\n");
|
||||
fwrite($f, "\tSystem::\$Configuration[\"Application.DefaultTenant\"] = \"" . $_POST["Application_DefaultTenant"] . "\";\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\t// Administration credentials for Tenant Manager\n");
|
||||
fwrite($f, "\tSystem::\$Configuration[\"Administration.UserName\"] = \"" . $_POST["TenantManager_UserName"] . "\";\n");
|
||||
fwrite($f, "\tSystem::\$Configuration[\"Administration.Password\"] = \"" . $_POST["TenantManager_Password"] . "\";\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\t// The location of static WebFramework-related files (scripts, stylesheets, etc.)\n");
|
||||
fwrite($f, "\tSystem::\$Configuration[\"WebFramework.StaticPath\"] = \"" . System::$Configuration["WebFramework.StaticPath"] . "\";\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "\t// *** GENERATED BY " . System::$Configuration["Application.Name"] . " SETUP APPLICATION - DO NOT EDIT BELOW THIS LINE ***\n");
|
||||
|
||||
$preinstalledKeys = array("Setup.Enabled", "Application.BasePath", "WebFramework.StaticPath", "Account.LoginPath", "Account.RegisterPath", "Account.ResetPasswordPath", "Application.DefaultTenant", "AdministratorUserName", "AdministratorPassword");
|
||||
foreach (System::$Configuration as $key => $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;
|
||||
}
|
||||
?>
|
||||
<div style="text-align: center;">
|
||||
<img src="<?php echo(System::ExpandRelativePath("~/Images/Logo.png")); ?>" style="height: 200px;" />
|
||||
</div>
|
||||
<p style="text-align: center;">
|
||||
<?php echo(System::$Configuration["Application.Name"]); ?> is configuring your initial instance. This would be a good time for a coffee break...
|
||||
</p>
|
||||
<table style="width: 600px; margin-left: auto; margin-right: auto;" border="1">
|
||||
<?php
|
||||
Message("Writing configuration file");
|
||||
|
||||
// set the database configuration
|
||||
System::$Configuration["Database.ServerName"] = $_POST["database_servername"];
|
||||
System::$Configuration["Database.DatabaseName"] = $_POST["database_databasename"];
|
||||
System::$Configuration["Database.UserName"] = $_POST["database_username"];
|
||||
System::$Configuration["Database.Password"] = $_POST["database_password"];
|
||||
System::$Configuration["Database.TablePrefix"] = $_POST["database_tableprefix"];
|
||||
|
||||
$retval = SaveConfiguration();
|
||||
|
||||
if ($retval)
|
||||
{
|
||||
Success("Configuration file wrote successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Failure("Could not write the configuration file!");
|
||||
return true;
|
||||
}
|
||||
|
||||
$retval = DataFX::Initialize();
|
||||
|
||||
if ($retval)
|
||||
{
|
||||
Success("Initialized DataFX library");
|
||||
}
|
||||
else
|
||||
{
|
||||
Failure("Could not initialize DataFX library with the new configuration!");
|
||||
Message("Database returned error " . DataFX::$Errors->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");
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
return true;
|
||||
}
|
||||
|
||||
$page = new WebPage();
|
||||
$page->BeginContent();
|
||||
?>
|
||||
<div style="text-align: center;">
|
||||
<img src="<?php echo(System::ExpandRelativePath("~/Images/Logo.png")); ?>" style="height: 200px;" />
|
||||
</div>
|
||||
<p style="text-align: center;">
|
||||
Please provide some information about your server to create the initial <?php echo(System::$Configuration["Application.Name"]); ?> tenant. Other
|
||||
tenants may be created and removed at any time by entering the Administrator Control Panel.
|
||||
</p>
|
||||
<form method="POST">
|
||||
<table style="width: 400px; margin-left: auto; margin-right: auto;">
|
||||
<tr>
|
||||
<td style="width: 128px;"><label for="txtServerName">Server name:</label></td>
|
||||
<td><input type="text" id="txtServerName" name="database_servername" style="width: 100%;" value="<?php echo(System::GetConfigurationValue("Database.ServerName", "localhost")); ?>" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtDatabaseName">Database name:</label></td>
|
||||
<td><input type="text" id="txtDatabaseName" name="database_databasename" style="width: 100%;" value="<?php echo(System::GetConfigurationValue("Database.DatabaseName", "Objectify")); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtUserName">User name:</label></td>
|
||||
<td><input type="text" id="txtUserName" name="database_username" style="width: 100%;" value="<?php echo(System::GetConfigurationValue("Database.UserName", "Objectify")); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtPassword">Password:</label></td>
|
||||
<td><input type="password" id="txtPassword" name="database_password" value="" style="width: 100%;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtTablePrefix">Table prefix:</label></td>
|
||||
<td><input type="text" id="txtTablePrefix" name="database_tableprefix" value="<?php echo(System::GetConfigurationValue("Database.TablePrefix", "phoenix_")); ?>" style="width: 100%;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><hr /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtAdministratorUserName">Administrator user name:</label></td>
|
||||
<td><input type="text" id="txtAdministratorUserName" name="TenantManager_UserName" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtAdministratorPassword">Administrator password:</label></td>
|
||||
<td><input type="password" id="txtAdministratorPassword" name="TenantManager_Password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtDefaultTenant">Initial tenant:</label></td>
|
||||
<td><input type="text" id="txtDefaultTenant" name="Application_DefaultTenant" value="default" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center;"><input type="submit" value="Continue" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
$page->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("<div style=\"text-align: center;\"><img style=\"height: 120px;\" src=\"" . System::ExpandRelativePath("~/Images/ObjectifyLogo.png") . "\" /></div><div>This Objectify installation has not been configured. Please contact the server administrator.</div>");
|
||||
$page->EndContent();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
));
|
||||
?>
|
||||
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tblDataTypes = new Table("DataTypes", "datatype_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("Name", "VARCHAR", 256, null, true),
|
||||
new Column("Description", "LONGTEXT", null, null, true),
|
||||
new Column("EncoderCodeBlob", "LONGBLOB", null, ColumnValue::Undefined, true),
|
||||
new Column("DecoderCodeBlob", "LONGBLOB", null, ColumnValue::Undefined, true),
|
||||
new Column("ColumnRendererCodeBlob", "LONGBLOB", null, ColumnValue::Undefined, true),
|
||||
new Column("EditorRendererCodeBlob", "LONGBLOB", null, ColumnValue::Undefined, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "Text"),
|
||||
new RecordColumn("Description", "Allows you to enter a single line of text."),
|
||||
new RecordColumn("EncoderCodeBlob", ColumnValue::Undefined),
|
||||
new RecordColumn("DecoderCodeBlob", ColumnValue::Undefined),
|
||||
new RecordColumn("ColumnRendererCodeBlob", ColumnValue::Undefined),
|
||||
new RecordColumn("EditorRendererCodeBlob", ColumnValue::Undefined)
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "Memo"),
|
||||
new RecordColumn("Description", "Allows you to enter large amounts of text."),
|
||||
new RecordColumn("EncoderCodeBlob", ColumnValue::Undefined),
|
||||
new RecordColumn("DecoderCodeBlob", ColumnValue::Undefined),
|
||||
new RecordColumn("ColumnRendererCodeBlob", <<<'EOD'
|
||||
echo("<div style=\"width: 100%; overflow: scroll; overflow-x: hidden;\">" . $input . "</div>");
|
||||
EOD
|
||||
),
|
||||
new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
|
||||
echo("<textarea id=\"" . $name . "\" name=\"" . $name . "\">" . $input . "</textarea>");
|
||||
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("<div style=\"width: 100%; overflow: scroll; overflow-x: hidden;\">" . $input . "</div>");
|
||||
EOD
|
||||
),
|
||||
new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
|
||||
echo("<textarea id=\"" . $name . "\" name=\"" . $name . "\">" . $input . "</textarea>");
|
||||
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("<input type=\"checkbox\" disabled=\"disabled\" />");
|
||||
EOD
|
||||
),
|
||||
new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
|
||||
echo("<input type=\"checkbox\" id=\"" . $name . "\" name=\"" . $name . "\" />");
|
||||
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("<input type=\"text\" id=\"Measurement_" . $name . "_Value\" /> <select id=\"Measurement_" . $name . "_Unit\">");
|
||||
echo("<option value=\"px\" selected=\"selected\">px</option>");
|
||||
echo("<option value=\"pt\" selected=\"selected\">pt</option>");
|
||||
echo("<option value=\"em\" selected=\"selected\">em</option>");
|
||||
echo("<option value=\"%\" selected=\"selected\">%</option>");
|
||||
echo("</select>");
|
||||
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("<div class=\"InstanceEditor SingleInstance ReadOnly\">");
|
||||
echo("<input type=\"hidden\" id=\"" . $name . "_Instances\" name=\"" . $name . "_Instances\" />");
|
||||
echo("<div class=\"InstanceList\">");
|
||||
if ($inst != null)
|
||||
{
|
||||
echo ("<a href=\"#\">" . $inst->ToString() . "</a>");
|
||||
}
|
||||
echo("</div>");
|
||||
echo("</div>");
|
||||
EOD
|
||||
),
|
||||
new RecordColumn("EditorRendererCodeBlob", <<<'EOD'
|
||||
$inst = $input->Instance;
|
||||
echo("<div class=\"InstanceEditor SingleInstance\">");
|
||||
$insts_text = $inst->ID;
|
||||
echo("<input type=\"hidden\" id=\"" . $name . "_Instances\" name=\"" . $name . "_Instances\" value=\"" . $insts_text . "\" />");
|
||||
echo("<input type=\"text\" id=\"" . $name . "_CurrentInstance\" name=\"" . $name . "_CurrentInstance\" />");
|
||||
echo("<div class=\"InstanceList\">");
|
||||
if ($inst != null)
|
||||
{
|
||||
echo ("<a href=\"#\">" . $inst->ToString() . "</a>");
|
||||
}
|
||||
echo("</div>");
|
||||
echo("<script type=\"text/javascript\">");
|
||||
echo("var t = document.getElementById('" . $name . "_CurrentInstance');");
|
||||
echo("t.onkeydown = function(e) { ");
|
||||
echo("alert(e.keyCode);");
|
||||
echo("};");
|
||||
echo("</script>");
|
||||
echo("</div>");
|
||||
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("<div class=\"InstanceEditor MultipleInstance ReadOnly\">");
|
||||
echo("<input type=\"hidden\" id=\"" . $name . "_Instances\" name=\"" . $name . "_Instances\" />");
|
||||
echo("<input type=\"text\" id=\"" . $name . "_CurrentInstance\" name=\"" . $name . "_CurrentInstance\" />");
|
||||
echo("<div class=\"InstanceList\">");
|
||||
foreach ($insts as $inst)
|
||||
{
|
||||
if ($inst != null)
|
||||
{
|
||||
echo ("<a href=\"#\">" . $inst->ToString() . "</a>");
|
||||
}
|
||||
}
|
||||
echo("</div>");
|
||||
echo("</div>");
|
||||
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("<div class=\"InstanceEditor MultipleInstance\">");
|
||||
$insts_text = "";
|
||||
$count = count($insts);
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
$inst = $insts[$i];
|
||||
$insts_text .= $inst->ID;
|
||||
if ($i < $count - 1) $insts_text .= ", ";
|
||||
}
|
||||
echo("<input type=\"hidden\" id=\"" . $name . "_Instances\" name=\"" . $name . "_Instances\" value=\"" . $insts_text . "\" />");
|
||||
echo("<input type=\"text\" id=\"" . $name . "_CurrentInstance\" name=\"" . $name . "_CurrentInstance\" />");
|
||||
echo("<div class=\"InstanceList\">");
|
||||
foreach ($insts as $inst)
|
||||
{
|
||||
if ($inst != null)
|
||||
{
|
||||
echo ("<a href=\"#\">" . $inst->ToString() . "</a>");
|
||||
}
|
||||
}
|
||||
echo("</div>");
|
||||
echo("<script type=\"text/javascript\">");
|
||||
echo("var t = document.getElementById('" . $name . "_CurrentInstance');");
|
||||
echo("t.onkeydown = function(e) { ");
|
||||
echo("alert(e.keyCode);");
|
||||
echo("};");
|
||||
echo("</script>");
|
||||
echo("</div>");
|
||||
EOD
|
||||
)
|
||||
))
|
||||
));
|
||||
$tables[] = $tblDataTypes;
|
||||
?>
|
||||
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
use DataFX\TableKey;
|
||||
use DataFX\TableKeyColumn;
|
||||
use DataFX\TableForeignKey;
|
||||
use DataFX\TableForeignKeyColumn;
|
||||
|
||||
$tblLanguages = new Table("Languages", "language_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("Name", "VARCHAR", 64, null, false)
|
||||
));
|
||||
$tables[] = $tblLanguages;
|
||||
?>
|
||||
168
PHP/Manager/Include/Modules/001-Setup/Tables/000-Modules.inc.php
Normal file
168
PHP/Manager/Include/Modules/001-Setup/Tables/000-Modules.inc.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
use DataFX\TableForeignKey;
|
||||
use DataFX\TableForeignKeyColumn;
|
||||
|
||||
$tblModules = new Table("Modules", "module_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("Title", "VARCHAR", 256, null, true),
|
||||
new Column("Description", "LONGTEXT", null, null, true),
|
||||
new Column("Enabled", "INT", null, 1, false)
|
||||
),
|
||||
array
|
||||
(
|
||||
// Discussions (V2) provides all the functionality of V1 Pages, Groups, and Forums
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Discussions"),
|
||||
new RecordColumn("Description", "Provides various types of discussion boards, pages, groups, and forums that allow your users to connect and communicate about specific topics.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Market"),
|
||||
new RecordColumn("Description", "Provides a virtual market system that allows users to buy and sell virtual items, create their own brands and stores, and item trading.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Brands"),
|
||||
new RecordColumn("Description", "Allows users to create their own brands and stores to sell their own virtual items.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Trading"),
|
||||
new RecordColumn("Description", "Allows users to trade items with each other. Items can be set to not be tradable, or only be tradable under certain conditions.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "World"),
|
||||
new RecordColumn("Description", "Provides a virtual world that is divided into Places. Users can have one or more personal Places, and complete access control is allowed.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Partners"),
|
||||
new RecordColumn("Description", "Allows you to promote other organizations and display advertisements on your social network.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Arcade"),
|
||||
new RecordColumn("Description", "Enables the hosting of games inside the social network, with integrated redemption rewards and leaderboard statistics tracking.")
|
||||
))
|
||||
));
|
||||
$tables[] = $tblModules;
|
||||
|
||||
$tblModuleMenuItems = new Table("ModuleMenuItems", "menuitem_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("ModuleID", "INT", null, null, false),
|
||||
new Column("Title", "VARCHAR", 256, null, false),
|
||||
new Column("Description", "LONGTEXT", null, null, true),
|
||||
new Column("TargetURL", "LONGTEXT", null, null, true),
|
||||
new Column("TargetScript", "LONGTEXT", null, null, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("ModuleID", 2),
|
||||
new RecordColumn("Title", "Market"),
|
||||
new RecordColumn("Description", "Buy, sell, and trade resources and items, and play Chance to win mystery rewards"),
|
||||
new RecordColumn("TargetURL", "~/market"),
|
||||
new RecordColumn("TargetScript", ColumnValue::Undefined)
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("ModuleID", 5),
|
||||
new RecordColumn("Title", "World"),
|
||||
new RecordColumn("Description", "Explore a virtual world with your very own animated avatar"),
|
||||
new RecordColumn("TargetURL", "~/world"),
|
||||
new RecordColumn("TargetScript", ColumnValue::Undefined)
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("ModuleID", 6),
|
||||
new RecordColumn("Title", "Partners"),
|
||||
new RecordColumn("Description", "See who we've partnered with to bring you even more awesome experiences, and learn about becoming a partner yourself"),
|
||||
new RecordColumn("TargetURL", "~/partners"),
|
||||
new RecordColumn("TargetScript", ColumnValue::Undefined)
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("ModuleID", 7),
|
||||
new RecordColumn("Title", "Arcade"),
|
||||
new RecordColumn("Description", "Play games and make friends in the Arcade."),
|
||||
new RecordColumn("TargetURL", "~/arcade"),
|
||||
new RecordColumn("TargetScript", ColumnValue::Undefined)
|
||||
))
|
||||
));
|
||||
$tblModuleMenuItems->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;
|
||||
?>
|
||||
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
use DataFX\TableKey;
|
||||
use DataFX\TableKeyColumn;
|
||||
use DataFX\TableForeignKey;
|
||||
use DataFX\TableForeignKeyColumn;
|
||||
|
||||
$tblTenants = new Table("Tenants", "tenant_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("URL", "VARCHAR", 30, null, true),
|
||||
new Column("Description", "LONGTEXT", null, null, false),
|
||||
new Column("Status", "INT", null, null, true),
|
||||
new Column("TypeID", "INT", null, null, true),
|
||||
new Column("PaymentPlanID", "INT", null, null, true),
|
||||
new Column("BeginTimestamp", "DATETIME", null, null, true),
|
||||
new Column("EndTimestamp", "DATETIME", null, null, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
));
|
||||
|
||||
$tblTenants->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;
|
||||
?>
|
||||
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
use DataFX\TableKey;
|
||||
use DataFX\TableKeyColumn;
|
||||
use DataFX\TableForeignKey;
|
||||
use DataFX\TableForeignKeyColumn;
|
||||
|
||||
$tblTenantObjects = new Table("TenantObjects", "object_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("TenantID", "INT", null, null, true), // if set, object is only visible/referencable within specified tenant
|
||||
new Column("ModuleID", "INT", null, null, true), // if set, object is only visible/referencable when specified module is enabled
|
||||
new Column("ParentObjectID", "INT", null, null, true), // if set, object inherits its permissions, properties, and other attributes from given object
|
||||
new Column("Name", "VARCHAR", 256, null, false)
|
||||
));
|
||||
$tblTenantObjects->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;
|
||||
?>
|
||||
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tables[] = new Table("DataCenters", "datacenter_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("Title", "VARCHAR", 256, null, true),
|
||||
new Column("Description", "LONGTEXT", null, null, true),
|
||||
new Column("HostName", "VARCHAR", 256, null, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Default"),
|
||||
new RecordColumn("Description", "The initial data center configured for PhoenixSNS tenanted hosting."),
|
||||
new RecordColumn("HostName", "www.yourdomain.com")
|
||||
))
|
||||
));
|
||||
?>
|
||||
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
use DataFX\TableForeignKey;
|
||||
use DataFX\TableForeignKeyColumn;
|
||||
use DataFX\TableForeignKeyReferenceOption;
|
||||
|
||||
$tblDebugMessages = new Table("DebugMessages", "message_", 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("Content", "LONGTEXT", null, null, false),
|
||||
new Column("SeverityID", "INT", null, 0, false),
|
||||
new Column("Timestamp", "DATETIME", null, null, false),
|
||||
new Column("IPAddress", "VARCHAR", 40, "", false)
|
||||
));
|
||||
$tables[] = $tblDebugMessages;
|
||||
|
||||
$tblDebugMessageBacktraces = new Table("DebugMessageBacktraces", "bt_", 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("FileName", "LONGTEXT", null, null, false),
|
||||
new Column("LineNumber", "INT", null, null, true)
|
||||
));
|
||||
$tblDebugMessageBacktraces->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;
|
||||
?>
|
||||
213
PHP/Manager/Include/Modules/001-Setup/Tables/Languages.inc.php
Normal file
213
PHP/Manager/Include/Modules/001-Setup/Tables/Languages.inc.php
Normal file
@ -0,0 +1,213 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tables[] = new Table("Languages", "language_", 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", 5, null, false),
|
||||
new Column("Title", "VARCHAR", 50, null, false)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "en-US"),
|
||||
new RecordColumn("Title", "English (United States)")
|
||||
))
|
||||
));
|
||||
|
||||
$tables[] = new Table("LanguageStrings", "languagestring_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("TenantID", "INT", null, null, false),
|
||||
new Column("LanguageID", "INT", null, null, false),
|
||||
new Column("StringName", "VARCHAR", 50, null, false),
|
||||
new Column("StringValue", "LONGTEXT", null, null, false)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "like"),
|
||||
new RecordColumn("StringValue", "Like")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "comment"),
|
||||
new RecordColumn("StringValue", "Comment")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "download"),
|
||||
new RecordColumn("StringValue", "Download")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "share"),
|
||||
new RecordColumn("StringValue", "Share")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "groups"),
|
||||
new RecordColumn("StringValue", "Groups")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "friends"),
|
||||
new RecordColumn("StringValue", "Friends")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "nogroups"),
|
||||
new RecordColumn("StringValue", "This user is not a member of any groups.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("LanguageID", 1),
|
||||
new RecordColumn("StringName", "nofriends"),
|
||||
new RecordColumn("StringValue", "This user does not have any friends. <a href=\"#\" onclick=\"AddFriendDialog.ShowDialog(); return false;\">Introduce yourself!</a>")
|
||||
)),
|
||||
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.")
|
||||
))
|
||||
));
|
||||
?>
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tables[] = new Table("PaymentPlans", "paymentplan_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("Title", "VARCHAR", 256, null, true),
|
||||
new Column("Description", "LONGTEXT", null, null, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Unpaid"),
|
||||
new RecordColumn("Description", "The owner is not paying for the provisioning of this tenant.")
|
||||
))
|
||||
));
|
||||
?>
|
||||
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
use PhoenixSNS\Objects\UserPresenceStatus;
|
||||
use PhoenixSNS\Objects\UserProfileVisibility;
|
||||
|
||||
$tables[] = new Table("SecurityPermissions", "permission_", 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", 50, null, false),
|
||||
new Column("Title", "LONGTEXT", null, null, false)
|
||||
), array
|
||||
(
|
||||
// 1
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "GroupCreate"),
|
||||
new RecordColumn("Title", "Create a group")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "GroupModify"),
|
||||
new RecordColumn("Title", "Modify groups created by others")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "GroupDelete"),
|
||||
new RecordColumn("Title", "Delete groups created by others")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "UserBan"),
|
||||
new RecordColumn("Title", "Ban a user from the network")
|
||||
)),
|
||||
// 5
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "PlaceCreate"),
|
||||
new RecordColumn("Title", "Create a Place as a normal user")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "PlaceCreateOfficial"),
|
||||
new RecordColumn("Title", "Create a Place as the official administrative user")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Name", "PersonalDefaultPageModify"),
|
||||
new RecordColumn("Title", "Modify your own Default Page")
|
||||
))
|
||||
));
|
||||
|
||||
$tables[] = new Table("SecurityGroups", "group_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("Title", "VARCHAR", 50, null, false),
|
||||
new Column("ParentGroupID", "INT", null, null, true)
|
||||
), array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Administrator"),
|
||||
new RecordColumn("ParentGroupID", ColumnValue::Undefined)
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Moderator"),
|
||||
new RecordColumn("ParentGroupID", 3)
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Member")
|
||||
))
|
||||
));
|
||||
|
||||
$tables[] = new Table("SecurityGroupPermissions", "grouppermission_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("GroupID", "INT", null, null, false),
|
||||
new Column("PermissionID", "INT", null, null, false)
|
||||
), array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("GroupID", 1), // Administrator
|
||||
new RecordColumn("PermissionID", 6) // (all moderator permissions) + PlaceCreateOfficial
|
||||
)),
|
||||
|
||||
// MODERATOR PERMISSIONS
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("GroupID", 2), // moderator
|
||||
new RecordColumn("PermissionID", 2) // (all member permissions) + GroupModify
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("GroupID", 2), // moderator
|
||||
new RecordColumn("PermissionID", 4) // (all member permissions) + UserBan
|
||||
)),
|
||||
|
||||
// MEMBER PERMISSIONS
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("GroupID", 3), // member
|
||||
new RecordColumn("PermissionID", 1) // GroupCreate
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("GroupID", 3), // member
|
||||
new RecordColumn("PermissionID", 5) // PlaceCreate
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("GroupID", 3), // member
|
||||
new RecordColumn("PermissionID", 7) // PersonalDefaultPageModify
|
||||
))
|
||||
));
|
||||
?>
|
||||
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tables[] = new Table("TenantDataCenters", "tdc_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("TenantID", "INT", null, null, true),
|
||||
new Column("DataCenterID", "INT", null, null, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("TenantID", 1),
|
||||
new RecordColumn("DataCenterID", 1)
|
||||
))
|
||||
));
|
||||
?>
|
||||
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tables[] = new Table("TenantTypes", "tenanttype_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, true),
|
||||
new Column("Title", "VARCHAR", 256, null, true),
|
||||
new Column("Description", "LONGTEXT", null, null, true)
|
||||
),
|
||||
array
|
||||
(
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Production"),
|
||||
new RecordColumn("Description", "The production tenant type. Usually the only tenant type visible to regular users. Add more (such as production, development, sandbox, sandbox preview, implementation preview, implementation) as needed.")
|
||||
)),
|
||||
new Record(array
|
||||
(
|
||||
new RecordColumn("Title", "Development"),
|
||||
new RecordColumn("Description", "The development tenant type. Usually used to create new features and modules before pushing them to production. Add more (such as production, development, sandbox, sandbox preview, implementation preview, implementation) as needed.")
|
||||
))
|
||||
));
|
||||
?>
|
||||
17
PHP/Manager/Include/Modules/001-Setup/Tables/Users.inc.php
Normal file
17
PHP/Manager/Include/Modules/001-Setup/Tables/Users.inc.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
use DataFX\DataFX;
|
||||
use DataFX\Table;
|
||||
use DataFX\Column;
|
||||
use DataFX\ColumnValue;
|
||||
use DataFX\Record;
|
||||
use DataFX\RecordColumn;
|
||||
|
||||
$tables[] = new Table("Users", "user_", array
|
||||
(
|
||||
// $name, $dataType, $size, $value, $allowNull, $primaryKey, $autoIncrement
|
||||
new Column("ID", "INT", null, null, false, true, true),
|
||||
new Column("LoginID", "VARCHAR", 50, null, false),
|
||||
new Column("PasswordHash", "VARCHAR", 256, null, false),
|
||||
new Column("PasswordSalt", "VARCHAR", 32, null, false)
|
||||
));
|
||||
?>
|
||||
48
PHP/Manager/Include/Pages/000-LoginPage.inc.php
Normal file
48
PHP/Manager/Include/Pages/000-LoginPage.inc.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
use Objectify\Objects\Tenant;
|
||||
|
||||
class LoginPage extends WebPage
|
||||
{
|
||||
public $InvalidCredentials;
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
<h1>Authentication Required</h1>
|
||||
<p>You must log in to view this page.</p>
|
||||
<form method="POST">
|
||||
<table style="margin-left: auto; margin-right: auto;" class="Borderless">
|
||||
<tr>
|
||||
<td><label for="txtUserName">User <u>N</u>ame</label></td>
|
||||
<td><input type="text" name="user_LoginID" id="txtUserName" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtPassword"><u>P</u>assword</label></td>
|
||||
<td><input type="password" name="user_Password" id="txtPassword" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="color: #FF0000; text-align: center;">
|
||||
<?php
|
||||
if ($this->InvalidCredentials)
|
||||
{
|
||||
?>Incorrect user name/password combination.<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: right;">
|
||||
<input type="submit" value="Continue" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
116
PHP/Manager/Include/Pages/000-MainPage.inc.php
Normal file
116
PHP/Manager/Include/Pages/000-MainPage.inc.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
use Objectify\Objects\Tenant;
|
||||
|
||||
class MainPage extends WebPage
|
||||
{
|
||||
protected function RenderContent()
|
||||
{
|
||||
$tenants = Tenant::Get();
|
||||
?>
|
||||
<h1>Tenant Management</h1>
|
||||
<p>There are <?php echo(count($tenants)); ?> tenants in total.</p>
|
||||
|
||||
<div class="Toolbar">
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/tenant/create")); ?>">Create New Tenant</a>
|
||||
</div>
|
||||
<?php
|
||||
$countActive = 0;
|
||||
$countExpired = 0;
|
||||
foreach ($tenants as $tenant)
|
||||
{
|
||||
if ($tenant->IsExpired())
|
||||
{
|
||||
$countExpired++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$countActive++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h2>Active Tenants (<?php echo($countActive); ?>)</h2>
|
||||
<table class="ListView" style="width: 100%;" border="1">
|
||||
<tr>
|
||||
<th>Tenant Name</th>
|
||||
<th>Tenant Type</th>
|
||||
<th>Data Centers</th>
|
||||
<th>Payment Plan</th>
|
||||
<th>Activation Date</th>
|
||||
<th>Termination Date</th>
|
||||
<th>Description</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($tenants as $tenant)
|
||||
{
|
||||
if ($tenant->IsExpired()) continue;
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/tenant/launch/" . $tenant->URL)); ?>" target="_blank"><?php echo($tenant->URL); ?></a></td>
|
||||
<td><?php echo($tenant->Type->Title); ?></td>
|
||||
<td><?php
|
||||
foreach ($tenant->DataCenters->Items as $item)
|
||||
{
|
||||
echo("<a href=\"http://" . $item->HostName . "/" . $tenant->URL . "\">" . $item->Title . " (" . $item->HostName . ")</a><br />");
|
||||
}
|
||||
?></td>
|
||||
<td><?php echo($tenant->PaymentPlan->Title); ?></td>
|
||||
<td><?php echo($tenant->BeginTimestamp == null ? "(indefinite)" : $tenant->BeginTimestamp); ?></td>
|
||||
<td><?php echo($tenant->EndTimestamp == null ? "(indefinite)" : $tenant->EndTimestamp); ?></td>
|
||||
<td><?php echo($tenant->Description); ?></td>
|
||||
<td style="text-align: center;">
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $tenant->URL)); ?>">Manage</a> |
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/modify/" . $tenant->URL)); ?>">Edit</a> |
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/clone/" . $tenant->URL)); ?>">Clone</a> |
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/delete/" . $tenant->URL)); ?>">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<h2>Inactive Tenants (<?php echo($countExpired); ?>)</h2>
|
||||
<table class="ListView" style="width: 100%;" border="1">
|
||||
<tr>
|
||||
<th>Tenant Name</th>
|
||||
<th>Tenant Type</th>
|
||||
<th>Data Centers</th>
|
||||
<th>Payment Plan</th>
|
||||
<th>Activation Date</th>
|
||||
<th>Termination Date</th>
|
||||
<th>Description</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($tenants as $tenant)
|
||||
{
|
||||
if (!$tenant->IsExpired()) continue;
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/tenant/launch/" . $tenant->URL)); ?>" target="_blank"><?php echo($tenant->URL); ?></a></td>
|
||||
<td><?php echo($tenant->Type->Title); ?></td>
|
||||
<td><?php echo($tenant->DataCenter->Title); ?></td>
|
||||
<td><?php echo($tenant->PaymentPlan->Title); ?></td>
|
||||
<td><?php echo($tenant->BeginTimestamp == null ? "(indefinite)" : $tenant->BeginTimestamp); ?></td>
|
||||
<td><?php echo($tenant->EndTimestamp == null ? "(indefinite)" : $tenant->EndTimestamp); ?></td>
|
||||
<td><?php echo($tenant->Description); ?></td>
|
||||
<td style="text-align: center;">
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $tenant->URL)); ?>">Manage</a> |
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/modify/" . $tenant->URL)); ?>">Edit</a> |
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/clone/" . $tenant->URL)); ?>">Clone</a> |
|
||||
<a href="<?php echo(System::ExpandRelativePath("~/tenant/delete/" . $tenant->URL)); ?>">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
104
PHP/Manager/Include/Pages/001-TenantPropertiesPage.inc.php
Normal file
104
PHP/Manager/Include/Pages/001-TenantPropertiesPage.inc.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class TenantPropertiesPage extends WebPage
|
||||
{
|
||||
public $Tenant;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
if ($this->Tenant != null)
|
||||
{
|
||||
$this->Title = "Edit Tenant Configuration: " . $this->Tenant->URL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Title = "Create New Tenant";
|
||||
}
|
||||
}
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
<h1>Edit Tenant Configuration</h1>
|
||||
<form method="POST">
|
||||
<table style="margin-left: auto; margin-right: auto; width: 500px;">
|
||||
<tr>
|
||||
<td style="width: 160px;"><label for="txtTenantURL">Name:</label></td>
|
||||
<td colspan="2"><input type="text" style="width: 100%;" id="txtTenantURL" name="tenant_URL" value="<?php if ($this->Tenant != null) echo($this->Tenant->URL); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="cboTenantType">Type:</label></td>
|
||||
<td colspan="2">
|
||||
<select id="cboTenantType" name="tenant_TypeID">
|
||||
<?php
|
||||
$tenanttypes = TenantType::Get();
|
||||
foreach ($tenanttypes as $tenanttype)
|
||||
{
|
||||
?><option<?php if ($this->Tenant != null && $this->Tenant->Type != null && $tenanttype->ID == $this->Tenant->Type->ID) { echo(" selected=\"selected\""); } ?> value="<?php echo($tenanttype->ID); ?>"><?php echo($tenanttype->Title); ?></option><?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="cboDataCenter">Data center:</label></td>
|
||||
<td colspan="2">
|
||||
<?php
|
||||
$datacenters = DataCenter::Get();
|
||||
foreach ($datacenters as $datacenter)
|
||||
{
|
||||
?><div><input type="checkbox" value="1" <?php if ($this->Tenant != null && $this->Tenant->DataCenters->Contains($datacenter)) { echo(" checked=\"checked\""); } ?> name="tenant_DataCenter_<?php echo($datacenter->ID); ?>" id="txtTenantDataCenter_<?php echo($datacenter->ID); ?>" /><label for="txtTenantDataCenter_<?php echo($datacenter->ID); ?>"><?php echo($datacenter->Title); ?></label><?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="cboPaymentPlan">Payment plan:</label></td>
|
||||
<td colspan="2">
|
||||
<select id="cboPaymentPlan" name="tenant_PaymentPlanID">
|
||||
<?php
|
||||
$paymentplans = PaymentPlan::Get();
|
||||
foreach ($paymentplans as $paymentplan)
|
||||
{
|
||||
?><option<?php if ($this->Tenant != null && $this->Tenant->PaymentPlan != null && $paymentplan->ID == $this->Tenant->PaymentPlan->ID) { echo(" selected=\"selected\""); } ?> value="<?php echo($paymentplan->ID); ?>"><?php echo($paymentplan->Title); ?></option><?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtActivationDate">Activation date:</label></td>
|
||||
<td><input type="text" style="width: 100%;" id="txtActivationDate" name="tenant_BeginTimestamp" value="<?php if ($this->Tenant != null) echo($this->Tenant->BeginTimestamp); ?>" /></td>
|
||||
<td style="width: 96px"><input type="checkbox" id="chkActivationDateValid" name="tenant_BeginTimestampValid" value="1" /><label for="chkActivationDateValid">Indefinite</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtTerminationDate">Termination date:</label></td>
|
||||
<td><input type="text" style="width: 100%;" id="txtTerminationDate" name="tenant_EndTimestamp" value="<?php if ($this->Tenant != null) echo($this->Tenant->EndTimestamp); ?>" /></td>
|
||||
<td style="width: 96px"><input type="checkbox" id="chkTerminationDateValid" name="tenant_EndTimestampValid" value="1" /><label for="chkTerminationDateValid">Indefinite</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;"><label for="txtDescription">Description:</label></td>
|
||||
<td colspan="2"><textarea style="width: 100%;" rows="5" id="txtDescription" name="tenant_Description"><?php if ($this->Tenant != null) echo($this->Tenant->Description); ?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="Buttons">
|
||||
<input type="submit" value="Save Changes" />
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/tenant")); ?>">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
39
PHP/Manager/Include/Pages/002-ConfirmOperationPage.inc.php
Normal file
39
PHP/Manager/Include/Pages/002-ConfirmOperationPage.inc.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
// use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class ConfirmOperationPage extends WebPage
|
||||
{
|
||||
public $Message;
|
||||
|
||||
public $ReturnButtonURL;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->ReturnButtonURL = "~/";
|
||||
}
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
<h1>Confirm Operation</h1>
|
||||
<p><?php echo($this->Message); ?></p>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="Confirm" value="1" />
|
||||
<input type="submit" value="Continue" />
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath($this->ReturnButtonURL)); ?>">Cancel</a>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
125
PHP/Manager/Include/Pages/003-TenantManagementPage.inc.php
Normal file
125
PHP/Manager/Include/Pages/003-TenantManagementPage.inc.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
use WebFX\Controls\TabContainer;
|
||||
use WebFX\Controls\TabPage;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
use Objectify\Objects\Module;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObject;
|
||||
use Objectify\Objects\TenantProperty;
|
||||
use Objectify\Objects\TenantPropertyValue;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class TenantManagementPage extends WebPage
|
||||
{
|
||||
public $Tenant;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
$this->Title = "Manage Tenant: " . $this->Tenant->URL;
|
||||
}
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
<h1>Tenant: <?php echo($this->Tenant->URL); ?></h1>
|
||||
<form method="POST">
|
||||
<?php
|
||||
$tbs = new TabContainer("tbsTabs");
|
||||
$tbs->TabPages[] = new TabPage("tabCustomProperties", "Custom Properties", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr id="Property_Header">
|
||||
<th style="width: 32px;"><a href="#" onclick="AddPropertyBelow('Header');" title="Add Below">[+]</a></th>
|
||||
<th style="width: 256px;">Property</th>
|
||||
<th>Description</th>
|
||||
<th style="width: 256px;">Value</th>
|
||||
</tr>
|
||||
<?php
|
||||
$properties = $this->Tenant->GetProperties();
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
?>
|
||||
<tr id="Property_<?php echo($property->ID); ?>">
|
||||
<td style="width: 32px;"><a href="#" onclick="AddPropertyBelow('<?php echo($property->ID); ?>');" title="Add Below">[+]</a></td>
|
||||
<td><?php echo($property->Name); ?></td>
|
||||
<td><?php echo($property->Description); ?></td>
|
||||
<td><?php $property->RenderEditor($this->Tenant->GetPropertyValue($property)); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
|
||||
$tbs->TabPages[] = new TabPage("tabEnabledModules", "Enabled Modules", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<p>Click on a module name to configure the module on this tenant.</p>
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr>
|
||||
<th style="width: 128px;">Module</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<?php
|
||||
$modules = Module::Get(null, $this->Tenant);
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><input id="chkModule_<?php echo($module->ID); ?>" type="checkbox"<?php if ($module->Enabled) { echo(" checked=\"checked\""); } ?> /> <a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->Tenant->URL . "/modules/" . $module->ID)); ?>"><?php echo($module->Title); ?></a></td>
|
||||
<td><?php echo($module->Description); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
|
||||
$tbs->TabPages[] = new TabPage("tabGlobalObjects", "Global Objects", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<p>Lists all of the objects that are available on this tenant that are not associated with a particular Module.</p>
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr>
|
||||
<th style="width: 128px;">Object</th>
|
||||
<th>Description</th>
|
||||
<th>Instances</th>
|
||||
</tr>
|
||||
<?php
|
||||
$objects = TenantObject::Get(null, $this->Tenant);
|
||||
foreach ($objects as $object)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->Tenant->URL . "/objects/" . $object->ID)); ?>"><?php echo($object->Name); ?></a></td>
|
||||
<td><?php echo($object->Description); ?></td>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->Tenant->URL . "/objects/" . $object->ID . "/instances")); ?>"><?php echo($object->CountInstances()); ?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
|
||||
$tbs->Render();
|
||||
?>
|
||||
<div class="Buttons">
|
||||
<input type="submit" value="Save Changes" />
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/tenant")); ?>">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
// use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\Module;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantProperty;
|
||||
use Objectify\Objects\TenantPropertyValue;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class TenantModuleManagementPage extends WebPage
|
||||
{
|
||||
public $Tenant;
|
||||
public $Module;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
if ($this->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)
|
||||
{
|
||||
?>
|
||||
<h1>Module: <?php echo($this->Module->Title); ?> on <?php echo($this->Tenant->URL); ?></h1>
|
||||
<h2>Module Configurable Properties</h2>
|
||||
<table style="width: 100%;">
|
||||
<tr id="Property_Header">
|
||||
<th style="width: 32px;"><a href="#" onclick="AddPropertyBelow('Header');" title="Add Below">[+]</a></th>
|
||||
<th style="width: 256px;">Property</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<?php
|
||||
/*
|
||||
$properties = $this->Module->GetProperties();
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
?>
|
||||
<tr id="Property_<?php echo($property->ID); ?>">
|
||||
<td style="width: 32px;"><a href="#" onclick="AddPropertyBelow('<?php echo($property->ID); ?>');" title="Add Below">[+]</a></td>
|
||||
<td><?php echo($property->Title); ?></td>
|
||||
<td><input style="width: 100%;" type="text" id="txtProperty_<?php echo($property->ID); ?>" name="Property_<?php echo($property->ID); ?>" value="<?php echo($this->Tenant->GetPropertyValue($property)); ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
*/
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<h1>Tenant: <?php echo($this->Tenant->URL); ?></h1>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<h2>Tenant Enabled Modules</h2>
|
||||
<p>Click on a module name to configure it</p>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<th style="width: 128px;">Module</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<?php
|
||||
$modules = Module::Get(null, $this->Tenant);
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><input id="chkModule_<?php echo($module->ID); ?>" type="checkbox"<?php if ($module->Enabled) { echo(" checked=\"checked\""); } ?> /> <a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->Tenant->URL . "/modules/" . $module->ID)); ?>"><?php echo($module->Title); ?></a></td>
|
||||
<td><?php echo($module->Description); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
41
PHP/Manager/Include/Pages/005-ModuleMainPage.inc.php
Normal file
41
PHP/Manager/Include/Pages/005-ModuleMainPage.inc.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
use Objectify\Objects\Module;
|
||||
|
||||
class ModuleMainPage extends WebPage
|
||||
{
|
||||
protected function RenderContent()
|
||||
{
|
||||
$modules = Module::Get();
|
||||
?>
|
||||
<h1>Module Management</h1>
|
||||
<p>There are <?php echo(count($modules)); ?> modules in total. Click a module name to configure that module.</p>
|
||||
|
||||
<div class="Toolbar">
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/module/create")); ?>">Create New Module</a>
|
||||
</div>
|
||||
<table style="width: 100%;" border="1">
|
||||
<tr>
|
||||
<th>Module</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/module/modify/" . $module->ID)); ?>"><?php echo($module->Title); ?></a></td>
|
||||
<td><?php echo($module->Description); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
84
PHP/Manager/Include/Pages/006-ModuleManagementPage.inc.php
Normal file
84
PHP/Manager/Include/Pages/006-ModuleManagementPage.inc.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
use Objectify\Objects\Module;
|
||||
|
||||
class ModuleManagementPage extends WebPage
|
||||
{
|
||||
public $Module;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
$this->Title = "Manage Module: " . $this->Module->Title;
|
||||
}
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
<h1>Module Management</h1>
|
||||
<h2><?php echo($this->Module->Title); ?></h2>
|
||||
|
||||
<form method="POST">
|
||||
<h3>Information</h3>
|
||||
<table style="width: 100%;" border="1">
|
||||
<tr>
|
||||
<td style="width: 100px;">Title: </td>
|
||||
<td><input name="module_Title" type="text" value="<?php echo($this->Module->Title); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">Description: </td>
|
||||
<td><textarea name="module_Description" style="width: 100%;" rows="5"><?php echo($this->Module->Description); ?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Application Menu Items</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Description</th>
|
||||
<th>Target</th>
|
||||
</tr>
|
||||
<?php
|
||||
$menuitems = $this->Module->GetMainMenuItems();
|
||||
foreach ($menuitems as $menuitem)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo($menuitem->Title); ?></td>
|
||||
<td><?php echo($menuitem->Description); ?></td>
|
||||
<td><?php echo($menuitem->TargetURL); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<h3>Module Pages</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>URL</th>
|
||||
</tr>
|
||||
<?php
|
||||
/*
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/module/modify/" . $module->ID)); ?>"><?php echo($module->Title); ?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
*/
|
||||
?>
|
||||
</table>
|
||||
<div class="Buttons" style="text-align: right;">
|
||||
<input type="submit" value="Save Changes" /> <a href="<?php echo(System::ExpandRelativePath("~/module")); ?>">Back to Modules</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
PHP/Manager/Include/Pages/007-DataCenterMainPage.inc.php
Normal file
43
PHP/Manager/Include/Pages/007-DataCenterMainPage.inc.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
use Objectify\Objects\DataCenter;
|
||||
|
||||
class DataCenterMainPage extends WebPage
|
||||
{
|
||||
protected function RenderContent()
|
||||
{
|
||||
$datacenters = DataCenter::Get();
|
||||
?>
|
||||
<h1>Data Center Management</h1>
|
||||
<p>There are <?php echo(count($datacenters)); ?> data centers in total. Click a data center name to configure that data center.</p>
|
||||
|
||||
<div class="Toolbar">
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/datacenter/create")); ?>">Create New Data Center</a>
|
||||
</div>
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr>
|
||||
<th>Data Center</th>
|
||||
<th>Description</th>
|
||||
<th>Hostname</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($datacenters as $datacenter)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/datacenter/modify/" . $datacenter->ID)); ?>"><?php echo($datacenter->Title); ?></a></td>
|
||||
<td><?php echo($datacenter->Description); ?></td>
|
||||
<td><a href="http://<?php echo($datacenter->HostName); ?>"><?php echo($datacenter->HostName); ?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
use Objectify\Objects\DataCenter;
|
||||
|
||||
class DataCenterManagementPage extends WebPage
|
||||
{
|
||||
public $DataCenter;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
$this->Title = "Manage Data Center: " . $this->DataCenter->Title;
|
||||
}
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
<h1>Data Center Management</h1>
|
||||
<h2><?php echo($this->DataCenter->Title); ?></h2>
|
||||
|
||||
<form method="POST">
|
||||
<h3>Information</h3>
|
||||
<table style="width: 100%;" border="1">
|
||||
<tr>
|
||||
<td style="width: 100px;">Title: </td>
|
||||
<td><input name="datacenter_Title" type="text" value="<?php echo($this->DataCenter->Title); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">Description: </td>
|
||||
<td><textarea name="datacenter_Description" style="width: 100%;" rows="5"><?php echo($this->DataCenter->Description); ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">Hostname: </td>
|
||||
<td><input name="datacenter_HostName" type="text" value="<?php echo($this->DataCenter->HostName); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="Buttons" style="text-align: right;">
|
||||
<input type="submit" value="Save Changes" /> <a href="<?php echo(System::ExpandRelativePath("~/datacenter")); ?>">Back to Data Centers</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
224
PHP/Manager/Include/Pages/009-TenantObjectManagementPage.inc.php
Normal file
224
PHP/Manager/Include/Pages/009-TenantObjectManagementPage.inc.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use WebFX\Controls\TabContainer;
|
||||
use WebFX\Controls\TabPage;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
// use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\Module;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObject;
|
||||
use Objectify\Objects\TenantProperty;
|
||||
use Objectify\Objects\TenantPropertyValue;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class TenantObjectManagementPage extends WebPage
|
||||
{
|
||||
public $CurrentTenant;
|
||||
public $CurrentObject;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
if ($this->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)
|
||||
{
|
||||
?>
|
||||
<h1>Object: <?php echo($this->CurrentObject->Name); ?> on <?php echo($this->CurrentTenant->URL); ?></h1>
|
||||
<form method="POST">
|
||||
<?php
|
||||
$tbs = new TabContainer("tbsObject");
|
||||
// ID title imageurl targeturl script contentfunc
|
||||
$tbs->TabPages[] = new TabPage("tabStaticProperties", "Static Properties", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr id="Property_Header">
|
||||
<th style="width: 32px;"><a href="#" onclick="AddPropertyBelow('Header');" title="Add Below">[+]</a></th>
|
||||
<th style="width: 256px;">Property</th>
|
||||
<th style="width: 128px;">Data Type</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
<?php
|
||||
$properties = $this->CurrentObject->GetProperties();
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
?>
|
||||
<tr id="StaticProperty_<?php echo($property->ID); ?>">
|
||||
<td style="width: 32px;"><a href="#" onclick="AddStaticPropertyBelow('<?php echo($property->ID); ?>');" title="Add Below">[+]</a></td>
|
||||
<td><?php echo($property->Name); ?></td>
|
||||
<td><?php echo($property->DataType == null ? "(undefined)" : "<a href=\"" . System::ExpandRelativePath("~/datatype/modify/" . $property->DataType->ID) . "\">" . $property->DataType->Name . "</a>"); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($property->DataType == null || $property->DataType->ColumnRendererCodeBlob == null)
|
||||
{
|
||||
?>
|
||||
<input style="width: 100%;" type="text" id="txtStaticProperty_<?php echo($property->ID); ?>" name="StaticProperty_<?php echo($property->ID); ?>" value="<?php echo($property->DefaultValue); ?>" />
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
call_user_func($property->DataType->ColumnRendererCodeBlob, $property->Value);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
$tbs->TabPages[] = new TabPage("tabInstanceProperties", "Instance Properties", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function AddInstancePropertyBelow(id)
|
||||
{
|
||||
var hdnNewPropertyCount = document.getElementById("hdnNewPropertyCount");
|
||||
hdnNewPropertyCount.value = parseInt(hdnNewPropertyCount.value) + 1;
|
||||
|
||||
var parentRow = document.getElementById("InstanceProperty_" + id);
|
||||
var table = parentRow.parentElement;
|
||||
|
||||
var tr = table.insertRow(parentRow.sectionRowIndex + 1);
|
||||
|
||||
var tdAdd = tr.insertCell(-1);
|
||||
tdAdd.innerHTML = "<a href=\"#\" onclick=\"AddInstancePropertyBelow('');\" title=\"Add Below\">[+]</a>";
|
||||
|
||||
var tdProperty = tr.insertCell(-1);
|
||||
tdProperty.innerHTML = "<input type=\"text\" name=\"InstanceProperty_" + hdnNewPropertyCount.value + "_Name\" />";
|
||||
|
||||
var tdDataType = tr.insertCell(-1);
|
||||
tdDataType.innerHTML = "<input type=\"text\" name=\"InstanceProperty_" + hdnNewPropertyCount.value + "_DataTypeID\" />";
|
||||
|
||||
var tdDefaultValue = tr.insertCell(-1);
|
||||
tdDefaultValue.innerHTML = "<input type=\"text\" name=\"InstanceProperty_" + hdnNewPropertyCount.value + "_DefaultValue\" />";
|
||||
}
|
||||
</script>
|
||||
<input type="hidden" id="hdnNewPropertyCount" name="InstanceProperty_NewPropertyCount" value="0" />
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr id="InstanceProperty_Header">
|
||||
<th style="width: 32px;"><a href="#" onclick="AddInstancePropertyBelow('Header'); return false;" title="Add Below">[+]</a></th>
|
||||
<th style="width: 256px;">Property</th>
|
||||
<th style="width: 128px;">Data Type</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
<?php
|
||||
$properties = $this->CurrentObject->GetInstanceProperties();
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
?>
|
||||
<tr id="InstanceProperty_<?php echo($property->ID); ?>">
|
||||
<td style="width: 32px;"><a href="#" onclick="AddInstancePropertyBelow('<?php echo($property->ID); ?>'); return false;" title="Add Below">[+]</a></td>
|
||||
<td><?php echo($property->Name); ?></td>
|
||||
<td><?php echo($property->DataType == null ? "(undefined)" : "<a href=\"" . System::ExpandRelativePath("~/datatype/modify/" . $property->DataType->ID) . "\">" . $property->DataType->Name . "</a>"); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$property->RenderColumn();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
$tbs->TabPages[] = new TabPage("tabStaticMethods", "Static Methods", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<table class="ListView" style="width: 100%;">
|
||||
<tr id="StaticMethod_Header">
|
||||
<th style="width: 32px;"><a href="#" onclick="AddStaticMethodBelow('Header');" title="Add Below">[+]</a></th>
|
||||
<th style="width: 256px;">Method</th>
|
||||
<th>Description</th>
|
||||
<th style="width: 128px;">Return Data Type</th>
|
||||
</tr>
|
||||
<?php
|
||||
$methods = $this->CurrentObject->GetMethods();
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
?>
|
||||
<tr id="StaticMethod_<?php echo($method->ID); ?>">
|
||||
<td style="width: 32px;"><a href="#" onclick="AddStaticMethodBelow('<?php echo($method->ID); ?>');" title="Add Below">[+]</a></td>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->CurrentTenant->URL . "/objects/" . $this->CurrentObject->ID . "/methods/static/" . $method->ID)); ?>"><?php echo($method->Name); ?></a></td>
|
||||
<td><?php echo($method->Description); ?></td>
|
||||
<td><?php /* echo($method->DataType == null ? "(undefined)" : "<a href=\"#\">" . $method->DataType->Name . "</a>"); */ ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
$tbs->TabPages[] = new TabPage("tabInstances", "Instances", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<table style="width: 100%;">
|
||||
<tr id="Property_Header">
|
||||
<?php
|
||||
$properties = $this->CurrentObject->GetInstanceProperties();
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
if ($property->ColumnVisible)
|
||||
{
|
||||
echo("<th>" . $property->Name . "</th>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$instances = $this->CurrentObject->GetInstances();
|
||||
foreach ($instances as $instance)
|
||||
{
|
||||
?>
|
||||
<tr id="Property_<?php echo($property->ID); ?>">
|
||||
<?php
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
if ($property->ColumnVisible)
|
||||
{
|
||||
echo("<td>");
|
||||
$value = $instance->GetPropertyValue($property);
|
||||
$property->RenderColumn($value);
|
||||
echo("</td>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
});
|
||||
$tbs->Render();
|
||||
?>
|
||||
|
||||
<div class="Buttons">
|
||||
<input type="submit" value="Save Changes" />
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->CurrentTenant->URL)); ?>">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use WebFX\WebScript;
|
||||
use WebFX\WebStyleSheet;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
// use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\Module;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObject;
|
||||
use Objectify\Objects\TenantProperty;
|
||||
use Objectify\Objects\TenantPropertyValue;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class TenantObjectMethodManagementPage extends WebPage
|
||||
{
|
||||
public $CurrentMethod;
|
||||
public $CurrentTenant;
|
||||
public $CurrentObject;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->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)
|
||||
{
|
||||
?>
|
||||
<h1>Method: <?php echo($this->CurrentMethod->Name); ?> on <?php echo($this->CurrentObject->Name); ?>@<?php echo($this->CurrentTenant->URL); ?></h1>
|
||||
<table class="FormView">
|
||||
<tr class="Required">
|
||||
<td><label for="txtMethodName">Method Name</label></td>
|
||||
<td><input type="text" id="txtMethodName" name="method_Name" value="<?php echo($this->CurrentMethod->Name); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Code Blob</h2>
|
||||
<form method="POST">
|
||||
<textarea id="txtCodeBlob" name="method_CodeBlob" style="width: 100%;" rows="40"><?php echo($this->CurrentMethod->CodeBlob); ?></textarea>
|
||||
<style type="text/css">
|
||||
.CodeMirror
|
||||
{
|
||||
border: dotted 1px #AAAAAA;
|
||||
line-height: 18px;
|
||||
}
|
||||
.CodeMirror .CodeMirror-linenumbers
|
||||
{
|
||||
width: 48px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var txtCodeBlob = document.getElementById("txtCodeBlob");
|
||||
var editor = CodeMirror.fromTextArea(txtCodeBlob,
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-php",
|
||||
indentUnit: 4,
|
||||
indentWithTabs: true
|
||||
});
|
||||
</script>
|
||||
<div class="Buttons">
|
||||
<input type="submit" value="Save Changes" />
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/tenant/manage/" . $this->CurrentTenant->URL . "/objects/" . $this->CurrentObject->ID)); ?>">Discard Changes</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
// use Objectify\Objects\DataCenter;
|
||||
use Objectify\Objects\Module;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObject;
|
||||
use Objectify\Objects\TenantProperty;
|
||||
use Objectify\Objects\TenantPropertyValue;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class TenantObjectInstanceBrowsePage extends WebPage
|
||||
{
|
||||
public $CurrentTenant;
|
||||
public $CurrentObject;
|
||||
|
||||
protected function Initialize()
|
||||
{
|
||||
$this->Title = "Browse Instances of Tenant Object: " . $this->CurrentObject->Name . " on " . $this->CurrentTenant->URL;
|
||||
}
|
||||
|
||||
protected function RenderContent()
|
||||
{
|
||||
if ($this->CurrentObject != null)
|
||||
{
|
||||
?>
|
||||
<h1>Object: <?php echo($this->CurrentObject->Name); ?> on <?php echo($this->CurrentTenant->URL); ?></h1>
|
||||
<h2>Object Instances</h2>
|
||||
<table style="width: 100%;">
|
||||
<tr id="Property_Header">
|
||||
<?php
|
||||
$properties = $this->CurrentObject->GetInstanceProperties();
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
if ($property->ColumnVisible)
|
||||
{
|
||||
echo("<th>" . $property->Name . "</th>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$instances = $this->CurrentObject->GetInstances();
|
||||
foreach ($instances as $instance)
|
||||
{
|
||||
?>
|
||||
<tr id="Property_<?php echo($property->ID); ?>">
|
||||
<?php
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
if ($property->ColumnVisible)
|
||||
{
|
||||
echo("<td>");
|
||||
$value = $instance->GetPropertyValue($property);
|
||||
$property->RenderColumn($value);
|
||||
echo("</td>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
252
PHP/Manager/Include/Pages/012-DataTypeModifyPage.inc.php
Normal file
252
PHP/Manager/Include/Pages/012-DataTypeModifyPage.inc.php
Normal file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
namespace Objectify\Tenant\Pages;
|
||||
|
||||
use WebFX\ModulePage;
|
||||
|
||||
use WebFX\System;
|
||||
|
||||
use WebFX\WebScript;
|
||||
use WebFX\WebStyleSheet;
|
||||
|
||||
use WebFX\Controls\FormView;
|
||||
use WebFX\Controls\FormViewItem;
|
||||
use WebFX\Controls\FormViewItemText;
|
||||
use WebFX\Controls\FormViewItemMemo;
|
||||
|
||||
use WebFX\Controls\TabContainer;
|
||||
use WebFX\Controls\TabPage;
|
||||
|
||||
use Objectify\Tenant\MasterPages\WebPage;
|
||||
|
||||
use Objectify\Objects\DataType;
|
||||
use Objectify\Objects\Module;
|
||||
use Objectify\Objects\PaymentPlan;
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObject;
|
||||
use Objectify\Objects\TenantProperty;
|
||||
use Objectify\Objects\TenantPropertyValue;
|
||||
use Objectify\Objects\TenantStatus;
|
||||
use Objectify\Objects\TenantType;
|
||||
|
||||
class DataTypeModifyPage extends WebPage
|
||||
{
|
||||
public $CurrentDataType;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->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)
|
||||
{
|
||||
?>
|
||||
<h1>Modify Data Type: <?php echo($this->CurrentDataType->Name); ?></h1>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?><h1>Create Data Type</h1><?php
|
||||
}
|
||||
?>
|
||||
<style type="text/css">
|
||||
.CodeMirror
|
||||
{
|
||||
border: dotted 1px #AAAAAA;
|
||||
line-height: 18px;
|
||||
}
|
||||
.CodeMirror .CodeMirror-linenumbers
|
||||
{
|
||||
width: 48px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var CodeMirrorDefaultParameters =
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-php",
|
||||
indentUnit: 4,
|
||||
indentWithTabs: true
|
||||
};
|
||||
|
||||
function InitializeCodeMirror(id)
|
||||
{
|
||||
var txt = document.getElementById(id);
|
||||
if (txt.CodeMirrorInitialized) return;
|
||||
|
||||
var edt = CodeMirror.fromTextArea(txt, CodeMirrorDefaultParameters);
|
||||
txt.CodeMirrorInitialized = true;
|
||||
}
|
||||
function tbs_OnClientTabChanged()
|
||||
{
|
||||
switch (tbs.SelectedTabID)
|
||||
{
|
||||
case "tabEncoder":
|
||||
{
|
||||
InitializeCodeMirror("txtEncoderCodeBlob");
|
||||
break;
|
||||
}
|
||||
case "tabDecoder":
|
||||
{
|
||||
InitializeCodeMirror("txtDecoderCodeBlob");
|
||||
break;
|
||||
}
|
||||
case "tabColumnRenderer":
|
||||
{
|
||||
InitializeCodeMirror("txtColumnRendererCodeBlob");
|
||||
break;
|
||||
}
|
||||
case "tabEditorRenderer":
|
||||
{
|
||||
InitializeCodeMirror("txtEditorRendererCodeBlob");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<form method="POST">
|
||||
<?php
|
||||
if ($this->CurrentDataType != null)
|
||||
{
|
||||
echo("<input type=\"hidden\" name=\"datatype_ID\" value=\"" . $this->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();
|
||||
?>
|
||||
<?php
|
||||
$tbs = new TabContainer("tbs");
|
||||
$tbs->OnClientTabChanged = "tbs_OnClientTabChanged();";
|
||||
$tbs->TabPages[] = new TabPage("tabEncoder", "Encoder", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<textarea id="txtEncoderCodeBlob" name="datatype_EncoderCodeBlob" style="width: 100%;" rows="20"><?php echo($this->CurrentDataType->EncoderCodeBlob); ?></textarea>
|
||||
<?php
|
||||
});
|
||||
$tbs->TabPages[] = new TabPage("tabDecoder", "Decoder", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<textarea id="txtDecoderCodeBlob" name="datatype_DecoderCodeBlob" style="width: 100%;" rows="20"><?php echo($this->CurrentDataType->DecoderCodeBlob); ?></textarea>
|
||||
<?php
|
||||
});
|
||||
$tbs->TabPages[] = new TabPage("tabColumnRenderer", "Column Renderer", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<textarea id="txtColumnRendererCodeBlob" name="datatype_ColumnRendererCodeBlob" style="width: 100%;" rows="20"><?php echo($this->CurrentDataType->ColumnRendererCodeBlob); ?></textarea>
|
||||
<?php
|
||||
});
|
||||
$tbs->TabPages[] = new TabPage("tabEditorRenderer", "Editor Renderer", null, null, null, function()
|
||||
{
|
||||
?>
|
||||
<textarea id="txtEditorRendererCodeBlob" name="datatype_EditorRendererCodeBlob" style="width: 100%;" rows="20"><?php echo($this->CurrentDataType->EditorRendererCodeBlob); ?></textarea>
|
||||
<?php
|
||||
});
|
||||
$tbs->Render();
|
||||
?>
|
||||
<div class="Buttons">
|
||||
<input type="submit" value="Save Changes" />
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/datatype")); ?>">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
class DataTypeBrowsePage extends WebPage
|
||||
{
|
||||
protected function RenderContent()
|
||||
{
|
||||
$items = DataType::Get();
|
||||
?>
|
||||
<table class="ListView">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($items as $item)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo(System::ExpandRelativePath("~/datatype/modify/" . $item->ID)); ?>"><?php echo($item->Name); ?></a></td>
|
||||
<td><?php echo($item->Description); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<div class="Buttons">
|
||||
<a class="Button Emphasis" href="<?php echo(System::ExpandRelativePath("~/datatype/modify")); ?>">Create New Data Type</a>
|
||||
<a class="Button" href="<?php echo(System::ExpandRelativePath("~/")); ?>">Exit</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
System::$Modules[] = new \WebFX\Module("net.Objectify.TenantManager.DataType", array
|
||||
(
|
||||
new ModulePage("datatype", array
|
||||
(
|
||||
new ModulePage("", function($path)
|
||||
{
|
||||
$page = new DataTypeBrowsePage();
|
||||
$page->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;
|
||||
})
|
||||
))
|
||||
));
|
||||
?>
|
||||
@ -1,29 +0,0 @@
|
||||
<%@ Page ModuleName="com.universaleditor.manager.Default" URL="/" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>This is a test</title>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Name type:</td>
|
||||
<td>
|
||||
<wfx:TextBox ID="txtNameType" Name="nameType" ChoiceRequired="false">
|
||||
<Choices>
|
||||
<Choice Value="1">Legal</Choice>
|
||||
<Choice Value="2">Preferred</Choice>
|
||||
<Choice Value="3">Maiden</Choice>
|
||||
<Choice Value="4">Other</Choice>
|
||||
</Choices>
|
||||
</wfx:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Name:</td>
|
||||
<td><wfx:TextBox ID="txtName" Name="name" SuggestionURL="" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
81
PHP/Manager/Include/UUID.inc.php
Normal file
81
PHP/Manager/Include/UUID.inc.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
class UUID
|
||||
{
|
||||
protected $urand;
|
||||
|
||||
public function __construct() {
|
||||
$this->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 . "}";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -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
|
||||
|
||||
62
PHP/TODO.txt
Normal file
62
PHP/TODO.txt
Normal file
@ -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:
|
||||
<Objectify>
|
||||
<Objects>
|
||||
<Object ID="5157" Title="Basic Object">
|
||||
<DisplayTemplate>
|
||||
<?php
|
||||
// do your stuff here...
|
||||
?>
|
||||
<h1>Instance <?php echo($thisInstance->Title); ?></h1>
|
||||
</DisplayTemplate>
|
||||
</Object>
|
||||
</Objects>
|
||||
<Instances>
|
||||
<Instance ID="72713" ObjectID="5157">
|
||||
<Properties>
|
||||
...
|
||||
</Properties>
|
||||
</Instance>
|
||||
</Instances>
|
||||
</Objectify>
|
||||
|
||||
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.
|
||||
347
PHP/Tenant/Include/Modules/000-Default/Main.inc.php
Normal file
347
PHP/Tenant/Include/Modules/000-Default/Main.inc.php
Normal file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
namespace Objectify\Modules;
|
||||
|
||||
use WebFX\Controls\ButtonGroup;
|
||||
use WebFX\Controls\ButtonGroupButton;
|
||||
use WebFX\Controls\ButtonGroupButtonAlignment;
|
||||
|
||||
use WebFX\Controls\Panel;
|
||||
|
||||
use Objectify\ResourceBundle;
|
||||
use Objectify\Pages\DashboardPage;
|
||||
use Objectify\Pages\MainPage;
|
||||
use Objectify\Pages\ErrorPage;
|
||||
use Objectify\Pages\LoginPage;
|
||||
|
||||
use Objectify\Objects\Tenant;
|
||||
use Objectify\Objects\TenantObjectMethodParameterValue;
|
||||
|
||||
use Objectify\Objects\User;
|
||||
use Objectify\Objects\UserProfileVisibility;
|
||||
|
||||
use WebFX\System;
|
||||
use WebFX\Module;
|
||||
use WebFX\ModulePage;
|
||||
|
||||
require_once("lessc.inc.php");
|
||||
require_once("JShrink.inc.php");
|
||||
require_once("ResourceBundle.inc.php");
|
||||
|
||||
function IsConfigured()
|
||||
{
|
||||
if (!(
|
||||
isset(System::$Configuration["Database.ServerName"]) &&
|
||||
isset(System::$Configuration["Database.DatabaseName"]) &&
|
||||
isset(System::$Configuration["Database.UserName"]) &&
|
||||
isset(System::$Configuration["Database.Password"]) &&
|
||||
isset(System::$Configuration["Database.TablePrefix"])
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
global $MySQL;
|
||||
$query = "SHOW TABLES LIKE '" . System::$Configuration["Database.TablePrefix"] . "Users'";
|
||||
$result = $MySQL->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;
|
||||
})
|
||||
));
|
||||
?>
|
||||
192
PHP/Tenant/Include/Modules/000-Default/ResourceBundle.inc.php
Normal file
192
PHP/Tenant/Include/Modules/000-Default/ResourceBundle.inc.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
namespace Objectify;
|
||||
|
||||
class ResourceBundle
|
||||
{
|
||||
public $Name;
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1,49 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Main.css" />
|
||||
<link rel="stylesheet" type="text/css" href="http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Workday/Main.css" />
|
||||
<script src="http://static.alcehosting.net/dropins/WebFramework/Scripts/TabContainer.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Modify Data Format</h1>
|
||||
<h2>Slightly Mad Studios BFF archive</h2>
|
||||
|
||||
<form method="POST">
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 128px;"><label for="txtTitle">Data Format Title: </label></td>
|
||||
<td><input type="text" id="txtTitle" name="dataformat_Title" value="Slightly Mad Studios BFF archive" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="txtParent">Parent Data Format: </label></td>
|
||||
<td><select id="txtParent" name="dataformat_Parent"></select></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="TabContainer" id="TabContainer_tbsTabs">
|
||||
<div class="TabContainerTabs" id="TabContainer_tbsTabs_Tabs">
|
||||
<a href="#" id="TabContainer_tbsTabs_Tab_tabImport">Import</a>
|
||||
<a href="#" id="TabContainer_tbsTabs_Tab_tabExport">Export</a>
|
||||
</div>
|
||||
<div class="TabContainerTabContents" id="TabContainer_tbsTabs_TabContents">
|
||||
<div class="TabContainerTabContent" id="TabContainer_tbsTabs_TabContent_tabImport">
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<th>Data type</th>
|
||||
<th>Title</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#">String</a></td>
|
||||
<td>Encryption key</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var tbsTabs = new TabContainer("tbsTabs");
|
||||
tbsTabs.SetSelectedTab(tbsTabs.GetTabByID("tabImport"));
|
||||
</script>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,29 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Main.css" />
|
||||
<link rel="stylesheet" type="text/css" href="http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Workday/Main.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Modify Data Format</h1>
|
||||
<h2>Slightly Mad Studios BFF archive</h2>
|
||||
|
||||
<wfx:TabContainer ID="tbsTabs">
|
||||
<wfx:TabPage ID="tabImport" Title="Import">
|
||||
<wfx:ListView ID="lvImportOptions">
|
||||
<Columns>
|
||||
<wfx:ListViewColumn Name="lvcType" Title="Field type" />
|
||||
<wfx:ListViewColumn Name="lvcTitle" Title="Title" />
|
||||
</Columns>
|
||||
</wfx:ListView>
|
||||
</wfx:TabPage>
|
||||
<wfx:TabPage ID="tabImport" Title="Export">
|
||||
<wfx:ListView ID="lvExportOptions">
|
||||
<Columns>
|
||||
<wfx:ListViewColumn Name="lvcType" Title="Field type" />
|
||||
<wfx:ListViewColumn Name="lvcTitle" Title="Title" />
|
||||
</Columns>
|
||||
</wfx:ListView>
|
||||
</wfx:TabPage>
|
||||
</wfx:TabContainer>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,36 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Main.css" />
|
||||
<link rel="stylesheet" type="text/css" href="http://static.alcehosting.net/dropins/WebFramework/StyleSheets/Workday/Main.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Modify Enumeration</h1>
|
||||
<h2>Slightly Mad Studios BFF Encryption Mode</h2>
|
||||
|
||||
<h3>Possible values:</h3>
|
||||
<wfx:ListView ID="lvEnumeratedValues">
|
||||
<Columns>
|
||||
<wfx:ListViewColumn Name="lvcName" Title="Name" />
|
||||
<wfx:ListViewColumn Name="lvcValue" Title="Value" />
|
||||
</Columns>
|
||||
<Records>
|
||||
<wfx:ListViewRecord>
|
||||
<Columns>
|
||||
<wfx:ListViewColumn Name="lvcName" Value="None" />
|
||||
<wfx:ListViewColumn Name="lvcValue" Value="0" />
|
||||
</Columns>
|
||||
</wfx:ListViewRecord>
|
||||
<wfx:ListViewRecord>
|
||||
<Columns>
|
||||
<wfx:ListViewColumn Name="lvcName" Value="RC4" />
|
||||
<wfx:ListViewColumn Name="lvcValue" Value="1" />
|
||||
</Columns>
|
||||
</wfx:ListViewRecord>
|
||||
</Records>
|
||||
</wfx:ListView>
|
||||
|
||||
<div class="Buttons">
|
||||
<a href="#">Save Changes</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -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
|
||||
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
namespace UniversalEditor\PublicWebsite\MasterPages;
|
||||
|
||||
class WebPage extends \WebFX\WebPage
|
||||
{
|
||||
|
||||
}
|
||||
?>
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace UniversalEditor\PublicWebsite\Modules;
|
||||
|
||||
use WebFX\System;
|
||||
use WebFX\Module;
|
||||
use WebFX\ModulePage;
|
||||
|
||||
use UniversalEditor\PublicWebsite\Pages\MainPage;
|
||||
|
||||
System::$Modules[] = new Module("com.universaleditor.PublicWebsite.Default", array
|
||||
(
|
||||
new ModulePage("", function($path)
|
||||
{
|
||||
$page = new MainPage();
|
||||
$page->Render();
|
||||
return true;
|
||||
})
|
||||
));
|
||||
?>
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace UniversalEditor\PublicWebsite\Pages;
|
||||
|
||||
use UniversalEditor\PublicWebsite\MasterPages\WebPage;
|
||||
|
||||
class MainPage extends WebPage
|
||||
{
|
||||
protected function RenderContent()
|
||||
{
|
||||
?>
|
||||
Welcome to Universal Editor!
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user