mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
use new crontask feature
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@92 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
c3b74fddcc
commit
15b8a6cdf8
37
hook.php
37
hook.php
@ -651,15 +651,35 @@ function plugin_headings_example($type,$ID,$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_sample_run($task) {
|
||||
$task->log("Example log message");
|
||||
$task->setVolume(mt_rand(0,$task->fields['param']));
|
||||
|
||||
// Cron function : name= cron_plugin_PLUGINNAME
|
||||
function cron_plugin_example(){
|
||||
logInFile('example',"cron called\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// >0 : done
|
||||
// <0 : to be run again (not finished)
|
||||
// 0 : nothing to do
|
||||
return 1;
|
||||
/**
|
||||
* Give localized information about 1 task
|
||||
*
|
||||
* @param $name of the task
|
||||
*
|
||||
* @return array of strings
|
||||
*/
|
||||
function plugin_example_cron_sample_info($name) {
|
||||
|
||||
return array (
|
||||
'description' => "Example cron task", // Mandatory
|
||||
'parameter' => "Example parameter"); // Optional
|
||||
}
|
||||
|
||||
|
||||
@ -735,6 +755,9 @@ function plugin_example_install(){
|
||||
$DB->query($query) or die("error populate glpi_plugin_example_dropdown". $DB->error());
|
||||
|
||||
}
|
||||
|
||||
// To be called for each task the plugin manage
|
||||
CronTask::Register('example', 'sample', DAY_TIMESTAMP, array('param'=>50));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,6 @@ function plugin_init_example() {
|
||||
|
||||
$PLUGIN_HOOKS['item_transfer']['example'] = 'plugin_item_transfer_example';
|
||||
|
||||
// Cron action
|
||||
$PLUGIN_HOOKS['cron']['example'] = DAY_TIMESTAMP;
|
||||
|
||||
//redirect appel http://localhost/glpi/index.php?redirect=plugin_example_2 (ID 2 du form)
|
||||
$PLUGIN_HOOKS['redirect_page']['example']="example.form.php";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user