Commit 5aca7c90b51305a3ad33e73f97a444766a708907

Authored by jacquiz
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
lib/browse/CategoryBrowser.inc
@@ -106,9 +106,10 @@ class CategoryBrowser extends Browser { @@ -106,9 +106,10 @@ class CategoryBrowser extends Browser {
106 $results["accessDenied"] = false; 106 $results["accessDenied"] = false;
107 while ($sql->next_record()) { 107 while ($sql->next_record()) {
108 // check permissions 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 $results["documents"][] = $oDocument; 113 $results["documents"][] = $oDocument;
113 } 114 }
114 } else { 115 } else {
lib/browse/DocumentTypeBrowser.inc
@@ -98,8 +98,9 @@ class DocumentTypeBrowser extends Browser { @@ -98,8 +98,9 @@ class DocumentTypeBrowser extends Browser {
98 $results["accessDenied"] = false; 98 $results["accessDenied"] = false;
99 while ($sql->next_record()) { 99 while ($sql->next_record()) {
100 // check permission 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 if ($oDocument->isLive()) { 104 if ($oDocument->isLive()) {
104 $results["documents"][] = $oDocument; 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,7 +40,7 @@ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
40 if (checkSession(true)) { 40 if (checkSession(true)) {
41 if (isset($fDocumentID)) { 41 if (isset($fDocumentID)) {
42 $oDocument = Document::get($fDocumentID); 42 $oDocument = Document::get($fDocumentID);
43 - if (Permission::userHasDocumentReadPermission($fDocumentID)) { 43 + if (Permission::userHasDocumentReadPermission($oDocument)) {
44 if (isset($fForInlineView)) { 44 if (isset($fForInlineView)) {
45 $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW); 45 $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW);
46 $oDocumentTransaction->create(); 46 $oDocumentTransaction->create();
presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php
@@ -141,7 +141,7 @@ if (checkSession()) { @@ -141,7 +141,7 @@ if (checkSession()) {
141 $oDocument = Document::get($fDocumentID); 141 $oDocument = Document::get($fDocumentID);
142 142
143 //if the user can view the document, they can email a link to it 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 if (isset($fSendEmail)) { 145 if (isset($fSendEmail)) {
146 // explode group and user ids 146 // explode group and user ids
147 $aGroupIDs = explode(",", $groupNewRight); 147 $aGroupIDs = explode(",", $groupNewRight);
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewHistoryBL.php
@@ -52,8 +52,9 @@ require_once("$default->fileSystemRoot/presentation/Html.inc"); @@ -52,8 +52,9 @@ require_once("$default->fileSystemRoot/presentation/Html.inc");
52 if (checkSession()) { 52 if (checkSession()) {
53 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 53 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
54 if (isset($fDocumentID)) { 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 $oPatternCustom = & new PatternCustom(); 58 $oPatternCustom = & new PatternCustom();
58 $oPatternCustom->setHtml(getPage($oDocument->getID(), $oDocument->getFolderID(), $oDocument->getName())); 59 $oPatternCustom->setHtml(getPage($oDocument->getID(), $oDocument->getFolderID(), $oDocument->getName()));
59 $main->setCentralPayload($oPatternCustom); 60 $main->setCentralPayload($oPatternCustom);
presentation/lookAndFeel/knowledgeTree/subscriptions/addSubscriptionBL.php
@@ -42,10 +42,12 @@ require_once("$default->fileSystemRoot/presentation/Html.inc"); @@ -42,10 +42,12 @@ require_once("$default->fileSystemRoot/presentation/Html.inc");
42 * @param integer the subscription type 42 * @param integer the subscription type
43 */ 43 */
44 function checkPermission($iExternalID, $iSubscriptionType) { 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 } else { 48 } else {
48 - return Permission::userHasDocumentReadPermission($iExternalID); 49 + $oDocument = Document::get($iExternalID);
  50 + return Permission::userHasDocumentReadPermission($oDocument);
49 } 51 }
50 } 52 }
51 // only if we have a valid session 53 // only if we have a valid session
@@ -53,6 +55,8 @@ if (checkSession()) { @@ -53,6 +55,8 @@ if (checkSession()) {
53 55
54 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); 56 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
55 require_once("subscriptionUI.inc"); 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 $oPatternCustom = & new PatternCustom(); 61 $oPatternCustom = & new PatternCustom();
58 62