From d44f8e2b4204629cb7efaa6e5b4fa87f43544982 Mon Sep 17 00:00:00 2001
From: Paul Mehrer
Date: Wed, 16 Dec 2020 09:36:14 +0100
Subject: [PATCH] fix(TB/Admin rename default groups) only default user group
could be renamed. now all default groups can safely be renamed
Change-Id: Ia1a1c1901bf7c5bd249cb2a74cfc5fe126d63625
Reviewed-on: http://gerrit.tine20.com/customers/18727
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Paul Mehrer
---
tine20/Admin/Controller/Group.php | 6 +++---
tine20/Tinebase/Group.php | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/tine20/Admin/Controller/Group.php b/tine20/Admin/Controller/Group.php
index f391696bb08..387cccc069e 100644
--- a/tine20/Admin/Controller/Group.php
+++ b/tine20/Admin/Controller/Group.php
@@ -211,12 +211,12 @@ public function update(Tinebase_Model_Group $_group, $_updateList = true)
// update default user group if name has changed
$oldGroup = Tinebase_Group::getInstance()->getGroupById($_group->getId());
- $defaultGroupName = Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
- if ($oldGroup->name == $defaultGroupName && $oldGroup->name != $_group->name) {
+ if ($oldGroup->name !== $_group->name &&
+ false !== ($confKey = Tinebase_Group::getDefaultGroupConfigKey($oldGroup->name))) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
. ' Updated default group name: ' . $oldGroup->name . ' -> ' . $_group->name
);
- Tinebase_User::setBackendConfiguration($_group->name, Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
+ Tinebase_User::setBackendConfiguration($_group->name, $confKey);
Tinebase_User::saveBackendConfiguration();
}
diff --git a/tine20/Tinebase/Group.php b/tine20/Tinebase/Group.php
index c2c18ba486c..d3bc60782b9 100644
--- a/tine20/Tinebase/Group.php
+++ b/tine20/Tinebase/Group.php
@@ -414,6 +414,32 @@ public static function createInitialGroups()
Tinebase_Group::getInstance()->addGroup($anonymousGroup);
}
+ /**
+ * returns the config key of the default group for that name or false in case that group name is not a default group
+ *
+ * @param string $groupName
+ * @return false|string
+ */
+ public static function getDefaultGroupConfigKey($groupName)
+ {
+ if ((Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY)
+ ? Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY)
+ : self::DEFAULT_ADMIN_GROUP) === $groupName) {
+ return Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY;
+ }
+ if ((Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY)
+ ? Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY)
+ : self::DEFAULT_USER_GROUP) === $groupName) {
+ return Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY;
+ }
+ if ((Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_ANONYMOUS_GROUP_NAME_KEY)
+ ? Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_ANONYMOUS_GROUP_NAME_KEY)
+ : self::DEFAULT_ANONYMOUS_GROUP) === $groupName) {
+ return Tinebase_User::DEFAULT_ANONYMOUS_GROUP_NAME_KEY;
+ }
+ return false;
+ }
+
public static function unsetInstance()
{
self::$_instance = null;