Each searchbar it's own config

This commit is contained in:
chfhtw
2025-07-29 16:52:29 +02:00
parent 30b895ad04
commit 1005963179
8 changed files with 90 additions and 34 deletions
+1 -23
View File
@@ -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',
+35
View File
@@ -0,0 +1,35 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
$CI =& get_instance();
$config['employee'] = $CI->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');
+11
View File
@@ -0,0 +1,11 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
$CI =& get_instance();
$config['student'] = $CI->config->item('student', 'search');
$config['prestudent'] = $CI->config->item('prestudent', 'search');
@@ -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
+10 -2
View File
@@ -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');
+9 -2
View File
@@ -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
};
}
+3 -3
View File
@@ -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));
}
}
});
@@ -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() {