Commit f695de1519cb565fe3e1ba58bbcd0f6672005f97

Authored by Neil Blakey-Milner
1 parent 17afb702

Remove a broken advanced search, awaiting a working one using the new

infrastructure.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4537 c91229c3-7414-0410-bfa2-8a42b809f60b
search/advancedSearchBL.php deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * Business logic used to perform advanced search. Advanced search allows
6   - * users to search by meta data types
7   - *
8   - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
9   - *
10   - * This program is free software; you can redistribute it and/or modify
11   - * it under the terms of the GNU General Public License as published by
12   - * the Free Software Foundation; either version 2 of the License, or
13   - * (at your option) any later version.
14   - *
15   - * This program is distributed in the hope that it will be useful,
16   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18   - * GNU General Public License for more details.
19   - *
20   - * You should have received a copy of the GNU General Public License
21   - * along with this program; if not, write to the Free Software
22   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23   - *
24   - * @version $Revision$
25   - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
26   - * @package search
27   - */
28   -
29   -require_once("../config/dmsDefaults.php");
30   -require_once(KT_DIR . '/search/advancedSearchUtil.inc');
31   -
32   -KTUtil::extractGPC('fForSearch', 'fSearchString', 'fShowSection', 'fStartIndex', 'fToSearch');
33   -
34   -if (checkSession()) {
35   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");
36   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc");
37   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
38   - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
39   - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
40   - require_once("$default->fileSystemRoot/lib/security/Permission.inc");
41   - require_once("advancedSearchUI.inc");
42   -
43   - if (!isset($fStartIndex)) {
44   - $fStartIndex = 1;
45   - }
46   -
47   - if (strlen($fForSearch)) {
48   - dealWithAdvancedSearch($_REQUEST, $fStartIndex);
49   - } else {
50   - //display search criteria
51   - $oPatternCustom = & new PatternCustom();
52   - $oPatternCustom->setHtml(getSearchPage());
53   - $main->setHasRequiredFields(true);
54   - $main->setCentralPayload($oPatternCustom);
55   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForSearch=1");
56   - $main->render();
57   - }
58   -}
59   -?>
search/advancedSearchUI.inc deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * Presentation logic used by advancedSearchBL.php
6   - *
7   - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
8   - *
9   - * This program is free software; you can redistribute it and/or modify
10   - * it under the terms of the GNU General Public License as published by
11   - * the Free Software Foundation; either version 2 of the License, or
12   - * (at your option) any later version.
13   - *
14   - * This program is distributed in the hope that it will be useful,
15   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17   - * GNU General Public License for more details.
18   - *
19   - * You should have received a copy of the GNU General Public License
20   - * along with this program; if not, write to the Free Software
21   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22   - *
23   - * @version $Revision$
24   - * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
25   - * @package search
26   - */
27   -
28   -require_once("$default->fileSystemRoot/lib/browse/Criteria.inc");
29   -
30   -function getMetaData($aMetaTagIDs) {
31   - global $default;
32   - /*ok*/ $sQuery = "SELECT name, id FROM $default->document_fields_table ORDER BY name ASC";
33   -
34   - $sql = $default->db;
35   - $sql->query($sQuery);
36   -
37   - $sToRender = "<table border=\"0\">\n";
38   - $sToRender .= "<input type=\"hidden\" name=\"adv_search_start\" value=\"\" />\n";
39   -
40   - $iRecordCount = 0;
41   - $sCheckAllJavascript = "";
42   - while ($sql->next_record()) {
43   - $sCheckAllJavascript .= "document.MainForm.f_adv_$iRecordCount.checked=value;\n";
44   - $sMetaDataCheckBox = "<input type=\"checkbox\" " . wasSelected($sql->f("id"), $aMetaTagIDs) . " name=\"f_adv_$iRecordCount\" value=\"" . $sql->f("id") . "\"></td><td>" . $sql->f("name");
45   - $iRecordCount++;
46   - if (($iRecordCount % 3) == 1) {
47   - $sToRender .= "<tr><td>$sMetaDataCheckBox</td>\n";
48   - } else if (($iRecordCount % 3) == 0) {
49   - $sToRender .= "<td>$sMetaDataCheckBox</td></tr>\n";
50   - } else {
51   - $sToRender .= "<td>$sMetaDataCheckBox</td>\n";
52   - }
53   - }
54   -
55   - $sToRender .= "<input type=\"hidden\" name=\"adv_search_end\" value=\"\" />\n";
56   - $sToRender .= "\n\n<SCRIPT LANGUAGE=\"javascript\">\n ";
57   - $sToRender .= "<!--\n";
58   - $sToRender .= "function setChecked(value) {\n";
59   - $sToRender .= $sCheckAllJavascript;
60   - $sToRender .= "\t}\n";
61   - $sToRender .= "-->\n";
62   - $sToRender .= "</SCRIPT>\n\n";
63   - $sToRender .= "<tr><td colspan=\"3\"><a href=\"javascript:setChecked(1)\"><img src=\"" . KTHtml::getCheckAllButton() . "\" border=\"0\"/></a></td><td colspan=\"3\"><a href=\"javascript:setChecked(0)\"><img src=\"" . KTHtml::getClearAllButton() . "\" border=\"0\"/></a></td></tr>";
64   - $sToRender .= "</table>\n";
65   -
66   - return $sToRender;
67   -}
68   -
69   -function getSearchPage($sSearchString = "", $aMetaTagIDs = array(), $sHeading = null, $bSearchArchive = false) {
70   - global $default;
71   - if (is_null($sHeading)) {
72   - $sHeading = _("Advanced Search");
73   - }
74   -
75   - $sToRender = renderHeading($sHeading);
76   -
77   - $sToRender .= sprintf('<p class="helpText">Want to use AND or OR? Use the
78   - <a href="%s">Boolean Search</a></p>', 'booleanSearch.php');
79   -
80   - $sToRender .= "<form name=\"advancedSearch\" method=\"POST\">";
81   -
82   - $sToRender .= "<table width=\"100%\">\n";
83   - $sToRender .= "<tr><td colspan=\"2\"><h3>" . _("Document Data") . "</h3></td></tr>";
84   - $aBaseCriteria = Criteria::getBaseCriteria();
85   - foreach ($aBaseCriteria as $k => $v) {
86   - $sToRender .= $v->searchDisplay($_REQUEST);
87   - }
88   - $sToRender .= "<tr><td colspan=\"2\"><h3>" . _("Document Fields") . "</h3></td></tr>";
89   - $aGenericCriteria = Criteria::getGenericCriteria();
90   - foreach ($aGenericCriteria as $k => $v) {
91   - $sToRender .= $v->searchDisplay($_REQUEST);
92   - }
93   -
94   - if ($bSearchArchive) {
95   - $sToRender .= "<input type=\"hidden\" name=\"fToSearch\" value=\"Archived\"/>";
96   - } else {
97   - $sToRender .= "<tr>\n";
98   - $sToRender .= "<td>&nbsp</td>\n";
99   - $sToRender .= "</tr>\n";
100   - $sToRender .= "<tr><td>" . _("Search") . ": <select name=\"fToSearch\"><option value=\"Live\">" . _("Live") . "</option><option value=\"Archived\">" . _("Archived") . "</option></select> " . _("Documents") . "</td></tr>";
101   - }
102   -
103   - $sToRender .= "</table>\n";
104   - $sToRender .= "<input name=\"advancedSearch\" type=\"image\" src=\"" . KTHtml::getSearchButton() . "\" border=\"0\"/>\n";
105   - $sToRender .= "</form>";
106   -
107   - return $sToRender . getSearchValidationJavaScript();
108   -}
109   -
110   -function getSearchValidationJavaScript() {
111   - /*$sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n ";
112   - $sToRender .= "<!--\n";
113   - $sToRender .= "function validateForm() {\n";
114   - $sToRender .= "\tif (!(validRequired(document.MainForm.fSearchString, 'Search text'))) {\n";
115   - $sToRender .= "\t\treturn false;\n\t}\n";
116   - $sToRender .= "\treturn true;\n}\n";
117   - $sToRender .= "-->\n";
118   - $sToRender .= "</SCRIPT>\n\n";
119   - return $sToRender;*/
120   - return "";
121   -}
122   -
123   -function wasSelected($iID, $aMetaTagIDs) {
124   - if (in_array($iID, $aMetaTagIDs)) {
125   - return "CHECKED";
126   - }
127   - return "";
128   -}
129   -
130   -function getSearchVariablesHtml($sSearchText, $sStatus, $sMetaTagIDs) {
131   - $aMetaTagIDs = explode(",", $sMetaTagIDs);
132   - $sToRender = "\n\n<input type=\"hidden\" name=\"fForSearch\" value=\"1\" />\n";
133   - $sToRender .= "\n\n<input type=\"hidden\" name=\"fSearchString\" value=\"$sSearchText\" />\n";
134   - $sToRender .= "\n\n<input type=\"hidden\" name=\"fToSearch\" value=\"$sStatus\" />\n";
135   - $sToRender .= "<input type=\"hidden\" name=\"adv_search_start\" value=\"\" />\n";
136   - for ($i = 0; $i < count($aMetaTagIDs); $i++) {
137   - $sToRender .= "<input type=\"hidden\" name=\"fMetaTag_$i\" value=\"" . $aMetaTagIDs[$i] . "\" />\n";
138   -
139   - }
140   - $sToRender .= "<input type=\"hidden\" name=\"adv_search_end\" value=\"\" />\n";
141   - return $sToRender;
142   -}
143   -?>
search/advancedSearchUtil.inc deleted
1   -<?php
2   -/**
3   - * $Id$
4   - *
5   - * Business logic used to perform advanced search. Advanced search allows
6   - * users to search by meta data types.
7   - *
8   - * Copyright (c) 2005 Jam Warehouse http://www.jamwarehouse.com
9   - *
10   - * This program is free software; you can redistribute it and/or modify
11   - * it under the terms of the GNU General Public License as published by
12   - * the Free Software Foundation; either version 2 of the License, or
13   - * (at your option) any later version.
14   - *
15   - * This program is distributed in the hope that it will be useful,
16   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18   - * GNU General Public License for more details.
19   - *
20   - * You should have received a copy of the GNU General Public License
21   - * along with this program; if not, write to the Free Software
22   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23   - *
24   - * @version $Revision$
25   - * @author Neil Blakey-Milner, Jam Warehouse (Pty) Ltd, South Africa
26   - * @package search
27   - */
28   -
29   -require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php');
30   -
31   -function searchCriteria ($var) {
32   - return preg_match('/^bmd(_?\d+)/', $var);
33   -}
34   -
35   -function criteriaNumber ($var) {
36   - $res = preg_replace('/^bmd(_?\d+)(\D.*)?/', '\\1', $var);
37   - if ($res !== false) {
38   - $res = strtr($res, '_', '-');
39   - }
40   - return $res;
41   -}
42   -
43   -function getAdvancedSearchResults($aOrigReq, $iStartIndex) {
44   - global $default;
45   -
46   - $sRefreshMessage = "<table><tr><td align=\"center\">" . _("If your browser displays a 'Warning: Page has Expired' message when you attempt to return to these search results, please click your browser's 'Refresh' button") . "</td></tr></table>";
47   -
48   - $aReq = array();
49   - foreach ($aOrigReq as $k => $v) {
50   - if (searchCriteria($k) === 1) {
51   - $v = trim($v);
52   - if ($v === "") {
53   - continue;
54   - }
55   - if ($v === "-1") {
56   - continue;
57   - }
58   - $aReq[$k] = $v;
59   - }
60   - }
61   -
62   - $aIDs = array_unique(array_map("criteriaNumber", array_keys($aReq)));
63   - $aSQL = array();
64   - $aJoinSQL = array();
65   - foreach ($aIDs as $iID) {
66   - $oCriterion =& Criteria::getCriterionByNumber($iID);
67   - $res = $oCriterion->searchSQL($aReq);
68   - if (!is_null($res)) {
69   - $aSQL[] = $res;
70   - }
71   - $res = $oCriterion->searchJoinSQL();
72   - if (!is_null($res)) {
73   - $aJoinSQL[] = $res;
74   - }
75   - }
76   - $aCritParams = array();
77   - $aCritQueries = array();
78   - foreach ($aSQL as $sSQL) {
79   - if (is_array($sSQL)) {
80   - $aCritQueries[] = $sSQL[0];
81   - $aCritParams = array_merge($aCritParams , $sSQL[1]);
82   - } else {
83   - $aCritQueries[] = $sSQL;
84   - }
85   - }
86   -
87   - if (count($aCritQueries) == 0) {
88   - return "No search criteria were specified";
89   - }
90   -
91   - $sSQLSearchString = join(" AND ", $aCritQueries);
92   - $sJoinSQL = join(" ", $aJoinSQL);
93   -
94   - $sToSearch = KTUtil::arrayGet($aOrigReq, 'fToSearch', 'Live');
95   -
96   - $oPermission =& KTPermission::getByName('ktcore.permissions.read');
97   - $sPermissionLookupsTable = KTUtil::getTableName('permission_lookups');
98   - $sPermissionLookupAssignmentsTable = KTUtil::getTableName('permission_lookup_assignments');
99   - $sPermissionDescriptorsTable = KTUtil::getTableName('permission_descriptors');
100   - $aGroups = GroupUtil::listGroupsForUserExpand($_SESSION['userID']);
101   - $aPermissionDescriptors = KTPermissionDescriptor::getByGroups($aGroups, array('ids' => true));
102   - $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors);
103   -
104   - $sQuery = DBUtil::compactQuery("
105   -SELECT
106   - F.name AS folder_name, F.id AS folder_id, D.id AS document_id,
107   - D.name AS document_name, D.filename AS file_name, COUNT(D.id) AS doc_count, 'View' AS view
108   -FROM
109   - $default->documents_table AS D
110   - INNER JOIN $default->folders_table AS F ON D.folder_id = F.id
111   - $sJoinSQL
112   - INNER JOIN $default->status_table AS SL ON D.status_id=SL.id
113   - INNER JOIN $sPermissionLookupsTable AS PL ON D.permission_lookup_id = PL.id
114   - INNER JOIN $sPermissionLookupAssignmentsTable AS PLA ON PL.id = PLA.permission_lookup_id AND PLA.permission_id = ?
115   -WHERE
116   - PLA.permission_descriptor_id IN ($sPermissionDescriptors)
117   - AND SL.name = ?
118   - AND ($sSQLSearchString)
119   -GROUP BY D.id
120   -ORDER BY doc_count DESC");
121   -
122   - $aParams = array();
123   - $aParams[] = $oPermission->getId();
124   - $aParams = array_merge($aParams, $aPermissionDescriptors);
125   - $aParams[] = $sToSearch;
126   - $aParams = array_merge($aParams, $aCritParams);
127   -
128   - //var_dump(DBUtil::getResultArray(array($sQuery, $aParams)));
129   - //exit(0);
130   -
131   - $aColumns = array("folder_name", "file_name", "document_name", "doc_count", "view");
132   - $aColumnTypes = array(3,3,3,1,3);
133   - $aColumnHeaders = array("<font color=\"ffffff\"><img src=$default->graphicsUrl/widgets/dfolder.gif>" . _("Folder") . "</font>", "<font color=\"ffffff\">" . _("Name") . "</font>", "<font color=\"ffffff\">" . _("Title") . "</font>", "<font color=\"ffffff\">" . _("Matches") . "</font>", "<font color=\"ffffff\">" . _("View") . "</font>");
134   - $aLinkURLs = array("$default->rootUrl/control.php?action=browse","$default->rootUrl/control.php?action=viewDocument", "$default->rootUrl/control.php?action=viewDocument", null, "$default->rootUrl/control.php?action=downloadDocument");
135   - $aDBQueryStringColumns = array("document_id","folder_id");
136   - $aQueryStringVariableNames = array("fDocumentID", "fFolderID");
137   -
138   - $oPatternBrowse = & new PatternBrowseableSearchResults(array($sQuery, $aParams), 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames);
139   - $oPatternBrowse->setStartIndex($iStartIndex);
140   - $oPatternBrowse->setSearchText("");
141   - $oPatternBrowse->setRememberValues($aReq);
142   - $sForSearch = "<input type=\"hidden\" name=\"fForSearch\" value=\"1\" />";
143   -
144   - return renderHeading(_("Advanced Search")) . $oPatternBrowse->render() . $sForSearch . $sRefreshMessage;
145   -}
146   -
147   -function dealWithAdvancedSearch($aReq, $iStartIndex) {
148   - global $main;
149   - $oPatternCustom = & new PatternCustom();
150   - $oPatternCustom->setHtml(getAdvancedSearchResults($aReq, $iStartIndex));
151   - $main->setCentralPayload($oPatternCustom);
152   - $main->render();
153   -}
154   -
155   -?>