diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index aacba5a4..b97f69e3 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -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); diff --git a/lam/lib/profiles.inc b/lam/lib/profiles.inc index 1c05cccc..c6818793 100644 --- a/lam/lib/profiles.inc +++ b/lam/lib/profiles.inc @@ -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 @@ -80,20 +80,21 @@ function profileExists($name, $typeId) { } /** -* Loads an profile of the given account type -* -* @param string $profile name of the profile (without . extension) -* @param string $typeId account type -* @return array hash array (attribute => value) -*/ -function loadAccountProfile($profile, $typeId) { + * Loads an profile of the given account type + * + * @param string $profile name of the profile (without . extension) + * @param string $typeId account type + * @param string $serverProfileName server profile name + * @return array hash array (attribute => value) + */ +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 . 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 diff --git a/lam/templates/profedit/profilepage.php b/lam/templates/profedit/profilepage.php index d6973745..aac4f8a2 100644 --- a/lam/templates/profedit/profilepage.php +++ b/lam/templates/profedit/profilepage.php @@ -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