Contentserv PHP API

CSEventPlugin extends CSPlugin
in package

This Plugin extends any CONTENTSERV Record by EventListening.

To be included, it must be placed in any core/event/[RECORDMODULE] subfolder where RECORDMODULE is the name of the Module where the Record which should be listened is placed within, e.g. core/event/pdm for Pdm Records To listen to events there is always passed a CSEvent object as argument. You can use the methods getValue, getValues, getRecordIDs, cancel, getRecord or anything else as described in

Tags
see
CSEvent

As especially "may" - events are often called, it is important to implement the event listeners as fast as possible For this reason the CSEvent contains many possibilities to get values from the listened records with optimized routines. If possible you should use the getValue or getValues methods, if possible, e.g. when requesting standard fields like ParentID, Label, StateID, ... .

since
5.1.2

Table of Contents

__call()  : mixed|string
All method calls which are not defined within the plugin are forwarded to the module Therefore it is possible to get, e.g. the label by calling the getSuiteName() method.
_construct()  : void
The construct method may be used to initialize custom plugin properties it is called immediately after instantiating the plugin all arguments passed to the getPlugins method are also available in this method.
addAlternativePluginFolder()  : void
A path to a specific folder in which should be search for plugins.
cacheMayEvents()  : bool
Checks whether the eventhandling of may events can be cached. If the cache is enabled each may event is sent only once to the Plugin as long as the corresponding data do not change.
getAlternativePluginFolder()  : array<string|int, mixed>
getEventTypes()  : array<string|int, string>
This method returns the event type names the plugin is listening to.
getLevel()  : int
The getLevel method may be overwritten in the plugins and defines the order, the plugins are called, where the highest level is called first.
getMetaData()  : CSMetaData
Returns the CSMetaData of the current plugin.
getModule()  : CSModule
Returns the module, if the plugin is defined within a module.
getPlugin()  : CSPlugin|null
Returns a CSPlugin for the given plugin type and plugin class name.
getPluginChooser()  : array<string|int, mixed>
Returns an array all defined CSPlugins for the current plugin type
getPluginData()  : mixed
getPluginDefinitionFile()  : string
Returns the path to the file, the plugin is defined.
getPluginName()  : mixed
getPlugins()  : array<string|int, CSPlugin>
Returns all defined CSPlugins for the current plugin type It should be used to get all matching plugins for a given plugin api.
getPluginsInModule()  : array<string|int, mixed>
Returns all CSPlugins for the current plugin type which are defined within the given module It should be used to get all matching plugins for a given plugin api.
getRecordClasses()  : array<string|int, mixed>|null
This method returns the class names the plugin is listening to. If it is NULL all classes are listened For a better performance the method isListening should be used instead.
isAvailable()  : bool
This method is called to check, whether the plugin is available.
isListening()  : bool
This method checks whether this plugin is listening for a special event or record class.
isListeningToMayEvents()  : bool
This method checks whether this plugin is listening to may events.
may()  : void
Checks any "May" event to be able to handle them without copy/paste in one global method.
mayCheckin()  : void
Checks whether Records may be undo checked in.
mayCheckout()  : void
Checks whether Records may be checked out.
mayCopy()  : void
Checks whether Records may be copied to a target folder.
mayCreate()  : void
Checks whether Records may be created as children of the given Record.
mayCreateFolder()  : void
Checks whether Record folders may be created as children of the given Record.
mayDelete()  : void
Checks whether Records may be deleted.
mayEdit()  : void
Checks whether Records may be edited.
mayMove()  : void
Checks whether Records may be moved to a target folder.
mayStore()  : void
Checks whether a Record may be stored.
mayUndoCheckout()  : void
Checks whether Records may be undo checked out.
mayUpdate()  : void
Checks whether Records may be updated using mass update operations.
mayView()  : void
Checks whether Records may be viewed.
onBeforeCheckin()  : void
Is called just before Records are checked in.
onBeforeCheckout()  : void
Is called just before Records are checked out.
onBeforeCopy()  : void
Is called when a Record is copied just before inserting the copy into the database.
onBeforeCreate()  : void
Is called when a Record is created just before it is inserted to the database.
onBeforeDelete()  : void
Is called when a Record is deleted just before being deleted.
onBeforeMove()  : void
Is called when a Record is moved just before moving it.
onBeforeRollback()  : void
Is called when a rollback is to be executed on a record.
onBeforeStore()  : void
Is called just before a Record is stored.
onBeforeUndoCheckout()  : void
Is called just before Records are undo checked out.
onBeforeUpdate()  : void
Is called when a Record is updated using a mass update operation just before it is updated on the database.
onCheckin()  : void
Is called after Records have been checked in.
onCheckout()  : void
Is called after Records have been checked out.
onCopy()  : void
Is called when a Record had been copied.
onCreate()  : void
Is called when a Record has been created and inserted into to the database.
onDelete()  : void
Is called when a Record has been deleted.
onMove()  : void
Is called when a Record has been moved.
onRollback()  : void
Is called when a Record has been rolled back.
onStore()  : void
Is called after a Record has been stored.
onUndoCheckout()  : void
Is called after Records have been undo checked out.
onUpdate()  : void
Is called after a Record is updated using a mass update operation on the database.
resetLoadedPlugins()  : mixed
reset the internal plugins cache for loaded plugins

