agenda_xcal.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. /**
  21. * \file htdocs/admin/agenda_xcal.php
  22. * \ingroup agenda
  23. * \brief Page to setup miscellaneous options of agenda module
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
  28. if (!$user->admin)
  29. accessforbidden();
  30. $langs->load("admin");
  31. $langs->load("other");
  32. $langs->load("agenda");
  33. $def = array();
  34. $actionsave=GETPOST('save','alpha');
  35. // Sauvegardes parametres
  36. if ($actionsave)
  37. {
  38. $i=0;
  39. $db->begin();
  40. $i+=dolibarr_set_const($db,'MAIN_AGENDA_XCAL_EXPORTKEY',trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha')),'chaine',0,'',$conf->entity);
  41. $i+=dolibarr_set_const($db,'MAIN_AGENDA_EXPORT_PAST_DELAY',trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY','alpha')),'chaine',0,'',$conf->entity);
  42. $i+=dolibarr_set_const($db,'MAIN_AGENDA_EXPORT_CACHE',trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE','alpha')),'chaine',0,'',$conf->entity);
  43. $i+=dolibarr_set_const($db,'AGENDA_EXPORT_FIX_TZ',trim(GETPOST('AGENDA_EXPORT_FIX_TZ','alpha')),'chaine',0,'',$conf->entity);
  44. if ($i >= 4)
  45. {
  46. $db->commit();
  47. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  48. }
  49. else
  50. {
  51. $db->rollback();
  52. setEventMessages($langs->trans("SaveFailed"), null, 'errors');
  53. }
  54. }
  55. /**
  56. * View
  57. */
  58. if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
  59. llxHeader();
  60. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  61. print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
  62. print '<br>';
  63. print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  64. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  65. $head=agenda_prepare_head();
  66. dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
  67. print $langs->trans("AgendaSetupOtherDesc")."<br>\n";
  68. print "<br>\n";
  69. print '<table class="noborder" width="100%">';
  70. print '<tr class="liste_titre">';
  71. print "<td>".$langs->trans("Parameter")."</td>";
  72. print "<td>".$langs->trans("Value")."</td>";
  73. //print "<td>".$langs->trans("Examples")."</td>";
  74. print "<td>&nbsp;</td>";
  75. print "</tr>";
  76. print '<tr class="oddeven">';
  77. print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
  78. 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">';
  79. if (! empty($conf->use_javascript_ajax))
  80. print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
  81. print '</td>';
  82. print "<td>&nbsp;</td>";
  83. print "</tr>";
  84. print '<tr class="oddeven">';
  85. print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
  86. 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>";
  87. print "<td>&nbsp;</td>";
  88. print "</tr>";
  89. print '<tr class="oddeven">';
  90. print "<td>".$langs->trans("UseACacheDelay")."</td>";
  91. 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>";
  92. print "<td>&nbsp;</td>";
  93. print "</tr>";
  94. print '</table>';
  95. print '<br>';
  96. print '<table class="noborder" width="100%">';
  97. print '<tr class="liste_titre">';
  98. print '<td width="25%">'.$langs->trans("Parameter")."</td>";
  99. print "<td>".$langs->trans("Value")."</td>";
  100. print "</tr>";
  101. print '<tr class="oddeven">';
  102. print '<td>'.$langs->trans("FixTZ")."</td>";
  103. print "<td>";
  104. print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.$conf->global->AGENDA_EXPORT_FIX_TZ.'">';
  105. print ' &nbsp; '.$langs->trans("FillThisOnlyIfRequired");
  106. print "</td>";
  107. print "</tr>";
  108. print '</table>';
  109. dol_fiche_end();
  110. print '<div class="center">';
  111. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  112. print "</div>";
  113. print "</form>\n";
  114. clearstatcache();
  115. //if ($mesg) print "<br>$mesg<br>";
  116. print "<br>";
  117. // Define $urlwithroot
  118. $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  119. $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  120. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  121. // Show message
  122. $message='';
  123. $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>';
  124. $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
  125. $message.='<br>';
  126. $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>';
  127. $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical/ics',$urlical);
  128. $message.='<br>';
  129. $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>';
  130. $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss);
  131. $message.='<br>';
  132. $message.='<br>';
  133. print $message;
  134. $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
  135. //$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'<br>';
  136. $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
  137. $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
  138. $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login);
  139. print info_admin($message);
  140. if (! empty($conf->use_javascript_ajax))
  141. {
  142. print "\n".'<script type="text/javascript">';
  143. print '$(document).ready(function () {
  144. $("#generate_token").click(function() {
  145. $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
  146. action: \'getrandompassword\',
  147. generic: true
  148. },
  149. function(token) {
  150. $("#MAIN_AGENDA_XCAL_EXPORTKEY").val(token);
  151. });
  152. });
  153. });';
  154. print '</script>';
  155. }
  156. llxFooter();
  157. $db->close();