SnapVersion Class Reference
[File Objects]

Wrapper class for Snap2 versions. More...

Inheritance diagram for SnapVersion:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 approveForDev ()
 Marks a version as visible on the dev site.
 approveForLive ()
 Marks a version as visible on the live site.
 defunct ()
 Mark this version as being defunct (inactive).
 deny ()
 Return a 'Pending' version to the 'In Progress' state.
 destroy ()
 Permanently delete version.
 getAllPaths ()
 INSERT BRIEF DESCRIPTION HERE.
 getCanonicalPath ()
 Retrieves canonical path of this version.
 listActions ($constraint=array(), $limit=array(), $order=array())
 Retrieves list of actions performed on this version.
 steal ()
 Take control of an 'In Progress' version.
 submit ()
 Marks a version as 'Pending'.
 update ($newCM)
 Updates the content of a version.

Static Public Member Functions

static lookup ($path)
 Retrieve version by path.
static retrieve ($id)
 Retrieves version by ID.

Public Attributes

const STATUS_DEFUNCT
 Version is in 'Defunct' state (zombie).
const STATUS_DEV
 Version is in 'Dev' state (visible on dev site).
const STATUS_LIVE
 Version is in 'Live' state (visible on live site).
const STATUS_PENDING
 Version is in 'Pending' state (ready to be approved for dev or live).
const STATUS_PRIVATE
 Version is in 'In Progress' state (can be edited).

Static Public Attributes

static $ATTRIBUTES
static $STAT_NAMES
static $STAT_VALUES


Detailed Description

Wrapper class for Snap2 versions.

A version represents a particular revision of content for a resource. A resource may contain multiple versions, but a version belongs to only one resource. A version will be in one of many states:

Most of the code in this class exists to facilitate the lifecycle described above. Versions also keep track of when these lifecycle changes occur, and a listing of those actions can be retrieved with listActions(). It is important to note that the version, not the resource, actually stores the content. A resource represents a logical piece of content, a version actually contains it.

Constants:
  • STATUS_PRIVATE: Version is in 'In Progress' state
  • STATUS_PENDING: Version is in 'Pending' state
  • STATUS_DEV: Version is in 'Dev' state (visible on dev site)
  • STATUS_LIVE: Version is in 'Live' state (visible on live site)
  • STATUS_DEFUNCT: Version is in 'Defunct' state (zombie)

Attributes:
  • id: Version ID
  • created: Date/time when version was created
  • modified: Date/time when version was last modified
  • author: User ID of user who created or last edited the version
  • status: Current state of version (one of the STATUS_* constants)
  • ordinal: Essentially, the index of the version within its resource
  • content: Raw content of version (use getContentModule() instead of querying the content directly)
  • resourceId: ID of resource to which this version belongs
  • prevVersionId: ID of version from which this version was copied, if this version was, in fact, copied

Fields:
  • resource: SnapResource object to which this version belongs
  • contentModule: SnapContent object derivative which represents the content in this version
  • prevVersion: SnapVersion object from which this version was copied, or null if there was no copy


Member Function Documentation

SnapVersion::approveForDev (  ) 

Marks a version as visible on the dev site.

The version must be in the 'Pending' state to be marked as dev. You must also have the ApproveDev permission on the version's resource, or AdminResource to approve for dev. The old dev version becomes defunct after this operation.

Returns:
[boolean]: success or failure

SnapVersion::approveForLive (  ) 

Marks a version as visible on the live site.

The version must either be in the 'Pending' state or the 'Dev' state to be approved for live. You must also have the ApproveLive permission on the version's resource, or AdminResource. The old live version is marked as defunct, and if this version was dev previously, there will no longer be a dev version for the resource.

Returns:
[boolean]: success or failure

SnapVersion::defunct (  ) 

Mark this version as being defunct (inactive).

Once a version is defuncted, it can no longer be used in any capacity, except to be copied from. To defunct a version, it must not already be defunct (for obvious reasons), and you must have the Edit permission to defunct an 'In Progress' or 'Pending' version, ApproveDev to defunct a 'Dev' version, ApproveLive to defunct a 'Live' version, or AdminResource to defunct all states. If the version was dev or live, then there will no longer be a dev or live version for the resource.

Returns:
[boolean]: success or failure

SnapVersion::deny (  ) 

Return a 'Pending' version to the 'In Progress' state.

