Merge pull request #18433 from aspangaro/15a2

NEW Ihm admin - Add tabs
This commit is contained in:
Laurent Destailleur 2021-08-18 21:30:41 +02:00 committed by GitHub
commit cec94b5f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 400 additions and 369 deletions

View File

@ -43,12 +43,12 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search
$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'language'; // 'language', 'template', 'login', 'other'
if (!defined("MAIN_MOTD")) { if (!defined("MAIN_MOTD")) {
define("MAIN_MOTD", ""); define("MAIN_MOTD", "");
} }
/* /*
* Action * Action
*/ */
@ -94,10 +94,15 @@ if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKG
} }
if ($action == 'update') { if ($action == 'update') {
$error = 0;
if ($mode == 'language') {
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_MULTILANGS", GETPOST("MAIN_MULTILANGS"), 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_MULTILANGS", GETPOST("MAIN_MULTILANGS"), 'chaine', 0, '', $conf->entity);
}
if ($mode == 'template') {
dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity);
/*$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); /*$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
@ -199,7 +204,9 @@ if ($action == 'update') {
} else { } else {
dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
} }
}
if ($mode == 'other') {
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity);
@ -216,10 +223,14 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'restricthtml')), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'restricthtml')), 'chaine', 0, '', $conf->entity);
}
if ($mode == 'login') {
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'restricthtml')), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'restricthtml')), 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities //dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
$varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; $varforimage = 'imagebackground';
$dirforimage = $conf->mycompany->dir_output . '/logos/';
if ($_FILES[$varforimage]["tmp_name"]) { if ($_FILES[$varforimage]["tmp_name"]) {
$reg = array(); $reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
@ -250,12 +261,11 @@ if ($action == 'update') {
} }
} }
} }
}
$_SESSION["mainmenu"] = ""; // The menu manager may have changed
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : ''));
$_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(GETPOSTISSET('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : ''));
exit; exit;
} }
@ -274,6 +284,7 @@ $formadmin = new FormAdmin($db);
print load_fiche_titre($langs->trans("GUISetup"), '', 'title_setup'); print load_fiche_titre($langs->trans("GUISetup"), '', 'title_setup');
print '<span class="opacitymedium">'.$langs->trans("DisplayDesc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("DisplayDesc")."</span><br>\n";
print "<br>\n";
//WYSIWYG Editor //WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -282,14 +293,17 @@ print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="page_y" value="">'; print '<input type="hidden" name="page_y" value="">';
print '<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).'">';
$head = ihm_prepare_head();
print dol_get_fiche_head($head, $mode, '', -1, '');
clearstatcache(); clearstatcache();
print '<br>'; if ($mode == 'language') {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table summary="edit" class="noborder centpercent editmode tableforfield">'; print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><th>'.img_picto('', 'language').' '.$langs->trans("Language").'</th><th></th>';
print '</tr>';
// Default language // Default language
print '<tr class="oddeven"><td>'.$langs->trans("DefaultLanguage").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("DefaultLanguage").'</td><td>';
@ -307,30 +321,17 @@ print '</tr>';
print '</table>' . "\n"; print '</table>' . "\n";
print '</div>'; print '</div>';
}
print '<br>'; if ($mode == 'template') {
print '<div class="center">';
print '<input class="button button-save" type="submit" name="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '<br><br>';
// Themes and themes options // Themes and themes options
showSkins(null, 1); showSkins(null, 1);
print '<br>'; }
print '<div class="center">';
print '<input class="button button-save reposition" type="submit" name="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '<br><br>';
if ($mode == 'other') {
// Other // Other
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table summary="otherparameters" class="noborder centpercent editmode tableforfield">'; print '<table summary="otherparameters" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><th class="titlefieldmiddle">'.$langs->trans("Miscellaneous").'</th>';
print '<th></th>';
print '<th width="20">&nbsp;</tg>';
print '</tr>';
// Disable javascript and ajax // Disable javascript and ajax
print '<tr class="oddeven"><td>' . $langs->trans("DisableJavascript") . '</td><td>'; print '<tr class="oddeven"><td>' . $langs->trans("DisableJavascript") . '</td><td>';
@ -451,22 +452,12 @@ print '</td></tr>'."\n";
print '</table>' . "\n"; print '</table>' . "\n";
print '</div>'; print '</div>';
}
print '<br>'; if ($mode == 'login') {
print '<div class="center">';
print '<input class="button button-save reposition" type="submit" name="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '<br><br>';
// Other // Other
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table summary="edit" class="noborder centpercent editmode tableforfield">'; print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre"><th class="titlefieldmiddle">'.$langs->trans("LoginPage").'</th>';
print '<th></th>';
print '<th width="20">&nbsp;</th>';
print '</tr>';
// Hide helpcenter link on login page // Hide helpcenter link on login page
print '<tr class="oddeven"><td>' . $langs->trans("DisableLinkToHelpCenter") . '</td><td>'; print '<tr class="oddeven"><td>' . $langs->trans("DisableLinkToHelpCenter") . '</td><td>';
@ -514,6 +505,7 @@ print '</td></tr>';
print '</table>' . "\n"; print '</table>' . "\n";
print '</div>'; print '</div>';
}
print '<br>'; print '<br>';
print '<div class="center">'; print '<div class="center">';

View File

@ -621,7 +621,7 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0,
/** /**
* Prepare array with list of tabs * Prepare array with list of tabs
* *
* @param int $nbofactivatedmodules Number f oactivated modules * @param int $nbofactivatedmodules Number if activated modules
* @param int $nboftotalmodules Nb of total modules * @param int $nboftotalmodules Nb of total modules
* @return array Array of tabs to show * @return array Array of tabs to show
*/ */
@ -664,6 +664,45 @@ function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules)
return $head; return $head;
} }
/**
* Prepare array with list of tabs
*
* @return array Array of tabs to show
*/
function ihm_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/ihm.php?mode=language";
$head[$h][1] = $langs->trans("DefaultLanguage");
$head[$h][2] = 'language';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/ihm.php?mode=template";
$head[$h][1] = $langs->trans("DefaultSkin");
$head[$h][2] = 'template';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/ihm.php?mode=login";
$head[$h][1] = $langs->trans("LoginPage");
$head[$h][2] = 'login';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/ihm.php?mode=other";
$head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'other';
$h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'ihm_admin');
complete_head_from_modules($conf, $langs, null, $head, $h, 'ihm_admin', 'remove');
return $head;
}
/** /**
* Prepare array with list of tabs * Prepare array with list of tabs