Commit 07e3abe21e33c4a7c650b5b1783856c9f6d5183b
1 parent
f01c5784
Add an option for getByGroups to return ids rather than objects.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3558 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
15 additions
and
3 deletions
lib/permissions/permissiondescriptor.inc.php
| ... | ... | @@ -131,11 +131,19 @@ class KTPermissionDescriptor extends KTEntity { |
| 131 | 131 | return $aRet; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - function &getByGroups($aGroups) { | |
| 134 | + function &getByGroups($aGroups, $aOptions = null) { | |
| 135 | 135 | global $default; |
| 136 | + if (is_null($aOptions)) { | |
| 137 | + $aOptions = array(); | |
| 138 | + } | |
| 139 | + $ids = KTUtil::arrayGet($aOptions, 'ids'); | |
| 136 | 140 | $aGroupIDs = array(); |
| 137 | 141 | foreach ($aGroups as $oGroup) { |
| 138 | - $aGroupIDs[] = $oGroup->getID(); | |
| 142 | + if (is_numeric($oGroup)) { | |
| 143 | + $aGroupIDs[] = $oGroup; | |
| 144 | + } else { | |
| 145 | + $aGroupIDs[] = $oGroup->getID(); | |
| 146 | + } | |
| 139 | 147 | } |
| 140 | 148 | $sGroupIDs = DBUtil::paramArray($aGroupIDs); |
| 141 | 149 | $sQuery = "SELECT DISTINCT descriptor_id FROM $default->permission_descriptor_groups_table WHERE group_id IN ( $sGroupIDs )"; |
| ... | ... | @@ -143,7 +151,11 @@ class KTPermissionDescriptor extends KTEntity { |
| 143 | 151 | $aIDs = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'descriptor_id'); |
| 144 | 152 | $aRet = array(); |
| 145 | 153 | foreach ($aIDs as $iID) { |
| 146 | - $aRet[] =& KTPermissionDescriptor::get($iID); | |
| 154 | + if ($ids === true) { | |
| 155 | + $aRet[] = $iID; | |
| 156 | + } else { | |
| 157 | + $aRet[] =& KTPermissionDescriptor::get($iID); | |
| 158 | + } | |
| 147 | 159 | } |
| 148 | 160 | return $aRet; |
| 149 | 161 | } | ... | ... |