Commit 0f2f79fb8829f0bbbaa18f5af3c99cdec1c7bee6

Authored by nbm
1 parent 5f8e2df5

Deal with the case where findRootObjectForPermissionObject is called on

a permission object which is set by a document (for itself).


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3651 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/permissions/permissionutil.inc.php
@@ -182,9 +182,15 @@ class KTPermissionUtil { @@ -182,9 +182,15 @@ class KTPermissionUtil {
182 */ 182 */
183 $sQuery = "SELECT id FROM $default->folders_table WHERE permission_object_id = ? ORDER BY LENGTH(parent_folder_ids) LIMIT 1"; 183 $sQuery = "SELECT id FROM $default->folders_table WHERE permission_object_id = ? ORDER BY LENGTH(parent_folder_ids) LIMIT 1";
184 $aParams = array($oPO->getID()); 184 $aParams = array($oPO->getID());
185 - $res = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id');  
186 - if (is_array($res)) {  
187 - return Folder::get($res[0]); 185 + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
  186 + if (!is_null($res)) {
  187 + return Folder::get($res);
  188 + }
  189 + $sQuery = "SELECT id FROM $default->documents_table WHERE permission_object_id = ? LIMIT 1";
  190 + $aParams = array($oPO->getID());
  191 + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
  192 + if (!is_null($res)) {
  193 + return Document::get($res);
188 } 194 }
189 return false; 195 return false;
190 } 196 }