spip.php 5.0 KB

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