Utility class containing functions used by most track engines.

package Gems
subpackage Tracker
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.4

 Methods

__construct()

__construct(array $trackData) 
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::__construct()

Parameters

$trackData

array

array containing track record

Integrate field loading en showing and editing

addFieldsToModel(\MUtil_Model_ModelAbstract $model, boolean $addDependency = true, $respTrackId = false) : \Gems_Tracker_Engine_TrackEngineAbstract
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::addFieldsToModel()

Parameters

$model

\MUtil_Model_ModelAbstract

$addDependency

boolean

True when editing, can be false in all other cases

$respTrackId

Optional Database column name where Respondent Track Id is set

Returns

\Gems_Tracker_Engine_TrackEngineAbstract

Called after the check that all required registry values have been set correctly has run.

afterRegistry() : void

Set menu parameters from this track engine

applyToMenuSource(\Gems_Menu_ParameterSource $source) : \Gems_Tracker_Engine_TrackEngineInterface
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::applyToMenuSource()

Parameters

$source

\Gems_Menu_ParameterSource

Returns

\Gems_Tracker_Engine_TrackEngineInterface(continuation pattern)

Calculate the track info from the fields

calculateFieldsInfo(array $data) : string
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::calculateFieldsInfo()

Parameters

$data

array

The values to save

Returns

stringThe description to save as track_info

Calculate the number of active rounds in this track from the database.

calculateRoundCount() : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::calculateRoundCount()

Returns

integerThe number of rounds in this track.

Should be called after answering the request to allow the Target to check if all required registry values have been set correctly.

checkRegistryRequestsAnswers() : boolean

Returns

booleanFalse if required are missing.

Check for the existence of all tokens and create them otherwise

