PHP7 compability stuff, recoding of genericdb

Dieser Commit ist enthalten in:
Oldperl 2016-10-08 13:39:50 +00:00
Ursprung e01da5b38f
Commit f7d6ecf59e
38 geänderte Dateien mit 439 neuen und 453 gelöschten Zeilen

Datei anzeigen

@ -50,7 +50,7 @@ class cApiActionCollection extends ItemCollection {
* @return cApiAction
*/
public function create($area, $name, $code = "", $location = "", $relevant = 1) {
$item = parent::create();
$item = parent::createNewItem();
if (is_string($area)) {
$c = new cApiArea();

Datei anzeigen

@ -54,7 +54,7 @@ class cApiUploadCollection extends ItemCollection {
public function create($dir, $file) {
global $client, $cfg, $auth;
$item = parent::create();
$item = parent::createNewItem();
$item->set("idclient", $client);
$item->set("filename", $file, false);

Datei anzeigen

@ -60,7 +60,7 @@ class CommunicationCollection extends ItemCollection
public function create()
{
global $auth, $client;
$item = parent::create();
$item = parent::createNewItem();
$client = Contenido_Security::toInteger($client);

Datei anzeigen

@ -236,7 +236,7 @@ class DBFSCollection extends ItemCollection
}
if ($dir && !$this->dir_exists($dir) || $file != ".") {
$item = parent::create();
$item = parent::createNewItem();
$item->set("idclient", $client);
$item->set("dirname", $dir);
$item->set("filename", $file);

Datei anzeigen

@ -77,7 +77,7 @@ class FrontendGroupCollection extends ItemCollection
$groupname = $groupname. md5(rand());
}
$item = parent::create();
$item = parent::createNewItem();
$item->set("idclient", $client);
$item->set("groupname", $groupname);
@ -170,7 +170,7 @@ class FrontendGroupMemberCollection extends ItemCollection
return false;
}
$item = parent::create();
$item = parent::createNewItem();
$item->set("idfrontenduser", $idfrontenduser);
$item->set("idfrontendgroup", $idfrontendgroup);

Datei anzeigen

@ -74,7 +74,7 @@ class FrontendPermissionCollection extends ItemCollection
$item = null;
if (!$this->checkPerm($group, $plugin, $action, $mitem)) {
$item = parent::create();
$item = parent::createNewItem();
$item->set("idlang", $lang);
$item->set("idfrontendgroup", $group);
$item->set("plugin", $plugin);

Datei anzeigen

@ -94,7 +94,7 @@ class FrontendUserCollection extends ItemCollection
return $this->create($username."_".substr(md5(rand()),0,10), $password);
}
$item = parent::create();
$item = parent::createNewItem();
$item->set("idclient", $client);
$item->set("username", $username);
$item->set("password", $password);

Datei anzeigen

@ -38,6 +38,10 @@ if (file_exists($driver_filename)) {
include_once($driver_filename);
}
// load all genericdb classes
cInclude("classes", "genericdb/class.item.base.abstract.php");
cInclude("classes", "genericdb/class.item.cache.php");
/**
* Class Contenido_ItemException.
@ -48,401 +52,10 @@ if (file_exists($driver_filename)) {
class Contenido_ItemException extends Exception {}
/**
* Class Contenido_ItemCache.
*
* Implements features to cache entries, usually result sets of Item classes.
* Contains a list of self instances, where each instance contains cached Items
* fore one specific table.
*
* @author Murat Purc <murat@purc.de>
* @version 0.1.2
* @copyright four for business AG <www.4fb.de>
*/
class Contenido_ItemCache
{
/**
* List of self instances (Contenido_ItemCache)
* @var array
*/
protected static $_oInstances = array();
/**
* Assoziative cache array
* @var array
*/
protected $_aItemsCache = array();
/**
* Table name for current instance
* @var string
*/
protected $_sTable = '';
/**
* Max number of items to cache
* @var int
*/
protected $_iMaxItemsToCache = 10;
/**
* Enable caching
* @var bool
*/
protected $_bEnable = false;
protected $_iFrame;
/**
* Contructor of Contenido_ItemCache
* @param string $sTable Table name
* @param array $aOptions Options array as follows:
* - $aOptions['max_items_to_cache'] = (int) Number of items to cache
* - $aOptions['enable'] = (bool) Flag to enable caching
*/
protected function __construct($sTable, array $aOptions = array())
{
$this->_sTable = $sTable;
if (isset($aOptions['max_items_to_cache']) && (int) $aOptions['max_items_to_cache'] > 0) {
$this->_iMaxItemsToCache = (int) $aOptions['max_items_to_cache'];
}
if (isset($aOptions['enable']) && is_bool($aOptions['enable'])) {
$this->_bEnable = (bool) $aOptions['enable'];
}
if(isset($_GET['frame']) && is_numeric($_GET['frame'])) {
$this->_iFrame = (int) $_GET['frame'];
} else {
$this->_bEnable = false;
}
}
/**
* Prevent cloning
*/
protected function __clone()
{
}
/**
* Returns item cache instance, creates it, if not done before.
* Works as a singleton for one specific table.
*
* @param string $sTable Table name
* @param array $aOptions Options array as follows:
* - $aOptions['max_items_to_cache'] = (int) Number of items to cache
* - $aOptions['enable'] = (bool) Flag to enable caching
*/
public static function getInstance($sTable, array $aOptions = array())
{
if (!isset(self::$_oInstances[$sTable])) {
self::$_oInstances[$sTable] = new self($sTable, $aOptions);
}
return self::$_oInstances[$sTable];
}
/**
* Returns items cache list.
*
* @return array
*/
public function getItemsCache()
{
return $this->_aItemsCache[$this->_iFrame];
}
/**
* Returns existing entry from cache by it's id.
*
* @param mixed $mId
* @return array|null
*/
public function getItem($mId)
{
if (!$this->_bEnable) {
return null;
}
if (isset($this->_aItemsCache[$this->_iFrame][$mId])) {
return $this->_aItemsCache[$this->_iFrame][$mId];
} else {
return null;
}
}
/**
* Returns existing entry from cache by matching propery value.
*
* @param mixed $mProperty
* @param mixed $mValue
* @return array|null
*/
public function getItemByProperty($mProperty, $mValue)
{
if (!$this->_bEnable) {
return null;
}
// loop thru all cached entries and try to find a entry by it's property
if(is_array($this->_aItemsCache[$this->_iFrame])
&& count($this->_aItemsCache[$this->_iFrame]) > 0) {
foreach ($this->_aItemsCache[$this->_iFrame] as $id => $aEntry) {
if (isset($aEntry[$mProperty]) && $aEntry[$mProperty] == $mValue) {
return $aEntry;
}
}
}
return null;
}
/**
* Returns existing entry from cache by matching properties and their values.
*
* @param array $aProperties Assoziative key value pairs
* @return array|null
*/
public function getItemByProperties(array $aProperties)
{
if (!$this->_bEnable) {
return null;
}
// loop thru all cached entries and try to find a entry by it's property
foreach ($this->_aItemsCache as $id => $aEntry) {
$mFound = null;
foreach ($aProperties as $key => $value) {
if (isset($aEntry[$key]) && $aEntry[$key] == $value) {
if (null === $mFound) {
$mFound = true;
}
} else {
$mFound = false;
break;
}
if (true === $mFound) {
return $aEntry;
}
}
}
return null;
}
/**
* Adds passed item data to internal cache
*
* @param mixed $mId
* @param array $aData Usually the recordset
* @return void
*/
public function addItem($mId, array $aData)
{
if (!$this->_bEnable) {
return null;
}
if(isset($this->_aItemsCache[$this->_iFrame])) {
$aTmpItemsArray = $this->_aItemsCache[$this->_iFrame];
if ($this->_iMaxItemsToCache == count($aTmpItemsArray)) {
// we have reached the maximum number of cached items, remove first entry
$firstEntryKey = array_shift($aTmpItemsArray);
if(is_array($firstEntryKey)) return null;
unset($this->_aItemsCache[$this->_iFrame][$firstEntryKey]);
}
}
// add entry
$this->_aItemsCache[$this->_iFrame][$mId] = $aData;
}
/**
* Removes existing cache entry by it's key
*
* @param mixed $mId
* @return void
*/
public function removeItem($mId)
{
if (!$this->_bEnable) {
return null;
}
// remove entry
if (isset($this->_aItemsCache[$this->_iFrame][$mId])){
unset($this->_aItemsCache[$this->_iFrame][$mId]);
}
}
}
/**
* Class Contenido_ItemBaseAbstract.
* Base class with common features for database based items and item collections.
*
* @author Murat Purc <murat@purc.de>
* @version 0.2
* @copyright four for business AG <www.4fb.de>
*/
abstract class Contenido_ItemBaseAbstract
{
/**
* Database instance, contains the database object
* @var DB_ConLite
*/
protected $db;
/**
* Second DB instance, is required for some additional queries without
* losing an current existing query result.
* @var DB_ConLite
*/
protected $secondDb;
/**
* Property collection instance
* @var PropertyCollection
*/
protected $properties;
/**
* Item cache instance
* @var Contenido_ItemCache
*/
protected static $_oCache;
/**
* GenericDB settings, see $cfg['sql']
* @var array
*/
protected $_settings;
/**
* Storage of the source table to use for the information
* @var string
*/
protected $table;
/**
* Storage of the primary key
* @var string
* @todo remove access from public
*/
public $primaryKey;
/**
* Checks for the virginity of created objects. If true, the object
* is virgin and no operations on it except load-Functions are allowed.
* @todo remove access from public
* @var bool
*/
public $virgin;
/**
* Lifetime of results/created objects?
* FIXME Not used at the moment!
* @var int
*/
protected $lifetime;
/**
* Storage of the last occured error
* @var string
*/
protected $lasterror = '';
/**
* Cache the result items
* FIXME seems to not used, remove it!
* @var array
*/
protected $cache;
/**
* Classname of current instance
* @var string
*/
protected $_className;
/**
* Sets some common properties
*
* @param string $sTable Name of table
* @param string $sPrimaryKey Primary key of table
* @param string $sClassName Name of parent class
* @param int $iLifetime Lifetime of the object in seconds (NOT USED!)
* @throws Contenido_ItemException If table name or primary key is not set
*/
protected function __construct($sTable, $sPrimaryKey, $sClassName, $iLifetime = 10)
{
global $cfg;
$this->db = new DB_ConLite();
if ($sTable == '') {
$sMsg = "$sClassName: No table specified. Inherited classes *need* to set a table";
throw new Contenido_ItemException($sMsg);
} elseif ($sPrimaryKey == '') {
$sMsg = "No primary key specified. Inherited classes *need* to set a primary key";
throw new Contenido_ItemException($sMsg);
}
$this->_settings = $cfg['sql'];
// instanciate caching
$aCacheOpt = (isset($this->_settings['cache'])) ? $this->_settings['cache'] : array();
self::$_oCache = Contenido_ItemCache::getInstance($sTable, $aCacheOpt);
$this->table = $sTable;
$this->primaryKey = $sPrimaryKey;
$this->virgin = true;
$this->lifetime = $iLifetime;
$this->_className = $sClassName;
}
/**
* Escape string for using in SQL-Statement.
*
* @param string $sString The string to escape
* @return string Escaped string
*/
public function escape($sString)
{
return $this->db->escape($sString);
}
/**
* Returns the second database instance, usable to run additional statements
* without losing current query results.
*
* @return DB_ConLite
*/
protected function _getSecondDBInstance()
{
if (!isset($this->secondDb) || !($this->secondDb instanceof DB_ConLite)) {
$this->secondDb = new DB_ConLite();
}
return $this->secondDb;
}
/**
* Returns properties instance, instantiates it if not done before.
*
* @return PropertyCollection
*/
protected function _getPropertiesCollectionInstance()
{
// Runtime on-demand allocation of the properties object
if (!isset($this->properties) || !($this->properties instanceof PropertyCollection)) {
$this->properties = new PropertyCollection();
}
return $this->properties;
}
}
/**
* Class ItemCollection
* Abstract class for database based item collections.
*
@ -451,7 +64,7 @@ abstract class Contenido_ItemBaseAbstract
* @version 0.2
* @copyright four for business 2003
*/
abstract class ItemCollection extends Contenido_ItemBaseAbstract
abstract class ItemCollection extends cItemBaseAbstract
{
/**
* Storage of all result items
@ -1537,7 +1150,7 @@ abstract class ItemCollection extends Contenido_ItemBaseAbstract
* @param string $primaryKeyValue Optional parameter for direct input of primary key value
* @return Item The newly created object
*/
public function create()
public function createNewItem($aData = NULL)
{ /* @var $oDb DB_ConLite */
$oDb = $this->_getSecondDBInstance();
$iNextId = $oDb->nextid($this->table);
@ -1696,7 +1309,7 @@ abstract class ItemCollection extends Contenido_ItemBaseAbstract
* @version 0.3
* @copyright four for business 2003
*/
abstract class Item extends Contenido_ItemBaseAbstract
abstract class Item extends cItemBaseAbstract
{
/**
* Storage of the source table to use for the user informations

Datei anzeigen

@ -69,7 +69,7 @@ class InUseCollection extends ItemCollection
$this->select("type = '".$type."' AND objectid = '".$objectid."'");
if (!$this->next()) {
$newitem = parent::create();
$newitem = parent::createNewItem();
$newitem->set("type", $type);
$newitem->set("objectid", $objectid);
$newitem->set("session", $session);

Datei anzeigen

@ -82,7 +82,7 @@ class NoteCollection extends CommunicationCollection
*/
public function create($itemtype, $itemid, $idlang, $message, $category = "")
{
$item = parent::create();
$item = parent::createNewItem();
$item->set("subject", "Note Item");
$item->set("message", $message);

Datei anzeigen

@ -122,7 +122,7 @@ class PropertyCollection extends ItemCollection
{
global $cfg, $auth;
$item = parent::create();
$item = parent::createNewItem();
if (!$bInternally) {
$itemtype = Contenido_Security::escapeDB($itemtype, null);
@ -459,7 +459,7 @@ class PropertyItem extends Item
* @param string $value
* @param bool $safe Flag to run filter on passed value
*/
public function setField($field, $value, $safe)
public function setField($field, $value, $safe = true)
{
if (array_key_exists($field, $this->maximumLength)) {
if (strlen($value) > $this->maximumLength[$field]) {

Datei anzeigen

@ -63,7 +63,7 @@ class TODOCollection extends CommunicationCollection
/**
* Creates a new communication item
*/
public function create($itemtype, $itemid, $reminderdate, $subject, $content, $notimail, $notibackend, $recipient)
public function createItem($itemtype, $itemid, $reminderdate, $subject, $content, $notimail, $notibackend, $recipient)
{
$item = parent::create();

Datei anzeigen

@ -70,7 +70,7 @@ class cApiArea extends Item
public function create($name, $parentid = 0, $relevant = 1, $online = 1)
{
$item = parent::create();
$item = parent::createNewItem();
$item->set("name", $name);
$item->set("relevant", $relevant);

Datei anzeigen

@ -64,7 +64,7 @@ class cApiContainerCollection extends ItemCollection
public function create($idtpl, $number, $module)
{
$item = parent::create();
$item = parent::createNewItem();
$item->set("idtpl", $idtpl);
$item->set("number", $number);
$item->set("module", $module);

Datei anzeigen

@ -45,7 +45,7 @@ class cApiContainerConfigurationCollection extends ItemCollection
public function create($idtplcfg, $number, $container)
{
$item = parent::create();
$item = parent::createNewItem();
$item->set("idtplcfg", $idtplcfg);
$item->set("number", $number);
$item->set("container", $container);

Datei anzeigen

@ -45,7 +45,7 @@ class cApiFileCollection extends ItemCollection
public function create($area, $filename, $filetype = "main")
{
$item = parent::create();
$item = parent::createNewItem();
if (is_string($area)) {
$c = new cApiArea();

Datei anzeigen

@ -45,7 +45,7 @@ class cApiFrameFileCollection extends ItemCollection
public function create($area, $idframe, $idfile)
{
$item = parent::create();
$item = parent::createNewItem();
if (is_string($area)) {
$c = new cApiArea();

Datei anzeigen

@ -41,7 +41,7 @@ class cApiLayoutCollection extends ItemCollection {
public function create($title) {
global $client;
$item = parent::create();
$item = parent::createNewItem();
$item->set("name", $title);
$item->set("idclient", $client);
$item->store();

Datei anzeigen

@ -48,7 +48,7 @@ class cApiModuleCollection extends ItemCollection {
*/
public function create($name) {
global $auth, $client;
$item = parent::create();
$item = parent::createNewItem();
$item->set("idclient", $client);
$item->set("name", $name);
@ -147,13 +147,12 @@ class cApiModule extends Item {
}
}
$oClient = cApiClient::getInstance($client);
if ($oClient->isLoaded()) {
$oClient = new cApiClient($client);
$aClientProp = $oClient->getPropertiesByType('modfileedit');
if (count($aClientProp) > 0) {
$this->_aModFileEditConf = array_merge($this->_aModFileEditConf, $aClientProp);
}
}
if ($mId !== false) {
$this->loadByPrimaryKey($mId);
}
@ -889,7 +888,7 @@ class cApiModule extends Item {
if ($this->_aModFileEditConf['use'] !== true) {
return false;
}
return $this->_setFieldFromFile('output', $this->_sModAlias . "_output.php");
return $this->_setFieldFromFile('output', $this->_sModAlias."_output.php");
}
/**
@ -903,7 +902,7 @@ class cApiModule extends Item {
if ($this->_aModFileEditConf['use'] !== true) {
return false;
}
return $this->_setFieldFromFile('input', $this->_sModAlias . "_input.php");
return $this->_setFieldFromFile('input', $this->_sModAlias."_input.php");
}
private function _displayNoteFromFile($bIsOldPath = FALSE) {
@ -1076,7 +1075,7 @@ class cApiModuleTranslationCollection extends ItemCollection {
}
return $item;
} else {
$item = parent::create();
$item = parent::createNewItem();
$item->set("idmod", $idmod);
$item->set("idlang", $idlang);
$item->set("original", $original);

Datei anzeigen

@ -61,7 +61,7 @@ class cApiTemplateConfigurationCollection extends ItemCollection
{
global $auth;
$item = parent::create();
$item = parent::createNewItem();
$item->set("idtpl", $idtpl);
$item->set("author", $auth->auth['uname']);
$item->set("status", 0);

Datei anzeigen

@ -54,7 +54,7 @@ class cApiUserCollection extends ItemCollection
if ($this->next()) {
return false;
} else {
$item = parent::create();
$item = parent::createNewItem();
$item->set("user_id", $md5user);
$item->set("username", $username);
$item->store();

Datei anzeigen

@ -31,33 +31,31 @@ if(!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
class gdbDriver
{
class gdbDriver {
var $_sEncoding;
var $_oItemClassInstance;
function gdbDriver ()
{}
function gdbDriver() {
function setEncoding ($sEncoding)
{
}
function setEncoding($sEncoding) {
$this->_sEncoding = $sEncoding;
}
function setItemClassInstance ($oInstance)
{
function setItemClassInstance($oInstance) {
$this->_oItemClassInstance = $oInstance;
}
function buildJoinQuery ($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey)
{
function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) {
}
function buildOperator ($sField, $sOperator, $sRestriction)
{
function buildOperator($sField, $sOperator, $sRestriction) {
}
}
?>

Datei anzeigen

@ -0,0 +1,162 @@
<?php
/**
*
*/
// security check
defined('CON_FRAMEWORK') or die('Illegal call');
abstract class cItemBaseAbstract {
/**
* Database instance, contains the database object
* @var DB_ConLite
*/
protected $db;
/**
* Second DB instance, is required for some additional queries without
* losing an current existing query result.
* @var DB_ConLite
*/
protected $secondDb;
/**
* Property collection instance
* @var PropertyCollection
*/
protected $properties;
/**
* Item cache instance
* @var Contenido_ItemCache
*/
protected static $_oCache;
/**
* GenericDB settings, see $cfg['sql']
* @var array
*/
protected $_settings;
/**
* Storage of the source table to use for the information
* @var string
*/
protected $table;
/**
* Storage of the primary key
* @var string
* @todo remove access from public
*/
public $primaryKey;
/**
* Checks for the virginity of created objects. If true, the object
* is virgin and no operations on it except load-Functions are allowed.
* @todo remove access from public
* @var bool
*/
public $virgin;
/**
* Lifetime of results/created objects?
* FIXME Not used at the moment!
* @var int
*/
protected $lifetime;
/**
* Storage of the last occured error
* @var string
*/
protected $lasterror = '';
/**
* Cache the result items
* FIXME seems to not used, remove it!
* @var array
*/
protected $cache;
/**
* Classname of current instance
* @var string
*/
protected $_className;
/**
* Sets some common properties
*
* @param string $sTable Name of table
* @param string $sPrimaryKey Primary key of table
* @param string $sClassName Name of parent class
* @param int $iLifetime Lifetime of the object in seconds (NOT USED!)
* @throws Contenido_ItemException If table name or primary key is not set
*/
protected function __construct($sTable, $sPrimaryKey, $sClassName, $iLifetime = 10) {
global $cfg;
$this->db = new DB_ConLite();
if ($sTable == '') {
$sMsg = "$sClassName: No table specified. Inherited classes *need* to set a table";
throw new Contenido_ItemException($sMsg);
} elseif ($sPrimaryKey == '') {
$sMsg = "No primary key specified. Inherited classes *need* to set a primary key";
throw new Contenido_ItemException($sMsg);
}
$this->_settings = $cfg['sql'];
// instanciate caching
$aCacheOpt = (isset($this->_settings['cache'])) ? $this->_settings['cache'] : array();
self::$_oCache = cItemCache::getInstance($sTable, $aCacheOpt);
$this->table = $sTable;
$this->primaryKey = $sPrimaryKey;
$this->virgin = true;
$this->lifetime = $iLifetime;
$this->_className = $sClassName;
}
/**
* Escape string for using in SQL-Statement.
*
* @param string $sString The string to escape
* @return string Escaped string
*/
public function escape($sString) {
return $this->db->escape($sString);
}
/**
* Returns the second database instance, usable to run additional statements
* without losing current query results.
*
* @return DB_ConLite
*/
protected function _getSecondDBInstance() {
if (!isset($this->secondDb) || !($this->secondDb instanceof DB_ConLite)) {
$this->secondDb = new DB_ConLite();
}
return $this->secondDb;
}
/**
* Returns properties instance, instantiates it if not done before.
*
* @return PropertyCollection
*/
protected function _getPropertiesCollectionInstance() {
// Runtime on-demand allocation of the properties object
if (!isset($this->properties) || !($this->properties instanceof PropertyCollection)) {
$this->properties = new PropertyCollection();
}
return $this->properties;
}
}
?>

Datei anzeigen

@ -0,0 +1,214 @@
<?php
/**
*
*/
// security check
defined('CON_FRAMEWORK') or die('Illegal call');
class cItemCache {
/**
* List of self instances (Contenido_ItemCache)
* @var array
*/
protected static $_oInstances = array();
/**
* Assoziative cache array
* @var array
*/
protected $_aItemsCache = array();
/**
* Table name for current instance
* @var string
*/
protected $_sTable = '';
/**
* Max number of items to cache
* @var int
*/
protected $_iMaxItemsToCache = 10;
/**
* Enable caching
* @var bool
*/
protected $_bEnable = false;
protected $_iFrame;
/**
* Contructor of Contenido_ItemCache
* @param string $sTable Table name
* @param array $aOptions Options array as follows:
* - $aOptions['max_items_to_cache'] = (int) Number of items to cache
* - $aOptions['enable'] = (bool) Flag to enable caching
*/
protected function __construct($sTable, array $aOptions = array()) {
$this->_sTable = $sTable;
if (isset($aOptions['max_items_to_cache']) && (int) $aOptions['max_items_to_cache'] > 0) {
$this->_iMaxItemsToCache = (int) $aOptions['max_items_to_cache'];
}
if (isset($aOptions['enable']) && is_bool($aOptions['enable'])) {
$this->_bEnable = (bool) $aOptions['enable'];
}
if (isset($_GET['frame']) && is_numeric($_GET['frame'])) {
$this->_iFrame = (int) $_GET['frame'];
} else {
$this->_bEnable = false;
}
}
/**
* Prevent cloning
*/
protected function __clone() {
}
/**
* Returns item cache instance, creates it, if not done before.
* Works as a singleton for one specific table.
*
* @param string $sTable Table name
* @param array $aOptions Options array as follows:
* - $aOptions['max_items_to_cache'] = (int) Number of items to cache
* - $aOptions['enable'] = (bool) Flag to enable caching
*/
public static function getInstance($sTable, array $aOptions = array()) {
if (!isset(self::$_oInstances[$sTable])) {
self::$_oInstances[$sTable] = new self($sTable, $aOptions);
}
return self::$_oInstances[$sTable];
}
/**
* Returns items cache list.
*
* @return array
*/
public function getItemsCache() {
return $this->_aItemsCache[$this->_iFrame];
}
/**
* Returns existing entry from cache by it's id.
*
* @param mixed $mId
* @return array|null
*/
public function getItem($mId) {
if (!$this->_bEnable) {
return null;
}
if (isset($this->_aItemsCache[$this->_iFrame][$mId])) {
return $this->_aItemsCache[$this->_iFrame][$mId];
} else {
return null;
}
}
/**
* Returns existing entry from cache by matching propery value.
*
* @param mixed $mProperty
* @param mixed $mValue
* @return array|null
*/
public function getItemByProperty($mProperty, $mValue) {
if (!$this->_bEnable) {
return null;
}
// loop thru all cached entries and try to find a entry by it's property
if (is_array($this->_aItemsCache[$this->_iFrame]) && count($this->_aItemsCache[$this->_iFrame]) > 0) {
foreach ($this->_aItemsCache[$this->_iFrame] as $id => $aEntry) {
if (isset($aEntry[$mProperty]) && $aEntry[$mProperty] == $mValue) {
return $aEntry;
}
}
}
return null;
}
/**
* Returns existing entry from cache by matching properties and their values.
*
* @param array $aProperties Assoziative key value pairs
* @return array|null
*/
public function getItemByProperties(array $aProperties) {
if (!$this->_bEnable) {
return null;
}
// loop thru all cached entries and try to find a entry by it's property
foreach ($this->_aItemsCache as $id => $aEntry) {
$mFound = null;
foreach ($aProperties as $key => $value) {
if (isset($aEntry[$key]) && $aEntry[$key] == $value) {
if (null === $mFound) {
$mFound = true;
}
} else {
$mFound = false;
break;
}
if (true === $mFound) {
return $aEntry;
}
}
}
return null;
}
/**
* Adds passed item data to internal cache
*
* @param mixed $mId
* @param array $aData Usually the recordset
* @return void
*/
public function addItem($mId, array $aData) {
if (!$this->_bEnable) {
return null;
}
if (isset($this->_aItemsCache[$this->_iFrame])) {
$aTmpItemsArray = $this->_aItemsCache[$this->_iFrame];
if ($this->_iMaxItemsToCache == count($aTmpItemsArray)) {
// we have reached the maximum number of cached items, remove first entry
$firstEntryKey = array_shift($aTmpItemsArray);
if (is_array($firstEntryKey))
return null;
unset($this->_aItemsCache[$this->_iFrame][$firstEntryKey]);
}
}
// add entry
$this->_aItemsCache[$this->_iFrame][$mId] = $aData;
}
/**
* Removes existing cache entry by it's key
*
* @param mixed $mId
* @return void
*/
public function removeItem($mId) {
if (!$this->_bEnable) {
return null;
}
// remove entry
if (isset($this->_aItemsCache[$this->_iFrame][$mId])) {
unset($this->_aItemsCache[$this->_iFrame][$mId]);
}
}
}

Datei anzeigen

@ -45,7 +45,7 @@ if ($action == "todo_save_item")
if (is_array($userassignment)) {
foreach ($userassignment as $key => $value) {
$item = $todo->create($itemtype, $itemid, strtotime($reminderdate), $subject, $message, $notiemail, $notibackend, $auth->auth["uid"]);
$item = $todo->createItem($itemtype, $itemid, strtotime($reminderdate), $subject, $message, $notiemail, $notibackend, $auth->auth["uid"]);
$item->set("recipient", $value);
$item->setProperty("todo", "enddate", $enddate);
$item->store();

Datei anzeigen

@ -82,7 +82,7 @@ class RecipientGroupCollection extends ItemCollection
$groupname = $groupname . md5(rand());
}
$item = parent::create();
$item = parent::createNewItem();
$item->set("idclient", $client);
$item->set("idlang", $lang);

Datei anzeigen

@ -74,7 +74,7 @@ class cNewsletterJobCollection extends ItemCollection
$client = Contenido_Security::toInteger($client);
$sName = Contenido_Security::escapeDB($sName, null);
$oItem = parent::create();
$oItem = parent::createNewItem();
$oItem->set("idnews", $iIDNews);
$oItem->set("idclient", $client);

Datei anzeigen

@ -84,7 +84,7 @@ class cNewsletterLogCollection extends ItemCollection
$oRecipient = new Recipient;
if ($oRecipient->loadByPrimaryKey($idnewsrcp)) {
$oItem = parent::create();
$oItem = parent::createNewItem();
$oItem->set("idnewsjob", $idnewsjob);
$oItem->set("idnewsrcp", $idnewsrcp);

Datei anzeigen

@ -80,7 +80,7 @@ class NewsletterCollection extends ItemCollection
return $this->create($sName."_".substr(md5(rand()), 0, 10));
}
$oItem = parent::create();
$oItem = parent::createNewItem();
$oItem->set("idclient", $client);
$oItem->set("idlang", $lang);
$oItem->set("name", $sName);
@ -108,7 +108,7 @@ class NewsletterCollection extends ItemCollection
$oBaseItem = new Newsletter();
$oBaseItem->loadByPrimaryKey($iItemID);
$oItem = parent::create();
$oItem = parent::createNewItem();
$oItem->set("name", $oBaseItem->get("name")."_".substr(md5(rand()), 0, 10));
$iIDArt = 0;

Datei anzeigen

@ -82,7 +82,7 @@ class RecipientCollection extends ItemCollection
if ($this->next()) {
return $this->create($sEMail."_".substr(md5(rand()),0,10), $sName, 0, $sJoinID, $iMessageType); // 0: Deactivate 'confirmed'
}
$oItem = parent::create();
$oItem = parent::createNewItem();
$oItem->set("idclient", $client);
$oItem->set("idlang", $lang);
$oItem->set("name", $sName);

Datei anzeigen

@ -66,7 +66,7 @@ class Workflows extends ItemCollection {
function create ()
{
global $auth, $client, $lang;
$newitem = parent::create();
$newitem = parent::createNewItem();
$newitem->setField("created", date("Y-m-d H-i-s"));
$newitem->setField("idauthor", $auth->auth["uid"]);
$newitem->setField("idclient", $client);

Datei anzeigen

@ -87,7 +87,7 @@ class WorkflowActions extends ItemCollection {
$this->select("idworkflowitem = '".Contenido_Security::escapeDB($idworkflowitem, NULL)."' AND action = '".Contenido_Security::escapeDB($action, NULL)."'");
if (!$this->next())
{
$newitem = parent::create();
$newitem = parent::createNewItem();
$newitem->setField("idworkflowitem",$idworkflowitem);
$newitem->setField("action",$action);
$newitem->store();

Datei anzeigen

@ -126,7 +126,7 @@ class WorkflowAllocations extends ItemCollection {
$this->lasterror = i18n("Workflow doesn't exist", "workflow");
return false;
}
$newitem = parent::create();
$newitem = parent::createNewItem();
if (!$newitem->setWorkflow($idworkflow))
{
$this->lasterror = $newitem->lasterror;

Datei anzeigen

@ -81,7 +81,7 @@ class WorkflowArtAllocations extends ItemCollection {
return false;
}
$newitem = parent::create();
$newitem = parent::createNewItem();
$newitem->setField("idartlang",$idartlang);
$newitem->store();

Datei anzeigen

@ -181,7 +181,7 @@ class WorkflowItems extends ItemCollection {
$lastPos = $item->getField("position") + 1;
}
$newItem = parent::create();
$newItem = parent::createNewItem();
if ($newItem->init($idworkflow, $lastPos) === false)
{
$this->delete($newItem->getField("idworkflowitem"));
@ -278,7 +278,7 @@ class WorkflowItem extends Item {
}
}
parent::setField($field, $value);
parent::setField($field, $value, $bSafe);
}
/**

Datei anzeigen

@ -60,7 +60,7 @@ class WorkflowTasks extends ItemCollection {
function create ()
{
$newitem = parent::create();
$newitem = parent::createNewItem();
return ($newitem);
}

Datei anzeigen

@ -103,7 +103,7 @@ class WorkflowUserSequences extends ItemCollection {
function create ($idworkflowitem)
{
global $auth, $client, $idworkflow;
$newitem = parent::create();
$newitem = parent::createNewItem();
$workflowitems = new WorkflowItems;
if (!$workflowitems->exists($idworkflowitem))
@ -198,7 +198,7 @@ class WorkflowUserSequence extends Item {
* @param string $field Field to set
* @param string $valie Value to set
*/
function setField($field, $value)
function setField($field, $value, $bSafe = true)
{
global $cfg;
@ -235,7 +235,7 @@ class WorkflowUserSequence extends Item {
}
parent::setField($field, $value);
parent::setField($field, $value, $bSafe);
if ($idusersquence) {
WorkflowUserSequences::updateArtAllocation(0);
}

Datei anzeigen

@ -1,5 +1,4 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 fdm=marker:
// +----------------------------------------------------------------------+
// | PHP Version 4 |
@ -97,6 +96,7 @@ class XML_RSS extends XML_Parser2 {
* @var array
*/
var $imageTags = array('TITLE', 'URL', 'LINK');
var $textinputTags = array('TITLE', 'DESCRIPTION', 'NAME', 'LINK');
/**