mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
remove crontask from hook - no more supported
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@129 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
54e3298027
commit
af4398aece
44
hook.php
44
hook.php
@ -616,44 +616,6 @@ function plugin_headings_example($item, $withtemplate=0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute 1 task manage by the plugin
|
|
||||||
*
|
|
||||||
* @param $task Object of CronTask class for log / stat
|
|
||||||
*
|
|
||||||
* @return interger
|
|
||||||
* >0 : done
|
|
||||||
* <0 : to be run again (not finished)
|
|
||||||
* 0 : nothing to do
|
|
||||||
*/
|
|
||||||
function plugin_example_cron_sample1_run($task) {
|
|
||||||
|
|
||||||
$task->log("Example log message from hook");
|
|
||||||
$task->setVolume(mt_rand(0,$task->fields['param']));
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Give localized information about 1 task
|
|
||||||
*
|
|
||||||
* @param $name of the task
|
|
||||||
*
|
|
||||||
* @return array of strings
|
|
||||||
*/
|
|
||||||
function plugin_example_cron_info($name) {
|
|
||||||
global $LANG;
|
|
||||||
|
|
||||||
switch ($name) {
|
|
||||||
case 'sample1' :
|
|
||||||
return array('description' => $LANG['plugin_example']['test'] . " (hook)", // Mandatory
|
|
||||||
'parameter' => $LANG['plugin_example']['test']); // Optional
|
|
||||||
}
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Do special actions for dynamic report
|
// Do special actions for dynamic report
|
||||||
function plugin_example_dynamicReport($parm) {
|
function plugin_example_dynamicReport($parm) {
|
||||||
|
|
||||||
@ -736,10 +698,8 @@ function plugin_example_install() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// To be called for each task the plugin manage
|
// To be called for each task the plugin manage
|
||||||
// 1 task in hook.php
|
// task in class
|
||||||
CronTask::Register('PluginExampleExample', 'sample1', HOUR_TIMESTAMP*2, array('param' => 50));
|
CronTask::Register('PluginExampleExample', 'Sample', DAY_TIMESTAMP, array('param' => 50));
|
||||||
// 1 task in class
|
|
||||||
CronTask::Register('PluginExampleExample', 'sample2', DAY_TIMESTAMP);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
global $LANG;
|
global $LANG;
|
||||||
|
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'sample2' :
|
case 'Sample' :
|
||||||
return array('description' => $LANG['plugin_example']['test']." (class)",
|
return array('description' => $LANG['plugin_example']['test']." (class)",
|
||||||
'parameter' => $LANG['plugin_example']['test']);
|
'parameter' => $LANG['plugin_example']['test']);
|
||||||
}
|
}
|
||||||
@ -118,10 +118,10 @@ class PluginExampleExample extends CommonDBTM {
|
|||||||
* <0 : to be run again (not finished)
|
* <0 : to be run again (not finished)
|
||||||
* 0 : nothing to do
|
* 0 : nothing to do
|
||||||
*/
|
*/
|
||||||
static function cronSample2($task) {
|
static function cronSample($task) {
|
||||||
|
|
||||||
$task->log("Example log message from class");
|
$task->log("Example log message from class");
|
||||||
$task->setVolume(mt_rand(0,10));
|
$task->setVolume(mt_rand(0,$task->fields['param']));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user