dolibarr  17.0.4
agenda_xcal.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2008-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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 
27 // Load Dolibarr environment
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
31 
32 
33 if (!$user->admin) {
35 }
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array("admin", "other", "agenda"));
39 
40 $def = array();
41 $actionsave = GETPOST('save', 'alpha');
42 $MAIN_AGENDA_XCAL_EXPORTKEY = getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY');
43 $MAIN_AGENDA_EXPORT_PAST_DELAY = getDolGlobalInt('MAIN_AGENDA_EXPORT_PAST_DELAY');
44 $MAIN_AGENDA_EXPORT_CACHE = getDolGlobalInt('MAIN_AGENDA_EXPORT_CACHE');
45 $AGENDA_EXPORT_FIX_TZ = getDolGlobalString('AGENDA_EXPORT_FIX_TZ');
46 
47 if (GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) {
48  $MAIN_AGENDA_XCAL_EXPORTKEY = trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha'));
49 }
50 if (GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) {
51  $MAIN_AGENDA_EXPORT_PAST_DELAY = intval(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'int'));
52 }
53 if (GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) {
54  $MAIN_AGENDA_EXPORT_CACHE = intval(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'int'));
55 }
56 if (GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) {
57  $AGENDA_EXPORT_FIX_TZ = trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha'));
58 }
59 
60 // Sauvegardes parametres
61 if ($actionsave) {
62  $i = 0;
63 
64  $db->begin();
65 
66  $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', $MAIN_AGENDA_XCAL_EXPORTKEY, 'chaine', 0, '', $conf->entity);
67  $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', $MAIN_AGENDA_EXPORT_PAST_DELAY, 'chaine', 0, '', $conf->entity);
68  $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', $MAIN_AGENDA_EXPORT_CACHE, 'chaine', 0, '', $conf->entity);
69  $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', $AGENDA_EXPORT_FIX_TZ, 'chaine', 0, '', $conf->entity);
70 
71  if ($i >= 4) {
72  $db->commit();
73  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
74  } else {
75  $db->rollback();
76  setEventMessages($langs->trans("SaveFailed"), null, 'errors');
77  }
78 }
79 
80 
81 
86 if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
87  $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
88 }
89 
90 $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
91 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
92 
93 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
94 print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
95 
96 
97 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
98 print '<input type="hidden" name="token" value="'.newToken().'">';
99 
100 $head = agenda_prepare_head();
101 
102 print dol_get_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
103 
104 print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
105 print "<br>\n";
106 
107 print '<table class="noborder centpercent">';
108 
109 print '<tr class="liste_titre">';
110 print "<td>".$langs->trans("Parameter")."</td>";
111 print "<td>".$langs->trans("Value")."</td>";
112 //print "<td>".$langs->trans("Examples")."</td>";
113 print "<td>&nbsp;</td>";
114 print "</tr>";
115 
116 print '<tr class="oddeven">';
117 print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
118 print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.dol_escape_htmltag($MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
119 if (!empty($conf->use_javascript_ajax)) {
120  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
121 }
122 print '</td>';
123 print "<td>&nbsp;</td>";
124 print "</tr>";
125 
126 print '<tr class="oddeven">';
127 print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
128 print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"".$MAIN_AGENDA_EXPORT_PAST_DELAY."\" size=\"10\"> ".$langs->trans("days")."</td>";
129 print "<td>&nbsp;</td>";
130 print "</tr>";
131 
132 print '<tr class="oddeven">';
133 print "<td>".$langs->trans("UseACacheDelay")."</td>";
134 print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"".$MAIN_AGENDA_EXPORT_CACHE."\" size=\"10\"></td>";
135 print "<td>&nbsp;</td>";
136 print "</tr>";
137 
138 print '</table>';
139 
140 print '<br>';
141 
142 print '<table class="noborder centpercent">';
143 
144 print '<tr class="liste_titre">';
145 print '<td width="25%">'.$langs->trans("Parameter")."</td>";
146 print "<td>".$langs->trans("Value")."</td>";
147 print "</tr>";
148 print '<tr class="oddeven">';
149 print '<td>'.$langs->trans("FixTZ")."</td>";
150 print "<td>";
151 print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.dol_escape_htmltag($AGENDA_EXPORT_FIX_TZ).'">';
152 print ' &nbsp; '.$langs->trans("FillThisOnlyIfRequired");
153 print "</td>";
154 print "</tr>";
155 
156 print '</table>';
157 
158 print dol_get_fiche_end();
159 
160 print $form->buttonsSaveCancel("Save", '');
161 
162 print "</form>\n";
163 
164 
165 clearstatcache();
166 
167 //if ($mesg) print "<br>$mesg<br>";
168 print "<br>";
169 
170 
171 // Define $urlwithroot
172 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
173 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
174 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
175 $getentity = ($conf->entity > 1 ? "&entity=".$conf->entity : "");
176 
177 // Show message
178 $message = '';
179 
180 $urlvcal = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank" rel="noopener noreferrer">';
181 $urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
182 $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlvcal, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'vcal', '').'</span>');
183 $message .= '<div class="urllink">';
184 $message .= '<input type="text" id="onlinepaymenturl1" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">';
185 if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
186  $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'.img_picto('', 'download').'</a>';
187 }
188 $message .= '</div>';
189 $message .= ajax_autoselect('onlinepaymenturl1');
190 $message .= '<br>';
191 
192 $urlical = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank" rel="noopener noreferrer">';
193 $urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
194 $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlical, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', '').'</span>');
195 $message .= '<div class="urllink">';
196 $message .= '<input type="text" id="onlinepaymenturl2" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">';
197 if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
198  $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'.img_picto('', 'download').'</a>';
199 }
200 $message .= '</div>';
201 $message .= ajax_autoselect('onlinepaymenturl2');
202 $message .= '<br>';
203 
204 $urlrss = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank" rel="noopener noreferrer">';
205 $urlrss .= $urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
206 $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlrss, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'rss', '').'</span>');
207 $message .= '<div class="urllink">';
208 $message .= '<input type="text" id="onlinepaymenturl3" class="quatrevingtpercent" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">';
209 if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
210  $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'">'.img_picto('', 'download').'</a>';
211 }
212 $message .= '</div>';
213 $message .= ajax_autoselect('onlinepaymenturl3');
214 $message .= '<br>';
215 
216 print $message;
217 
218 $message = $langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
219 $message .= $langs->trans("AgendaUrlOptions3", $user->login, $user->login).'<br>';
220 $message .= $langs->trans("AgendaUrlOptionsNotAdmin", $user->login, $user->login).'<br>';
221 $message .= $langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
222 $message .= $langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
223 $message .= $langs->trans("AgendaUrlOptionsNotAutoEvent", 'systemauto', 'systemauto').'<br>';
224 $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
225 
226 print info_admin($message);
227 
228 $constname = 'MAIN_AGENDA_XCAL_EXPORTKEY';
229 
230 // Add button to autosuggest a key
231 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
232 print dolJSToSetRandomPassword($constname);
233 
234 // End of page
235 llxFooter();
236 $db->close();
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:632
agenda_prepare_head()
Prepare array with list of tabs.
Definition: agenda.lib.php:364
if(GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) if(GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:90
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.