spip.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  6. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  7. * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
  8. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/admin/spip.php
  25. * \ingroup mailmanspip
  26. * \brief Page to setup the module MailmanSpip (SPIP)
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  32. // Load translation files required by the page
  33. $langs->loadLangs(array("admin", "members", "mailmanspip"));
  34. if (! $user->admin) accessforbidden();
  35. $type=array('yesno','texte','chaine');
  36. $action = GETPOST('action','aZ09');
  37. /*
  38. * Actions
  39. */
  40. // Action mise a jour ou ajout d'une constante
  41. if ($action == 'update' || $action == 'add')
  42. {
  43. $constname=GETPOST("constname");
  44. $constvalue=GETPOST("constvalue");
  45. // Action mise a jour ou ajout d'une constante
  46. if ($action == 'update' || $action == 'add')
  47. {
  48. foreach($_POST['constname'] as $key => $val)
  49. {
  50. $constname=$_POST["constname"][$key];
  51. $constvalue=$_POST["constvalue"][$key];
  52. $consttype=$_POST["consttype"][$key];
  53. $constnote=$_POST["constnote"][$key];
  54. $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
  55. if (! $res > 0) $error++;
  56. }
  57. if (! $error)
  58. {
  59. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  60. }
  61. else
  62. {
  63. setEventMessages($langs->trans("Error"), null, 'errors');
  64. }
  65. }
  66. }
  67. // Action activation d'un sous module du module adherent
  68. if ($action == 'set')
  69. {
  70. $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity);
  71. if ($result < 0)
  72. {
  73. dol_print_error($db);
  74. }
  75. }
  76. // Action desactivation d'un sous module du module adherent
  77. if ($action == 'unset')
  78. {
  79. $result=dolibarr_del_const($db,$_GET["name"],$conf->entity);
  80. if ($result < 0)
  81. {
  82. dol_print_error($db);
  83. }
  84. }
  85. /*
  86. * View
  87. */
  88. $help_url='';
  89. llxHeader('',$langs->trans("MailmanSpipSetup"),$help_url);
  90. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  91. print load_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'title_setup');
  92. $head = mailmanspip_admin_prepare_head();
  93. /*
  94. * Spip
  95. */
  96. if (! empty($conf->global->ADHERENT_USE_SPIP))
  97. {
  98. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  99. dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
  100. //$link=img_picto($langs->trans("Active"),'tick').' ';
  101. $link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">';
  102. //$link.=$langs->trans("Disable");
  103. $link.=img_picto($langs->trans("Activated"),'switch_on');
  104. $link.='</a>';
  105. // Edition des varibales globales
  106. $constantes=array(
  107. 'ADHERENT_SPIP_SERVEUR',
  108. 'ADHERENT_SPIP_DB',
  109. 'ADHERENT_SPIP_USER',
  110. 'ADHERENT_SPIP_PASS'
  111. );
  112. print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
  113. print '<br>';
  114. form_constantes($constantes,2);
  115. dol_fiche_end();
  116. print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
  117. print '</form>';
  118. }
  119. else
  120. {
  121. dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
  122. $link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">';
  123. //$link.=$langs->trans("Activate");
  124. $link.=img_picto($langs->trans("Disabled"),'switch_off');
  125. $link.='</a>';
  126. print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
  127. dol_fiche_end();
  128. }
  129. // End of page
  130. llxFooter();
  131. $db->close();