Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
Workflow_Manager Class Reference
Inheritance diagram for Workflow_Manager:
MySource_Object

Public Member Functions

 Workflow_Manager ()
 
 allowsWorkflow ($assetid)
 
 getSchemas ($assetid, $granted=NULL, $running=FALSE, $cascades=NULL)
 
 getAssetSchemaInfo ($assetid, $schemaid=NULL, $cascades=NULL, $include_cascades=TRUE, $include_last_started_by=FALSE)
 
 setSchema ($assetid, $schemaid, $granted, $cascades=TRUE, $force_set=FALSE)
 
 deleteSchema ($assetid, $schemaid, $running=TRUE)
 
 getSchemaWorkflows ($assetid, $schemaid='all')
 
 setWorkflow ($assetid, $workflow)
 
 whoCanPublish ($assetid, $schemaid=NULL, $group=FALSE)
 
 notifyOnLive ($assetid, $old_status)
 
 requiresComment ($assetid, $userid)
 
 _whoCanPublishWorkflow ($assetid, $schemaid)
 
 _loadCurrentStep (&$workflow)
 
 recordPublish ($assetid, $publisher)
 
 testPublish ($assetid, $publisher, $stream_name='')
 
 _recordPublish (&$workflow, $publisherid, $assetid)
 
 generateWorkflowArray ($assetid, $streamid)
 
 startWorkflow ($assetid, $auto_approve=TRUE, $base_msg=NULL, $stream_name=NULL)
 
 isWorkflowComplete ($assetid)
 
 getWorkflowCurrentSteps ($assetid)
 
 cancelWorkflow ($assetid, $base_msg=NULL)
 
 completeWorkflow ($assetid)
 
 _clearWorkflow ($assetid)
 
 purgeWorkflow ($assetid)
 
 silentWorkflowParty ($assetid)
 
 escalateWorkflow ($assetid, $schemaid)
 
getCurrentStepArray (&$workflow, $current_step=NULL)
 
getCurrentStep (&$workflow, $current_step=NULL)
 
 getStreams ($schemaid, $ignore_default=FALSE)
 
 getBypassableStreams ($assetid, $schemaid, $current_userid=NULL)
 
 getDefaultStream ($schemaids)
 
 getStreamByName ($schemaids, $stream_name)
 
 setStartingStream ($assetid, $stream_name)
 
 getStartingStream ($assetid)
 
 addMessageReplacements ($asset, $subject, $body, &$replacements)
 
 setCurrentUserAsLastStarted ($userid, $assetid)
 
- Public Member Functions inherited from MySource_Object
 MySource_Object ()
 
 __sleep ()
 
 __wakeup ()
 

Data Fields

 $_valid_logic_with_right_operand = Array('>=')
 
 $_valid_step_logic = Array('>=' => 'At least', 'all' => 'All')
 
 $_valid_cond_logic = Array('>=' => 'At least', 'all' => 'All')
 
- Data Fields inherited from MySource_Object
 $_tmp
 

Detailed Description

Definition at line 31 of file workflow_manager.inc.

Member Function Documentation

_clearWorkflow (   $assetid)

Clears all generated workflow arrays from the workflow table for the passed assetID

Parameters
int$assetidthe ID of the asset to clear workflow for
Returns
boolean public

Definition at line 2083 of file workflow_manager.inc.

_loadCurrentStep ( $workflow)

Goes through the passed workflow array and sets what step we are up to

Parameters
array&$workflowthe workflow we are working out the current step for
Returns
void private

Definition at line 872 of file workflow_manager.inc.

_recordPublish ( $workflow,
  $publisherid,
  $assetid 
)

Changes the passed workflow to indicate that a user has approved the asset

Returns TRUE if the publisher was able to publish and thus that the passed workflow has actually changed - FALSE otherwise. This code is abstracted from RecordPublish so it can be used by testPublish

Parameters
array&$workflowthe workflow add approval to
int$publisheridthe ID of the user who has approved
int$assetidthe ID of the asset being published
Returns
boolean public

Definition at line 1464 of file workflow_manager.inc.

_whoCanPublishWorkflow (   $assetid,
  $schemaid 
)

Returns an array of all users who can publish the running workflow for the passed schemaID

