contenido\classes\class.inuse.php
Description: Contenido In-Use classes
Requirements:
- Author
- Timo A. Hummel
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- Contenido Backend classes
- Since
- file available since contenido release <= 4.6 {@internal created 2003-07-18 modified 2008-06-30, Dominik Ziegler, add security fix $Id: class.inuse.php 421 2008-06-30 13:39:59Z dominik.ziegler $: }}
- Version
- 1.0.8
\InUseCollection
- Parent(s)
- \ItemCollection
- Author
- Timo A. Hummel
- Copyright
- four for business 2003
- Version
- 0.1
Properties

array $_forwardJoinPartnersForward join partners for this data object
- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_forwardJoinPartners

array $_groupConditions- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_groupConditions

array $_innerGroupConditions = array()array()Details- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_innerGroupConditions

array $_resultFields = array()array()Details- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_resultFields

array $_whereRestriction- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_whereRestriction

string $table- Type
- string
- Access
- private
- Inherited_from
- \ItemCollection::$$table
Methods

ItemCollection(string $table, $primaryKey, $lifetime = 10) : voidConstructor Function Note: Default lifetime is 10 seconds.
Inherited from: \ItemCollection::ItemCollection()| Name | Type | Description |
|---|---|---|
| $table | string | The table to use as information source |
| $primaryKey | ||
| $lifetime |

_buildGroupWhereStatements() : arrayBuilds a where statement out of the setGroupWhere calls
| Type | Description |
|---|---|
| array | with all where statements |

_buildWhereStatements() : arrayBuilds a where statement out of the setWhere calls
| Type | Description |
|---|---|
| array | with all where statements |

_fetchJoinTables(\none $ignore_root) : arrayFetches all tables which will be joined later on.
The returned array has the following format:
array( array(fields), array(tables), array(joins), array(wheres) );
Notes: The table is the table name which needs to be added to the FROM clause The join statement which is inserted after the master table The where statement is combined with all other where statements The fields to select from
| Name | Type | Description |
|---|---|---|
| $ignore_root | \none |
| Type | Description |
|---|---|
| array | see above |

_findReverseJoinPartner( $parentclass, $classname) : void| Name | Type | Description |
|---|---|---|
| $parentclass | ||
| $classname |

_initializeDriver( $bForceInit = false) : void_initializeDriver: Initializes the driver to use with GenericDB.
Inherited from: \ItemCollection::_initializeDriver()| Name | Type | Description |
|---|---|---|
| $bForceInit | boolean If true, forces the driver to initialize, even if it already exists. |

_recursiveStructuredFetch( $objects, $array) : void| Name | Type | Description |
|---|---|---|
| $objects | ||
| $array |

_setItemClass(string $classname) : \none_setItemClass: private method to set the accompanying item object.
Inherited from: \ItemCollection::_setItemClass()| Name | Type | Description |
|---|---|---|
| $classname | string | specifies the classname |
| Type | Description |
|---|---|
| \none |

_setJoinPartner(string $foreignCollectionClass) : \none_setJoinPartner: Defines the reverse links for this table.
Inherited from: \ItemCollection::_setJoinPartner()Important: The class specified by $foreignCollectionClass needs to be a collection class and has to exist Define all links in the constructor of your object
| Name | Type | Description |
|---|---|---|
| $foreignCollectionClass | string | Specifies the foreign class to use |
| Type | Description |
|---|---|
| \none |

addResultField( $field) : void| Name | Type | Description |
|---|---|---|
| $field |

checkAndMark( $type, $objectid, $returnWarning = false, $warningTemplate = "", $allowOverride = false, $location = "") : mixedChecks and marks if not marked.
Example: Check for "idmod", also return a lock message: list($inUse, $message) = $col->checkAndMark("idmod", $idmod, true, i18n("Module is in use by %s (%s)"));
Example 2: Check for "idmod", don't return a lock message $inUse = $col->checkAndMark("idmod", $idmod);
| Name | Type | Description |
|---|---|---|
| $type | string Specifies the type to de-mark. | |
| $objectid | mixed Specifies the object ID | |
| $returnWarning | boolean If true, also returns an error message if in use | |
| $warningTemplate | string String to fill with the template (%s as placeholder, first %s is the username, second is the real name) | |
| $allowOverride | boolean True if the user can override the lock | |
| $location | string Value to append to the override lock button |
| Type | Description |
|---|---|
| mixed | If returnWarning is false, returns a boolean value wether the object is locked. If returnWarning is true, returns a 2 item array (boolean inUse, string errormessage). |

