dolibarr 22.0.5
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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
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 <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
32
33
45if (!$user->admin) {
47}
48
49// Load translation files required by the page
50$langs->loadLangs(array("admin", "other", "agenda"));
51
52$def = array();
53$actionsave = GETPOST('save', 'alpha');
54$MAIN_AGENDA_XCAL_EXPORTKEY = getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY');
55$MAIN_AGENDA_EXPORT_PAST_DELAY = getDolGlobalString('MAIN_AGENDA_EXPORT_PAST_DELAY', 100);
56$MAIN_AGENDA_EXPORT_CACHE = getDolGlobalInt('MAIN_AGENDA_EXPORT_CACHE');
57$AGENDA_EXPORT_FIX_TZ = getDolGlobalString('AGENDA_EXPORT_FIX_TZ');
58
59if (GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) {
60 $MAIN_AGENDA_XCAL_EXPORTKEY = trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha'));
61}
62if (GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) {
63 $MAIN_AGENDA_EXPORT_PAST_DELAY = intval(GETPOSTINT('MAIN_AGENDA_EXPORT_PAST_DELAY'));
64}
65if (GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) {
66 $MAIN_AGENDA_EXPORT_CACHE = intval(GETPOSTINT('MAIN_AGENDA_EXPORT_CACHE'));
67}
68if (GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) {
69 $AGENDA_EXPORT_FIX_TZ = trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha'));
70}
71
72// Sauvegardes parameters
73if ($actionsave) {
74 $i = 0;
75
76 $db->begin();
77
78 $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', $MAIN_AGENDA_XCAL_EXPORTKEY, 'chaine', 0, '', $conf->entity);
79 $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', $MAIN_AGENDA_EXPORT_PAST_DELAY, 'chaine', 0, '', $conf->entity);
80 $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', $MAIN_AGENDA_EXPORT_CACHE, 'chaine', 0, '', $conf->entity);
81 $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', $AGENDA_EXPORT_FIX_TZ, 'chaine', 0, '', $conf->entity);
82
83 if ($i >= 4) {
84 $db->commit();
85 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
86 } else {
87 $db->rollback();
88 setEventMessages($langs->trans("SaveFailed"), null, 'errors');
89 }
90}
91
92
93
98$form = new Form($db);
99
100if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
101 $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
102}
103
104$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
105llxHeader('', $langs->trans("AgendaSetup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-agenda_xcal');
106
107$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
108print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
109
110
111print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
112print '<input type="hidden" name="token" value="'.newToken().'">';
113
114$head = agenda_prepare_head();
115
116print dol_get_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
117
118print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
119print "<br>\n";
120
121print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
122print '<table class="noborder centpercent">';
123
124print '<tr class="liste_titre">';
125print "<td>".$langs->trans("Parameter")."</td>";
126print "<td></td>";
127//print "<td>".$langs->trans("Examples")."</td>";
128print "<td>&nbsp;</td>";
129print "</tr>";
130
131print '<tr class="oddeven">';
132print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
133print '<td><input required="required" type="text" class="flat minwidth100 maxwidth300 widthcentpercentminusx" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.dol_escape_htmltag($MAIN_AGENDA_XCAL_EXPORTKEY).'">';
134if (!empty($conf->use_javascript_ajax)) {
135 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
136}
137print '</td>';
138print "<td>&nbsp;</td>";
139print "</tr>";
140
141print '<tr class="oddeven">';
142print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
143print '<td><input type="text" class="flat width50 right" name="MAIN_AGENDA_EXPORT_PAST_DELAY" value="'.$MAIN_AGENDA_EXPORT_PAST_DELAY.'"> <span class="opacitymedium">'.$langs->trans("days")."</span></td>";
144print "<td>&nbsp;</td>";
145print "</tr>";
146
147print '<tr class="oddeven">';
148print "<td>".$langs->trans("UseACacheDelay")."</td>";
149print '<td><input type="text" class="flat width50 right" name="MAIN_AGENDA_EXPORT_CACHE" value="'.$MAIN_AGENDA_EXPORT_CACHE.'"> <span class="opacitymedium">'.$langs->trans("seconds").'</span></td>';
150print "<td>&nbsp;</td>";
151print "</tr>";
152
153print '</table>';
154print '</div>';
155
156print '<br>';
157
158print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
159print '<table class="noborder centpercent">';
160
161print '<tr class="liste_titre">';
162print '<td width="25%">'.$langs->trans("Parameter")."</td>";
163print "<td>".$langs->trans("Value")."</td>";
164print "</tr>";
165print '<tr class="oddeven">';
166print '<td>'.$langs->trans("FixTZ")."</td>";
167print "<td>";
168print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.dol_escape_htmltag($AGENDA_EXPORT_FIX_TZ).'">';
169print ' &nbsp; <span class="opacitymedium">'.$langs->trans("FillThisOnlyIfRequired").'</span>';
170print "</td>";
171print "</tr>";
172
173print '</table>';
174print '</div>';
175
176print dol_get_fiche_end();
177
178print $form->buttonsSaveCancel("Save", '');
179
180print "</form>\n";
181
182
183clearstatcache();
184
185
186print "<br><br><br>";
187
188
189// Define $urlwithroot
190$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
191$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
192//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
193$getentity = ($conf->entity > 1 ? "&entity=".$conf->entity : "");
194
195// Show message
196$message = '';
197
198$urlvcal = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'" target="_blank" rel="noopener noreferrer">';
199$urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', 'KEYNOTDEFINED')).'</a>';
200$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlvcal, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'vcal', '').'</span>');
201$message .= '<div class="urllink">';
202$message .= '<input type="text" id="onlinepaymenturl1" class="quatrevingtpercentminusx" spellcheck="false" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'">';
203if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
204 $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'">'.img_picto('', 'download').'</a>';
205}
206$message .= '</div>';
207$message .= ajax_autoselect('onlinepaymenturl1');
208$message .= '<br>';
209
210$urlical = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'" target="_blank" rel="noopener noreferrer">';
211$urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'</a>';
212$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlical, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', '').'</span>');
213$message .= '<div class="urllink">';
214$message .= '<input type="text" id="onlinepaymenturl2" class="quatrevingtpercentminusx" spellcheck="false" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'">';
215if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
216 $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'">'.img_picto('', 'download').'</a>';
217}
218$message .= '</div>';
219$message .= ajax_autoselect('onlinepaymenturl2');
220$message .= '<br>';
221
222$urlrss = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'" target="_blank" rel="noopener noreferrer">';
223$urlrss .= $urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'</a>';
224$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlrss, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'rss', '').'</span>');
225$message .= '<div class="urllink">';
226$message .= '<input type="text" id="onlinepaymenturl3" class="quatrevingtpercentminusx" spellcheck="false" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'">';
227if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
228 $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY', '...')).'">'.img_picto('', 'download').'</a>';
229}
230$message .= '</div>';
231$message .= ajax_autoselect('onlinepaymenturl3');
232$message .= '<br>';
233
234print $message;
235
236$message = $langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
237$message .= $langs->trans("AgendaUrlOptions3", $user->login, $user->login, $user->login).'<br>';
238$message .= $langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
239$message .= $langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
240$message .= $langs->trans("AgendaUrlOptionsType", 'systemauto|system').'<br>';
241$message .= $langs->trans("AgendaUrlOptionsCode", 'AC_COMPANY_CREATE,AC_PROPAL_VALIDATE,AC_CODE...').'<br>';
242$message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
243//$defaultnotolderthan = getDolGlobalString('MAIN_AGENDA_EXPORT_PAST_DELAY', 100);
244//$message .= $langs->trans("AgendaUrlOptionsLimitDays", 'X', 'X', $defaultnotolderthan).'<br>'; // This option is hidden because already set and defined into previous options
245$message .= $langs->trans("AgendaUrlOptionsLimit", '1000').'<br>';
246
247print info_admin($message);
248
249$constname = 'MAIN_AGENDA_XCAL_EXPORTKEY';
250
251// Add button to autosuggest a key
252include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
253print dolJSToSetRandomPassword($constname);
254
255// End of page
256llxFooter();
257$db->close();
global $dolibarr_main_url_root
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).
agenda_prepare_head()
Prepare array with list of tabs.
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) $form
View.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript 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.