refactoring
This commit is contained in:
parent
7fcc2cf38d
commit
c9d32bf2de
|
@ -1454,7 +1454,7 @@ class accountContainer {
|
|||
*/
|
||||
private function loadProfileIfRequested() {
|
||||
if (isset($_POST['accountContainerLoadProfile']) && isset($_POST['accountContainerSelectLoadProfile'])) {
|
||||
$profile = \LAM\PROFILES\loadAccountProfile($_POST['accountContainerSelectLoadProfile'], $this->type->getId());
|
||||
$profile = \LAM\PROFILES\loadAccountProfile($_POST['accountContainerSelectLoadProfile'], $this->type->getId(), $_SESSION['config']->getName());
|
||||
$this->lastLoadedProfile = $_POST['accountContainerSelectLoadProfile'];
|
||||
// pass profile to each module
|
||||
$modules = array_keys($this->module);
|
||||
|
@ -1775,7 +1775,7 @@ class accountContainer {
|
|||
$this->lastLoadedProfile = $cookieProfileName;
|
||||
}
|
||||
}
|
||||
$profile = \LAM\PROFILES\loadAccountProfile($profileName, $this->type->getId());
|
||||
$profile = \LAM\PROFILES\loadAccountProfile($profileName, $this->type->getId(), $_SESSION['config']->getName());
|
||||
// pass profile to each module
|
||||
$modules = array_keys($this->module);
|
||||
foreach ($modules as $module) $this->module[$module]->load_profile($profile);
|
||||
|
|
|
@ -5,7 +5,7 @@ use \LAMException;
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2018 Roland Gruber
|
||||
Copyright (C) 2003 - 2020 Roland Gruber
|
||||
|
||||
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
|
||||
|
@ -84,16 +84,17 @@ function profileExists($name, $typeId) {
|
|||
*
|
||||
* @param string $profile name of the profile (without .<scope> extension)
|
||||
* @param string $typeId account type
|
||||
* @param string $serverProfileName server profile name
|
||||
* @return array hash array (attribute => value)
|
||||
*/
|
||||
function loadAccountProfile($profile, $typeId) {
|
||||
function loadAccountProfile($profile, $typeId, $serverProfileName) {
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$type = $typeManager->getConfiguredType($typeId);
|
||||
if (!isValidProfileName($profile) || !preg_match("/^[a-z0-9_]+$/i", $typeId) || ($type == null)) {
|
||||
return false;
|
||||
}
|
||||
$settings = array();
|
||||
$file = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/" . $_SESSION['config']->getName() . '/' . $profile . "." . $typeId;
|
||||
$file = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/" . $serverProfileName . '/' . $profile . "." . $typeId;
|
||||
if (is_file($file)) {
|
||||
$file = @fopen($file, "r");
|
||||
if ($file) {
|
||||
|
@ -133,9 +134,10 @@ function loadAccountProfile($profile, $typeId) {
|
|||
* @param array $attributes hash array (attribute => value)
|
||||
* @param string $profile name of the account profile (without .<scope> extension)
|
||||
* @param string $typeId account type
|
||||
* @param string $serverProfileName server profile name
|
||||
* @return boolean true, if saving succeeded
|
||||
*/
|
||||
function saveAccountProfile($attributes, $profile, $typeId) {
|
||||
function saveAccountProfile($attributes, $profile, $typeId, $serverProfileName) {
|
||||
if (!isLoggedIn()) return false;
|
||||
// check profile name and type id
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
|
@ -146,7 +148,7 @@ function saveAccountProfile($attributes, $profile, $typeId) {
|
|||
if (!is_array($attributes)) {
|
||||
return false;
|
||||
}
|
||||
$path = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/" . $_SESSION['config']->getName() . '/' . $profile . "." . $typeId;
|
||||
$path = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/" . $serverProfileName . '/' . $profile . "." . $typeId;
|
||||
$file = @fopen($path, "w");
|
||||
if ($file) {
|
||||
// write attributes
|
||||
|
|
|
@ -10,7 +10,7 @@ use \htmlSubTitle;
|
|||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2019 Roland Gruber
|
||||
Copyright (C) 2003 - 2020 Roland Gruber
|
||||
|
||||
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
|
||||
|
@ -127,7 +127,7 @@ if (isset($_POST['save'])) {
|
|||
$errors = checkProfileOptions($_POST['accounttype'], $options);
|
||||
if (sizeof($errors) == 0) { // input data is valid, save profile
|
||||
// save profile
|
||||
if (\LAM\PROFILES\saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) {
|
||||
if (\LAM\PROFILES\saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'], $_SESSION['config']->getName())) {
|
||||
metaRefresh('profilemain.php?savedSuccessfully=' . $_POST['profname']);
|
||||
exit();
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ if (isset($_POST['save'])) {
|
|||
}
|
||||
}
|
||||
elseif (isset($_GET['edit'])) {
|
||||
$old_options = \LAM\PROFILES\loadAccountProfile($_GET['edit'], $type->getId());
|
||||
$old_options = \LAM\PROFILES\loadAccountProfile($_GET['edit'], $type->getId(), $_SESSION['config']->getName());
|
||||
}
|
||||
|
||||
// display formular
|
||||
|
|
Loading…
Reference in New Issue