setup.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 <https://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 || !isModEnabled('modulebuilder')) {
  27. accessforbidden();
  28. }
  29. $action = GETPOST('action', 'aZ09');
  30. $backtopage = GETPOST('backtopage', 'alpha');
  31. /*
  32. * Actions
  33. */
  34. if ($action == "update") {
  35. $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'restricthtml'), 'chaine', 0, '', $conf->entity);
  36. $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  37. $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  38. $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  39. $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  40. $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  41. $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity);
  42. $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  43. if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) {
  44. setEventMessages('ErrorFailedToSaveDate', null, 'errors');
  45. $db->rollback();
  46. } else {
  47. setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
  48. $db->commit();
  49. }
  50. }
  51. $reg = array();
  52. if (preg_match('/set_(.*)/', $action, $reg)) {
  53. $code = $reg[1];
  54. $values = GETPOST($code);
  55. if (is_array($values)) {
  56. $values = implode(',', $values);
  57. }
  58. if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
  59. header("Location: ".$_SERVER["PHP_SELF"]);
  60. exit;
  61. } else {
  62. dol_print_error($db);
  63. }
  64. }
  65. if (preg_match('/del_(.*)/', $action, $reg)) {
  66. $code = $reg[1];
  67. if (dolibarr_del_const($db, $code, 0) > 0) {
  68. Header("Location: ".$_SERVER["PHP_SELF"]);
  69. exit;
  70. } else {
  71. dol_print_error($db);
  72. }
  73. }
  74. /*
  75. * View
  76. */
  77. $form = new Form($db);
  78. $help_url = '';
  79. llxHeader('', $langs->trans("ModulebuilderSetup"), $help_url);
  80. $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
  81. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  82. print '<input type="hidden" name="token" value="'.newToken().'">';
  83. print '<input type="hidden" name="action" value="update">';
  84. print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback);
  85. if (GETPOST('withtab', 'alpha')) {
  86. print dol_get_fiche_head($head, 'modulebuilder', '', -1);
  87. }
  88. print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc")."</span><br>\n";
  89. print '<br>';
  90. print '<table class="noborder centpercent">';
  91. print '<tr class="liste_titre">';
  92. print '<td>'.$langs->trans("Parameter").'</td>';
  93. print '<td>'.$langs->trans("Value").'</td>';
  94. print "</tr>\n";
  95. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  96. // What is use case of this 2 options ?
  97. print '<tr class="oddeven">';
  98. print '<td>'.$langs->trans("UseAboutPage").'</td>';
  99. print '<td>';
  100. if ($conf->use_javascript_ajax) {
  101. print ajax_constantonoff('MODULEBUILDER_USE_ABOUT');
  102. } else {
  103. if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) {
  104. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=set_MODULEBUILDER_USE_ABOUT&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  105. } else {
  106. print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=del_MODULEBUILDER_USE_ABOUT&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  107. }
  108. }
  109. print '</td></tr>';
  110. }
  111. print '<tr class="oddeven">';
  112. print '<td>'.$langs->trans("UseSpecificEditorName").'</td>';
  113. print '<td>';
  114. print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_NAME" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME.'">';
  115. print '</td>';
  116. print '</tr>';
  117. print '<tr class="oddeven">';
  118. print '<td>'.$langs->trans("UseSpecificEditorURL").'</td>';
  119. print '<td>';
  120. print '<input type="text" name="MODULEBUILDER_SPECIFIC_EDITOR_URL" value="'.$conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL.'">';
  121. print '</td>';
  122. print '</tr>';
  123. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  124. print '<tr class="oddeven">';
  125. print '<td>'.$langs->trans("UseSpecificFamily").'</td>';
  126. print '<td>';
  127. print '<input type="text" name="MODULEBUILDER_SPECIFIC_FAMILY" value="'.$conf->global->MODULEBUILDER_SPECIFIC_FAMILY.'">';
  128. print '</td>';
  129. print '</tr>';
  130. print '<tr class="oddeven">';
  131. print '<td>'.$langs->trans("UseSpecificAuthor").'</td>';
  132. print '<td>';
  133. print '<input type="text" name="MODULEBUILDER_SPECIFIC_AUTHOR" value="'.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR.'">';
  134. print '</td>';
  135. print '</tr>';
  136. print '<tr class="oddeven">';
  137. print '<td>'.$langs->trans("UseSpecificVersion").'</td>';
  138. print '<td>';
  139. print '<input type="text" name="MODULEBUILDER_SPECIFIC_VERSION" value="'.$conf->global->MODULEBUILDER_SPECIFIC_VERSION.'">';
  140. print '</td>';
  141. print '</tr>';
  142. }
  143. print '<tr class="oddeven">';
  144. print '<td>'.$langs->trans("UseSpecificReadme").'</td>';
  145. print '<td>';
  146. print '<textarea class="centpercent" rows="20" name="MODULEBUILDER_SPECIFIC_README">'.$conf->global->MODULEBUILDER_SPECIFIC_README.'</textarea>';
  147. print '</td>';
  148. print '</tr>';
  149. print '<tr class="oddeven">';
  150. print '<td>'.$langs->trans("AsciiToHtmlConverter").'</td>';
  151. print '<td>';
  152. print '<input type="text" name="MODULEBUILDER_ASCIIDOCTOR" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTOR.'">';
  153. print ' '.$langs->trans("Example").': asciidoc, asciidoctor';
  154. print '</td>';
  155. print '</tr>';
  156. print '<tr class="oddeven">';
  157. print '<td>'.$langs->trans("AsciiToPdfConverter").'</td>';
  158. print '<td>';
  159. print '<input type="text" name="MODULEBUILDER_ASCIIDOCTORPDF" value="'.$conf->global->MODULEBUILDER_ASCIIDOCTORPDF.'">';
  160. print ' '.$langs->trans("Example").': asciidoctor-pdf';
  161. print '</td>';
  162. print '</tr>';
  163. print '</table>';
  164. print $form->buttonsSaveCancel("Save", '');
  165. if (GETPOST('withtab', 'alpha')) {
  166. print dol_get_fiche_end();
  167. }
  168. print '<br>';
  169. print '</form>';
  170. // End of page
  171. llxFooter();
  172. $db->close();