Methods

__call()

All method calls which are not defined within the plugin are forwarded to the module Therefore it is possible to get, e.g. the label by calling the getSuiteName() method.

public __call(mixed $methodName, mixed $methodArguments) : mixed|string
Parameters
$methodName : mixed
$methodArguments : mixed
Tags
Return values
mixed|string

_construct()

The construct method may be used to initialize custom plugin properties it is called immediately after instantiating the plugin all arguments passed to the getPlugins method are also available in this method.

public _construct() : void
Tags
Return values
void

addAlternativePluginFolder()

A path to a specific folder in which should be search for plugins.

public static addAlternativePluginFolder(mixed $sPluginFolder) : void
Parameters
$sPluginFolder : mixed
Tags
Return values
void

cacheMayEvents()

Checks whether the eventhandling of may events can be cached. If the cache is enabled each may event is sent only once to the Plugin as long as the corresponding data do not change.

public cacheMayEvents(CSEvent $event) : bool

If you are using complex routines, e.g. data from different tables to analyse whether an User may do something, the caching might be a problem. You can use this method to disable caching then

Parameters
$event : CSEvent

the Event containing informations about the Record, the event type, the ids, ...

Tags
Return values
bool

whether internal caching is enabled for this event

getAlternativePluginFolder()

public static getAlternativePluginFolder() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

getEventTypes()

This method returns the event type names the plugin is listening to.

public getEventTypes() : array<string|int, string>

If it return an empty array all event types are listened.

For a better performance restrict the plugin only for the necessary event types.

Tags
Return values
array<string|int, string>

An array of all event type names which should be listened.

getLevel()

The getLevel method may be overwritten in the plugins and defines the order, the plugins are called, where the highest level is called first.

public getLevel() : int

The method can also be set for all plugins within a module by overwriting the modules getLevel method.

Tags
Return values
int

the level of the plugin where it is called

getMetaData()

Returns the CSMetaData of the current plugin.

public getMetaData() : CSMetaData
Tags
access

public

Return values
CSMetaData

getModule()

Returns the module, if the plugin is defined within a module.

public getModule() : CSModule

This method can be used in the plugin api and the plugin wherever access to the defining module is required. If it is used in the Api, it should be noticed that this method may return null, if the plugin is directly defined in the projects or admin.local plugins directory.

Tags
Return values
CSModule

the module object, if the plugin defined in a module or null otherwise

getPlugin()

Returns a CSPlugin for the given plugin type and plugin class name.

public static getPlugin(string $pluginApiPath, string $className[, mixed $arguments = NULL ]) : CSPlugin|null

As standard behaviour the module subfolder is guessed from the forward URL parameter. If a plugin should point to something in a special module subfolder, this scope can be added by adding the module name in squared bracket at the end of the $pluginApiPath, e.g. 'core/api/plugins/CSRecordPlugin.php[pms]' to get all CSRecordPlugins defined for pms records.

Parameters
$pluginApiPath : string

The relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).

$className : string

The target plugin class name, which should be loaded.

$arguments : mixed = NULL

one or multiple arguments which should be passed to the isAvailable method.

Tags
Return values
CSPlugin|null

Returns the requested plugin for the given parameter.

getPluginChooser()

Returns an array all defined CSPlugins for the current plugin type

public static getPluginChooser(string $pluginApiPath[, mixed $arguments = NULL ]) : array<string|int, mixed>
Parameters
$pluginApiPath : string

the relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).

$arguments : mixed = NULL

one ore multiple arguments which should be passed to the isAvailable method.

Tags
Return values
array<string|int, mixed>

of CSPlugins in the form [CLASSNAME => LABEL] where the CLASSNAME may be used in the CSPlugin::getPlugin method

getPluginData()

public getPluginData() : mixed
Tags
Return values
mixed

getPluginDefinitionFile()

Returns the path to the file, the plugin is defined.

public getPluginDefinitionFile() : string
Tags
Return values
string

the path to the plugin

getPluginName()

public getPluginName() : mixed
Tags
Return values
mixed

getPlugins()

