Commit cbcfc8077c12eea4cdffaf5448bf790fe2fd397d
1 parent
43686f9f
fix for KTS-583: delete fails
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5060 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
22 additions
and
10 deletions
browse.php
| ... | ... | @@ -43,6 +43,8 @@ require_once(KT_LIB_DIR . "/widgets/portlet.inc.php"); |
| 43 | 43 | require_once(KT_LIB_DIR . '/actions/folderaction.inc.php'); |
| 44 | 44 | require_once(KT_DIR . '/plugins/ktcore/KTFolderActions.php'); |
| 45 | 45 | |
| 46 | +require_once(KT_LIB_DIR . "/permissions/permissionutil.inc.php"); | |
| 47 | +require_once(KT_LIB_DIR . "/permissions/permission.inc.php"); | |
| 46 | 48 | |
| 47 | 49 | /******* NBM's FAMOUS MOVECOLUMN HACK |
| 48 | 50 | * |
| ... | ... | @@ -683,6 +685,7 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 683 | 685 | $aFolderSelection = KTUtil::arrayGet($_REQUEST, 'selection_f' , array()); |
| 684 | 686 | $aDocumentSelection = KTUtil::arrayGet($_REQUEST, 'selection_d' , array()); |
| 685 | 687 | |
| 688 | + $oPerm = KTPermission::getByName('ktcore.permissions.delete'); | |
| 686 | 689 | |
| 687 | 690 | // now show the items... |
| 688 | 691 | $delItems = array(); |
| ... | ... | @@ -696,6 +699,9 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 696 | 699 | $folderStr = '<strong>' . _('Folders: ') . '</strong>'; |
| 697 | 700 | foreach ($aFolderSelection as $iFolderId) { |
| 698 | 701 | $oF = Folder::get($iFolderId); |
| 702 | + if (!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oF)) { | |
| 703 | + $this->errorRedirectToMain(_('You do not have permission to delete the folder: ') . $oF->getName()); | |
| 704 | + } | |
| 699 | 705 | $delItems['folders'][] = $oF->getName(); |
| 700 | 706 | } |
| 701 | 707 | $folderStr .= implode(', ', $delItems['folders']); |
| ... | ... | @@ -705,7 +711,12 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 705 | 711 | $documentStr = '<strong>' . _('Documents: ') . '</strong>'; |
| 706 | 712 | foreach ($aDocumentSelection as $iDocId) { |
| 707 | 713 | $oD = Document::get($iDocId); |
| 708 | - $delItems['documents'][] = $oD->getName(); | |
| 714 | + if (!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oD)) { | |
| 715 | + $this->errorRedirectToMain(_('You do not have permission to delete the document: ') . $oD->getName()); | |
| 716 | + } | |
| 717 | + if (!PEAR::isError($oD)) { | |
| 718 | + $delItems['documents'][] = $oD->getName(); | |
| 719 | + } | |
| 709 | 720 | } |
| 710 | 721 | $documentStr .= implode(', ', $delItems['documents']); |
| 711 | 722 | } |
| ... | ... | @@ -734,7 +745,7 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 734 | 745 | $fFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1); |
| 735 | 746 | |
| 736 | 747 | |
| 737 | - | |
| 748 | + $oPerm = KTPermission::getByName('ktcore.permissions.delete'); | |
| 738 | 749 | $res = KTUtil::arrayGet($_REQUEST,'sReason'); |
| 739 | 750 | $sReason = $res; |
| 740 | 751 | if (empty($res)) { |
| ... | ... | @@ -751,17 +762,19 @@ class BrowseDispatcher extends KTStandardDispatcher { |
| 751 | 762 | $oF = Folder::get($id); |
| 752 | 763 | if (PEAR::isError($oF) || ($oF == false)) { |
| 753 | 764 | return $this->errorRedirectToMain(_('Invalid Folder selected.')); |
| 754 | - } else { | |
| 765 | + } else if (!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oF)) { | |
| 766 | + return $this->errorRedirectToMain(sprintf(_('You do not have permissions to delete the folder: %s'), $oF->getName())); | |
| 767 | + } else{ | |
| 755 | 768 | $aFolders[] = $oF; |
| 756 | 769 | } |
| 757 | 770 | } |
| 758 | 771 | foreach ($aDocumentSelection as $id) { |
| 759 | 772 | $oD = Document::get($id); |
| 760 | - if (!Permission::userHasDocumentWritePermission($oD)) { | |
| 761 | - return $this->errorRedirectToMain(sprintf(_('You do not have permissions to delete the documen: %s'), $oD->getName())); | |
| 762 | - } | |
| 773 | + | |
| 763 | 774 | if (PEAR::isError($oD) || ($oD == false)) { |
| 764 | 775 | return $this->errorRedirectToMain(_('Invalid Document selected.')); |
| 776 | + } else if (!KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oD)) { | |
| 777 | + return $this->errorRedirectToMain(sprintf(_('You do not have permissions to delete the document: %s'), $oD->getName())); | |
| 765 | 778 | } else { |
| 766 | 779 | $aDocuments[] = $oD; |
| 767 | 780 | } | ... | ... |
lib/foldermanagement/folderutil.inc.php
| ... | ... | @@ -203,8 +203,7 @@ class KTFolderUtil { |
| 203 | 203 | function delete($oStartFolder, $oUser, $sReason, $aOptions = null) { |
| 204 | 204 | require_once(KT_LIB_DIR . '/unitmanagement/Unit.inc'); |
| 205 | 205 | |
| 206 | - // FIXME: we need to work out if "write" is the right perm. | |
| 207 | - $oPerm = KTPermission::getByName('ktcore.permissions.write'); | |
| 206 | + $oPerm = KTPermission::getByName('ktcore.permissions.delete'); | |
| 208 | 207 | |
| 209 | 208 | $bIgnorePermissions = KTUtil::arrayGet($aOptions, 'ignore_permissions'); |
| 210 | 209 | |
| ... | ... | @@ -270,7 +269,7 @@ class KTFolderUtil { |
| 270 | 269 | |
| 271 | 270 | // now we can go ahead. |
| 272 | 271 | foreach ($aDocuments as $oDocument) { |
| 273 | - $res = KTDocumentUtil::delete($oDocument, $sReason, 1); // id of destination folder = ROOT | |
| 272 | + $res = KTDocumentUtil::delete($oDocument, $sReason); | |
| 274 | 273 | if (PEAR::isError($res)) { |
| 275 | 274 | DBUtil::rollback(); |
| 276 | 275 | return PEAR::raiseError(_('Delete Aborted. Unexpected failure to delete document: ') . $oDocument->getName() . $res->getMessage()); | ... | ... |
plugins/ktcore/KTDocumentActions.php
| ... | ... | @@ -359,7 +359,7 @@ class KTDocumentEditAction extends KTDocumentAction { |
| 359 | 359 | class KTDocumentDeleteAction extends KTDocumentAction { |
| 360 | 360 | var $sName = 'ktcore.actions.document.delete'; |
| 361 | 361 | |
| 362 | - var $_sShowPermission = "ktcore.permissions.write"; | |
| 362 | + var $_sShowPermission = "ktcore.permissions.delete"; | |
| 363 | 363 | |
| 364 | 364 | function getDisplayName() { |
| 365 | 365 | return _('Delete'); | ... | ... |