[ task #122 ] Create a scheduled cron module
This commit is contained in:
parent
0215031632
commit
d2875d4e6d
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
||||||
|
* Copyright (C) 2013 Florian Henry <florian.henry@opn-concept.pro>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -15,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file htdocs/jobs/lib/jobs.lib.php
|
* \file cron/lib/cron.lib.php
|
||||||
* \brief Ensemble de fonctions de base pour le module jobs
|
* \brief Ensemble de fonctions de base pour le module jobs
|
||||||
* \ingroup jobs
|
* \ingroup jobs
|
||||||
*/
|
*/
|
||||||
@ -52,12 +53,12 @@ function cron_prepare_head($object)
|
|||||||
$h = 0;
|
$h = 0;
|
||||||
$head = array();
|
$head = array();
|
||||||
|
|
||||||
$head[$h][0] = dol_buildpath('/cron/cron/card.php', 1).'?id='.$object->id;
|
$head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id;
|
||||||
$head[$h][1] = $langs->trans("CronTask");
|
$head[$h][1] = $langs->trans("CronTask");
|
||||||
$head[$h][2] = 'card';
|
$head[$h][2] = 'card';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
$head[$h][0] = dol_buildpath('/cron/cron/info.php', 1).'?id='.$object->id;
|
$head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id;
|
||||||
$head[$h][1] = $langs->trans("CronInfoPage");
|
$head[$h][1] = $langs->trans("CronInfoPage");
|
||||||
$head[$h][2] = 'info';
|
$head[$h][2] = 'info';
|
||||||
$h++;
|
$h++;
|
||||||
|
|||||||
@ -60,13 +60,13 @@ class modCron extends DolibarrModules
|
|||||||
|
|
||||||
// Config pages
|
// Config pages
|
||||||
//-------------
|
//-------------
|
||||||
$this->config_page_url = array("cron");
|
$this->config_page_url = array("cron.php@cron");
|
||||||
|
|
||||||
// Dependancies
|
// Dependancies
|
||||||
//-------------
|
//-------------
|
||||||
$this->depends = array();
|
$this->depends = array();
|
||||||
$this->requiredby = array();
|
$this->requiredby = array();
|
||||||
$this->langfiles = array("cron");
|
$this->langfiles = array("cron@cron");
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
//-----------
|
//-----------
|
||||||
@ -122,52 +122,27 @@ class modCron extends DolibarrModules
|
|||||||
$r=0;
|
$r=0;
|
||||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
'type'=>'left', // This is a Left menu entry
|
'type'=>'left', // This is a Left menu entry
|
||||||
'titre'=>'CronJobs',
|
'titre'=>'CronListActive',
|
||||||
'url'=>'/cron/index.php',
|
'url'=>'/cron/list.php?status=1',
|
||||||
'langs'=>'cron@cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position'=>100,
|
'position'=>200,
|
||||||
'leftmenu'=>'cron',
|
|
||||||
'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
'perms'=>'$user->admin', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
'target'=>'',
|
'target'=>'',
|
||||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools',
|
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
'type'=>'left',
|
'type'=>'left', // This is a Left menu entry
|
||||||
'titre'=>'CronListActive',
|
'titre'=>'CronListInactive',
|
||||||
'url'=>'/cron/cron/list.php?status=1',
|
'url'=>'/cron/list.php?status=0',
|
||||||
'langs'=>'cron@cron',
|
'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position'=>201,
|
'position'=>201,
|
||||||
'enabled'=>'$user->rights->cron->read',
|
'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
'perms'=>'$user->rights->cron->read',
|
'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
'target'=>'',
|
'target'=>'',
|
||||||
'user'=>2);
|
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools',
|
|
||||||
'type'=>'left',
|
|
||||||
'titre'=>'CronListInactive',
|
|
||||||
'url'=>'/cron/cron/list.php?status=0',
|
|
||||||
'langs'=>'cron@cron',
|
|
||||||
'position'=>201,
|
|
||||||
'enabled'=>'$user->rights->cron->read',
|
|
||||||
'perms'=>'$user->rights->cron->read',
|
|
||||||
'target'=>'',
|
|
||||||
'user'=>2);
|
|
||||||
$r++;
|
|
||||||
|
|
||||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools',
|
|
||||||
'type'=>'left',
|
|
||||||
'titre'=>'CronAdd',
|
|
||||||
'url'=>'/cron/cron/card.php?action=create',
|
|
||||||
'langs'=>'cron@cron',
|
|
||||||
'position'=>202,
|
|
||||||
'enabled'=>'$user->rights->cron->create',
|
|
||||||
'perms'=>'$user->rights->cron->create',
|
|
||||||
'target'=>'',
|
|
||||||
'user'=>2);
|
|
||||||
$r++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -106,10 +106,10 @@ print '<br><br>';
|
|||||||
|
|
||||||
// Cron launch
|
// Cron launch
|
||||||
print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
|
print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
|
||||||
$url=dol_buildpath('/cron/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login;
|
$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login;
|
||||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||||
print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
|
print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
|
||||||
$url=dol_buildpath('/cron/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
||||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -126,11 +126,11 @@ if ($linuxlike) {
|
|||||||
}
|
}
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
||||||
$file=dol_buildpath('/cron/script/cron/cron_run_jobs.php').' '.(empty($conf->global->MAIN_CRON_KEY)?'securitykey':''.$conf->global->MAIN_CRON_KEY.'').' '.$user->login.' cronjobid(optionnal)';
|
$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->MAIN_CRON_KEY)?'securitykey':''.$conf->global->MAIN_CRON_KEY.'').' '.$user->login.' cronjobid(optionnal)';
|
||||||
if ($linuxlike) {
|
if ($linuxlike) {
|
||||||
print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php '.$file."<br>\n";
|
print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php ..'.$file."<br>\n";
|
||||||
} else {
|
} else {
|
||||||
print DOL_DOCUMENT_ROOT.'> php '.$file."<br>\n";
|
print DOL_DOCUMENT_ROOT.'> php ..'.$file."<br>\n";
|
||||||
}
|
}
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ $object->info($id);
|
|||||||
|
|
||||||
$head = cron_prepare_head($object);
|
$head = cron_prepare_head($object);
|
||||||
|
|
||||||
dol_fiche_head($head, 'info', $langs->trans("CronInfo"), 0, 'bill');
|
dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'bill');
|
||||||
|
|
||||||
print '<table width="100%"><tr><td>';
|
print '<table width="100%"><tr><td>';
|
||||||
dol_print_object_info($object);
|
dol_print_object_info($object);
|
||||||
|
|||||||
@ -283,7 +283,13 @@ if (count($object->lines)>0) {
|
|||||||
print $langs->trans('CronNoJobs');
|
print $langs->trans('CronNoJobs');
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<div style="clear:both"></div>';
|
print "\n\n<div class=\"tabsAction\">\n";
|
||||||
|
if (! $user->rights->cron->create) {
|
||||||
|
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("New").'</a>';
|
||||||
|
} else {
|
||||||
|
print '<a class="butAction" href="'.dol_buildpath('/cron/card.php',1).'?action=create">'.$langs->trans("New").'</a>';
|
||||||
|
}
|
||||||
|
print '<br><br></div>';
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
@ -18,7 +18,7 @@
|
|||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS llx_cronjob
|
CREATE TABLE llx_cronjob
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user