The publishers are based on the current step in the workflow so the users returned are only users who will affect the workflow at this point

Parameters
int$assetidthe ID of the asset to get publishers for
int$schemaidthe id of the schema to find publishers for
Returns
array private

Definition at line 781 of file workflow_manager.inc.

addMessageReplacements (   $asset,
  $subject,
  $body,
$replacements 
)

Add keyword values for the given $asset to the $replacements array by extracting any extra keywords found in the $subject and $body.

Parameters
object$assetThe asset in workflow to get keyword replacements from
string$subjectThe message subject
string$bodyThe message body
array$replacementsThe keywords and their replacement values
Returns
void

Definition at line 2776 of file workflow_manager.inc.

allowsWorkflow (   $assetid)

Check if workflow can be set on an asset

Parameters
string$assetidthe ID of the asset to check
Returns
boolean public

Definition at line 74 of file workflow_manager.inc.

cancelWorkflow (   $assetid,
  $base_msg = NULL 
)

Cancel the currently running workflows for the passed asset

Parameters
int$assetidthe ID of the asset to cancel workflow for
object$msgan internal message to be sent instead of the default
Returns
boolean public

Definition at line 1901 of file workflow_manager.inc.

completeWorkflow (   $assetid)

Completes the workflow by clearing out all the running workflows from the DB

Parameters
int$assetidthe ID of the asset to complete workflow for
Returns
boolean public

Definition at line 2061 of file workflow_manager.inc.

deleteSchema (   $assetid,
  $schemaid,
  $running = TRUE 
)

Remove a set schema from an asset

Parameters
int$assetidthe ID of the asset to delete the schema from
int$schemaidthe ID of the schema to delete
boolean$runningwhether to check if the asset has running schemas
Returns
boolean public

Definition at line 341 of file workflow_manager.inc.

escalateWorkflow (   $assetid,
  $schemaid 
)

Escalates workflow

If there are escalation steps, move to them. If not, move to sibling.

Parameters
int$assetidthe ID of the asset who's workflow is being escalated
int$schemaidThe ID of the schema being escalated
Returns
boolean public

Definition at line 2178 of file workflow_manager.inc.

generateWorkflowArray (   $assetid,
  $streamid 
)

Generate an array representing the workflow structure for a STREAM at this point in time

The generated array is a snap shot of the schema at a point in time that can get written to the database and used for publishing etc.

Parameters
int$assetidthe ID of the asset to generate the file for
int$streamidthe ID of the stream
Returns
boolean public

Definition at line 1567 of file workflow_manager.inc.

getAssetSchemaInfo (   $assetid,
  $schemaid = NULL,
  $cascades = NULL,
  $include_cascades = TRUE,
  $include_last_started_by = FALSE 
)

Get list of schemas for a certain asset, optionally filtered by cascading setting

This is primarily used for showing settings on the Metadata Schemas screen.

Parameters
int$assetidthe ID of the asset
int$schemaidthe ID of the schema
boolean$cascadeslimit to cascades setting : null = all, true = on, false = off
boolean$include_cascadesinclude schema cascades info
boolean$include_last_started_byinclude schema last_started_by info
Returns
multitype:

Definition at line 169 of file workflow_manager.inc.

getBypassableStreams (   $assetid,
  $schemaid,
  $current_userid = NULL 
)

Get a list of stream IDs that could bypass workflow for the passed asset and user

Parameters
string$assetidID of the asset being tested
string$schemaidID of the schema whose streams are being tested
string$current_useridTest with this user, or NULL for current user

Definition at line 2613 of file workflow_manager.inc.

& getCurrentStep ( $workflow,
  $current_step = NULL 
)

Returns a reference to the current or specified step

Parameters
array&$workflowthe workflow we are searching in
array$current_stepthe address of the desired step
Returns
array public

Definition at line 2560 of file workflow_manager.inc.

& getCurrentStepArray ( $workflow,
  $current_step = NULL 
)

Returns an array of workflow steps containing the current or specified step and it's siblings

Parameters
array&$workflowthe workflow we are searching in
array$current_stepthe address of the desired step
Returns
array public

Definition at line 2534 of file workflow_manager.inc.

