agenda_xcal.php 8.5 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@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. /**
  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. // Load translation files required by the page
  31. $langs->loadLangs(array("admin","other","agenda"));
  32. $def = array();
  33. $actionsave=GETPOST('save', 'alpha');
  34. // Sauvegardes parametres
  35. if ($actionsave)
  36. {
  37. $i=0;
  38. $db->begin();
  39. $i+=dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity);
  40. $i+=dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity);
  41. $i+=dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
  42. $i+=dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
  43. if ($i >= 4)
  44. {
  45. $db->commit();
  46. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  47. }
  48. else
  49. {
  50. $db->rollback();
  51. setEventMessages($langs->trans("SaveFailed"), null, 'errors');
  52. }
  53. }
  54. /**
  55. * View
  56. */
  57. if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
  58. $wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
  59. llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
  60. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  61. print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
  62. print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  63. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  64. $head=agenda_prepare_head();
  65. dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
  66. print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
  67. print "<br>\n";
  68. print '<table class="noborder" width="100%">';
  69. print '<tr class="liste_titre">';
  70. print "<td>".$langs->trans("Parameter")."</td>";
  71. print "<td>".$langs->trans("Value")."</td>";
  72. //print "<td>".$langs->trans("Examples")."</td>";
  73. print "<td>&nbsp;</td>";
  74. print "</tr>";
  75. print '<tr class="oddeven">';
  76. print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
  77. 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">';
  78. if (! empty($conf->use_javascript_ajax))
  79. print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
  80. print '</td>';
  81. print "<td>&nbsp;</td>";
  82. print "</tr>";
  83. print '<tr class="oddeven">';
  84. print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
  85. 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>";
  86. print "<td>&nbsp;</td>";
  87. print "</tr>";
  88. print '<tr class="oddeven">';
  89. print "<td>".$langs->trans("UseACacheDelay")."</td>";
  90. 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>";
  91. print "<td>&nbsp;</td>";
  92. print "</tr>";
  93. print '</table>';
  94. print '<br>';
  95. print '<table class="noborder" width="100%">';
  96. print '<tr class="liste_titre">';
  97. print '<td width="25%">'.$langs->trans("Parameter")."</td>";
  98. print "<td>".$langs->trans("Value")."</td>";
  99. print "</tr>";
  100. print '<tr class="oddeven">';
  101. print '<td>'.$langs->trans("FixTZ")."</td>";
  102. print "<td>";
  103. print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.$conf->global->AGENDA_EXPORT_FIX_TZ.'">';
  104. print ' &nbsp; '.$langs->trans("FillThisOnlyIfRequired");
  105. print "</td>";
  106. print "</tr>";
  107. print '</table>';
  108. dol_fiche_end();
  109. print '<div class="center">';
  110. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  111. print "</div>";
  112. print "</form>\n";
  113. clearstatcache();
  114. //if ($mesg) print "<br>$mesg<br>";
  115. print "<br>";
  116. // Define $urlwithroot
  117. $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  118. $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  119. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  120. // Show message
  121. $message='';
  122. $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>';
  123. $message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal);
  124. $message.='<br>';
  125. $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>';
  126. $message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical);
  127. $message.='<br>';
  128. $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>';
  129. $message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport", 'rss', $urlrss);
  130. $message.='<br>';
  131. $message.='<br>';
  132. print $message;
  133. $message =$langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
  134. $message.=$langs->trans("AgendaUrlOptions3", $user->login, $user->login).'<br>';
  135. $message.=$langs->trans("AgendaUrlOptionsNotAdmin", $user->login, $user->login).'<br>';
  136. $message.=$langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
  137. $message.=$langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
  138. $message.=$langs->trans("AgendaUrlOptionsNotAutoEvent", 'systemauto', 'systemauto').'<br>';
  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. // End of page
  157. llxFooter();
  158. $db->close();