Returns all defined CSPlugins for the current plugin type It should be used to get all matching plugins for a given plugin api.

public static getPlugins(string $pluginApiPath[, mixed $arguments = NULL ]) : array<string|int, CSPlugin>

As standard behaviour the module subfolder is guessed from the forward URL parameter. If a plugin should point to something in a special module subfolder, this scope can be added by adding the module name in squared bracket at the end of the $pluginApiPath, e.g. 'core/api/plugins/CSRecordPlugin.php[pms]' to get all CSRecordPlugins defined for pms records.

Parameters
$pluginApiPath : string

the relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).

$arguments : mixed = NULL

one ore multiple arguments which should be passed to the isAvailable method.

Tags
Return values
array<string|int, CSPlugin>

array of CSPlugin objects matching the defined plugin criteria

getPluginsInModule()

Returns all CSPlugins for the current plugin type which are defined within the given module It should be used to get all matching plugins for a given plugin api.

public static getPluginsInModule(string $moduleName, string $pluginApiPath[, mixed $sFileNamePattern = '' ][, mixed $arguments = NULL ]) : array<string|int, mixed>
Parameters
$moduleName : string

the module which should be searched for plugins

$pluginApiPath : string

the relative path in filesystem for the requested plugin api.

$sFileNamePattern : mixed = ''
$arguments : mixed = NULL

one ore multiple arguments which should be passed to the isAvailable method.

Tags
Return values
array<string|int, mixed>

of CSPlugin objects matching the defined plugin criterias

getRecordClasses()

This method returns the class names the plugin is listening to. If it is NULL all classes are listened For a better performance the method isListening should be used instead.

public getRecordClasses() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|null

Either NULL or an array of all classes which should be listened

isAvailable()

This method is called to check, whether the plugin is available.

public isAvailable() : bool

If further arguments are added to the CSPlugin::getPlugins call, they are added as arguments to this method.

For simpler usage of the plugin concept: This method should be overwritten with the correct signature for a plugin call, if arguments are passed.

Tags
Return values
bool

whether the plugin is available for the given arguments

isListening()

This method checks whether this plugin is listening for a special event or record class.

public isListening(Record $oRecord, string $sEventType) : bool

It may be used to increased performance by aborting plugin calls as early as possible. Aborted event types can be defined in the method "getEventTypes"

Parameters
$oRecord : Record

the current events Record instance

$sEventType : string

(e.g. "maymove")

Tags
see
isListeningToMayEvents()
see
getRecordClasses()
see
getEventTypes()
Return values
bool

whether this event is listened

isListeningToMayEvents()

This method checks whether this plugin is listening to may events.

public isListeningToMayEvents() : bool
Tags
Return values
bool

If it returns true the plugin is listening to may events.

may()

Checks any "May" event to be able to handle them without copy/paste in one global method.

