* Copyright (C) 2021 Dorian Laurent * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file partnership/admin/setup.php * \ingroup partnership * \brief Partnership setup page. */ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; } // Try main.inc.php using relative path if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } global $langs, $user; // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/partnership.lib.php'; //require_once "../class/myclass.class.php"; // Translations $langs->loadLangs(array("admin", "partnership")); // Security check if (!$user->admin) { accessforbidden(); } $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); $error = 0; /* * Actions */ $nomessageinsetmoduleoptions = 1; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setting') { require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php"; $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty'; $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity); $partnership = new modPartnership($db); $error += $partnership->delete_tabs(); $error += $partnership->insert_tabs(); $error += $partnership->delete_menus(); $error += $partnership->insert_menus(); if (GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int')) dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity); } if ($action) { if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("SetupNotError"), null, 'errors'); } header("Location: ".$_SERVER['PHP_SELF']); exit; } /* * View */ $title = $langs->trans('PartnershipSetup'); llxHeader('', $title); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($title, $linkback, 'title_setup'); $head = partnershipAdminPrepareHead(); print dol_get_fiche_head($head, 'settings', $title, -1, 'partnership'); $form = new Form($db); // Module to manage partnership / services code $dirpartnership = array('/core/modules/partnership/'); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); /* * Other conf */ print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { print ''; print ''; print ''; print ''; } print ''; print ''; print ''; print ''; print '
'.$langs->trans("Setting").''.$langs->trans("Value").''.$langs->trans("Examples").'
'.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").''; print ''; print ''.$langs->trans("partnershipforthirdpartyormember").'
'.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; $dnbdays = '7'; $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays; print ''; print ''.$dnbdays.'
'.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").''; $dbacklinks = 'dolibarr.org|dolibarr.fr|dolibarr.es'; $backlinks = (!empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK)) ? $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK : $dbacklinks; print ''; print ''.$dbacklinks.'
'; print '
'; print ''; print '
'; print '
'; // End of page llxFooter(); $db->close();