Commit ba32dec44e87f360306f462c01ca95d220036052
1 parent
3c71a8fb
Add a "workflow" action to documents.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3786 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
144 additions
and
0 deletions
config/siteMap.inc
| @@ -93,6 +93,7 @@ $default->siteMap->addPage("checkOutDocument", "/presentation/lookAndFeel/knowle | @@ -93,6 +93,7 @@ $default->siteMap->addPage("checkOutDocument", "/presentation/lookAndFeel/knowle | ||
| 93 | $default->siteMap->addPage("checkInDocument", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/checkInDocumentBL.php", "Manage Documents", User, "Check In Document", false); | 93 | $default->siteMap->addPage("checkInDocument", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/checkInDocumentBL.php", "Manage Documents", User, "Check In Document", false); |
| 94 | 94 | ||
| 95 | $default->siteMap->addPage("editDocumentPermissions", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentPermissions.php", "Manage Documents", User, _("Document Permissions")); | 95 | $default->siteMap->addPage("editDocumentPermissions", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentPermissions.php", "Manage Documents", User, _("Document Permissions")); |
| 96 | +$default->siteMap->addPage("documentWorkflow", "/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentWorkflow.php", "Manage Documents", User, _("Document Workflow")); | ||
| 96 | 97 | ||
| 97 | $default->siteMap->addSectionColour("Manage Documents", "td", "BDDFE0"); | 98 | $default->siteMap->addSectionColour("Manage Documents", "td", "BDDFE0"); |
| 98 | $default->siteMap->addSectionColour("Manage Documents", "th", "57AFAE"); | 99 | $default->siteMap->addSectionColour("Manage Documents", "th", "57AFAE"); |
plugins/ktcore/KTDocumentActions.php
| @@ -186,4 +186,12 @@ class KTDocumentPermissionsAction extends KTBuiltInDocumentAction { | @@ -186,4 +186,12 @@ class KTDocumentPermissionsAction extends KTBuiltInDocumentAction { | ||
| 186 | var $sName = 'ktcore.actions.document.permissions'; | 186 | var $sName = 'ktcore.actions.document.permissions'; |
| 187 | } | 187 | } |
| 188 | $oKTActionRegistry->registerAction('documentaction', 'KTDocumentPermissionsAction', 'ktcore.actions.document.permissions'); | 188 | $oKTActionRegistry->registerAction('documentaction', 'KTDocumentPermissionsAction', 'ktcore.actions.document.permissions'); |
| 189 | + | ||
| 190 | +class KTDocumentWorkflowAction extends KTBuiltInDocumentAction { | ||
| 191 | + var $sBuiltInAction = 'documentWorkflow'; | ||
| 192 | + var $sDisplayName = 'Workflow'; | ||
| 193 | + var $sName = 'ktcore.actions.document.workflow'; | ||
| 194 | +} | ||
| 195 | +$oKTActionRegistry->registerAction('documentaction', 'KTDocumentWorkflowAction', 'ktcore.actions.document.workflow'); | ||
| 196 | + | ||
| 189 | ?> | 197 | ?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/documentWorkflow.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../../../config/dmsDefaults.php"); | ||
| 4 | + | ||
| 5 | +require_once(KT_DIR . "/presentation/Html.inc"); | ||
| 6 | + | ||
| 7 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | ||
| 8 | +require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); | ||
| 9 | + | ||
| 10 | +$sectionName = "Manage Documents"; | ||
| 11 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | ||
| 12 | + | ||
| 13 | +require_once(KT_LIB_DIR . "/dispatcher.inc.php"); | ||
| 14 | +require_once(KT_LIB_DIR . "/validation/dispatchervalidation.inc.php"); | ||
| 15 | + | ||
| 16 | +function displayFolderPathLink($aPathArray, $aPathNameArray, $sLinkPage = "") { | ||
| 17 | + global $default; | ||
| 18 | + if (strlen($sLinkPage) == 0) { | ||
| 19 | + $sLinkPage = $_SERVER["PHP_SELF"]; | ||
| 20 | + } | ||
| 21 | + $default->log->debug("displayFolderPathLink: slinkPage=$sLinkPage"); | ||
| 22 | + // display a separate link to each folder in the path | ||
| 23 | + for ($i=0; $i<count($aPathArray); $i++) { | ||
| 24 | + $iFolderID = $aPathArray[$i]; | ||
| 25 | + // retrieve the folder name for this folder | ||
| 26 | + $sFolderName = $aPathNameArray[$i]; | ||
| 27 | + // generate a link back to this page setting fFolderID | ||
| 28 | + $sLink = generateLink($sLinkPage, | ||
| 29 | + "fBrowseType=folder&fFolderID=$iFolderID", | ||
| 30 | + $sFolderName); | ||
| 31 | + $sPathLinks = (strlen($sPathLinks) > 0) ? $sPathLinks . " > " . $sLink : $sLink; | ||
| 32 | + } | ||
| 33 | + return $sPathLinks; | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +class DocumentWorkflowDispatcher extends KTStandardDispatcher { | ||
| 38 | + function do_main() { | ||
| 39 | + $oTemplating = new KTTemplating; | ||
| 40 | + $oTemplate = $oTemplating->loadTemplate("ktcore/document/document_workflow"); | ||
| 41 | + $oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentID']); | ||
| 42 | + $oPO = KTPermissionObject::get($oDocument->getPermissionObjectID()); | ||
| 43 | + $aPermissions = KTPermission::getList(); | ||
| 44 | + $aMapPermissionGroup = array(); | ||
| 45 | + foreach ($aPermissions as $oPermission) { | ||
| 46 | + $oPA = KTPermissionAssignment::getByPermissionAndObject($oPermission, $oPO); | ||
| 47 | + if (PEAR::isError($oPA)) { | ||
| 48 | + continue; | ||
| 49 | + } | ||
| 50 | + $oDescriptor = KTPermissionDescriptor::get($oPA->getPermissionDescriptorID()); | ||
| 51 | + $iPermissionID = $oPermission->getID(); | ||
| 52 | + $aIDs = $oDescriptor->getGroups(); | ||
| 53 | + $aMapPermissionGroup[$iPermissionID] = array(); | ||
| 54 | + foreach ($aIDs as $iID) { | ||
| 55 | + $aMapPermissionGroup[$iPermissionID][$iID] = true; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + $aMapPermissionUser = array(); | ||
| 59 | + $aUsers = User::getList(); | ||
| 60 | + foreach ($aPermissions as $oPermission) { | ||
| 61 | + $iPermissionID = $oPermission->getID(); | ||
| 62 | + foreach ($aUsers as $oUser) { | ||
| 63 | + if (KTPermissionUtil::userHasPermissionOnItem($oUser, $oPermission, $oDocument)) { | ||
| 64 | + $aMapPermissionUser[$iPermissionID][$oUser->getID()] = true; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + $oInherited = KTPermissionUtil::findRootObjectForPermissionObject($oPO); | ||
| 70 | + if ($oInherited === $oDocument) { | ||
| 71 | + $bEdit = true; | ||
| 72 | + } else { | ||
| 73 | + $iInheritedFolderID = $oInherited->getID(); | ||
| 74 | + $sInherited = displayFolderPathLink(Folder::getFolderPathAsArray($iInheritedFolderID), | ||
| 75 | + Folder::getFolderPathNamesAsArray($iInheritedFolderID), | ||
| 76 | + "$default->rootUrl/control.php?action=editFolderPermissions"); | ||
| 77 | + $bEdit = false; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + $aTemplateData = array( | ||
| 81 | + "permissions" => $aPermissions, | ||
| 82 | + "groups" => Group::getList(), | ||
| 83 | + "iDocumentID" => $_REQUEST['fDocumentID'], | ||
| 84 | + "aMapPermissionGroup" => $aMapPermissionGroup, | ||
| 85 | + "users" => $aUsers, | ||
| 86 | + "aMapPermissionUser" => $aMapPermissionUser, | ||
| 87 | + "edit" => $bEdit, | ||
| 88 | + "inherited" => $sInherited, | ||
| 89 | + ); | ||
| 90 | + return $oTemplate->render($aTemplateData); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + function handleOutput($data) { | ||
| 94 | + global $main; | ||
| 95 | + $main->bFormDisabled = true; | ||
| 96 | + $main->setCentralPayload($data); | ||
| 97 | + $main->render(); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + function do_update() { | ||
| 101 | + $oDocument = Document::get($_REQUEST['fDocumentID']); | ||
| 102 | + $oPO = KTPermissionObject::get($oDocument->getPermissionObjectID()); | ||
| 103 | + $aFoo = $_REQUEST['foo']; | ||
| 104 | + $aPermissions = KTPermission::getList(); | ||
| 105 | + foreach ($aPermissions as $oPermission) { | ||
| 106 | + $iPermID = $oPermission->getID(); | ||
| 107 | + $aAllowed = KTUtil::arrayGet($aFoo, $iPermID, array()); | ||
| 108 | + KTPermissionUtil::setPermissionForID($oPermission, $oPO, $aAllowed); | ||
| 109 | + } | ||
| 110 | + KTPermissionUtil::updatePermissionLookupForPO($oPO); | ||
| 111 | + return $this->errorRedirectToMain('Permissions updated', | ||
| 112 | + array('fDocumentID' => $oDocument->getID())); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + function do_copyPermissions() { | ||
| 116 | + $oDocument = Document::get($_REQUEST['fDocumentID']); | ||
| 117 | + KTPermissionUtil::copyPermissionObject($oDocument); | ||
| 118 | + return $this->errorRedirectToMain('Permissions updated', | ||
| 119 | + array('fDocumentID' => $oDocument->getID())); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + function do_inheritPermissions() { | ||
| 123 | + $oDocument = Document::get($_REQUEST['fDocumentID']); | ||
| 124 | + KTPermissionUtil::inheritPermissionObject($oDocument); | ||
| 125 | + return $this->errorRedirectToMain('Permissions updated', | ||
| 126 | + array('fDocumentID' => $oDocument->getID())); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +$oDispatcher = new DocumentPermissionsDispatcher; | ||
| 133 | +$oDispatcher->dispatch(); | ||
| 134 | + | ||
| 135 | +?> |