Commit a2d6a45677f6e0dc097035b16cd66431e53a58f5

Authored by Michael Joseph
1 parent 6f01096d

(#2677) fixed checkin/out no access case

moved publish button to list


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2444 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc
... ... @@ -234,20 +234,6 @@ function renderEditableDocumentRouting($oDocument) {
234 234 $sToRender .= "\t\t</tr></table></td>\n";
235 235 }
236 236  
237   - // only display the publish button for unpublished documents
238   - if (!DocumentCollaboration::documentIsPendingWebPublishing($oDocument->getID())) {
239   - // if there is collaboration
240   - if ($oDocument->hasCollaboration()) {
241   - // only display publish button if collaboration is complete and you're the last user in the collaboration process (or a sysadmin)
242   - if (DocumentCollaboration::documentCollaborationDone($oDocument->getID()) &&
243   - ( ($_SESSION["userID"] == DocumentCollaboration::getLastCollaboratorID($oDocument->getID())) || Permission::userIsSystemAdministrator() ) ) {
244   - $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
245   - }
246   - } else if ( ($_SESSION["userID"] == $oDocument->getCreatorID()) || Permission::userIsSystemAdministrator() ) {
247   - // no collaboration for this folder, so only the creator (or an administrator) can request publication
248   - $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
249   - }
250   - }
251 237 $sToRender .= "\t</tr>";
252 238 $sToRender .= "\t</table>\n";
253 239  
... ... @@ -370,23 +356,23 @@ function displayViewButton($oDocument, $bEdit) {
370 356 }
371 357  
372 358 function displayCheckInOutButton($oDocument, $bEdit) {
373   - if ($bEdit) {
374   - $sQueryString = "fDocumentID=" . $oDocument->getID();
375   - // display the check in button if the document is checked out and you checked the document out
376   - if ($oDocument->getIsCheckedOut()) {
377   - if ($oDocument->getCheckedOutUserID() == $_SESSION["userID"]) {
378   - $sAction = "checkInDocument";
379   - $sImageName = "checkin";
380   - } else {
381   - $oUser = User::get($oDocument->getCheckedOutUserID());
382   - $sDisabledText = "The document can only be checked back in by " . $oUser->getName();
383   - }
384   - // otherwise display the check out button
385   - } else {
386   - $sAction = "checkOutDocument";
387   - $sImageName = "checkout";
388   - }
389   - } else {
  359 +
  360 + $sQueryString = "fDocumentID=" . $oDocument->getID();
  361 + // display the check in button if the document is checked out and you checked the document out
  362 + if ($oDocument->getIsCheckedOut()) {
  363 + if ($oDocument->getCheckedOutUserID() == $_SESSION["userID"]) {
  364 + $sAction = "checkInDocument";
  365 + $sImageName = "checkin";
  366 + } else {
  367 + $oUser = User::get($oDocument->getCheckedOutUserID());
  368 + $sDisabledText = "The document can only be checked back in by " . $oUser->getName();
  369 + }
  370 + // otherwise display the check out button
  371 + } else {
  372 + $sAction = "checkOutDocument";
  373 + $sImageName = "checkout";
  374 + }
  375 + if (!$bEdit) {
390 376 $sDisabledText = "You do not have write access to this document";
391 377 }
392 378 return "<tr><td align=\"left\">" . displayButton($sAction, $sQueryString, $sImageName, $sDisabledText) . "</td></tr>\n";
... ... @@ -470,28 +456,30 @@ function displayDependantDocumentButton($oDocument, $bEdit) {
470 456 return "<td align=\"left\"><a href=\"" . generateControllerLink("createDependantDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/dependentdoc.gif\" border=\"0\" /></a></td>\n";
471 457 }
472 458  
473   -/*
474 459 function displayPublishButton($oDocument, $bEdit) {
475   - // only display the publish button for unpublished documents
  460 + // only display the publish button for unpublished documents
476 461 if (!DocumentCollaboration::documentIsPendingWebPublishing($oDocument->getID())) {
477 462 // if there is collaboration
478 463 if ($oDocument->hasCollaboration()) {
479 464 // only display publish button if collaboration is complete and you're the last user in the collaboration process (or a sysadmin)
480   - if (DocumentCollaboration::documentCollaborationDone($oDocument->getID()) &&
481   - ( ($_SESSION["userID"] == DocumentCollaboration::getLastCollaboratorID($oDocument->getID())) || Permission::userIsSystemAdministrator() ) ) {
482   - $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
  465 + if (DocumentCollaboration::documentCollaborationDone($oDocument->getID())) {
  466 + if ( !($_SESSION["userID"] == DocumentCollaboration::getLastCollaboratorID($oDocument->getID())) && !Permission::userIsSystemAdministrator() ) {
  467 + $sDisabledText = "You are not the last collaborator and hence cannot publish this document";
  468 + }
  469 + } else {
  470 + $sDisabledText = "You cannot publish this document until collaboration is complete";
483 471 }
484   - } else if ( ($_SESSION["userID"] == $oDocument->getCreatorID()) || Permission::userIsSystemAdministrator() ) {
485   - // no collaboration for this folder, so only the creator (or an administrator) can request publication
486   - $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n";
  472 + } else {
  473 + // no collaboration, check the user permissions
  474 + if ( !($_SESSION["userID"] == $oDocument->getCreatorID()) && !Permission::userIsSystemAdministrator() ) {
  475 + $sDisabledText = "You do not have permission to publish this document.";
  476 + }
487 477 }
488 478 } else {
489 479 $sDisabledText = "This document is already published.";
490 480 }
491   - // FIXME: need to disabled publish button
492   - return "<tr><td align=\"left\">" . displayButton("archiveDocument", "fDocumentID=" . $oDocument->getID(), "archive", $sDisabledText) . "</td></tr>\n";
  481 + return "<tr><td align=\"left\">" . displayButton("viewDocument", "fDocumentID=" . $oDocument->getID() . "&fForPublish=1", "publish", $sDisabledText) . "</td></tr>\n";
493 482 }
494   -*/
495 483  
496 484 function displayActionButtons($oDocument, $bEdit) {
497 485 $sToRender .= displayViewButton($oDocument, $bEdit);
... ... @@ -504,14 +492,8 @@ function displayActionButtons($oDocument, $bEdit) {
504 492 $sToRender .= displayDiscussionButton($oDocument, $bEdit);
505 493 $sToRender .= displayArchiveButton($oDocument, $bEdit);
506 494 $sToRender .= displayDependantDocumentButton($oDocument, $bEdit);
507   - // FIXME: need disabled publish button
508   - //$sToRender .= displayPublishButton($oDocument, $bEdit);
  495 + $sToRender .= displayPublishButton($oDocument, $bEdit);
509 496  
510   - $iDummyButtons = 1;
511   - // spacing hack
512   - for ($i=0; $i<$iDummyButtons; $i++) {
513   - $sToRender .= "<tr><td align=\"left\">&nbsp;</td></tr>\n";
514   - }
515 497 return $sToRender;
516 498 }
517 499  
... ...