checkMark( $type, $objectid) : intChecks if a specific item is marked
| Name | Type | Description |
|---|---|---|
| $type | string Specifies the type to de-mark. | |
| $objectid | mixed Specifies the object ID |
| Type | Description |
|---|---|
| int | Returns false if it's not in use or returns the object if it is. |

create() : voidcreate() Creates a new item in the table and loads it afterwards.
Inherited from: \ItemCollection::create()
deleteWhere( $field, $restriction, $operator = "=") : voiddeleteWhere ($field, $restriction, $operator)
Inherited from: \ItemCollection::deleteWhere()Restricts a query with a where clause
| Name | Type | Description |
|---|---|---|
| $field | ||
| $restriction | ||
| $operator |

deleteWhereGroup( $group, $field, $restriction, $operator = "=") : voiddeleteWhereGroup ($group, $field, $restriction, $operator)
Inherited from: \ItemCollection::deleteWhereGroup()Restricts a query with a where clause, groupable
| Name | Type | Description |
|---|---|---|
| $group | ||
| $field | ||
| $restriction | ||
| $operator |

exists(integer $id) : boolean| Name | Type | Description |
|---|---|---|
| $id | integer | The id to check for |
| Type | Description |
|---|---|
| boolean | true if object exists, false if not |

fetchArray( $key, $fields) : arrayfetchArray() Fetches an array of fields from the database.
Inherited from: \ItemCollection::fetchArray()Example: $i = $object->fetchArray("idartlang", array("idlang", "name"));
could result in: $i[5] = array("idlang" => 5, "name" => "My Article");
Important: If you don't pass an array for fields, the function doesn't create an array.
| Name | Type | Description |
|---|---|---|
| $key | string Name of the field to use for the key | |
| $fields | mixed String or array |
| Type | Description |
|---|---|
| array | Resulting array |

fetchObject( $class) : void| Name | Type | Description |
|---|---|---|
| $class |

fetchTable( $fields = array(), $objects = array()) : void| Name | Type | Description |
|---|---|---|
| $fields | ||
| $objects |

flexSelect(string $distinct = "", string $from = "", string $where = "", string $group_by = "", string $order_by = "", string $limit = "") : arrayflexSelect ($distinct = "", $from = "", $where = "", $group_by = "", $order_by = "", $limit = "") Selects all entries from the database and returns them as DBObject-objects to the user.
Inherited from: \ItemCollection::flexSelect()Objects are loaded using their primary key.
| Name | Type | Description |
|---|---|---|
| $distinct | string | Specifies if distinct will be added to the SQL statement ($distinct !== "" -> DISTINCT) |
| $from | string | Specifies the additional from clause (e.g. "con_news_groups AS groups, con_news_groupmembers AS groupmembers"). |
| $where | string | Specifies the where clause. |
| $group_by | string | Specifies the group by clause. |
| $order_by | string | Specifies the order by clause. |
| $limit | string | Specifies the limit by clause. |
| Type | Description |
|---|---|
| array | Array of DBObject-Objects |
- Author
- HerrB

link( $foreignClass) : voidsets the query to use foreign tables in the resultset
Inherited from: \ItemCollection::link()| Name | Type | Description |
|---|---|---|
| $foreignClass |

loadItem( $vitem) : objectloadItem ($item) Loads a single object from the database.
Inherited from: \ItemCollection::loadItem()Needs to be overridden by the extension class.
| Name | Type | Description |
|---|---|---|
| $vitem |
| Type | Description |
|---|---|
| object | The newly created object |

markInUse( $type, $objectid, $session, $user) : voidMarks a specific object as "in use".
Note that items are released when the session is destroyed.
Currently, the following types are defined and approved as internal Contenido standard: article module layout template
| Name | Type | Description |
|---|---|---|
| $type | string Specifies the type to mark. | |
| $objectid | mixed Specifies the object ID | |
| $session | string Specifies the session for which the "in use" mark is valid | |
| $user | string Specifies the user which requested the in-use flag |

