Commit 093c37959cfc419c705341d644fc1d5f783fde67
1 parent
6e7d9630
KTS-3937 - Added the document id in the where clause of the sql.
"CLONE -"Last Comments" for "document transition reason" showing up for every document (SUP-1219)" Committed by: Megan Watson Reviewed by: Donald Jackson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/branches/RB_3.5.4a@9606 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
28 additions
and
23 deletions
plugins/ktcore/KTDocumentViewlets.php
| ... | ... | @@ -6,31 +6,31 @@ |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | 12 | * Free Software Foundation. |
| 13 | - * | |
| 13 | + * | |
| 14 | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | 17 | * details. |
| 18 | - * | |
| 18 | + * | |
| 19 | 19 | * You should have received a copy of the GNU General Public License |
| 20 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | |
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 21 | + * | |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | |
| 28 | + * | |
| 29 | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | 34 | * copyright notice. |
| 35 | 35 | * Contributor( s): ______________________________________ |
| 36 | 36 | * |
| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 | require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php"); |
| 40 | 40 | require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); |
| 41 | 41 | |
| 42 | -// {{{ KTDocumentDetailsAction | |
| 42 | +// {{{ KTDocumentDetailsAction | |
| 43 | 43 | class KTWorkflowViewlet extends KTDocumentViewlet { |
| 44 | 44 | var $sName = 'ktcore.viewlets.document.workflow'; |
| 45 | 45 | |
| ... | ... | @@ -47,20 +47,21 @@ class KTWorkflowViewlet extends KTDocumentViewlet { |
| 47 | 47 | $oKTTemplating =& KTTemplating::getSingleton(); |
| 48 | 48 | $oTemplate =& $oKTTemplating->loadTemplate("ktcore/document/viewlets/workflow"); |
| 49 | 49 | if (is_null($oTemplate)) { return ""; } |
| 50 | - | |
| 50 | + | |
| 51 | 51 | $oWorkflowState = KTWorkflowState::get($this->oDocument->getWorkflowStateId()); |
| 52 | 52 | if (PEAR::isError($oWorkflowState)) { |
| 53 | 53 | return ""; |
| 54 | 54 | } |
| 55 | - | |
| 55 | + | |
| 56 | 56 | $aDisplayTransitions = array(); |
| 57 | 57 | $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($this->oDocument, $this->oUser); |
| 58 | 58 | if (empty($aTransitions)) { |
| 59 | 59 | return ""; |
| 60 | 60 | } |
| 61 | - | |
| 61 | + | |
| 62 | 62 | // Check if the document has been checked out |
| 63 | 63 | $bIsCheckedOut = $this->oDocument->getIsCheckedOut(); |
| 64 | + $iId = $this->oDocument->getId(); | |
| 64 | 65 | if($bIsCheckedOut){ |
| 65 | 66 | // If document is checked out, don't link into the workflow. |
| 66 | 67 | $aDisplayTransitions = array(); |
| ... | ... | @@ -69,43 +70,47 @@ class KTWorkflowViewlet extends KTDocumentViewlet { |
| 69 | 70 | if(is_null($oTransition) || PEAR::isError($oTransition)){ |
| 70 | 71 | continue; |
| 71 | 72 | } |
| 72 | - | |
| 73 | + | |
| 73 | 74 | $aDisplayTransitions[] = array( |
| 74 | - 'url' => KTUtil::ktLink('action.php', 'ktcore.actions.document.workflow', array("fDocumentId" => $this->oDocument->getId(), "action" => "quicktransition", "fTransitionId" => $oTransition->getId())), | |
| 75 | + 'url' => KTUtil::ktLink('action.php', 'ktcore.actions.document.workflow', array("fDocumentId" => $iId, "action" => "quicktransition", "fTransitionId" => $oTransition->getId())), | |
| 75 | 76 | 'name' => $oTransition->getName(), |
| 76 | 77 | ); |
| 77 | 78 | } |
| 78 | 79 | } |
| 79 | - | |
| 80 | + | |
| 80 | 81 | //Retreive the comment for the previous transition |
| 81 | 82 | $aCommentQuery = array( |
| 82 | - "SELECT comment FROM document_transactions where transaction_namespace='ktcore.transactions.workflow_state_transition' ORDER BY id DESC LIMIT 1;" | |
| 83 | + "SELECT comment FROM document_transactions | |
| 84 | + where transaction_namespace='ktcore.transactions.workflow_state_transition' | |
| 85 | + AND document_id = ? | |
| 86 | + ORDER BY id DESC LIMIT 1;" | |
| 83 | 87 | ); |
| 88 | + $aCommentQuery[] = array($iId); | |
| 84 | 89 | $aTransitionComments = DBUtil::getResultArray($aCommentQuery); |
| 85 | - $oLatestTransitionComment = null; | |
| 90 | + $oLatestTransitionComment = null; | |
| 86 | 91 | if(!empty($aTransitionComments)) |
| 87 | 92 | { |
| 88 | 93 | $aRow = $aTransitionComments[0]; |
| 89 | 94 | $oLatestTransitionComment = $aRow['comment']; |
| 90 | 95 | $iCommentPosition = strpos($oLatestTransitionComment,':'); //comment found after first colon in string |
| 91 | - | |
| 96 | + | |
| 92 | 97 | if($iCommentPosition>0) //if comment found |
| 93 | 98 | { |
| 94 | - $oLatestTransitionComment = substr($oLatestTransitionComment, $iCommentPosition+2, (strlen($oLatestTransitionComment)-$iCommentPosition)); | |
| 99 | + $oLatestTransitionComment = substr($oLatestTransitionComment, $iCommentPosition+2, (strlen($oLatestTransitionComment)-$iCommentPosition)); | |
| 95 | 100 | } |
| 96 | - else //if no comment found - i.e. first state in workflow | |
| 101 | + else //if no comment found - i.e. first state in workflow | |
| 97 | 102 | { |
| 98 | 103 | $oLatestTransitionComment = null; |
| 99 | 104 | } |
| 100 | 105 | } |
| 101 | - | |
| 106 | + | |
| 102 | 107 | $oTemplate->setData(array( |
| 103 | 108 | 'context' => $this, |
| 104 | 109 | 'bIsCheckedOut' => $bIsCheckedOut, |
| 105 | 110 | 'transitions' => $aDisplayTransitions, |
| 106 | 111 | 'state_name' => $oWorkflowState->getName(), |
| 107 | 112 | 'comment' => $oLatestTransitionComment, |
| 108 | - )); | |
| 113 | + )); | |
| 109 | 114 | return $oTemplate->render(); |
| 110 | 115 | } |
| 111 | 116 | } | ... | ... |