Commit 8a609c16a216ad7ee393b80e46891cbd3724b9cd

Authored by michael
1 parent 6cc5b5da

(#2763) tidied and refactored, don't display check box when checking document ba…

…ck in, just display confirmation page


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2468 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/doccheckoutmanagement/editDocCheckoutBL.php
... ... @@ -27,41 +27,30 @@ if (checkSession()) {
27 27 global $default;
28 28 $oPatternCustom = & new PatternCustom();
29 29  
30   - $oPatternCustom->addHtml(renderHeading("Edit Document Checkout"));
31   -
32   - if (isset($fDocID)){
  30 + if (isset($fDocumentID)) {
33 31 if (isset($fUpdate)) {
34   - $oDocument = Document::get($fDocID);
35   -
36   - if (($oDocument->getIsCheckedOut() > 0 && $fDocCheckout=="on" ) ||
37   - ($oDocument->getIsCheckedOut() == 0 && $fDocCheckout=="" )){
38   - $main->setErrorMessage("No changes were made to the document checkout.");
39   - } else {
40   - if ($fDocCheckout=="on"){
41   - $oDocument->setIsCheckedOut(1);
  32 + $oDocument = Document::get($fDocumentID);
  33 + $oDocument->setIsCheckedOut(0);
  34 + $oDocument->setCheckedOutUserID(-1);
  35 + if ($oDocument->update()) {
  36 + // checkout cancelled transaction
  37 + $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), "Document checked out cancelled", FORCE_CHECKIN);
  38 + if ($oDocumentTransaction->create()) {
  39 + $default->log->debug("editDocCheckoutBL.php created forced checkin document transaction for document ID=" . $oDocument->getID());
42 40 } else {
43   - $oDocument->setIsCheckedOut(0);
44   - $oDocument->setCheckedOutUserID(-1);
45   - }
46   - if ($oDocument->update()){
47   - // checkout cancelled transaction
48   - $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), "Document checked out cancelled", FORCE_CHECKIN);
49   - if ($oDocumentTransaction->create()) {
50   - $default->log->debug("editDocCheckoutBL.php created forced checkin document transaction for document ID=" . $oDocument->getID());
51   - } else {
52   - $default->log->error("editDocCheckoutBL.php couldn't create create document transaction for document ID=" . $oDocument->getID());
53   - }
54   - $oPatternCustom->addHtml(getEditCheckoutSuccessPage());
55   - } else {
56   - $main->setErrorMessage("Error while trying to update the document checkout.");
57   - }
58   - }
  41 + $default->log->error("editDocCheckoutBL.php couldn't create create document transaction for document ID=" . $oDocument->getID());
  42 + }
  43 + $oPatternCustom->setHtml(getEditCheckoutSuccessPage());
  44 + } else {
  45 + $oPatternCustom->setHtml(getErrorPage("Error while trying to update the document checkout."));
  46 + }
59 47 } else {
60   - $oPatternCustom->addHtml($fDocCheckout . getEditCheckoutPage($fDocID));
61   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fUpdate=1&fDocID=$fDocID");
  48 + $oPatternCustom->addHtml(getEditCheckoutPage($fDocumentID));
  49 + $main->setFormAction($_SERVER["PHP_SELF"]);
62 50 }
63 51 } else {
64 52 // no document selected
  53 + $oPatternCustom->setHtml(getErrorPage("No document selected to check back in"));
65 54 }
66 55 //render the page
67 56 $main->setCentralPayload($oPatternCustom);
... ...
presentation/lookAndFeel/knowledgeTree/administration/doccheckoutmanagement/editDocCheckoutUI.inc
... ... @@ -8,39 +8,25 @@
8 8 *
9 9 */
10 10  
11   -
12 11 function getEditCheckoutSuccessPage(){
13 12 global $default;
14   -
15   - $sToRender .= "Succesfully updated document checkout.\n";
16   - $sToRender .= "<a href=\"$default->rootUrl/control.php?action=listDocs\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a>";
17   -
18   - return $sToRender;
19   -
  13 + return statusPage("Edit Document Checkout", "Succesfully updated document checkout.", "", "listDocs");
20 14 }
21 15  
22   -function getEditCheckoutPage($fDocID){
  16 +function getErrorPage($sMessage) {
  17 + return statusPage("Edit Document Checkout", "Error checking in document", $sMessage, "listDocs");
  18 +}
  19 +
  20 +function getEditCheckoutPage($fDocumentID){
23 21 global $default;
24 22  
25   - $oDoc = Document::get($fDocID);
26   -
  23 + $oDocument = Document::get($fDocumentID);
  24 + $sToRender .= renderHeading("Edit Document Checkout");
27 25 $sToRender .= "<table>\n";
28   - $sToRender .= "<tr>\n";
29   - $sToRender .= "<td>\n";
30   - $sToRender .= "<b>Document Name: </b>" . $oDoc->getName();
31   - $sToRender .= "</td>\n";
32   - $sToRender .= "</tr>\n";
33   - $sToRender .= "<tr>\n";
34   - $sToRender .= "<td>\n";
35   - $sToRender .= "<b>Checked out?: </b>";
36   -
37   - if($oDoc->getIsCheckedOut() > 0){
38   - $bCheckedOut = "checked";
39   - }
40   - $sToRender .= "<input type=checkbox $bCheckedOut name=fDocCheckout>";
41   -
42   - $sToRender .= "</td>\n";
43   - $sToRender .= "</tr>\n";
  26 + $sToRender .= "<tr><td>Are you sure you want to Check In this document:</tr></td>";
  27 + $sToRender .= "<tr><td><b>" . $oDocument->getDisplayPath() . "</b></td></tr>";
  28 + $sToRender .= "<input type=\"hidden\" name=\"fUpdate\" value=\"1\">\n";
  29 + $sToRender .= "<input type=\"hidden\" name=\"fDocumentID\" value=\"$fDocumentID\">\n";
44 30 $sToRender .= "<tr>\n";
45 31 $sToRender .= "<td align=right>\n";
46 32 $sToRender .= getUpdateButton();
... ... @@ -50,22 +36,18 @@ function getEditCheckoutPage($fDocID){
50 36 $sToRender .= "</td>\n";
51 37 $sToRender .= "</tr>\n";
52 38 $sToRender .= "</table>\n";
53   -
54 39 return $sToRender;
55   -
56 40 }
57 41  
58 42 // gets the updatebutton when a unit is selected
59 43 function getUpdateButton() {
60 44 global $default;
61   -
62 45 return "<input type=\"image\" src =\"$default->graphicsUrl/widgets/update.gif\" value=\"submit\" border=\"0\"/>\n";
63 46 }
64 47  
65 48 // gets the cancel button when a unit is selected
66 49 function getCancelButton() {
67 50 global $default;
68   -
69 51 return "<a href=\"$default->rootUrl/control.php?action=listDocs\"><img src =\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a>\n";
70 52 }
71 53  
... ...
presentation/lookAndFeel/knowledgeTree/administration/doccheckoutmanagement/listDocumentsBL.php
... ... @@ -8,59 +8,38 @@
8 8 *
9 9 */
10 10  
11   - require_once("../../../../../config/dmsDefaults.php");
12   -
13   -if (checkSession()) {
14   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
15   - //require_once("listOrgUI.inc");
16   - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
17   - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
18   - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
19   - require_once("$default->fileSystemRoot/lib/users/User.inc");
20   - require_once("$default->fileSystemRoot/lib/security/permission.inc");
21   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
22   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
23   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
24   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");
25   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
26   - require_once("$default->fileSystemRoot/lib/discussions/DiscussionThread.inc");
27   - require_once("$default->fileSystemRoot/lib/discussions/DiscussionComment.inc");
28   - require_once("$default->fileSystemRoot/presentation/Html.inc");
29   -
  11 +require_once("../../../../../config/dmsDefaults.php");
  12 +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  13 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  14 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  15 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  16 +require_once("$default->fileSystemRoot/presentation/Html.inc");
30 17  
31   - $oPatternCustom = & new PatternCustom();
32   -
33   -if(checkSession()) {
  18 +if (checkSession()) {
34 19  
35   - $oPatternCustom->addHtml(renderHeading("Checked out Documents")); // Create the Heading
36   -
37   -
38   - $main->setFormAction($_SERVER['PHP_SELF']);
39   -
40   - $sQuery = "SELECT documents.id as DocId, documents.name as Name, documents.filename as File, " .
41   - "CASE WHEN users.name Is Null THEN '<font color=blue>* No one</font>' ELSE users.name END AS UserName, " .
42   - "'Check In' " .
43   - "FROM documents left join users " .
44   - "on documents.checked_out_user_id = users.id " .
45   - "WHERE documents.is_checked_out = 1";
  20 + $oPatternCustom = & new PatternCustom();
  21 + $aDocuments = Document::getList("is_checked_out = 1");
  22 + $sToRender .= renderHeading("Checked out Documents");
  23 + $sToRender .= "<table><tr><th width=\"80\">Document</th><th>Checked Out By</th><th>&nbsp;</th>";
  24 + if (count($aDocuments) > 0) {
  25 + for ($i=0; $i<count($aDocuments); $i++) {
  26 + if ($aDocuments[$i]) {
  27 + $oUser = User::get($aDocuments[$i]->getCheckedOutUserID());
  28 + $sToRender .= "<tr><td>" . $aDocuments[$i]->getDisplayPath() . "</td>";
  29 + $sToRender .= "<td>" . $oUser->getName() . "</td>";
  30 + $sToRender .= "<td>" . generateControllerLink("editDocCheckout", "fDocumentID=" . $aDocuments[$i]->getID(), "Check In") . "</td>";
  31 + }
  32 + }
  33 + } else {
  34 + $sToRender .= "<tr><td colspan=\"3\">There are no checked out document</td></tr>";
  35 + }
  36 + $sToRender .= "</table>";
46 37  
47   - $aColumns = array("Name", "File", "UserName", "Check In");
48   - $aColumnNames = array("Name", "File", "Checked Out by", "");
49   - $aColumnTypes = array(1,1,1,3);
50   - $aDBColumnArray = array("DocId");
51   - $aQueryStringVariableNames = array("fDocID");
52   -
53   - $aHyperLinkURL = array( 3=> "$default->rootUrl/control.php?action=editDocCheckout");
54   -
55   - $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
56   - $oSearchResults->setDisplayColumnHeadings(true);
57   - $oSearchResults->setEmptyTableMessage("No checked out documents");
58   -
59   - $oPatternCustom->addHtml($oSearchResults->render());
60   -
61   - } // end of if checksession
62   -
  38 + $oPatternCustom->setHtml($sToRender);
  39 +
  40 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
63 41 $main->setCentralPayload($oPatternCustom);
  42 + $main->setFormAction($_SERVER['PHP_SELF']);
64 43 $main->render();
65 44 }
66 45 -?>
  46 +?>
67 47 \ No newline at end of file
... ...