diff --git a/workflow/engine/src/ProcessMaker/Core/System.php b/workflow/engine/src/ProcessMaker/Core/System.php index 4f6af90ad..91ad8ab49 100644 --- a/workflow/engine/src/ProcessMaker/Core/System.php +++ b/workflow/engine/src/ProcessMaker/Core/System.php @@ -77,7 +77,8 @@ class System 'mobile_offline_tables_download_interval' => 24, 'highlight_home_folder_enable' => 0, 'highlight_home_folder_refresh_time' => 10, - 'highlight_home_folder_scope' => 'unassigned' // For now only this list is supported + 'highlight_home_folder_scope' => 'unassigned', // For now only this list is supported + 'disable_advanced_search_case_title_fulltext' => 0 ]; /** diff --git a/workflow/engine/src/ProcessMaker/Model/Delegation.php b/workflow/engine/src/ProcessMaker/Model/Delegation.php index 4c5af796a..6450e110a 100644 --- a/workflow/engine/src/ProcessMaker/Model/Delegation.php +++ b/workflow/engine/src/ProcessMaker/Model/Delegation.php @@ -5,6 +5,7 @@ namespace ProcessMaker\Model; use G; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; +use ProcessMaker\Core\System; class Delegation extends Model { @@ -229,14 +230,21 @@ class Delegation extends Model $query->join('APPLICATION', function ($join) use ($filterBy, $search, $status, $query) { $join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER'); if ($filterBy == 'APP_TITLE' && $search) { - // Cleaning "fulltext" operators in order to avoid unexpected results - $search = str_replace(['-', '+', '<', '>', '(', ')', '~', '*', '"'], ['', '', '', '', '', '', '', '', ''], $search); + $config = System::getSystemConfiguration(); + if ((int)$config['disable_advanced_search_case_title_fulltext'] === 0) { + // Cleaning "fulltext" operators in order to avoid unexpected results + $search = str_replace(['-', '+', '<', '>', '(', ')', '~', '*', '"'], + ['', '', '', '', '', '', '', '', ''], $search); - // Build the "fulltext" expression - $search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"'; + // Build the "fulltext" expression + $search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"'; - // Searching using "fulltext" index - $join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)"); + // Searching using "fulltext" index + $join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)"); + } else { + // Searching using "like" operator + $join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%"); + } } // Based on the below, we can further limit the join so that we have a smaller data set based on join criteria switch ($status) {