mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Add full text index & search for document contents (related to #440)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
// Sort by
|
||||
if(!empty($_GET['sb'])){
|
||||
$sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
|
||||
}else{
|
||||
$sb = "document_name";
|
||||
}
|
||||
|
||||
# Tag from GET
|
||||
// Tag from GET
|
||||
if (isset($_GET['tag'])) {
|
||||
$tag = intval($_GET['tag']);
|
||||
# Avoid doubling up
|
||||
@@ -16,6 +17,14 @@ else {
|
||||
$tag = '';
|
||||
}
|
||||
|
||||
// Search query SQL snippet
|
||||
if(!empty($q)){
|
||||
$query_snippet = "AND (MATCH(document_content_raw) AGAINST ('$q'))";
|
||||
}
|
||||
else{
|
||||
$query_snippet = ""; // empty
|
||||
}
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
@@ -26,15 +35,15 @@ $sql_no_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents
|
||||
WHERE document_client_id = $client_id
|
||||
AND documents.company_id = $session_company_id
|
||||
AND document_template = 0
|
||||
AND (document_name LIKE '%$q%' OR document_content LIKE '%$q%')
|
||||
$query_snippet
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to";
|
||||
|
||||
$sql_with_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents
|
||||
LEFT JOIN documents_tagged ON documents.document_id = documents_tagged.document_id
|
||||
WHERE document_client_id = $client_id
|
||||
AND document_template = 0
|
||||
AND documents.company_id = $session_company_id
|
||||
AND (document_name LIKE '%$q%' OR document_content LIKE '%$q%')
|
||||
AND document_template = 0
|
||||
$query_snippet
|
||||
AND documents_tagged.tag_id LIKE '%$tag%'
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user