queryAndFetchStructured(\objects $objects) : arrayfetchStructured Returns an array of arrays
Inherited from: \ItemCollection::queryAndFetchStructured()| Name | Type | Description |
|---|---|---|
| $objects | \objects | array with the correct order of the objects |
| Type | Description |
|---|---|
| array | result |

removeItemMarks( $type, $itemid) : voidRemoves the mark for a specific item
| Name | Type | Description |
|---|---|---|
| $type | string Specifies the type to de-mark. | |
| $itemid | string Specifies the item |

removeMark( $type, $objectid, $session) : voidRemoves the "in use" mark from a specific object.
| Name | Type | Description |
|---|---|---|
| $type | string Specifies the type to de-mark. | |
| $objectid | mixed Specifies the object ID | |
| $session | string Specifies the session for which the "in use" mark is valid |

removeResultField( $field) : void| Name | Type | Description |
|---|---|---|
| $field |

removeSessionMarks( $session) : voidRemoves all in-use marks for a specific session.
| Name | Type | Description |
|---|---|---|
| $session | string Specifies the session for which the "in use" marks should be removed |

removeTypeMarks( $type, $session) : voidRemoves all marks for a specific type and session
| Name | Type | Description |
|---|---|---|
| $type | string Specifies the type to de-mark. | |
| $session | string Specifies the session for which the "in use" mark is valid |

select(string $where = "", string $group_by = "", string $order_by = "", string $limit = "") : arrayselect ($where = "", $group_by = "", $order_by = "", $limit = "") Selects all entries from the database and returns them as DBObject-objects to the user.
Inherited from: \ItemCollection::select()Objects are loaded using their primary key.
| Name | Type | Description |
|---|---|---|
| $where | string | Specifies the where clause. |
| $group_by | string | Specifies the group by clause. |
| $order_by | string | Specifies the order by clause. |
| $limit | string | Specifies the limit by clause. |
| Type | Description |
|---|---|
| array | Array of DBObject-Objects |

setEncoding( $sEncoding) : void| Name | Type | Description |
|---|---|---|
| $sEncoding |

setGroupCondition( $group1, $group2, $condition = "AND") : voidsetGroupCondition ($group1, $group2, $condition)
Inherited from: \ItemCollection::setGroupCondition()Defines how groups are linked to each other
| Name | Type | Description |
|---|---|---|
| $group1 | ||
| $group2 | ||
| $condition |

setInnerGroupCondition( $group, $condition = "AND") : voidsetInnerGroupCondition ($group, $condition)
Inherited from: \ItemCollection::setInnerGroupCondition()Defines how relations in one group are linked each together
| Name | Type | Description |
|---|---|---|
| $group | ||
| $condition |

setLimit( $iRowStart, $iRowCount) : void| Name | Type | Description |
|---|---|---|
| $iRowStart | ||
| $iRowCount |

setOrder( $order) : void| Name | Type | Description |
|---|---|---|
| $order |

setWhere( $field, $restriction, $operator = "=") : voidRestricts a query with a where clause
| Name | Type | Description |
|---|---|---|
| $field | ||
| $restriction | ||
| $operator |

setWhereGroup( $group, $field, $restriction, $operator = "=") : voidsetWhereGroup ($group, $field, $restriction, $operator)
Inherited from: \ItemCollection::setWhereGroup()Restricts a query with a where clause, groupable
| Name | Type | Description |
|---|---|---|
| $group | ||
| $field | ||
| $restriction | ||
| $operator |
\InUseItem
- Parent(s)
- \Item
- Author
- Timo A. Hummel
- Copyright
- four for business 2003
- Version
- 0.1
Properties

array $_arrInFilters = array('urlencode', 'conHtmlSpecialChars', 'addslashes')array('urlencode', 'conHtmlSpecialChars', 'addslashes')Details- Type
- array
- Access
- private
- Inherited_from
- \Item::$$_arrInFilters

array $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode')array('stripslashes', 'htmldecode', 'urldecode')Details- Type
- array
- Access
- private
- Inherited_from
- \Item::$$_arrOutFilters

