dolibarr  x.y.z
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 
43 // Sauvegardes parametres
44 if ($actionsave) {
45  $i = 0;
46 
47  $db->begin();
48 
49  $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity);
50  $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity);
51  $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
52  $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
53 
54  if ($i >= 4) {
55  $db->commit();
56  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
57  } else {
58  $db->rollback();
59  setEventMessages($langs->trans("SaveFailed"), null, 'errors');
60  }
61 }
62 
63 
64 
69 if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
70  $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
71 }
72 
73 $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
74 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
75 
76 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
77 print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
78 
79 
80 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
81 print '<input type="hidden" name="token" value="'.newToken().'">';
82 
83 $head = agenda_prepare_head();
84 
85 print dol_get_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
86 
87 print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
88 print "<br>\n";
89 
90 print '<table class="noborder centpercent">';
91 
92 print '<tr class="liste_titre">';
93 print "<td>".$langs->trans("Parameter")."</td>";
94 print "<td>".$langs->trans("Value")."</td>";
95 //print "<td>".$langs->trans("Examples")."</td>";
96 print "<td>&nbsp;</td>";
97 print "</tr>";
98 
99 print '<tr class="oddeven">';
100 print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
101 print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
102 if (!empty($conf->use_javascript_ajax)) {
103  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
104 }
105 print '</td>';
106 print "<td>&nbsp;</td>";
107 print "</tr>";
108 
109 print '<tr class="oddeven">';
110 print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
111 print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"".(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha') ?GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha') : $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)."\" size=\"10\"> ".$langs->trans("days")."</td>";
112 print "<td>&nbsp;</td>";
113 print "</tr>";
114 
115 print '<tr class="oddeven">';
116 print "<td>".$langs->trans("UseACacheDelay")."</td>";
117 print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"".(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha') ?GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha') : $conf->global->MAIN_AGENDA_EXPORT_CACHE)."\" size=\"10\"></td>";
118 print "<td>&nbsp;</td>";
119 print "</tr>";
120 
121 print '</table>';
122 
123 print '<br>';
124 
125 print '<table class="noborder centpercent">';
126 
127 print '<tr class="liste_titre">';
128 print '<td width="25%">'.$langs->trans("Parameter")."</td>";
129 print "<td>".$langs->trans("Value")."</td>";
130 print "</tr>";
131 print '<tr class="oddeven">';
132 print '<td>'.$langs->trans("FixTZ")."</td>";
133 print "<td>";
134 print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.$conf->global->AGENDA_EXPORT_FIX_TZ.'">';
135 print ' &nbsp; '.$langs->trans("FillThisOnlyIfRequired");
136 print "</td>";
137 print "</tr>";
138 
139 print '</table>';
140 
141 print dol_get_fiche_end();
142 
143 print $form->buttonsSaveCancel("Save", '');
144 
145 print "</form>\n";
146 
147 
148 clearstatcache();
149 
150 //if ($mesg) print "<br>$mesg<br>";
151 print "<br>";
152 
153 
154 // Define $urlwithroot
155 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
156 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
157 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
158 $getentity = ($conf->entity > 1 ? "&entity=".$conf->entity : "");
159 
160 // Show message
161 $message = '';
162 
163 $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">';
164 $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>';
165 $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlvcal, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'vcal', '').'</span>');
166 $message .= '<div class="urllink">';
167 $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) : '...').'">';
168 if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
169  $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>';
170 }
171 $message .= '</div>';
172 $message .= ajax_autoselect('onlinepaymenturl1');
173 $message .= '<br>';
174 
175 $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">';
176 $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>';
177 $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlical, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', '').'</span>');
178 $message .= '<div class="urllink">';
179 $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) : '...').'">';
180 if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
181  $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>';
182 }
183 $message .= '</div>';
184 $message .= ajax_autoselect('onlinepaymenturl2');
185 $message .= '<br>';
186 
187 $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">';
188 $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>';
189 $message .= img_picto('', 'globe').' '.str_replace('{url}', $urlrss, '<span class="opacitymedium">'.$langs->trans("WebCalUrlForVCalExport", 'rss', '').'</span>');
190 $message .= '<div class="urllink">';
191 $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) : '...').'">';
192 if (!empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
193  $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>';
194 }
195 $message .= '</div>';
196 $message .= ajax_autoselect('onlinepaymenturl3');
197 $message .= '<br>';
198 
199 print $message;
200 
201 $message = $langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
202 $message .= $langs->trans("AgendaUrlOptions3", $user->login, $user->login).'<br>';
203 $message .= $langs->trans("AgendaUrlOptionsNotAdmin", $user->login, $user->login).'<br>';
204 $message .= $langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
205 $message .= $langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
206 $message .= $langs->trans("AgendaUrlOptionsNotAutoEvent", 'systemauto', 'systemauto').'<br>';
207 $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
208 
209 print info_admin($message);
210 
211 $constname = 'MAIN_AGENDA_XCAL_EXPORTKEY';
212 
213 // Add button to autosuggest a key
214 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
215 print dolJSToSetRandomPassword($constname);
216 
217 // End of page
218 llxFooter();
219 $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($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:73
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.
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.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token')
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.