Commit f8d2b151599390527eeda0923d711a150b8477fa

Authored by bshuttle
1 parent 7e5aae3a

fix for 528: recursion fails.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5030 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/KTPermissions.php
@@ -455,7 +455,6 @@ class KTRoleAllocationPlugin extends KTFolderAction { @@ -455,7 +455,6 @@ class KTRoleAllocationPlugin extends KTFolderAction {
455 455
456 function renegeratePermissionsForRole($iRoleId) { 456 function renegeratePermissionsForRole($iRoleId) {
457 $iStartFolderId = $this->oFolder->getId(); 457 $iStartFolderId = $this->oFolder->getId();
458 - $oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($iStartFolderId, $iRoleId);  
459 /* 458 /*
460 * 1. find all folders & documents "below" this one which use the role 459 * 1. find all folders & documents "below" this one which use the role
461 * definition _active_ (not necessarily present) at this point. 460 * definition _active_ (not necessarily present) at this point.
@@ -474,31 +473,22 @@ class KTRoleAllocationPlugin extends KTFolderAction { @@ -474,31 +473,22 @@ class KTRoleAllocationPlugin extends KTFolderAction {
474 * update their permissions. 473 * update their permissions.
475 */ 474 */
476 475
477 - $sQuery = 'SELECT f.id as `id` FROM ' . Folder::_table() . ' AS f LEFT JOIN ' . RoleAllocation::_table() . ' AS ra ON (f.id = ra.folder_id) WHERE f.parent_id = ? AND ra.role_id ';  
478 - if ($oRoleAllocation == null) { // no alloc.  
479 - $sQuery .= ' IS NULL ';  
480 - $hasId = false;  
481 - } else {  
482 - $sQuery .= ' = ? ';  
483 - $aId = $oRoleAllocation->getId();  
484 - $hasId = true;  
485 - } 476 + $sRoleAllocTable = KTUtil::getTableName('role_allocations');
  477 + $sFolderTable = KTUtil::getTableName('folders');
  478 + $sQuery = sprintf('SELECT f.id as id FROM %s AS f LEFT JOIN %s AS ra ON (f.id = ra.folder_id) WHERE ra.id IS NULL AND f.parent_id = ?', $sFolderTable, $sRoleAllocTable);
486 479
487 480
488 $folder_queue = array($iStartFolderId); 481 $folder_queue = array($iStartFolderId);
489 while (!empty($folder_queue)) { 482 while (!empty($folder_queue)) {
490 $active_folder = array_pop($folder_queue); 483 $active_folder = array_pop($folder_queue);
491 484
492 -  
493 - $aParams = array($active_folder);  
494 - if ($hasId) { $aParams[] = $aId; }  
495 - 485 + $aParams = array($active_folder);
496 486
497 $aNewFolders = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); 487 $aNewFolders = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id');
498 if (PEAR::isError($aNewFolders)) { 488 if (PEAR::isError($aNewFolders)) {
499 $this->errorRedirectToMain(_('Failure to generate folderlisting.')); 489 $this->errorRedirectToMain(_('Failure to generate folderlisting.'));
500 } 490 }
501 - $folder_queue = array_merge ($folder_queue, $aNewFolders); // push. 491 + $folder_queue = array_merge ($folder_queue, (array) $aNewFolders); // push.
502 492
503 493
504 // update the folder. 494 // update the folder.