Commit 9982e88317d6c49b651ee4030bf61ec9a83916df
1 parent
f17ac464
Add a folder action to view transactions on a folder
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5243 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
116 additions
and
0 deletions
plugins/ktcore/folder/Transactions.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * $Id$ | |
| 5 | + * | |
| 6 | + * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | |
| 7 | + * | |
| 8 | + * This program is free software; you can redistribute it and/or modify | |
| 9 | + * it under the terms of the GNU General Public License as published by | |
| 10 | + * the Free Software Foundation; using version 2 of the License. | |
| 11 | + * | |
| 12 | + * This program is distributed in the hope that it will be useful, | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | + * GNU General Public License for more details. | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License | |
| 18 | + * along with this program; if not, write to the Free Software | |
| 19 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 | + * | |
| 21 | + * ------------------------------------------------------------------------- | |
| 22 | + * | |
| 23 | + * You can contact the copyright owner regarding licensing via the contact | |
| 24 | + * details that can be found on the KnowledgeTree web site: | |
| 25 | + * | |
| 26 | + * http://www.ktdms.com/ | |
| 27 | + */ | |
| 28 | + | |
| 29 | +require_once(KT_LIB_DIR . '/actions/folderaction.inc.php'); | |
| 30 | + | |
| 31 | +require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php"); | |
| 32 | +require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php"); | |
| 33 | +require_once(KT_LIB_DIR . "/foldermanagement/folderutil.inc.php"); | |
| 34 | +require_once(KT_LIB_DIR . "/documentmanagement/observers.inc.php"); | |
| 35 | + | |
| 36 | +require_once(KT_LIB_DIR . "/documentmanagement/documentutil.inc.php"); | |
| 37 | + | |
| 38 | +class KTFolderTransactionsAction extends KTFolderAction { | |
| 39 | + var $sName = 'ktcore.actions.folder.transactions'; | |
| 40 | + var $_sShowPermission = "ktcore.permissions.read"; | |
| 41 | + | |
| 42 | + function getDisplayName() { | |
| 43 | + return _kt('Folder transactions'); | |
| 44 | + } | |
| 45 | + | |
| 46 | + function do_main() { | |
| 47 | + $this->oPage->setBreadcrumbDetails(_kt("transactions")); | |
| 48 | + $this->oPage->setTitle(_kt('Folder transactions')); | |
| 49 | + | |
| 50 | + // $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/transactions'); | |
| 51 | + | |
| 52 | + $folder_data = array(); | |
| 53 | + $folder_data["folder_id"] = $this->oFolder->getId(); | |
| 54 | + | |
| 55 | + $this->oPage->setSecondaryTitle($this->oFolder->getName()); | |
| 56 | + | |
| 57 | + $aTransactions = array(); | |
| 58 | + // FIXME do we really need to use a raw db-access here? probably... | |
| 59 | + $sQuery = "SELECT DTT.name AS transaction_name, U.name AS user_name, FT.comment AS comment, FT.datetime AS datetime " . | |
| 60 | + "FROM " . KTUtil::getTableName("folder_transactions") . " AS FT LEFT JOIN " . KTUtil::getTableName("users") . " AS U ON FT.user_id = U.id " . | |
| 61 | + "LEFT JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = FT.transaction_namespace " . | |
| 62 | + "WHERE FT.folder_id = ? ORDER BY FT.datetime DESC"; | |
| 63 | + $aParams = array($this->oFolder->getId()); | |
| 64 | + $res = DBUtil::getResultArray(array($sQuery, $aParams)); | |
| 65 | + if (PEAR::isError($res)) { | |
| 66 | + var_dump($res); // FIXME be graceful on failure. | |
| 67 | + exit(0); | |
| 68 | + } | |
| 69 | + | |
| 70 | + // FIXME roll up view transactions | |
| 71 | + $aTransactions = $res; | |
| 72 | + | |
| 73 | + // render pass. | |
| 74 | + $this->oPage->title = _kt("Folder History"); | |
| 75 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 76 | + $oTemplate = $oTemplating->loadTemplate("kt3/view_folder_history"); | |
| 77 | + $aTemplateData = array( | |
| 78 | + "context" => $this, | |
| 79 | + "folder_id" => $folder_id, | |
| 80 | + "folder" => $this->oFolder, | |
| 81 | + "transactions" => $aTransactions, | |
| 82 | + ); | |
| 83 | + return $oTemplate->render($aTemplateData); | |
| 84 | + } | |
| 85 | + | |
| 86 | + | |
| 87 | +} | |
| 88 | + | |
| 89 | +?> | ... | ... |
templates/kt3/view_folder_history.smarty
0 → 100644
| 1 | +<h2>{i18n}Transaction History{/i18n}: {$folder->getName()}</h2> | |
| 2 | + | |
| 3 | +<p class="descriptiveText">{i18n}This page provides details of all activities that have been carried out on the folder.{/i18n}</p> | |
| 4 | + | |
| 5 | + | |
| 6 | + <table class="document_history" summary="{i18n}Folder History{/i18n}" cellspacing="0"> | |
| 7 | + | |
| 8 | + <thead> | |
| 9 | + <tr> | |
| 10 | + <th class="username">{i18n}User{/i18n}</th> | |
| 11 | + <th class="action">{i18n}Action{/i18n}</th> | |
| 12 | + <th class="date">{i18n}Date{/i18n}</th> | |
| 13 | + <th class="comment">{i18n}Comment{/i18n}</th> | |
| 14 | + </tr> | |
| 15 | + </thead> | |
| 16 | + <tbody> | |
| 17 | + {foreach item=aTransactionRow from=$transactions} | |
| 18 | + <tr class="{cycle options=even,odd}"> | |
| 19 | + <td class="username">{$aTransactionRow.user_name}</td> | |
| 20 | + <td class="action">{$aTransactionRow.transaction_name}</td> | |
| 21 | + <td class="date">{$aTransactionRow.datetime}</td> | |
| 22 | + <td class="comment">{$aTransactionRow.comment}</td> | |
| 23 | + </tr> | |
| 24 | + {/foreach} | |
| 25 | + </tbody> | |
| 26 | + | |
| 27 | + </table> | ... | ... |