$_metaObject- Type
- n/a
- Inherited_from
- \Item::$$_metaObject

string $oldPrimaryKey- Type
- string
- Access
- private
- Inherited_from
- \Item::$$oldPrimaryKey

array $values- Type
- array
- Access
- private
- Inherited_from
- \Item::$$values

boolean $virginIf true, the object is virgin and no operations on it except load-Functions are allowed.
- Type
- boolean
- Access
- private
- Inherited_from
- \Item::$$virgin
Methods

Item(string $table = "", string $primaryKey = "", $lifetime = 10) : void| Name | Type | Description |
|---|---|---|
| $table | string | The table to use as information source |
| $primaryKey | string | The primary key to use |
| $lifetime |

_inFilter(mixed $data) : mixedFilters the passed data using the functions defines in the _arrInFilters array.
Inherited from: \Item::_inFilter()| Name | Type | Description |
|---|---|---|
| $data | mixed | Data to filter |
| Type | Description |
|---|---|
| mixed | Filtered data |
- Access
- private
- See
- \setFilters

_onLoad() : \noneFunction which is called whenever an item is loaded. Inherited classes should override this function if desired.
| Type | Description |
|---|---|
| \none |

_outFilter(mixed $data) : mixedFilters the passed data using the functions defines in the _arrOutFilters array.
Inherited from: \Item::_outFilter()| Name | Type | Description |
|---|---|---|
| $data | mixed | Data to filter |
| Type | Description |
|---|---|
| mixed | Filtered data |
- Access
- private
- See
- \setFilters

_setMetaObject( $objectname) : void| Name | Type | Description |
|---|---|---|
| $objectname |

deleteProperty(string $type, string $name) : voiddeleteProperty ($type, $name) Deletes a custom property
Inherited from: \Item::deleteProperty()| Name | Type | Description |
|---|---|---|
| $type | string | Specifies the type |
| $name | string | Specifies the name |

get(string $field) : mixed| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to retrieve |
| Type | Description |
|---|---|
| mixed | Value of the field |

getField(string $field) : mixed| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to retrieve |
| Type | Description |
|---|---|
| mixed | Value of the field |

getProperty(string $type, string $name) : boolean| Name | Type | Description |
|---|---|---|
| $type | string | Specifies the type |
| $name | string | Specifies the name |
| Type | Description |
|---|---|
| boolean | Value of the given property |

loadBy(string $field, string $value, bool $bSafe = true) : boolloadBy ($field, $value) Loads an item by colum/field from the database
Inherited from: \Item::loadBy()| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field |
| $value | string | Specifies the value |
| $bSafe | bool | use inFilter or not |
| Type | Description |
|---|---|
| bool | True if the load was successful |

loadByPrimaryKey(string $value) : boolloadByPrimaryKey ($value) Loads an item by ID from the database
Inherited from: \Item::loadByPrimaryKey()| Name | Type | Description |
|---|---|---|
| $value | string | Specifies the primary key value |
| Type | Description |
|---|---|
| bool | True if the load was successful |

set(string $field, string $value, $safe = true) : void| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to set |
| $value | string | Specifies the value to set |
| $safe |

setField(string $field, string $value, boolean $safe = true) : voidsetField($field, $value) Sets the value of a specific field
Inherited from: \Item::setField()| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to set |
| $value | string | Specifies the value to set |
| $safe | boolean | Speficies if we should translate characters |

setFilters(array $arrInFilters = array(), array $arrOutFilters = array()) : voidDefine the filter functions used when data is being stored or retrieved from the database.
Inherited from: \Item::setFilters()Examples:
$obj->setFilters(array('addslashes'), array('stripslashes')); $obj->setFilters(array('htmlencode', 'addslashes'), array('stripslashes', 'htmlencode'));
| Name | Type | Description |
|---|---|---|
| $arrInFilters | array | inFilters array with function names |
| $arrOutFilters | array | outFilters array with function names |

setProperty(string $type, string $name, string $value) : voidsetProperty ($type, $name, $value) Sets a custom property
Inherited from: \Item::setProperty()| Name | Type | Description |
|---|---|---|
| $type | string | Specifies the type |
| $name | string | Specifies the name |
| $value | string | Specifies the value |