Commit 5aca7c90b51305a3ad33e73f97a444766a708907
1 parent
36f33999
Type: functionality change
Description: Passing through document object instead of document id to permissions checks to avoid redundant DB accesses to intsantiate db model objects git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2880 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
6 changed files
with
19 additions
and
12 deletions
lib/browse/CategoryBrowser.inc
| ... | ... | @@ -106,9 +106,10 @@ class CategoryBrowser extends Browser { |
| 106 | 106 | $results["accessDenied"] = false; |
| 107 | 107 | while ($sql->next_record()) { |
| 108 | 108 | // check permissions |
| 109 | - if (Permission::userHasDocumentReadPermission($sql->f("document_id"))) { | |
| 110 | - $oDocument = & Document::get($sql->f("document_id")); | |
| 111 | - if ($oDocument->isLive()) { | |
| 109 | + $oDocument = & Document::get($sql->f("document_id")); | |
| 110 | + | |
| 111 | + if (Permission::userHasDocumentReadPermission($oDocument)) { | |
| 112 | + if ($oDocument->isLive()) { | |
| 112 | 113 | $results["documents"][] = $oDocument; |
| 113 | 114 | } |
| 114 | 115 | } else { | ... | ... |
lib/browse/DocumentTypeBrowser.inc
| ... | ... | @@ -98,8 +98,9 @@ class DocumentTypeBrowser extends Browser { |
| 98 | 98 | $results["accessDenied"] = false; |
| 99 | 99 | while ($sql->next_record()) { |
| 100 | 100 | // check permission |
| 101 | - if (Permission::userHasDocumentReadPermission($sql->f("id"))) { | |
| 102 | - $oDocument = & Document::get($sql->f("id")); | |
| 101 | + $oDocument = & Document::get($sql->f("id")); | |
| 102 | + if (Permission::userHasDocumentReadPermission($oDocument)) { | |
| 103 | + | |
| 103 | 104 | if ($oDocument->isLive()) { |
| 104 | 105 | $results["documents"][] = $oDocument; |
| 105 | 106 | } | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/downloadBL.php
| ... | ... | @@ -40,7 +40,7 @@ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 40 | 40 | if (checkSession(true)) { |
| 41 | 41 | if (isset($fDocumentID)) { |
| 42 | 42 | $oDocument = Document::get($fDocumentID); |
| 43 | - if (Permission::userHasDocumentReadPermission($fDocumentID)) { | |
| 43 | + if (Permission::userHasDocumentReadPermission($oDocument)) { | |
| 44 | 44 | if (isset($fForInlineView)) { |
| 45 | 45 | $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW); |
| 46 | 46 | $oDocumentTransaction->create(); | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php
| ... | ... | @@ -141,7 +141,7 @@ if (checkSession()) { |
| 141 | 141 | $oDocument = Document::get($fDocumentID); |
| 142 | 142 | |
| 143 | 143 | //if the user can view the document, they can email a link to it |
| 144 | - if (Permission::userHasDocumentReadPermission($fDocumentID)) { | |
| 144 | + if (Permission::userHasDocumentReadPermission($oDocument)) { | |
| 145 | 145 | if (isset($fSendEmail)) { |
| 146 | 146 | // explode group and user ids |
| 147 | 147 | $aGroupIDs = explode(",", $groupNewRight); | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryBL.php
| ... | ... | @@ -52,8 +52,9 @@ require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 52 | 52 | if (checkSession()) { |
| 53 | 53 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 54 | 54 | if (isset($fDocumentID)) { |
| 55 | - if (Permission::userHasDocumentReadPermission($fDocumentID)) { | |
| 56 | - $oDocument = & Document::get($fDocumentID); | |
| 55 | + $oDocument = & Document::get($fDocumentID); | |
| 56 | + if (Permission::userHasDocumentReadPermission($oDocument)) { | |
| 57 | + | |
| 57 | 58 | $oPatternCustom = & new PatternCustom(); |
| 58 | 59 | $oPatternCustom->setHtml(getPage($oDocument->getID(), $oDocument->getFolderID(), $oDocument->getName())); |
| 59 | 60 | $main->setCentralPayload($oPatternCustom); | ... | ... |
presentation/lookAndFeel/knowledgeTree/subscriptions/addSubscriptionBL.php
| ... | ... | @@ -42,10 +42,12 @@ require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 42 | 42 | * @param integer the subscription type |
| 43 | 43 | */ |
| 44 | 44 | function checkPermission($iExternalID, $iSubscriptionType) { |
| 45 | - if ($iSubscriptionType == SubscriptionConstants::subscriptionType("FolderSubscription")) { | |
| 46 | - return Permission::userHasFolderReadPermission($iExternalID); | |
| 45 | + if ($iSubscriptionType == SubscriptionConstants::subscriptionType("FolderSubscription")) { | |
| 46 | + $oFolder = Folder::get($iExternalID); | |
| 47 | + return Permission::userHasFolderReadPermission($oFolder); | |
| 47 | 48 | } else { |
| 48 | - return Permission::userHasDocumentReadPermission($iExternalID); | |
| 49 | + $oDocument = Document::get($iExternalID); | |
| 50 | + return Permission::userHasDocumentReadPermission($oDocument); | |
| 49 | 51 | } |
| 50 | 52 | } |
| 51 | 53 | // only if we have a valid session |
| ... | ... | @@ -53,6 +55,8 @@ if (checkSession()) { |
| 53 | 55 | |
| 54 | 56 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 55 | 57 | require_once("subscriptionUI.inc"); |
| 58 | + require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | |
| 59 | + require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 56 | 60 | |
| 57 | 61 | $oPatternCustom = & new PatternCustom(); |
| 58 | 62 | ... | ... |