Commit 0df2b01c3184a3d75401969419dbc40cf904c481
1 parent
0282948c
Replaced by KT3UI view.php
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4031 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
0 additions
and
935 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Contains the business logic required to build the document view page. | |
| 6 | - * Will use documentViewUI.php for HTML | |
| 7 | - * | |
| 8 | - * Expected form varaibles: | |
| 9 | - * o $fDocumentID - Primary key of document to view | |
| 10 | - * | |
| 11 | - * Optional form variables: | |
| 12 | - * o fCollaborationEdit - the user attempted to edit a collaboration step that is currently active | |
| 13 | - * o fForDownload - the user is attempting to download the document | |
| 14 | - * o fBeginCollaboration - the user selected the 'Begin Collaboration' button | |
| 15 | - * o fFireSubscription - the document has been modified, and a subscription alert must be fired | |
| 16 | - * | |
| 17 | - * | |
| 18 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 19 | - * | |
| 20 | - * This program is free software; you can redistribute it and/or modify | |
| 21 | - * it under the terms of the GNU General Public License as published by | |
| 22 | - * the Free Software Foundation; either version 2 of the License, or | |
| 23 | - * (at your option) any later version. | |
| 24 | - * | |
| 25 | - * This program is distributed in the hope that it will be useful, | |
| 26 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 27 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 28 | - * GNU General Public License for more details. | |
| 29 | - * | |
| 30 | - * You should have received a copy of the GNU General Public License | |
| 31 | - * along with this program; if not, write to the Free Software | |
| 32 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 33 | - * | |
| 34 | - * @version $Revision$ | |
| 35 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 36 | - * @package documentmanagement | |
| 37 | - */ | |
| 38 | - | |
| 39 | -require_once("../../../../config/dmsDefaults.php"); | |
| 40 | - | |
| 41 | -KTUtil::extractGPC('fCheckedOut', 'fComment', 'fDocumentID', 'fFireSubscription', 'fFolderName', 'fForPublish', 'fShowSection', 'fSubmit', 'fWebSiteID'); | |
| 42 | - | |
| 43 | -require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | |
| 44 | - | |
| 45 | -require_once("$default->fileSystemRoot/lib/email/Email.inc"); | |
| 46 | - | |
| 47 | -require_once("$default->fileSystemRoot/lib/users/User.inc"); | |
| 48 | - | |
| 49 | -require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); | |
| 50 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc"); | |
| 51 | -require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | |
| 52 | -require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentInstance.inc"); | |
| 53 | - | |
| 54 | -require_once("$default->fileSystemRoot/lib/archiving/ArchivingSettings.inc"); | |
| 55 | -require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiving.inc"); | |
| 56 | -require_once("$default->fileSystemRoot/lib/archiving/TimePeriod.inc"); | |
| 57 | - | |
| 58 | -require_once("$default->fileSystemRoot/lib/foldermanagement/FolderUserRole.inc"); | |
| 59 | -require_once("$default->fileSystemRoot/lib/roles/Role.inc"); | |
| 60 | -require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | |
| 61 | - | |
| 62 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); | |
| 63 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | |
| 64 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 65 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); | |
| 66 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | |
| 67 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | |
| 68 | - | |
| 69 | -require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); | |
| 70 | - | |
| 71 | -require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc"); | |
| 72 | -require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); | |
| 73 | - | |
| 74 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/restoreArchivedDocumentUI.inc"); | |
| 75 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc"); | |
| 76 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc"); | |
| 77 | -require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | |
| 78 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 79 | - | |
| 80 | -if (checkSession()) { | |
| 81 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 82 | - $oPatternCustom = & new PatternCustom(); | |
| 83 | - if (isset($fDocumentID)) { | |
| 84 | - $oDocument = & Document::get($fDocumentID); | |
| 85 | - if (isset($fCollaborationEdit) && Permission::userHasDocumentWritePermission($oDocument)) { | |
| 86 | - //return value from collaborationBL.php. User attempted to edit | |
| 87 | - //a step in the document collaboration process that is currently being | |
| 88 | - //executed | |
| 89 | - $sStatusMessage = _("You cannot edit a document collaboration step that is completed or currently underway"); | |
| 90 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 91 | - $main->setDHTMLScrolling(false); | |
| 92 | - } else if (isset($fBeginCollaboration) && Permission::userHasDocumentWritePermission($oDocument)) { | |
| 93 | - //begin the collaboration process | |
| 94 | - //first ensure that all steps in the collaboration process are assigned | |
| 95 | - $aFolderCollaboration = FolderCollaboration::getList(array("WHERE folder_id = ?", $oDocument->getFolderID()));/*ok*/ | |
| 96 | - if (count($aFolderCollaboration) > 0) { | |
| 97 | - //if the the folder has collaboration steps set up | |
| 98 | - $aFolderUserRoles = FolderUserRole::getList(array("document_id = ?", $fDocumentID));/*ok*/ | |
| 99 | - if (count($aFolderCollaboration) == count($aFolderUserRoles)) { | |
| 100 | - //if all the roles have been assigned we can start the collaboration process | |
| 101 | - | |
| 102 | - //TODO: check if this collaboration has already occured, and then reset all the steps before beginning it again | |
| 103 | - //DocumentCollaboration::resetDocumentCollaborationSteps($fDocumentID); | |
| 104 | - | |
| 105 | - $oDocument->beginCollaborationProcess(); | |
| 106 | - $sStatusMessage = _("Document collaboration successfully started"); | |
| 107 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 108 | - } else { | |
| 109 | - // check that default users have been assigned to the routing steps before using them | |
| 110 | - | |
| 111 | - if (FolderCollaboration::defaultUsersAssigned($aFolderCollaboration)) { | |
| 112 | - //not all the roles have actual users assigned to them, so we must assign the | |
| 113 | - //default users and then proceed | |
| 114 | - | |
| 115 | - FolderUserRole::createDefaultFolderUserRoles($oDocument); | |
| 116 | - $oDocument->beginCollaborationProcess(); | |
| 117 | - $sStatusMessage = _("Document collaboration successfully started"); | |
| 118 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 119 | - } else { | |
| 120 | - // the folder does not have default users assigned for the routing steps | |
| 121 | - $sStatusMessage = _("Default users have not been assigned at the folder level. Please set these up, or choose specific users for this document before attempting to start collaboration."); | |
| 122 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 123 | - } | |
| 124 | - } | |
| 125 | - } else { | |
| 126 | - //the folder has no collaboration set up yet, so we can't start document collaboration | |
| 127 | - $sStatusMessage = _("The collaboration steps for the folder must be set up before collaboration can begin"); | |
| 128 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 129 | - } | |
| 130 | - $main->setDHTMLScrolling(false); | |
| 131 | - | |
| 132 | - } else if ((isset($fCollaborationStepComplete)) && (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($fDocumentID))) { | |
| 133 | - //the user has signled that they have completed their step in the collaboration process | |
| 134 | - if (DocumentCollaboration::isLastStepInCollaborationProcess($fDocumentID)) { | |
| 135 | - //the last step in the collaboration process has been performed- email the document creator | |
| 136 | - $oDocument->endCollaborationProcess(); | |
| 137 | - | |
| 138 | - // on the last collaboration step- trigger a major revision | |
| 139 | - // major version number rollover | |
| 140 | - $oDocument->setMajorVersionNumber($oDocument->getMajorVersionNumber()+1); | |
| 141 | - // reset minor version number | |
| 142 | - $oDocument->setMinorVersionNumber(0); | |
| 143 | - $oDocument->update(); | |
| 144 | - // TODO: create a transaction? | |
| 145 | - | |
| 146 | - $oUser = User::get($oDocument->getCreatorID()); | |
| 147 | - $sBody = $oUser->getName() . ", the collaboration process for the document, '" . generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=" . $oDocument->getID(), $oDocument->getName()) . "', has been completed. "; | |
| 148 | - $oEmail = & new Email(); | |
| 149 | - $oEmail->send($oUser->getEmail(), "Document collaboration complete", $sBody); | |
| 150 | - | |
| 151 | - // collaboration accepted transaction | |
| 152 | - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document collaboration step accepted", COLLAB_ACCEPT); | |
| 153 | - if ($oDocumentTransaction->create()) { | |
| 154 | - $default->log->debug("viewBL.php created collaboration accepted document transaction for document ID=$fDocumentID"); | |
| 155 | - } else { | |
| 156 | - $default->log->error("viewBL.php couldn't create collaboration accepted document transaction for document ID=$fDocumentID"); | |
| 157 | - } | |
| 158 | - | |
| 159 | - //possibly set the document up for web publishing???? | |
| 160 | - $sStatusMessage = _("Document collaboration complete. The document initiator has been notified"); | |
| 161 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 162 | - } else { | |
| 163 | - //start the next steps if all criteria are met | |
| 164 | - DocumentCollaboration::beginNextStepInCollaborationProcess($fDocumentID, $_SESSION["userID"]); | |
| 165 | - // collaboration accepted transaction | |
| 166 | - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document collaboration step accepted", COLLAB_ACCEPT); | |
| 167 | - if ($oDocumentTransaction->create()) { | |
| 168 | - $default->log->debug("viewBL.php created collaboration accepted document transaction for document ID=$fDocumentID"); | |
| 169 | - } else { | |
| 170 | - $default->log->error("viewBL.php couldn't create collaboration accepted document transaction for document ID=$fDocumentID"); | |
| 171 | - } | |
| 172 | - $sStatusMessage = _("The next steps in the collaboration process have been started"); | |
| 173 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 174 | - } | |
| 175 | - $main->setDHTMLScrolling(false); | |
| 176 | - | |
| 177 | - } else if (isset($fForPublish) && | |
| 178 | - !DocumentCollaboration::documentIsPublished($fDocumentID) && | |
| 179 | - !DocumentCollaboration::documentIsPendingWebPublishing($fDocumentID)) { | |
| 180 | - | |
| 181 | - if ($fSubmit) { | |
| 182 | - // user wishes to publish document | |
| 183 | - $oWebDocument = WebDocument::get(lookupID($default->web_documents_table, "document_id", $fDocumentID)); | |
| 184 | - $default->log->info("retrieved web document=" . arrayToString($oWebDocument)); | |
| 185 | - if ($oWebDocument) { | |
| 186 | - if ($fWebSiteID) { | |
| 187 | - $oWebDocument->setStatusID(PENDING); | |
| 188 | - $oWebDocument->setWebSiteID($fWebSiteID); | |
| 189 | - $oWebDocument->setDateTime(getCurrentDateTime()); | |
| 190 | - } else { | |
| 191 | - $oWebDocument->setStatusID(PUBLISHED); | |
| 192 | - $oWebDocument->setWebSiteID(-1); | |
| 193 | - $oWebDocument->setDateTime(getCurrentDateTime()); | |
| 194 | - } | |
| 195 | - | |
| 196 | - if ($oWebDocument->update()) { | |
| 197 | - $default->log->info("updated status=" . arrayToString($oWebDocument)); | |
| 198 | - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE); | |
| 199 | - $oDocumentTransaction->create(); | |
| 200 | - if ((strlen($fWebSiteID) > 0)) { | |
| 201 | - DocumentCollaboration::notifyWebMaster($fDocumentID, $fComment); | |
| 202 | - } | |
| 203 | - if ($fWebSiteID) { | |
| 204 | - $sStatusMessage = _("The document has been marked as pending publishing and the web publisher has been notified"); | |
| 205 | - } else { | |
| 206 | - $sStatusMessage = _("The document has been published"); | |
| 207 | - } | |
| 208 | - $default->log->info("printing page"); | |
| 209 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 210 | - } else { | |
| 211 | - $sStatusMessage = _("An error occured while attempting to update the document for publishing. Please try again later."); | |
| 212 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 213 | - } | |
| 214 | - } else { | |
| 215 | - $sStatusMessage = _("An error occured while attempting to update the document for publishing. Please try again later."); | |
| 216 | - $oPatternCustom->setHtml(getStatusPage($oDocument, $sStatusMessage)); | |
| 217 | - } | |
| 218 | - } else { | |
| 219 | - // prompt for the website to publish to | |
| 220 | - $oPatternCustom->setHtml(getWebPublishPage($oDocument)); | |
| 221 | - $main->setFormAction($_SERVER['PHP_SELF']); | |
| 222 | - } | |
| 223 | - $main->setDHTMLScrolling(false); | |
| 224 | - | |
| 225 | - } else if (Permission::userHasDocumentWritePermission($oDocument) || Permission::userHasDocumentReadPermission($oDocument)) { | |
| 226 | - | |
| 227 | - // check subscription flag | |
| 228 | - // ?? | |
| 229 | - if (isset($fFireSubscription)) { | |
| 230 | - // fire subscription alerts for the modified document | |
| 231 | - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"), | |
| 232 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 233 | - array( "folderID" => $oDocument->getFolderID(), | |
| 234 | - "modifiedDocumentName" => $oDocument->getName())); | |
| 235 | - $default->log->info("viewBL.php fired $count subscription alerts for modified document $fFolderName"); | |
| 236 | - } | |
| 237 | - | |
| 238 | - if ($oDocument->isLive()) { | |
| 239 | - if (Permission::userHasDocumentWritePermission($oDocument)) { | |
| 240 | - $oPatternCustom->setHtml(getPage($oDocument, true)); | |
| 241 | - } else if (Permission::userHasDocumentReadPermission($oDocument)) { | |
| 242 | - $oPatternCustom->setHtml(getPage($oDocument, false)); | |
| 243 | - } | |
| 244 | - $main->setDHTMLScrolling(false); | |
| 245 | - | |
| 246 | - $sJavaScript = "switchDiv('" . (isset($fShowSection) ? $fShowSection : "documentData") . "', 'document');"; | |
| 247 | - if ($fCheckedOut) { | |
| 248 | - $sCheckOutMessage = _("You have now checked out this document. No one else can make updates to the document while you have it checked out. Save the document, make your changes and check it back in as soon as you finish working on it."); | |
| 249 | - $sJavaScript .= "redirectLink('$sCheckOutMessage', '" . generateControllerUrl("downloadDocument", "fDocumentID=$fDocumentID") . "')"; | |
| 250 | - } | |
| 251 | - $main->setOnLoadJavaScript($sJavaScript); | |
| 252 | - } else if ($oDocument->isArchived()) { | |
| 253 | - | |
| 254 | - // allow admins to restore the document | |
| 255 | - if (Permission::userIsSystemAdministrator() || Permission::userIsUnitAdministrator()) { | |
| 256 | - $oPatternCustom->setHtml(getRestoreArchivedDocumentPage($oDocument)); | |
| 257 | - } else { | |
| 258 | - // and ordinary users to request that the document be restored | |
| 259 | - $oPatternCustom->setHtml(getRequestRestoreDocumentPage($oDocument)); | |
| 260 | - } | |
| 261 | - } else { | |
| 262 | - $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 263 | - $main->setErrorMessage(_("The document you have chosen no longer exists in the DMS.")); | |
| 264 | - } | |
| 265 | - $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID()); | |
| 266 | - } else { | |
| 267 | - if ($oDocument) { | |
| 268 | - $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 269 | - } else { | |
| 270 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 271 | - } | |
| 272 | - $main->setErrorMessage(_("Either you do not have permission to view this document, or the document you have chosen no longer exists on the file system.")); | |
| 273 | - } | |
| 274 | - | |
| 275 | - } else { | |
| 276 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 277 | - $oPatternCustom->setHtml("<a href=\"javascript:history.go(-1)\"><img src=\"" . KTHtml::getBackButton() . "\" border=\"0\" /></a>\n"); | |
| 278 | - $main->setErrorMessage(_("You have not chosen a document to view")); | |
| 279 | - } | |
| 280 | - $main->setCentralPayload($oPatternCustom); | |
| 281 | - $main->render(); | |
| 282 | -} | |
| 283 | -?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id$ | |
| 4 | - * | |
| 5 | - * Contains HTML information required to build the document view page. | |
| 6 | - * Will be used by documentViewBL. | |
| 7 | - * | |
| 8 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 9 | - * | |
| 10 | - * This program is free software; you can redistribute it and/or modify | |
| 11 | - * it under the terms of the GNU General Public License as published by | |
| 12 | - * the Free Software Foundation; either version 2 of the License, or | |
| 13 | - * (at your option) any later version. | |
| 14 | - * | |
| 15 | - * This program is distributed in the hope that it will be useful, | |
| 16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | - * GNU General Public License for more details. | |
| 19 | - * | |
| 20 | - * You should have received a copy of the GNU General Public License | |
| 21 | - * along with this program; if not, write to the Free Software | |
| 22 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 23 | - * | |
| 24 | - * @version $Revision$ | |
| 25 | - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | |
| 26 | - * @package documentmanagement | |
| 27 | - */ | |
| 28 | - | |
| 29 | -require_once(KT_LIB_DIR . '/workflow/workflowstate.inc.php'); | |
| 30 | - | |
| 31 | -function renderDocumentPath($oDocument, $bDisplayActions = false) { | |
| 32 | - global $default; | |
| 33 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 34 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 35 | - | |
| 36 | - $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > "; | |
| 37 | - // #3425 for consistency | |
| 38 | - if ($bDisplayActions) { | |
| 39 | - $sDocumentPath .= "<a onClick=\"alert('" . _("This will view a copy of the current version of this document in the DMS. Any changes to this file will not be managed in the DMS.") . "'); return true;\" href=\"" . generateControllerUrl("downloadDocument", "fDocumentID=" . $oDocument->getID() . "&fForInlineView=1") . "\">" . $oDocument->getFileName() . "</a>"; | |
| 40 | - } else { | |
| 41 | - $sDocumentPath .= $oDocument->getFileName(); | |
| 42 | - } | |
| 43 | - return "<table border=\"0\" cellpadding=\"5\" width=\"610\"><tr bgcolor=\"$sTDBGColour\"><td width=\"87%\">" . $sDocumentPath . "</td>" . ($bDisplayActions ? "<td width=\"15%\" align=\"center\" valign=\"middle\"><strong>Actions</strong></td>" : "") . "</tr></table>\n"; | |
| 44 | -} | |
| 45 | - | |
| 46 | -function renderDocumentData($oDocument, $bEditable, $sStatusMessage = "") { | |
| 47 | - global $default; | |
| 48 | - $iVersionID = KTUtil::arrayGet($_REQUEST, 'fVersionID'); | |
| 49 | - $aDocuments = array($oDocument->getID()); | |
| 50 | - if (!empty($iVersionID)) { | |
| 51 | - $aDocuments[] = $iVersionID; | |
| 52 | - } | |
| 53 | - $sWhere = DBUtil::paramArray($aDocuments); | |
| 54 | - /*ok*/ $sQuery = "SELECT D.id, D.name, D.modified, D.created, D.size, U.name AS initiator, D.metadata_version, CONCAT(CONCAT(D.major_version, '.'), D.minor_version) AS version, DTL.name AS document_type, D.is_checked_out, COALESCE(U2.name, '') AS c_user " . | |
| 55 | - "FROM $default->documents_table AS D " . | |
| 56 | - "LEFT JOIN $default->users_table AS U ON U.id = D.creator_id " . | |
| 57 | - "LEFT OUTER JOIN $default->document_types_table AS DTL ON DTL.id = D.document_type_id " . | |
| 58 | - "LEFT OUTER JOIN $default->users_table AS U2 ON U2.id = D.checked_out_user_id " . | |
| 59 | - "WHERE D.id = ?"; | |
| 60 | - | |
| 61 | - // $aColumns = array("metadata_version", "name", "modified", "created", "size", "initiator", "document_type", "c_user", "id", "version"); | |
| 62 | - $aColumns = array( | |
| 63 | - "metadata_version" =>_("Metadata Version"), | |
| 64 | - "name" => _("Document title"), | |
| 65 | - "modified" => _("Last updated"), | |
| 66 | - "created" => _("Created"), | |
| 67 | - "size" => _("File Size"), | |
| 68 | - "initiator" => _("Document initiator"), | |
| 69 | - "document_type" => _("Document Type"), | |
| 70 | - "c_user" => _("Checked out by"), | |
| 71 | - "id" => _("ID"), | |
| 72 | - "document_version" => _("Document Version"), | |
| 73 | - ); | |
| 74 | - | |
| 75 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 76 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document_generic_metadata'); | |
| 77 | - | |
| 78 | - $iDocumentsLen = count($aDocuments); | |
| 79 | - $map = array(); | |
| 80 | - $iDocumentCount = 0; | |
| 81 | - foreach ($aDocuments as $iDocumentID) { | |
| 82 | - $oThisDocument =& Document::get($iDocumentID); | |
| 83 | - if (PEAR::isError($oThisDocument)) { | |
| 84 | - continue; | |
| 85 | - } | |
| 86 | - if ($oThisDocument === false) { | |
| 87 | - continue; | |
| 88 | - } | |
| 89 | - $aRow = DBUtil::getOneResult(array($sQuery, array($iDocumentID))); | |
| 90 | - foreach ($aColumns as $dbname => $prettyname) { | |
| 91 | - $newarray = KTUtil::arrayGet($map, $prettyname, array_fill(0, $iDocumentsLen, null)); | |
| 92 | - $newarray[$iDocumentCount] = $aRow[$dbname]; | |
| 93 | - $map[$prettyname] = $newarray; | |
| 94 | - } | |
| 95 | - $oState =& KTWorkflowState::getByDocument($oThisDocument); | |
| 96 | - $map['Workflow state'] = KTUtil::arrayGet($map, 'Metadata Version', array_fill(0, $iDocumentsLen, null)); | |
| 97 | - if ($oState) { | |
| 98 | - $map['Workflow state'][$iDocumentCount] = $oState->getHumanName(); | |
| 99 | - } else { | |
| 100 | - $map['Workflow state'][$iDocumentCount] = "Not in workflow"; | |
| 101 | - } | |
| 102 | - $iDocumentCount++; | |
| 103 | - } | |
| 104 | - | |
| 105 | - $oTemplate->setData(array( | |
| 106 | - 'map' => $map, | |
| 107 | - )); | |
| 108 | - | |
| 109 | - return $oTemplate->render(); | |
| 110 | -} | |
| 111 | - | |
| 112 | - | |
| 113 | -function renderGenericMetaData($oDocument, $bEditable) { | |
| 114 | - global $default; | |
| 115 | - $iVersionID = KTUtil::arrayGet($_REQUEST, 'fVersionID'); | |
| 116 | - $aDocuments = array($oDocument->getID()); | |
| 117 | - if (!empty($iVersionID)) { | |
| 118 | - $aDocuments[] = $iVersionID; | |
| 119 | - } | |
| 120 | - /*ok*/ $sQuery = "SELECT DF.name AS name, DFL.value as value " . | |
| 121 | - "FROM $default->documents_table AS D INNER JOIN $default->document_fields_link_table AS DFL ON D.id = DFL.document_id " . | |
| 122 | - "INNER JOIN $default->document_fields_table AS DF ON DF.id = DFL.document_field_id " . | |
| 123 | - "WHERE document_id = ? " . | |
| 124 | - "AND DF.is_generic = 1"; | |
| 125 | - | |
| 126 | - | |
| 127 | - $iDocumentsLen = count($aDocuments); | |
| 128 | - $map = array(); | |
| 129 | - $iDocumentCount = 0; | |
| 130 | - foreach ($aDocuments as $iDocumentID) { | |
| 131 | - $map['Metadata Version'] = KTUtil::arrayGet($map, 'Metadata Version', array_fill(0, $iDocumentsLen, null)); | |
| 132 | - $oThisDocument =& Document::get($iDocumentID); | |
| 133 | - if (PEAR::isError($oThisDocument)) { | |
| 134 | - continue; | |
| 135 | - } | |
| 136 | - if ($oThisDocument === false) { | |
| 137 | - continue; | |
| 138 | - } | |
| 139 | - $map['Metadata Version'][$iDocumentCount] = $oThisDocument->getMetadataVersion(); | |
| 140 | - $aTDRows = DBUtil::getResultArray(array($sQuery, array($iDocumentID))); | |
| 141 | - foreach ($aTDRows as $aRow) { | |
| 142 | - $newarray = KTUtil::arrayGet($map, $aRow['name'], array_fill(0, $iDocumentsLen, null)); | |
| 143 | - $newarray[$iDocumentCount] = $aRow['value']; | |
| 144 | - $map[$aRow['name']] = $newarray; | |
| 145 | - } | |
| 146 | - $iDocumentCount++; | |
| 147 | - } | |
| 148 | - | |
| 149 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 150 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document_generic_metadata'); | |
| 151 | - if ($bEditable) { | |
| 152 | - $editable = "<a href=\"$default->rootUrl/control.php?action=modifyDocumentGenericMetaData&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getEditButton() . "\" border=\"0\"></a>"; | |
| 153 | - } else { | |
| 154 | - $editable = ""; | |
| 155 | - } | |
| 156 | - $sToRender .= $oTemplate->render(array( | |
| 157 | - 'map' => $map, | |
| 158 | - 'editable' => $editable, | |
| 159 | - )); | |
| 160 | - | |
| 161 | - return $sToRender; | |
| 162 | -} | |
| 163 | - | |
| 164 | -function renderTypeSpecificMetaData($oDocument, $bEditable) { | |
| 165 | - global $default; | |
| 166 | - $iVersionID = KTUtil::arrayGet($_REQUEST, 'fVersionID'); | |
| 167 | - $aDocuments = array($oDocument->getID()); | |
| 168 | - if (!empty($iVersionID)) { | |
| 169 | - $aDocuments[] = $iVersionID; | |
| 170 | - } | |
| 171 | - | |
| 172 | - $sParam = DBUtil::paramArray($aDocuments); | |
| 173 | - $sQuery = "SELECT D.id AS document_id, DF.id AS field_id, DFL.value AS value, F.id AS fieldset_id " . | |
| 174 | - "FROM $default->documents_table AS D INNER JOIN document_fields_link AS DFL ON D.id = DFL.document_id " . | |
| 175 | - "INNER JOIN $default->document_fields_table AS DF ON DF.ID = DFL.document_field_id " . | |
| 176 | - "INNER JOIN $default->fieldsets_table AS F ON F.id = DF.parent_fieldset " . | |
| 177 | - "WHERE D.id IN ($sParam) " . | |
| 178 | - "AND DF.name NOT LIKE 'Category' " . | |
| 179 | - "AND DF.is_generic = 0"; | |
| 180 | - $aParam = $aDocuments; | |
| 181 | - | |
| 182 | - $aResults = DBUtil::getResultArray(array($sQuery, $aParam)); | |
| 183 | - | |
| 184 | - $aMap = array(); | |
| 185 | - foreach ($aResults as $aResult) { | |
| 186 | - $fieldset_id = $aResult['fieldset_id']; | |
| 187 | - $field_id = $aResult['field_id']; | |
| 188 | - $document_id = $aResult['document_id']; | |
| 189 | - $aMyFieldset = KTUtil::arrayGet($aMap, $fieldset_id); | |
| 190 | - if (empty($aMyFieldset)) { | |
| 191 | - $aMap[$fieldset_id]["fieldset"] = KTFieldset::get($fieldset_id); | |
| 192 | - $aMap[$fieldset_id]["fields"] = array(); | |
| 193 | - } | |
| 194 | - $aMyField = KTUtil::arrayGet($aMap[$fieldset_id]['fields'], $field_id); | |
| 195 | - if (empty($aMyField)) { | |
| 196 | - $aMap[$fieldset_id]['fields'][$field_id] = array(); | |
| 197 | - $aMap[$fieldset_id]['fields'][$field_id]['field'] = DocumentField::get($field_id); | |
| 198 | - $aMap[$fieldset_id]['fields'][$field_id]['values'] = array(); | |
| 199 | - } | |
| 200 | - $aMap[$fieldset_id]['fields'][$field_id]['values'][$document_id] = $aResult['value']; | |
| 201 | - } | |
| 202 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 203 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document_specific_metadata'); | |
| 204 | - $sToRender = $oTemplate->render(array( | |
| 205 | - 'aDocumentIds' => $aDocuments, | |
| 206 | - 'map' => $aMap, | |
| 207 | - )); | |
| 208 | - return $sToRender; | |
| 209 | - | |
| 210 | - print "<pre>"; | |
| 211 | - foreach ($aMap as $k => $v) { | |
| 212 | - print $v['fieldset']->getName() . "\n"; | |
| 213 | - foreach ($v['fields'] as $k => $aField) { | |
| 214 | - print $aField['field']->getName() . ": "; | |
| 215 | - foreach ($aField['values'] as $document_id => $sValue) { | |
| 216 | - print "$document_id => $sValue"; | |
| 217 | - } | |
| 218 | - print "\n"; | |
| 219 | - } | |
| 220 | - print "\n\n"; | |
| 221 | - } | |
| 222 | - exit(0); | |
| 223 | - | |
| 224 | - | |
| 225 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 226 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document_specific_metadata'); | |
| 227 | - if ($bEditable) { | |
| 228 | - $editable = "<a href=\"$default->rootUrl/control.php?action=modifyDocumentTypeMetaData&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getEditButton() . "\" border=\"0\"></a>"; | |
| 229 | - } else { | |
| 230 | - $editable = ""; | |
| 231 | - } | |
| 232 | - $sToRender = $oTemplate->render(array( | |
| 233 | - 'map' => $map, | |
| 234 | - 'editable' => $editable, | |
| 235 | - )); | |
| 236 | - | |
| 237 | - return $sToRender; | |
| 238 | -} | |
| 239 | - | |
| 240 | -function renderDocumentArchiveSettingsDetails($oDocument, $bEditable) { | |
| 241 | - global $default; | |
| 242 | - | |
| 243 | - // retrieve the appropriate settings given the document id | |
| 244 | - $oDocumentArchiving = DocumentArchiving::getFromDocumentID($oDocument->getID()); | |
| 245 | - if ($oDocumentArchiving) { | |
| 246 | - // retrieve the settings | |
| 247 | - $oArchiveSettings = ArchivingSettings::get($oDocumentArchiving->getArchivingSettingsID()); | |
| 248 | - // switch on archiving type | |
| 249 | - $sArchivingType = lookupName($default->archiving_type_lookup_table, $oArchiveSettings->getArchivingTypeID()); | |
| 250 | - $oTimePeriod = TimePeriod::get($oArchiveSettings->getTimePeriodID()); | |
| 251 | - | |
| 252 | - $sDisplayText = "<td>"; | |
| 253 | - switch ($sArchivingType) { | |
| 254 | - case "Date" : | |
| 255 | - $sDisplayText .= _("Expiration Date") . ": " . $oArchiveSettings->getExpirationDate(); | |
| 256 | - if ($oTimePeriod) { | |
| 257 | - $sDisplayText .= "<br/>Expires after " . $oTimePeriod->getUnits() . " "; | |
| 258 | - $sDisplayText .= lookupName($default->time_unit_lookup_table, $oTimePeriod->getTimeUnitID()) . " from document creation date"; | |
| 259 | - } | |
| 260 | - break; | |
| 261 | - case "Utilisation" : | |
| 262 | - $sDisplayText .= "Archive document " . $oTimePeriod->getUnits() . " "; | |
| 263 | - $sDisplayText .= lookupName($default->time_unit_lookup_table, $oTimePeriod->getTimeUnitID()); | |
| 264 | - $sDisplayText .= " after the last " . lookupName($default->transaction_types_table, $oArchiveSettings->getDocumentTransactionID()) . " transaction"; | |
| 265 | - break; | |
| 266 | - } | |
| 267 | - $sDisplayText .= "</td>" . ($bEditable ? "<td>" . generateControllerLink("modifyDocumentArchiveSettings", "fDocumentID=" . $oDocument->getID(), "Edit") . "</td>" : ""); | |
| 268 | - $sArchivingType = _("Archiving Type") . ": " . $sArchivingType; | |
| 269 | - } else { | |
| 270 | - $sArchivingType = ""; | |
| 271 | - $sDisplayText = _("No archiving settings"); | |
| 272 | - } | |
| 273 | - | |
| 274 | - $sToRender = "<table cellpadding=\"5\" border=\"0\" width=\"500\">"; | |
| 275 | - $sToRender .= "<caption align=\"top\" colspan=\"2\" align=\"left\"><b>" . _("Archiving Settings") . "</b></caption>"; | |
| 276 | - $sToRender .= "<th align=\"left\">" . $sArchivingType . "</th>"; | |
| 277 | - $sToRender .= "<tr bgcolor=\"F5F6EE\">"; | |
| 278 | - $sToRender .= $sDisplayText; | |
| 279 | - $sToRender .= "</tr>"; | |
| 280 | - $sToRender .= "</table>"; | |
| 281 | - return $sToRender; | |
| 282 | -} | |
| 283 | - | |
| 284 | -function renderDocumentArchiveSettings($oDocument, $bEditable) { | |
| 285 | - global $default; | |
| 286 | - | |
| 287 | - $sToRender .= "\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | |
| 288 | - $sToRender .= "\t<tr>\n"; | |
| 289 | - | |
| 290 | - $sToRender .= "\t\t<td>" . renderDocumentArchiveSettingsDetails($oDocument, $bEditable) . "</td>\n"; | |
| 291 | - $sToRender .= "\t</tr>"; | |
| 292 | - if ($bEditable) { | |
| 293 | - $sToRender .= "\t<tr>\n"; | |
| 294 | - // if there are no archiving settings then allow their addition | |
| 295 | - $oDocumentArchiving = DocumentArchiving::getFromDocumentID($oDocument->getID()); | |
| 296 | - $sToRender .= "\t\t<td>" . ($oDocumentArchiving ? "" : generateControllerLink("addDocumentArchiveSettings", "fDocumentID=" . $oDocument->getID(), "<img src=\"" . KTHtml::getAddButton() . "\" border=\"0\"/>")) . "</td>\n"; | |
| 297 | - $sToRender .= "\t</tr>"; | |
| 298 | - } | |
| 299 | - $sToRender .= "\t</table>\n"; | |
| 300 | - | |
| 301 | - return $sToRender; | |
| 302 | -} | |
| 303 | - | |
| 304 | -function renderEditableLinkedDocuments($oDocument) { | |
| 305 | - global $default; | |
| 306 | - | |
| 307 | - /*ok*/ $sQuery = array("SELECT D.id AS child_document_id, D.name, DL.id as document_link_id, " . | |
| 308 | - "DL.parent_document_id AS parent_document_id, DLT.name AS link_type, 'Unlink' AS unlink " . | |
| 309 | - "FROM $default->documents_table AS D INNER JOIN $default->document_link_table AS DL ON D.id = DL.child_document_id " . | |
| 310 | - "INNER JOIN $default->document_link_types_table AS DLT ON DL.link_type_id = DLT.id " . | |
| 311 | - "WHERE DL.parent_document_id = ?", $oDocument->getID()); | |
| 312 | - | |
| 313 | - $aColumns = array("name", "link_type", "unlink"); | |
| 314 | - $aColumnHeaders = array(_("Document"), _("Document Link Type")); | |
| 315 | - $aColumnTypes = array(3,3,3); | |
| 316 | - $aDBColumnArray = array("parent_document_id", "child_document_id","document_link_id", "child_document_id"); | |
| 317 | - $aQueryStringVariableNames = array("fParentDocumentID","fChildDocumentID", "fDocumentLinkID", "fDocumentID"); | |
| 318 | - $aLinkURLs = array(0=>"$default->rootUrl/control.php?action=viewDocument", 2=>"$default->rootUrl/control.php?action=removeDocumentLink"); | |
| 319 | - | |
| 320 | - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "500", $aLinkURLs, $aDBColumnArray, $aQueryStringVariableNames); | |
| 321 | - $oPatternTableSqlQuery->setTableHeading(_("Linked documents")); | |
| 322 | - $oPatternTableSqlQuery->setDisplayColumnHeadings(true); | |
| 323 | - | |
| 324 | - $sToRender .= "\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | |
| 325 | - $sToRender .= "\t<tr>\n"; | |
| 326 | - $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n"; | |
| 327 | - $sToRender .= "\t</tr>"; | |
| 328 | - $sToRender .= "\t<tr>\n"; | |
| 329 | - $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=addDocumentLink&fDocumentID=" . $oDocument->getID() ."\"><img src=\"" . KTHtml::getAddButton() . "\" border=\"0\"/></a></td>\n"; | |
| 330 | - $sToRender .= "\t</tr>"; | |
| 331 | - $sToRender .= "\t</table>\n"; | |
| 332 | - return $sToRender; | |
| 333 | -} | |
| 334 | - | |
| 335 | -function renderNonEditableLinkedDocuments($oDocument) { | |
| 336 | - global $default; | |
| 337 | - | |
| 338 | - /*ok*/ $sQuery = array("SELECT D.id, D.name " . | |
| 339 | - "FROM $default->documents_table AS D INNER JOIN $default->document_link_table AS DL ON D.id = DL.child_document_id " . | |
| 340 | - "WHERE DL.parent_document_id = ?", $oDocument->getID()); | |
| 341 | - | |
| 342 | - $aColumns = array("name"); | |
| 343 | - $aColumnHeaders = array(_("Document")); | |
| 344 | - $aColumnTypes = array(3); | |
| 345 | - $aDBColumnArray = array("id"); | |
| 346 | - $aQueryStringVariableNames = array("fDocumentID"); | |
| 347 | - $aLinkURLs = array(0=>"$default->rootUrl/control.php?action=viewDocument"); | |
| 348 | - | |
| 349 | - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "500", $aLinkURLs, $aDBColumnArray, $aQueryStringVariableNames); | |
| 350 | - $oPatternTableSqlQuery->setTableHeading(_("Linked documents")); | |
| 351 | - $oPatternTableSqlQuery->setDisplayColumnHeadings(true); | |
| 352 | - | |
| 353 | - $sToRender .= "\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | |
| 354 | - $sToRender .= "\t<tr>\n"; | |
| 355 | - $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n"; | |
| 356 | - $sToRender .= "\t</tr>"; | |
| 357 | - $sToRender .= "\t</table>\n"; | |
| 358 | - return $sToRender; | |
| 359 | -} | |
| 360 | - | |
| 361 | -function renderDependantDocuments($oDocument, $bEdit) { | |
| 362 | - global $default; | |
| 363 | - // FIXME: only allow escalation if you have write access and are the same user that requested the | |
| 364 | - // dependant document? | |
| 365 | - /*ok*/ $sQuery = array("SELECT DDI.id AS instance_id, DDI.document_title, U.name AS user_name, 'Escalate' AS escalate " . | |
| 366 | - "FROM $default->dependant_document_instance_table DDI " . | |
| 367 | - "INNER JOIN $default->users_table AS U ON DDI.user_id = U.id " . | |
| 368 | - "WHERE DDI.parent_document_id = ?", $oDocument->getID()); | |
| 369 | - | |
| 370 | - $aColumns = array("document_title", "user_name", "escalate"); | |
| 371 | - $aColumnHeaders = array(_("Document Title"), _("User")); | |
| 372 | - $aColumnTypes = array(1,1,3); | |
| 373 | - $aDBColumnArray = array("instance_id"); | |
| 374 | - $aQueryStringVariableNames = array("fInstanceID"); | |
| 375 | - $aLinkURLs = array(2=>generateControllerUrl("escalateDependantDocument")); | |
| 376 | - | |
| 377 | - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "500", $aLinkURLs, $aDBColumnArray, $aQueryStringVariableNames); | |
| 378 | - $oPatternTableSqlQuery->setTableHeading(_("Dependant documents")); | |
| 379 | - $oPatternTableSqlQuery->setDisplayColumnHeadings(true); | |
| 380 | - | |
| 381 | - $sToRender .= "\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | |
| 382 | - $sToRender .= "\t<tr>\n"; | |
| 383 | - $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n"; | |
| 384 | - $sToRender .= "\t</tr>"; | |
| 385 | - $sToRender .= "\t<tr>\n"; | |
| 386 | - $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=createDependantDocument&fDocumentID=" . $oDocument->getID() ."\"><img src=\"" . KTHtml::getAddButton() . "\" border=\"0\"/></a></td>\n"; | |
| 387 | - $sToRender .= "\t</tr>"; | |
| 388 | - $sToRender .= "\t</table>\n"; | |
| 389 | - return $sToRender; | |
| 390 | -} | |
| 391 | - | |
| 392 | -function renderDocumentVersions ($oDocument) { | |
| 393 | - $aVersions = Document::getByLiveDocument($oDocument); | |
| 394 | - $sToRender = "<table class=\"pretty\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"; | |
| 395 | - $sToRender .= "<thead><tr><th>Metadata Version</th><th>Modified date</th><th>Document Version</th></tr></thead>\n"; | |
| 396 | - $sToRender .= "<tbody>\n"; | |
| 397 | - $iDocumentID = $oDocument->getID(); | |
| 398 | - $sLink = generateControllerLink('viewDocument', "fDocumentID=$iDocumentID"); | |
| 399 | - $sDocumentLink = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID"); | |
| 400 | - $sToRender .= sprintf('<tr><td><a href="%s">%s</a> (Live)</td><td>%s</td><td><a href="%s">%s</a></tr>%s', $sLink, $oDocument->getMetadataVersion(), $oDocument->getLastModifiedDate(), $sDocumentLink, $oDocument->getVersion(), "\n"); | |
| 401 | - foreach ($aVersions as $oVersion) { | |
| 402 | - $iDocumentVersionID = $oVersion->getVersion(); | |
| 403 | - if ($iDocumentVersionID == $oDocument->getVersion()) { | |
| 404 | - $sDocumentLink = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID"); | |
| 405 | - } else { | |
| 406 | - $sDocumentLink = generateControllerLink("downloadDocument", "fDocumentID=$iDocumentID&fVersion=$iDocumentVersionID"); | |
| 407 | - } | |
| 408 | - $sToRender .= "<tr>\n"; | |
| 409 | - $iVersionID = $oVersion->getID(); | |
| 410 | - $sLink = generateControllerLink('viewDocument', "fDocumentID=$iDocumentID&fVersionID=$iVersionID"); | |
| 411 | - $sToRender .= sprintf('<td><a href="%s">%s</a></td>%s', $sLink, $oVersion->getMetadataVersion(), "\n"); | |
| 412 | - $sToRender .= sprintf('<td>%s</td>%s', $oVersion->getLastModifiedDate(), "\n"); | |
| 413 | - $sToRender .= sprintf('<td><a href="%s">%s</td>%s', $sDocumentLink, $oVersion->getVersion(), "\n"); | |
| 414 | - $sToRender .= "</tr>\n"; | |
| 415 | - } | |
| 416 | - $sToRender .= "</tbody>\n"; | |
| 417 | - $sToRender .= "</table>\n"; | |
| 418 | - return $sToRender; | |
| 419 | -} | |
| 420 | - | |
| 421 | -// This array exists only to give gettext a hint that these buttons | |
| 422 | -// should be added to the .po file. | |
| 423 | - | |
| 424 | -$aTranslatedButtons = array( | |
| 425 | - _("View"), | |
| 426 | - _("Email"), | |
| 427 | - _("Checkout"), | |
| 428 | - _("Delete"), | |
| 429 | - _("History"), | |
| 430 | - _("Move"), | |
| 431 | - _("Subscribe"), | |
| 432 | - _("Unsubscribe"), | |
| 433 | - _("Discussion"), | |
| 434 | - _("Archive"), | |
| 435 | - _("Link New Doc"), | |
| 436 | - _("Publish"), | |
| 437 | -); | |
| 438 | - | |
| 439 | - | |
| 440 | -$aImageNameToLabel = array( | |
| 441 | - "dependentdoc" => "Link new doc", | |
| 442 | -); | |
| 443 | - | |
| 444 | -function displayButton($sAction, $sQueryString, $sImageName, $sDisabledText = "", $sJS = "") { | |
| 445 | - global $default; | |
| 446 | - global $aImageNameToLabel; | |
| 447 | - // the active is active if there is no disabled text | |
| 448 | - $bActive = !strlen($sDisabledText) > 0; | |
| 449 | - if ($default->useTextButtons === false) { | |
| 450 | - $sImage = "<img border=\"0\" src=\"$default->graphicsUrl/widgets/docactions/"; | |
| 451 | - if ($bActive) { | |
| 452 | - $sImage .= "$sImageName.gif\""; | |
| 453 | - } else { | |
| 454 | - $sImage .= "disabled-$sImageName.gif\" title=\"$sDisabledText\""; | |
| 455 | - } | |
| 456 | - $sImage .= "/>"; | |
| 457 | - } else { | |
| 458 | - if (array_key_exists($sImageName, $aImageNameToLabel)) { | |
| 459 | - $sLabel = $aImageNameToLabel[$sImageName]; | |
| 460 | - } else { | |
| 461 | - $sLabel = $sImageName; | |
| 462 | - } | |
| 463 | - $sTranslatedWords = _(ucwords($sLabel)); | |
| 464 | - $sLabel = strtoupper($sTranslatedWords); | |
| 465 | - if ($bActive) { | |
| 466 | - $sClass = "button"; | |
| 467 | - $sJS = $sJS . " onMouseOver=\"javascript:this.style.backgroundColor='#EEEEEE';\" onMouseOut=\"javascript:this.style.backgroundColor='#FFFFFF';\""; | |
| 468 | - } else { | |
| 469 | - $sClass = "disabledbutton"; | |
| 470 | - } | |
| 471 | - $sImage = "<span class=\"$sClass\" $sJS>$sLabel</span>"; | |
| 472 | - } | |
| 473 | - if ($bActive) { | |
| 474 | - return generateControllerLink($sAction, $sQueryString, $sImage); | |
| 475 | - } else { | |
| 476 | - return $sImage; | |
| 477 | - } | |
| 478 | -} | |
| 479 | - | |
| 480 | -/** | |
| 481 | - * Displays document action buttons | |
| 482 | - */ | |
| 483 | - | |
| 484 | -function displayActionButtons($oDocument, $bEdit) { | |
| 485 | - require_once(KT_LIB_DIR . '/actions/documentaction.inc.php'); | |
| 486 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 487 | - $oTemplate = $oTemplating->loadTemplate('ktcore/document_action'); | |
| 488 | - | |
| 489 | - $sToRender = ""; | |
| 490 | - | |
| 491 | - // XXX: Anonymous/Guest interaction | |
| 492 | - $oUser =& User::get($_SESSION["userID"]); | |
| 493 | - | |
| 494 | - foreach (KTDocumentActionUtil::getDocumentActionsForDocument($oDocument, $oUser) as $oAction) { | |
| 495 | - $aInfo = $oAction->getInfo(); | |
| 496 | - if (is_null($aInfo)) { | |
| 497 | - continue; | |
| 498 | - } | |
| 499 | - $sToRender .= $oTemplate->render($aInfo); | |
| 500 | - } | |
| 501 | - | |
| 502 | - return $sToRender; | |
| 503 | -} | |
| 504 | - | |
| 505 | -function renderSectionDiv($sDivName, $sHtml) { | |
| 506 | - global $default; | |
| 507 | - return "<div id=\"$sDivName\" style=\"visibility:hidden;position:absolute;top:5px;left:5px;\">$sHtml</div>"; | |
| 508 | -} | |
| 509 | - | |
| 510 | -function renderDocumentSection($sSectionName, $sHeadingText, $bDisplayLink, $iDocumentID) { | |
| 511 | - if ($bDisplayLink) { | |
| 512 | - $sLink = generateControllerLink("viewDocument", "fDocumentID=$iDocumentID&fShowSection=$sSectionName", $sHeadingText); | |
| 513 | - } else { | |
| 514 | - $sLink = "<a href=\"#\" onClick=\"switchDiv('$sSectionName', 'document');\">$sHeadingText</a>"; | |
| 515 | - } | |
| 516 | - return '<span style="display:block; background-color:' . getColour($iColour) . '">' . $sLink . '</span>' . "\n"; | |
| 517 | -} | |
| 518 | - | |
| 519 | -function getPage($oDocument, $bEdit, $sStatusMessage = "") { | |
| 520 | - global $default; | |
| 521 | - | |
| 522 | - $sToRender .= renderHeading(_("Document Detail")); | |
| 523 | - $sToRender .= renderDocumentPath($oDocument, true) . "\n\n"; | |
| 524 | - $sToRender .= "<table cellspacing=\"0\" cellpadding=\"0\" id=\"headingTable\">"; | |
| 525 | - $sToRender .= "<tr><td valign=\"top\">"; | |
| 526 | - $sToRender .= "<table border=\"0\" width=\"530\">"; | |
| 527 | - $sToRender .= "<tr><td>"; | |
| 528 | - | |
| 529 | - // if we have a status message, then make the section links refresh to viewDocument with the fShowSection variable | |
| 530 | - // ie. effectively removes statusMessage on next click | |
| 531 | - $bDisplayLink = ($sStatusMessage) ? true : false; | |
| 532 | - | |
| 533 | - $sToRender .= renderDocumentSection("documentData", _("Document Data"), $bDisplayLink, $oDocument->getID()); | |
| 534 | - $sToRender .= renderDocumentSection("genericMetaData", _("Generic Meta Data"), $bDisplayLink, $oDocument->getID()); | |
| 535 | - $sToRender .= renderDocumentSection("typeSpecificMetaData", _("Type Specific Meta Data"), $bDisplayLink, $oDocument->getID()); | |
| 536 | - $sToRender .= renderDocumentSection("archiveSettings", _("Archive Settings"), $bDisplayLink, $oDocument->getID()); | |
| 537 | - $sToRender .= renderDocumentSection("linkedDocuments", _("Linked Documents"), $bDisplayLink, $oDocument->getID()); | |
| 538 | - $sToRender .= renderDocumentSection("metadataVersions", _("Metadata Versions"), $bDisplayLink, $oDocument->getID()); | |
| 539 | - | |
| 540 | - $sToRender .= "</td></tr>"; | |
| 541 | - $sToRender .= "</table>"; | |
| 542 | - $sToRender .= '</td><td rowspan="2" valign="top">'; | |
| 543 | - $sToRender .= "<table cellspacing=\"0\" cellpadding=\"0\">\n"; | |
| 544 | - $sToRender .= displayActionButtons($oDocument, $bEdit); | |
| 545 | - $sToRender .= "</table>\n"; | |
| 546 | - $sToRender .= "</td></tr>"; | |
| 547 | - | |
| 548 | - $sToRender .= "<tr><td>"; | |
| 549 | - | |
| 550 | - $sToRender .= '<div style="position:relative;">'; | |
| 551 | - $sToRender .= renderSectionDiv("documentData", renderDocumentData($oDocument, $bEdit, $sStatusMessage)); | |
| 552 | - $sToRender .= renderSectionDiv("genericMetaData", renderGenericMetaData($oDocument, $bEdit)); | |
| 553 | - $sToRender .= renderSectionDiv("typeSpecificMetaData", renderTypeSpecificMetaData($oDocument, $bEdit)); | |
| 554 | - $sToRender .= renderSectionDiv("archiveSettings", renderDocumentArchiveSettings($oDocument, $bEdit)); | |
| 555 | - if ($bEdit) { | |
| 556 | - $sToRender .= renderSectionDiv("linkedDocuments", renderEditableLinkedDocuments($oDocument) . renderDependantDocuments($oDocument, $bEdit)); | |
| 557 | - } else { | |
| 558 | - $sToRender .= renderSectionDiv("linkedDocuments", renderNonEditableLinkedDocuments($oDocument, $bEdit) . renderDependantDocuments($oDocument, $bEdit)); | |
| 559 | - } | |
| 560 | - $sToRender .= renderSectionDiv("metadataVersions", renderDocumentVersions($oDocument)); | |
| 561 | - | |
| 562 | - $sToRender .= "<br />"; | |
| 563 | - $sToRender .= "<br />"; | |
| 564 | - $sToRender .= "<br />"; | |
| 565 | - $sToRender .= "<br />"; | |
| 566 | - $sToRender .= "<br />"; | |
| 567 | - $sToRender .= "<br />"; | |
| 568 | - $sToRender .= "<br />"; | |
| 569 | - $sToRender .= "<br />"; | |
| 570 | - $sToRender .= "<br />"; | |
| 571 | - $sToRender .= "<br />"; | |
| 572 | - $sToRender .= "<br />"; | |
| 573 | - $sToRender .= "<br />"; | |
| 574 | - $sToRender .= "<br />"; | |
| 575 | - $sToRender .= "<br />"; | |
| 576 | - $sToRender .= "</div>"; | |
| 577 | - $sToRender .= "</td></tr>"; | |
| 578 | - $sToRender .= "</table>"; | |
| 579 | - return $sToRender; | |
| 580 | -} | |
| 581 | - | |
| 582 | -function getStatusPage($oDocument, $sStatusMessage) { | |
| 583 | - global $default; | |
| 584 | - | |
| 585 | - $sToRender = "<div id=\"headings\" style=\"position:relative;visibility:visible;top:2px;left:2px;\">"; | |
| 586 | - $sToRender .= renderHeading(_("Document Detail")); | |
| 587 | - $sToRender .= renderDocumentPath($oDocument, false) . "\n\n"; | |
| 588 | - $sToRender .= "<table border=\"0\" width=\"610\">"; | |
| 589 | - | |
| 590 | - // if we have a status message, then make the section links refresh to viewDocument with the fShowSection variable | |
| 591 | - // ie. effectively removes statusMessage on next click | |
| 592 | - $bDisplayLink = ($sStatusMessage) ? true : false; | |
| 593 | - | |
| 594 | - $sToRender .= renderDocumentSection("documentData", _("Document Data"), $bDisplayLink, $oDocument->getID()); | |
| 595 | - $sToRender .= renderDocumentSection("genericMetaData", _("Generic Meta Data"), $bDisplayLink, $oDocument->getID()); | |
| 596 | - $sToRender .= renderDocumentSection("typeSpecificMetaData", _("Type Specific Meta Data"), $bDisplayLink, $oDocument->getID()); | |
| 597 | - $sToRender .= renderDocumentSection("archiveSettings", _("Archive Settings"), $bDisplayLink, $oDocument->getID()); | |
| 598 | - $sToRender .= renderDocumentSection("linkedDocuments", _("Linked Documents"), $bDisplayLink, $oDocument->getID()); | |
| 599 | - $sToRender .= renderDocumentSection("metadataVersions", _("Document Versions"), $bDisplayLink, $oDocument->getID()); | |
| 600 | - $sToRender .= "</table>"; | |
| 601 | - $sToRender .= "</div>"; | |
| 602 | - $sToRender .= renderDocumentData($oDocument, false, $sStatusMessage); | |
| 603 | - return $sToRender; | |
| 604 | -} | |
| 605 | - | |
| 606 | -function getWebPublishPage($oDocument) { | |
| 607 | - global $default; | |
| 608 | - | |
| 609 | - $oPatternListBox = & new PatternListBox($default->web_sites_table, "web_site_name", "id", "fWebSiteID"); | |
| 610 | - | |
| 611 | - $sToRender .= renderHeading(_("Document Detail")); | |
| 612 | - $sToRender .= renderDocumentPath($oDocument, false) . "\n\n"; | |
| 613 | - | |
| 614 | - $sToRender .= "<table>\n"; | |
| 615 | - $sToRender .= "\t<tr>"; | |
| 616 | - $sToRender .= "\t\t<th align=\"left\">" . _("Choose the website to publish to:") . "</th>\n"; | |
| 617 | - $sToRender .= "\t</tr>"; | |
| 618 | - $sToRender .= "\t<tr>\n"; | |
| 619 | - $sToRender .= "\t\t<td>" . $oPatternListBox->render() . "</td>\n"; | |
| 620 | - $sToRender .= "\t</tr>"; | |
| 621 | - $sToRender .= "\t<tr>\n"; | |
| 622 | - $sToRender .= "\t\t<th nowrap align=\"left\">" . _("Enter a comment for the web master:") . "</th>\n"; | |
| 623 | - $sToRender .= "\t</tr>"; | |
| 624 | - $sToRender .= "\t<tr>\n"; | |
| 625 | - $sToRender .= "\t\t<td><input type=\"text\" name=\"fComment\" size=\"30\"/></td>\n"; | |
| 626 | - $sToRender .= "\t</tr>"; | |
| 627 | - $sToRender .= "\t\t<input type=\"hidden\" name=\"fForPublish\" value=\"1\"/>\n"; | |
| 628 | - $sToRender .= "\t\t<input type=\"hidden\" name=\"fSubmit\" value=\"1\"/>\n"; | |
| 629 | - $sToRender .= "\t<tr>\n"; | |
| 630 | - $sToRender .= "\t\t<td><input type=\"image\" src=\"" . KTHtml::getPublishButton() . "\" border=\"0\"/></a>"; | |
| 631 | - $sToRender .= "\t\t<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\" /></a></td>\n"; | |
| 632 | - $sToRender .= "\t</tr>"; | |
| 633 | - $sToRender .= "</table>\n"; | |
| 634 | - | |
| 635 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 636 | - $sToRender .= "function validateForm(theForm) {\n"; | |
| 637 | - $sToRender .= "\tif (!(validRequired(document.MainForm.fWebSiteID,'Website'))) {\n"; | |
| 638 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 639 | - $sToRender .= "\tif (!(validRequired(document.MainForm.fComment,'Publish comment'))) {\n"; | |
| 640 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 641 | - $sToRender .= "return true;\n}\n"; | |
| 642 | - $sToRender .= "//-->\n</script>\n\n"; | |
| 643 | - | |
| 644 | - $sToRender .= renderDocumentData($oDocument, $bEdit); | |
| 645 | - | |
| 646 | - return $sToRender; | |
| 647 | -} | |
| 648 | - | |
| 649 | -function wrapInTable($sHtml) { | |
| 650 | - return "\n\t\t\t<table border = 1, width = 100%><tr><td>$sHtml</td></tr></table>\n"; | |
| 651 | -} | |
| 652 | -?> |