Skip to content
Snippets Groups Projects
Commit 2c4dc16e authored by Tobias Baden's avatar Tobias Baden
Browse files

Updated the search

- Enabled Shortname and fullname search
- Updated Version
parent e2820cd0
Branches
Tags
No related merge requests found
......@@ -179,8 +179,12 @@ class block_hshcourselist extends block_base {
global $DB;
$params = array(SITEID);
$keywordArray = explode(" ", $search);
foreach($keywordArray as $key => $value) {
$keywordArray[$key] = "%".$keywordArray[$key]."%";
$paramscount = count($keywordArray);
$duplicatedKeywordArray = array();
for ($x = 0; $x <= $paramscount-1; $x++) {
$actualLength = count($duplicatedKeywordArray);
$duplicatedKeywordArray[$actualLength] = "%".$keywordArray[$x]."%";
$duplicatedKeywordArray[$actualLength+1] = "%".$keywordArray[$x]."%";
}
$where = 'id != ? AND (';
if ($splitterms) {
......@@ -200,10 +204,10 @@ class block_hshcourselist extends block_base {
$params = array_merge($params, array($search));
$where .= 'id = ?';
} else {
$params = array_merge($params, $keywordArray);
$where .= 'fullname ILIKE ?';
for ($i = 0; $i <= count($keywordArray)-2; $i++) {
$where .= ' AND fullname ILIKE ? OR shortname ILIKE ?';
$params = array_merge($params, $duplicatedKeywordArray);
$where .= '(fullname ILIKE ? OR shortname ILIKE ?)';
for ($i = 1; $i <= $paramscount-1; $i++) {
$where .= ' AND (fullname ILIKE ? OR shortname ILIKE ?)';
}
}
}
......
<?php
$plugin->component = 'block_hshcourselist';
$plugin->version = 2018083002; // YYYYMMDDHH
$plugin->version = 2018083003; // YYYYMMDDHH
$plugin->requires = 2016112900; // YYYYMMDDHH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment