dolibarr  7.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  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
32 {
33  global $langs, $conf, $user;
34  $h = 0;
35  $head = array();
36 
37  $head[$h][0] = dol_buildpath('/cron/admin/cron.php', 1);
38  $head[$h][1] = $langs->trans("Miscellaneous");
39  $head[$h][2] = 'setup';
40  $h++;
41 
42  complete_head_from_modules($conf, $langs, null, $head, $h, 'cronadmin');
43 
44  complete_head_from_modules($conf, $langs, null, $head, $h, 'cronadmin', 'remove');
45 
46 
47  return $head;
48 }
49 
56 function cron_prepare_head(Cronjob $object)
57 {
58  global $langs, $conf, $user;
59  $h = 0;
60  $head = array();
61 
62  $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id;
63  $head[$h][1] = $langs->trans("CronTask");
64  $head[$h][2] = 'card';
65  $h++;
66 
67  $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id;
68  $head[$h][1] = $langs->trans("Info");
69  $head[$h][2] = 'info';
70  $h++;
71 
72  complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron');
73 
74  complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove');
75 
76  return $head;
77 }
78 
85 {
86  global $conf, $langs, $user;
87  global $dolibarr_main_url_root;
88 
89  // Define $urlwithroot
90  $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
91  $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
92  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
93 
94  // Cron launch
95  print '<div class="div-table-responsive-no-min">';
96  print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
97  $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98  print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
99  print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
100  $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101  print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
102  print '</div>';
103  print '<br>';
104 
105  $logintouse = 'firstadmin';
106  if ($user->admin) $logintouse = $user->login;
107 
108  print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
109 
110  $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
111  print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n";
112  print '<br>';
113 
114  // Add note
115  if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
116  {
117  $linuxlike=1;
118  if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
119  if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
120  print $langs->trans("Note").': ';
121  if ($linuxlike)
122  {
123  print $langs->trans("CronExplainHowToRunUnix");
124  print '<br>';
125  print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
126  }
127  else
128  {
129  print $langs->trans("CronExplainHowToRunWin");
130  }
131  }
132 
133  return 0;
134 }
135 
136 
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
cron_prepare_head(Cronjob $object)
Return array of tabs to used on a cron job.
Definition: cron.lib.php:56
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_print_cron_urls()
Show information with URLs to launch jobs.
Definition: cron.lib.php:84
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
cronadmin_prepare_head()
Return array of tabs to used on pages to setup cron module.
Definition: cron.lib.php:31
print
Draft customers invoices.
Definition: index.php:91
Crob Job class.