diff --git a/application/config/search.php b/application/config/search.php index 220d5e435..1450dff7b 100644 --- a/application/config/search.php +++ b/application/config/search.php @@ -210,23 +210,6 @@ $config['student'] = [ JOIN public.tbl_person p USING(person_id)" ]; -$config['studentcis'] = $config['student']; -unset($config['studentcis']['searchfields']['email']); -unset($config['studentcis']['searchfields']['tel']); -$config['studentcis']['resultfields'] = [ - "s.student_uid AS uid", - "s.matrikelnr", - "p.person_id", - "(p.vorname || ' ' || p.nachname) AS name", - "ARRAY[s.student_uid || '@' || '" . DOMAIN . "'] AS email", - "CASE - WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto - ELSE NULL END - AS photo_url", - "b.aktiv" -]; -$config['studentcis']['renderer'] = 'student'; - $config['prestudent'] = [ 'primarykey' => 'prestudent_id', 'table' => 'public.tbl_prestudent', @@ -511,6 +494,7 @@ $config['employee'] = [ ) k ON (k.standort_id = m.standort_id)" ]; +// TODO(chris): move to searchpv21.php $config['unassigned_employee'] = $config['employee']; $config['unassigned_employee']['alias'] = ['mitarbeiter_ohne_zuordnung']; $config['unassigned_employee']['prepare'] = "unassigned_employee AS ( @@ -672,12 +656,6 @@ $config['organisationunit'] = [ ON (oe_parent.organisationseinheittyp_kurzbz = type_parent.organisationseinheittyp_kurzbz)" ]; -$config['active_organisationunit'] = $config['organisationunit']; -$config['active_organisationunit']['alias'] = ['aou', 'aktive organisationseinheit', 'aoe']; -$config['active_organisationunit']['prepare'] = 'active_organisationseinheit AS (SELECT * FROM public.tbl_organisationseinheit WHERE aktiv = true)'; -$config['active_organisationunit']['table'] = 'active_organisationseinheit'; -$config['active_organisationunit']['renderer'] = 'organisationunit'; - $config['room'] = [ 'alias' => ['raum'], 'primarykey' => 'ort_kurzbz', diff --git a/application/config/searchcis.php b/application/config/searchcis.php new file mode 100644 index 000000000..ce385338f --- /dev/null +++ b/application/config/searchcis.php @@ -0,0 +1,35 @@ +config->item('employee', 'search'); + +$config['student'] = $CI->config->item('student', 'search'); +unset($config['student']['searchfields']['email']); +unset($config['student']['searchfields']['tel']); +$config['student']['resultfields'] = [ + "s.student_uid AS uid", + "s.matrikelnr", + "p.person_id", + "(p.vorname || ' ' || p.nachname) AS name", + "ARRAY[s.student_uid || '@' || '" . DOMAIN . "'] AS email", + "CASE + WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto + ELSE NULL END + AS photo_url", + "b.aktiv" +]; + +$config['organisationunit'] = $CI->config->item('organisationunit', 'search'); +$config['organisationunit']['prepare'] = 'active_organisationseinheit AS (SELECT * FROM public.tbl_organisationseinheit WHERE aktiv = true)'; +$config['organisationunit']['table'] = 'active_organisationseinheit'; + +$config['room'] = $CI->config->item('room', 'search'); + +$config['cms'] = $CI->config->item('cms', 'search'); + +$config['dms'] = $CI->config->item('dms', 'search'); diff --git a/application/config/searchstv.php b/application/config/searchstv.php new file mode 100644 index 000000000..96c118ac8 --- /dev/null +++ b/application/config/searchstv.php @@ -0,0 +1,11 @@ +config->item('student', 'search'); + +$config['prestudent'] = $CI->config->item('prestudent', 'search'); diff --git a/application/controllers/api/frontend/v1/Searchbar.php b/application/controllers/api/frontend/v1/Searchbar.php index 1f51334fc..363b6e534 100644 --- a/application/controllers/api/frontend/v1/Searchbar.php +++ b/application/controllers/api/frontend/v1/Searchbar.php @@ -36,7 +36,8 @@ class Searchbar extends FHCAPI_Controller // NOTE(chris): additional permission checks will be done in SearchBarLib parent::__construct([ 'search' => self::PERM_LOGGED, - 'searchAdvanced' => self::PERM_LOGGED + 'searchCis' => self::PERM_LOGGED, + 'searchStv' => self::PERM_LOGGED ]); } @@ -71,9 +72,25 @@ class Searchbar extends FHCAPI_Controller /** * Gets a JSON body via HTTP POST and provides the parameters */ - public function searchAdvanced() + public function searchCis() { - $this->load->library('SearchLib'); + return $this->searchAdvanced([ 'config' => 'searchcis' ]); + } + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function searchStv() + { + return $this->searchAdvanced([ 'config' => 'searchstv' ]); + } + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + private function searchAdvanced($config) + { + $this->load->library('SearchLib', $config); $this->load->library('form_validation'); // Checks if the searchstr and the types parameters are in the POSTed JSON diff --git a/application/libraries/SearchLib.php b/application/libraries/SearchLib.php index 659e5e78c..24894eab5 100644 --- a/application/libraries/SearchLib.php +++ b/application/libraries/SearchLib.php @@ -40,17 +40,25 @@ class SearchLib /** * Gets the CI instance and loads model + * + * @param array $params + * @return void */ - public function __construct() + public function __construct($params = null) { $this->_ci =& get_instance(); // get code igniter instance + $config = $params['config'] ?? null; // It is loaded only to have the DB functions available $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); // Load Config - $this->_ci->load->config('search', true); + $this->_ci->load->config('search', true, (boolean)$config); $this->_ci->load->config('searchfunctions', true); + if ($config) { + $this->_ci->load->config($config, true); + $this->_ci->config->set_item('search', $this->_ci->config->item($config)); + } $this->_ci->load->library('PhrasesLib', [['search'], null], 'search_phrases'); diff --git a/public/js/api/factory/searchbar.js b/public/js/api/factory/searchbar.js index 6bff98cbc..6bcf577b4 100644 --- a/public/js/api/factory/searchbar.js +++ b/public/js/api/factory/searchbar.js @@ -23,10 +23,17 @@ export default { params }; }, - searchAdvanced(params) { + searchCis(params) { return { method: 'post', - url: '/api/frontend/v1/searchbar/searchAdvanced', + url: '/api/frontend/v1/searchbar/searchCis', + params + }; + }, + searchStv(params) { + return { + method: 'post', + url: '/api/frontend/v1/searchbar/searchStv', params }; } diff --git a/public/js/apps/Cis.js b/public/js/apps/Cis.js index 65ee6c45a..efc104d69 100644 --- a/public/js/apps/Cis.js +++ b/public/js/apps/Cis.js @@ -17,9 +17,9 @@ const app = Vue.createApp({ calcheightonly: true, types: [ "employee", - "studentcis", + "student", "room", - "active_organisationunit", + "organisationunit", "cms", "dms" ], @@ -137,7 +137,7 @@ const app = Vue.createApp({ }, methods: { searchfunction: function(searchsettings) { - return this.$api.call(ApiSearchbar.searchAdvanced(searchsettings)); + return this.$api.call(ApiSearchbar.searchCis(searchsettings)); } } }); diff --git a/public/js/components/Stv/Studentenverwaltung.js b/public/js/components/Stv/Studentenverwaltung.js index c7a4ce15a..e37122427 100644 --- a/public/js/components/Stv/Studentenverwaltung.js +++ b/public/js/components/Stv/Studentenverwaltung.js @@ -147,7 +147,7 @@ export default { this.$refs.stvList.reload(); }, searchfunction(params, config) { - return this.$api.call(ApiSearchbar.searchAdvanced(params), config); + return this.$api.call(ApiSearchbar.searchStv(params), config); } }, created() {