blockedlog.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
  3. * Copyright (C) 2017-2018 Laurent Destailleur <eldy@destailleur.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/blockedlog/admin/blockedlog.php
  20. * \ingroup blockedlog
  21. * \brief Page setup for blockedlog module
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array('admin', 'blockedlog', 'other'));
  30. // Access Control
  31. if (!$user->admin || empty($conf->blockedlog->enabled)) {
  32. accessforbidden();
  33. }
  34. // Get Parameters
  35. $action = GETPOST('action', 'aZ09');
  36. $backtopage = GETPOST('backtopage', 'alpha');
  37. $withtab = GETPOST('withtab', 'int');
  38. /*
  39. * Actions
  40. */
  41. $reg = array();
  42. if (preg_match('/set_(.*)/', $action, $reg)) {
  43. $code = $reg[1];
  44. $values = GETPOST($code);
  45. if (is_array($values)) {
  46. $values = implode(',', $values);
  47. }
  48. if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) {
  49. header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
  50. exit;
  51. } else {
  52. dol_print_error($db);
  53. }
  54. }
  55. if (preg_match('/del_(.*)/', $action, $reg)) {
  56. $code = $reg[1];
  57. if (dolibarr_del_const($db, $code, 0) > 0) {
  58. Header("Location: ".$_SERVER["PHP_SELF"].($withtab ? '?withtab='.$withtab : ''));
  59. exit;
  60. } else {
  61. dol_print_error($db);
  62. }
  63. }
  64. /*
  65. * View
  66. */
  67. $form = new Form($db);
  68. $block_static = new BlockedLog($db);
  69. $block_static->loadTrackedEvents();
  70. $title = $langs->trans("BlockedLogSetup");
  71. $help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
  72. llxHeader('', $title, $help_url);
  73. $linkback = '';
  74. if ($withtab) {
  75. $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
  76. }
  77. print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'), $linkback);
  78. if ($withtab) {
  79. $head = blockedlogadmin_prepare_head();
  80. print dol_get_fiche_head($head, 'blockedlog', '', -1);
  81. }
  82. print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
  83. print '<br>';
  84. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  85. print '<table class="noborder centpercent">';
  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. print '<tr class="oddeven">';
  91. print '<td class="titlefield">';
  92. print $langs->trans("CompanyInitialKey").'</td><td>';
  93. print $block_static->getSignature();
  94. print '</td></tr>';
  95. if (getDolGlobalString('BLOCKEDLOG_USE_REMOTE_AUTHORITY')) {
  96. // Example with a yes / no select
  97. print '<tr class="oddeven">';
  98. print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
  99. print '<td class="right" width="300">';
  100. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  101. print '<input type="hidden" name="token" value="'.newToken().'">';
  102. print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
  103. print '<input type="hidden" name="withtab" value="'.$withtab.'">';
  104. print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="' . getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL').'" size="40" />';
  105. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  106. print '</form>';
  107. print '</td></tr>';
  108. }
  109. print '<tr class="oddeven">';
  110. print '<td>'.$langs->trans("BlockedLogDisableNotAllowedForCountry").'</td>';
  111. print '<td>';
  112. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  113. print '<input type="hidden" name="token" value="'.newToken().'">';
  114. print '<input type="hidden" name="action" value="set_BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY">';
  115. print '<input type="hidden" name="withtab" value="'.$withtab.'">';
  116. $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
  117. $sql .= " FROM ".MAIN_DB_PREFIX."c_country";
  118. $sql .= " WHERE active > 0";
  119. $countryArray = array();
  120. $resql = $db->query($sql);
  121. if ($resql) {
  122. while ($obj = $db->fetch_object($resql)) {
  123. $countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
  124. }
  125. }
  126. $seledted = !getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY') ? array() : explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);
  127. print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $seledted);
  128. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  129. print '</form>';
  130. print '</td>';
  131. print '<tr class="oddeven">';
  132. print '<td class="titlefield">';
  133. print $langs->trans("ListOfTrackedEvents").'</td><td>';
  134. $arrayoftrackedevents = $block_static->trackedevents;
  135. foreach ($arrayoftrackedevents as $key => $val) {
  136. print $key.' - '.$langs->trans($val).'<br>';
  137. }
  138. print '</td></tr>';
  139. print '</tr>';
  140. print '</table>';
  141. print '</div>';
  142. if ($withtab) {
  143. print dol_get_fiche_end();
  144. }
  145. print '<br><br>';
  146. // End of page
  147. llxFooter();
  148. $db->close();