dolibarr 20.0.0
cron.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org>
4 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
27// Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
31
32// Load translation files required by the page
33$langs->loadLangs(array('admin', 'cron'));
34
35if (!$user->admin) {
37}
38
39$actionsave = GETPOST("save", 'alphanohtml');
40
41// Save parameters
42if (!empty($actionsave)) {
43 $i = 0;
44
45 $db->begin();
46
47 $i += dolibarr_set_const($db, 'CRON_KEY', GETPOST("CRON_KEY"), 'chaine', 0, '', 0);
48
49 if ($i >= 1) {
50 $db->commit();
51 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
52 } else {
53 $db->rollback();
54 setEventMessages($langs->trans("Error"), null, 'errors');
55 }
56}
57
58
59/*
60 * View
61 */
62
63$help_url = '';
64llxHeader('', '', $help_url);
65
66$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
67print load_fiche_titre($langs->trans("CronSetup"), $linkback, 'title_setup');
68
69// Configuration header
71
72print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
73print '<input type="hidden" name="token" value="'.newToken().'">';
74
75print dol_get_fiche_head($head, 'setup', $langs->trans("Module2300Name"), -1, 'cron');
76
77print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>';
78
79print "<br>\n";
80
81print '<table class="noborder centpercent">';
82
83print '<tr class="liste_titre">';
84print "<td>".$langs->trans("Parameter")."</td>";
85print "<td>".$langs->trans("Value")."</td>";
86print "<td></td>";
87print "</tr>";
88
89// Security key for cron (if CRON_DISABLE_KEY_CHANGE is 1: modification is not allowed, -1: no button refresh)
90print '<tr class="oddeven">';
91print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
92$disabled = '';
93if (getDolGlobalInt('CRON_DISABLE_KEY_CHANGE') > 0) {
94 $disabled = ' disabled="disabled"';
95}
96print '<td>';
97if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') != 1) {
98 print '<input type="text" class="flat minwidth300 widthcentpercentminusx"'.$disabled.' id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ? GETPOST('CRON_KEY') : getDolGlobalString('CRON_KEY')).'">';
99 if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') == 0) {
100 if (!empty($conf->use_javascript_ajax)) {
101 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
102 }
103 } elseif (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') == -1) {
104 $langs->load("errors");
105 print '&nbsp;'.img_picto($langs->trans("WarningChangingThisMayBreakStopTaskScheduler"), 'info');
106 }
107} else {
108 print getDolGlobalString('CRON_KEY');
109 print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ? GETPOST('CRON_KEY') : getDolGlobalString('CRON_KEY')).'">';
110}
111print '</td>';
112print '<td>&nbsp;</td>';
113print '</tr>';
114
115print '</table>';
116
117print dol_get_fiche_end();
118
119if (!getDolGlobalString('CRON_DISABLE_KEY_CHANGE')) {
120 print $form->buttonsSaveCancel("Save", '');
121}
122
123print '</form>';
124
125
126print '<br><br><br>';
127
128//print $langs->trans("UseMenuModuleToolsToAddCronJobs", dol_buildpath('/cron/list.php?leftmenu=admintools', 1)).'<br>';
129if (getDolGlobalString('CRON_WARNING_DELAY_HOURS')) {
130 print info_admin($langs->trans("WarningCronDelayed", getDolGlobalString('CRON_WARNING_DELAY_HOURS'))).'<br>';
131}
132
133print '<br>';
134
136
137
138print '<br>';
139
140$constname = 'CRON_KEY';
141
142// Add button to autosuggest a key
143include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
144print dolJSToSetRandomPassword($constname);
145
146llxFooter();
147$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
cronadmin_prepare_head()
Return array of tabs to used on pages to setup cron module.
Definition cron.lib.php:31
dol_print_cron_urls()
Show information with URLs to launch jobs.
Definition cron.lib.php:89
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.