CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Item Class Reference

Common base class for persistent items store in database. More...

Inheritance diagram for Item:
[legend]

## Public Member Functions
| __construct ($Id)
| Constructor, used to load existing items. More...
| Destroy ()
| Destroy item. More...
| Delete ()
| Destroy item. More...
| Id ()
| Get item ID. More...
| Name ($NewValue=DB_NOVALUE)
| Get/set name of item. More...
| DateCreated ($NewValue=DB_NOVALUE)
| Get/set when item was created. More...
| CreatedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who created the item. More...
| DateLastModified ($NewValue=DB_NOVALUE)
| Get/set when item was last modified. More...
| LastModifiedBy ($NewValue=DB_NOVALUE)
| Get/set ID of user who last modified the item. More...

## Static Public Member Functions
static | GetCanonicalId ($Id)
| Normalize item ID to canonical form. More...
static | ItemExists ($Id)
| Check whether an item exists with the specified ID. More...

## Public Attributes
const | NO_ITEM = -2123456789
| ID value used to indicate no item. More...

## Protected Member Functions
| UpdateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(). More...
| UpdateDateValue ($ColumnName, $NewValue=DB_NOVALUE)
| Convenience function to supply parameters to Database::UpdateValue(), with preprocessing of new values to convert them into an SQL-compatible date format. More...

## Static Protected Member Functions
static | CreateWithValues ($Values)
| Create a new item, using specified initial database values. More...
static | SetDatabaseAccessValues ($ClassName)
| Set the database access values (table name, ID column name, name column name) for specified class. More...

## Protected Attributes
| $DB
| $Id
| $ItemIdColumnName
| $ItemNameColumnName
| $ItemTableName
| $ValueCache = array()

## Static Protected Attributes
static | $ItemIdColumnNames
static | $ItemNameColumnNames
static | $ItemTableNames

## Detailed Description

Common base class for persistent items store in database.

Definition at line 13 of file Item.php.

## Constructor & Destructor Documentation

Item::__construct | ( |  | $Id | ) |

Constructor, used to load existing items.

To create new items, child classes should implement a static Create() method.

Parameters

  mixed | $Id | ID of item to load, in a form resolvable by GetCanonicalId().

See also
  Create()
  GetCanonicalId()

Exceptions

  InvalidArgumentException | If ID is invalid.

Definition at line 30 of file Item.php.

References $Id, and Id().

## Member Function Documentation

Item::CreatedBy | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get/set ID of user who created the item.

(This method assumes there is a "CreatedBy" column in the database of type INT.)

Parameters

  int | $NewValue | New user ID.

Returns
  int ID of user who created item.

Definition at line 128 of file Item.php.

References UpdateValue().

static Item::CreateWithValues | ( |  | $Values | ) |
| staticprotected

Create a new item, using specified initial database values.

Parameters

  array | $Values | Values to set database columns to for new item, with column names for the index.

Returns
  object Newly-created item.

Definition at line 227 of file Item.php.

References $DB.

Item::DateCreated | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get/set when item was created.

(This method assumes there is a "DateCreated" column in the database of type DATETIME.)

Parameters

  string | $NewValue | New creation date.

Returns
  string Creation date in the format "YYYY-MM-DD HH:MM:SS".

Definition at line 117 of file Item.php.

References UpdateDateValue().

Item::DateLastModified | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get/set when item was last modified.

(This method assumes there is a "DateLastModified" column in the database of type DATETIME.)

Parameters

  string | $NewValue | New modification date.

Returns
  string Modification date in the format "YYYY-MM-DD HH:MM:SS".

Definition at line 139 of file Item.php.

References UpdateDateValue().

Item::Delete | ( |  | ) |

Destroy item.

Provided for backward compatibility - Destroy() should be used instead.

Deprecated:

Definition at line 72 of file Item.php.

References Destroy().

Item::Destroy | ( |  | ) |

Destroy item.

Item object should no longer be used after this call.

Definition at line 60 of file Item.php.

References Id().

Referenced by Topic\Delete(), Message\Delete(), Delete(), Forum\Delete(), and ControlledName\Delete().

Here is the caller graph for this function:

static Item::GetCanonicalId | ( |  | $Id | ) |
| static

Normalize item ID to canonical form.

Parameters

  mixed | $Id | ID to normalize.

Returns
  int Canonical ID.

Definition at line 91 of file Item.php.

References $Id.

Item::Id | ( |  | ) |

Get item ID.

Returns
  int Canonical item ID.

Definition at line 81 of file Item.php.

References $Id.

Referenced by __construct(), Forum\AddTopic(), Topic\Delete(), Forum\Delete(), ControlledName\Delete(), Destroy(), Forum\ForumId(), ControlledName\GetAssociatedResources(), Forum\GetLastMessage(), Topic\GetMessageList(), File\GetNameOfStoredFile(), Forum\GetTopicList(), ControlledName\InUse(), Message\MessageId(), ControlledName\RemapTo(), Topic\TopicId(), ControlledName\UpdateLastAssigned(), UpdateValue(), and ControlledName\VariantName().

Here is the caller graph for this function:

static Item::ItemExists | ( |  | $Id | ) |
| static

Check whether an item exists with the specified ID.

This only checks whether there is an entry for an item with the specified ID in the database – it does not check anything else (e.g. the type of the item).

Parameters

  int | $Id | ID to check.

