Commit 22363685499d7be64db437c9772e397408be18af
1 parent
17f54fb4
web publishing functionality
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1473 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
143 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/webDocumentBL.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +require_once("../../../../config/dmsDefaults.php"); | ||
| 4 | +require_once("$default->fileSystemRoot/lib/email/Email.inc"); | ||
| 5 | +require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 6 | +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 7 | +require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); | ||
| 8 | +require_once("$default->fileSystemRoot/lib/web/WebSite.inc"); | ||
| 9 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 10 | +require_once("webDocumentUI.inc"); | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * $Id$ | ||
| 14 | + * | ||
| 15 | + * This page displays a web document pending publication and allows the webmaster | ||
| 16 | + * to flag the upload to 3rd party website as completed. | ||
| 17 | + * | ||
| 18 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | ||
| 19 | + * | ||
| 20 | + * @version $Revision$ | ||
| 21 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 22 | + * @package presentation.lookAndFeel.knowledgeTree.documentmanagement | ||
| 23 | + */ | ||
| 24 | + | ||
| 25 | +/* | ||
| 26 | + * Querystring variables | ||
| 27 | + * --------------------- | ||
| 28 | + * fWebDocumentID - the web document to process | ||
| 29 | + */ | ||
| 30 | + | ||
| 31 | +// ------------------------------- | ||
| 32 | +// page start | ||
| 33 | +// ------------------------------- | ||
| 34 | + | ||
| 35 | +// only if we have a valid session | ||
| 36 | +if (checkSession()) { | ||
| 37 | + | ||
| 38 | + $oContent = new PatternCustom(); | ||
| 39 | + | ||
| 40 | + // retrieve variables | ||
| 41 | + if ($fWebDocumentID) { | ||
| 42 | + $oWebDocument = WebDocument::get($fWebDocumentID); | ||
| 43 | + if ($oWebDocument) { | ||
| 44 | + if ($fUploaded && $fUploadUrl) { | ||
| 45 | + // the web document has been uploaded, so update the document status | ||
| 46 | + $oWebDocument->setStatusID(PUBLISHED); | ||
| 47 | + $oWebDocument->setDateTime(getCurrentDateTime()); | ||
| 48 | + if ($oWebDocument->update()) { | ||
| 49 | + // successfully updated- notify the originator | ||
| 50 | + $oDocument = Document::get($oWebDocument->getDocumentID()); | ||
| 51 | + $oUser = User::get($oDocument->getCreatorID()); | ||
| 52 | + $oEmail = new Email(); | ||
| 53 | + $sBody = "The document entitled '" . $oDocument->getName() . "' you requested for web publication has been uploaded to $fUploadUrl."; | ||
| 54 | + $oEmail->send($oUser->getEmail(), "Web publication", $sBody); | ||
| 55 | + // redirect to the dashboard | ||
| 56 | + controllerRedirect("dashboard", ""); | ||
| 57 | + } else { | ||
| 58 | + $oContent->setHtml(renderErrorPage("There was an error updating the web document status")); | ||
| 59 | + } | ||
| 60 | + } else { | ||
| 61 | + // display the upload instructions for the web master | ||
| 62 | + $oContent->setHtml(renderUploadPage($oWebDocument)); | ||
| 63 | + } | ||
| 64 | + } else { | ||
| 65 | + $oContent->setHtml(renderErrorPage("The web document could not be retrieved from the database")); | ||
| 66 | + } | ||
| 67 | + } else { | ||
| 68 | + $oContent->setHtml(renderErrorPage("No web document selected")); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + require_once("../../../webpageTemplate.inc"); | ||
| 72 | + $main->setCentralPayload($oContent); | ||
| 73 | + $main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 74 | + $main->render(); | ||
| 75 | +} | ||
| 76 | +?> |
presentation/lookAndFeel/knowledgeTree/documentmanagement/webDocumentUI.inc
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id$ | ||
| 5 | + * | ||
| 6 | + * Web document presentation. | ||
| 7 | + * | ||
| 8 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | ||
| 9 | + * | ||
| 10 | + * @version $Revision$ | ||
| 11 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 12 | + * @package presentation.lookAndFeel.knowledgeTree.documentmanagement | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | +function renderHeading() { | ||
| 16 | + global $default; | ||
| 17 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | ||
| 18 | + $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); | ||
| 19 | + $sToRender = "<table border=\"0\" width=\"100%\">\n"; | ||
| 20 | + $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\">Web Document</th></tr>\n"; | ||
| 21 | + $sToRender .= "<tr/>\n"; | ||
| 22 | + $sToRender .= "<tr/>\n"; | ||
| 23 | + $sToRender .= "</table>\n"; | ||
| 24 | + return $sToRender; | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Prompts the user for a checkout comment | ||
| 29 | + * | ||
| 30 | + * @param object the document we're checking out | ||
| 31 | + */ | ||
| 32 | +function renderUploadPage($oWebDocument) { | ||
| 33 | + global $default; | ||
| 34 | + $oDocument = Document::get($oWebDocument->getDocumentID()); | ||
| 35 | + $oWebSite = WebSite::get($oWebDocument->getWebSiteID()); | ||
| 36 | + $oUser = User::get($oDocument->getCreatorID()); | ||
| 37 | + | ||
| 38 | + $sToRender = renderHeading(); | ||
| 39 | + $sToRender .= "<table>\n"; | ||
| 40 | + $sToRender .= "<tr><td>'" . $oUser->getName() . "' has requested that the document </td></tr>"; | ||
| 41 | + $sToRender .= "<tr><td><strong>" . generateControllerLink("viewDocument", "fDocumentID=" . $oDocument->getID(), $oDocument->getDisplayPath()) . "</strong></td></tr>"; | ||
| 42 | + $sToRender .= "<tr><td>be uploaded to website <strong>'" . $oWebSite->getWebSiteName() . "'</strong> (" . $oWebSite->getWebSiteURL() . ")</td></tr>\n"; | ||
| 43 | + $sToRender .= "<tr><td>Once the document has been uploaded, please enter the URL that it has been uploaded to in the text box below and click 'Done' </td></tr>\n"; | ||
| 44 | + $sToRender .= "<tr/>\n"; | ||
| 45 | + $sToRender .= "<tr><td>Upload URL: <input type=\"text\" name=\"fUploadUrl\" size=\"30\" value=\"" . $oWebSite->getWebSiteURL() . "\"/></td></tr>\n"; | ||
| 46 | + $sToRender .= "<tr><td><input type=\"hidden\" name=\"fUploaded\" value=\"1\"/></td></tr>\n"; | ||
| 47 | + $sToRender .= "<tr><td><input type=\"hidden\" name=\"fWebDocumentID\" value=\"" . $oWebDocument->getID() . "\"/></td></tr>\n"; | ||
| 48 | + $sToRender .= "<tr>\n"; | ||
| 49 | + $sToRender .= "</tr>\n"; | ||
| 50 | + $sToRender .= "<tr>\n"; | ||
| 51 | + $sToRender .= "<td><input type=\"image\" src =\"$default->graphicsUrl/widgets/done.gif\" value=\"Submit\" onClick=\"return validRequired(document.MainForm.fUploadUrl, 'upload URL');\" />\n"; | ||
| 52 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=dashboard\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a></td>\n"; | ||
| 53 | + $sToRender .= "</tr>\n"; | ||
| 54 | + $sToRender .= "</table>\n"; | ||
| 55 | + | ||
| 56 | + return $sToRender; | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +function renderErrorPage($sErrorMessage, $iDocumentID = -1) { | ||
| 60 | + global $default; | ||
| 61 | + return "<p class=\"errorText\">$sErrorMessage</p>\n" . | ||
| 62 | + (($iDocumentID == -1) ? | ||
| 63 | + "<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=$iDocumentID\">" : | ||
| 64 | + "<a href=\"javascript:history.go(-1)\">") . | ||
| 65 | + "<img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"/></a>\n"; | ||
| 66 | +} | ||
| 67 | +?> |