diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc index 4890a6a..5cd348c 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc @@ -345,78 +345,173 @@ function renderNonEditableLinkedDocuments($oDocument) { return $sToRender; } -function displayButton($sControllerLink, $sQueryString, $sImageName, $bActive, $sInactiveTooltip = "") { +function displayButton($sAction, $sQueryString, $sImageName, $sDisabledText = "") { + global $default; + + // the active is active if there is no disabled text + $bActive = !strlen($sDisabledText) > 0; $sImage = "graphicsUrl/widgets/docactions/"; if ($bActive) { $sImage .= "$sImageName.gif\""; } else { - $sImage .= "disabled-$sImageName.gif\" alt=\"$sInactiveTooltip\""; + $sImage .= "disabled-$sImageName.gif\" alt=\"$sDisabledText\""; } $sImage .= "/>"; - return generateControllerLink($sControllerLink, $sQueryString, $sImage); + if ($bActive) { + return generateControllerLink($sAction, $sQueryString, $sImage); + } else { + return $sImage; + } } -function displayActionButtons($oDocument, $bEdit) { - global $default; - - $iDummyButtons = 2; - - // view - $sToRender .= "graphicsUrl/widgets/docactions/view.gif\" border=\"0\" alt=\"View the document\"/>\n"; +function displayViewButton($oDocument, $bEdit) { + global $default; + $sViewAlert = "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 "graphicsUrl/widgets/docactions/view.gif\" border=\"0\" alt=\"View the document\"/>\n"; +} + +function displayCheckInOutButton($oDocument, $bEdit) { if ($bEdit) { + $sQueryString = "fDocumentID=" . $oDocument->getID(); // display the check in button if the document is checked out and you checked the document out - if ($oDocument->getIsCheckedOut() && ($oDocument->getCheckedOutUserID() == $_SESSION["userID"])) { - $sToRender .= "graphicsUrl/widgets/docactions/checkin.gif\" border=\"0\" />\n"; + if ($oDocument->getIsCheckedOut()) { + if ($oDocument->getCheckedOutUserID() == $_SESSION["userID"]) { + $sAction = "checkInDocument"; + $sImageName = "checkin"; + } else { + $oUser = User::get($oDocument->getCheckedOutUserID()); + $sDisabledText = "The document can only be checked back in by " . $oUser->getName(); + } // otherwise display the check out button } else { - $sToRender .= "graphicsUrl/widgets/docactions/checkout.gif\" border=\"0\" />\n"; + $sAction = "checkOutDocument"; + $sImageName = "checkout"; } } else { - // display spacing button - $iDummyButtons++; + $sDisabledText = "You do not have write access to this document"; } - - $sToRender .= "graphicsUrl/widgets/docactions/email.gif\" border=\"0\" />\n"; - if ($bEdit && !$oDocument->getIsCheckedOut()) { - $sToRender .= "graphicsUrl/widgets/docactions/delete.gif\" border=\"0\" />\n"; + return "" . displayButton($sAction, $sQueryString, $sImageName, $sDisabledText) . "\n"; +} + +function displayEmailButton($oDocument) { + global $default; + return "graphicsUrl/widgets/docactions/email.gif\" border=\"0\" />\n"; +} + +function displayDeleteButton($oDocument, $bEdit) { + if ($bEdit) { + $sQueryString = "fDocumentID=" . $oDocument->getID(); + if ($oDocument->getIsCheckedOut()) { + $sDisabledText = "This document can't be deleted because its checked out"; + } } else { - $iDummyButtons++; + $sDisabledText = "You do not have write access to this document"; } - - $sToRender .= "graphicsUrl/widgets/docactions/history.gif\" border=\"0\" />\n"; + return "" . displayButton("deleteDocument", $sQueryString, "delete", $sDisabledText) . "\n"; +} + +function displayHistoryButton($oDocument) { + global $default; + return "graphicsUrl/widgets/docactions/history.gif\" border=\"0\" />\n"; +} +function displayMoveButton($oDocument, $bEdit) { if ($bEdit) { + $sQueryString = "fFolderID=" . $oDocument->getFolderID() . "&fDocumentID=" . $oDocument->getID(); // documents in collaboration and checked out documents can't be moved - if (!$oDocument->getIsCheckedOut() && (!DocumentCollaboration::documentCollaborationStarted($oDocument->getID()))) { - $sToRender .= "graphicsUrl/widgets/docactions/move.gif\" border=\"0\" />\n"; + if ($oDocument->getIsCheckedOut()) { + $sDisabledText = "The document is checked out"; + } + if (DocumentCollaboration::documentCollaborationStarted($oDocument->getID())) { + $sDisabledText = "The document is in collaboration"; } } else { - $iDummyButtons++; + $sDisabledText = "You do not have write access to this document"; } - + return "" . displayButton("moveDocument", $sQueryString, "move", $sDisabledText) . "\n"; +} + +function displaySubscriptionButton($oDocument) { // display the unsubscribe button if the user is subscribed to the document if (Subscription::exists($_SESSION["userID"], $oDocument->getID(), SubscriptionConstants::subscriptionType("DocumentSubscription"))) { - $sToRender .= "graphicsUrl/widgets/docactions/unsubscribe.gif\" border=\"0\" />\n"; + $sAction = "removeSubscription"; + $sImageName = "unsubscribe"; // otherwise display the subscribe button } else { - $sToRender .= "graphicsUrl/widgets/docactions/subscribe.gif\" border=\"0\" />\n"; - } - $sToRender .= "graphicsUrl/widgets/docactions/discussion.gif\" border=\"0\" />\n"; + $sAction = "addSubscription"; + $sImageName = "subscribe"; + } + return "" . displayButton($sAction, "fDocumentID=" . $oDocument->getID(), $sImageName) . "\n"; +} + +function displayDiscussionButton($oDocument, $bEdit) { + global $default; + return "graphicsUrl/widgets/docactions/discussion.gif\" border=\"0\" />\n"; +} + +function displayArchiveButton($oDocument, $bEdit) { // only display the archive button for available documents // if the document is not checked out // and if the document is not in collaboration - if (!$oDocument->getIsCheckedOut() && (!$oDocument->hasCollaboration() || !DocumentCollaboration::documentCollaborationStarted($oDocument->getID()))) { - $sToRender .= "graphicsUrl/widgets/docactions/archive.gif\" border=\"0\" />\n"; + if ($bEdit) { + if (!$oDocument->getIsCheckedOut()) { + if ($oDocument->hasCollaboration() || DocumentCollaboration::documentCollaborationStarted($oDocument->getID())) { + $sDisabledText = "This document is in collaboration and cannot be archived"; + } + } else { + $sDisabledText = "This document is checked out and cannot be archived."; + } } else { - $iDummyButtons++; + $sDisabledText = "You do not have write access to this document"; } - - $sToRender .= "graphicsUrl/widgets/docactions/dependentdoc.gif\" border=\"0\" />\n"; + return "" . displayButton("archiveDocument", "fDocumentID=" . $oDocument->getID(), "archive", $sDisabledText) . "\n"; +} +function displayDependantDocumentButton($oDocument, $bEdit) { + global $default; + return "graphicsUrl/widgets/docactions/dependentdoc.gif\" border=\"0\" />\n"; +} + +/* +function displayPublishButton($oDocument, $bEdit) { + // only display the publish button for unpublished documents + if (!DocumentCollaboration::documentIsPendingWebPublishing($oDocument->getID())) { + // if there is collaboration + if ($oDocument->hasCollaboration()) { + // only display publish button if collaboration is complete and you're the last user in the collaboration process (or a sysadmin) + if (DocumentCollaboration::documentCollaborationDone($oDocument->getID()) && + ( ($_SESSION["userID"] == DocumentCollaboration::getLastCollaboratorID($oDocument->getID())) || Permission::userIsSystemAdministrator() ) ) { + $sToRender .= "graphicsUrl/widgets/publish.gif\" border=\"0\"/>\n"; + } + } else if ( ($_SESSION["userID"] == $oDocument->getCreatorID()) || Permission::userIsSystemAdministrator() ) { + // no collaboration for this folder, so only the creator (or an administrator) can request publication + $sToRender .= "graphicsUrl/widgets/publish.gif\" border=\"0\"/>\n"; + } + } else { + $sDisabledText = "This document is already published."; + } + // FIXME: need to disabled publish button + return "" . displayButton("archiveDocument", "fDocumentID=" . $oDocument->getID(), "archive", $sDisabledText) . "\n"; +} +*/ + +function displayActionButtons($oDocument, $bEdit) { + $sToRender .= displayViewButton($oDocument, $bEdit); + $sToRender .= displayEmailButton($oDocument); + $sToRender .= displayDeleteButton($oDocument, $bEdit); + $sToRender .= displayHistoryButton($oDocument); + $sToRender .= displayMoveButton($oDocument, $bEdit); + $sToRender .= displaySubscriptionButton($oDocument); + $sToRender .= displayDiscussionButton($oDocument, $bEdit); + $sToRender .= displayArchiveButton($oDocument, $bEdit); + $sToRender .= displayDependantDocumentButton($oDocument, $bEdit); + // FIXME: need disabled publish button + //$sToRender .= displayPublishButton($oDocument, $bEdit); + + $iDummyButtons = 1; // spacing hack for ($i=0; $i<$iDummyButtons; $i++) { $sToRender .= " \n"; - } - + } return $sToRender; }