getDefaultStream (   $schemaids)

Returns the default stream for a certain schema or set of schemas

If sent an array of schema IDs, the return value will be an array of (schema ID => stream ID). If a single schema ID, the return will be a scalar asset ID (string) value.

Parameters
mixedarray|string $schemaids Schema ID(s) to search
Returns
mixed array|string

Definition at line 2644 of file workflow_manager.inc.

getSchemas (   $assetid,
  $granted = NULL,
  $running = FALSE,
  $cascades = NULL 
)

Get an array of schemaIDs for all schemas applied and denied on an asset Can also optionally get running workflows only.

Return value: Array( schemaid => granted[1|0] ) if $granted is null OR array(schemaid) if it is set

Parameters
int$assetidthe ID of the asset to get schemas for
boolean$grantedtype of access : null = all, true = applied, false = denied
boolean$runningonly getting running workflows
Returns
array public

Definition at line 96 of file workflow_manager.inc.

getSchemaWorkflows (   $assetid,
  $schemaid = 'all' 
)

Get the workflow values set for an asset on a particular schema or all schemas

Return value: Array( schemaid => workflow_array )

Parameters
int$assetidthe ID of the asset to get workflow for
int$schemaidthe ID of the schema to get workflow for ('all' or omit for all workflows)
Returns
array public
See Also
Asset::useSystemVersion()

Definition at line 400 of file workflow_manager.inc.

getStartingStream (   $assetid)

Return a set starting stream name

Parameters
string$schemaidThe asset to get the starting stream name for
Returns
string

Definition at line 2757 of file workflow_manager.inc.

getStreamByName (   $schemaids,
  $stream_name 
)

Returns the list of streams matching a defined stream name

If a stream name does not exist for a passed schema, it will use the default stream for these.

If sent an array of schema IDs, the return value will be an array of (schema ID => stream ID). If a single schema ID, the return will be a scalar asset ID (string) value.

Parameters
mixedarray|string $schemaids Schema ID(s) to search
string$stream_nameStream name to search for
Returns
mixed array|string

Definition at line 2686 of file workflow_manager.inc.

getStreams (   $schemaid,
  $ignore_default = FALSE 
)

Returns a list of streams attached to a certain schema

Returned array is in format (streamid => stream name)

Parameters
string$schemaidSchema ID to search
boolean$ignore_defaultTRUE = ignore the default stream: only alternate streams are returned
Returns
array

Definition at line 2583 of file workflow_manager.inc.

getWorkflowCurrentSteps (   $assetid)

Get the currently running steps of the workflow array, keyed by schema ID

Parameters
int$assetidthe ID of the asset to check workflow completness for
Returns
array public

Definition at line 1873 of file workflow_manager.inc.

isWorkflowComplete (   $assetid)

Starts workflow by writing out all workflow arrays to the workflow table for the passed assetID

Parameters
int$assetidthe ID of the asset to check workflow completness for
Returns
boolean public

Definition at line 1848 of file workflow_manager.inc.

notifyOnLive (   $assetid,
  $old_status 
)

Notifies people in the workflow that want to know when the asset goes live

Parameters
int$assetidthe ID of the asset that has gone live
int$old_statusthe status the asset is changing from
Returns
boolean public

Definition at line 580 of file workflow_manager.inc.

purgeWorkflow (   $assetid)

Deletes any workflow entries that this asset has

Parameters
string$assetidthe asset id
Returns
boolean public

Definition at line 2122 of file workflow_manager.inc.

recordPublish (   $assetid,
  $publisher 
)

Changes the running workflows for an asset to indicate that a user has approved the asset

Parameters
int$assetidthe ID of the asset to set the approval for
int$publisherthe ID of the user who has approved
Returns
boolean public

Definition at line 1034 of file workflow_manager.inc.

requiresComment (   $assetid,
  $userid 
)

Determines whether commenting is mandatory for a particular user

Parameters
string$assetidthe ID of the asset to check
string$useridthe ID of the user to check
Returns
boolean public

Definition at line 704 of file workflow_manager.inc.

setCurrentUserAsLastStarted (   $userid,
  $assetid 
)

