Commit 48cdcd25c311f254121ccbda8fcf7281c2797037

Authored by nbm
1 parent 7c980159

Deal with folders that don't have permission_folder_id set properly for

whatever reason.  Copy their parent until we find someone with
permission_folder_id set.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5498 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/upgrades/UpgradeFunctions.inc.php
... ... @@ -224,6 +224,14 @@ class UpgradeFunctions {
224 224 global $default;
225 225 require_once(KT_LIB_DIR . '/permissions/permissionobject.inc.php');
226 226  
  227 + DBUtil::runQuery("UPDATE folders SET permission_folder_id = 1 WHERE id = 1");
  228 + $aBrokenFolders = DBUtil::getResultArray('SELECT id, parent_id FROM folders WHERE permission_folder_id = 0 OR permission_folder_id IS NULL ORDER BY LENGTH(parent_folder_ids)');
  229 + foreach ($aBrokenFolders as $aFolderInfo) {
  230 + $iFolderId = $aFolderInfo['id'];
  231 + $iParentFolderId = $aFolderInfo['parent_id'];
  232 + $iParentFolderPermissionFolder = DBUtil::getOneResultKey(array("SELECT permission_folder_id FROM folders WHERE id = ?", array($iParentFolderId)), 'permission_folder_id');
  233 + $res = DBUtil::whereUpdate('folders', array('permission_folder_id' => $iParentFolderPermissionFolder), array('id' => $iFolderId));
  234 + }
227 235  
228 236 // First, set permission object on all folders that were
229 237 // "permission folders".
... ... @@ -260,7 +268,6 @@ class UpgradeFunctions {
260 268 DBUtil::runQuery($query);
261 269 }
262 270  
263   -
264 271 $sDocumentsTable = KTUtil::getTableName('documents');
265 272 $sFoldersTable = KTUtil::getTableName('folders');
266 273  
... ...