Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(TB/Admin rename default groups) only default user group could be …
Browse files Browse the repository at this point in the history
…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/) <tine20-jenkins@metaways.de>
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
  • Loading branch information
paulmhh committed Dec 16, 2020
1 parent 6002438 commit d44f8e2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tine20/Admin/Controller/Group.php
Expand Up @@ -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();
}

Expand Down
26 changes: 26 additions & 0 deletions tine20/Tinebase/Group.php
Expand Up @@ -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;
Expand Down

0 comments on commit d44f8e2

Please sign in to comment.