Commit 797a90bd0e47a391acf0bdc5e3d8eb6ca47138a8
1 parent
6d0ed5d0
(#2677) Grey out buttons that aren't accessible with explanatory tooltips
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2431 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
132 additions
and
37 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc
| ... | ... | @@ -345,78 +345,173 @@ function renderNonEditableLinkedDocuments($oDocument) { |
| 345 | 345 | return $sToRender; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | -function displayButton($sControllerLink, $sQueryString, $sImageName, $bActive, $sInactiveTooltip = "") { | |
| 348 | +function displayButton($sAction, $sQueryString, $sImageName, $sDisabledText = "") { | |
| 349 | + global $default; | |
| 350 | + | |
| 351 | + // the active is active if there is no disabled text | |
| 352 | + $bActive = !strlen($sDisabledText) > 0; | |
| 349 | 353 | $sImage = "<img border=\"0\" src=\"$default->graphicsUrl/widgets/docactions/"; |
| 350 | 354 | if ($bActive) { |
| 351 | 355 | $sImage .= "$sImageName.gif\""; |
| 352 | 356 | } else { |
| 353 | - $sImage .= "disabled-$sImageName.gif\" alt=\"$sInactiveTooltip\""; | |
| 357 | + $sImage .= "disabled-$sImageName.gif\" alt=\"$sDisabledText\""; | |
| 354 | 358 | } |
| 355 | 359 | $sImage .= "/>"; |
| 356 | - return generateControllerLink($sControllerLink, $sQueryString, $sImage); | |
| 360 | + if ($bActive) { | |
| 361 | + return generateControllerLink($sAction, $sQueryString, $sImage); | |
| 362 | + } else { | |
| 363 | + return $sImage; | |
| 364 | + } | |
| 357 | 365 | } |
| 358 | 366 | |
| 359 | -function displayActionButtons($oDocument, $bEdit) { | |
| 360 | - global $default; | |
| 361 | - | |
| 362 | - $iDummyButtons = 2; | |
| 363 | - | |
| 364 | - // view | |
| 365 | - $sToRender .= "<tr><td align=\"left\"><a onClick=\"alert('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 true;\" href=\"" . generateControllerLink("downloadDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/view.gif\" border=\"0\" alt=\"View the document\"/></a></td></tr>\n"; | |
| 367 | +function displayViewButton($oDocument, $bEdit) { | |
| 368 | + global $default; | |
| 369 | + $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."; | |
| 370 | + return "<tr><td align=\"left\"><a onClick=\"alert('$sViewAlert '); return true;\" href=\"" . generateControllerLink("downloadDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/view.gif\" border=\"0\" alt=\"View the document\"/></a></td></tr>\n"; | |
| 371 | +} | |
| 372 | + | |
| 373 | +function displayCheckInOutButton($oDocument, $bEdit) { | |
| 366 | 374 | if ($bEdit) { |
| 375 | + $sQueryString = "fDocumentID=" . $oDocument->getID(); | |
| 367 | 376 | // display the check in button if the document is checked out and you checked the document out |
| 368 | - if ($oDocument->getIsCheckedOut() && ($oDocument->getCheckedOutUserID() == $_SESSION["userID"])) { | |
| 369 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("checkInDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/checkin.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 377 | + if ($oDocument->getIsCheckedOut()) { | |
| 378 | + if ($oDocument->getCheckedOutUserID() == $_SESSION["userID"]) { | |
| 379 | + $sAction = "checkInDocument"; | |
| 380 | + $sImageName = "checkin"; | |
| 381 | + } else { | |
| 382 | + $oUser = User::get($oDocument->getCheckedOutUserID()); | |
| 383 | + $sDisabledText = "The document can only be checked back in by " . $oUser->getName(); | |
| 384 | + } | |
| 370 | 385 | // otherwise display the check out button |
| 371 | 386 | } else { |
| 372 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("checkOutDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/checkout.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 387 | + $sAction = "checkOutDocument"; | |
| 388 | + $sImageName = "checkout"; | |
| 373 | 389 | } |
| 374 | 390 | } else { |
| 375 | - // display spacing button | |
| 376 | - $iDummyButtons++; | |
| 391 | + $sDisabledText = "You do not have write access to this document"; | |
| 377 | 392 | } |
| 378 | - | |
| 379 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("emailDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/email.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 380 | - if ($bEdit && !$oDocument->getIsCheckedOut()) { | |
| 381 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("deleteDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/delete.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 393 | + return "<tr><td align=\"left\">" . displayButton($sAction, $sQueryString, $sImageName, $sDisabledText) . "</td></tr>\n"; | |
| 394 | +} | |
| 395 | + | |
| 396 | +function displayEmailButton($oDocument) { | |
| 397 | + global $default; | |
| 398 | + return "<tr><td align=\"left\"><a href=\"" . generateControllerLink("emailDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/email.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 399 | +} | |
| 400 | + | |
| 401 | +function displayDeleteButton($oDocument, $bEdit) { | |
| 402 | + if ($bEdit) { | |
| 403 | + $sQueryString = "fDocumentID=" . $oDocument->getID(); | |
| 404 | + if ($oDocument->getIsCheckedOut()) { | |
| 405 | + $sDisabledText = "This document can't be deleted because its checked out"; | |
| 406 | + } | |
| 382 | 407 | } else { |
| 383 | - $iDummyButtons++; | |
| 408 | + $sDisabledText = "You do not have write access to this document"; | |
| 384 | 409 | } |
| 385 | - | |
| 386 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("viewHistory", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/history.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 410 | + return "<tr><td align=\"left\">" . displayButton("deleteDocument", $sQueryString, "delete", $sDisabledText) . "</td></tr>\n"; | |
| 411 | +} | |
| 412 | + | |
| 413 | +function displayHistoryButton($oDocument) { | |
| 414 | + global $default; | |
| 415 | + return "<tr><td align=\"left\"><a href=\"" . generateControllerLink("viewHistory", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/history.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 416 | +} | |
| 417 | +function displayMoveButton($oDocument, $bEdit) { | |
| 387 | 418 | if ($bEdit) { |
| 419 | + $sQueryString = "fFolderID=" . $oDocument->getFolderID() . "&fDocumentID=" . $oDocument->getID(); | |
| 388 | 420 | // documents in collaboration and checked out documents can't be moved |
| 389 | - if (!$oDocument->getIsCheckedOut() && (!DocumentCollaboration::documentCollaborationStarted($oDocument->getID()))) { | |
| 390 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("moveDocument", "fFolderID=" . $oDocument->getFolderID() . "&fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/move.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 421 | + if ($oDocument->getIsCheckedOut()) { | |
| 422 | + $sDisabledText = "The document is checked out"; | |
| 423 | + } | |
| 424 | + if (DocumentCollaboration::documentCollaborationStarted($oDocument->getID())) { | |
| 425 | + $sDisabledText = "The document is in collaboration"; | |
| 391 | 426 | } |
| 392 | 427 | } else { |
| 393 | - $iDummyButtons++; | |
| 428 | + $sDisabledText = "You do not have write access to this document"; | |
| 394 | 429 | } |
| 395 | - | |
| 430 | + return "<tr><td align=\"left\">" . displayButton("moveDocument", $sQueryString, "move", $sDisabledText) . "</td></tr>\n"; | |
| 431 | +} | |
| 432 | + | |
| 433 | +function displaySubscriptionButton($oDocument) { | |
| 396 | 434 | // display the unsubscribe button if the user is subscribed to the document |
| 397 | 435 | if (Subscription::exists($_SESSION["userID"], $oDocument->getID(), SubscriptionConstants::subscriptionType("DocumentSubscription"))) { |
| 398 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("removeSubscription", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/unsubscribe.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 436 | + $sAction = "removeSubscription"; | |
| 437 | + $sImageName = "unsubscribe"; | |
| 399 | 438 | // otherwise display the subscribe button |
| 400 | 439 | } else { |
| 401 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("addSubscription", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/subscribe.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 402 | - } | |
| 403 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("viewDiscussion", "fDocumentID=" . $oDocument->getID() . "&fForDiscussion=1") . "\"><img src=\"$default->graphicsUrl/widgets/docactions/discussion.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 440 | + $sAction = "addSubscription"; | |
| 441 | + $sImageName = "subscribe"; | |
| 442 | + } | |
| 443 | + return "<tr><td align=\"left\">" . displayButton($sAction, "fDocumentID=" . $oDocument->getID(), $sImageName) . "</td></tr>\n"; | |
| 444 | +} | |
| 445 | + | |
| 446 | +function displayDiscussionButton($oDocument, $bEdit) { | |
| 447 | + global $default; | |
| 448 | + return "<tr><td align=\"left\"><a href=\"" . generateControllerLink("viewDiscussion", "fDocumentID=" . $oDocument->getID() . "&fForDiscussion=1") . "\"><img src=\"$default->graphicsUrl/widgets/docactions/discussion.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 449 | +} | |
| 450 | + | |
| 451 | +function displayArchiveButton($oDocument, $bEdit) { | |
| 404 | 452 | // only display the archive button for available documents |
| 405 | 453 | // if the document is not checked out |
| 406 | 454 | // and if the document is not in collaboration |
| 407 | - if (!$oDocument->getIsCheckedOut() && (!$oDocument->hasCollaboration() || !DocumentCollaboration::documentCollaborationStarted($oDocument->getID()))) { | |
| 408 | - $sToRender .= "<tr><td align=\"left\"><a href=\"" . generateControllerLink("archiveDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/archive.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 455 | + if ($bEdit) { | |
| 456 | + if (!$oDocument->getIsCheckedOut()) { | |
| 457 | + if ($oDocument->hasCollaboration() || DocumentCollaboration::documentCollaborationStarted($oDocument->getID())) { | |
| 458 | + $sDisabledText = "This document is in collaboration and cannot be archived"; | |
| 459 | + } | |
| 460 | + } else { | |
| 461 | + $sDisabledText = "This document is checked out and cannot be archived."; | |
| 462 | + } | |
| 409 | 463 | } else { |
| 410 | - $iDummyButtons++; | |
| 464 | + $sDisabledText = "You do not have write access to this document"; | |
| 411 | 465 | } |
| 412 | - | |
| 413 | - $sToRender .= "<td align=\"left\"><a href=\"" . generateControllerLink("createDependantDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/dependentdoc.gif\" border=\"0\" /></a></td>\n"; | |
| 466 | + return "<tr><td align=\"left\">" . displayButton("archiveDocument", "fDocumentID=" . $oDocument->getID(), "archive", $sDisabledText) . "</td></tr>\n"; | |
| 467 | +} | |
| 414 | 468 | |
| 469 | +function displayDependantDocumentButton($oDocument, $bEdit) { | |
| 470 | + global $default; | |
| 471 | + return "<td align=\"left\"><a href=\"" . generateControllerLink("createDependantDocument", "fDocumentID=" . $oDocument->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/docactions/dependentdoc.gif\" border=\"0\" /></a></td>\n"; | |
| 472 | +} | |
| 473 | + | |
| 474 | +/* | |
| 475 | +function displayPublishButton($oDocument, $bEdit) { | |
| 476 | + // only display the publish button for unpublished documents | |
| 477 | + if (!DocumentCollaboration::documentIsPendingWebPublishing($oDocument->getID())) { | |
| 478 | + // if there is collaboration | |
| 479 | + if ($oDocument->hasCollaboration()) { | |
| 480 | + // only display publish button if collaboration is complete and you're the last user in the collaboration process (or a sysadmin) | |
| 481 | + if (DocumentCollaboration::documentCollaborationDone($oDocument->getID()) && | |
| 482 | + ( ($_SESSION["userID"] == DocumentCollaboration::getLastCollaboratorID($oDocument->getID())) || Permission::userIsSystemAdministrator() ) ) { | |
| 483 | + $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n"; | |
| 484 | + } | |
| 485 | + } else if ( ($_SESSION["userID"] == $oDocument->getCreatorID()) || Permission::userIsSystemAdministrator() ) { | |
| 486 | + // no collaboration for this folder, so only the creator (or an administrator) can request publication | |
| 487 | + $sToRender .= "<td><a href=" . $_SERVER['PHP_SELF'] . "?fDocumentID=" . $oDocument->getID() . "&fForPublish=1><img src=\"$default->graphicsUrl/widgets/publish.gif\" border=\"0\"/></a></td>\n"; | |
| 488 | + } | |
| 489 | + } else { | |
| 490 | + $sDisabledText = "This document is already published."; | |
| 491 | + } | |
| 492 | + // FIXME: need to disabled publish button | |
| 493 | + return "<tr><td align=\"left\">" . displayButton("archiveDocument", "fDocumentID=" . $oDocument->getID(), "archive", $sDisabledText) . "</td></tr>\n"; | |
| 494 | +} | |
| 495 | +*/ | |
| 496 | + | |
| 497 | +function displayActionButtons($oDocument, $bEdit) { | |
| 498 | + $sToRender .= displayViewButton($oDocument, $bEdit); | |
| 499 | + $sToRender .= displayEmailButton($oDocument); | |
| 500 | + $sToRender .= displayDeleteButton($oDocument, $bEdit); | |
| 501 | + $sToRender .= displayHistoryButton($oDocument); | |
| 502 | + $sToRender .= displayMoveButton($oDocument, $bEdit); | |
| 503 | + $sToRender .= displaySubscriptionButton($oDocument); | |
| 504 | + $sToRender .= displayDiscussionButton($oDocument, $bEdit); | |
| 505 | + $sToRender .= displayArchiveButton($oDocument, $bEdit); | |
| 506 | + $sToRender .= displayDependantDocumentButton($oDocument, $bEdit); | |
| 507 | + // FIXME: need disabled publish button | |
| 508 | + //$sToRender .= displayPublishButton($oDocument, $bEdit); | |
| 509 | + | |
| 510 | + $iDummyButtons = 1; | |
| 415 | 511 | // spacing hack |
| 416 | 512 | for ($i=0; $i<$iDummyButtons; $i++) { |
| 417 | 513 | $sToRender .= "<tr><td align=\"left\"> </td></tr>\n"; |
| 418 | - } | |
| 419 | - | |
| 514 | + } | |
| 420 | 515 | return $sToRender; |
| 421 | 516 | } |
| 422 | 517 | ... | ... |