summaryrefslogtreecommitdiff
path: root/backend/php/src/objects
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
commitef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (side-by-side diff)
treec403752d66a2c4775f00affd4fa8431b29c5b68c /backend/php/src/objects
parent597ecfbc0249d83e1b856cbd558340c01237a360 (diff)
downloadclipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2
First version of the newly restructured repository
Diffstat (limited to 'backend/php/src/objects') (more/less context) (ignore whitespace changes)
-rw-r--r--backend/php/src/objects/class.database.php79
-rw-r--r--backend/php/src/objects/class.onetimepassword.php400
-rw-r--r--backend/php/src/objects/class.onetimepasswordstatus.php368
-rw-r--r--backend/php/src/objects/class.pog_base.php143
-rw-r--r--backend/php/src/objects/class.record.php436
-rw-r--r--backend/php/src/objects/class.recordversion.php381
-rw-r--r--backend/php/src/objects/class.user.php502
-rw-r--r--backend/php/src/objects/ignore_objects.txt0
8 files changed, 2309 insertions, 0 deletions
diff --git a/backend/php/src/objects/class.database.php b/backend/php/src/objects/class.database.php
new file mode 100644
index 0000000..e8a13f7
--- a/dev/null
+++ b/backend/php/src/objects/class.database.php
@@ -0,0 +1,79 @@
+<?php
+/**
+* <b>Database Connection</b> class.
+* @author Php Object Generator
+* @version 3.0d / PHP5.1
+* @see http://www.phpobjectgenerator.com/
+* @copyright Free for personal & commercial use. (Offered under the BSD license)
+*/
+ Class Database
+{
+ public $connection;
+
+ private function Database()
+ {
+ $databaseName = $GLOBALS['configuration']['db'];
+ $serverName = $GLOBALS['configuration']['host'];
+ $databaseUser = $GLOBALS['configuration']['user'];
+ $databasePassword = $GLOBALS['configuration']['pass'];
+ $databasePort = $GLOBALS['configuration']['port'];
+ $this->connection = mysql_connect ($serverName.":".$databasePort, $databaseUser, $databasePassword);
+ if ($this->connection)
+ {
+ if (!mysql_select_db ($databaseName))
+ {
+ throw new Exception('I cannot find the specified database "'.$databaseName.'". Please edit configuration.php.');
+ }
+ }
+ else
+ {
+ throw new Exception('I cannot connect to the database. Please edit configuration.php with your database configuration.');
+ }
+ }
+
+ public static function Connect()
+ {
+ static $database = null;
+ if (!isset($database))
+ {
+ $database = new Database();
+ }
+ return $database->connection;
+ }
+
+ public static function Reader($query, $connection)
+ {
+ $cursor = mysql_query($query, $connection);
+ return $cursor;
+ }
+
+ public static function Read($cursor)
+ {
+ return mysql_fetch_assoc($cursor);
+ }
+
+ public static function NonQuery($query, $connection)
+ {
+ mysql_query($query, $connection);
+ $result = mysql_affected_rows($connection);
+ if ($result == -1)
+ {
+ return false;
+ }
+ return $result;
+
+ }
+
+ public static function Query($query, $connection)
+ {
+ $result = mysql_query($query, $connection);
+ return mysql_num_rows($result);
+ }
+
+ public static function InsertOrUpdate($query, $connection)
+ {
+ $result = mysql_query($query, $connection);
+ return intval(mysql_insert_id($connection));
+ }
+}
+?>
diff --git a/backend/php/src/objects/class.onetimepassword.php b/backend/php/src/objects/class.onetimepassword.php
new file mode 100644
index 0000000..90d5f1d
--- a/dev/null
+++ b/backend/php/src/objects/class.onetimepassword.php
@@ -0,0 +1,400 @@
+<?php
+/*
+ This SQL query will create the table to store your object.
+
+ CREATE TABLE `onetimepassword` (
+ `onetimepasswordid` int(11) NOT NULL auto_increment,
+ `userid` int(11) NOT NULL,
+ `onetimepasswordstatusid` int(11) NOT NULL,
+ `reference` VARCHAR(255) NOT NULL,
+ `key` VARCHAR(255) NOT NULL,
+ `key_checksum` VARCHAR(255) NOT NULL,
+ `data` TEXT NOT NULL,
+ `version` VARCHAR(255) NOT NULL,
+ `creation_date` TIMESTAMP NOT NULL,
+ `request_date` TIMESTAMP NOT NULL,
+ `usage_date` TIMESTAMP NOT NULL, INDEX(`userid`,`onetimepasswordstatusid`), PRIMARY KEY (`onetimepasswordid`)) ENGINE=MyISAM;
+*/
+
+/**
+* <b>onetimepassword</b> class with integrated CRUD methods.
+* @author Php Object Generator
+* @version POG 3.0d / PHP5.1
+* @copyright Free for personal & commercial use. (Offered under the BSD license)
+* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pog&objectName=onetimepassword&attributeList=array+%28%0A++0+%3D%3E+%27user%27%2C%0A++1+%3D%3E+%27onetimepasswordstatus%27%2C%0A++2+%3D%3E+%27reference%27%2C%0A++3+%3D%3E+%27key%27%2C%0A++4+%3D%3E+%27key_checksum%27%2C%0A++5+%3D%3E+%27data%27%2C%0A++6+%3D%3E+%27version%27%2C%0A++7+%3D%3E+%27creation_date%27%2C%0A++8+%3D%3E+%27request_date%27%2C%0A++9+%3D%3E+%27usage_date%27%2C%0A%29&typeList=array+%28%0A++0+%3D%3E+%27BELONGSTO%27%2C%0A++1+%3D%3E+%27BELONGSTO%27%2C%0A++2+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++3+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++4+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++5+%3D%3E+%27TEXT%27%2C%0A++6+%3D%3E+%27VARCHAR%28255%29%27%2C%0A++7+%3D%3E+%27TIMESTAMP%27%2C%0A++8+%3D%3E+%27TIMESTAMP%27%2C%0A++9+%3D%3E+%27TIMESTAMP%27%2C%0A%29
+*/
+include_once('class.pog_base.php');
+class onetimepassword extends POG_Base
+{
+ public $onetimepasswordId = '';
+
+ /**
+ * @var INT(11)
+ */
+ public $userId;
+
+ /**
+ * @var INT(11)
+ */
+ public $onetimepasswordstatusId;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $reference;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $key;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $key_checksum;
+
+ /**
+ * @var TEXT
+ */
+ public $data;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $version;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $creation_date;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $request_date;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $usage_date;
+
+ public $pog_attribute_type = array(
+ "onetimepasswordId" => array('db_attributes' => array("NUMERIC", "INT")),
+ "user" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
+ "onetimepasswordstatus" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
+ "reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "key" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "key_checksum" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "data" => array('db_attributes' => array("TEXT", "TEXT")),
+ "version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ "request_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ "usage_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ );
+ public $pog_query;
+
+
+ /**
+ * Getter for some private attributes
+ * @return mixed $attribute
+ */
+ public function __get($attribute)
+ {
+ if (isset($this->{"_".$attribute}))
+ {
+ return $this->{"_".$attribute};
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function onetimepassword($reference='', $key='', $key_checksum='', $data='', $version='', $creation_date='', $request_date='', $usage_date='')
+ {
+ $this->reference = $reference;
+ $this->key = $key;
+ $this->key_checksum = $key_checksum;
+ $this->data = $data;
+ $this->version = $version;
+ $this->creation_date = $creation_date;
+ $this->request_date = $request_date;
+ $this->usage_date = $usage_date;
+ }
+
+
+ /**
+ * Gets object from database
+ * @param integer $onetimepasswordId
+ * @return object $onetimepassword
+ */
+ function Get($onetimepasswordId)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select * from `onetimepassword` where `onetimepasswordid`='".intval($onetimepasswordId)."' LIMIT 1";
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $this->onetimepasswordId = $row['onetimepasswordid'];
+ $this->userId = $row['userid'];
+ $this->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
+ $this->reference = $this->Unescape($row['reference']);
+ $this->key = $this->Unescape($row['key']);
+ $this->key_checksum = $this->Unescape($row['key_checksum']);
+ $this->data = $this->Unescape($row['data']);
+ $this->version = $this->Unescape($row['version']);
+ $this->creation_date = $row['creation_date'];
+ $this->request_date = $row['request_date'];
+ $this->usage_date = $row['usage_date'];
+ }
+ return $this;
+ }
+
+
+ /**
+ * Returns a sorted array of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array $onetimepasswordList
+ */
+ function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $connection = Database::Connect();
+ $sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
+ $this->pog_query = "select * from `onetimepassword` ";
+ $onetimepasswordList = Array();
+ if (sizeof($fcv_array) > 0)
+ {
+ $this->pog_query .= " where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $this->pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
+ {
+ $this->pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ }
+ }
+ if ($sortBy != '')
+ {
+ if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $sortBy = "BASE64_DECODE($sortBy) ";
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "onetimepasswordid";
+ }
+ $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
+ $thisObjectName = get_class($this);
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $onetimepassword = new $thisObjectName();
+ $onetimepassword->onetimepasswordId = $row['onetimepasswordid'];
+ $onetimepassword->userId = $row['userid'];
+ $onetimepassword->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
+ $onetimepassword->reference = $this->Unescape($row['reference']);
+ $onetimepassword->key = $this->Unescape($row['key']);
+ $onetimepassword->key_checksum = $this->Unescape($row['key_checksum']);
+ $onetimepassword->data = $this->Unescape($row['data']);
+ $onetimepassword->version = $this->Unescape($row['version']);
+ $onetimepassword->creation_date = $row['creation_date'];
+ $onetimepassword->request_date = $row['request_date'];
+ $onetimepassword->usage_date = $row['usage_date'];
+ $onetimepasswordList[] = $onetimepassword;
+ }
+ return $onetimepasswordList;
+ }
+
+
+ /**
+ * Saves the object to the database
+ * @return integer $onetimepasswordId
+ */
+ function Save()
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select `onetimepasswordid` from `onetimepassword` where `onetimepasswordid`='".$this->onetimepasswordId."' LIMIT 1";
+ $rows = Database::Query($this->pog_query, $connection);
+ if ($rows > 0)
+ {
+ $this->pog_query = "update `onetimepassword` set
+ `userid`='".$this->userId."',
+ `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."',
+ `reference`='".$this->Escape($this->reference)."',
+ `key`='".$this->Escape($this->key)."',
+ `key_checksum`='".$this->Escape($this->key_checksum)."',
+ `data`='".$this->Escape($this->data)."',
+ `version`='".$this->Escape($this->version)."',
+ `creation_date`='".$this->creation_date."',
+ `request_date`='".$this->request_date."',
+ `usage_date`='".$this->usage_date."' where `onetimepasswordid`='".$this->onetimepasswordId."'";
+ }
+ else
+ {
+ $this->pog_query = "insert into `onetimepassword` (`userid`, `onetimepasswordstatusid`, `reference`, `key`, `key_checksum`, `data`, `version`, `creation_date`, `request_date`, `usage_date` ) values (
+ '".$this->userId."',
+ '".$this->onetimepasswordstatusId."',
+ '".$this->Escape($this->reference)."',
+ '".$this->Escape($this->key)."',
+ '".$this->Escape($this->key_checksum)."',
+ '".$this->Escape($this->data)."',
+ '".$this->Escape($this->version)."',
+ '".$this->creation_date."',
+ '".$this->request_date."',
+ '".$this->usage_date."' )";
+ }
+ $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
+ if ($this->onetimepasswordId == "")
+ {
+ $this->onetimepasswordId = $insertId;
+ }
+ return $this->onetimepasswordId;
+ }
+
+
+ /**
+ * Clones the object and saves it to the database
+ * @return integer $onetimepasswordId
+ */
+ function SaveNew()
+ {
+ $this->onetimepasswordId = '';
+ return $this->Save();
+ }
+
+
+ /**
+ * Deletes the object from the database
+ * @return boolean
+ */
+ function Delete()
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "delete from `onetimepassword` where `onetimepasswordid`='".$this->onetimepasswordId."'";
+ return Database::NonQuery($this->pog_query, $connection);
+ }
+
+
+ /**
+ * Deletes a list of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param bool $deep
+ * @return
+ */
+ function DeleteList($fcv_array)
+ {
+ if (sizeof($fcv_array) > 0)
+ {
+ $connection = Database::Connect();
+ $pog_query = "delete from `onetimepassword` where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
+ {
+ $pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
+ }
+ else
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
+ }
+ }
+ }
+ return Database::NonQuery($pog_query, $connection);
+ }
+ }
+
+
+ /**
+ * Associates the user object to this one
+ * @return boolean
+ */
+ function GetUser()
+ {
+ $user = new user();
+ return $user->Get($this->userId);
+ }
+
+
+ /**
+ * Associates the user object to this one
+ * @return
+ */
+ function SetUser(&$user)
+ {
+ $this->userId = $user->userId;
+ }
+
+
+ /**
+ * Associates the onetimepasswordstatus object to this one
+ * @return boolean
+ */
+ function GetOnetimepasswordstatus()
+ {
+ $onetimepasswordstatus = new onetimepasswordstatus();
+ return $onetimepasswordstatus->Get($this->onetimepasswordstatusId);
+ }
+
+
+ /**
+ * Associates the onetimepasswordstatus object to this one
+ * @return
+ */
+ function SetOnetimepasswordstatus(&$onetimepasswordstatus)
+ {
+ $this->onetimepasswordstatusId = $onetimepasswordstatus->onetimepasswordstatusId;
+ }
+}
+?> \ No newline at end of file
diff --git a/backend/php/src/objects/class.onetimepasswordstatus.php b/backend/php/src/objects/class.onetimepasswordstatus.php
new file mode 100644
index 0000000..f0ef08a
--- a/dev/null
+++ b/backend/php/src/objects/class.onetimepasswordstatus.php
@@ -0,0 +1,368 @@
+<?php
+/*
+ This SQL query will create the table to store your object.
+
+ CREATE TABLE `onetimepasswordstatus` (
+ `onetimepasswordstatusid` int(11) NOT NULL auto_increment,
+ `code` VARCHAR(255) NOT NULL,
+ `name` VARCHAR(255) NOT NULL,
+ `description` TEXT NOT NULL, PRIMARY KEY (`onetimepasswordstatusid`)) ENGINE=MyISAM;
+*/
+
+/**
+* <b>onetimepasswordstatus</b> class with integrated CRUD methods.
+* @author Php Object Generator
+* @version POG 3.0d / PHP5.1 MYSQL
+* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
+* @copyright Free for personal & commercial use. (Offered under the BSD license)
+* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=onetimepasswordstatus&attributeList=array+%28%0A++0+%3D%3E+%27onetimepassword%27%2C%0A++1+%3D%3E+%27code%27%2C%0A++2+%3D%3E+%27name%27%2C%0A++3+%3D%3E+%27description%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527TEXT%2527%252C%250A%2529
+*/
+include_once('class.pog_base.php');
+class onetimepasswordstatus extends POG_Base
+{
+ public $onetimepasswordstatusId = '';
+
+ /**
+ * @var private array of onetimepassword objects
+ */
+ private $_onetimepasswordList = array();
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $code;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $name;
+
+ /**
+ * @var TEXT
+ */
+ public $description;
+
+ public $pog_attribute_type = array(
+ "onetimepasswordstatusId" => array('db_attributes' => array("NUMERIC", "INT")),
+ "onetimepassword" => array('db_attributes' => array("OBJECT", "HASMANY")),
+ "code" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "name" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "description" => array('db_attributes' => array("TEXT", "TEXT")),
+ );
+ public $pog_query;
+
+
+ /**
+ * Getter for some private attributes
+ * @return mixed $attribute
+ */
+ public function __get($attribute)
+ {
+ if (isset($this->{"_".$attribute}))
+ {
+ return $this->{"_".$attribute};
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function onetimepasswordstatus($code='', $name='', $description='')
+ {
+ $this->_onetimepasswordList = array();
+ $this->code = $code;
+ $this->name = $name;
+ $this->description = $description;
+ }
+
+
+ /**
+ * Gets object from database
+ * @param integer $onetimepasswordstatusId
+ * @return object $onetimepasswordstatus
+ */
+ function Get($onetimepasswordstatusId)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select * from `onetimepasswordstatus` where `onetimepasswordstatusid`='".intval($onetimepasswordstatusId)."' LIMIT 1";
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $this->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
+ $this->code = $this->Unescape($row['code']);
+ $this->name = $this->Unescape($row['name']);
+ $this->description = $this->Unescape($row['description']);
+ }
+ return $this;
+ }
+
+
+ /**
+ * Returns a sorted array of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array $onetimepasswordstatusList
+ */
+ function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $connection = Database::Connect();
+ $sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
+ $this->pog_query = "select * from `onetimepasswordstatus` ";
+ $onetimepasswordstatusList = Array();
+ if (sizeof($fcv_array) > 0)
+ {
+ $this->pog_query .= " where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $this->pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
+ {
+ $this->pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ }
+ }
+ if ($sortBy != '')
+ {
+ if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $sortBy = "BASE64_DECODE($sortBy) ";
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "onetimepasswordstatusid";
+ }
+ $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
+ $thisObjectName = get_class($this);
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $onetimepasswordstatus = new $thisObjectName();
+ $onetimepasswordstatus->onetimepasswordstatusId = $row['onetimepasswordstatusid'];
+ $onetimepasswordstatus->code = $this->Unescape($row['code']);
+ $onetimepasswordstatus->name = $this->Unescape($row['name']);
+ $onetimepasswordstatus->description = $this->Unescape($row['description']);
+ $onetimepasswordstatusList[] = $onetimepasswordstatus;
+ }
+ return $onetimepasswordstatusList;
+ }
+
+
+ /**
+ * Saves the object to the database
+ * @return integer $onetimepasswordstatusId
+ */
+ function Save($deep = true)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select `onetimepasswordstatusid` from `onetimepasswordstatus` where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."' LIMIT 1";
+ $rows = Database::Query($this->pog_query, $connection);
+ if ($rows > 0)
+ {
+ $this->pog_query = "update `onetimepasswordstatus` set
+ `code`='".$this->Escape($this->code)."',
+ `name`='".$this->Escape($this->name)."',
+ `description`='".$this->Escape($this->description)."' where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."'";
+ }
+ else
+ {
+ $this->pog_query = "insert into `onetimepasswordstatus` (`code`, `name`, `description` ) values (
+ '".$this->Escape($this->code)."',
+ '".$this->Escape($this->name)."',
+ '".$this->Escape($this->description)."' )";
+ }
+ $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
+ if ($this->onetimepasswordstatusId == "")
+ {
+ $this->onetimepasswordstatusId = $insertId;
+ }
+ if ($deep)
+ {
+ foreach ($this->_onetimepasswordList as $onetimepassword)
+ {
+ $onetimepassword->onetimepasswordstatusId = $this->onetimepasswordstatusId;
+ $onetimepassword->Save($deep);
+ }
+ }
+ return $this->onetimepasswordstatusId;
+ }
+
+
+ /**
+ * Clones the object and saves it to the database
+ * @return integer $onetimepasswordstatusId
+ */
+ function SaveNew($deep = false)
+ {
+ $this->onetimepasswordstatusId = '';
+ return $this->Save($deep);
+ }
+
+
+ /**
+ * Deletes the object from the database
+ * @return boolean
+ */
+ function Delete($deep = false, $across = false)
+ {
+ if ($deep)
+ {
+ $onetimepasswordList = $this->GetOnetimepasswordList();
+ foreach ($onetimepasswordList as $onetimepassword)
+ {
+ $onetimepassword->Delete($deep, $across);
+ }
+ }
+ $connection = Database::Connect();
+ $this->pog_query = "delete from `onetimepasswordstatus` where `onetimepasswordstatusid`='".$this->onetimepasswordstatusId."'";
+ return Database::NonQuery($this->pog_query, $connection);
+ }
+
+
+ /**
+ * Deletes a list of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param bool $deep
+ * @return
+ */
+ function DeleteList($fcv_array, $deep = false, $across = false)
+ {
+ if (sizeof($fcv_array) > 0)
+ {
+ if ($deep || $across)
+ {
+ $objectList = $this->GetList($fcv_array);
+ foreach ($objectList as $object)
+ {
+ $object->Delete($deep, $across);
+ }
+ }
+ else
+ {
+ $connection = Database::Connect();
+ $pog_query = "delete from `onetimepasswordstatus` where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
+ {
+ $pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
+ }
+ else
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
+ }
+ }
+ }
+ return Database::NonQuery($pog_query, $connection);
+ }
+ }
+ }
+
+
+ /**
+ * Gets a list of onetimepassword objects associated to this one
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array of onetimepassword objects
+ */
+ function GetOnetimepasswordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $onetimepassword = new onetimepassword();
+ $fcv_array[] = array("onetimepasswordstatusId", "=", $this->onetimepasswordstatusId);
+ $dbObjects = $onetimepassword->GetList($fcv_array, $sortBy, $ascending, $limit);
+ return $dbObjects;
+ }
+
+
+ /**
+ * Makes this the parent of all onetimepassword objects in the onetimepassword List array. Any existing onetimepassword will become orphan(s)
+ * @return null
+ */
+ function SetOnetimepasswordList(&$list)
+ {
+ $this->_onetimepasswordList = array();
+ $existingOnetimepasswordList = $this->GetOnetimepasswordList();
+ foreach ($existingOnetimepasswordList as $onetimepassword)
+ {
+ $onetimepassword->onetimepasswordstatusId = '';
+ $onetimepassword->Save(false);
+ }
+ $this->_onetimepasswordList = $list;
+ }
+
+
+ /**
+ * Associates the onetimepassword object to this one
+ * @return
+ */
+ function AddOnetimepassword(&$onetimepassword)
+ {
+ $onetimepassword->onetimepasswordstatusId = $this->onetimepasswordstatusId;
+ $found = false;
+ foreach($this->_onetimepasswordList as $onetimepassword2)
+ {
+ if ($onetimepassword->onetimepasswordId > 0 && $onetimepassword->onetimepasswordId == $onetimepassword2->onetimepasswordId)
+ {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found)
+ {
+ $this->_onetimepasswordList[] = $onetimepassword;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/backend/php/src/objects/class.pog_base.php b/backend/php/src/objects/class.pog_base.php
new file mode 100644
index 0000000..6a8f570
--- a/dev/null
+++ b/backend/php/src/objects/class.pog_base.php
@@ -0,0 +1,143 @@
+<?php
+class POG_Base
+{
+ /**
+ * Overloading
+ */
+ function __call($method, $argv)
+ {
+ include_once($GLOBALS['configuration']['plugins_path']."/IPlugin.php");
+ include_once($GLOBALS['configuration']['plugins_path']."/plugin.".strtolower($method).".php");
+ eval('$plugin = new $method($this,$argv);');
+ return $plugin->Execute();
+ }
+
+ /**
+ * constructor
+ *
+ * @return POG_Base
+ */
+ private function POG_Base()
+ {
+ }
+
+
+ function SetFieldAttribute($fieldName, $attributeName, $attributeValue)
+ {
+ if (isset($this->pog_attribute_type[$fieldName]) && isset($this->pog_attribute_type[$fieldName][$attributeName]))
+ {
+ $this->pog_attribute_type[$fieldName][$attributeName] = $attributeValue;
+ }
+ }
+
+ function GetFieldAttribute($fieldName, $attributeName)
+ {
+ if (isset($this->pog_attribute_type[$fieldName]) && isset($this->pog_attribute_type[$fieldName][$attributeName]))
+ {
+ return $this->pog_attribute_type[$fieldName][$attributeName];
+ }
+ return null;
+ }
+
+ ///////////////////////////
+ // Data manipulation
+ ///////////////////////////
+
+ /**
+ * This function will try to encode $text to base64, except when $text is a number. This allows us to Escape all data before they're inserted in the database, regardless of attribute type.
+ * @param string $text
+ * @return string encoded to base64
+ */
+ public function Escape($text)
+ {
+ if ($GLOBALS['configuration']['db_encoding'] && !is_numeric($text))
+ {
+ return base64_encode($text);
+ }
+ return addslashes($text);
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param unknown_type $text
+ * @return unknown
+ */
+ public function Unescape($text)
+ {
+ if ($GLOBALS['configuration']['db_encoding'] && !is_numeric($text))
+ {
+ return base64_decode($text);
+ }
+ return stripcslashes($text);
+ }
+
+
+ ////////////////////////////////
+ // Table -> Object Mapping
+ ////////////////////////////////
+
+ /**
+ * Executes $query against database and returns the result set as an array of POG objects
+ *
+ * @param string $query. SQL query to execute against database
+ * @param string $objectClass. POG Object type to return
+ * @param bool $lazy. If true, will also load all children/sibling
+ */
+ public function FetchObjects($query, $objectClass, $lazy = true)
+ {
+ $databaseConnection = Database::Connect();
+ $result = Database::Query($query, $databaseConnection);
+ $objectList = $this->CreateObjects($result, $objectClass, $lazy);
+ return $objectList;
+ }
+
+ private function CreateObjects($mysql_result, $objectClass, $lazyLoad = true)
+ {
+ $objectList = array();
+ while ($row = mysql_fetch_assoc($mysql_result))
+ {
+ $pog_object = new $objectClass();
+ $this->PopulateObjectAttributes($row, $pog_object);
+ $objectList[] = $pog_object;
+ }
+ return $objectList;
+ }
+
+ private function PopulateObjectAttributes($fetched_row, $pog_object)
+ {
+ foreach ($this->GetAttributes($pog_object) as $column)
+ {
+ $pog_object->{$column} = $this->Unescape($fetched_row[strtolower($column)]);
+ }
+ return $pog_object;
+ }
+
+ private function GetAttributes($object)
+ {
+ $columns = array();
+ foreach ($object->pog_attribute_type as $att => $properties)
+ {
+ if ($properties['db_attributes'][0] != 'OBJECT')
+ {
+ $columns[] = $att;
+ }
+ }
+ return $columns;
+ }
+
+ //misc
+ public static function IsColumn($value)
+ {
+ if (strlen($value) > 2)
+ {
+ if (substr($value, 0, 1) == '`' && substr($value, strlen($value) - 1, 1) == '`')
+ {
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+}
+?> \ No newline at end of file
diff --git a/backend/php/src/objects/class.record.php b/backend/php/src/objects/class.record.php
new file mode 100644
index 0000000..a269e75
--- a/dev/null
+++ b/backend/php/src/objects/class.record.php
@@ -0,0 +1,436 @@
+<?php
+/*
+ This SQL query will create the table to store your object.
+
+ CREATE TABLE `record` (
+ `recordid` int(11) NOT NULL auto_increment,
+ `userid` int(11) NOT NULL,
+ `reference` VARCHAR(255) NOT NULL,
+ `data` LONGTEXT NOT NULL,
+ `version` VARCHAR(255) NOT NULL,
+ `creation_date` TIMESTAMP NOT NULL,
+ `update_date` TIMESTAMP NOT NULL,
+ `access_date` TIMESTAMP NOT NULL, INDEX(`userid`), PRIMARY KEY (`recordid`)) ENGINE=MyISAM;
+*/
+
+/**
+* <b>record</b> class with integrated CRUD methods.
+* @author Php Object Generator
+* @version POG 3.0e / PHP5.1 MYSQL
+* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
+* @copyright Free for personal & commercial use. (Offered under the BSD license)
+* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=record&attributeList=array+%28%0A++0+%3D%3E+%27user%27%2C%0A++1+%3D%3E+%27recordversion%27%2C%0A++2+%3D%3E+%27reference%27%2C%0A++3+%3D%3E+%27data%27%2C%0A++4+%3D%3E+%27version%27%2C%0A++5+%3D%3E+%27creation_date%27%2C%0A++6+%3D%3E+%27update_date%27%2C%0A++7+%3D%3E+%27access_date%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2529
+*/
+include_once('class.pog_base.php');
+class record extends POG_Base
+{
+ public $recordId = '';
+
+ /**
+ * @var INT(11)
+ */
+ public $userId;
+
+ /**
+ * @var private array of recordversion objects
+ */
+ private $_recordversionList = array();
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $reference;
+
+ /**
+ * @var LONGTEXT
+ */
+ public $data;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $version;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $creation_date;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $update_date;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $access_date;
+
+ public $pog_attribute_type = array(
+ "recordId" => array('db_attributes' => array("NUMERIC", "INT")),
+ "user" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
+ "recordversion" => array('db_attributes' => array("OBJECT", "HASMANY")),
+ "reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "data" => array('db_attributes' => array("TEXT", "LONGTEXT")),
+ "version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ "update_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ "access_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ );
+ public $pog_query;
+
+
+ /**
+ * Getter for some private attributes
+ * @return mixed $attribute
+ */
+ public function __get($attribute)
+ {
+ if (isset($this->{"_".$attribute}))
+ {
+ return $this->{"_".$attribute};
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function record($reference='', $data='', $version='', $creation_date='', $update_date='', $access_date='')
+ {
+ $this->_recordversionList = array();
+ $this->reference = $reference;
+ $this->data = $data;
+ $this->version = $version;
+ $this->creation_date = $creation_date;
+ $this->update_date = $update_date;
+ $this->access_date = $access_date;
+ }
+
+
+ /**
+ * Gets object from database
+ * @param integer $recordId
+ * @return object $record
+ */
+ function Get($recordId)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select * from `record` where `recordid`='".intval($recordId)."' LIMIT 1";
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $this->recordId = $row['recordid'];
+ $this->userId = $row['userid'];
+ $this->reference = $this->Unescape($row['reference']);
+ $this->data = $this->Unescape($row['data']);
+ $this->version = $this->Unescape($row['version']);
+ $this->creation_date = $row['creation_date'];
+ $this->update_date = $row['update_date'];
+ $this->access_date = $row['access_date'];
+ }
+ return $this;
+ }
+
+
+ /**
+ * Returns a sorted array of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array $recordList
+ */
+ function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $connection = Database::Connect();
+ $sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
+ $this->pog_query = "select * from `record` ";
+ $recordList = Array();
+ if (sizeof($fcv_array) > 0)
+ {
+ $this->pog_query .= " where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $this->pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
+ {
+ $this->pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ }
+ }
+ if ($sortBy != '')
+ {
+ if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $sortBy = "BASE64_DECODE($sortBy) ";
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "recordid";
+ }
+ $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
+ $thisObjectName = get_class($this);
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $record = new $thisObjectName();
+ $record->recordId = $row['recordid'];
+ $record->userId = $row['userid'];
+ $record->reference = $this->Unescape($row['reference']);
+ $record->data = $this->Unescape($row['data']);
+ $record->version = $this->Unescape($row['version']);
+ $record->creation_date = $row['creation_date'];
+ $record->update_date = $row['update_date'];
+ $record->access_date = $row['access_date'];
+ $recordList[] = $record;
+ }
+ return $recordList;
+ }
+
+
+ /**
+ * Saves the object to the database
+ * @return integer $recordId
+ */
+ function Save($deep = true)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select `recordid` from `record` where `recordid`='".$this->recordId."' LIMIT 1";
+ $rows = Database::Query($this->pog_query, $connection);
+ if ($rows > 0)
+ {
+ $this->pog_query = "update `record` set
+ `userid`='".$this->userId."',
+ `reference`='".$this->Escape($this->reference)."',
+ `data`='".$this->Escape($this->data)."',
+ `version`='".$this->Escape($this->version)."',
+ `creation_date`='".$this->creation_date."',
+ `update_date`='".$this->update_date."',
+ `access_date`='".$this->access_date."' where `recordid`='".$this->recordId."'";
+ }
+ else
+ {
+ $this->pog_query = "insert into `record` (`userid`, `reference`, `data`, `version`, `creation_date`, `update_date`, `access_date` ) values (
+ '".$this->userId."',
+ '".$this->Escape($this->reference)."',
+ '".$this->Escape($this->data)."',
+ '".$this->Escape($this->version)."',
+ '".$this->creation_date."',
+ '".$this->update_date."',
+ '".$this->access_date."' )";
+ }
+ $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
+ if ($this->recordId == "")
+ {
+ $this->recordId = $insertId;
+ }
+ if ($deep)
+ {
+ foreach ($this->_recordversionList as $recordversion)
+ {
+ $recordversion->recordId = $this->recordId;
+ $recordversion->Save($deep);
+ }
+ }
+ return $this->recordId;
+ }
+
+
+ /**
+ * Clones the object and saves it to the database
+ * @return integer $recordId
+ */
+ function SaveNew($deep = false)
+ {
+ $this->recordId = '';
+ return $this->Save($deep);
+ }
+
+
+ /**
+ * Deletes the object from the database
+ * @return boolean
+ */
+ function Delete($deep = false, $across = false)
+ {
+ if ($deep)
+ {
+ $recordversionList = $this->GetRecordversionList();
+ foreach ($recordversionList as $recordversion)
+ {
+ $recordversion->Delete($deep, $across);
+ }
+ }
+ $connection = Database::Connect();
+ $this->pog_query = "delete from `record` where `recordid`='".$this->recordId."'";
+ return Database::NonQuery($this->pog_query, $connection);
+ }
+
+
+ /**
+ * Deletes a list of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param bool $deep
+ * @return
+ */
+ function DeleteList($fcv_array, $deep = false, $across = false)
+ {
+ if (sizeof($fcv_array) > 0)
+ {
+ if ($deep || $across)
+ {
+ $objectList = $this->GetList($fcv_array);
+ foreach ($objectList as $object)
+ {
+ $object->Delete($deep, $across);
+ }
+ }
+ else
+ {
+ $connection = Database::Connect();
+ $pog_query = "delete from `record` where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
+ {
+ $pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
+ }
+ else
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
+ }
+ }
+ }
+ return Database::NonQuery($pog_query, $connection);
+ }
+ }
+ }
+
+
+ /**
+ * Associates the user object to this one
+ * @return boolean
+ */
+ function GetUser()
+ {
+ $user = new user();
+ return $user->Get($this->userId);
+ }
+
+
+ /**
+ * Associates the user object to this one
+ * @return
+ */
+ function SetUser(&$user)
+ {
+ $this->userId = $user->userId;
+ }
+
+
+ /**
+ * Gets a list of recordversion objects associated to this one
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array of recordversion objects
+ */
+ function GetRecordversionList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $recordversion = new recordversion();
+ $fcv_array[] = array("recordId", "=", $this->recordId);
+ $dbObjects = $recordversion->GetList($fcv_array, $sortBy, $ascending, $limit);
+ return $dbObjects;
+ }
+
+
+ /**
+ * Makes this the parent of all recordversion objects in the recordversion List array. Any existing recordversion will become orphan(s)
+ * @return null
+ */
+ function SetRecordversionList(&$list)
+ {
+ $this->_recordversionList = array();
+ $existingRecordversionList = $this->GetRecordversionList();
+ foreach ($existingRecordversionList as $recordversion)
+ {
+ $recordversion->recordId = '';
+ $recordversion->Save(false);
+ }
+ $this->_recordversionList = $list;
+ }
+
+
+ /**
+ * Associates the recordversion object to this one
+ * @return
+ */
+ function AddRecordversion(&$recordversion)
+ {
+ $recordversion->recordId = $this->recordId;
+ $found = false;
+ foreach($this->_recordversionList as $recordversion2)
+ {
+ if ($recordversion->recordversionId > 0 && $recordversion->recordversionId == $recordversion2->recordversionId)
+ {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found)
+ {
+ $this->_recordversionList[] = $recordversion;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/backend/php/src/objects/class.recordversion.php b/backend/php/src/objects/class.recordversion.php
new file mode 100644
index 0000000..3fbc436
--- a/dev/null
+++ b/backend/php/src/objects/class.recordversion.php
@@ -0,0 +1,381 @@
+<?php
+/*
+ This SQL query will create the table to store your object.
+
+ CREATE TABLE `recordversion` (
+ `recordversionid` int(11) NOT NULL auto_increment,
+ `recordid` int(11) NOT NULL,
+ `reference` VARCHAR(255) NOT NULL,
+ `header` LONGTEXT NOT NULL,
+ `data` LONGTEXT NOT NULL,
+ `version` VARCHAR(255) NOT NULL,
+ `previous_version_key` VARCHAR(255) NOT NULL,
+ `previous_version_id` INT NOT NULL,
+ `creation_date` TIMESTAMP NOT NULL,
+ `update_date` TIMESTAMP NOT NULL,
+ `access_date` TIMESTAMP NOT NULL, INDEX(`recordid`), PRIMARY KEY (`recordversionid`)) ENGINE=MyISAM;
+*/
+
+/**
+* <b>recordversion</b> class with integrated CRUD methods.
+* @author Php Object Generator
+* @version POG 3.0e / PHP5.1 MYSQL
+* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
+* @copyright Free for personal & commercial use. (Offered under the BSD license)
+* @link http://www.phpobjectgenerator.com/?language=php5.1=pdo&pdoDriver=mysql&objectName=recordversion&attributeList=array+%28%0A++0+%3D%3E+%27record%27%2C%0A++1+%3D%3E+%27reference%27%2C%0A++2+%3D%3E+%27header%27%2C%0A++3+%3D%3E+%27data%27%2C%0A++4+%3D%3E+%27version%27%2C%0A++5+%3D%3E+%27previous_version_key%27%2C%0A++6+%3D%3E+%27previous_version_id%27%2C%0A++7+%3D%3E+%27creation_date%27%2C%0A++8+%3D%3E+%27update_date%27%2C%0A++9+%3D%3E+%27access_date%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B8%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B9%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2529
+*/
+include_once('class.pog_base.php');
+class recordversion extends POG_Base
+{
+ public $recordversionId = '';
+
+ /**
+ * @var INT(11)
+ */
+ public $recordId;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $reference;
+
+ /**
+ * @var LONGTEXT
+ */
+ public $header;
+
+ /**
+ * @var LONGTEXT
+ */
+ public $data;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $version;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $previous_version_key;
+
+ /**
+ * @var INT
+ */
+ public $previous_version_id;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $creation_date;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $update_date;
+
+ /**
+ * @var TIMESTAMP
+ */
+ public $access_date;
+
+ public $pog_attribute_type = array(
+ "recordversionId" => array('db_attributes' => array("NUMERIC", "INT")),
+ "record" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
+ "reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "header" => array('db_attributes' => array("TEXT", "LONGTEXT")),
+ "data" => array('db_attributes' => array("TEXT", "LONGTEXT")),
+ "version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "previous_version_key" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "previous_version_id" => array('db_attributes' => array("NUMERIC", "INT")),
+ "creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ "update_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ "access_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
+ );
+ public $pog_query;
+
+
+ /**
+ * Getter for some private attributes
+ * @return mixed $attribute
+ */
+ public function __get($attribute)
+ {
+ if (isset($this->{"_".$attribute}))
+ {
+ return $this->{"_".$attribute};
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function recordversion($reference='', $header='', $data='', $version='', $previous_version_key='', $previous_version_id='', $creation_date='', $update_date='', $access_date='')
+ {
+ $this->reference = $reference;
+ $this->header = $header;
+ $this->data = $data;
+ $this->version = $version;
+ $this->previous_version_key = $previous_version_key;
+ $this->previous_version_id = $previous_version_id;
+ $this->creation_date = $creation_date;
+ $this->update_date = $update_date;
+ $this->access_date = $access_date;
+ }
+
+
+ /**
+ * Gets object from database
+ * @param integer $recordversionId
+ * @return object $recordversion
+ */
+ function Get($recordversionId)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select * from `recordversion` where `recordversionid`='".intval($recordversionId)."' LIMIT 1";
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $this->recordversionId = $row['recordversionid'];
+ $this->recordId = $row['recordid'];
+ $this->reference = $this->Unescape($row['reference']);
+ $this->header = $this->Unescape($row['header']);
+ $this->data = $this->Unescape($row['data']);
+ $this->version = $this->Unescape($row['version']);
+ $this->previous_version_key = $this->Unescape($row['previous_version_key']);
+ $this->previous_version_id = $this->Unescape($row['previous_version_id']);
+ $this->creation_date = $row['creation_date'];
+ $this->update_date = $row['update_date'];
+ $this->access_date = $row['access_date'];
+ }
+ return $this;
+ }
+
+
+ /**
+ * Returns a sorted array of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array $recordversionList
+ */
+ function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $connection = Database::Connect();
+ $sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
+ $this->pog_query = "select * from `recordversion` ";
+ $recordversionList = Array();
+ if (sizeof($fcv_array) > 0)
+ {
+ $this->pog_query .= " where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $this->pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
+ {
+ $this->pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ }
+ }
+ if ($sortBy != '')
+ {
+ if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $sortBy = "BASE64_DECODE($sortBy) ";
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "recordversionid";
+ }
+ $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
+ $thisObjectName = get_class($this);
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $recordversion = new $thisObjectName();
+ $recordversion->recordversionId = $row['recordversionid'];
+ $recordversion->recordId = $row['recordid'];
+ $recordversion->reference = $this->Unescape($row['reference']);
+ $recordversion->header = $this->Unescape($row['header']);
+ $recordversion->data = $this->Unescape($row['data']);
+ $recordversion->version = $this->Unescape($row['version']);
+ $recordversion->previous_version_key = $this->Unescape($row['previous_version_key']);
+ $recordversion->previous_version_id = $this->Unescape($row['previous_version_id']);
+ $recordversion->creation_date = $row['creation_date'];
+ $recordversion->update_date = $row['update_date'];
+ $recordversion->access_date = $row['access_date'];
+ $recordversionList[] = $recordversion;
+ }
+ return $recordversionList;
+ }
+
+
+ /**
+ * Saves the object to the database
+ * @return integer $recordversionId
+ */
+ function Save()
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select `recordversionid` from `recordversion` where `recordversionid`='".$this->recordversionId."' LIMIT 1";
+ $rows = Database::Query($this->pog_query, $connection);
+ if ($rows > 0)
+ {
+ $this->pog_query = "update `recordversion` set
+ `recordid`='".$this->recordId."',
+ `reference`='".$this->Escape($this->reference)."',
+ `header`='".$this->Escape($this->header)."',
+ `data`='".$this->Escape($this->data)."',
+ `version`='".$this->Escape($this->version)."',
+ `previous_version_key`='".$this->Escape($this->previous_version_key)."',
+ `previous_version_id`='".$this->Escape($this->previous_version_id)."',
+ `creation_date`='".$this->creation_date."',
+ `update_date`='".$this->update_date."',
+ `access_date`='".$this->access_date."' where `recordversionid`='".$this->recordversionId."'";
+ }
+ else
+ {
+ $this->pog_query = "insert into `recordversion` (`recordid`, `reference`, `header`, `data`, `version`, `previous_version_key`, `previous_version_id`, `creation_date`, `update_date`, `access_date` ) values (
+ '".$this->recordId."',
+ '".$this->Escape($this->reference)."',
+ '".$this->Escape($this->header)."',
+ '".$this->Escape($this->data)."',
+ '".$this->Escape($this->version)."',
+ '".$this->Escape($this->previous_version_key)."',
+ '".$this->Escape($this->previous_version_id)."',
+ '".$this->creation_date."',
+ '".$this->update_date."',
+ '".$this->access_date."' )";
+ }
+ $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
+ if ($this->recordversionId == "")
+ {
+ $this->recordversionId = $insertId;
+ }
+ return $this->recordversionId;
+ }
+
+
+ /**
+ * Clones the object and saves it to the database
+ * @return integer $recordversionId
+ */
+ function SaveNew()
+ {
+ $this->recordversionId = '';
+ return $this->Save();
+ }
+
+
+ /**
+ * Deletes the object from the database
+ * @return boolean
+ */
+ function Delete()
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "delete from `recordversion` where `recordversionid`='".$this->recordversionId."'";
+ return Database::NonQuery($this->pog_query, $connection);
+ }
+
+
+ /**
+ * Deletes a list of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param bool $deep
+ * @return
+ */
+ function DeleteList($fcv_array)
+ {
+ if (sizeof($fcv_array) > 0)
+ {
+ $connection = Database::Connect();
+ $pog_query = "delete from `recordversion` where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
+ {
+ $pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
+ }
+ else
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
+ }
+ }
+ }
+ return Database::NonQuery($pog_query, $connection);
+ }
+ }
+
+
+ /**
+ * Associates the record object to this one
+ * @return boolean
+ */
+ function GetRecord()
+ {
+ $record = new record();
+ return $record->Get($this->recordId);
+ }
+
+
+ /**
+ * Associates the record object to this one
+ * @return
+ */
+ function SetRecord(&$record)
+ {
+ $this->recordId = $record->recordId;
+ }
+}
+?> \ No newline at end of file
diff --git a/backend/php/src/objects/class.user.php b/backend/php/src/objects/class.user.php
new file mode 100644
index 0000000..f92c7ac
--- a/dev/null
+++ b/backend/php/src/objects/class.user.php
@@ -0,0 +1,502 @@
+<?php
+/*
+ This SQL query will create the table to store your object.
+
+ CREATE TABLE `user` (
+ `userid` int(11) NOT NULL auto_increment,
+ `username` VARCHAR(255) NOT NULL,
+ `srp_s` VARCHAR(255) NOT NULL,
+ `srp_v` VARCHAR(255) NOT NULL,
+ `header` LONGTEXT NOT NULL,
+ `statistics` LONGTEXT NOT NULL,
+ `auth_version` VARCHAR(255) NOT NULL,
+ `version` VARCHAR(255) NOT NULL,
+ `lock` VARCHAR(255) NOT NULL, PRIMARY KEY (`userid`)) ENGINE=MyISAM;
+*/
+
+/**
+* <b>user</b> class with integrated CRUD methods.
+* @author Php Object Generator
+* @version POG 3.0e / PHP5.1 MYSQL
+* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
+* @copyright Free for personal & commercial use. (Offered under the BSD license)
+* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=user&attributeList=array+%28%0A++0+%3D%3E+%27username%27%2C%0A++1+%3D%3E+%27srp_s%27%2C%0A++2+%3D%3E+%27srp_v%27%2C%0A++3+%3D%3E+%27header%27%2C%0A++4+%3D%3E+%27statistics%27%2C%0A++5+%3D%3E+%27auth_version%27%2C%0A++6+%3D%3E+%27version%27%2C%0A++7+%3D%3E+%27lock%27%2C%0A++8+%3D%3E+%27record%27%2C%0A++9+%3D%3E+%27onetimepassword%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B8%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B9%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2529
+*/
+include_once('class.pog_base.php');
+class user extends POG_Base
+{
+ public $userId = '';
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $username;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $srp_s;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $srp_v;
+
+ /**
+ * @var LONGTEXT
+ */
+ public $header;
+
+ /**
+ * @var LONGTEXT
+ */
+ public $statistics;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $auth_version;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $version;
+
+ /**
+ * @var VARCHAR(255)
+ */
+ public $lock;
+
+ /**
+ * @var private array of record objects
+ */
+ private $_recordList = array();
+
+ /**
+ * @var private array of onetimepassword objects
+ */
+ private $_onetimepasswordList = array();
+
+ public $pog_attribute_type = array(
+ "userId" => array('db_attributes' => array("NUMERIC", "INT")),
+ "username" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "srp_s" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "srp_v" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "header" => array('db_attributes' => array("TEXT", "LONGTEXT")),
+ "statistics" => array('db_attributes' => array("TEXT", "LONGTEXT")),
+ "auth_version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "lock" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
+ "record" => array('db_attributes' => array("OBJECT", "HASMANY")),
+ "onetimepassword" => array('db_attributes' => array("OBJECT", "HASMANY")),
+ );
+ public $pog_query;
+
+
+ /**
+ * Getter for some private attributes
+ * @return mixed $attribute
+ */
+ public function __get($attribute)
+ {
+ if (isset($this->{"_".$attribute}))
+ {
+ return $this->{"_".$attribute};
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function user($username='', $srp_s='', $srp_v='', $header='', $statistics='', $auth_version='', $version='', $lock='')
+ {
+ $this->username = $username;
+ $this->srp_s = $srp_s;
+ $this->srp_v = $srp_v;
+ $this->header = $header;
+ $this->statistics = $statistics;
+ $this->auth_version = $auth_version;
+ $this->version = $version;
+ $this->lock = $lock;
+ $this->_recordList = array();
+ $this->_onetimepasswordList = array();
+ }
+
+
+ /**
+ * Gets object from database
+ * @param integer $userId
+ * @return object $user
+ */
+ function Get($userId)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select * from `user` where `userid`='".intval($userId)."' LIMIT 1";
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $this->userId = $row['userid'];
+ $this->username = $this->Unescape($row['username']);
+ $this->srp_s = $this->Unescape($row['srp_s']);
+ $this->srp_v = $this->Unescape($row['srp_v']);
+ $this->header = $this->Unescape($row['header']);
+ $this->statistics = $this->Unescape($row['statistics']);
+ $this->auth_version = $this->Unescape($row['auth_version']);
+ $this->version = $this->Unescape($row['version']);
+ $this->lock = $this->Unescape($row['lock']);
+ }
+ return $this;
+ }
+
+
+ /**
+ * Returns a sorted array of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array $userList
+ */
+ function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $connection = Database::Connect();
+ $sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
+ $this->pog_query = "select * from `user` ";
+ $userList = Array();
+ if (sizeof($fcv_array) > 0)
+ {
+ $this->pog_query .= " where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $this->pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
+ {
+ $this->pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ else
+ {
+ $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
+ $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
+ }
+ }
+ }
+ }
+ if ($sortBy != '')
+ {
+ if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
+ {
+ if ($GLOBALS['configuration']['db_encoding'] == 1)
+ {
+ $sortBy = "BASE64_DECODE($sortBy) ";
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "$sortBy ";
+ }
+ }
+ else
+ {
+ $sortBy = "userid";
+ }
+ $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
+ $thisObjectName = get_class($this);
+ $cursor = Database::Reader($this->pog_query, $connection);
+ while ($row = Database::Read($cursor))
+ {
+ $user = new $thisObjectName();
+ $user->userId = $row['userid'];
+ $user->username = $this->Unescape($row['username']);
+ $user->srp_s = $this->Unescape($row['srp_s']);
+ $user->srp_v = $this->Unescape($row['srp_v']);
+ $user->header = $this->Unescape($row['header']);
+ $user->statistics = $this->Unescape($row['statistics']);
+ $user->auth_version = $this->Unescape($row['auth_version']);
+ $user->version = $this->Unescape($row['version']);
+ $user->lock = $this->Unescape($row['lock']);
+ $userList[] = $user;
+ }
+ return $userList;
+ }
+
+
+ /**
+ * Saves the object to the database
+ * @return integer $userId
+ */
+ function Save($deep = true)
+ {
+ $connection = Database::Connect();
+ $this->pog_query = "select `userid` from `user` where `userid`='".$this->userId."' LIMIT 1";
+ $rows = Database::Query($this->pog_query, $connection);
+ if ($rows > 0)
+ {
+ $this->pog_query = "update `user` set
+ `username`='".$this->Escape($this->username)."',
+ `srp_s`='".$this->Escape($this->srp_s)."',
+ `srp_v`='".$this->Escape($this->srp_v)."',
+ `header`='".$this->Escape($this->header)."',
+ `statistics`='".$this->Escape($this->statistics)."',
+ `auth_version`='".$this->Escape($this->auth_version)."',
+ `version`='".$this->Escape($this->version)."',
+ `lock`='".$this->Escape($this->lock)."'where `userid`='".$this->userId."'";
+ }
+ else
+ {
+ $this->pog_query = "insert into `user` (`username`, `srp_s`, `srp_v`, `header`, `statistics`, `auth_version`, `version`, `lock`) values (
+ '".$this->Escape($this->username)."',
+ '".$this->Escape($this->srp_s)."',
+ '".$this->Escape($this->srp_v)."',
+ '".$this->Escape($this->header)."',
+ '".$this->Escape($this->statistics)."',
+ '".$this->Escape($this->auth_version)."',
+ '".$this->Escape($this->version)."',
+ '".$this->Escape($this->lock)."')";
+ }
+ $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
+ if ($this->userId == "")
+ {
+ $this->userId = $insertId;
+ }
+ if ($deep)
+ {
+ foreach ($this->_recordList as $record)
+ {
+ $record->userId = $this->userId;
+ $record->Save($deep);
+ }
+ foreach ($this->_onetimepasswordList as $onetimepassword)
+ {
+ $onetimepassword->userId = $this->userId;
+ $onetimepassword->Save($deep);
+ }
+ }
+ return $this->userId;
+ }
+
+
+ /**
+ * Clones the object and saves it to the database
+ * @return integer $userId
+ */
+ function SaveNew($deep = false)
+ {
+ $this->userId = '';
+ return $this->Save($deep);
+ }
+
+
+ /**
+ * Deletes the object from the database
+ * @return boolean
+ */
+ function Delete($deep = false, $across = false)
+ {
+ if ($deep)
+ {
+ $recordList = $this->GetRecordList();
+ foreach ($recordList as $record)
+ {
+ $record->Delete($deep, $across);
+ }
+ $onetimepasswordList = $this->GetOnetimepasswordList();
+ foreach ($onetimepasswordList as $onetimepassword)
+ {
+ $onetimepassword->Delete($deep, $across);
+ }
+ }
+ $connection = Database::Connect();
+ $this->pog_query = "delete from `user` where `userid`='".$this->userId."'";
+ return Database::NonQuery($this->pog_query, $connection);
+ }
+
+
+ /**
+ * Deletes a list of objects that match given conditions
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param bool $deep
+ * @return
+ */
+ function DeleteList($fcv_array, $deep = false, $across = false)
+ {
+ if (sizeof($fcv_array) > 0)
+ {
+ if ($deep || $across)
+ {
+ $objectList = $this->GetList($fcv_array);
+ foreach ($objectList as $object)
+ {
+ $object->Delete($deep, $across);
+ }
+ }
+ else
+ {
+ $connection = Database::Connect();
+ $pog_query = "delete from `user` where ";
+ for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
+ {
+ if (sizeof($fcv_array[$i]) == 1)
+ {
+ $pog_query .= " ".$fcv_array[$i][0]." ";
+ continue;
+ }
+ else
+ {
+ if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
+ {
+ $pog_query .= " AND ";
+ }
+ if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
+ }
+ else
+ {
+ $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
+ }
+ }
+ }
+ return Database::NonQuery($pog_query, $connection);
+ }
+ }
+ }
+
+
+ /**
+ * Gets a list of record objects associated to this one
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array of record objects
+ */
+ function GetRecordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $record = new record();
+ $fcv_array[] = array("userId", "=", $this->userId);
+ $dbObjects = $record->GetList($fcv_array, $sortBy, $ascending, $limit);
+ return $dbObjects;
+ }
+
+
+ /**
+ * Makes this the parent of all record objects in the record List array. Any existing record will become orphan(s)
+ * @return null
+ */
+ function SetRecordList(&$list)
+ {
+ $this->_recordList = array();
+ $existingRecordList = $this->GetRecordList();
+ foreach ($existingRecordList as $record)
+ {
+ $record->userId = '';
+ $record->Save(false);
+ }
+ $this->_recordList = $list;
+ }
+
+
+ /**
+ * Associates the record object to this one
+ * @return
+ */
+ function AddRecord(&$record)
+ {
+ $record->userId = $this->userId;
+ $found = false;
+ foreach($this->_recordList as $record2)
+ {
+ if ($record->recordId > 0 && $record->recordId == $record2->recordId)
+ {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found)
+ {
+ $this->_recordList[] = $record;
+ }
+ }
+
+
+ /**
+ * Gets a list of onetimepassword objects associated to this one
+ * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
+ * @param string $sortBy
+ * @param boolean $ascending
+ * @param int limit
+ * @return array of onetimepassword objects
+ */
+ function GetOnetimepasswordList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
+ {
+ $onetimepassword = new onetimepassword();
+ $fcv_array[] = array("userId", "=", $this->userId);
+ $dbObjects = $onetimepassword->GetList($fcv_array, $sortBy, $ascending, $limit);
+ return $dbObjects;
+ }
+
+
+ /**
+ * Makes this the parent of all onetimepassword objects in the onetimepassword List array. Any existing onetimepassword will become orphan(s)
+ * @return null
+ */
+ function SetOnetimepasswordList(&$list)
+ {
+ $this->_onetimepasswordList = array();
+ $existingOnetimepasswordList = $this->GetOnetimepasswordList();
+ foreach ($existingOnetimepasswordList as $onetimepassword)
+ {
+ $onetimepassword->userId = '';
+ $onetimepassword->Save(false);
+ }
+ $this->_onetimepasswordList = $list;
+ }
+
+
+ /**
+ * Associates the onetimepassword object to this one
+ * @return
+ */
+ function AddOnetimepassword(&$onetimepassword)
+ {
+ $onetimepassword->userId = $this->userId;
+ $found = false;
+ foreach($this->_onetimepasswordList as $onetimepassword2)
+ {
+ if ($onetimepassword->onetimepasswordId > 0 && $onetimepassword->onetimepasswordId == $onetimepassword2->onetimepasswordId)
+ {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found)
+ {
+ $this->_onetimepasswordList[] = $onetimepassword;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/backend/php/src/objects/ignore_objects.txt b/backend/php/src/objects/ignore_objects.txt
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/backend/php/src/objects/ignore_objects.txt