Commit 7516d413e088d8a85e6313599c3f8a5192349654
1 parent
8562bf37
Use Group addMember and removeMember rather than mess directly with link
objects. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3425 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
6 additions
and
10 deletions
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/editUserGroupsBL.php
| ... | ... | @@ -36,24 +36,20 @@ KTUtil::extractGPC('fAssign', 'fUserID', 'fUserSet', 'groupAddedLeft', 'groupAdd |
| 36 | 36 | */ |
| 37 | 37 | function updateGroups($iUserID, $aToAddIDs, $aToRemoveIDs) { |
| 38 | 38 | |
| 39 | - // Add groups | |
| 39 | + $oUser = User::get($iUserID); | |
| 40 | + | |
| 40 | 41 | foreach ($aToAddIDs as $iGroupID ) { |
| 41 | 42 | if ($iGroupID > 0) { |
| 42 | - $oUserGroup = new GroupUserLink($iGroupID, $iUserID); | |
| 43 | - if (!$oUserGroup->create()) { | |
| 44 | - return false; | |
| 45 | - } | |
| 43 | + $oGroup = Group::get($iGroupID); | |
| 44 | + $oGroup->addMember($oUser); | |
| 46 | 45 | } |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | // Remove groups |
| 50 | 49 | foreach ($aToRemoveIDs as $iGroupID ) { |
| 51 | 50 | if ($iGroupID > 0) { |
| 52 | - $oUserGroup = new GroupUserLink($iGroupID, $iUserID); | |
| 53 | - $oUserGroup->setUserGroupID($iGroupID,$iUserID); | |
| 54 | - if(!$oUserGroup->delete()) { | |
| 55 | - return false; | |
| 56 | - } | |
| 51 | + $oGroup = Group::get($iGroupID); | |
| 52 | + $oGroup->removeMember($oUser); | |
| 57 | 53 | } |
| 58 | 54 | } |
| 59 | 55 | ... | ... |