Commit 5ca42071f68dc3f30eec80d1efc886064286d3bd
1 parent
602adf63
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/trunk@9605 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
28 additions
and
23 deletions
plugins/ktcore/KTDocumentViewlets.php
| @@ -6,31 +6,31 @@ | @@ -6,31 +6,31 @@ | ||
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2008 KnowledgeTree Inc. | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | 9 | + * |
| 10 | * This program is free software; you can redistribute it and/or modify it under | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | * the terms of the GNU General Public License version 3 as published by the | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | * Free Software Foundation. | 12 | * Free Software Foundation. |
| 13 | - * | 13 | + * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | * details. | 17 | * details. |
| 18 | - * | 18 | + * |
| 19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 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 | * California 94120-7775, or email info@knowledgetree.com. | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | 24 | + * |
| 25 | * The interactive user interfaces in modified source and object code versions | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | * of this program must display Appropriate Legal Notices, as required under | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | * Section 5 of the GNU General Public License version 3. | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | 28 | + * |
| 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * copyright notice. | 34 | * copyright notice. |
| 35 | * Contributor( s): ______________________________________ | 35 | * Contributor( s): ______________________________________ |
| 36 | * | 36 | * |
| @@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
| 39 | require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php"); | 39 | require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php"); |
| 40 | require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); | 40 | require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); |
| 41 | 41 | ||
| 42 | -// {{{ KTDocumentDetailsAction | 42 | +// {{{ KTDocumentDetailsAction |
| 43 | class KTWorkflowViewlet extends KTDocumentViewlet { | 43 | class KTWorkflowViewlet extends KTDocumentViewlet { |
| 44 | var $sName = 'ktcore.viewlets.document.workflow'; | 44 | var $sName = 'ktcore.viewlets.document.workflow'; |
| 45 | 45 | ||
| @@ -47,20 +47,21 @@ class KTWorkflowViewlet extends KTDocumentViewlet { | @@ -47,20 +47,21 @@ class KTWorkflowViewlet extends KTDocumentViewlet { | ||
| 47 | $oKTTemplating =& KTTemplating::getSingleton(); | 47 | $oKTTemplating =& KTTemplating::getSingleton(); |
| 48 | $oTemplate =& $oKTTemplating->loadTemplate("ktcore/document/viewlets/workflow"); | 48 | $oTemplate =& $oKTTemplating->loadTemplate("ktcore/document/viewlets/workflow"); |
| 49 | if (is_null($oTemplate)) { return ""; } | 49 | if (is_null($oTemplate)) { return ""; } |
| 50 | - | 50 | + |
| 51 | $oWorkflowState = KTWorkflowState::get($this->oDocument->getWorkflowStateId()); | 51 | $oWorkflowState = KTWorkflowState::get($this->oDocument->getWorkflowStateId()); |
| 52 | if (PEAR::isError($oWorkflowState)) { | 52 | if (PEAR::isError($oWorkflowState)) { |
| 53 | return ""; | 53 | return ""; |
| 54 | } | 54 | } |
| 55 | - | 55 | + |
| 56 | $aDisplayTransitions = array(); | 56 | $aDisplayTransitions = array(); |
| 57 | $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($this->oDocument, $this->oUser); | 57 | $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($this->oDocument, $this->oUser); |
| 58 | if (empty($aTransitions)) { | 58 | if (empty($aTransitions)) { |
| 59 | return ""; | 59 | return ""; |
| 60 | } | 60 | } |
| 61 | - | 61 | + |
| 62 | // Check if the document has been checked out | 62 | // Check if the document has been checked out |
| 63 | $bIsCheckedOut = $this->oDocument->getIsCheckedOut(); | 63 | $bIsCheckedOut = $this->oDocument->getIsCheckedOut(); |
| 64 | + $iId = $this->oDocument->getId(); | ||
| 64 | if($bIsCheckedOut){ | 65 | if($bIsCheckedOut){ |
| 65 | // If document is checked out, don't link into the workflow. | 66 | // If document is checked out, don't link into the workflow. |
| 66 | $aDisplayTransitions = array(); | 67 | $aDisplayTransitions = array(); |
| @@ -69,43 +70,47 @@ class KTWorkflowViewlet extends KTDocumentViewlet { | @@ -69,43 +70,47 @@ class KTWorkflowViewlet extends KTDocumentViewlet { | ||
| 69 | if(is_null($oTransition) || PEAR::isError($oTransition)){ | 70 | if(is_null($oTransition) || PEAR::isError($oTransition)){ |
| 70 | continue; | 71 | continue; |
| 71 | } | 72 | } |
| 72 | - | 73 | + |
| 73 | $aDisplayTransitions[] = array( | 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 | 'name' => $oTransition->getName(), | 76 | 'name' => $oTransition->getName(), |
| 76 | ); | 77 | ); |
| 77 | } | 78 | } |
| 78 | } | 79 | } |
| 79 | - | 80 | + |
| 80 | //Retreive the comment for the previous transition | 81 | //Retreive the comment for the previous transition |
| 81 | $aCommentQuery = array( | 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 | $aTransitionComments = DBUtil::getResultArray($aCommentQuery); | 89 | $aTransitionComments = DBUtil::getResultArray($aCommentQuery); |
| 85 | - $oLatestTransitionComment = null; | 90 | + $oLatestTransitionComment = null; |
| 86 | if(!empty($aTransitionComments)) | 91 | if(!empty($aTransitionComments)) |
| 87 | { | 92 | { |
| 88 | $aRow = $aTransitionComments[0]; | 93 | $aRow = $aTransitionComments[0]; |
| 89 | $oLatestTransitionComment = $aRow['comment']; | 94 | $oLatestTransitionComment = $aRow['comment']; |
| 90 | $iCommentPosition = strpos($oLatestTransitionComment,':'); //comment found after first colon in string | 95 | $iCommentPosition = strpos($oLatestTransitionComment,':'); //comment found after first colon in string |
| 91 | - | 96 | + |
| 92 | if($iCommentPosition>0) //if comment found | 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 | $oLatestTransitionComment = null; | 103 | $oLatestTransitionComment = null; |
| 99 | } | 104 | } |
| 100 | } | 105 | } |
| 101 | - | 106 | + |
| 102 | $oTemplate->setData(array( | 107 | $oTemplate->setData(array( |
| 103 | 'context' => $this, | 108 | 'context' => $this, |
| 104 | 'bIsCheckedOut' => $bIsCheckedOut, | 109 | 'bIsCheckedOut' => $bIsCheckedOut, |
| 105 | 'transitions' => $aDisplayTransitions, | 110 | 'transitions' => $aDisplayTransitions, |
| 106 | 'state_name' => $oWorkflowState->getName(), | 111 | 'state_name' => $oWorkflowState->getName(), |
| 107 | 'comment' => $oLatestTransitionComment, | 112 | 'comment' => $oLatestTransitionComment, |
| 108 | - )); | 113 | + )); |
| 109 | return $oTemplate->render(); | 114 | return $oTemplate->render(); |
| 110 | } | 115 | } |
| 111 | } | 116 | } |