Returns
  bool TRUE if item exists with ID, otherwise FALSE.

Definition at line 162 of file Item.php.

References $DB, and $Id.

Referenced by FormUI_Base\ConvertItemIdsToNames(), ResourceFactory\DuplicateResource(), ResourceFactory\FilterNonViewableResources(), ControlledName\Qualifier(), Classification\Qualifier(), and Resource\Set().

Here is the caller graph for this function:

Item::LastModifiedBy | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get/set ID of user who last modified the item.

(This method assumes there is a "LastModifiedBy" column in the database of type INT.)

Parameters

  int | $NewValue | New user ID.

Returns
  int ID of user who last modified item.

Definition at line 150 of file Item.php.

References UpdateValue().

Item::Name | ( |  | $NewValue = `DB_NOVALUE` | ) |

Get/set name of item.

(This method assumes that either a item name column was configured or there is a "Name" column in the database of type TEXT.)

Parameters

  string | $NewValue | New name. (OPTIONAL)

Returns
  string Current name.

Definition at line 103 of file Item.php.

References UpdateValue().

Referenced by File\CreateCopy(), File\GetLink(), and File\GetNameOfStoredFile().

Here is the caller graph for this function:

static Item::SetDatabaseAccessValues | ( |  | $ClassName | ) |
| staticprotected

Set the database access values (table name, ID column name, name column name) for specified class.

This may be overridden in a child class, if different values are needed.

Parameters

  string | $ClassName | Class to set values for.

Definition at line 267 of file Item.php.

References StdLib\Pluralize().

Item::UpdateDateValue | ( |  | $ColumnName,
|  |  | $NewValue = `DB_NOVALUE`
| ) |  |
| protected

Convenience function to supply parameters to Database::UpdateValue(), with preprocessing of new values to convert them into an SQL-compatible date format.

Parameters

  string | $ColumnName | Name of database column.
  string | $NewValue | New value for field. (OPTIONAL)

Returns
  string Return value from Database::UpdateValue().

See also
  Database::UpdateValue()

Definition at line 300 of file Item.php.

References DB_NOVALUE, and UpdateValue().

Referenced by DateCreated(), and DateLastModified().

Here is the caller graph for this function:

Item::UpdateValue | ( |  | $ColumnName,
|  |  | $NewValue = `DB_NOVALUE`
| ) |  |
| protected

Convenience function to supply parameters to Database::UpdateValue().

Parameters

  string | $ColumnName | Name of database column.
  string | $NewValue | New value for field. (OPTIONAL)

Returns
  string Return value from Database::UpdateValue().

See also
  Database::UpdateValue()

Definition at line 284 of file Item.php.

References Id().

Referenced by Message\Body(), File\Comment(), CreatedBy(), Topic\CreatorId(), Topic\DateCreated(), Message\DateEdited(), Message\DatePosted(), Message\EditorId(), ControlledName\FieldId(), File\FieldId(), Classification\FieldId(), Forum\ForumDescription(), Topic\ForumId(), Forum\ForumName(), LastModifiedBy(), Classification\LinkString(), Topic\MessageCount(), Forum\MessageCount(), Forum\ModeratorId(), Qualifier\Name(), ControlledName\Name(), Name(), Qualifier\NSpace(), Message\ParentId(), Message\ParentType(), Message\PosterId(), ControlledName\QualifierId(), Classification\QualifierId(), Classification\RecalcDepthAndFullName(), Classification\RecalcResourceCount(), File\ResourceId(), Classification\SegmentName(), Message\Subject(), Forum\TopicCount(), Topic\TopicName(), UpdateDateValue(), Qualifier\Url(), and Topic\ViewCount().

Here is the caller graph for this function:

## Member Data Documentation

Item::$DB
| protected

Definition at line 210 of file Item.php.

Referenced by Resource\Classifications(), ControlledName\ControlledNameExists(), Qualifier\Create(), Topic\Create(), Message\Create(), ControlledName\Create(), Forum\Create(), Classification\Create(), File\Create(), Resource\Create(), CreateWithValues(), Resource\Delete(), ControlledName\Delete(), Resource\GetSchemaForResource(), Resource\IsTempResource(), ItemExists(), Resource\Rating(), and Resource\Set().

Item::$Id
| protected

Definition at line 211 of file Item.php.

Referenced by __construct(), Resource\Clear(), Qualifier\Create(), Resource\Create(), GetCanonicalId(), Id(), Classification\Id(), Resource\Id(), Resource\IsTempResource(), ItemExists(), Classification\RecalcResourceCount(), and Resource\Set().

Item::$ItemIdColumnName
| protected

Definition at line 212 of file Item.php.

Item::$ItemIdColumnNames
| staticprotected

Definition at line 217 of file Item.php.

Item::$ItemNameColumnName
| protected

Definition at line 213 of file Item.php.

Item::$ItemNameColumnNames
| staticprotected

Definition at line 218 of file Item.php.

Item::$ItemTableName
| protected

Definition at line 214 of file Item.php.

Item::$ItemTableNames
| staticprotected

Definition at line 219 of file Item.php.

Item::$ValueCache = array()
| protected

Definition at line 215 of file Item.php.

const Item::NO_ITEM = -2123456789

ID value used to indicate no item.

Definition at line 19 of file Item.php.

The documentation for this class was generated from the following file:

- lib/ScoutLib/Item.php