dolibarr 21.0.0-alpha
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
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
31
32
33if (!$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 = getDolGlobalString('MAIN_AGENDA_EXPORT_PAST_DELAY', 100);
44$MAIN_AGENDA_EXPORT_CACHE = getDolGlobalInt('MAIN_AGENDA_EXPORT_CACHE');
45$AGENDA_EXPORT_FIX_TZ = getDolGlobalString('AGENDA_EXPORT_FIX_TZ');
46
47if (GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) {
48 $MAIN_AGENDA_XCAL_EXPORTKEY = trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha'));
49}
50if (GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) {
51 $MAIN_AGENDA_EXPORT_PAST_DELAY = intval(GETPOSTINT('MAIN_AGENDA_EXPORT_PAST_DELAY'));
52}
53if (GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) {
54 $MAIN_AGENDA_EXPORT_CACHE = intval(GETPOSTINT('MAIN_AGENDA_EXPORT_CACHE'));
55}
56if (GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) {
57 $AGENDA_EXPORT_FIX_TZ = trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha'));
58}
59
60// Sauvegardes parameters
61if ($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
86if (!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|DE:Modul_Terminplanung';
91llxHeader('', $langs->trans("AgendaSetup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-agenda_xcal');
92
93$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
94print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
95
96
97print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
98print '<input type="hidden" name="token" value="'.newToken().'">';
99
100$head = agenda_prepare_head();
101
102print dol_get_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
103
104print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
105print "<br>\n";
106
107print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
108print '<table class="noborder centpercent">';
109
110print '<tr class="liste_titre">';
111print "<td>".$langs->trans("Parameter")."</td>";
112print "<td>".$langs->trans("Value")."</td>";
113//print "<td>".$langs->trans("Examples")."</td>";
114print "<td>&nbsp;</td>";
115print "</tr>";
116
117print '<tr class="oddeven">';
118print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
119print '<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).'">';
120if (!empty($conf->use_javascript_ajax)) {
121 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
122}
123print '</td>';
124print "<td>&nbsp;</td>";
125print "</tr>";
126
127print '<tr class="oddeven">';
128print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
129print '<td><input type="text" class="flat width50 right" name="MAIN_AGENDA_EXPORT_PAST_DELAY" value="'.$MAIN_AGENDA_EXPORT_PAST_DELAY.'"> '.$langs->trans("days")."</td>";
130print "<td>&nbsp;</td>";
131print "</tr>";
132
133print '<tr class="oddeven">';
134print "<td>".$langs->trans("UseACacheDelay")."</td>";
135print '<td><input type="text" class="flat width50 right" name="MAIN_AGENDA_EXPORT_CACHE" value="'.$MAIN_AGENDA_EXPORT_CACHE.'"></td>';
136print "<td>&nbsp;</td>";
137print "</tr>";
138
139print '</table>';
140print '</div>';
141
142print '<br>';
143
144print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
145print '<table class="noborder centpercent">';
146
147print '<tr class="liste_titre">';
148print '<td width="25%">'.$langs->trans("Parameter")."</td>";
149print "<td>".$langs->trans("Value")."</td>";
150print "</tr>";
151print '<tr class="oddeven">';
152print '<td>'.$langs->trans("FixTZ")."</td>";
153print "<td>";
154print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.dol_escape_htmltag($AGENDA_EXPORT_FIX_TZ).'">';
155print ' &nbsp; '.$langs->trans("FillThisOnlyIfRequired");
156print "</td>";
157print "</tr>";
158
159print '</table>';
160print '</div>';
161
162print dol_get_fiche_end();
163
164print $form->buttonsSaveCancel("Save", '');
165
166print "</form>\n";
167
168
169clearstatcache();
170
171//if ($mesg) print "<br>$mesg<br>";
172print "<br>";
173
174
175// Define $urlwithroot
176$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
177$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
178//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
179$getentity = ($conf->entity > 1 ? "&entity=".$conf->entity : "");
180
181// Show message
182$message = '';
183
184$urlvcal = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'" target="_blank" rel="noopener noreferrer">';
185$urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : 'KEYNOTDEFINED').'</a>';
186$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlvcal, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'vcal', '').'</span>');
187$message .= '<div class="urllink">';
188$message .= '<input type="text" id="onlinepaymenturl1" class="quatrevingtpercent" spellcheck="false" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'">';
189if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
190 $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'">'.img_picto('', 'download').'</a>';
191}
192$message .= '</div>';
193$message .= ajax_autoselect('onlinepaymenturl1');
194$message .= '<br>';
195
196$urlical = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'" target="_blank" rel="noopener noreferrer">';
197$urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : 'KEYNOTDEFINED').'</a>';
198$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlical, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', '').'</span>');
199$message .= '<div class="urllink">';
200$message .= '<input type="text" id="onlinepaymenturl2" class="quatrevingtpercent" spellcheck="false" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'">';
201if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
202 $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'">'.img_picto('', 'download').'</a>';
203}
204$message .= '</div>';
205$message .= ajax_autoselect('onlinepaymenturl2');
206$message .= '<br>';
207
208$urlrss = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'" target="_blank" rel="noopener noreferrer">';
209$urlrss .= $urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : 'KEYNOTDEFINED').'</a>';
210$message .= img_picto('', 'globe').' '.str_replace('{url}', $urlrss, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'rss', '').'</span>');
211$message .= '<div class="urllink">';
212$message .= '<input type="text" id="onlinepaymenturl3" class="quatrevingtpercent" spellcheck="false" value="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'">';
213if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
214 $message .= ' <a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) : '...').'">'.img_picto('', 'download').'</a>';
215}
216$message .= '</div>';
217$message .= ajax_autoselect('onlinepaymenturl3');
218$message .= '<br>';
219
220print $message;
221
222$message = $langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
223$message .= $langs->trans("AgendaUrlOptions3", $user->login, $user->login, $user->login).'<br>';
224$message .= $langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
225$message .= $langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
226$message .= $langs->trans("AgendaUrlOptionsType", 'systemauto|system').'<br>';
227$message .= $langs->trans("AgendaUrlOptionsCode", 'AC_COMPANY_CREATE,AC_PROPAL_VALIDATE,AC_CODE...').'<br>';
228$message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
229//$defaultnotolderthan = getDolGlobalString('MAIN_AGENDA_EXPORT_PAST_DELAY', 100);
230//$message .= $langs->trans("AgendaUrlOptionsLimitDays", $defaultnotolderthan, $defaultnotolderthan, $defaultnotolderthan).'<br>';
231$message .= $langs->trans("AgendaUrlOptionsLimit", '1000').'<br>';
232
233print info_admin($message);
234
235$constname = 'MAIN_AGENDA_XCAL_EXPORTKEY';
236
237// Add button to autosuggest a key
238include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
239print dolJSToSetRandomPassword($constname);
240
241// End of page
242llxFooter();
243$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).
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) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
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:70
llxFooter()
Footer empty.
Definition document.php:107
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)
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)
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.
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.