When the user is directly approving the asset changes without having to initiate the workflow, we need to set this user id as the value for 'last_started_by' col in the sq_ast_wflow table to prevent the issue cause in Bug #5871 Matrix emailing the workflow initiator from previous workflow process when asset pushed to Live.

Parameters
string$useriduserid to set 'last_started_by' col value in db
string$assetidid of the asset we are changing the status
Returns
void

Definition at line 2809 of file workflow_manager.inc.

setSchema (   $assetid,
  $schemaid,
  $granted,
  $cascades = TRUE,
  $force_set = FALSE 
)

Apply a schema to or Deny from, an asset

Parameters
int$assetidthe ID of the asset to set the schema on
int$schemaidthe ID of the schema to set
boolean$grantedis this schema applied (TRUE) or denied (FALSE)?
boolean$force_setif true, existing workflow schemas will be updated regardless of whether or not the new workflow schemas are found to conflict with them
Returns
boolean public

Definition at line 235 of file workflow_manager.inc.

setStartingStream (   $assetid,
  $stream_name 
)

Set an stream to use when starting the workflow for a certain asset

This is to get around coupling issues - since the POST var handling should be at the Details static screen level, but the starting of workflow happens at status change level - and there is no way to pass extra data to a status change.

It is intended to be called immediately before starting workflow. This only has effect for the request, and is cleared when workflow is actually started.

It can still be overridden by sending a stream ID to startWorkflow().

If streamid is NULL, the set stream will be cleared, and the default stream will be used instead.

Parameters
string$assetidThe asset to set a starting stream for
string$stream_nameThe stream to set as "active". NULL to clear.
Returns
void

Definition at line 2743 of file workflow_manager.inc.

setWorkflow (   $assetid,
  $workflow 
)

Set workflow values for an asset

Parameters
int$assetidthe ID of the asset to set the values for
array$workflowthe values to set
Returns
boolean public

Definition at line 470 of file workflow_manager.inc.

silentWorkflowParty (   $assetid)

Check if the passed assetid is a silent party in the worflow process

For example, when pulling a standard page through workflow, the bodycopy is a silent party because it cannot be shared and so has the same admins as the standard page. However, any tables can be shared and so they are not silent parties.

Parameters
int$assetidthe ID of the asset to check
Returns
boolean public

Definition at line 2157 of file workflow_manager.inc.

startWorkflow (   $assetid,
  $auto_approve = TRUE,
  $base_msg = NULL,
  $stream_name = NULL 
)

Starts workflow by writing out all workflow arrays to the workflow table for the passed assetID

Parameters
int$assetidthe ID of the asset to start workflow for
boolean$auto_approveregister that the current user has approed the workflow once it has been started
object$msgan internal message to be sent instead of the default
Returns
boolean public

Definition at line 1613 of file workflow_manager.inc.

testPublish (   $assetid,
  $publisher,
  $stream_name = '' 
)

Pretend this user has approved the workflow to see if the workflow process will be completed

Use this to find out if the user is allowed to live edit.

If workflow has not started, it will test whether a user can approve a workflow simply by starting it. In this case, usually workflow can be bypassed completely (notwithstanding other roadblocks, such as incomplete metadata).

If a workflow schema contains multiple streams, it can test either a single stream or ALL of them (again, presuming workflow has not started). By default, it will test the default stream. If all streams are tested, it will only return TRUE if ALL of them are able to be completed.

Parameters
int$assetidthe ID of the asset to set the approval for
int$publisherthe ID of the user who we are testing approval for
string$stream_namethe name of the stream to test. NULL to test ALL streams. '' to test default stream. Only applicable when workflow has not started.
Returns
boolean public

Definition at line 1369 of file workflow_manager.inc.

whoCanPublish (   $assetid,
  $schemaid = NULL,
  $group = FALSE 
)

Returns an array of all users who can publish one of the running workflows

The publishers are based on the current step in the workflow so the users returned are only users who will affect the workflow at this point.

Parameters
int$assetidthe ID of the asset to get publishers for
int$schemaidthe schema to get publishers for
boolean$groupgroup the return value by workflowid
Returns
array public

Definition at line 543 of file workflow_manager.inc.

Constructor

Definition at line 60 of file workflow_manager.inc.


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