dolibarr 24.0.0-beta
cron.lib.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@opn-concept.pro>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
34{
35 global $langs, $conf, $user;
36 $h = 0;
37 $head = array();
38
39 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/admin/cron.php');
40 $head[$h][1] = $langs->trans("Miscellaneous");
41 $head[$h][2] = 'setup';
42 $h++;
43
44 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/list.php', ['mode' => 'modulesetup']);
45 $head[$h][1] = $langs->trans("Module2300Name");
46 $head[$h][2] = 'jobs';
47 $h++;
48
49 complete_head_from_modules($conf, $langs, null, $head, $h, 'cronadmin');
50
51 complete_head_from_modules($conf, $langs, null, $head, $h, 'cronadmin', 'remove');
52
53
54 return $head;
55}
56
64{
65 global $langs, $conf, $user;
66 $h = 0;
67 $head = array();
68
69 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/card.php', ['id' => $object->id]);
70 $head[$h][1] = $langs->trans("CronTask");
71 $head[$h][2] = 'card';
72 $h++;
73
74 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/cron/info.php', ['id' => $object->id]);
75 $head[$h][1] = $langs->trans("Info");
76 $head[$h][2] = 'info';
77 $h++;
78
79 complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron');
80
81 complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove');
82
83 return $head;
84}
85
92{
93 global $conf, $langs, $user;
95
96 // Define $urlwithroot
97 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
98 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
99 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
100
101 // Cron launch
102 print '<div class="div-table-responsive-no-min">';
103 print $langs->trans("URLToLaunchCronJobs").':<br>';
104 $query = [
105 'securitykey' => getDolGlobalString('CRON_KEY'),
106 'userlogin' => $user->login,
107 ];
108 $url = dolBuildUrl($urlwithroot.'/public/cron/cron_run_jobs_by_url.php', $query);
109 print '<div class="urllink">';
110 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$url.'">';
111 print ' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe')."</a>\n";
112 print '</div>';
113 print '<br> '.$langs->trans("OrToLaunchASpecificJob").'<br>';
114 $query += ['id' => 'cronjobid'];
115 $url = dolBuildUrl($urlwithroot.'/public/cron/cron_run_jobs_by_url.php', $query);
116 print '<div class="urllink">';
117 print '<input type="text" id="publicurlmemberall" class="quatrevingtpercentminusx" value="'.$url.'">';
118 print ' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe')."</a>\n";
119 print '</div>';
120 print '</div>';
121 print '<br>';
122
123 print ajax_autoselect("publicurlmember");
124 print ajax_autoselect("publicurlmemberall");
125
126 $logintouse = 'firstadmin';
127 if ($user->admin) {
128 $logintouse = $user->login;
129 }
130
131 print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
132
133 $pathtoscript = '/pathtoscript';
134 if (getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT')) {
135 $pathtoscript = getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT');
136 }
137
138 $file = $pathtoscript.'/scripts/cron/cron_run_jobs.php '.(!getDolGlobalString('CRON_KEY') ? 'securitykey' : '' . getDolGlobalString('CRON_KEY')).' '.$logintouse.' [cronjobid]';
139 print '<textarea class="quatrevingtpercent">'.$file."</textarea><br>\n";
140 print '<br>';
141
142 // Add note
143 if (!getDolGlobalString('CRON_DISABLE_TUTORIAL_CRON')) {
144 $linuxlike = 1;
145 if (preg_match('/^win/i', PHP_OS)) {
146 $linuxlike = 0;
147 }
148 if (preg_match('/^mac/i', PHP_OS)) {
149 $linuxlike = 0;
150 }
151 print $langs->trans("Note").': ';
152 if ($linuxlike) {
153 print $langs->trans("CronExplainHowToRunUnix");
154 print '<br>';
155 print '<textarea class="quatrevingtpercent">*/5 * * * * '.$pathtoscript.'/scripts/cron/cron_run_jobs.php '.(!getDolGlobalString('CRON_KEY') ? 'securitykey' : '' . getDolGlobalString('CRON_KEY')).' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
156 } else {
157 print $langs->trans("CronExplainHowToRunWin");
158 }
159 }
160
161 return 0;
162}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
global $dolibarr_main_url_root
Cron Job class.
cron_prepare_head(Cronjob $object)
Return array of tabs to used on a cron job.
Definition cron.lib.php:63
cronadmin_prepare_head()
Return array of tabs to used on pages to setup cron module.
Definition cron.lib.php:33
dol_print_cron_urls()
Show information with URLs to launch jobs.
Definition cron.lib.php:91
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.