Commit 5df727905c746d19f1010082ba75e5bccb956522
1 parent
545a3bae
Remove old folder permissions edit/view code - folder permission
view/edit is now a folder action. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4127 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
0 additions
and
304 deletions
presentation/lookAndFeel/knowledgeTree/foldermanagement/copyInheritedPermissionsBL.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Business logic used to edit folder properties | |
| 6 | - * | |
| 7 | - * Expected form variables: | |
| 8 | - * o $fFolderID - primary key of folder user is currently browsing | |
| 9 | - * | |
| 10 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 11 | - * | |
| 12 | - * This program is free software; you can redistribute it and/or modify | |
| 13 | - * it under the terms of the GNU General Public License as published by | |
| 14 | - * the Free Software Foundation; either version 2 of the License, or | |
| 15 | - * (at your option) any later version. | |
| 16 | - * | |
| 17 | - * This program is distributed in the hope that it will be useful, | |
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | - * GNU General Public License for more details. | |
| 21 | - * | |
| 22 | - * You should have received a copy of the GNU General Public License | |
| 23 | - * along with this program; if not, write to the Free Software | |
| 24 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 25 | - * | |
| 26 | - * @version $Revision$ | |
| 27 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 28 | - * @package foldermanagement | |
| 29 | - */ | |
| 30 | - | |
| 31 | -require_once("../../../../config/dmsDefaults.php"); | |
| 32 | - | |
| 33 | -KTUtil::extractGPC('fInheritedFolderID', 'fFolderID'); | |
| 34 | - | |
| 35 | -if (!checkSession()) { | |
| 36 | - exit(0); | |
| 37 | -} | |
| 38 | - | |
| 39 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | |
| 40 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc"); | |
| 41 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); | |
| 42 | -require_once("editUI.inc"); | |
| 43 | -require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | |
| 44 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 45 | -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | |
| 46 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | |
| 47 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 48 | -require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 49 | - | |
| 50 | -$oPatternCustom = & new PatternCustom(); | |
| 51 | - | |
| 52 | -if (!isset($fFolderID)) { | |
| 53 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 54 | - $main->setErrorMessage(_("No folder currently selected")); | |
| 55 | - $main->setCentralPayload($oPatternCustom); | |
| 56 | - $main->render(); | |
| 57 | - exit(0); | |
| 58 | -} | |
| 59 | - | |
| 60 | -$oFolder = Folder::get($fFolderID); | |
| 61 | -if (!$oFolder) { | |
| 62 | - // folder doesn't exist | |
| 63 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 64 | - $main->setErrorMessage(_("The folder you're trying to modify does not exist in the DMS")); | |
| 65 | - $main->setCentralPayload($oPatternCustom); | |
| 66 | - $main->render(); | |
| 67 | - exit(0); | |
| 68 | -} | |
| 69 | - | |
| 70 | -if (!isset($fInheritedFolderID)) { | |
| 71 | - //else display an error message | |
| 72 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 73 | - $main->setErrorMessage(_("No inherited folder given")); | |
| 74 | - $main->setCentralPayload($oPatternCustom); | |
| 75 | - $main->render(); | |
| 76 | - exit(0); | |
| 77 | -} | |
| 78 | - | |
| 79 | -$oInheritedFolder = Folder::get($fInheritedFolderID); | |
| 80 | -if (!$oInheritedFolder) { | |
| 81 | - //else display an error message | |
| 82 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 83 | - $main->setErrorMessage(_("The inherited folder given does not exist in the DMS")); | |
| 84 | - $main->setCentralPayload($oPatternCustom); | |
| 85 | - $main->render(); | |
| 86 | - exit(0); | |
| 87 | -} | |
| 88 | - | |
| 89 | -//if the user can edit the folder | |
| 90 | -if (!Permission::userHasFolderWritePermission($oFolder)) { | |
| 91 | - //user does not have write permission for this folder, | |
| 92 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 93 | - $main->setErrorMessage(_("You do not have permission to edit this folder")); | |
| 94 | - $main->setCentralPayload($oPatternCustom); | |
| 95 | - $main->render(); | |
| 96 | - exit(0); | |
| 97 | -} | |
| 98 | - | |
| 99 | -$sQuery = DBUtil::compactQuery(" | |
| 100 | -SELECT | |
| 101 | - GFL.group_id AS group_id, | |
| 102 | - GFL.can_read AS can_read, | |
| 103 | - GFL.can_write AS can_write | |
| 104 | -FROM | |
| 105 | - $default->groups_folders_table AS GFL | |
| 106 | -WHERE GFL.folder_id = ?"); | |
| 107 | -$aParams = array($fInheritedFolderID); | |
| 108 | -$aPermissions = DBUtil::getResultArray(array($sQuery, $aParams)); | |
| 109 | - | |
| 110 | -if (PEAR::isError($aPermissions)) { | |
| 111 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 112 | - $main->setErrorMessage(_("Error retrieving folder permissions")); | |
| 113 | - $main->setCentralPayload($oPatternCustom); | |
| 114 | - $main->render(); | |
| 115 | - exit(0); | |
| 116 | -} | |
| 117 | - | |
| 118 | -foreach ($aPermissions as $aRow) { | |
| 119 | - $aRow['folder_id'] = $fFolderID; | |
| 120 | - $res = DBUtil::autoInsert($default->groups_folders_table, $aRow); | |
| 121 | - if (PEAR::isError($res)) { | |
| 122 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 123 | - $main->setErrorMessage(_("Error saving folder permissions")); | |
| 124 | - $main->setCentralPayload($oPatternCustom); | |
| 125 | - $main->render(); | |
| 126 | - exit(0); | |
| 127 | - } | |
| 128 | -} | |
| 129 | - | |
| 130 | -$oFolder->updatePermissions(); | |
| 131 | - | |
| 132 | -controllerRedirect("editFolder", "fFolderID=$fFolderID&fShowSection=folderPermissions"); | |
| 133 | - | |
| 134 | -?> |
presentation/lookAndFeel/knowledgeTree/foldermanagement/folderPermissions.php deleted
| 1 | -<?php | |
| 2 | - | |
| 3 | -require_once("../../../../config/dmsDefaults.php"); | |
| 4 | - | |
| 5 | -require_once(KT_DIR . "/presentation/Html.inc"); | |
| 6 | - | |
| 7 | -require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 8 | -require_once(KT_LIB_DIR . "/permissions/permission.inc.php"); | |
| 9 | -require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); | |
| 10 | -require_once(KT_LIB_DIR . "/groups/Group.inc"); | |
| 11 | - | |
| 12 | -require_once(KT_LIB_DIR . "/permissions/permission.inc.php"); | |
| 13 | -require_once(KT_LIB_DIR . "/permissions/permissionobject.inc.php"); | |
| 14 | -require_once(KT_LIB_DIR . "/permissions/permissionassignment.inc.php"); | |
| 15 | -require_once(KT_LIB_DIR . "/permissions/permissiondescriptor.inc.php"); | |
| 16 | -require_once(KT_LIB_DIR . "/permissions/permissionutil.inc.php"); | |
| 17 | -require_once(KT_LIB_DIR . "/permissions/permissiondynamiccondition.inc.php"); | |
| 18 | - | |
| 19 | -require_once(KT_LIB_DIR . "/search/savedsearch.inc.php"); | |
| 20 | - | |
| 21 | -require_once(KT_LIB_DIR . "/dispatcher.inc.php"); | |
| 22 | -$sectionName = "Manage Documents"; | |
| 23 | -require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | |
| 24 | - | |
| 25 | -function displayFolderPathLink($aPathArray, $aPathNameArray, $sLinkPage = "") { | |
| 26 | - global $default; | |
| 27 | - if (strlen($sLinkPage) == 0) { | |
| 28 | - $sLinkPage = $_SERVER["PHP_SELF"]; | |
| 29 | - } | |
| 30 | - $default->log->debug("displayFolderPathLink: slinkPage=$sLinkPage"); | |
| 31 | - // display a separate link to each folder in the path | |
| 32 | - for ($i=0; $i<count($aPathArray); $i++) { | |
| 33 | - $iFolderId = $aPathArray[$i]; | |
| 34 | - // retrieve the folder name for this folder | |
| 35 | - $sFolderName = $aPathNameArray[$i]; | |
| 36 | - // generate a link back to this page setting fFolderId | |
| 37 | - $sLink = generateLink($sLinkPage, | |
| 38 | - "fBrowseType=folder&fFolderID=$iFolderId", | |
| 39 | - $sFolderName); | |
| 40 | - $sPathLinks = (strlen($sPathLinks) > 0) ? $sPathLinks . " > " . $sLink : $sLink; | |
| 41 | - } | |
| 42 | - return $sPathLinks; | |
| 43 | -} | |
| 44 | - | |
| 45 | - | |
| 46 | -class FolderPermissions extends KTStandardDispatcher { | |
| 47 | - var $bAutomaticTransaction = true; | |
| 48 | - | |
| 49 | - function check() { | |
| 50 | - if (KTUtil::arrayGet($_REQUEST, 'fFolderID')) { | |
| 51 | - $_REQUEST['fFolderId'] = $_REQUEST['fFolderID']; | |
| 52 | - } | |
| 53 | - $this->oFolder =& $this->oValidator->validateFolder($_REQUEST['fFolderId']); | |
| 54 | - return true; | |
| 55 | - } | |
| 56 | - function do_main() { | |
| 57 | - $oTemplating = new KTTemplating; | |
| 58 | - $oTemplate = $oTemplating->loadTemplate("ktcore/folder/permissions"); | |
| 59 | - $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); | |
| 60 | - $aPermissions = KTPermission::getList(); | |
| 61 | - $aMapPermissionGroup = array(); | |
| 62 | - foreach ($aPermissions as $oPermission) { | |
| 63 | - $oPA = KTPermissionAssignment::getByPermissionAndObject($oPermission, $oPO); | |
| 64 | - if (PEAR::isError($oPA)) { | |
| 65 | - continue; | |
| 66 | - } | |
| 67 | - $oDescriptor = KTPermissionDescriptor::get($oPA->getPermissionDescriptorId()); | |
| 68 | - $iPermissionId = $oPermission->getId(); | |
| 69 | - $aIds = $oDescriptor->getGroups(); | |
| 70 | - $aMapPermissionGroup[$iPermissionId] = array(); | |
| 71 | - foreach ($aIds as $iId) { | |
| 72 | - $aMapPermissionGroup[$iPermissionId][$iId] = true; | |
| 73 | - } | |
| 74 | - } | |
| 75 | - $aMapPermissionUser = array(); | |
| 76 | - $aUsers = User::getList(); | |
| 77 | - foreach ($aPermissions as $oPermission) { | |
| 78 | - $iPermissionId = $oPermission->getId(); | |
| 79 | - foreach ($aUsers as $oUser) { | |
| 80 | - if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPermission, $this->oFolder)) { | |
| 81 | - $aMapPermissionUser[$iPermissionId][$oUser->getId()] = true; | |
| 82 | - } | |
| 83 | - } | |
| 84 | - } | |
| 85 | - | |
| 86 | - $oInherited = KTPermissionUtil::findRootObjectForPermissionObject($oPO); | |
| 87 | - if ($oInherited === $this->oFolder) { | |
| 88 | - $bEdit = true; | |
| 89 | - } else { | |
| 90 | - $iInheritedFolderId = $oInherited->getId(); | |
| 91 | - $sInherited = displayFolderPathLink(Folder::getFolderPathAsArray($iInheritedFolderId), | |
| 92 | - Folder::getFolderPathNamesAsArray($iInheritedFolderId), | |
| 93 | - "$default->rootUrl/control.php?action=editFolderPermissions"); | |
| 94 | - $bEdit = false; | |
| 95 | - } | |
| 96 | - | |
| 97 | - $aDynamicConditions = KTPermissionDynamicCondition::getByPermissionObject($oPO); | |
| 98 | - $aTemplateData = array( | |
| 99 | - "permissions" => $aPermissions, | |
| 100 | - "groups" => Group::getList(), | |
| 101 | - "iFolderId" => $this->oFolder->getId(), | |
| 102 | - "aMapPermissionGroup" => $aMapPermissionGroup, | |
| 103 | - "users" => $aUsers, | |
| 104 | - "aMapPermissionUser" => $aMapPermissionUser, | |
| 105 | - "edit" => $bEdit, | |
| 106 | - "inherited" => $sInherited, | |
| 107 | - "conditions" => KTSavedSearch::getConditions(), | |
| 108 | - "dynamic_conditions" => $aDynamicConditions, | |
| 109 | - ); | |
| 110 | - return $oTemplate->render($aTemplateData); | |
| 111 | - } | |
| 112 | - | |
| 113 | - function handleOutput($data) { | |
| 114 | - global $main; | |
| 115 | - $main->bFormDisabled = true; | |
| 116 | - $main->setCentralPayload($data); | |
| 117 | - $main->render(); | |
| 118 | - } | |
| 119 | - | |
| 120 | - function do_update() { | |
| 121 | - $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); | |
| 122 | - $aFoo = $_REQUEST['foo']; | |
| 123 | - $aPermissions = KTPermission::getList(); | |
| 124 | - foreach ($aPermissions as $oPermission) { | |
| 125 | - $iPermId = $oPermission->getId(); | |
| 126 | - $aAllowed = KTUtil::arrayGet($aFoo, $iPermId, array()); | |
| 127 | - KTPermissionUtil::setPermissionForId($oPermission, $oPO, $aAllowed); | |
| 128 | - } | |
| 129 | - KTPermissionUtil::updatePermissionLookupForPO($oPO); | |
| 130 | - return $this->successRedirectToMain('Permissions updated', | |
| 131 | - array('fFolderId' => $this->oFolder->getId())); | |
| 132 | - } | |
| 133 | - | |
| 134 | - function do_copyPermissions() { | |
| 135 | - KTPermissionUtil::copyPermissionObject($this->oFolder); | |
| 136 | - return $this->successRedirectToMain('Permissions updated', | |
| 137 | - array('fFolderId' => $oFolder->getId())); | |
| 138 | - } | |
| 139 | - | |
| 140 | - function do_inheritPermissions() { | |
| 141 | - KTPermissionUtil::inheritPermissionObject($this->oFolder); | |
| 142 | - return $this->successRedirectToMain('Permissions updated', | |
| 143 | - array('fFolderId' => $this->oFolder->getId())); | |
| 144 | - } | |
| 145 | - | |
| 146 | - function do_newDynamicPermission() { | |
| 147 | - $oGroup =& $this->oValidator->validateGroup($_REQUEST['fGroupId']); | |
| 148 | - $oCondition =& $this->oValidator->validateCondition($_REQUEST['fConditionId']); | |
| 149 | - $aPermissionIds = $_REQUEST['fPermissionIds']; | |
| 150 | - $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); | |
| 151 | - | |
| 152 | - $oDynamicCondition = KTPermissionDynamicCondition::createFromArray(array( | |
| 153 | - 'groupid' => $oGroup->getId(), | |
| 154 | - 'conditionid' => $oCondition->getId(), | |
| 155 | - 'permissionobjectid' => $oPO->getId(), | |
| 156 | - )); | |
| 157 | - $aOptions = array( | |
| 158 | - 'redirect_to' => array('main', 'fFolderId=' . $this->oFolder->getId()), | |
| 159 | - ); | |
| 160 | - $this->oValidator->notError($oDynamicCondition, $aOptions); | |
| 161 | - $res = $oDynamicCondition->saveAssignment($aPermissionIds); | |
| 162 | - $this->oValidator->notError($res, $aOptions); | |
| 163 | - $this->successRedirectToMain("Dynamic permission added", "fFolderId=" . $this->oFolder->getId()); | |
| 164 | - } | |
| 165 | -} | |
| 166 | - | |
| 167 | -$oDispatcher = new FolderPermissions; | |
| 168 | -$oDispatcher->dispatch(); | |
| 169 | - | |
| 170 | -?> |