Commit cd6e54eb68160bd2bd86ce6ef09e6f9a3221fb62
1 parent
5bee6874
Type: functionality change
Description: Passing through folder object instead of folder 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@2881 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
12 changed files
with
31 additions
and
19 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. | 21 | * GNU General Public License for more details. |
| 22 | - * | 22 | + * |
| 23 | * You should have received a copy of the GNU General Public License | 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software | 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| @@ -50,7 +50,8 @@ if (checkSession()) { | @@ -50,7 +50,8 @@ if (checkSession()) { | ||
| 50 | require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/store.inc"); | 50 | require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/store.inc"); |
| 51 | 51 | ||
| 52 | if (isset($fFolderID)) { | 52 | if (isset($fFolderID)) { |
| 53 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 53 | + $oFolder = Folder::get($fFolderID); |
| 54 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 54 | //user has permission to add document to this folder | 55 | //user has permission to add document to this folder |
| 55 | if (isset($fStore)) { | 56 | if (isset($fStore)) { |
| 56 | // check that a document type has been selected | 57 | // check that a document type has been selected |
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
| @@ -181,7 +181,8 @@ function getPage($iFolderID, $iDocumentTypeID, $iDependantDocumentID = null, $sM | @@ -181,7 +181,8 @@ function getPage($iFolderID, $iDocumentTypeID, $iDependantDocumentID = null, $sM | ||
| 181 | 181 | ||
| 182 | } else { | 182 | } else { |
| 183 | // only allow document type choosing if the user has write permission | 183 | // only allow document type choosing if the user has write permission |
| 184 | - if (Permission::userHasFolderWritePermission($iFolderID)) { | 184 | + $oFolder = Folder::get($iFolderID); |
| 185 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 185 | $sToRender .= getDocumentType($iFolderID, $iDocumentTypeID, $iDependantDocumentID); | 186 | $sToRender .= getDocumentType($iFolderID, $iDocumentTypeID, $iDependantDocumentID); |
| 186 | $sActionButtons .= generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>"); | 187 | $sActionButtons .= generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>"); |
| 187 | $sActionButtons .= "<input type=\"image\" src=\"$default->graphicsUrl/widgets/next.gif\" border=\"0\"/>"; | 188 | $sActionButtons .= "<input type=\"image\" src=\"$default->graphicsUrl/widgets/next.gif\" border=\"0\"/>"; |
presentation/lookAndFeel/knowledgeTree/foldermanagement/addFolderCollaborationBL.php
| @@ -33,12 +33,13 @@ require_once("../../../../config/dmsDefaults.php"); | @@ -33,12 +33,13 @@ require_once("../../../../config/dmsDefaults.php"); | ||
| 33 | 33 | ||
| 34 | if (checkSession()) { | 34 | if (checkSession()) { |
| 35 | if (isset($fFolderID)) { | 35 | if (isset($fFolderID)) { |
| 36 | + $oFolder = Folder::get($fFolderID); | ||
| 36 | //if a folder has been selected | 37 | //if a folder has been selected |
| 37 | include_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | 38 | include_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); |
| 38 | include_once("$default->fileSystemRoot/lib/security/Permission.inc"); | 39 | include_once("$default->fileSystemRoot/lib/security/Permission.inc"); |
| 39 | include_once("$default->fileSystemRoot/lib/users/User.inc"); | 40 | include_once("$default->fileSystemRoot/lib/users/User.inc"); |
| 40 | require_once("$default->fileSystemRoot/presentation/Html.inc"); | 41 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 41 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 42 | + if (Permission::userHasFolderWritePermission($oFolder)) { |
| 42 | //can only create new collaboration steps if the user has folder write permission | 43 | //can only create new collaboration steps if the user has folder write permission |
| 43 | if (isset($fForStore)) { | 44 | if (isset($fForStore)) { |
| 44 | //attempt to create the new folder collaboration entry | 45 | //attempt to create the new folder collaboration entry |
presentation/lookAndFeel/knowledgeTree/foldermanagement/addFolderDocTypeBL.php
| @@ -36,8 +36,8 @@ if (checkSession()) { | @@ -36,8 +36,8 @@ if (checkSession()) { | ||
| 36 | require_once("addFolderDocTypeUI.inc"); | 36 | require_once("addFolderDocTypeUI.inc"); |
| 37 | 37 | ||
| 38 | $oPatternCustom = & new PatternCustom(); | 38 | $oPatternCustom = & new PatternCustom(); |
| 39 | - | ||
| 40 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 39 | + $oFolder = Folder::get($fFolderID); |
| 40 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 41 | if (isset($fForAdd)) { | 41 | if (isset($fForAdd)) { |
| 42 | //user has selected a document type | 42 | //user has selected a document type |
| 43 | if (Folder::folderIsLinkedToDocType($fFolderID, $fDocumentTypeID)) { | 43 | if (Folder::folderIsLinkedToDocType($fFolderID, $fDocumentTypeID)) { |
presentation/lookAndFeel/knowledgeTree/foldermanagement/addGroupFolderLinkBL.php
| @@ -43,8 +43,9 @@ if (checkSession()) { | @@ -43,8 +43,9 @@ if (checkSession()) { | ||
| 43 | if (isset($fFolderID)) { | 43 | if (isset($fFolderID)) { |
| 44 | $oPatternCustom = & new PatternCustom(); | 44 | $oPatternCustom = & new PatternCustom(); |
| 45 | $oPatternCustom->setHtml(""); | 45 | $oPatternCustom->setHtml(""); |
| 46 | + $oFolder = Folder::get($fFolderID); | ||
| 46 | // if a folder has been selected | 47 | // if a folder has been selected |
| 47 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 48 | + if (Permission::userHasFolderWritePermission($oFolder)) { |
| 48 | // can only add access if the user has folder write permission | 49 | // can only add access if the user has folder write permission |
| 49 | if (isset($fForStore)) { | 50 | if (isset($fForStore)) { |
| 50 | // attempt to create the new folder access entry | 51 | // attempt to create the new folder access entry |
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteDependantDocumentBL.php
| @@ -43,8 +43,8 @@ if (checkSession()) { | @@ -43,8 +43,8 @@ if (checkSession()) { | ||
| 43 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | 43 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); |
| 44 | require_once("deleteDependantDocumentUI.inc"); | 44 | require_once("deleteDependantDocumentUI.inc"); |
| 45 | 45 | ||
| 46 | - | ||
| 47 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 46 | + $oFolder = Folder::get($fFolderID); |
| 47 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 48 | //user has permission to alter folder contents | 48 | //user has permission to alter folder contents |
| 49 | if (isset($fForDelete)) { | 49 | if (isset($fForDelete)) { |
| 50 | $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); | 50 | $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID); |
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteFolderBL.php
| @@ -46,10 +46,11 @@ if (checkSession()) { | @@ -46,10 +46,11 @@ if (checkSession()) { | ||
| 46 | $oPatternCustom = & new PatternCustom(); | 46 | $oPatternCustom = & new PatternCustom(); |
| 47 | 47 | ||
| 48 | if (isset($fFolderID)) { | 48 | if (isset($fFolderID)) { |
| 49 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 49 | + $oFolder = Folder::get($fFolderID); |
| 50 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 50 | if (isset($fDeleteConfirmed)) { | 51 | if (isset($fDeleteConfirmed)) { |
| 51 | // deletion of folder is confirmed | 52 | // deletion of folder is confirmed |
| 52 | - $oFolder = Folder::get($fFolderID); | 53 | + |
| 53 | if (isset($oFolder)) { | 54 | if (isset($oFolder)) { |
| 54 | // check if there are any documents or folders in this folder | 55 | // check if there are any documents or folders in this folder |
| 55 | 56 |
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteFolderCollaborationBL.php
| @@ -41,7 +41,9 @@ if (checkSession()) { | @@ -41,7 +41,9 @@ if (checkSession()) { | ||
| 41 | include_once("$default->fileSystemRoot/lib/groups/Group.inc"); | 41 | include_once("$default->fileSystemRoot/lib/groups/Group.inc"); |
| 42 | include_once("$default->fileSystemRoot/lib/roles/Role.inc"); | 42 | include_once("$default->fileSystemRoot/lib/roles/Role.inc"); |
| 43 | require_once("$default->fileSystemRoot/presentation/Html.inc"); | 43 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 44 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 44 | + |
| 45 | + $oFolder = Folder::get($fFolderID); | ||
| 46 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 45 | //can only delete new collaboration steps if the user has folder write permission | 47 | //can only delete new collaboration steps if the user has folder write permission |
| 46 | if (isset($fForDelete)) { | 48 | if (isset($fForDelete)) { |
| 47 | $oFolderCollaboration = & FolderCollaboration::get($fFolderCollaborationID); | 49 | $oFolderCollaboration = & FolderCollaboration::get($fFolderCollaborationID); |
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteFolderDocTypeBL.php
| @@ -38,7 +38,8 @@ if (checkSession()) { | @@ -38,7 +38,8 @@ if (checkSession()) { | ||
| 38 | 38 | ||
| 39 | $oPatternCustom = & new PatternCustom(); | 39 | $oPatternCustom = & new PatternCustom(); |
| 40 | 40 | ||
| 41 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 41 | + $oFolder = Folder::get($fFolderID); |
| 42 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 42 | //user has permission to delete | 43 | //user has permission to delete |
| 43 | if (isset($fFolderDocTypeID)) { | 44 | if (isset($fFolderDocTypeID)) { |
| 44 | //the required variables exist | 45 | //the required variables exist |
presentation/lookAndFeel/knowledgeTree/foldermanagement/deleteGroupFolderLinkBL.php
| @@ -46,8 +46,10 @@ if (checkSession()) { | @@ -46,8 +46,10 @@ if (checkSession()) { | ||
| 46 | if (isset($fFolderID) && isset($fGroupFolderLinkID)) { | 46 | if (isset($fFolderID) && isset($fGroupFolderLinkID)) { |
| 47 | // if a folder has been selected | 47 | // if a folder has been selected |
| 48 | $oPatternCustom = & new PatternCustom(); | 48 | $oPatternCustom = & new PatternCustom(); |
| 49 | - $oPatternCustom->setHtml(""); | ||
| 50 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 49 | + $oPatternCustom->setHtml(""); |
| 50 | + | ||
| 51 | + $oFolder = Folder::get($fFolderID); | ||
| 52 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 51 | // can only delete group folder links if the user has folder write permission | 53 | // can only delete group folder links if the user has folder write permission |
| 52 | if (isset($fForDelete)) { | 54 | if (isset($fForDelete)) { |
| 53 | $oGroupFolderLink = & GroupFolderLink::get($fGroupFolderLinkID); | 55 | $oGroupFolderLink = & GroupFolderLink::get($fGroupFolderLinkID); |
presentation/lookAndFeel/knowledgeTree/foldermanagement/editGroupFolderLinkBL.php
| @@ -47,8 +47,10 @@ if (checkSession()) { | @@ -47,8 +47,10 @@ if (checkSession()) { | ||
| 47 | if (isset($fFolderID) && isset($fGroupFolderLinkID)) { | 47 | if (isset($fFolderID) && isset($fGroupFolderLinkID)) { |
| 48 | // if a folder has been selected | 48 | // if a folder has been selected |
| 49 | $oPatternCustom = & new PatternCustom(); | 49 | $oPatternCustom = & new PatternCustom(); |
| 50 | - $oPatternCustom->setHtml(""); | ||
| 51 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 50 | + $oPatternCustom->setHtml(""); |
| 51 | + | ||
| 52 | + $oFolder = Folder::get($fFolderID); | ||
| 53 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 52 | // can only edit group folder links if the user has folder write permission | 54 | // can only edit group folder links if the user has folder write permission |
| 53 | if (isset($fForStore)) { | 55 | if (isset($fForStore)) { |
| 54 | $oGroupFolderLink = & GroupFolderLink::get($fGroupFolderLinkID); | 56 | $oGroupFolderLink = & GroupFolderLink::get($fGroupFolderLinkID); |
presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php
| @@ -47,8 +47,8 @@ if (checkSession()) { | @@ -47,8 +47,8 @@ if (checkSession()) { | ||
| 47 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | 47 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); |
| 48 | require_once("viewDependantDocumentsUI.inc"); | 48 | require_once("viewDependantDocumentsUI.inc"); |
| 49 | 49 | ||
| 50 | - | ||
| 51 | - if (Permission::userHasFolderWritePermission($fFolderID)) { | 50 | + $oFolder = Folder::get($fFolderID); |
| 51 | + if (Permission::userHasFolderWritePermission($oFolder)) { | ||
| 52 | //user has folder write permission | 52 | //user has folder write permission |
| 53 | if (isset($fForStore)) { | 53 | if (isset($fForStore)) { |
| 54 | $oDependantDocumentTemplate; | 54 | $oDependantDocumentTemplate; |