public may(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the event type, the ids, ...

Tags
Return values
void

mayCheckin()

Checks whether Records may be undo checked in.

public mayCheckin(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayCheckout()

Checks whether Records may be checked out.

public mayCheckout(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayCopy()

Checks whether Records may be copied to a target folder.

public mayCopy(CSEvent $event[, string $targetID = null ]) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$targetID : string = null

the ID of the target, where the Records should be moved to It might be NULL, if it checked whether a Record may be moved anywhere.

Tags
Return values
void

mayCreate()

Checks whether Records may be created as children of the given Record.

public mayCreate(CSEvent $event[, array<string|int, mixed> $aData = array() ]) : void

Note: The mayCreate method contains the parent Record as event object, where a new element should be created and the onCreate and onBeforeCreate methods contain the new Record itself.

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$aData : array<string|int, mixed> = array()

the data array of an object which should be inserted. This array can also be empty, if it is just checked in general whether creation is possible.

Tags
Return values
void

mayCreateFolder()

Checks whether Record folders may be created as children of the given Record.

public mayCreateFolder(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayDelete()

Checks whether Records may be deleted.

public mayDelete(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayEdit()

Checks whether Records may be edited.

public mayEdit(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayMove()

Checks whether Records may be moved to a target folder.

public mayMove(CSEvent $event[, string $targetID = null ]) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$targetID : string = null

the optional ID of the target, where the Records should be moved to. It might be NULL, if it checked whether a Record may be moved anywhere.

Tags
Return values
void

mayStore()

Checks whether a Record may be stored.

public mayStore(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayUndoCheckout()

Checks whether Records may be undo checked out.

public mayUndoCheckout(CSEvent $event) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

mayUpdate()

Checks whether Records may be updated using mass update operations.

public mayUpdate(CSEvent $event, string $name, string $value) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$name : string

the name of the value which is updated

$value : string

the new value which should be used

Tags
Return values
void

mayView()

Checks whether Records may be viewed.

public mayView(CSEvent $event[, object $viewer = null ]) : void

The method cancel can be used to cancel the event for some or all IDs.

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$viewer : object = null

an optional viewer, e.g. a CSGuiEditor or a CSGuiList, a CSTree, ... where the object should be displayed in a GuiComponent or null, if just the objects visiblity is checked using any API call.

Tags
Return values
void

onBeforeCheckin()

Is called just before Records are checked in.

public onBeforeCheckin(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onBeforeCheckout()

Is called just before Records are checked out.

public onBeforeCheckout(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onBeforeCopy()

Is called when a Record is copied just before inserting the copy into the database.

public onBeforeCopy(CSEvent $event, string $targetID) : void

The records contained in the event still have the ID of the copy source. The original record which will will be duplicated can be accessed and modified with the object $event->getRecord().

Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$targetID : string

the ID of the target, where the Records will be copied to

Tags
Return values
void

onBeforeCreate()

Is called when a Record is created just before it is inserted to the database.

public onBeforeCreate(CSEvent $event) : void

The Record which should be inserted can be accessed with $event->getRecord().

Parameters
$event : CSEvent

the Event containing informations about the created Record

Tags
Return values
void

onBeforeDelete()

Is called when a Record is deleted just before being deleted.

public onBeforeDelete(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onBeforeMove()

Is called when a Record is moved just before moving it.

public onBeforeMove(CSEvent $event, string $targetID, mixed $oldParentID) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$targetID : string

the ID of the target, where the Records will be moved to

$oldParentID : mixed
Tags
Return values
void

onBeforeRollback()

Is called when a rollback is to be executed on a record.

public onBeforeRollback(CSEvent $oEvent, int $iVersionNr) : void

The Record which should be rolled back can be accessed with $event->getRecord().

Parameters
$oEvent : CSEvent

he Event containing informations about the rolled back Record

$iVersionNr : int

the version number to which the record was rolled back.

Tags
Return values
void

onBeforeStore()

Is called just before a Record is stored.

public onBeforeStore(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record

Tags
Return values
void

onBeforeUndoCheckout()

Is called just before Records are undo checked out.

public onBeforeUndoCheckout(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onBeforeUpdate()

Is called when a Record is updated using a mass update operation just before it is updated on the database.

public onBeforeUpdate(CSEvent $event, string $name, string $value) : void

The event is triggered with the API method call "updateValues" on a Record.

Parameters
$event : CSEvent

the Event containing information about the Record, the ids, ...

$name : string

the name of the value which is updated

$value : string

the new value which will be used

Tags
Return values
void

onCheckin()

Is called after Records have been checked in.

public onCheckin(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onCheckout()

Is called after Records have been checked out.

public onCheckout(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onCopy()

Is called when a Record had been copied.

public onCopy(CSEvent $event, string $targetID, array<string|int, mixed> $srcIDs) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$targetID : string

the ID of the target, where the Records will be copied to

$srcIDs : array<string|int, mixed>

an array containing all matching IDs in the form ($newID => $srcID, ...)

Tags
Return values
void

onCreate()

Is called when a Record has been created and inserted into to the database.

public onCreate(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the created Record

Tags
Return values
void

onDelete()

Is called when a Record has been deleted.

public onDelete(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onMove()

Is called when a Record has been moved.

public onMove(CSEvent $event, mixed $targetID, mixed $oldParentID) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

$targetID : mixed
$oldParentID : mixed
Tags
Return values
void

onRollback()

Is called when a Record has been rolled back.

public onRollback(CSEvent $oEvent, int $iVersionNr) : void
Parameters
$oEvent : CSEvent

the Event containing informations about the rolled back Record

$iVersionNr : int

the version number to which the record was rolled back.

Tags
Return values
void

onStore()

Is called after a Record has been stored.

public onStore(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record

Tags
Return values
void

onUndoCheckout()

Is called after Records have been undo checked out.

public onUndoCheckout(CSEvent $event) : void
Parameters
$event : CSEvent

the Event containing informations about the Record, the ids, ...

Tags
Return values
void

onUpdate()

Is called after a Record is updated using a mass update operation on the database.

public onUpdate(CSEvent $event, string $name, string $value) : void

The event is triggered with the API method call "updateValues" on a Record.

Parameters
$event : CSEvent

the Event containing information about the Record, the ids, ...

$name : string

the name of the value which is updated

$value : string

the new value which had been used

Tags
Return values
void

resetLoadedPlugins()

reset the internal plugins cache for loaded plugins

public static resetLoadedPlugins() : mixed
Tags
@return

void;

access

public

Return values
mixed

        

Search results