dolibarr  7.0.0-beta
modCron.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
3  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
26 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 
28 
32 class modCron extends DolibarrModules
33 {
34 
40  function __construct($db)
41  {
42  global $langs, $conf;
43 
44  $this->db = $db;
45  $this->numero = 2300;
46 
47  // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
48  // It is used to group modules in module setup page
49  $this->family = "base";
50  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51  $this->name = preg_replace('/^mod/i', '', get_class($this));
52  $this->description = "Enable the Dolibarr cron service";
53  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
54  $this->version = 'dolibarr';
55  // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
56  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
57  // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
58  $this->special = 2;
59  // Name of image file used for this module.
60  $this->picto = 'technic';
61 
62  // Data directories to create when module is enabled
63  $this->dirs = array();
64 
65  // Config pages
66  //-------------
67  $this->config_page_url = array("cron.php@cron");
68 
69  // Dependancies
70  //-------------
71  $this->hidden = !empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module
72  $this->depends = array(); // List of modules id that must be enabled if this module is enabled
73  $this->requiredby = array(); // List of modules id to disable if this one is disabled
74  $this->conflictwith = array(); // List of modules id this module is in conflict with
75  $this->langfiles = array("cron");
76 
77  // Constants
78  //-----------
79  $this->const = array(
80  0=>array(
81  'CRON_KEY',
82  'chaine',
83  '',
84  'CRON KEY',
85  0,
86  'main',
87  0
88  ),);
89 
90  // New pages on tabs
91  // -----------------
92  $this->tabs = array();
93 
94  // Boxes
95  //------
96  $this->boxes = array();
97 
98  // Cronjobs
99  $this->cronjobs = array(
100  0=>array('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),
101  1=>array('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'))),
102  // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
103  );
104 
105  // Permissions
106  $this->rights = array(); // Permission array used by this module
107  $this->rights_class = 'cron';
108  $r = 0;
109 
110  $this->rights[$r][0] = 23001;
111  $this->rights[$r][1] = 'Read cron jobs';
112  $this->rights[$r][3] = 0;
113  $this->rights[$r][4] = 'read';
114  $r++;
115 
116  $this->rights[$r][0] = 23002;
117  $this->rights[$r][1] = 'Create cron Jobs';
118  $this->rights[$r][3] = 0;
119  $this->rights[$r][4] = 'create';
120  $r++;
121 
122  $this->rights[$r][0] = 23003;
123  $this->rights[$r][1] = 'Delete cron Jobs';
124  $this->rights[$r][3] = 0;
125  $this->rights[$r][4] = 'delete';
126  $r++;
127 
128  $this->rights[$r][0] = 23004;
129  $this->rights[$r][1] = 'Execute cron Jobs';
130  $this->rights[$r][3] = 0;
131  $this->rights[$r][4] = 'execute';
132  $r++;
133 
134  // Main menu entries
135  $r = 0;
136  $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
137  'type'=>'left', // This is a Left menu entry
138  'titre'=>'CronList',
139  'url'=>'/cron/list.php?status=-2&leftmenu=admintools',
140  'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
141  'position'=>200,
142  'enabled'=>'$conf->cron->enabled && preg_match(\'/^admintools/\', $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.
143  'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
144  'target'=>'',
145  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
146  $r++;
147  }
148 }
Class DolibarrModules.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
__construct($db)
Constructor.
Class to describe a Cron module.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104