Commit c027d65ed92ae7b4e51e2fa387be131e10afdaa8
1 parent
17d84a4c
Corrected logic flow
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@718 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
169 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/collaborationBL.php
0 → 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | +* Document collaboration business logic - contains business logic to set up | |
| 4 | +* document approval process | |
| 5 | +* | |
| 6 | +* Required form variables: | |
| 7 | +* o fFolderCollaborationID - primary key of folder collaboration entry we are viewing | |
| 8 | +* o fDocumentID - primary key of document this folder collaboration entry is for | |
| 9 | +* | |
| 10 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 11 | +* @date 28 January 2003 | |
| 12 | +* @package presentation.lookAndFeel.knowledgeTree.documentmanagement | |
| 13 | +* | |
| 14 | +*/ | |
| 15 | + | |
| 16 | +require_once("../../../../config/dmsDefaults.php"); | |
| 17 | + | |
| 18 | +if (checkSession()) { | |
| 19 | + require_once("$default->owl_fs_root/lib/visualpatterns/PatternListBox.inc"); | |
| 20 | + require_once("$default->owl_fs_root/lib/foldermanagement/FolderCollaboration.inc"); | |
| 21 | + require_once("$default->owl_fs_root/lib/foldermanagement/FolderUserRole.inc"); | |
| 22 | + require_once("$default->owl_fs_root/lib/foldermanagement/Folder.inc"); | |
| 23 | + require_once("$default->owl_fs_root/lib/documentmanagement/Document.inc"); | |
| 24 | + require_once("$default->owl_fs_root/lib/groups/Group.inc"); | |
| 25 | + require_once("$default->owl_fs_root/presentation/Html.inc"); | |
| 26 | + require_once("$default->owl_fs_root/lib/security/permission.inc"); | |
| 27 | + require_once("$default->owl_fs_root/lib/visualpatterns/PatternCustom.inc"); | |
| 28 | + require_once("collaborationUI.inc"); | |
| 29 | + | |
| 30 | + //if the required form variabled are set | |
| 31 | + if (isset($fFolderCollaborationID) && isset($fDocumentID)) { | |
| 32 | + //if the user has write permission for the document | |
| 33 | + if (Permission::userHasDocumentWritePermission($fDocumentID)) { | |
| 34 | + if (isset($fForStore)) { | |
| 35 | + //if we are storing, get the folder collaboration entry from the database | |
| 36 | + $oFolderCollaboration = & FolderCollaboration::get($fFolderCollaborationID); | |
| 37 | + if (isset($fUserID) & ($fUserID != -1)) { | |
| 38 | + //if a user has been selected, then set up the folders_users_roles_link database entry | |
| 39 | + $oFolderUserRole = & FolderUserRole::getFromFolderCollaboration($fFolderCollaborationID); | |
| 40 | + if (!($oFolderUserRole === false)) { | |
| 41 | + //if we have an entry, just update it | |
| 42 | + $oFolderUserRole->setUserID($fUserID); | |
| 43 | + $oFolderUserRole->update(); | |
| 44 | + } else { | |
| 45 | + //otherwise, create a new one | |
| 46 | + $oFolderUserRole = & new FolderUserRole($fUserID, $fDocumentID, $fFolderCollaborationID, 0); | |
| 47 | + $oFolderUserRole->create(); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + if (isset($fRoleID) & ($fRoleID != -1)) { | |
| 51 | + //if a role was chosen then update the folder collaboration entry in the db | |
| 52 | + $oFolderCollaboration->setRoleID($fRoleID); | |
| 53 | + $oFolderCollaboration->update(); | |
| 54 | + } | |
| 55 | + //go back to the document view page | |
| 56 | + redirect("$default->owl_root_url/control.php?action=viewDocument&fDocumentID=$fDocumentID"); | |
| 57 | + } else { | |
| 58 | + //we're still browsing, so just display the document routing details | |
| 59 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 60 | + $oPatternCustom = & new PatternCustom(); | |
| 61 | + | |
| 62 | + $aFolderCollaborationArray = getFolderCollaborationArray($fFolderCollaborationID); | |
| 63 | + $oPatternCustom->setHtml(getDocumentRoutingPage($aFolderCollaborationArray["group_id"],$aFolderCollaborationArray["user_id"], $aFolderCollaborationArray["role_id"], $aFolderCollaborationArray["sequence"], $fDocumentID)); | |
| 64 | + $main->setCentralPayload($oPatternCustom); | |
| 65 | + $main->setFormAction($_SEVER["PHP_SELF"] . "?fFolderCollaborationID=$fFolderCollaborationID&fDocumentID=$fDocumentID&fForStore=1"); | |
| 66 | + $main->render(); | |
| 67 | + } | |
| 68 | + } else { | |
| 69 | + //user does not have permission to edit these details | |
| 70 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 71 | + $oPatternCustom = & new PatternCustom(); | |
| 72 | + $oPatternCustom->setHtml("<a href=\"$default->owl_root_url/control.php?action=viewDocument&fDocumentID=" . $fDocumentID . "\">Return to document view page</a>"); | |
| 73 | + $main->setCentralPayload($oPatternCustom); | |
| 74 | + $main->setErrorMessage("You do not have permission to edit document routing details"); | |
| 75 | + $main->render(); | |
| 76 | + } | |
| 77 | + } else { | |
| 78 | + //user does not have permission to edit these details | |
| 79 | + require_once("$default->owl_fs_root/presentation/webpageTemplate.inc"); | |
| 80 | + $oPatternCustom = & new PatternCustom(); | |
| 81 | + $oPatternCustom->setHtml("<a href=\"$default->owl_root_url/control.php?action=dashboard\">Return to document dashboard</a>"); | |
| 82 | + $main->setCentralPayload($oPatternCustom); | |
| 83 | + $main->setErrorMessage("No document/document routing details are currently selected"); | |
| 84 | + $main->render(); | |
| 85 | + } | |
| 86 | +} | |
| 87 | + | |
| 88 | +function getFolderCollaborationArray($fFolderCollaborationID) { | |
| 89 | + global $default; | |
| 90 | + $sQuery = "SELECT GFL.group_id AS group_id, GFL.folder_id AS folder_id, GFL.precedence AS precedence, GFL.role_id, U.id AS user_id " . | |
| 91 | + "FROM $default->owl_groups_folders_approval_table AS GFL LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFL.id " . | |
| 92 | + "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " . | |
| 93 | + "WHERE GFL.id = $fFolderCollaborationID"; | |
| 94 | + | |
| 95 | + $sql = $default->db; | |
| 96 | + $sql->query($sQuery); | |
| 97 | + if ($sql->next_record()) { | |
| 98 | + return array("group_id" => $sql->f("group_id"), "user_id" => $sql->f("user_id"), "role_id" => $sql->f("role_id"), "sequence" => $sql->f("precedence")); | |
| 99 | + } | |
| 100 | +} | |
| 101 | + | |
| 102 | +?> | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/collaborationUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | +* Presentation data for collaborationBL.php | |
| 4 | +* | |
| 5 | +* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 6 | +* @date 28 January 2003 | |
| 7 | +* @package presentation.lookAndFeel.knowledgeTree.documentmanagement | |
| 8 | +* | |
| 9 | +*/ | |
| 10 | + | |
| 11 | +function getGroupRow($iGroupID) { | |
| 12 | + $oGroup = Group::get($iGroupID); | |
| 13 | + return "<input type=\"hidden\" name=\"fGroupID\" value=\"" . $iGroupID . "\" />" . $oGroup->getName(); | |
| 14 | +} | |
| 15 | + | |
| 16 | +function getUserDropDown($iGroupID, $iUserID) { | |
| 17 | + global $default; | |
| 18 | + $oPatternListBox = & new PatternListBox("$default->owl_users_table", "name", "id", "fUserID"); | |
| 19 | + $sFromClause = "INNER JOIN $default->owl_users_groups_table AS UGL ON ST.id = UGL.user_id "; | |
| 20 | + $oPatternListBox->setFromClause($sFromClause); | |
| 21 | + $sWhereClause = "UGL.group_id = $iGroupID"; | |
| 22 | + $oPatternListBox->setWhereClause($sWhereClause); | |
| 23 | + | |
| 24 | + if (isset($iUserID)) { | |
| 25 | + $oPatternListBox->setSelectedValue($iUserID); | |
| 26 | + } | |
| 27 | + | |
| 28 | + $oPatternListBox->setEmptyErrorMessage("There are no users in this group"); | |
| 29 | + return $oPatternListBox->render(); | |
| 30 | +} | |
| 31 | + | |
| 32 | +function getRoleDropDown($iRoleID) { | |
| 33 | + global $default; | |
| 34 | + $oPatternListBox = & new PatternListBox("$default->owl_roles_table", "name", "id", "fRoleID"); | |
| 35 | + if (isset($iRoleID)) { | |
| 36 | + $oPatternListBox->setSelectedValue($iRoleID); | |
| 37 | + } | |
| 38 | + $oPatternListBox->setEmptyErrorMessage("There are no users in this group"); | |
| 39 | + return $oPatternListBox->render(); | |
| 40 | +} | |
| 41 | + | |
| 42 | +function getDocumentRoutingPage($iGroupID, $iUserID, $iRoleID, $iSequenceNumber, $fDocumentID) { | |
| 43 | + global $default; | |
| 44 | + return "<table cellspacing=2, cellpadding=2, border=0>\n" . | |
| 45 | + "<caption><b>Document Routing</b></caption>\n" . | |
| 46 | + "<tr>\n" . | |
| 47 | + "<td><b>Group</b></td><td>".getGroupRow($iGroupID)."</td>\n" . | |
| 48 | + "</tr>\n" . | |
| 49 | + "<tr>\n" . | |
| 50 | + "<td><b>Role</b></td><td>".getRoleDropDown($iRoleID)."</td>\n" . | |
| 51 | + "</tr>\n" . | |
| 52 | + "<tr>\n" . | |
| 53 | + "<td><b>Player</b></td><td>".getUserDropDown($iGroupID, $iUserID)."</td>\n" . | |
| 54 | + "</tr>\n" . | |
| 55 | + "<tr>\n" . | |
| 56 | + "<tr>\n" . | |
| 57 | + "<td><b>Seq. no.</b></td><td>$iSequenceNumber</td>\n" . | |
| 58 | + "</tr>\n" . | |
| 59 | + "<tr>\n" . | |
| 60 | + "<td colspan=\"2\"> </td>\n" . | |
| 61 | + "</tr>\n" . | |
| 62 | + "<tr>\n" . | |
| 63 | + "<td><b><input type=\"submit\" value=\"Submit\" /></b></td><td><a href=\"$default->owl_root_url/control.php?action=viewDocument&fDocumentID=$fDocumentID \">Cancel</a></td>\n" . | |
| 64 | + "</tr>\n" . | |
| 65 | + "</table>\n"; | |
| 66 | +} | |
| 67 | +?> | ... | ... |