Commit f92a7febf3415c2cd0fd7254cd5e4e7aabf18222
1 parent
b6e51ea6
moved searching capability from the pattern
passing document objects inserted hook for user notification on document restoration git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2082 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
39 additions
and
11 deletions
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/archivedDocumentsUI.inc
| @@ -107,20 +107,18 @@ function renderSearchPage($aMetaTagIDs = array()) { | @@ -107,20 +107,18 @@ function renderSearchPage($aMetaTagIDs = array()) { | ||
| 107 | /** | 107 | /** |
| 108 | * Performs the search and displays the results | 108 | * Performs the search and displays the results |
| 109 | */ | 109 | */ |
| 110 | -function renderArchivedDocumentsResultsPage($sDocumentIDs) { | 110 | +function renderArchivedDocumentsResultsPage($aDocuments) { |
| 111 | global $default; | 111 | global $default; |
| 112 | 112 | ||
| 113 | - $aDocumentIDs = explode(",", $sDocumentIDs); | ||
| 114 | $sToRender = renderHeading("Archived Documents Search Results"); | 113 | $sToRender = renderHeading("Archived Documents Search Results"); |
| 115 | $sToRender .= "<table>"; | 114 | $sToRender .= "<table>"; |
| 116 | $sToRender .= "<tr><td>Select the archived documents you'd like to restore, and click 'Restore', or 'Cancel' to abort</td></tr>\n"; | 115 | $sToRender .= "<tr><td>Select the archived documents you'd like to restore, and click 'Restore', or 'Cancel' to abort</td></tr>\n"; |
| 117 | - for ($i=0; $i<count($aDocumentIDs); $i++) { | 116 | + for ($i=0; $i<count($aDocuments); $i++) { |
| 118 | // and print document paths with checkboxes | 117 | // and print document paths with checkboxes |
| 119 | - $oDocument = Document::get($aDocumentIDs[$i]); | ||
| 120 | $sToRender .= "\t<tr>\n"; | 118 | $sToRender .= "\t<tr>\n"; |
| 121 | $sToRender .= "\t\t<td bgcolor=\"" . getColour($i) . "\">\n"; | 119 | $sToRender .= "\t\t<td bgcolor=\"" . getColour($i) . "\">\n"; |
| 122 | - $sToRender .= "<input type=\"checkbox\" name=\"fDocumentIDs[]\" value=\"" . $oDocument->getID() . "\"/>\n"; | ||
| 123 | - $sToRender .= $oDocument->getDisplayPath() . "\n"; | 120 | + $sToRender .= "<input type=\"checkbox\" name=\"fDocumentIDs[]\" value=\"" . $aDocuments[$i]->getID() . "\"/>\n"; |
| 121 | + $sToRender .= $aDocuments[$i]->getDisplayPath() . "\n"; | ||
| 124 | $sToRender .= "\t\t</td>\n"; | 122 | $sToRender .= "\t\t</td>\n"; |
| 125 | $sToRender .= "\t</tr>\n"; | 123 | $sToRender .= "\t</tr>\n"; |
| 126 | } | 124 | } |
presentation/lookAndFeel/knowledgeTree/administration/documentmanagement/manageArchivedDocumentsBL.php
| @@ -36,10 +36,10 @@ if (checkSession()) { | @@ -36,10 +36,10 @@ if (checkSession()) { | ||
| 36 | $sMetaTagIDs = getChosenMetaDataTags(); | 36 | $sMetaTagIDs = getChosenMetaDataTags(); |
| 37 | if (strlen($sMetaTagIDs) > 0) { | 37 | if (strlen($sMetaTagIDs) > 0) { |
| 38 | $sSQLSearchString = getSQLSearchString($fSearchString); | 38 | $sSQLSearchString = getSQLSearchString($fSearchString); |
| 39 | - $sDocumentIDs = getApprovedDocumentString($sMetaTagIDs, $sSQLSearchString, "Archived"); | ||
| 40 | - if (strlen($sDocumentIDs) > 0) { | 39 | + $aDocuments = searchForDocuments($sMetaTagIDs, $sSQLSearchString, "Archived"); |
| 40 | + if (count($aDocuments) > 0) { | ||
| 41 | // display the documents | 41 | // display the documents |
| 42 | - $oContent->setHtml(renderArchivedDocumentsResultsPage($sDocumentIDs)); | 42 | + $oContent->setHtml(renderArchivedDocumentsResultsPage($aDocuments)); |
| 43 | } else { | 43 | } else { |
| 44 | $oContent->setHtml(getSearchPage($fSearchString, explode(",",$sMetaTagIDs), "Archived Documents Search", true)); | 44 | $oContent->setHtml(getSearchPage($fSearchString, explode(",",$sMetaTagIDs), "Archived Documents Search", true)); |
| 45 | $sErrorMessage = "No documents matched your search criteria"; | 45 | $sErrorMessage = "No documents matched your search criteria"; |
| @@ -64,6 +64,10 @@ if (checkSession()) { | @@ -64,6 +64,10 @@ if (checkSession()) { | ||
| 64 | $aSuccessDocuments = array(); | 64 | $aSuccessDocuments = array(); |
| 65 | for ($i = 0; $i < count($aDocuments); $i++) { | 65 | for ($i = 0; $i < count($aDocuments); $i++) { |
| 66 | if ($aDocuments[$i]) { | 66 | if ($aDocuments[$i]) { |
| 67 | + // TODO: check if there are requests for this document to be archived | ||
| 68 | + // and email them | ||
| 69 | + // FIXME: refactor notification | ||
| 70 | + | ||
| 67 | // set the status to live | 71 | // set the status to live |
| 68 | $aDocuments[$i]->setStatusID(lookupStatusID("Live")); | 72 | $aDocuments[$i]->setStatusID(lookupStatusID("Live")); |
| 69 | if ($aDocuments[$i]->update()) { | 73 | if ($aDocuments[$i]->update()) { |
| @@ -88,7 +92,6 @@ if (checkSession()) { | @@ -88,7 +92,6 @@ if (checkSession()) { | ||
| 88 | } | 92 | } |
| 89 | } else { | 93 | } else { |
| 90 | // display the advanced search form, but specify that only archived documents must be returned | 94 | // display the advanced search form, but specify that only archived documents must be returned |
| 91 | - //getSearchPage($sSearchString = "", $aMetaTagIDs = array(), $sHeading = "Advanced Search", $bSearchArchive = false) { | ||
| 92 | $oContent->setHtml(getSearchPage("", array(), "Archived Documents Search", true)); | 95 | $oContent->setHtml(getSearchPage("", array(), "Archived Documents Search", true)); |
| 93 | } | 96 | } |
| 94 | 97 | ||
| @@ -101,5 +104,32 @@ if (checkSession()) { | @@ -101,5 +104,32 @@ if (checkSession()) { | ||
| 101 | $main->setFormAction($_SERVER['PHP_SELF']); | 104 | $main->setFormAction($_SERVER['PHP_SELF']); |
| 102 | $main->setHasRequiredFields(true); | 105 | $main->setHasRequiredFields(true); |
| 103 | $main->render(); | 106 | $main->render(); |
| 104 | -} | 107 | +} |
| 108 | + | ||
| 109 | + | ||
| 110 | +/** | ||
| 111 | +* Generate a string consisting of all documents that match the search criteria | ||
| 112 | +* and that the user is allowed to see | ||
| 113 | +*/ | ||
| 114 | +function searchForDocuments($sMetaTagIDs, $sSQLSearchString, $sStatus = "Live") { | ||
| 115 | + global $default; | ||
| 116 | + $aDocuments = array(); | ||
| 117 | + $sQuery = "SELECT DISTINCT D.id " . | ||
| 118 | + "FROM documents AS D INNER JOIN document_fields_link AS DFL ON DFL.document_id = D.id " . | ||
| 119 | + "INNER JOIN document_fields AS DF ON DF.id = DFL.document_field_id " . | ||
| 120 | + "INNER JOIN search_document_user_link AS SDUL ON SDUL.document_id = D.ID " . | ||
| 121 | + "INNER JOIN status_lookup AS SL on D.status_id=SL.id " . | ||
| 122 | + "WHERE DF.ID IN ($sMetaTagIDs) " . | ||
| 123 | + "AND (" . $sSQLSearchString . ") " . | ||
| 124 | + "AND SL.name='$sStatus' " . | ||
| 125 | + "AND SDUL.user_id = " . $_SESSION["userID"]; | ||
| 126 | + $default->log->info("searchForDocuments $sQuery"); | ||
| 127 | + $sql = $default->db; | ||
| 128 | + $sql->query($sQuery); | ||
| 129 | + while ($sql->next_record()) { | ||
| 130 | + $aDocuments[] = & Document::get($sql->f("id")); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + return $aDocuments; | ||
| 134 | +} | ||
| 105 | ?> | 135 | ?> |
| 106 | \ No newline at end of file | 136 | \ No newline at end of file |