diff --git a/app/Config/Schema/schema.xml b/app/Config/Schema/schema.xml index d1c95301b..274e9af50 100644 --- a/app/Config/Schema/schema.xml +++ b/app/Config/Schema/schema.xml @@ -3142,6 +3142,7 @@ + diff --git a/app/Controller/StandardController.php b/app/Controller/StandardController.php index bfa173950..751fa9a81 100644 --- a/app/Controller/StandardController.php +++ b/app/Controller/StandardController.php @@ -839,7 +839,16 @@ public function index() { if(!empty($this->request->query['search_identifier'])) { // XXX temporary implementation -- need more general approach (CO-1053) $args = array(); - $args['conditions']['Identifier.identifier'] = $this->request->query['search_identifier']; + // search.identifier is supported by CoDepartment, OrgIdentity, CoGroup, CoPerson API. All these requests + // require the coId as a query parameter + $CoSetting = ClassRegistry::init('CoSetting'); + if(!empty($this->request->query['coid']) + && $CoSetting->identifierISearchEnabled($this->request->query['coid']) + ) { + $args['conditions']['LOWER(Identifier.identifier) LIKE'] = '%' . $this->request->query['search_identifier'] . '%'; + } else { + $args['conditions']['Identifier.identifier'] = $this->request->query['search_identifier']; + } $orgPooled = $this->CmpEnrollmentConfiguration->orgIdentitiesPooled(); if(!empty($this->params['url']['coid']) && !$orgPooled) { diff --git a/app/Lib/lang.php b/app/Lib/lang.php index cb590c2c7..d8df81adb 100644 --- a/app/Lib/lang.php +++ b/app/Lib/lang.php @@ -1660,6 +1660,7 @@ 'fd.id.seq' => 'ID', 'fd.id.val' => 'ID: %1$s', // The next set must be named fd.model.validation-field + 'fd.identifier.caseinsensitive.search.enable' => 'Enable Case Insensitive Identifier Searching', 'fd.identifier.description' => 'Description', 'fd.identifier.identifier' => 'Identifier', 'fd.identifier.login' => 'Login', diff --git a/app/Model/CoSetting.php b/app/Model/CoSetting.php index 7f8a9fba3..254618c0d 100644 --- a/app/Model/CoSetting.php +++ b/app/Model/CoSetting.php @@ -84,6 +84,11 @@ class CoSetting extends AppModel { 'required' => false, 'allowEmpty' => true ), + 'enable_ident_isearch' => array( + 'rule' => 'boolean', + 'required' => false, + 'allowEmpty' => true + ), 'enable_nsf_demo' => array( 'rule' => 'boolean', 'required' => false, @@ -202,6 +207,7 @@ class CoSetting extends AppModel { 'group_create_admin_only' => false, 'enable_normalization' => true, 'enable_nsf_demo' => false, + 'enable_ident_isearch' => false, 'group_validity_sync_window' => DEF_GROUP_SYNC_WINDOW, 'invitation_validity' => DEF_INV_VALIDITY, 'garbage_collection_interval' => DEF_GARBAGE_COLLECT_INTERVAL, @@ -495,6 +501,18 @@ public function getTAndCLoginMode($coId) { return $this->lookupValue($coId, 't_and_c_login_mode'); } + /** + * Determine if Identifier Case Insensitise search is enabled for the specified CO. + * + * @since COmanage Registry 4.3.3 + * @param integer $coId CO ID + * @return boolean True if enabled, false otherwise + */ + + public function identifierISearchEnabled($coId) { + return (boolean)$this->lookupValue($coId, 'enable_ident_isearch'); + } + /** * Obtain a single CO setting. * diff --git a/app/Model/Identifier.php b/app/Model/Identifier.php index 68c576b3e..924934bfa 100644 --- a/app/Model/Identifier.php +++ b/app/Model/Identifier.php @@ -461,12 +461,17 @@ public function findCoForRecord($id) { * @param integer $coId CO ID to constrain search to * @param string $q String to search for * @param integer $limit Search limit - * @return Array Array of search results, as from find('all) + * @return Array Array of search results, as from find('all') */ public function search($coId, $q, $limit) { $args = array(); - $args['conditions']['LOWER(Identifier.identifier) LIKE'] = '%' . strtolower($q) . '%'; + $CoSetting = ClassRegistry::init('CoSetting'); + if($CoSetting->identifierISearchEnabled($coId)) { + $args['conditions']['LOWER(Identifier.identifier) LIKE'] = '%' . $q . '%'; + } else { + $args['conditions']['Identifier.identifier'] = $q; + } $args['conditions']['OR'] = array( 'CoPerson.co_id' => $coId, 'CoGroup.co_id' => $coId