From 0f1bd1b5509308ca9010091ea0e9b37863181212 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 23 Oct 2013 17:26:00 +0000 Subject: [PATCH] switch primary group in additional group memberships (RFE 108) --- lam/lib/modules/posixAccount.inc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 63d24d26..d0cab3cb 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -988,6 +988,15 @@ class posixAccount extends baseModule implements passwordService { $errorMessage = $this->messages['gidNumber'][2]; $errorMessage[] = array($this->orig['gidNumber'][0], $this->orig['uidNumber'][0], $_POST['gidNumber']); $errors[] = $errorMessage; + if ($this->isBooleanConfigOptionSet('posixAccount_primaryGroupAsSecondary') && !empty($this->attributes['gidNumber'][0])) { + // change primary group in $this->groups + $oldGroupName = $this->getGroupName($this->attributes['gidNumber'][0]); + $newGroupName = $this->getGroupName($_POST['gidNumber']); + if (!empty($oldGroupName) && !empty($newGroupName)) { + $this->groups = array_delete(array($oldGroupName), $this->groups); + $this->groups[] = $newGroupName; + } + } } if (isset($this->orig['uidNumber'][0]) && $this->orig['uidNumber'][0]!='' && trim($_POST['uidNumber'])!=$this->attributes['uidNumber'][0]) { $errorMessage = $this->messages['uidNumber'][5];