diff --git a/block_hshcourselist.php b/block_hshcourselist.php index 0773f22b98933a6fed95ebf9025ae6c0e4695742..023ecd30a5481463498cc05169e0082f61faeee3 100644 --- a/block_hshcourselist.php +++ b/block_hshcourselist.php @@ -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 ?)'; } } } diff --git a/version.php b/version.php index c9c93f89dceeb2c122f276f55dc3f2633932fcdb..46d44972bd1bd2e76a5864ee61a87c8decc93ec5 100644 --- a/version.php +++ b/version.php @@ -1,4 +1,4 @@ <?php $plugin->component = 'block_hshcourselist'; -$plugin->version = 2018083002; // YYYYMMDDHH +$plugin->version = 2018083003; // YYYYMMDDHH $plugin->requires = 2016112900; // YYYYMMDDHH