dolibarr  7.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@capnetworks.com>
6  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 // Dolibarr environment
28 $res = @include("../../main.inc.php"); // From htdocs directory
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
31 
32 $langs->load("admin");
33 $langs->load("cron");
34 
35 if (! $user->admin)
37 
38 $actionsave=GETPOST("save");
39 
40 // Save parameters
41 if (!empty($actionsave))
42 {
43  $i=0;
44 
45  $db->begin();
46 
47  $i+=dolibarr_set_const($db,'CRON_KEY',trim(GETPOST("CRON_KEY")),'chaine',0,'',0);
48 
49  if ($i >= 1)
50  {
51  $db->commit();
52  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
53  }
54  else
55  {
56  $db->rollback();
57  setEventMessages($langs->trans("Error"), null, 'errors');
58  }
59 }
60 
61 
62 /*
63  * View
64  */
65 
66 llxHeader();
67 
68 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
69 print load_fiche_titre($langs->trans("CronSetup"),$linkback,'title_setup');
70 
71 // Configuration header
72 $head = cronadmin_prepare_head();
73 
74 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
75 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76 
77 dol_fiche_head($head, 'setup', $langs->trans("Module2300Name"), -1, 'cron');
78 
79 print "<br>\n";
80 
81 print '<table class="noborder" width="100%">';
82 
83 print '<tr class="liste_titre">';
84 print "<td>".$langs->trans("Parameter")."</td>";
85 print "<td>".$langs->trans("Value")."</td>";
86 print "<td>&nbsp;</td>";
87 print "</tr>";
88 
89 print '<tr class="impair">';
90 print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
91 $disabled='';
92 if (! empty($conf->global->CRON_DISABLE_KEY_CHANGE)) $disabled=' disabled="disabled"';
93 print '<td>';
94 if (empty($conf->global->CRON_DISABLE_KEY_CHANGE))
95 {
96  print '<input type="text" class="flat minwidth200"'.$disabled.' id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '">';
97  if (! empty($conf->use_javascript_ajax))
98  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
99 }
100 else
101 {
102  print (! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'');
103  print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '">';
104 }
105 print '</td>';
106 print '<td>&nbsp;</td>';
107 print '</tr>';
108 
109 print '</table>';
110 
111 dol_fiche_end();
112 
113 print '<div class="center">';
114 print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
115 print '</div>';
116 
117 print '</form>';
118 
119 
120 print '<br><br>';
121 
122 print $langs->trans("UseMenuModuleToolsToAddCronJobs").'<br>';
123 if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) print info_admin($langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS));
124 
125 print '<br><br>';
126 
128 
129 
130 print '<br>';
131 
132 if (! empty($conf->use_javascript_ajax))
133 {
134  print "\n".'<script type="text/javascript">';
135  print '$(document).ready(function () {
136  $("#generate_token").click(function() {
137  $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
138  action: \'getrandompassword\',
139  generic: true
140 },
141  function(token) {
142  $("#CRON_KEY").val(token);
143 });
144 });
145 });';
146  print '</script>';
147 }
148 
149 llxFooter();
150 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
dol_print_cron_urls()
Show information with URLs to launch jobs.
Definition: cron.lib.php:84
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).
Definition: admin.lib.php:485
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
cronadmin_prepare_head()
Return array of tabs to used on pages to setup cron module.
Definition: cron.lib.php:31
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1')
Show information for admin users or standard users.
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91