dolibarr 21.0.0-alpha
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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
33{
34 global $langs, $conf, $user;
35 $h = 0;
36 $head = array();
37
38 $head[$h][0] = DOL_URL_ROOT.'/cron/admin/cron.php';
39 $head[$h][1] = $langs->trans("Miscellaneous");
40 $head[$h][2] = 'setup';
41 $h++;
42
43 $head[$h][0] = DOL_URL_ROOT.'/cron/list.php?mode=modulesetup';
44 $head[$h][1] = $langs->trans("Module2300Name");
45 $head[$h][2] = 'jobs';
46 $h++;
47
48 complete_head_from_modules($conf, $langs, null, $head, $h, 'cronadmin');
49
50 complete_head_from_modules($conf, $langs, null, $head, $h, 'cronadmin', 'remove');
51
52
53 return $head;
54}
55
63{
64 global $langs, $conf, $user;
65 $h = 0;
66 $head = array();
67
68 $head[$h][0] = DOL_URL_ROOT.'/cron/card.php?id='.$object->id;
69 $head[$h][1] = $langs->trans("CronTask");
70 $head[$h][2] = 'card';
71 $h++;
72
73 $head[$h][0] = DOL_URL_ROOT.'/cron/info.php?id='.$object->id;
74 $head[$h][1] = $langs->trans("Info");
75 $head[$h][2] = 'info';
76 $h++;
77
78 complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron');
79
80 complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove');
81
82 return $head;
83}
84
91{
92 global $conf, $langs, $user;
93 global $dolibarr_main_url_root;
94
95 // Define $urlwithroot
96 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
97 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
98 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
99
100 // Cron launch
101 print '<div class="div-table-responsive-no-min">';
102 print $langs->trans("URLToLaunchCronJobs").':<br>';
103 $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(!getDolGlobalString('CRON_KEY') ? '' : 'securitykey=' . getDolGlobalString('CRON_KEY').'&').'userlogin='.$user->login;
104 print '<div class="urllink">';
105 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$url.'">';
106 print ' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe')."</a>\n";
107 print '</div>';
108 print '<br> '.$langs->trans("OrToLaunchASpecificJob").'<br>';
109 $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(!getDolGlobalString('CRON_KEY') ? '' : 'securitykey=' . getDolGlobalString('CRON_KEY').'&').'userlogin='.$user->login.'&id=cronjobid';
110 print '<div class="urllink">';
111 print '<input type="text" id="publicurlmemberall" class="quatrevingtpercentminusx" value="'.$url.'">';
112 print ' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe')."</a>\n";
113 print '</div>';
114 print '</div>';
115 print '<br>';
116
117 print ajax_autoselect("publicurlmember");
118 print ajax_autoselect("publicurlmemberall");
119
120 $logintouse = 'firstadmin';
121 if ($user->admin) {
122 $logintouse = $user->login;
123 }
124
125 print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
126
127 $pathtoscript = '/pathtoscript';
128 if (getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT')) {
129 $pathtoscript = getDolGlobalString('MAIN_DOL_SCRIPTS_ROOT');
130 }
131
132 $file = $pathtoscript.'/scripts/cron/cron_run_jobs.php '.(!getDolGlobalString('CRON_KEY') ? 'securitykey' : '' . getDolGlobalString('CRON_KEY')).' '.$logintouse.' [cronjobid]';
133 print '<textarea class="quatrevingtpercent">'.$file."</textarea><br>\n";
134 print '<br>';
135
136 // Add note
137 if (!getDolGlobalString('CRON_DISABLE_TUTORIAL_CRON')) {
138 $linuxlike = 1;
139 if (preg_match('/^win/i', PHP_OS)) {
140 $linuxlike = 0;
141 }
142 if (preg_match('/^mac/i', PHP_OS)) {
143 $linuxlike = 0;
144 }
145 print $langs->trans("Note").': ';
146 if ($linuxlike) {
147 print $langs->trans("CronExplainHowToRunUnix");
148 print '<br>';
149 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>';
150 } else {
151 print $langs->trans("CronExplainHowToRunWin");
152 }
153 }
154
155 return 0;
156}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Cron Job class.
cron_prepare_head(Cronjob $object)
Return array of tabs to used on a cron job.
Definition cron.lib.php:62
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
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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.