From d630e1f9b0abee6d7c274963d1b5f5ff2974577b Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 18 Feb 2011 19:15:43 +0000 Subject: [PATCH] fixed renaming of default profile (3183920) --- lam/HISTORY | 2 ++ lam/templates/config/profmanage.php | 10 +++++++--- lam/templates/login.php | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index f44deea1..2fe29c89 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -3,6 +3,8 @@ April 2011 3.4.0 - LAM Pro: -> support automount entries -> Zarafa groups: allow combination with group of names + - fixed bugs: + -> renaming of default profile (3183920) 12.02.2011 3.3.0 diff --git a/lam/templates/config/profmanage.php b/lam/templates/config/profmanage.php index 84d13782..ece5df77 100644 --- a/lam/templates/config/profmanage.php +++ b/lam/templates/config/profmanage.php @@ -129,12 +129,16 @@ if (isset($_POST['submit'])) { } // rename profile elseif ($_POST['action'] == "rename") { - if (preg_match("/^[a-z0-9_-]+$/i", $_POST['renfilename']) && !in_array($_POST['renfilename'], getConfigProfiles())) { - if (rename("../../config/" . $_POST['oldfilename'] . ".conf", - "../../config/" . $_POST['renfilename'] . ".conf")) { + if (preg_match("/^[a-z0-9_-]+$/i", $_POST['oldfilename']) && preg_match("/^[a-z0-9_-]+$/i", $_POST['renfilename']) && !in_array($_POST['renfilename'], getConfigProfiles())) { + if (rename("../../config/" . $_POST['oldfilename'] . ".conf", "../../config/" . $_POST['renfilename'] . ".conf")) { $msg = _("Renamed profile."); } else $error = _("Could not rename file!"); + // update default profile setting if needed + if ($cfg->default == $_POST['oldfilename']) { + $cfg->default = $_POST['renfilename']; + $cfg->save(); + } } else $error = _("Profile name is invalid!"); } diff --git a/lam/templates/login.php b/lam/templates/login.php index 47618cdb..4c0f81e4 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -68,7 +68,7 @@ if(isset($_GET['useProfile'])) { $default_Config = new LAMCfgMain(); $_SESSION["cfgMain"] = $default_Config; $default_Profile = $default_Config->default; -if(isset($_COOKIE["lam_default_profile"])) { +if(isset($_COOKIE["lam_default_profile"]) && in_array($_COOKIE["lam_default_profile"], getConfigProfiles())) { $default_Profile = $_COOKIE["lam_default_profile"]; } // Reload loginpage after a profile change