dolibarr/htdocs/cron/admin/cron.php

158 lines
4.8 KiB
PHP
Raw Permalink Normal View History

2013-03-13 19:55:21 +01:00
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
* \file cron/admin/cron.php
* \ingroup cron
*/
2013-03-13 19:55:21 +01:00
2013-03-22 17:10:17 +01:00
// Dolibarr environment
2018-07-26 11:57:25 +02:00
require '../../main.inc.php';
2013-03-13 19:55:21 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
2013-03-22 17:10:17 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
2013-03-13 19:55:21 +01:00
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
/**
* @var Conf $conf
* @var DoliDB $db
* @var Form $form
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
2018-05-26 20:51:17 +02:00
// Load translation files required by the page
$langs->loadLangs(array('admin', 'cron'));
2013-03-13 19:55:21 +01:00
2021-02-28 23:47:30 +01:00
if (!$user->admin) {
2013-03-13 19:55:21 +01:00
accessforbidden();
2021-02-28 23:47:30 +01:00
}
2013-03-13 19:55:21 +01:00
2020-11-21 14:14:53 +01:00
$actionsave = GETPOST("save", 'alphanohtml');
2013-03-13 19:55:21 +01:00
2015-11-21 05:20:08 +01:00
// Save parameters
2021-02-28 23:47:30 +01:00
if (!empty($actionsave)) {
$i = 0;
2013-03-22 17:10:17 +01:00
$db->begin();
$i += dolibarr_set_const($db, 'CRON_KEY', GETPOST("CRON_KEY"), 'chaine', 0, '', 0);
2013-03-22 17:10:17 +01:00
2021-02-28 23:47:30 +01:00
if ($i >= 1) {
2013-03-22 17:10:17 +01:00
$db->commit();
2015-11-21 05:20:08 +01:00
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
2020-05-21 15:05:19 +02:00
} else {
2013-03-22 17:10:17 +01:00
$db->rollback();
2015-11-21 05:20:08 +01:00
setEventMessages($langs->trans("Error"), null, 'errors');
2013-03-22 17:10:17 +01:00
}
2013-03-13 19:55:21 +01:00
}
/*
* View
*/
2013-03-13 19:55:21 +01:00
$help_url = '';
llxHeader('', '', $help_url);
2013-03-13 19:55:21 +01:00
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("CronSetup"), $linkback, 'title_setup');
2013-03-13 19:55:21 +01:00
2013-03-22 17:10:17 +01:00
// Configuration header
$head = cronadmin_prepare_head();
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'setup', $langs->trans("Module2300Name"), -1, 'cron');
2013-03-22 17:10:17 +01:00
2020-11-21 14:14:53 +01:00
print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>';
2013-03-13 19:55:21 +01:00
print "<br>\n";
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
2013-03-13 19:55:21 +01:00
print '<tr class="liste_titre">';
print "<td>".$langs->trans("Parameter")."</td>";
print "<td>".$langs->trans("Value")."</td>";
print "<td></td>";
2013-03-13 19:55:21 +01:00
print "</tr>";
2024-06-09 17:35:05 +02:00
// Security key for cron (if CRON_DISABLE_KEY_CHANGE is 1: modification is not allowed, -1: no button refresh)
print '<tr class="oddeven">';
2013-03-13 19:55:21 +01:00
print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
$disabled = '';
2024-06-09 17:35:05 +02:00
if (getDolGlobalInt('CRON_DISABLE_KEY_CHANGE') > 0) {
2021-02-28 23:47:30 +01:00
$disabled = ' disabled="disabled"';
}
print '<td>';
2024-06-09 17:35:05 +02:00
if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') != 1) {
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')).'">';
2024-06-09 17:35:05 +02:00
if (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') == 0) {
if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
} elseif (getDolGlobalString('CRON_DISABLE_KEY_CHANGE') == -1) {
$langs->load("errors");
print '&nbsp;'.img_picto($langs->trans("WarningChangingThisMayBreakStopTaskScheduler"), 'info');
2021-02-28 23:47:30 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2024-06-09 17:35:05 +02:00
print getDolGlobalString('CRON_KEY');
print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'.(GETPOST('CRON_KEY') ? GETPOST('CRON_KEY') : getDolGlobalString('CRON_KEY')).'">';
}
2013-03-13 19:55:21 +01:00
print '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
print '</table>';
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
if (!getDolGlobalString('CRON_DISABLE_KEY_CHANGE')) {
print $form->buttonsSaveCancel("Save", '');
}
2013-03-13 19:55:21 +01:00
print '</form>';
2019-03-11 20:54:25 +01:00
print '<br><br><br>';
2013-03-13 19:55:21 +01:00
2020-11-21 14:14:53 +01:00
//print $langs->trans("UseMenuModuleToolsToAddCronJobs", dol_buildpath('/cron/list.php?leftmenu=admintools', 1)).'<br>';
2023-11-27 11:39:32 +01:00
if (getDolGlobalString('CRON_WARNING_DELAY_HOURS')) {
2024-01-05 04:18:53 +01:00
print info_admin($langs->trans("WarningCronDelayed", getDolGlobalString('CRON_WARNING_DELAY_HOURS'))).'<br>';
2021-02-28 23:47:30 +01:00
}
2019-03-11 20:54:25 +01:00
print '<br>';
2013-03-13 19:55:21 +01:00
dol_print_cron_urls();
2013-03-13 19:55:21 +01:00
print '<br>';
$constname = 'CRON_KEY';
// Add button to autosuggest a key
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
print dolJSToSetRandomPassword($constname);
2013-03-13 19:55:21 +01:00
llxFooter();
2018-05-26 20:51:17 +02:00
$db->close();