Commit d6e502fdefb5ac6fc8e06e6fc3aa89c5afe78ad2

Authored by Michael Joseph
1 parent 8ff68661

adding new document details view prototypes


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2138 c91229c3-7414-0410-bfa2-8a42b809f60b
tests/documentmanagement/viewBL.php 0 → 100644
  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 + * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  19 + * @date 21 January 2003
  20 + * @package presentation.lookAndFeel.knowledgeTree.documentManager
  21 + */
  22 +
  23 +require_once("../../config/dmsDefaults.php");
  24 +
  25 +require_once("$default->fileSystemRoot/lib/security/permission.inc");
  26 +
  27 +require_once("$default->fileSystemRoot/lib/email/Email.inc");
  28 +
  29 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  30 +
  31 +require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc");
  32 +require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentTransaction.inc");
  33 +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  34 +require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentInstance.inc");
  35 +require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentCollaboration.inc");
  36 +
  37 +require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiving.inc");
  38 +
  39 +require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
  40 +require_once("$default->fileSystemRoot/lib/foldermanagement/FolderUserRole.inc");
  41 +require_once("$default->fileSystemRoot/lib/roles/Role.inc");
  42 +require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  43 +
  44 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
  45 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  46 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  47 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
  48 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  49 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  50 +
  51 +require_once("$default->fileSystemRoot/lib/web/WebDocument.inc");
  52 +
  53 +require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc");
  54 +
  55 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/documentmanagement/documentUI.inc");
  56 +require_once("viewUI.inc");
  57 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
  58 +require_once("$default->fileSystemRoot/presentation/Html.inc");
  59 +
  60 +if (checkSession()) {
  61 + if (isset($fDocumentID)) {
  62 + if (isset($fCollaborationEdit) && Permission::userHasDocumentWritePermission($fDocumentID)) {
  63 + //return value from collaborationBL.php. User attempted to edt
  64 + //a step in the document collaboration process that is currently being
  65 + //executed
  66 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  67 +
  68 + $oDocument = & Document::get($fDocumentID);
  69 + $oPatternCustom = & new PatternCustom();
  70 + $oPatternCustom->setHtml(getEditPage($oDocument));
  71 + $main->setCentralPayload($oPatternCustom);
  72 + $main->setErrorMessage("You cannot edit a document collaboration step that is completed or currently underway");
  73 + $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID());
  74 + $main->render();
  75 + } else if (isset($fForInlineView) && Permission::userHasDocumentReadPermission($fDocumentID)) {
  76 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Inline view", VIEW);
  77 + $oDocumentTransaction->create();
  78 + PhysicalDocumentManager::inlineViewPhysicalDocument($fDocumentID);
  79 + } else if (isset($fForDownload) && Permission::userHasDocumentReadPermission($fDocumentID)) {
  80 + //if the user has document read permission, perform the download
  81 + if (isset($fVersion)) {
  82 + // we're downloading an old version of the document
  83 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document version $fVersion downloaded", DOWNLOAD);
  84 + $oDocumentTransaction->create();
  85 + PhysicalDocumentManager::downloadVersionedPhysicalDocument($fDocumentID, $fVersion);
  86 + } else {
  87 + // download the current version
  88 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document downloaded", DOWNLOAD);
  89 + $oDocumentTransaction->create();
  90 + PhysicalDocumentManager::downloadPhysicalDocument($fDocumentID);
  91 + }
  92 + } else if (isset($fBeginCollaboration) && Permission::userHasDocumentWritePermission($fDocumentID)) {
  93 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  94 + //begin the collaboration process
  95 + //first ensure that all steps in the collaboration process are assigned
  96 + $oDocument = Document::get($fDocumentID);
  97 + $aFolderCollaboration = FolderCollaboration::getList("WHERE folder_id = " . $oDocument->getFolderID());
  98 + if (count($aFolderCollaboration) > 0) {
  99 + //if the the folder has collaboration steps set up
  100 + $aFolderUserRoles = FolderUserRole::getList("document_id = " . $fDocumentID);
  101 + if (count($aFolderCollaboration) == count($aFolderUserRoles)) {
  102 + //if all the roles have been assigned we can start the collaboration process
  103 +
  104 + //TODO: check if this collaboration has already occured, and then reset all the steps before beginning it again
  105 + //DocumentCollaboration::resetDocumentCollaborationSteps($fDocumentID);
  106 +
  107 + $oDocument->beginCollaborationProcess();
  108 + $oPatternCustom = & new PatternCustom();
  109 + $oPatternCustom->setHtml(getEditPage($oDocument));
  110 + $main->setCentralPayload($oPatternCustom);
  111 + $main->setErrorMessage("Document collaboration successfully started");
  112 + $main->render();
  113 + } else {
  114 + //not all the roles have users assigned to them, so display an error message
  115 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  116 + $oPatternCustom = & new PatternCustom();
  117 + $oPatternCustom->setHtml(getEditPage($oDocument));
  118 + $main->setCentralPayload($oPatternCustom);
  119 + $main->setErrorMessage("Document collaboration not started. Not all steps in the process have been assigned");
  120 + $main->render();
  121 + }
  122 + } else {
  123 + //the folder has no collaboration set up yet, so we can't start document collaboration
  124 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  125 + $oPatternCustom = & new PatternCustom();
  126 + $oPatternCustom->setHtml(getEditPage($oDocument));
  127 + $main->setCentralPayload($oPatternCustom);
  128 + $main->setErrorMessage("The collaboration steps for the folder must be set up before collaboration can begin");
  129 + $main->render();
  130 + }
  131 + } else if ((isset($fCollaborationStepComplete)) && (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($fDocumentID))) {
  132 + //the user has signled that they have completed their step in the collaboration process
  133 + if (DocumentCollaboration::isLastStepInCollaborationProcess($fDocumentID)) {
  134 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  135 + //the last step in the collaboration process has been performed- email the document creator
  136 +
  137 + $oDocument = Document::get($fDocumentID);
  138 + $oDocument->endCollaborationProcess();
  139 +
  140 + // on the last collaboration step- trigger a major revision
  141 + // major version number rollover
  142 + $oDocument->setMajorVersionNumber($oDocument->getMajorVersionNumber()+1);
  143 + // reset minor version number
  144 + $oDocument->setMinorVersionNumber(0);
  145 + $oDocument->update();
  146 + // TODO: create a transaction?
  147 +
  148 + $oUser = User::get($oDocument->getCreatorID());
  149 + $sBody = $oUser->getName() . ", the collaboration process for the document, '" . generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=" . $oDocument->getID(), $oDocument->getName()) . "', has been completed. ";
  150 + $oEmail = & new Email();
  151 + $oEmail->send($oUser->getEmail(), "Document collaboration complete", $sBody);
  152 +
  153 + //possibly set the document up for web publishing????
  154 + $oPatternCustom = & new PatternCustom();
  155 + $oPatternCustom->setHtml(getEditPage($oDocument));
  156 + $main->setCentralPayload($oPatternCustom);
  157 + $main->setErrorMessage("Document collaboration complete. The document initiator has been notified");
  158 + $main->render();
  159 +
  160 + } else {
  161 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  162 + //start the next steps if all criteria are met
  163 + DocumentCollaboration::beginNextStepInCollaborationProcess($fDocumentID, $_SESSION["userID"]);
  164 + $oDocument = Document::get($fDocumentID);
  165 + $oPatternCustom = & new PatternCustom();
  166 + $oPatternCustom->setHtml(getEditPage($oDocument));
  167 + $main->setCentralPayload($oPatternCustom);
  168 + $main->setErrorMessage("The next steps in the collaboration process have been started");
  169 + $main->render();
  170 + }
  171 + } else if ((isset($fForPublish)) && (!DocumentCollaboration::documentIsPendingWebPublishing($fDocumentID))) {
  172 + if (isset($fWebSiteID)) {
  173 + // user wishes to publish document
  174 + $oDocument = Document::get($fDocumentID);
  175 + $aWebDocument = WebDocument::getList("document_id = $fDocumentID");
  176 + $oWebDocument = $aWebDocument[0];
  177 + $oWebDocument->setStatusID(PENDING);
  178 + $oWebDocument->setWebSiteID($fWebSiteID);
  179 + if ($oWebDocument->update()) {
  180 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  181 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE);
  182 + $oDocumentTransaction->create();
  183 + $oDocument = Document::get($fDocumentID);
  184 + DocumentCollaboration::notifyWebMaster($fDocumentID, $fComment);
  185 + $oPatternCustom = & new PatternCustom();
  186 + $oPatternCustom->setHtml(getEditPage($oDocument));
  187 + $main->setCentralPayload($oPatternCustom);
  188 + $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified");
  189 + $main->render();
  190 +
  191 + } else {
  192 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  193 + $oDocument = Document::get($fDocumentID);
  194 + $oPatternCustom = & new PatternCustom();
  195 + $oPatternCustom->setHtml(getEditPage($oDocument));
  196 + $main->setCentralPayload($oPatternCustom);
  197 + $main->setErrorMessage("An error occured while attempting to update the document for publishing");
  198 + $main->render();
  199 + }
  200 + } else {
  201 + // prompt for the website to publish to
  202 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  203 + $oDocument = Document::get($fDocumentID);
  204 + $oPatternCustom = & new PatternCustom();
  205 + $oPatternCustom->setHtml(getWebPublishPage($oDocument));
  206 + $main->setCentralPayload($oPatternCustom);
  207 + $main->setFormAction($_SERVER['PHP_SELF']);
  208 + $main->setHasRequiredFields(true);
  209 + $main->render();
  210 + }
  211 +
  212 + } else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) {
  213 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  214 + require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc");
  215 +
  216 + $oDocument = & Document::get($fDocumentID);
  217 +
  218 + // check subscription flag
  219 + if (isset($fFireSubscription)) {
  220 + // fire subscription alerts for the modified document
  221 + $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ModifyDocument"),
  222 + SubscriptionConstants::subscriptionType("DocumentSubscription"),
  223 + array( "folderID" => $oDocument->getFolderID(),
  224 + "modifiedDocumentName" => $oDocument->getName()));
  225 + $default->log->info("viewBL.php fired $count subscription alerts for modified document $fFolderName");
  226 + }
  227 +
  228 + $oPatternCustom = & new PatternCustom();
  229 + if ($oDocument->isLive()) {
  230 + if (Permission::userHasDocumentWritePermission($fDocumentID)) {
  231 + $oPatternCustom->setHtml(getEditPage($oDocument));
  232 + } else if (Permission::userHasDocumentReadPermission($fDocumentID)) {
  233 + $oPatternCustom->setHtml(getViewPage($oDocument));
  234 + }
  235 + } else if ($oDocument->isArchived()) {
  236 + // cancel
  237 + $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
  238 + $main->setErrorMessage("This document has been archived.");
  239 + }
  240 + $main->setCentralPayload($oPatternCustom);
  241 + //$main->setOnLoadJavaScript("switchDiv('documentData')");
  242 + $main->setFormAction("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID());
  243 + $main->render();
  244 + } else {
  245 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  246 +
  247 + $oPatternCustom = & new PatternCustom();
  248 + $oPatternCustom->setHtml("<a href=\"" . generateControllerLink("browse", "fFolderID=" . $oDocument->getFolderID()) . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a>\n");
  249 + $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.");
  250 + $main->setCentralPayload($oPatternCustom);
  251 + $main->render();
  252 + }
  253 + } else {
  254 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  255 +
  256 + $oPatternCustom = & new PatternCustom();
  257 + $oPatternCustom->setHtml("");
  258 + $main->setErrorMessage("You have not chosen a document to view");
  259 + $main->setCentralPayload($oPatternCustom);
  260 + $main->render();
  261 + }
  262 +}
  263 +
  264 +?>
  265 +
  266 +
