dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28// Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
32
42// Load translation files required by the page
43$langs->loadLangs(array('admin', 'cron'));
44
45if (!$user->admin) {
47}
48
49$actionsave = GETPOST("save", 'alphanohtml');
50
51// Save parameters
52if (!empty($actionsave)) {
53 $i = 0;
54
55 $db->begin();
56
57 $i += dolibarr_set_const($db, 'CRON_KEY', GETPOST("CRON_KEY"), 'chaine', 0, '', 0);
58
59 if ($i >= 1) {
60 $db->commit();
61 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
62 } else {
63 $db->rollback();
64 setEventMessages($langs->trans("Error"), null, 'errors');
65 }
66}
67
68
69/*
70 * View
71 */
72
73$help_url = '';
74llxHeader('', '', $help_url);
75
76$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
77print load_fiche_titre($langs->trans("CronSetup"), $linkback, 'title_setup');
78
79// Configuration header
81
82print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
83print '<input type="hidden" name="token" value="'.newToken().'">';
84
85print dol_get_fiche_head($head, 'setup', $langs->trans("Module2300Name"), -1, 'cron');
86
87print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>';
88
89print "<br>\n";
90
91print '<table class="noborder centpercent">';
92
93print '<tr class="liste_titre">';
94print "<td>".$langs->trans("Parameter")."</td>";
95print "<td>".$langs->trans("Value")."</td>";
96print "<td></td>";
97print "</tr>";
98
99// Security key for cron (if CRON_DISABLE_KEY_CHANGE is 1: modification is not allowed, -1: no button refresh)
100print '<tr class="oddeven">';
101print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
102$disabled = '';
103if (getDolGlobalInt('CRON_DISABLE_KEY_CHANGE') > 0) {
104 $disabled = ' disabled="disabled"';
105}
106print '<td>';
107if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') != 1) {
108 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')).'">';
109 if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') == 0) {
110 if (!empty($conf->use_javascript_ajax)) {
111 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
112 }
113 } elseif (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') == -1) {
114 $langs->load("errors");
115 print '&nbsp;'.img_picto($langs->trans("WarningChangingThisMayBreakStopTaskScheduler"), 'info');
116 }
117} else {
118 print getDolGlobalString('CRON_KEY');
119 print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ? GETPOST('CRON_KEY') : getDolGlobalString('CRON_KEY')).'">';
120}
121print '</td>';
122print '<td>&nbsp;</td>';
123print '</tr>';
124
125print '</table>';
126
127print dol_get_fiche_end();
128
129if (!getDolGlobalString('CRON_DISABLE_KEY_CHANGE')) {
130 print $form->buttonsSaveCancel("Save", '');
131}
132
133print '</form>';
134
135
136print '<br><br><br>';
137
138//print $langs->trans("UseMenuModuleToolsToAddCronJobs", dol_buildpath('/cron/list.php?leftmenu=admintools', 1)).'<br>';
139if (getDolGlobalString('CRON_WARNING_DELAY_HOURS')) {
140 print info_admin($langs->trans("WarningCronDelayed", getDolGlobalString('CRON_WARNING_DELAY_HOURS'))).'<br>';
141}
142
143print '<br>';
144
146
147
148print '<br>';
149
150$constname = 'CRON_KEY';
151
152// Add button to autosuggest a key
153include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
154print dolJSToSetRandomPassword($constname);
155
156llxFooter();
157$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
cronadmin_prepare_head()
Return array of tabs to used on pages to setup cron module.
Definition cron.lib.php:32
dol_print_cron_urls()
Show information with URLs to launch jobs.
Definition cron.lib.php:90
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
getDolGlobalString($key, $default='')
Return a 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.