dolibarr  7.0.0-beta
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@capnetworks.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 <http://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
30 
31 
32 if (!$user->admin)
34 
35 $langs->load("admin");
36 $langs->load("other");
37 $langs->load("agenda");
38 
39 $def = array();
40 $actionsave=GETPOST('save','alpha');
41 
42 // Sauvegardes parametres
43 if ($actionsave)
44 {
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  {
56  $db->commit();
57  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
58  }
59  else
60  {
61  $db->rollback();
62  setEventMessages($langs->trans("SaveFailed"), null, 'errors');
63  }
64 }
65 
66 
67 
72 if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
73 
74 $wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
75 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
76 
77 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
78 print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
79 
80 
81 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
82 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
83 
84 $head=agenda_prepare_head();
85 
86 dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
87 
88 print $langs->trans("AgendaSetupOtherDesc")."<br>\n";
89 print "<br>\n";
90 
91 print '<table class="noborder" width="100%">';
92 
93 print '<tr class="liste_titre">';
94 print "<td>".$langs->trans("Parameter")."</td>";
95 print "<td>".$langs->trans("Value")."</td>";
96 //print "<td>".$langs->trans("Examples")."</td>";
97 print "<td>&nbsp;</td>";
98 print "</tr>";
99 
100 print '<tr class="oddeven">';
101 print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
102 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">';
103 if (! empty($conf->use_javascript_ajax))
104  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
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" width="100%">';
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 dol_fiche_end();
142 
143 print '<div class="center">';
144 print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
145 print "</div>";
146 
147 print "</form>\n";
148 
149 
150 clearstatcache();
151 
152 //if ($mesg) print "<br>$mesg<br>";
153 print "<br>";
154 
155 
156 // Define $urlwithroot
157 $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
158 $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
159 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
160 
161 
162 // Show message
163 $message='';
164 $urlvcal='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
165 $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
166 $message.='<br>';
167 $urlical='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
168 $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical/ics',$urlical);
169 $message.='<br>';
170 $urlrss='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
171 $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss);
172 $message.='<br>';
173 $message.='<br>';
174 print $message;
175 
176 $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
177 $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
178 $message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'<br>';
179 $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
180 $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login);
181 
182 print info_admin($message);
183 
184 if (! empty($conf->use_javascript_ajax))
185 {
186  print "\n".'<script type="text/javascript">';
187  print '$(document).ready(function () {
188  $("#generate_token").click(function() {
189  $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
190  action: \'getrandompassword\',
191  generic: true
192  },
193  function(token) {
194  $("#MAIN_AGENDA_XCAL_EXPORTKEY").val(token);
195  });
196  });
197  });';
198  print '</script>';
199 }
200 
201 
202 llxFooter();
203 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
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.
agenda_prepare_head()
Prepare array with list of tabs.
Definition: agenda.lib.php:399
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.
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.
if(GETPOST('button_removefilter_x','alpha')||GETPOST('button_removefilter.x','alpha')||GETPOST('button_removefilter','alpha')) if($action=="save"&&empty($cancel)) if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg) $wikihelp)
View.
Definition: agenda.php:143
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