PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/agenda_extsites.php

https://github.com/asterix14/dolibarr
PHP | 193 lines | 121 code | 38 blank | 34 comment | 16 complexity | a63a67bcd84c32acb8be88c7c4741d27 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/agenda_extsites.php
  20. * \ingroup agenda
  21. * \brief Page to setup external calendars for agenda module
  22. */
  23. require("../main.inc.php");
  24. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  25. require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php');
  26. require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php');
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
  29. if (!$user->admin)
  30. accessforbidden();
  31. $langs->load("agenda");
  32. $langs->load("admin");
  33. $langs->load("other");
  34. $def = array();
  35. $actiontest=GETPOST("test");
  36. $actionsave=GETPOST("save");
  37. if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
  38. $MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
  39. // List of aviable colors
  40. $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
  41. /*
  42. * Actions
  43. */
  44. if ($actionsave)
  45. {
  46. $db->begin();
  47. $disableext=GETPOST("AGENDA_DISABLE_EXT");
  48. if ($disableext) $disableext=0; else $disableext=1;
  49. $res=dolibarr_set_const($db,'AGENDA_DISABLE_EXT',$disableext,'chaine',0);
  50. $i=1;
  51. $error=0;
  52. // Save agendas
  53. while ($i <= $MAXAGENDA)
  54. {
  55. $color=trim(GETPOST("agenda_ext_color".$i));
  56. if ($color=='-1') $color='';
  57. //print 'color='.$color;
  58. $res=dolibarr_set_const($db,'AGENDA_EXT_NAME'.$i,trim(GETPOST("agenda_ext_name".$i)),'chaine',0);
  59. if (! $res > 0) $error++;
  60. $res=dolibarr_set_const($db,'AGENDA_EXT_SRC'.$i,trim(GETPOST("agenda_ext_src".$i)),'chaine',0);
  61. if (! $res > 0) $error++;
  62. $res=dolibarr_set_const($db,'AGENDA_EXT_COLOR'.$i,$color,'chaine',0);
  63. if (! $res > 0) $error++;
  64. $i++;
  65. }
  66. // Save nb of agenda
  67. $res=dolibarr_set_const($db,'AGENDA_EXT_NB',trim(GETPOST("AGENDA_EXT_NB")),'chaine',0);
  68. if (! $res > 0) $error++;
  69. if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
  70. $MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
  71. if (! $error)
  72. {
  73. $db->commit();
  74. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  75. }
  76. else
  77. {
  78. $db->rollback();
  79. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  80. }
  81. }
  82. /*
  83. * View
  84. */
  85. $form=new Form($db);
  86. $formadmin=new FormAdmin($db);
  87. $formother=new FormOther($db);
  88. $arrayofjs=array();
  89. $arrayofcss=array();
  90. llxHeader('',$langs->trans("AgendaSetup"),'','',0,0,$arrayofjs,$arrayofcss);
  91. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  92. print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
  93. print '<br>';
  94. print $langs->trans("AgendaExtSitesDesc")."<br>\n";
  95. print "<br>\n";
  96. $head=agenda_prepare_head();
  97. dol_fiche_head($head, 'extsites', $langs->trans("Agenda"));
  98. print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  99. $selectedvalue=(GETPOST("AGENDA_DISABLE_AGENDA"))?GETPOST("AGENDA_DISABLE_EXT"):$conf->global->AGENDA_DISABLE_EXT;
  100. if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
  101. print $langs->trans("ExtSitesEnableThisTool").' '.$form->selectyesno("AGENDA_DISABLE_EXT",$selectedvalue,1).'<br><br>';
  102. $var=false;
  103. print "<table class=\"noborder\" width=\"100%\">";
  104. print "<tr class=\"liste_titre\">";
  105. print '<td width="180">'.$langs->trans("Parameter")."</td>";
  106. print "<td>".$langs->trans("Value")."</td>";
  107. print "</tr>";
  108. // Nb of agenda
  109. print "<tr ".$bc[$var].">";
  110. print "<td>".$langs->trans("ExtSitesNbOfAgenda")."</td>";
  111. print "<td>";
  112. print '<input class="flat" type="text" size="2" name="AGENDA_EXT_NB" value="'.$conf->global->AGENDA_EXT_NB.'">';
  113. print "</td>";
  114. print "</tr>";
  115. print "</table>";
  116. print "<br>";
  117. print "<table class=\"noborder\" width=\"100%\">";
  118. print "<tr class=\"liste_titre\">";
  119. print "<td>".$langs->trans("Parameter")."</td>";
  120. print "<td>".$langs->trans("Name")."</td>";
  121. print "<td>".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics)</td>';
  122. print '<td align="center">'.$langs->trans("Color").'</td>';
  123. print "</tr>";
  124. $i=1;
  125. $var=true;
  126. while ($i <= $MAXAGENDA)
  127. {
  128. $key=$i;
  129. $var=!$var;
  130. print "<tr ".$bc[$var].">";
  131. print '<td width="180" nowrap="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>";
  132. $name='AGENDA_EXT_NAME'.$key;
  133. $src='AGENDA_EXT_SRC'.$key;
  134. $color='AGENDA_EXT_COLOR'.$key;
  135. print "<td><input type=\"text\" class=\"flat\" name=\"agenda_ext_name".$key."\" value=\"". $conf->global->$name . "\" size=\"28\"></td>";
  136. print "<td><input type=\"text\" class=\"flat\" name=\"agenda_ext_src".$key."\" value=\"". $conf->global->$src . "\" size=\"60\"></td>";
  137. print '<td nowrap="nowrap" align="center">';
  138. // Possible colors are limited by Google
  139. //print $formadmin->select_colors($conf->global->$color, "google_agenda_color".$key, $colorlist);
  140. print $formother->select_color($conf->global->$color, "agenda_ext_color".$key, 'extsitesconfig', 1, '');
  141. print '</td>';
  142. print "</tr>";
  143. $i++;
  144. }
  145. print '</table>';
  146. print '<br>';
  147. print '<center>';
  148. print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
  149. print "</center>";
  150. print "</form>\n";
  151. dol_fiche_end();
  152. dol_htmloutput_mesg($mesg);
  153. $db->close();
  154. llxFooter();
  155. ?>