Commit 4c72b2c290aee843dfa1e37460ba23539eb5c1ea

Authored by Michael Joseph
1 parent aae7e791

add web publishing functionality- allows the web site to publish on to be select…

…ed, and now only displaying the publish button after document collaboration is complete OR there is no collaboration for this document


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1467 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php
@@ -42,6 +42,7 @@ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.i @@ -42,6 +42,7 @@ require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.i
42 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); 42 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
43 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc"); 43 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListFromQuery.inc");
44 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); 44 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  45 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
45 46
46 require_once("$default->fileSystemRoot/lib/web/WebDocument.inc"); 47 require_once("$default->fileSystemRoot/lib/web/WebDocument.inc");
47 48
@@ -87,6 +88,10 @@ if (checkSession()) { @@ -87,6 +88,10 @@ if (checkSession()) {
87 $aFolderUserRoles = FolderUserRole::getList("document_id = " . $fDocumentID); 88 $aFolderUserRoles = FolderUserRole::getList("document_id = " . $fDocumentID);
88 if (count($aFolderCollaboration) == count($aFolderUserRoles)) { 89 if (count($aFolderCollaboration) == count($aFolderUserRoles)) {
89 //if all the roles have been assigned we can start the collaboration process 90 //if all the roles have been assigned we can start the collaboration process
  91 +
  92 + //TODO: check if this collaboration has already occured, and then reset all the steps before beginning it again
  93 + //Document::resetDocumentCollaborationSteps($fDocumentID);
  94 +
90 $oDocument->beginCollaborationProcess(); 95 $oDocument->beginCollaborationProcess();
91 $oPatternCustom = & new PatternCustom(); 96 $oPatternCustom = & new PatternCustom();
92 $oPatternCustom->setHtml(getEditPage($oDocument)); 97 $oPatternCustom->setHtml(getEditPage($oDocument));
@@ -115,10 +120,10 @@ if (checkSession()) { @@ -115,10 +120,10 @@ if (checkSession()) {
115 //the user has signled that they have completed their step in the collaboration process 120 //the user has signled that they have completed their step in the collaboration process
116 if (Document::isLastStepInCollaborationProcess($fDocumentID)) { 121 if (Document::isLastStepInCollaborationProcess($fDocumentID)) {
117 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 122 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
118 - //the last step in the collaboration process has been performed  
119 - //reset all the steps and email the document creator  
120 - Document::resetDocumentCollaborationSteps($fDocumentID);  
121 - $oDocument = Document::get($fDocumentID); 123 + //the last step in the collaboration process has been performed- email the document creator
  124 +
  125 + $oDocument = Document::get($fDocumentID);
  126 + $oDocument->endCollaborationProcess();
122 127
123 // on the last collaboration step- trigger a major revision 128 // on the last collaboration step- trigger a major revision
124 // major version number rollover 129 // major version number rollover
@@ -152,37 +157,57 @@ if (checkSession()) { @@ -152,37 +157,57 @@ if (checkSession()) {
152 $main->render(); 157 $main->render();
153 } 158 }
154 } else if ((isset($fForPublish)) && (!Document::documentIsPendingWebPublishing($fDocumentID))) { 159 } else if ((isset($fForPublish)) && (!Document::documentIsPendingWebPublishing($fDocumentID))) {
155 - //user wishes to public document  
156 - $oDocument = Document::get($fDocumentID);  
157 - if ($_SESSION["userID"] == $oDocument->getCreatorID()) {  
158 - //only the creator can send the document for publishing  
159 - $aWebDocument = WebDocument::getList("document_id = $fDocumentID");  
160 - $oWebDocument = $aWebDocument[0];  
161 - $oWebDocument->setStatusID(PENDING);  
162 - if ($oWebDocument->update()) {  
163 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
164 - $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE);  
165 - $oDocumentTransaction->create();  
166 - $oDocument = Document::get($fDocumentID);  
167 - Document::notifyWebMaster($fDocumentID);  
168 - $oPatternCustom = & new PatternCustom();  
169 - $oPatternCustom->setHtml(getEditPage($oDocument));  
170 - $main->setCentralPayload($oPatternCustom);  
171 - $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified");  
172 - $main->render();  
173 -  
174 - } else {  
175 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
176 - $oDocument = Document::get($fDocumentID);  
177 - $oPatternCustom = & new PatternCustom();  
178 - $oPatternCustom->setHtml(getEditPage($oDocument));  
179 - $main->setCentralPayload($oPatternCustom);  
180 - $main->setErrorMessage("An error occured while attempting to update the document for publishing");  
181 - $main->render();  
182 - }  
183 - } else {  
184 -  
185 - } 160 + if (isset($fWebSiteID)) {
  161 + // user wishes to publish document
  162 + $oDocument = Document::get($fDocumentID);
  163 + $default->log->info("userID=" . $_SESSION["userID"] . "; docid=$fDocumentID; creator id=" . $oDocument->getCreatorID());
  164 + if ($_SESSION["userID"] == $oDocument->getCreatorID()) {
  165 + //only the creator can send the document for publishing
  166 + $aWebDocument = WebDocument::getList("document_id = $fDocumentID");
  167 + $oWebDocument = $aWebDocument[0];
  168 + $oWebDocument->setStatusID(PENDING);
  169 + $oWebDocument->setWebSiteID($fWebSiteID);
  170 + if ($oWebDocument->update()) {
  171 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  172 + $oDocumentTransaction = & new DocumentTransaction($fDocumentID, "Document sent for web publishing", UPDATE);
  173 + $oDocumentTransaction->create();
  174 + $oDocument = Document::get($fDocumentID);
  175 + Document::notifyWebMaster($fDocumentID);
  176 + $oPatternCustom = & new PatternCustom();
  177 + $oPatternCustom->setHtml(getEditPage($oDocument));
  178 + $main->setCentralPayload($oPatternCustom);
  179 + $main->setErrorMessage("The document has been marked as pending publishing and the web publisher has been notified");
  180 + $main->render();
  181 +
  182 + } else {
  183 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  184 + $oDocument = Document::get($fDocumentID);
  185 + $oPatternCustom = & new PatternCustom();
  186 + $oPatternCustom->setHtml(getEditPage($oDocument));
  187 + $main->setCentralPayload($oPatternCustom);
  188 + $main->setErrorMessage("An error occured while attempting to update the document for publishing");
  189 + $main->render();
  190 + }
  191 + } else {
  192 + // you're can't publish if you're not the originator
  193 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  194 + $oDocument = Document::get($fDocumentID);
  195 + $oPatternCustom = & new PatternCustom();
  196 + $oPatternCustom->setHtml(getEditPage($oDocument));
  197 + $main->setCentralPayload($oPatternCustom);
  198 + $main->setErrorMessage("You can't publish this document because you're not the document originator");
  199 + $main->render();
  200 + }
  201 + } else {
  202 + // prompt for the website to publish to
  203 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  204 + $oDocument = Document::get($fDocumentID);
  205 + $oPatternCustom = & new PatternCustom();
  206 + $oPatternCustom->setHtml(getWebPublishPage($oDocument));
  207 + $main->setCentralPayload($oPatternCustom);
  208 + $main->setFormAction($_SERVER['PHP_SELF']);
  209 + $main->render();
  210 + }
186 211
187 } else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) { 212 } else if (Permission::userHasDocumentWritePermission($fDocumentID) || Permission::userHasDocumentReadPermission($fDocumentID)) {
188 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 213 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc
@@ -94,11 +94,10 @@ function renderEditableDocumentRouting($oDocument) { @@ -94,11 +94,10 @@ function renderEditableDocumentRouting($oDocument) {
94 $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 " . 94 $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 " .
95 "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " . 95 "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " .
96 "INNER JOIN roles AS R ON GFAL.role_id = R.id " . 96 "INNER JOIN roles AS R ON GFAL.role_id = R.id " .
97 - "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id " .  
98 - "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id AND FURL.document_id = D.id " . 97 + "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id AND FURL.document_id = D.id " .
  98 + "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " .
99 "WHERE D.id = " . $oDocument->getID() . " " . 99 "WHERE D.id = " . $oDocument->getID() . " " .
100 "ORDER BY GFAL.precedence, role_name ASC"; 100 "ORDER BY GFAL.precedence, role_name ASC";
101 -  
102 $aColumns = array("role_name", "name", "precedence", "active", "done", "edit"); 101 $aColumns = array("role_name", "name", "precedence", "active", "done", "edit");
103 $aColumnHeaders = array("Role", "User", "Seq", "Active", "Done", ""); 102 $aColumnHeaders = array("Role", "User", "Seq", "Active", "Done", "");
104 $aColumnTypes = array(1,1,1,1,1,3); 103 $aColumnTypes = array(1,1,1,1,1,3);
@@ -118,7 +117,7 @@ function renderNonEditableDocumentRouting($oDocument) { @@ -118,7 +117,7 @@ function renderNonEditableDocumentRouting($oDocument) {
118 $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 " . 117 $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 " .
119 "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " . 118 "FROM documents AS D INNER JOIN $default->owl_groups_folders_approval_table AS GFAL ON D.folder_id = GFAL.folder_id " .
120 "INNER JOIN roles AS R ON GFAL.role_id = R.id " . 119 "INNER JOIN roles AS R ON GFAL.role_id = R.id " .
121 - "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id " . 120 + "LEFT OUTER JOIN folders_users_roles_link AS FURL ON FURL.group_folder_approval_id = GFAL.id AND FURL.document_id = D.id " .
122 "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " . 121 "LEFT OUTER JOIN users AS U ON FURL.user_id = U.id " .
123 "WHERE D.id = " . $oDocument->getID() . " " . 122 "WHERE D.id = " . $oDocument->getID() . " " .
124 "ORDER BY GFAL.precedence, role_name ASC"; 123 "ORDER BY GFAL.precedence, role_name ASC";
@@ -170,13 +169,10 @@ function getEditPage($oDocument) { @@ -170,13 +169,10 @@ function getEditPage($oDocument) {
170 $sToRender .= "\t\t<td>" . renderEditableDocumentRouting($oDocument) . "</td>\n"; 169 $sToRender .= "\t\t<td>" . renderEditableDocumentRouting($oDocument) . "</td>\n";
171 $sToRender .= "\t</tr>"; 170 $sToRender .= "\t</tr>";
172 $sToRender .= "\t<tr>\n"; 171 $sToRender .= "\t<tr>\n";
173 - if ((!Document::documentCollaborationStarted($oDocument->getID())) && ($_SESSION["userID"] == $oDocument->getCreatorID())) { 172 + if ($oDocument->hasCollaboration() && (!Document::documentCollaborationStarted($oDocument->getID())) && ($_SESSION["userID"] == $oDocument->getCreatorID())) {
174 //if not all collaboration steps have been set, then you cannot start the collaboration process 173 //if not all collaboration steps have been set, then you cannot start the collaboration process
175 //only the creator of the document can start the collaboration process 174 //only the creator of the document can start the collaboration process
176 $sToRender .= "\t\t<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fBeginCollaboration=1><img src=\"$default->graphicsUrl/widgets/begin.gif\" border=\"0\"/></a>"; 175 $sToRender .= "\t\t<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fBeginCollaboration=1><img src=\"$default->graphicsUrl/widgets/begin.gif\" border=\"0\"/></a>";
177 - if (!Document::documentIsPendingWebPublishing($iDocumentID)) {  
178 - $sToRender .= "<a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a>\n";  
179 - }  
180 $sToRender .= "</td>\n"; 176 $sToRender .= "</td>\n";
181 } else if (Document::userIsPerformingCurrentCollaborationStep($oDocument->getID())) { 177 } else if (Document::userIsPerformingCurrentCollaborationStep($oDocument->getID())) {
182 //if the current user is responsible for an active step in the collaboration process 178 //if the current user is responsible for an active step in the collaboration process
@@ -185,7 +181,12 @@ function getEditPage($oDocument) { @@ -185,7 +181,12 @@ function getEditPage($oDocument) {
185 $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"; 181 $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";
186 $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"; 182 $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";
187 $sToRender .= "\t\t</tr></table></td>\n"; 183 $sToRender .= "\t\t</tr></table></td>\n";
188 - } 184 + } else if (!$oDocument->hasCollaboration() || Document::documentCollaborationDone($oDocument->getID())) {
  185 + // only display publish button if there is no collaboration or collaboration is complete
  186 + if (!Document::documentIsPendingWebPublishing($iDocumentID) && ($_SESSION["userID"] == $oDocument->getCreatorID())) {
  187 + $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
  188 + }
  189 + }
189 $sToRender .= "\t</tr>"; 190 $sToRender .= "\t</tr>";
190 $sToRender .= "\t</table>"; 191 $sToRender .= "\t</table>";
191 $sToRender .= "</td>\n"; 192 $sToRender .= "</td>\n";
@@ -202,6 +203,7 @@ function getEditPage($oDocument) { @@ -202,6 +203,7 @@ function getEditPage($oDocument) {
202 $sToRender .= "<td><a href=\"" . generateControllerLink("checkOutDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/checkout.gif\" border=\"0\" /></a></td>\n"; 203 $sToRender .= "<td><a href=\"" . generateControllerLink("checkOutDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/checkout.gif\" border=\"0\" /></a></td>\n";
203 } 204 }
204 205
  206 + // IE ssl download hack- don't use ssl to download
205 if ($default->phpSniff->property("browser") == "ie") { 207 if ($default->phpSniff->property("browser") == "ie") {
206 $sToRender .= "<td><a href=\"http://" . $default->serverName . $_SERVER["PHP_SELF"] . "?fDocumentID=" . $oDocument->getID() . "&fForDownload=1\"><img src=\"$default->graphicsUrl/widgets/download.gif\" border=\"0\" /></a></td>\n"; 208 $sToRender .= "<td><a href=\"http://" . $default->serverName . $_SERVER["PHP_SELF"] . "?fDocumentID=" . $oDocument->getID() . "&fForDownload=1\"><img src=\"$default->graphicsUrl/widgets/download.gif\" border=\"0\" /></a></td>\n";
207 } else { 209 } else {
@@ -370,6 +372,51 @@ function getCheckInEditPage($oDocument) { @@ -370,6 +372,51 @@ function getCheckInEditPage($oDocument) {
370 return $sToRender; 372 return $sToRender;
371 } 373 }
372 374
  375 +function getWebPublishPage($oDocument) {
  376 + global $default;
  377 +
  378 + $oPatternListBox = & new PatternListBox($default->owl_web_sites_table, "web_site_name", "id", "fWebSiteID");
  379 +
  380 + $sToRender = renderHeading() . renderDocumentPath($oDocument) . "\n<br>\n";
  381 + $sToRender .= "<table border = 0>\n";
  382 + $sToRender .= "<tr>\n";
  383 + $sToRender .= "<td>\n";
  384 + $sToRender .= "\t<table border = 0 width = 280>\n";
  385 + $sToRender .= "\t<tr width>\n";
  386 + $sToRender .= "\t\t<td>" . renderDocumentData($oDocument) . "</td>\n";
  387 + $sToRender .= "\t</tr>\n";
  388 + $sToRender .= "\t<tr>\n";
  389 + $sToRender .= "\t<td>" . renderGenericMetaData($oDocument) . "</td>\n";
  390 + $sToRender .= "\t<tr>\n";
  391 + $sToRender .= "\t<tr>\n";
  392 + $sToRender .= "\t\t<td>" . renderTypeSpecificMetaData($oDocument) . "</td>\n";
  393 + $sToRender .= "\t</tr>\n";
  394 + $sToRender .= "\t</table>\n";
  395 + $sToRender .= "</td>\n";
  396 + $sToRender .= "<td valign=top>\n";
  397 + $sToRender .= "\t<table border = 0, width = 230>\n";
  398 + $sToRender .= "\t<tr>\n";
  399 + $sToRender .= "\t\t<td>" . renderNonEditableDocumentRouting($oDocument) . "</td>\n";
  400 + $sToRender .= "\t<tr>\n";
  401 + $sToRender .= "\t<tr>\n";
  402 + $sToRender .= "\t\t<th>Choose the website to publish to:</th>\n";
  403 + $sToRender .= "\t</tr>";
  404 + $sToRender .= "\t<tr>\n";
  405 + $sToRender .= "\t\t<td>" . $oPatternListBox->render() . "</td>\n";
  406 + $sToRender .= "\t\t<input type=\"hidden\" name=\"fForPublish\" value=\"1\" />\n";
  407 + $sToRender .= "\t</tr>";
  408 + $sToRender .= "\t<tr>\n";
  409 + $sToRender .= "\t\t<td><input type=\"image\" src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a>";
  410 + $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";
  411 + $sToRender .= "\t</tr>";
  412 + $sToRender .= "\t</table>";
  413 + $sToRender .= "</td>\n";
  414 + $sToRender .= "</tr>\n";
  415 + $sToRender .= "</table>";
  416 +
  417 + return $sToRender;
  418 +}
  419 +
373 function wrapInTable($sHtml) { 420 function wrapInTable($sHtml) {
374 return "\n\t\t\t<table border = 1, width = 100%><tr><td>$sHtml</td></tr></table>\n"; 421 return "\n\t\t\t<table border = 1, width = 100%><tr><td>$sHtml</td></tr></table>\n";
375 } 422 }