The use case for this method is that a version may need more work before it could be considered ready for approval. In order to deny a version, the version must be in the 'Pending' state and you must have ApproveDev or ApproveLive permission on the version's resource, or AdminResource.

Returns:
[boolean]: success or failure

SnapVersion::destroy (  ) 

Permanently delete version.

When a version is destroyed, any external files associated with its content are deleted, and the version is removed from the database. This operation cannot be undone. You must have AdminResource on the version's resource to perform this operation.

Returns:
[boolean]: success or failure

SnapVersion::getAllPaths (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

SnapVersion::getCanonicalPath (  ) 

Retrieves canonical path of this version.

The canonical path of a version is just the canonical path of its resource with '@' and the version's ordinal appended. For example, '//test/foo@5'.

Returns:
[string]: canonical path of version, or false if version is invalid

SnapVersion::listActions ( constraint = array(),
limit = array(),
order = array() 
)

Retrieves list of actions performed on this version.

Actions are things like "Edit", "Submit", etc. That is, changes in state of a version. This is useful for tracking progress. This method will list those actions for just this version. The result array consists of subarrays which contain three fields: 'uid', which is the user ID of the user who performed the action; 'action', which is a string naming the action; 'actionTime', which is a MySQL timestamp of when the action occurred; and 'id', which is the ID of the version upon which the action was performed.

This method allows you to trim down the result set and sort it, mostly arbitrarily. The first parameter can be an array that specifies constraints that are converted into a WHERE clause on the database query. See [[SWAT_Model2::Simple_Entities]] for more on how to specify a constraint array. The second parameter lets you limit the number of results. As a simple number, a 'LIMIT x' is appended to the query. If an array of two numbers is given, then the first number specifies the offset to start the resultset at and the second specifies the number of records after that. The final parameter specifies how to order the results. If the elements in the array are not associative, then they are passed directly to the ORDER BY clause as is. If they are associative, then the key specifies the column and the value specifies either ASC or DESC.

Parameters:
$constraint [array]: trim down results by conditions
$limit [array]: limit number of results by count and offset
$order [array]: sort results
Returns:
[array]: array of action info arrays (see description above), or null on error

static SnapVersion::lookup ( path  )  [static]

Retrieve version by path.

Use this method to retrieve a version if you know its path. There is no other way to retrieve a version by path, so don't even try.

Parameters:
$path [string]: path to version
Returns:
[SnapVersion]: version object pointed to by path, or null on failure or invalid path

static SnapVersion::retrieve ( id  )  [static]

Retrieves version by ID.

Use this method to retrieve a version if you know its ID. Do not construct a version directly, or bad things will happen.

Parameters:
$id [integer]: ID of version to retrieve
Returns:
[SnapVersion]: version object for ID, or null on failure or invalid ID

SnapVersion::steal (  ) 

Take control of an 'In Progress' version.

Only the current author of a version can edit it. If you have Edit permission, or AdminResource on the version's resource, then you can steal the version and now you can edit it. The version must be in the 'In Progress' state to steal it.

Returns:
[boolean]: success or failure

SnapVersion::submit (  ) 

Marks a version as 'Pending'.

If a version is in the 'In Progress' state it can be marked as ready for approval (or denial) using this method. You must have the Edit permission on the version's owning resource, or AdminResource.

Returns:
[boolean]: success or failure

SnapVersion::update ( newCM  ) 

Updates the content of a version.

This method modifies the content of the version. You must pass in a content module which contains information about the new content. That content module should be created directly and then modified with an appropriate modification function (see the documentation of the relevant content module for more). Typically, you would call this method in the following fashion: $cm = new SnapContentXml($version); $cm->setXML('...some xml string...'); $version->update($cm); You must have the Edit permission on the version's resource to update the version. AdminResource and the ADMIN privilege also work. The version must also be in the 'In Progress' state to be updated.

Parameters:
$newCM [SnapContent]: content module describing new content
Returns:
[boolean]: success or failure


Member Data Documentation

SnapVersion::$ATTRIBUTES [static]

Database attributes

SnapVersion::$STAT_NAMES [static]

Array that associates status constants with friendly names, like 'In Progress'

SnapVersion::$STAT_VALUES [static]

Array that associates standard friendly names, like 'In Progress', with status constants


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

Generated on Wed Nov 24 02:03:22 2010 for Common by  doxygen 1.5.6