setup.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/modulebuilder/admin/setup.php
  19. * \ingroup modulebuilder
  20. * \brief Page setup for modulebuilder module
  21. */
  22. require '../../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  24. global $conf,$langs,$user, $db;
  25. $langs->loadLangs(array("admin", "other", "modulebuilder"));
  26. if (!$user->admin || empty($conf->modulebuilder->enabled))
  27. accessforbidden();
  28. $action = GETPOST('action', 'aZ09');
  29. $backtopage = GETPOST('backtopage', 'alpha');
  30. /*
  31. * Actions
  32. */
  33. if($action=="update"){
  34. $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README'), 'chaine', 0, '', $conf->entity);
  35. if ($res1 < 0)
  36. {
  37. setEventMessages('ErrorFailedToSaveDate', null, 'errors');
  38. $db->rollback();
  39. }
  40. else
  41. {
  42. setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
  43. $db->commit();
  44. }
  45. }
  46. if (preg_match('/set_(.*)/', $action, $reg)) {
  47. $code = $reg[1];
  48. $values = GETPOST($code);
  49. if (is_array($values))
  50. $values = implode(',', $values);
  51. if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
  52. header("Location: " . $_SERVER["PHP_SELF"]);
  53. exit;
  54. } else {
  55. dol_print_error($db);
  56. }
  57. }
  58. if (preg_match('/del_(.*)/', $action, $reg)) {
  59. $code = $reg[1];
  60. if (dolibarr_del_const($db, $code, 0) > 0) {
  61. Header("Location: " . $_SERVER["PHP_SELF"]);
  62. exit;
  63. } else {
  64. dol_print_error($db);
  65. }
  66. }
  67. /*
  68. * View
  69. */
  70. $form = new Form($db);
  71. llxHeader('', $langs->trans("ModulebuilderSetup"));
  72. $linkback = '';
  73. if (GETPOST('withtab', 'alpha')) {
  74. $linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php') . '">' . $langs->trans("BackToModuleList") . '</a>';
  75. }
  76. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  77. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  78. print '<input type="hidden" name="action" value="update">';
  79. print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback);
  80. if (GETPOST('withtab', 'alpha')) {
  81. dol_fiche_head($head, 'modulebuilder', '', -1);
  82. }
  83. print '<span class="opacitymedium">' . $langs->trans("ModuleBuilderDesc") . "</span><br>\n";
  84. print '<br>';
  85. print '<table class="noborder" width="100%">';
  86. print '<tr class="liste_titre">';
  87. print '<td>' . $langs->trans("Key") . '</td>';
  88. print '<td>' . $langs->trans("Value") . '</td>';
  89. print "</tr>\n";
  90. if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
  91. {
  92. // What is use cas of this 2 options ?
  93. print '<tr class="oddeven">';
  94. print '<td>' . $langs->trans("UseAboutPage") . '</td>';
  95. print '<td align="center">';
  96. if ($conf->use_javascript_ajax) {
  97. print ajax_constantonoff('MODULEBUILDER_USE_ABOUT');
  98. } else {
  99. if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) {
  100. print '<a href="' . $_SERVER['PHP_SELF'] . '?action=set_MODULEBUILDER_USE_ABOUT">' . img_picto($langs->trans("Disabled"), 'off') . '</a>';
  101. } else {
  102. print '<a href="' . $_SERVER['PHP_SELF'] . '?action=del_MODULEBUILDER_USE_ABOUT">' . img_picto($langs->trans("Enabled"), 'on') . '</a>';
  103. }
  104. }
  105. print '</td></tr>';
  106. print '<tr class="oddeven">';
  107. print '<td>' . $langs->trans("UseDocFolder") . '</td>';
  108. print '<td align="center">';
  109. if ($conf->use_javascript_ajax) {
  110. print ajax_constantonoff('MODULEBUILDER_USE_DOCFOLDER');
  111. } else {
  112. if (empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)) {
  113. print '<a href="' . $_SERVER['PHP_SELF'] . '?action=set_MODULEBUILDER_USE_DOCFOLDER">' . img_picto($langs->trans("Disabled"), 'off') . '</a>';
  114. } else {
  115. print '<a href="' . $_SERVER['PHP_SELF'] . '?action=del_MODULEBUILDER_USE_DOCFOLDER">' . img_picto($langs->trans("Enabled"), 'on') . '</a>';
  116. }
  117. }
  118. print '</td></tr>';
  119. }
  120. print '<tr class="oddeven">';
  121. print '<td class="tdtop">' . $langs->trans("UseSpecificReadme") . '</td>';
  122. print '<td>';
  123. print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>';
  124. print '</td>';
  125. print '</tr>';
  126. print '</table>';
  127. print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'" name="Button"></center>';
  128. if (GETPOST('withtab', 'alpha')) {
  129. dol_fiche_end();
  130. }
  131. print '<br>';
  132. print '</form>';
  133. // End of page
  134. llxFooter();
  135. $db->close();