From 4c72b2c290aee843dfa1e37460ba23539eb5c1ea Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Mon, 10 Mar 2003 13:24:37 +0000 Subject: [PATCH] add web publishing functionality- allows the web site to publish on to be selected, and now only displaying the publish button after document collaboration is complete OR there is no collaboration for this document --- presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------- presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 116 insertions(+), 44 deletions(-) diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php index e7e8176..8edbe54 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php @@ -42,6 +42,7 @@ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.i require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); @@ -87,6 +88,10 @@ if (checkSession()) { $aFolderUserRoles = FolderUserRole::getList("document_id = " . $fDocumentID); if (count($aFolderCollaboration) == count($aFolderUserRoles)) { //if all the roles have been assigned we can start the collaboration process + + //TODO: check if this collaboration has already occured, and then reset all the steps before beginning it again + //Document::resetDocumentCollaborationSteps($fDocumentID); + $oDocument->beginCollaborationProcess(); $oPatternCustom = & new PatternCustom(); $oPatternCustom->setHtml(getEditPage($oDocument)); @@ -115,10 +120,10 @@ if (checkSession()) { //the user has signled that they have completed their step in the collaboration process if (Document::isLastStepInCollaborationProcess($fDocumentID)) { require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - //the last step in the collaboration process has been performed - //reset all the steps and email the document creator - Document::resetDocumentCollaborationSteps($fDocumentID); - $oDocument = Document::get($fDocumentID); + //the last step in the collaboration process has been performed- email the document creator + + $oDocument = Document::get($fDocumentID); + $oDocument->endCollaborationProcess(); // on the last collaboration step- trigger a major revision // major version number rollover @@ -152,37 +157,57 @@ if (checkSession()) { $main->render(); } } else if ((isset($fForPublish)) && (!Document::documentIsPendingWebPublishing($fDocumentID))) { - //user wishes to public document - $oDocument = Document::get($fDocumentID); - if ($_SESSION["userID"] == $oDocument->getCreatorID()) { - //only the creator can send the document for publishing - $aWebDocument = WebDocument::getList("document_id = $fDocumentID"); - $oWebDocument = $aWebDocument[0]; - $oWebDocument->setStatusID(PENDING); - if ($oWebDocument->update()) { - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE); - $oDocumentTransaction->create(); - $oDocument = Document::get($fDocumentID); - Document::notifyWebMaster($fDocumentID); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getEditPage($oDocument)); - $main->setCentralPayload($oPatternCustom); - $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified"); - $main->render(); - - } else { - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oDocument = Document::get($fDocumentID); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getEditPage($oDocument)); - $main->setCentralPayload($oPatternCustom); - $main->setErrorMessage("An error occured while attempting to update the document for publishing"); - $main->render(); - } - } else { - - } + if (isset($fWebSiteID)) { + // user wishes to publish document + $oDocument = Document::get($fDocumentID); + $default->log->info("userID=" . $_SESSION["userID"] . "; docid=$fDocumentID; creator id=" . $oDocument->getCreatorID()); + if ($_SESSION["userID"] == $oDocument->getCreatorID()) { + //only the creator can send the document for publishing + $aWebDocument = WebDocument::getList("document_id = $fDocumentID"); + $oWebDocument = $aWebDocument[0]; + $oWebDocument->setStatusID(PENDING); + $oWebDocument->setWebSiteID($fWebSiteID); + if ($oWebDocument->update()) { + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE); + $oDocumentTransaction->create(); + $oDocument = Document::get($fDocumentID); + Document::notifyWebMaster($fDocumentID); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getEditPage($oDocument)); + $main->setCentralPayload($oPatternCustom); + $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified"); + $main->render(); + + } else { + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oDocument = Document::get($fDocumentID); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getEditPage($oDocument)); + $main->setCentralPayload($oPatternCustom); + $main->setErrorMessage("An error occured while attempting to update the document for publishing"); + $main->render(); + } + } else { + // you're can't publish if you're not the originator + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oDocument = Document::get($fDocumentID); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getEditPage($oDocument)); + $main->setCentralPayload($oPatternCustom); + $main->setErrorMessage("You can't publish this document because you're not the document originator"); + $main->render(); + } + } else { + // prompt for the website to publish to + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oDocument = Document::get($fDocumentID); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getWebPublishPage($oDocument)); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER['PHP_SELF']); + $main->render(); + } } else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) { require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc index 65cdb46..ae1b8a6 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc @@ -94,11 +94,10 @@ function renderEditableDocumentRouting($oDocument) { $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 " . "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " . "INNER JOIN roles AS R ON GFAL.role_id = R.id " . - "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id " . - "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id AND FURL.document_id = D.id " . + "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id AND FURL.document_id = D.id " . + "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " . "WHERE D.id = " . $oDocument->getID() . " " . "ORDER BY GFAL.precedence, role_name ASC"; - $aColumns = array("role_name", "name", "precedence", "active", "done", "edit"); $aColumnHeaders = array("Role", "User", "Seq", "Active", "Done", ""); $aColumnTypes = array(1,1,1,1,1,3); @@ -118,7 +117,7 @@ function renderNonEditableDocumentRouting($oDocument) { $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 " . "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " . "INNER JOIN roles AS R ON GFAL.role_id = R.id " . - "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id " . + "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id AND FURL.document_id = D.id " . "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " . "WHERE D.id = " . $oDocument->getID() . " " . "ORDER BY GFAL.precedence, role_name ASC"; @@ -170,13 +169,10 @@ function getEditPage($oDocument) { $sToRender .= "\t\t" . renderEditableDocumentRouting($oDocument) . "\n"; $sToRender .= "\t"; $sToRender .= "\t\n"; - if ((!Document::documentCollaborationStarted($oDocument->getID())) && ($_SESSION["userID"] == $oDocument->getCreatorID())) { + if ($oDocument->hasCollaboration() && (!Document::documentCollaborationStarted($oDocument->getID())) && ($_SESSION["userID"] == $oDocument->getCreatorID())) { //if not all collaboration steps have been set, then you cannot start the collaboration process //only the creator of the document can start the collaboration process $sToRender .= "\t\tgraphicsUrl/widgets/begin.gif\" border=\"0\"/>"; - if (!Document::documentIsPendingWebPublishing($iDocumentID)) { - $sToRender .= "graphicsUrl/widgets/publish.gif\" border=\"0\"/>\n"; - } $sToRender .= "\n"; } else if (Document::userIsPerformingCurrentCollaborationStep($oDocument->getID())) { //if the current user is responsible for an active step in the collaboration process @@ -185,7 +181,12 @@ function getEditPage($oDocument) { $sToRender .= "\t\tgraphicsUrl/widgets/approve.gif\" border=\"0\"/>\n"; $sToRender .= "\t\trootUrl/control.php?action=collaborationStepReject&fDocumentID=$iDocumentID\">graphicsUrl/widgets/reject.gif\" border=\"0\"/>\n"; $sToRender .= "\t\t\n"; - } + } else if (!$oDocument->hasCollaboration() || Document::documentCollaborationDone($oDocument->getID())) { + // only display publish button if there is no collaboration or collaboration is complete + if (!Document::documentIsPendingWebPublishing($iDocumentID) && ($_SESSION["userID"] == $oDocument->getCreatorID())) { + $sToRender .= "graphicsUrl/widgets/publish.gif\" border=\"0\"/>\n"; + } + } $sToRender .= "\t"; $sToRender .= "\t"; $sToRender .= "\n"; @@ -202,6 +203,7 @@ function getEditPage($oDocument) { $sToRender .= "graphicsUrl/widgets/checkout.gif\" border=\"0\" />\n"; } + // IE ssl download hack- don't use ssl to download if ($default->phpSniff->property("browser") == "ie") { $sToRender .= "serverName . $_SERVER["PHP_SELF"] . "?fDocumentID=" . $oDocument->getID() . "&fForDownload=1\">graphicsUrl/widgets/download.gif\" border=\"0\" />\n"; } else { @@ -370,6 +372,51 @@ function getCheckInEditPage($oDocument) { return $sToRender; } +function getWebPublishPage($oDocument) { + global $default; + + $oPatternListBox = & new PatternListBox($default->owl_web_sites_table, "web_site_name", "id", "fWebSiteID"); + + $sToRender = renderHeading() . renderDocumentPath($oDocument) . "\n
\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "
\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t
" . renderDocumentData($oDocument) . "
" . renderGenericMetaData($oDocument) . "
" . renderTypeSpecificMetaData($oDocument) . "
\n"; + $sToRender .= "
\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t"; + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t"; + $sToRender .= "\t\n"; + $sToRender .= "\t\t\n"; + $sToRender .= "\t"; + $sToRender .= "\t
" . renderNonEditableDocumentRouting($oDocument) . "
Choose the website to publish to:
" . $oPatternListBox->render() . "
graphicsUrl/widgets/publish.gif\" border=\"0\"/>"; + $sToRender .= "\t\trootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\">graphicsUrl/widgets/cancel.gif\" border=\"0\" />
"; + $sToRender .= "
"; + + return $sToRender; +} + function wrapInTable($sHtml) { return "\n\t\t\t
$sHtml
\n"; } -- libgit2 0.21.4