diff --git a/lib/groups/GroupUtil.php b/lib/groups/GroupUtil.php index d8bee70..cc0e441 100644 --- a/lib/groups/GroupUtil.php +++ b/lib/groups/GroupUtil.php @@ -8,31 +8,31 @@ * Document Management Made Simple * Copyright (C) 2008, 2009 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original + * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ */ @@ -251,6 +251,24 @@ class GroupUtil { return $aRet; } + /** + * Lists all the available sub groups + */ + function _listSubGroups() + { + global $default; + $sql = 'SELECT parent_group_id, member_group_id FROM '.$default->groups_groups_table; + $aGroups = DBUtil::getResultArray($sql); + + foreach ($aGroups as $aRow) { + $aList = KTUtil::arrayGet($aDirectGroups, $aRow['parent_group_id'], array()); + $aList[] = $aRow['member_group_id']; + $aDirectGroups[$aRow['parent_group_id']] = $aList; + } + + return GroupUtil::expandGroupArray($aDirectGroups); + } + // {{{ _listGroupsIDsForUserExpand function _listGroupIDsForUserExpand ($oUser) { $iUserId = KTUtil::getId($oUser); @@ -265,8 +283,11 @@ class GroupUtil { if (KTLOG_CACHE) $default->log->debug(sprintf("Using group cache for _listGroupIDsForUserExpand %d", $iUserId)); return $mCached; } - $aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::buildGroupArray()); - $aDirectGroups = GroupUtil::listGroupsForUser($oUser); + + // Get all subgroups + $aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::_listSubGroups()); + //$aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::buildGroupArray()); + //$aDirectGroups = GroupUtil::listGroupsForUser($oUser); $sQuery = "SELECT group_id FROM $default->users_groups_table WHERE user_id = ?"; $aParams = array($iUserId); $aGroupIDs = DBUtil::getResultArrayKey(array($sQuery, $aParams), "group_id"); diff --git a/lib/permissions/permissionutil.inc.php b/lib/permissions/permissionutil.inc.php index 2aa6c10..d18cdd3 100644 --- a/lib/permissions/permissionutil.inc.php +++ b/lib/permissions/permissionutil.inc.php @@ -511,23 +511,21 @@ class KTPermissionUtil { } // check if permission has been set // $permArr[permId] = array('folders' => array('id' => bool), 'docs' => array('id' => bool)); - if(isset($permArr[$iPermId][$lookup][$iDocId])){ - return $permArr[$iPermId][$lookup][$iDocId]; + if(isset(KTPermissionUtil::$permArr[$iPermId][$lookup][$iDocId])){ + return KTPermissionUtil::$permArr[$iPermId][$lookup][$iDocId]; } - - $oPL = KTPermissionLookup::get($oFolderOrDocument->getPermissionLookupID()); $oPLA = KTPermissionLookupAssignment::getByPermissionAndLookup($oPermission, $oPL); if (PEAR::isError($oPLA)) { //print $oPL->getID(); - $permArr[$iPermId][$lookup][$iDocId] = false; + KTPermissionUtil::$permArr[$iPermId][$lookup][$iDocId] = false; return false; } $oPD = KTPermissionDescriptor::get($oPLA->getPermissionDescriptorID()); // set permission array to true - $permArr[$iPermId][$lookup][$iDocId] = true; + KTPermissionUtil::$permArr[$iPermId][$lookup][$iDocId] = true; // check for permissions $aGroups = GroupUtil::listGroupsForUserExpand($oUser); @@ -537,7 +535,7 @@ class KTPermissionUtil { else if ($oPD->hasRoles(array(-4)) && !$oUser->isAnonymous()) { return true; } // permission isn't true, set to false - $permArr[$iPermId][$lookup][$iDocId] = false; + KTPermissionUtil::$permArr[$iPermId][$lookup][$iDocId] = false; return false; } // }}}