... ...
tests/documentmanagement/viewUI.inc 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id$
  4 + *
  5 + * Contains HTML information required to build the document view page.
  6 + * Will be used by documentViewBL.php
  7 + *
  8 + * Variables expected:
  9 + * o $fDocumentID Primary key of document to view
  10 + *
  11 + *
  12 + * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
  13 + * @date 21 January 2003
  14 + * @package presentation.lookAndFeel.knowledgeTree.documentManager
  15 + */
  16 +
  17 +function renderDocumentPath($oDocument) {
  18 + global $default;
  19 + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
  20 + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
  21 + $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > ";
  22 + $sDocumentPath .= "<a href=\"$default->rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $oDocument->getID() . "&fForInlineView=1\">" . $oDocument->getName() . "</a>";
  23 + return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n";
  24 +}
  25 +
  26 +function renderDocumentData($oDocument, $bEditable) {
  27 + global $default;
  28 + $sQuery = "SELECT D.name, D.modified, DTT.datetime AS created, U.name AS initiator, CONCAT(CONCAT(D.major_version, '.'), D.minor_version) AS version, WDSL.name AS status, DTL.name AS document_type, D.is_checked_out, COALESCE(U2.name, '') AS c_user " .
  29 + "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_web_documents_table AS WD ON WD.document_id = D.ID " .
  30 + "INNER JOIN $default->owl_web_documents_status_table AS WDSL ON WD.status_id = WDSL.id " .
  31 + "INNER JOIN $default->owl_users_table AS U ON U.id = D.creator_id " .
  32 + "INNER JOIN $default->owl_document_transactions_table AS DTT ON DTT.document_id = D.id " .
  33 + "INNER JOIN $default->owl_transaction_types_table AS TT ON DTT.transaction_id = TT.id " .
  34 + "INNER JOIN $default->owl_document_types_table AS DTL ON DTL.id = D.document_type_id " .
  35 + "LEFT OUTER JOIN $default->owl_users_table AS U2 ON U2.id = D.checked_out_user_id " .
  36 + "WHERE D.id = " . $oDocument->getID() . " " .
  37 + "AND TT.name LIKE 'Create'";
  38 +
  39 + $aColumns = array("name", "modified", "created", "initiator", "document_type", "version", "status", "c_user");
  40 + $aColumnNames = array("Document title", "Last updated", "Created", "Document initiator", "Document Type", "Version", "Status", "Checked out by");
  41 + $aColumnTypes = array(1,1,1,1,1,1,1,1);
  42 + $oPatternListFromQuery = & new PatternListFromQuery($sQuery, $aColumns, $aColumnNames, $aColumnTypes);
  43 + $oPatternListFromQuery->setTableHeading("Document Data");
  44 + $oPatternListFromQuery->setTableWidth("100%");
  45 +
  46 + $sToRender = "<div id=\"documentData\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">";
  47 + $sToRender .= "\t<table border=\"0\" width=\"100%\">\n";
  48 + $sToRender .= "\t<tr>\n";
  49 + $sToRender .= "\t\t<td>" . $oPatternListFromQuery->render() . "</td>\n";
  50 + $sToRender .= "\t</tr>\n";
  51 + if ($bEditable) {
  52 + $sToRender .= "\t<tr>\n";
  53 + $sToRender .= "<td colspan=\"2\"><a href=\"$default->rootUrl/control.php?action=modifyDocument&fDocumentID=$iDocumentID\"><image src=\"$default->graphicsUrl/widgets/edit.gif\" border=\"0\"></a></td>\n";
  54 + $sToRender .= "\t</tr>\n";
  55 + }
  56 + $sToRender .= "\t</table>\n";
  57 + $sToRender .= "</div>";
  58 + return $sToRender;
  59 +}
  60 +
  61 +function renderEditableLinkedDocuments($oDocument) {
  62 + global $default;
  63 +
  64 + $sQuery = "SELECT D.id AS child_document_id, D.name, DL.id as document_link_id, DL.parent_document_id AS parent_document_id, 'Unlink' AS unlink " .
  65 + "FROM documents AS D INNER JOIN document_link AS DL ON D.id = DL.child_document_id " .
  66 + "WHERE DL.parent_document_id = " . $oDocument->getID();
  67 +
  68 + $aColumns = array("name", "unlink");
  69 + $aColumnHeaders = array("Document");
  70 + $aColumnTypes = array(3,3);
  71 + $aDBColumnArray = array("parent_document_id", "child_document_id","document_link_id");
  72 + $aQueryStringVariableNames = array("fParentDocumentID","fChildDocumentID", "fDocumentLinkID");
  73 + $aLinkURLs = array(0=>"$default->rootUrl/control.php?action=viewDocument", 1=>"$default->rootUrl/control.php?action=removeDocumentLink");
  74 +
  75 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%", $aLinkURLs,$aDBColumnArray,$aQueryStringVariableNames);
  76 + $oPatternTableSqlQuery->setTableHeading("Linked documents");
  77 + $oPatternTableSqlQuery->setDisplayColumnHeadings(true);
  78 +
  79 + $sToRender .= "<div id=\"linkedDocuments\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">";
  80 + $sToRender .= "\t<table border=\"0\" width=\"100%\">\n";
  81 + $sToRender .= "\t<tr>\n";
  82 + $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n";
  83 + $sToRender .= "\t</tr>";
  84 + $sToRender .= "\t<tr>\n";
  85 + $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=addDocumentLink&fDocumentID=" . $oDocument->getID() ."\"><img src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/></a></td>\n";
  86 + $sToRender .= "\t</tr>";
  87 + $sToRender .= "\t</table>\n";
  88 + $sToRender .= "</div>";
  89 + return $sToRender;
  90 +}
  91 +
  92 +function renderNonEditableLinkedDocuments($oDocument) {
  93 + global $default;
  94 +
  95 + $sQuery = "SELECT D.id, D.name, 'Delete' AS del " .
  96 + "FROM documents AS D INNER JOIN document_link AS DL ON D.id = DL.child_document_id " .
  97 + "WHERE DL.parent_document_id = " . $oDocument->getID();
  98 +
  99 + $aColumns = array("name","del");
  100 + $aColumnNames = array("Document");
  101 + $aColumnTypes = array(1,3);
  102 +
  103 + $oPatternListFromQuery = & new PatternListFromQuery($sQuery, $aColumns, $aColumnNames, $aColumnTypes);
  104 + $oPatternListFromQuery->setTableHeading("Linked documents");
  105 + $oPatternListFromQuery->setTableWidth("100%");
  106 + return $oPatternListFromQuery->render();
  107 +}
  108 +
  109 +
  110 +function renderGenericMetaData($oDocument) {
  111 + global $default;
  112 + $sQuery = "SELECT DF.name AS name, DFL.value as value " .
  113 + "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_document_fields_table AS DFL ON D.id = DFL.document_id " .
  114 + "INNER JOIN $default->owl_fields_table AS DF ON DF.id = DFL.document_field_id " .
  115 + "WHERE document_id = " . $oDocument->getID() . " " .
  116 + "AND DF.is_generic = 1";
  117 + $aColumns = array("name", "value");
  118 + $aColumnHeaders = array("Tag", "Value");
  119 + $aColumnTypes = array(1,1);
  120 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%");
  121 + $oPatternTableSqlQuery->setTableHeading("Generic Meta Data");
  122 +
  123 + $sToRender .= "<div id=\"genericMetaData\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">";
  124 + $sToRender .= "\t<table border=\"0\" width=\"100%\">\n";
  125 + $sToRender .= "\t<tr>\n";
  126 + $sToRender .= "\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n";
  127 + $sToRender .= "\t</tr>\n";
  128 + $sToRender .= "\t<tr>\n";
  129 + $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=modifyDocumentGenericMetaData&fDocumentID=$iDocumentID\"><image src=\"$default->graphicsUrl/widgets/edit.gif\" border=\"0\"></a></td>\n";
  130 + $sToRender .= "\t</tr>\n";
  131 + $sToRender .= "\t</table>\n";
  132 + $sToRender .= "</div>";
  133 + return $sToRender;
  134 +}
  135 +
  136 +function renderTypeSpecificMetaData($oDocument) {
  137 + global $default;
  138 +
  139 + $sQuery = "SELECT DF.name AS name, DFL.value AS value " .
  140 + "FROM documents AS D INNER JOIN document_fields_link AS DFL ON D.id = DFL.document_id " .
  141 + "INNER JOIN document_fields AS DF ON DF.ID = DFL.document_field_id " .
  142 + "WHERE D.id = " . $oDocument->getID() . " " .
  143 + "AND DF.name NOT LIKE 'Author' " .
  144 + "AND DF.name NOT LIKE 'Category' " .
  145 + "AND DF.is_generic = 0";
  146 + $aColumns = array("name", "value");
  147 + $aColumnHeaders = array("Tag", "Value");
  148 + $aColumnTypes = array(1,1);
  149 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%");
  150 + $oPatternTableSqlQuery->setTableHeading("Type Specific Meta Data");
  151 + $oPatternTableSqlQuery->setEmptyTableMessage("No Type Specific Meta Data");
  152 +
  153 + $sToRender .= "<div id=\"typeSpecificMetaData\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">";
  154 + $sToRender .= "\t<table border=\"0\" width=\"100%\">\n";
  155 + $sToRender .= "\t<tr>\n";
  156 + $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n";
  157 + $sToRender .= "\t</tr>\n";
  158 + $sToRender .= "\t<tr>\n";
  159 + $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=modifyDocumentTypeMetaData&fDocumentID=$iDocumentID\"><image src=\"$default->graphicsUrl/widgets/edit.gif\" border=\"0\"></a></td>\n";
  160 + $sToRender .= "\t</tr>\n";
  161 + $sToRender .= "\t</table>\n";
  162 + $sToRender .= "</div>";
  163 + return $sToRender;
  164 +}
  165 +
  166 +function renderEditableDocumentRouting($oDocument) {
  167 + global $default;
  168 + $sQuery = "SELECT D.id as document_id, GFAL.id as id, R.name AS role_name, COALESCE(U.Name, 'Not assigned') AS name, GFAL.precedence AS precedence, COALESCE(FURL.active,0) AS active, COALESCE(FURL.done, 0) AS done, 'Edit' as edit " .
  169 + "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " .
  170 + "INNER JOIN roles AS R ON GFAL.role_id = R.id " .
  171 + "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id AND FURL.document_id = D.id " .
  172 + "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " .
  173 + "WHERE D.id = " . $oDocument->getID() . " " .
  174 + "ORDER BY GFAL.precedence, role_name ASC";
  175 + $aColumns = array("role_name", "name", "precedence", "active", "done", "edit");
  176 + $aColumnHeaders = array("Role", "User", "Seq", "Active", "Done", "");
  177 + $aColumnTypes = array(1,1,1,1,1,3);
  178 + $aDBColumnArray = array("id","document_id","active","done");
  179 + $aQueryStringVariableNames = array("fFolderCollaborationID", "fDocumentID","fIsActive","fIsDone");
  180 + $aLinkURLs = array(5=>"$default->rootUrl/control.php?action=modifyDocumentRouting");
  181 +
  182 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%", $aLinkURLs,$aDBColumnArray,$aQueryStringVariableNames);
  183 + $oPatternTableSqlQuery->setTableHeading("Document Routing");
  184 + $oPatternTableSqlQuery->setDisplayColumnHeadings(true);
  185 +
  186 + $sToRender .= "<div id=\"documentRouting\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">";
  187 + $sToRender .= "\t<table border=\"0\" width=\"100%\">\n";
  188 + $sToRender .= "\t<tr>\n";
  189 + $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n";
  190 + $sToRender .= "\t</tr>";
  191 + $sToRender .= "\t<tr>\n";
  192 + // collaboration cannot be started or approved/rejected unless the document is not checked out
  193 + if (!$oDocument->getIsCheckedOut() && $oDocument->hasCollaboration() && (!DocumentCollaboration::documentCollaborationStarted($oDocument->getID())) && ($_SESSION["userID"] == $oDocument->getCreatorID())) {
  194 + //if not all collaboration steps have been set, then you cannot start the collaboration process
  195 + //only the creator of the document can start the collaboration process
  196 + $sToRender .= "\t\t<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fBeginCollaboration=1><img src=\"$default->graphicsUrl/widgets/begin.gif\" border=\"0\"/></a>";
  197 + $sToRender .= "</td>\n";
  198 + } else if (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($oDocument->getID())) {
  199 + //if the current user is responsible for an active step in the collaboration process
  200 + $sToRender .= "\t\t<td><table border=\"0\"><tr>\n";
  201 + $sToRender .= "\t\t<td><b>You currently have an active role<br> in the collaboration process</b></td>\n";
  202 + // collaboration cannot be started or approved/rejected if the document is checked out
  203 + if (!$oDocument->getIsCheckedOut()) {
  204 + $sToRender .= "\t\t<td align=\"center\"><a onClick=\"return confirm('Are you sure you want to approve? You will not have access to this document until the collaboration process is complete (unless the document is rejected in a subsequent step)');\" href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fCollaborationStepComplete=1><img src=\"$default->graphicsUrl/widgets/approve.gif\" border=\"0\"/></a></td>\n";
  205 + $sToRender .= "\t\t<td align=\"center\"><a href=\"$default->rootUrl/control.php?action=collaborationStepReject&fDocumentID=" . $oDocument->getID() . "\"><img src=\"$default->graphicsUrl/widgets/reject.gif\" border=\"0\"/></a></td>\n";
  206 + }
  207 + $sToRender .= "\t\t</tr></table></td>\n";
  208 + }
  209 + if (!DocumentCollaboration::documentIsPendingWebPublishing($oDocument->getID())) {
  210 + // only display for unpublished documents
  211 + // if there is collaboration
  212 + if ($oDocument->hasCollaboration()) {
  213 + // only display publish button if collaboration is complete and you're the last user in the collaboration process
  214 + if (DocumentCollaboration::documentCollaborationDone($oDocument->getID()) && ($_SESSION["userID"] == DocumentCollaboration::getLastCollaboratorID($oDocument->getID()))) {
  215 + $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
  216 + }
  217 + } else if ($_SESSION["userID"] == $oDocument->getCreatorID()) {
  218 + // no collaboration for this folder, so only the creator can request publication
  219 + // ??: or an administrator?
  220 + $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
  221 + }
  222 + }
  223 + $sToRender .= "\t</tr>";
  224 + $sToRender .= "\t</table>\n";
  225 + $sToRender .= "</div>";
  226 + return $sToRender;
  227 +
  228 +}
  229 +
  230 +function renderNonEditableDocumentRouting($oDocument) {
  231 + global $default;
  232 + $sQuery = "SELECT D.id as document_id, GFAL.id as id, R.name AS role_name, COALESCE(U.Name, 'Not assigned') AS name, GFAL.precedence AS precedence, COALESCE(FURL.active,0) AS active, COALESCE(FURL.done, 0) AS done " .
  233 + "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " .
  234 + "INNER JOIN roles AS R ON GFAL.role_id = R.id " .
  235 + "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id AND FURL.document_id = D.id " .
  236 + "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " .
  237 + "WHERE D.id = " . $oDocument->getID() . " " .
  238 + "ORDER BY GFAL.precedence, role_name ASC";
  239 +
  240 + $aColumns = array("role_name", "name", "precedence", "active", "done");
  241 + $aColumnHeaders = array("Role", "User", "Seq", "Active", "Done");
  242 + $aColumnTypes = array(1,1,1,1,1);
  243 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%", "$default->rootUrl/control.php?action=modifyDocumentRouting",$aDBColumnArray,$aQueryStringVariableNames);
  244 + $oPatternTableSqlQuery->setTableHeading("Document Routing");
  245 + $oPatternTableSqlQuery->setDisplayColumnHeadings(true);
  246 + return $oPatternTableSqlQuery->render();
  247 +
  248 +}
  249 +
  250 +function renderDocumentArchiveSettings($oDocument) {
  251 + global $default;
  252 + $sQuery = "SELECT d.id, atl.name, 'Edit' AS edit FROM $default->owl_document_archiving_table AS da " .
  253 + "INNER JOIN $default->owl_archiving_type_lookup_table AS atl ON da.archiving_type_id=atl.id " .
  254 + "INNER JOIN $default->owl_documents_table AS d ON da.document_id=d.id " .
  255 + "WHERE d.id = " . $oDocument->getID();
  256 +
  257 + $aColumns = array("name", "edit");
  258 + $aColumnHeaders = array("Archiving Type");
  259 + $aColumnTypes = array(1,3);
  260 + $aDBColumnArray = array("id");
  261 + $aQueryStringVariableNames = array("f ");
  262 + $aLinkURLs = array(1=>"$default->rootUrl/control.php?action=modifyDocumentArchiveSettings");
  263 + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%", $aLinkURLs ,$aDBColumnArray,$aQueryStringVariableNames);
  264 + $oPatternTableSqlQuery->setTableHeading("Archiving Settings");
  265 + $oPatternTableSqlQuery->setEmptyTableMessage("No archiving settings");
  266 + $oPatternTableSqlQuery->setDisplayColumnHeadings(true);
  267 +
  268 + $sToRender .= "<div id=\"archiveSettings\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">";
  269 + $sToRender .= "\t<table border=\"0\" width=\"100%\">\n";
  270 + $sToRender .= "\t<tr>\n";
  271 + $sToRender .= "\t\t<td>" . $oPatternTableSqlQuery->render() . "</td>\n";
  272 + $sToRender .= "\t</tr>";
  273 + $sToRender .= "\t<tr>\n";
  274 + // if there are no archiving settings then allow their addition
  275 + $oDocumentArchiving = DocumentArchiving::getFromDocumentID($oDocument->getID());
  276 + $sToRender .= "\t\t<td>" . ((!$oDocumentArchiving) ? "<a href=\"$default->rootUrl/control.php?action=addDocumentArchiveSettings&fDocumentID=" . $oDocument->getID() . "\"><img src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/></a>" : "") . "</td>\n";
  277 + $sToRender .= "\t</tr>";
  278 + $sToRender .= "\t</table>\n";
  279 + $sToRender .= "</div>";
  280 + return $sToRender;
  281 +}
  282 +
  283 +function displayActionButtons($oDocument, $bEdit) {
  284 + global $default;
  285 + if ($bEdit) {
  286 + // display the check in button if the document is checked out and you checked the document out
  287 + if ($oDocument->getIsCheckedOut() && ($oDocument->getCheckedOutUserID() == $_SESSION["userID"])) {
  288 + $sToRender = "<tr><td align=\"right\"><a href=\"" . generateControllerLink("checkInDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/checkin.gif\" border=\"0\" /></a></td></tr>\n";
  289 + // otherwise display the check out button
  290 + } else {
  291 + $sToRender = "<tr><td align=\"right\"><a href=\"" . generateControllerLink("checkOutDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/checkout.gif\" border=\"0\" /></a></td></tr>\n";
  292 + }
  293 + }
  294 +
  295 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("emailDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/email.gif\" border=\"0\" /></a></td></tr>\n";
  296 + if ($bEdit) {
  297 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("deleteDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/delete.gif\" border=\"0\" /></a></td></tr>\n";
  298 + }
  299 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("viewHistory", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/history.gif\" border=\"0\" /></a></td></tr>\n";
  300 + if ($bEdit) {
  301 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("moveDocument", "fFolderID=" . $oDocument->getFolderID() . "&fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/move.gif\" border=\"0\" /></a></td></tr>\n";
  302 + }
  303 +
  304 + // display the unsubscribe button if the user is subscribed to the document
  305 + if (Subscription::exists($_SESSION["userID"], $oDocument->getID(), SubscriptionConstants::subscriptionType("DocumentSubscription"))) {
  306 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("removeSubscription", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/unsubscribe.gif\" border=\"0\" /></a></td></tr>\n";
  307 + // otherwise display the subscribe button
  308 + } else {
  309 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("addSubscription", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/subscribe.gif\" border=\"0\" /></a></td></tr>\n";
  310 + }
  311 + $sToRender .= "<tr><td align=\"right\"><a onClick=\"alert('This will download a copy of the document and is not the same as Checking Out a document- changes to this downloaded file will not be managed in the DMS.'); return true;\" href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $oDocument->getID() . "&fForDownload=1") . "\"><img src=\"$default->graphicsUrl/widgets/download.gif\" border=\"0\" /></a></td></tr>\n";
  312 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("viewDiscussion", "fDocumentID=" . $oDocument->getID() . "&fForDiscussion=1") . "\"><img src=\"$default->graphicsUrl/widgets/discussion.gif\" border=\"0\" /></a></td></tr>\n";
  313 + // only display the archive button for available documents
  314 + if (!$oDocument->getIsCheckedOut() || !$oDocument->hasCollaboration() || (!DocumentCollaboration::documentCollaborationStarted($oDocument->getID()))) {
  315 + $sToRender .= "<tr><td align=\"right\"><a href=\"" . generateControllerLink("archiveDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/archive.gif\" border=\"0\" /></a></td></tr>\n";
  316 + }
  317 +
  318 + return $sToRender;
  319 +}
  320 +
  321 +function renderDiv($sDivName, $sHtml) {
  322 + return "<div id=\"$sDivName\" style=\"position:absolute;visibility:hidden;top:265px;left:130px;\">$sHtml</div>";
  323 +}
  324 +
  325 +function getEditPage($oDocument) {
  326 + global $default;
  327 + $iDocumentID = $oDocument->getID();
  328 +
  329 + $sToRender = renderHeading("Document Detail") . renderDocumentPath($oDocument) . "\n\n";
  330 +
  331 + $sToRender .= renderHeading("<a href=\"javascript:void();\" onClick=\"switchDiv('documentData');\">Document Data</a>");
  332 + $sToRender .= renderHeading("<a href=\"javascript:void();\" onClick=\"switchDiv('genericMetaData');\">Generic Meta Data</a>");
  333 + $sToRender .= renderHeading("<a href=\"javascript:void();\" onClick=\"switchDiv('typeSpecificMetaData');\">Type Specific Meta Data</a>");
  334 + $sToRender .= renderHeading("<a href=\"javascript:void();\" onClick=\"switchDiv('archiveSettings');\">Archive Settings</a>");
  335 + $sToRender .= renderHeading("<a href=\"javascript:void();\" onClick=\"switchDiv('documentRouting');\">Document Routing</a>");
  336 + $sToRender .= renderHeading("<a href=\"javascript:void();\" onClick=\"switchDiv('linkedDocuments');\">Linked Documents</a>");
  337 +
  338 + $sToRender .= renderDocumentData($oDocument, true);
  339 + $sToRender .= renderTypeSpecificMetaData($oDocument);
  340 + $sToRender .= renderDocumentArchiveSettings($oDocument);
  341 + $sToRender .= renderEditableLinkedDocuments($oDocument);
  342 + $sToRender .= renderEditableDocumentRouting($oDocument);
  343 + $sToRender .= renderGenericMetaData($oDocument);
  344 +
  345 + $sToRender .= "<div id=\"actionButtons\" style=\"position:absolute;top:265px;left:657px;\">";
  346 + $sToRender .= "<table>\n";
  347 + $sToRender .= displayActionButtons($oDocument, true);
  348 + $sToRender .= "</table>\n";
  349 + $sToRender .= "</div>";
  350 +
  351 + return $sToRender;
  352 +}
  353 +
  354 +function getViewPage($oDocument) {
  355 + global $default;
  356 + $iDocumentID = $oDocument->getID();
  357 + $sToRender = renderHeading("Document Detail") . renderDocumentPath($oDocument) . "\n<br>\n";
  358 +
  359 + $sToRender .= "<table>\n";
  360 + $sToRender .= "<tr>\n";
  361 + $sToRender .= displayActionButtons($oDocument, false);
  362 + $sToRender .= "</tr>\n";
  363 + $sToRender .= "</table>\n";
  364 +
  365 + $sToRender .= "<table border = 0>\n";
  366 + $sToRender .= "<tr>\n";
  367 + $sToRender .= "<td>\n";
  368 + $sToRender .= "\t<table border = 0 width = 280>\n";
  369 + $sToRender .= "\t<tr width>\n";
  370 + $sToRender .= "\t\t<td>" . renderDocumentData($oDocument) . "</td>\n";
  371 + $sToRender .= "\t</tr>\n";
  372 + $sToRender .= "\t<tr>\n";
  373 + $sToRender .= "\t<td>" . renderGenericMetaData($oDocument) . "</td>\n";
  374 + $sToRender .= "\t<tr>\n";
  375 + $sToRender .= "\t<tr>\n";
  376 + $sToRender .= "\t\t<td>" . renderTypeSpecificMetaData($oDocument) . "</td>\n";
  377 + $sToRender .= "\t</tr>\n";
  378 + $sToRender .= "\t</table>\n";
  379 + $sToRender .= "</td>\n";
  380 + $sToRender .= "<td valign=top>\n";
  381 + $sToRender .= "\t<table border = 0, width = 230>\n";
  382 + $sToRender .= "\t<tr>\n";
  383 + $sToRender .= "\t\t<td>" . renderNonEditableDocumentRouting($oDocument) . "</td>\n";
  384 + $sToRender .= "\t</tr>";
  385 + if (DocumentCollaboration::userIsPerformingCurrentCollaborationStep($oDocument->getID())) {
  386 + //if the current user is responsible for an active step in the collaboration process
  387 + $sToRender .= "\t\t<tr><td><table border=\"0\"><tr>\n";
  388 + $sToRender .= "\t\t<td><b>You currently have an active role<br> in the collaboration process</b></td>\n";
  389 + $sToRender .= "\t\t<td align=\"center\"><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fCollaborationStepComplete=1><img src=\"$default->graphicsUrl/widgets/approve.gif\" border=\"0\"/></a></td>\n";
  390 + $sToRender .= "\t\t<td align=\"center\"><a href=\"$default->rootUrl/control.php?action=collaborationStepReject&fDocumentID=$iDocumentID\"><img src=\"$default->graphicsUrl/widgets/reject.gif\" border=\"0\"/></a></td>\n";
  391 + $sToRender .= "\t\t</tr></table></td>\n";
  392 + }
  393 + $sToRender .= "\t</table>";
  394 + $sToRender .= "</td>\n";
  395 + $sToRender .= "</tr>\n";
  396 + $sToRender .= "</table>";
  397 +
  398 + $sToRender .= "<table>\n";
  399 + $sToRender .= "<tr>\n";
  400 + $sToRender .= displayActionButtons($oDocument, false);
  401 + $sToRender .= "</tr>\n";
  402 + $sToRender .= "</table>\n";
  403 +
  404 + return $sToRender;
  405 +}
  406 +
  407 +/**
  408 + * Displays the document view page with additional input controls
  409 + * for checking out the document
  410 + *
  411 + * @param object the document to view and check out
  412 + */
  413 +function getCheckOutEditPage($oDocument, $bCheckedOut = false) {
  414 + global $default;
  415 + $sToRender = renderHeading("Document Detail") . renderDocumentPath($oDocument) . "\n<br>\n";
  416 + $sToRender .= "<table border = 0>\n";
  417 + $sToRender .= "<tr>\n";
  418 + $sToRender .= "<td>\n";
  419 + $sToRender .= "\t<table border = 0 width = 280>\n";
  420 + $sToRender .= "\t<tr width>\n";
  421 + $sToRender .= "\t\t<td>" . renderDocumentData($oDocument) . "</td>\n";
  422 + $sToRender .= "\t</tr>\n";
  423 + $sToRender .= "\t<tr>\n";
  424 + $sToRender .= "\t<td>" . renderGenericMetaData($oDocument) . "</td>\n";
  425 + $sToRender .= "\t<tr>\n";
  426 + $sToRender .= "\t<tr>\n";
  427 + $sToRender .= "\t\t<td>" . renderTypeSpecificMetaData($oDocument) . "</td>\n";
  428 + $sToRender .= "\t</tr>\n";
  429 + $sToRender .= "\t</table>\n";
  430 + $sToRender .= "</td>\n";
  431 + $sToRender .= "<td valign=top>\n";
  432 + $sToRender .= "\t<table border = 0, width = 230>\n";
  433 + $sToRender .= "\t<tr>\n";
  434 + $sToRender .= "\t\t<td>" . renderNonEditableDocumentRouting($oDocument) . "</td>\n";
  435 + $sToRender .= "\t<tr>\n";
  436 + $sToRender .= "\t<tr>\n";
  437 + if ($bCheckedOut) {
  438 + $sToRender .= "\t\t<td>You have now checked out this document. No one else can make updates to the document while you have it checked out. Click the Download button to get the latest version of the file. Please check it back in, as soon as you finish working on it.</td>\n";
  439 + $sToRender .= "\t</tr>";
  440 + $sToRender .= "\t<tr>\n";
  441 + $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "&fForDownload=1\"><img src=\"$default->graphicsUrl/widgets/download.gif\" border=\"0\" /></a>\n";
  442 + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a></td>\n";
  443 + } else {
  444 + $sToRender .= "\t\t<td>" . renderCheckOutPage($oDocument) . "</td>\n";
  445 + }
  446 + $sToRender .= "\t</tr>";
  447 + $sToRender .= "\t</table>";
  448 + $sToRender .= "</td>\n";
  449 + $sToRender .= "</tr>\n";
  450 + $sToRender .= "</table>";
  451 +
  452 + return $sToRender;
  453 +}
  454 +
  455 +/**
  456 + * Displays the document view page with additional input controls
  457 + * for checking in the document
  458 + *
  459 + * @param object the document to view and check out
  460 + */
  461 +function getCheckInEditPage($oDocument) {
  462 + global $default;
  463 + $sToRender = renderHeading("Document Detail") . renderDocumentPath($oDocument) . "\n<br>\n";
  464 + $sToRender .= "<table border = 0>\n";
  465 + $sToRender .= "<tr>\n";
  466 + $sToRender .= "<td>\n";
  467 + $sToRender .= "\t<table border = 0 width = 280>\n";
  468 + $sToRender .= "\t<tr width>\n";
  469 + $sToRender .= "\t\t<td>" . renderDocumentData($oDocument) . "</td>\n";
  470 + $sToRender .= "\t</tr>\n";
  471 + $sToRender .= "\t<tr>\n";
  472 + $sToRender .= "\t<td>" . renderGenericMetaData($oDocument) . "</td>\n";
  473 + $sToRender .= "\t<tr>\n";
  474 + $sToRender .= "\t<tr>\n";
  475 + $sToRender .= "\t\t<td>" . renderTypeSpecificMetaData($oDocument) . "</td>\n";
  476 + $sToRender .= "\t</tr>\n";
  477 + $sToRender .= "\t</table>\n";
  478 + $sToRender .= "</td>\n";
  479 + $sToRender .= "<td valign=top>\n";
  480 + $sToRender .= "\t<table border = 0, width = 230>\n";
  481 + $sToRender .= "\t<tr>\n";
  482 + $sToRender .= "\t\t<td>" . renderNonEditableDocumentRouting($oDocument) . "</td>\n";
  483 + $sToRender .= "\t<tr>\n";
  484 + $sToRender .= "\t<tr>\n";
  485 + $sToRender .= "\t\t<td>" . renderCheckInPage($oDocument) . "</td>\n";
  486 + $sToRender .= "\t</tr>";
  487 + $sToRender .= "\t</table>";
  488 + $sToRender .= "</td>\n";
  489 + $sToRender .= "</tr>\n";
  490 + $sToRender .= "</table>";
  491 +
  492 + return $sToRender;
  493 +}
  494 +
  495 +function getWebPublishPage($oDocument) {
  496 + global $default;
  497 +
  498 + $oPatternListBox = & new PatternListBox($default->owl_web_sites_table, "web_site_name", "id", "fWebSiteID");
  499 +
  500 + $sToRender = renderHeading("Document Detail") . renderDocumentPath($oDocument) . "\n<br>\n";
  501 + $sToRender .= "<table border = 0>\n";
  502 + $sToRender .= "<tr>\n";
  503 + $sToRender .= "<td>\n";
  504 + $sToRender .= "\t<table border = 0 width = 280>\n";
  505 + $sToRender .= "\t<tr width>\n";
  506 + $sToRender .= "\t\t<td>" . renderDocumentData($oDocument) . "</td>\n";
  507 + $sToRender .= "\t</tr>\n";
  508 + $sToRender .= "\t<tr>\n";
  509 + $sToRender .= "\t<td>" . renderGenericMetaData($oDocument) . "</td>\n";
  510 + $sToRender .= "\t<tr>\n";
  511 + $sToRender .= "\t<tr>\n";
  512 + $sToRender .= "\t\t<td>" . renderTypeSpecificMetaData($oDocument) . "</td>\n";
  513 + $sToRender .= "\t</tr>\n";
  514 + $sToRender .= "\t</table>\n";
  515 + $sToRender .= "</td>\n";
  516 + $sToRender .= "<td valign=top>\n";
  517 + $sToRender .= "\t<table border=\"0\" width=\"230\">\n";
  518 + $sToRender .= "\t<tr>\n";
  519 + $sToRender .= "\t\t<td>" . renderNonEditableDocumentRouting($oDocument) . "</td>\n";
  520 + $sToRender .= "\t<tr>\n";
  521 + $sToRender .= "\t<tr>\n";
  522 + $sToRender .= "\t\t<th align=\"left\">Choose the website to publish to:</th>\n";
  523 + $sToRender .= "\t</tr>";
  524 + $sToRender .= "\t<tr>\n";
  525 + $sToRender .= "\t\t<td>" . $oPatternListBox->render() . "</td>\n";
  526 + $sToRender .= "\t\t<input type=\"hidden\" name=\"fForPublish\" value=\"1\" />\n";
  527 + $sToRender .= "\t</tr>";
  528 + $sToRender .= "\t<tr>\n";
  529 + $sToRender .= "\t\t<th nowrap align=\"left\">Enter a comment for the web master:</th>\n";
  530 + $sToRender .= "\t</tr>";
  531 + $sToRender .= "\t<tr>\n";
  532 + $sToRender .= "\t\t<td><input type=\"text\" name=\"fComment\" size=\"30\" /></td>\n";
  533 + $sToRender .= "\t</tr>";
  534 + $sToRender .= "\t<tr>\n";
  535 + $sToRender .= "\t\t<td><input type=\"image\" src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a>";
  536 + $sToRender .= "\t\t<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a></td>\n";
  537 + $sToRender .= "\t</tr>";
  538 + $sToRender .= "\t</table>";
  539 + $sToRender .= "</td>\n";
  540 + $sToRender .= "</tr>\n";
  541 + $sToRender .= "</table>";
  542 +
  543 + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";
  544 + $sToRender .= "function validateForm(theForm) {\n";
  545 + $sToRender .= "\tif (!(validRequired(document.MainForm.fWebSiteID,'Website'))) {\n";
  546 + $sToRender .= "\t\treturn false;\n\t}\n";
  547 + $sToRender .= "\tif (!(validRequired(document.MainForm.fComment,'Publish comment'))) {\n";
  548 + $sToRender .= "\t\treturn false;\n\t}\n";
  549 + $sToRender .= "return true;\n}\n";
  550 + $sToRender .= "//-->\n</script>\n\n";
  551 +
  552 + return $sToRender;
  553 +}
  554 +
  555 +function wrapInTable($sHtml) {
  556 + return "\n\t\t\t<table border = 1, width = 100%><tr><td>$sHtml</td></tr></table>\n";
  557 +}
  558 +
  559 +?>
... ...