checkRoundsFor(\Gems_Tracker_RespondentTrack $respTrack, integer $userId, \Gems_Task_TaskRunnerBatch $batch = null
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::checkRoundsFor()

Parameters

$respTrack

\Gems_Tracker_RespondentTrack

The respondent track to check

$userId

integer

Id of the user who takes the action (for logging)

$batch

Convert a TrackEngine instance to a TrackEngine of another type.

convertTo(\type $conversionTargetClass) 
see
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::convertTo()

Parameters

$conversionTargetClass

\type

Copy a track and all it's related data (rounds/fields etc)

copyTrack(\inte $oldTrackId) : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::copyTrack()

Parameters

$oldTrackId

\inte

The id of the track to copy

Returns

integerThe id of the copied track

Returns a list of classnames this track engine can be converted into.

getConversionTargets(array $options) : array

Should always contain at least the class itself.

see
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getConversionTargets()

Parameters

$options

array

The track engine class options available in as a "track engine class names" => "descriptions" array

Returns

arrayFilter or adaptation of $options

Returns an array of the fields in this track key / value are id / field name

getFieldNames() : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldNames()

Returns

arrayfieldid => fieldcode

Get the FieldUpdateEvent for this trackId

getFieldUpdateEvent() : \Gems_TrackFieldUpdateEventInterface
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldUpdateEvent()

Returns

\Gems_TrackFieldUpdateEventInterface| null

Returns an array of the fields in this track key / value are id / code

getFields() : array

Returns

arrayfieldid => fieldcode

Returns the field data for the respondent track id.

getFieldsData(integer $respTrackId) : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldsData()

Parameters

$respTrackId

integer

Gems respondent track id or null when new

Returns

arrayof the existing field values for this respondent track

Get the storage model for field values

getFieldsDataStorageModel() : \Gems\Tracker\Model\FieldDataModel
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldsDataStorageModel()

Returns

\Gems\Tracker\Model\FieldDataModel

Returns the field definition for the track enige.

getFieldsDefinition() : \Gems\Tracker\Engine\FieldsDefinition;
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldsDefinition()

Returns

\Gems\Tracker\Engine\FieldsDefinition;

Returns a model that can be used to retrieve or save the field definitions for the track editor.

getFieldsMaintenanceModel(boolean $detailed = false, string $action = 'index') : \Gems\Tracker\Model\FieldMaintenanceModel
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldsMaintenanceModel()

Parameters

$detailed

boolean

Create a model for the display of detailed item data or just a browse table

$action

string

The current action

Returns

\Gems\Tracker\Model\FieldMaintenanceModel

Returns an array name => code of all the fields of the type specified

getFieldsOfType(string $fieldType) : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFieldsOfType()

Parameters

$fieldType

string

Returns

arrayname => code

Get the round id of the first round

getFirstRoundId() : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getFirstRoundId()

Returns

integerGems id of first round

Look up the round id for the next round

getNextRoundId(integer $roundId) : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getNextRoundId()

Parameters

$roundId

integer

Gems round id

Returns

integerGems round id

Look up the round id for the previous round

getPreviousRoundId(integer $roundId, integer $roundOrder = null) : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getPreviousRoundId()

Parameters

$roundId

integer

Gems round id

$roundOrder

integer

Optional extra round order, for when the current round may have changed.

Returns

integerGems round id

Get the round object

getRound(integer $roundId) : \Gems\Tracker\Round
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRound()

Parameters

$roundId

integer

Gems round id

Returns

\Gems\Tracker\Round

Returns a snippet name that can be used to display the answers to the token or nothing.

getRoundAnswerSnippets(\Gems_Tracker_Token $token) : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundAnswerSnippets()

Parameters

$token

\Gems_Tracker_Token

Returns

arrayOf snippet names

Return the Round Changed event name for this round

getRoundChangedEvent(integer $roundId) : \Gems_Event_RoundChangedEventInterface
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundChangedEvent()

Parameters

$roundId

integer

Returns

\Gems_Event_RoundChangedEventInterfaceevent instance or null

Get the defaults for a new round

getRoundDefaults() : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundDefaults()

Returns

arrayOf fieldname => default

The round descriptions for this track

getRoundDescriptions() : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundDescriptions()

Returns

arrayroundId => string

An array of snippet names for editing a round.

getRoundEditSnippetNames() : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundEditSnippetNames()

Returns

arrayof string snippet names

Returns a model that can be used to retrieve or save the data.

getRoundModel(boolean $detailed, string $action) : \MUtil_Model_ModelAbstract
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundModel()

Parameters

$detailed

boolean

Create a model for the display of detailed item data or just a browse table

$action

string

The current action

Returns

\MUtil_Model_ModelAbstract

An array of snippet names for editing a round.

getRoundShowSnippetNames() : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRoundShowSnippetNames()

Returns

arrayof string snippet names

Get all the round objects

getRounds() : array
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getRounds()

Returns

arrayof roundId => \Gems\Tracker\Round

Returns a model that can be used to save, edit, etc. the token

getTokenModel() : \Gems_Tracker_Model_StandardTokenModel
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getTokenModel()

Returns

\Gems_Tracker_Model_StandardTokenModel

Get the TrackCompletedEvent for this trackId

getTrackCalculationEvent() : \Gems_Event_TrackCalculationEventInterface
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getTrackCalculationEvent()

Returns

\Gems_Event_TrackCalculationEventInterface| null

Get the TrackCompletedEvent for this trackId

getTrackCompletionEvent() : \Gems_Event_TrackCompletedEventInterface | null
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getTrackCompletionEvent()

Returns

\Gems_Event_TrackCompletedEventInterfacenull

getTrackId()

getTrackId() : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getTrackId()

Returns

integerThe track id

getTrackName()

getTrackName() : string
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::getTrackName()

Returns

stringThe gems track name

Is the field an appointment type

isAppointmentField(string $fieldName) : boolean
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::isAppointmentField()

Parameters

$fieldName

string

Returns

boolean

Updates the number of rounds in this track.

updateRoundCount(integer $userId) : integer
inherited_from \Gems_Tracker_Engine_TrackEngineInterface::updateRoundCount()

Parameters

$userId

integer

The current user

Returns

integer1 if data changed, 0 otherwise

Loads the rounds data for this type of track engine.

_ensureRounds() 

Can be overruled by sub classes.

Returns a list of available icons under 'htdocs/pulse/icons'

_getAvailableIcons() : array<mixed,string>

Returns

array<mixed,string>

Creates all tokens that should exist, but do not exist

addNewTokens(\Gems_Tracker_RespondentTrack $respTrack, integer $userId) : integer

NOTE: When overruling this function you should not create tokens because they were deleted by the user

Parameters

$respTrack

\Gems_Tracker_RespondentTrack

The respondent track to check

$userId

integer

Id of the user who takes the action (for logging)

Returns

integerThe number of tokens created by this code

Checks all existing tokens and updates any changes to the original rounds (when necessary)

checkExistingRoundsFor(\Gems_Tracker_RespondentTrack $respTrack, integer $userId) : integer

Parameters

$respTrack

\Gems_Tracker_RespondentTrack

The respondent track to check

$userId

integer

Id of the user who takes the action (for logging)

Returns

integerThe number of tokens changed by this code

Create model for rounds. Allowes overriding by sub classes.

createRoundModel() : \Gems_Model_JoinModel

Returns

\Gems_Model_JoinModel

Remove the unanswered tokens for inactive rounds.

removeInactiveRounds(\Gems_Tracker_RespondentTrack $respTrack, integer $userId) : integer

Parameters

$respTrack

\Gems_Tracker_RespondentTrack

The respondent track to check

$userId

integer

Id of the user who takes the action (for logging)

Returns

integerThe number of tokens changed by this code

Update the track, both in the database and in memory.

_update(array $values, integer $userId) : integer

Parameters

$values

array

The values that this token should be set to

$userId

integer

The current user

Returns

integer1 if data changed, 0 otherwise

 Properties

 

Stores how the fields are define for this track

$_fieldsDefinition : \Gems\Tracker\Engine\FieldsDefinition;

Default

 

of rounds objects, initiated at need

$_roundObjects : array

Default

 

of rounds data

$_rounds : array

Default

 

$_trackData

$_trackData : array

Default

 

$_trackId

$_trackId : integer

Default

 

$db

$db : \Zend_Db_Adapter_Abstract

Default

 

$events

$events : \Gems_Events

Default

 

$loader

$loader : \Gems_Loader

Default

 

$tracker

$tracker : \Gems_Tracker

Default

 

$util

$util : \Gems_Util

Default

 

$view

$view : \Zend_View

Default