HousekeepingScript
extends CSActiveScriptPlugin
in package
The base of all ActiveScript plugins To be included, it must be placed in a plugins/script subfolder with a file name ending with Script.php.
Tags
Table of Contents
- ATTR_MONITORING_PROCESSES = 'MonitoringProcesses:'
- EXECUTION_TIME_LIMIT = 1800
- Default execution time limit for the script.
- $ENUM_MIGRATE_LOGRECORDNAMES : array<string|int, mixed>
- A migration array to ensure old saved data is used properly with the real record name.
- __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.
- addSteps() : void
- This method will be called by the framework to find out how many execution steps the plugin intends to run.
- canBeInterrupted() : bool
- Tells if the script can be interrupted, to allow to disable Stop and Pause buttons.
- canInterruptBeforeStep() : bool
- Will be called by the framework when the job is requested to interrupt
- checkInterruptionRequest() : void
- Checks if an interruption request is being available for the current job. If so and the interruption is confirmed, the job gets interrupted.
- cleanLogForRecordName() : bool
- Deletes a table for given Log record by days filter.
- getActiveScript() : CSActiveScript
- Returns the ActiveScript
- getActiveScriptJob() : CSActiveScriptJob
- Returns the ActiveScriptJob
- getAdditionalLogRecordDefinitions() : array<string|int, mixed>
- This function enhanced the plugin with more Log Records to delete.
- getAdditionalLogRecordDetails() : array<string|int, mixed>
- With this function it is possible to manipulate all System Default Log Details.
- getAlternativePluginFolder() : array<string|int, mixed>
- getAvailableSleepDurationsPerStep() : array<string|int, int>
- Allows the plugin to provide a list of predefined numbers of microseconds the script should be able to sleep between each step.
- getDetailsArrayKeyForLogRecordName() : string
- Returns a unique key for the Log record which is used as identifier in the big array of all Log Records.
- getIcon() : string
- 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.
- getLogRecordDetails() : array<string|int, mixed>
- Returns an array with detail information about all Log Records within CS.
- getMetaData() : CSMetaData
- Returns the CSMetaData of the current plugin.
- getModule() : CSModule
- Returns the module, if the plugin is defined within a module.
- getMonitoringProcessesDetails() : array<string|int, mixed>
- Returns an array with detail information about monitoring processes folder
- getOutputKeys() : array<string|int, string>
- Lets a plugin developer tell which output his script will provide
- 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.
- isAvailable() : bool
- This method is called to check, whether the plugin is available.
- isAvailableForCurrentUser() : bool
- Tells if this script is available for the current user outside of the actual editor
- isReadyToRerun() : bool
- If a job is configured to be kept alive, this method is called after each iteration to check if the next iteration should be started. It should be overwritten on plugin side to do a check if new data is available to be processed by the job.
- onAfterRunScript() : void
- Will be called by the framework after the script was executed. Compared to the onBeforeRunSteps-method, when it is called, all other tasks are already finished.
- onAfterRunSteps() : void
- Will be called by the framework after each step was executed
- onBeforeAutomaticResume() : void
- Will be called by the framework before a job is resumed after being stopped in an unusual way.
- onBeforeRunScript() : void
- Will be called by the framework before the script is executed.
- onBeforeRunSteps() : void
- Will be called by the framework before each step is executed
- prepareEditor() : void
- This method can be overwritten by the plugin to add fields to the editor for custom configuration
- resetLoadedPlugins() : mixed
- reset the internal plugins cache for loaded plugins
- run() : mixed
- This is the most important method to implement when defining your CSOpenSearch Here the search is executed and the found IDs will be added to the Response
- runStep() : mixed
- This method will be called by the framework when the step with the given ID should be executed
- setActiveScript() : mixed
- Sets the ActiveScript
- setActiveScriptJob() : void
- Sets the active script
- shouldBeKeptAlive() : bool
- Returns whether the job should be kept alive by the framework. Only CORE jobs are allowed to define itself as such.
- shouldBeSelectableInGui() : bool
- Tells if the plugin wishes to be selectable by a user in the script editor.
- shouldIgnoreExecutionFlag() : bool
- Function to validate if the execution should skip automation settings
- supportsAutomaticResume() : bool
- Tells if the plugin supports automatic resume in case the job has been stopped in an unusual way (like webserver crashes). In case it returns true the script will automatically be resumed when a webserver is started again and the script was running at the time it was stopped.
Constants
ATTR_MONITORING_PROCESSES
public
mixed
ATTR_MONITORING_PROCESSES
= 'MonitoringProcesses:'
Tags
EXECUTION_TIME_LIMIT
Default execution time limit for the script.
public
int
EXECUTION_TIME_LIMIT
= 1800
Tags
Properties
$ENUM_MIGRATE_LOGRECORDNAMES
A migration array to ensure old saved data is used properly with the real record name.
public
static array<string|int, mixed>
$ENUM_MIGRATE_LOGRECORDNAMES
= array(
// the stored key => the real table name
'CleanLog' => 'Log',
'CleanMonitor' => 'MonitorObservation',
//'CleanScriptLog' => 'ActiveScriptJob', // do not migrate this value due to invalid name conventions
'CleanCometLog' => 'CometLog',
'CleanDeletionLog' => 'Deletion',
'CleanRestLog' => 'Restlog',
'CleanWsdlLog' => 'WsdlLogging',
'CleanSmartLog' => 'SmartLog',
'CleanUserSessionLog' => 'UserVisit',
)
Tags
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 —addSteps()
This method will be called by the framework to find out how many execution steps the plugin intends to run.
public
addSteps(CSActiveScriptStepList $oStepList) : void
Parameters
- $oStepList : CSActiveScriptStepList
-
the step list to add to
Tags
Return values
void —canBeInterrupted()
Tells if the script can be interrupted, to allow to disable Stop and Pause buttons.
public
canBeInterrupted() : bool
Tags
Return values
bool —true if the script can be interrupted, otherwise false.
canInterruptBeforeStep()
Will be called by the framework when the job is requested to interrupt
public
canInterruptBeforeStep(CSActiveScriptStep $oStep) : bool
Parameters
- $oStep : CSActiveScriptStep
-
the current step to run
Tags
Return values
bool —true if the script can be interrupted, false if not at this step
checkInterruptionRequest()
Checks if an interruption request is being available for the current job. If so and the interruption is confirmed, the job gets interrupted.
public
checkInterruptionRequest(mixed $oStep) : void
Parameters
- $oStep : mixed
Tags
Return values
void —cleanLogForRecordName()
Deletes a table for given Log record by days filter.
public
cleanLogForRecordName(string $sLogRecordName, int $iDays) : bool
Parameters
- $sLogRecordName : string
- $iDays : int
Tags
Return values
bool —getActiveScript()
Returns the ActiveScript
public
getActiveScript() : CSActiveScript
Tags
Return values
CSActiveScript —The active script
getActiveScriptJob()
Returns the ActiveScriptJob
public
getActiveScriptJob() : CSActiveScriptJob
Tags
Return values
CSActiveScriptJob —The active script job
getAdditionalLogRecordDefinitions()
This function enhanced the plugin with more Log Records to delete.
public
getAdditionalLogRecordDefinitions() : array<string|int, mixed>
This plugins call on it self a dynamic function '_clean{RecordName}(arguments)' so each user defined Record can be handled in an unique way.
For Example: '_cleanActiveScriptJob'
Tags
Return values
array<string|int, mixed> —getAdditionalLogRecordDetails()
With this function it is possible to manipulate all System Default Log Details.
public
getAdditionalLogRecordDetails(array<string|int, mixed> $aDefaultSystemLogDetails) : array<string|int, mixed>
Further Details array can be added to the given $aDefaultSystemLogDetails. The return value must be merged together with the "+" operator to preserve array keys!
Parameters
- $aDefaultSystemLogDetails : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getAlternativePluginFolder()
public
static getAlternativePluginFolder() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getAvailableSleepDurationsPerStep()
Allows the plugin to provide a list of predefined numbers of microseconds the script should be able to sleep between each step.
public
getAvailableSleepDurationsPerStep() : array<string|int, int>
The administrator of the script should be able to choose from this list. The value 0 will automatically be added to the list and is also the default.
Tags
Return values
array<string|int, int> —array with milliseconds like array(25, 50, 100, 250, 500) or single int like 1000 or string[] as associative array with the seconds to sleep as value and an optional explanation as key e.g. array('Slow' => 1000, 'Normal' => 500, 'Fast' => 100)
getDetailsArrayKeyForLogRecordName()
Returns a unique key for the Log record which is used as identifier in the big array of all Log Records.
public
getDetailsArrayKeyForLogRecordName(string $sLogRecordName) : string
Parameters
- $sLogRecordName : string
Tags
Return values
string —getIcon()
public
getIcon() : string
Tags
Return values
string —the icon representation of the script as relative URL
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
getLogRecordDetails()
Returns an array with detail information about all Log Records within CS.
public
getLogRecordDetails() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getMetaData()
Returns the CSMetaData of the current plugin.
public
getMetaData() : CSMetaData
Tags
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
getMonitoringProcessesDetails()
Returns an array with detail information about monitoring processes folder
public
getMonitoringProcessesDetails() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getOutputKeys()
Lets a plugin developer tell which output his script will provide
public
getOutputKeys() : array<string|int, string>
Tags
Return values
array<string|int, string> —array with the allowed output keys
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
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
isAvailableForCurrentUser()
Tells if this script is available for the current user outside of the actual editor
public
isAvailableForCurrentUser() : bool
Tags
Return values
bool —isReadyToRerun()
If a job is configured to be kept alive, this method is called after each iteration to check if the next iteration should be started. It should be overwritten on plugin side to do a check if new data is available to be processed by the job.
public
isReadyToRerun() : bool
Tags
Return values
bool —True, if the next iteration can be started, otherwise false.
onAfterRunScript()
Will be called by the framework after the script was executed. Compared to the onBeforeRunSteps-method, when it is called, all other tasks are already finished.
public
onAfterRunScript() : void
Tags
Return values
void —onAfterRunSteps()
Will be called by the framework after each step was executed
public
onAfterRunSteps(CSActiveScriptStepList $oStepList) : void
Parameters
- $oStepList : CSActiveScriptStepList
-
the step list built up in the addSteps method.
Tags
Return values
void —onBeforeAutomaticResume()
Will be called by the framework before a job is resumed after being stopped in an unusual way.
public
onBeforeAutomaticResume(CSActiveScriptStepList $oStepList) : void
Parameters
- $oStepList : CSActiveScriptStepList
-
the step list built up in the addSteps method.
Tags
Return values
void —onBeforeRunScript()
Will be called by the framework before the script is executed.
public
onBeforeRunScript() : void
Tags
Return values
void —onBeforeRunSteps()
Will be called by the framework before each step is executed
public
onBeforeRunSteps(CSActiveScriptStepList $oStepList) : void
Parameters
- $oStepList : CSActiveScriptStepList
-
the step list built up in the addSteps method.
Tags
Return values
void —prepareEditor()
This method can be overwritten by the plugin to add fields to the editor for custom configuration
public
prepareEditor(CSGuiEditor $oEditor) : void
For each field you add you can pickup the configured value later in the run method
Parameters
- $oEditor : CSGuiEditor
Tags
Return values
void —resetLoadedPlugins()
reset the internal plugins cache for loaded plugins
public
static resetLoadedPlugins() : mixed
Tags
Return values
mixed —run()
This is the most important method to implement when defining your CSOpenSearch Here the search is executed and the found IDs will be added to the Response
public
final run() : mixed
Tags
Return values
mixed —runStep()
This method will be called by the framework when the step with the given ID should be executed
public
runStep(CSActiveScriptStep $oStep) : mixed
Parameters
- $oStep : CSActiveScriptStep
-
the step to execute
Tags
Return values
mixed —setActiveScript()
Sets the ActiveScript
public
setActiveScript(CSActiveScript $oActiveScript) : mixed
Parameters
- $oActiveScript : CSActiveScript
-
the active script
Tags
Return values
mixed —setActiveScriptJob()
Sets the active script
public
setActiveScriptJob(CSActiveScriptJob $oActiveScriptJob) : void
Parameters
- $oActiveScriptJob : CSActiveScriptJob
-
the script job
Tags
Return values
void —shouldBeKeptAlive()
Returns whether the job should be kept alive by the framework. Only CORE jobs are allowed to define itself as such.
public
shouldBeKeptAlive() : bool
Tags
Return values
bool —True, if the job should be kept alive, otherwise false.
shouldBeSelectableInGui()
Tells if the plugin wishes to be selectable by a user in the script editor.
public
shouldBeSelectableInGui() : bool
If not the plugin can only be assigned through the API to a script.
Tags
Return values
bool —if true the plugin is selectable.
shouldIgnoreExecutionFlag()
Function to validate if the execution should skip automation settings
public
final shouldIgnoreExecutionFlag() : bool
Tags
Return values
bool —If the execution should ignore the automation settings
supportsAutomaticResume()
Tells if the plugin supports automatic resume in case the job has been stopped in an unusual way (like webserver crashes). In case it returns true the script will automatically be resumed when a webserver is started again and the script was running at the time it was stopped.
public
supportsAutomaticResume() : bool
IMPORTANT: to be able to automatically resume, a script must take care of restoring pointers or other references in onBeforeAutomaticResume so no error occurs.
Tags
Return values
bool —true, if automatic resume is supported, otherwise false.
