[ task #122 ] Create a scheduled cron module
This commit is contained in:
parent
0215031632
commit
d2875d4e6d
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* 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
|
||||
* 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/>.
|
||||
*/
|
||||
/**
|
||||
* \file htdocs/jobs/lib/jobs.lib.php
|
||||
* \file cron/lib/cron.lib.php
|
||||
* \brief Ensemble de fonctions de base pour le module jobs
|
||||
* \ingroup jobs
|
||||
*/
|
||||
@ -52,12 +53,12 @@ function cron_prepare_head($object)
|
||||
$h = 0;
|
||||
$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][2] = 'card';
|
||||
$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][2] = 'info';
|
||||
$h++;
|
||||
|
||||
@ -60,13 +60,13 @@ class modCron extends DolibarrModules
|
||||
|
||||
// Config pages
|
||||
//-------------
|
||||
$this->config_page_url = array("cron");
|
||||
$this->config_page_url = array("cron.php@cron");
|
||||
|
||||
// Dependancies
|
||||
//-------------
|
||||
$this->depends = array();
|
||||
$this->requiredby = array();
|
||||
$this->langfiles = array("cron");
|
||||
$this->langfiles = array("cron@cron");
|
||||
|
||||
// Constantes
|
||||
//-----------
|
||||
@ -122,52 +122,27 @@ class modCron extends DolibarrModules
|
||||
$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
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'CronJobs',
|
||||
'url'=>'/cron/index.php',
|
||||
'langs'=>'cron@cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>100,
|
||||
'leftmenu'=>'cron',
|
||||
'titre'=>'CronListActive',
|
||||
'url'=>'/cron/list.php?status=1',
|
||||
'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>200,
|
||||
'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'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools',
|
||||
'type'=>'left',
|
||||
'titre'=>'CronListActive',
|
||||
'url'=>'/cron/cron/list.php?status=1',
|
||||
'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'=>'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++;
|
||||
|
||||
$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
|
||||
'titre'=>'CronListInactive',
|
||||
'url'=>'/cron/list.php?status=0',
|
||||
'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>201,
|
||||
'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', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -106,10 +106,10 @@ print '<br><br>';
|
||||
|
||||
// Cron launch
|
||||
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 ' '.$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 '<br>';
|
||||
print '<br>';
|
||||
@ -126,11 +126,11 @@ if ($linuxlike) {
|
||||
}
|
||||
print '<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) {
|
||||
print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php '.$file."<br>\n";
|
||||
print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php ..'.$file."<br>\n";
|
||||
} else {
|
||||
print DOL_DOCUMENT_ROOT.'> php '.$file."<br>\n";
|
||||
print DOL_DOCUMENT_ROOT.'> php ..'.$file."<br>\n";
|
||||
}
|
||||
print '<br>';
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ $object->info($id);
|
||||
|
||||
$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>';
|
||||
dol_print_object_info($object);
|
||||
|
||||
@ -283,7 +283,13 @@ if (count($object->lines)>0) {
|
||||
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();
|
||||
$db->close();
|
||||
@ -18,7 +18,7 @@
|
||||
-- ===================================================================
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS llx_cronjob
|
||||
CREATE TABLE llx_cronjob
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user