spip.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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@capnetworks.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. $langs->load("admin");
  33. $langs->load("members");
  34. $langs->load("mailmanspip");
  35. if (! $user->admin) accessforbidden();
  36. $type=array('yesno','texte','chaine');
  37. $action = GETPOST('action','aZ09');
  38. /*
  39. * Actions
  40. */
  41. // Action mise a jour ou ajout d'une constante
  42. if ($action == 'update' || $action == 'add')
  43. {
  44. $constname=GETPOST("constname");
  45. $constvalue=GETPOST("constvalue");
  46. // Action mise a jour ou ajout d'une constante
  47. if ($action == 'update' || $action == 'add')
  48. {
  49. foreach($_POST['constname'] as $key => $val)
  50. {
  51. $constname=$_POST["constname"][$key];
  52. $constvalue=$_POST["constvalue"][$key];
  53. $consttype=$_POST["consttype"][$key];
  54. $constnote=$_POST["constnote"][$key];
  55. $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
  56. if (! $res > 0) $error++;
  57. }
  58. if (! $error)
  59. {
  60. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  61. }
  62. else
  63. {
  64. setEventMessages($langs->trans("Error"), null, 'errors');
  65. }
  66. }
  67. }
  68. // Action activation d'un sous module du module adherent
  69. if ($action == 'set')
  70. {
  71. $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity);
  72. if ($result < 0)
  73. {
  74. dol_print_error($db);
  75. }
  76. }
  77. // Action desactivation d'un sous module du module adherent
  78. if ($action == 'unset')
  79. {
  80. $result=dolibarr_del_const($db,$_GET["name"],$conf->entity);
  81. if ($result < 0)
  82. {
  83. dol_print_error($db);
  84. }
  85. }
  86. /*
  87. * View
  88. */
  89. $help_url='';
  90. llxHeader('',$langs->trans("MailmanSpipSetup"),$help_url);
  91. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  92. print load_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'title_setup');
  93. $head = mailmanspip_admin_prepare_head();
  94. $var=true;
  95. /*
  96. * Spip
  97. */
  98. if (! empty($conf->global->ADHERENT_USE_SPIP))
  99. {
  100. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  101. dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
  102. //$link=img_picto($langs->trans("Active"),'tick').' ';
  103. $link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">';
  104. //$link.=$langs->trans("Disable");
  105. $link.=img_picto($langs->trans("Activated"),'switch_on');
  106. $link.='</a>';
  107. // Edition des varibales globales
  108. $constantes=array(
  109. 'ADHERENT_SPIP_SERVEUR',
  110. 'ADHERENT_SPIP_DB',
  111. 'ADHERENT_SPIP_USER',
  112. 'ADHERENT_SPIP_PASS'
  113. );
  114. print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
  115. print '<br>';
  116. form_constantes($constantes,2);
  117. dol_fiche_end();
  118. print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
  119. print '</form>';
  120. }
  121. else
  122. {
  123. dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
  124. $link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">';
  125. //$link.=$langs->trans("Activate");
  126. $link.=img_picto($langs->trans("Disabled"),'switch_off');
  127. $link.='</a>';
  128. print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
  129. dol_fiche_end();
  130. }
  131. llxFooter();
  132. $db->close();