2013-03-13 19:55:21 +01:00
< ? php
2013-03-22 17:10:17 +01:00
/* Copyright ( C ) 2012 Nicolas Villa aka Boyquotes http :// informetic . fr
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2013-03-13 19:55:21 +01:00
*
* 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
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2013-03-13 19:55:21 +01:00
*/
/**
2013-03-22 17:10:17 +01:00
* \defgroup cron Module cron
* \brief cron module descriptor .
2013-08-22 16:49:23 +02:00
* \file htdocs / core / modules / modCron . class . php
2013-03-22 17:10:17 +01:00
* \ingroup cron
* \brief Description and activation file for module Jobs
2013-03-13 19:55:21 +01:00
*/
2017-09-04 12:42:51 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2013-03-13 19:55:21 +01:00
2013-04-17 16:26:14 +02:00
2013-03-13 19:55:21 +01:00
/**
* Class to describe a Cron module
*/
class modCron extends DolibarrModules
{
/**
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2013-03-13 19:55:21 +01:00
{
2017-09-04 12:42:51 +02:00
global $langs , $conf ;
2013-08-06 03:56:59 +02:00
2013-03-13 19:55:21 +01:00
$this -> db = $db ;
$this -> numero = 2300 ;
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
2013-03-23 19:23:17 +01:00
$this -> family = " base " ;
2013-03-13 19:55:21 +01:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2017-09-04 12:42:51 +02:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2013-03-13 19:55:21 +01:00
$this -> description = " Enable the Dolibarr cron service " ;
2017-08-22 18:34:58 +02:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2013-03-13 19:55:21 +01:00
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
// Name of image file used for this module.
2017-09-04 12:42:51 +02:00
$this -> picto = 'technic' ;
2013-03-13 19:55:21 +01:00
// Data directories to create when module is enabled
$this -> dirs = array ();
// Config pages
//-------------
$this -> config_page_url = array ( " cron.php@cron " );
2018-04-07 21:11:58 +02:00
// Dependancies
//-------------
2017-09-04 12:42:51 +02:00
$this -> hidden = ! empty ( $conf -> global -> MODULE_CRON_DISABLED ); // A condition to disable module
$this -> depends = array (); // List of modules id that must be enabled if this module is enabled
2018-04-07 21:11:58 +02:00
$this -> requiredby = array (); // List of modules id to disable if this one is disabled
2017-09-04 12:42:51 +02:00
$this -> conflictwith = array (); // List of modules id this module is in conflict with
2018-04-07 21:11:58 +02:00
$this -> langfiles = array ( " cron " );
2013-03-13 19:55:21 +01:00
2018-04-07 21:11:58 +02:00
// Constants
//-----------
$this -> const = array (
2013-03-22 17:10:17 +01:00
0 => array (
2013-03-23 19:23:17 +01:00
'CRON_KEY' ,
2013-03-22 17:10:17 +01:00
'chaine' ,
'' ,
'CRON KEY' ,
0 ,
'main' ,
0
),);
2013-03-13 19:55:21 +01:00
// New pages on tabs
// -----------------
$this -> tabs = array ();
// Boxes
//------
$this -> boxes = array ();
2016-01-30 02:51:26 +01:00
// Cronjobs
$this -> cronjobs = array (
2018-04-05 12:28:52 +02:00
0 => array ( 'entity' => 0 , 'label' => 'PurgeDeleteTemporaryFilesShort' , 'jobtype' => 'method' , 'class' => 'core/class/utils.class.php' , 'objectname' => 'Utils' , 'method' => 'purgeFiles' , 'parameters' => '' , 'comment' => 'PurgeDeleteTemporaryFiles' , 'frequency' => 2 , 'unitfrequency' => 3600 * 24 * 7 , 'priority' => 50 , 'status' => 1 , 'test' => true ),
1 => array ( 'entity' => 0 , 'label' => 'MakeLocalDatabaseDumpShort' , 'jobtype' => 'method' , 'class' => 'core/class/utils.class.php' , 'objectname' => 'Utils' , 'method' => 'dumpDatabase' , 'parameters' => 'none,auto,1,auto,10' , 'comment' => 'MakeLocalDatabaseDump' , 'frequency' => 1 , 'unitfrequency' => 3600 * 24 * 7 , 'priority' => 90 , 'status' => 0 , 'test' => in_array ( $db -> type , array ( 'mysql' , 'mysqli' ))),
// 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
2016-01-30 02:51:26 +01:00
);
2017-08-03 11:42:22 +02:00
// Permissions
2017-09-04 12:42:51 +02:00
$this -> rights = array (); // Permission array used by this module
2017-08-03 11:42:22 +02:00
$this -> rights_class = 'cron' ;
2017-09-04 12:42:51 +02:00
$r = 0 ;
2017-08-03 11:42:22 +02:00
2013-03-22 17:10:17 +01:00
$this -> rights [ $r ][ 0 ] = 23001 ;
$this -> rights [ $r ][ 1 ] = 'Read cron jobs' ;
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
2013-03-22 17:10:17 +01:00
$this -> rights [ $r ][ 4 ] = 'read' ;
$r ++ ;
2013-03-23 19:23:17 +01:00
2013-03-22 17:10:17 +01:00
$this -> rights [ $r ][ 0 ] = 23002 ;
$this -> rights [ $r ][ 1 ] = 'Create cron Jobs' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'create' ;
$r ++ ;
2013-03-23 19:23:17 +01:00
2013-03-22 17:10:17 +01:00
$this -> rights [ $r ][ 0 ] = 23003 ;
$this -> rights [ $r ][ 1 ] = 'Delete cron Jobs' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'delete' ;
$r ++ ;
2013-03-23 19:23:17 +01:00
2013-03-22 17:10:17 +01:00
$this -> rights [ $r ][ 0 ] = 23004 ;
$this -> rights [ $r ][ 1 ] = 'Execute cron Jobs' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'execute' ;
$r ++ ;
2013-03-17 19:39:53 +01:00
2013-03-30 14:27:13 +01:00
// Main menu entries
2017-09-04 12:42:51 +02:00
$r = 0 ;
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=home,fk_leftmenu=admintools' , // 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
2013-04-17 16:26:14 +02:00
'titre' => 'CronList' ,
2019-05-13 10:26:30 +02:00
'url' => '/cron/list.php?leftmenu=admintools' ,
2017-09-04 12:42:51 +02:00
'langs' => 'cron' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
2013-03-30 14:27:13 +01:00
'position' => 200 ,
2018-06-19 13:10:13 +02:00
'enabled' => '$conf->cron->enabled && preg_match(\'/^(admintools|all)/\', $leftmenu)' , // 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.
2017-09-04 12:42:51 +02:00
'perms' => '$user->rights->cron->read' , // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
2013-03-30 14:27:13 +01:00
'target' => '' ,
2017-09-04 12:42:51 +02:00
'user' => 2 ); // 0=Menu for internal users, 1=external users, 2=both
2013-03-22 17:10:17 +01:00
$r ++ ;
2013-03-13 19:55:21 +01:00
}
}