Merge branch 'master' into feature-25999/C4_cleanup

This commit is contained in:
SimonGschnell
2025-01-08 11:17:29 +01:00
30 changed files with 1750 additions and 33 deletions
@@ -88,7 +88,7 @@ class Profil extends FHCAPI_Controller
$res->data = $this->studentProfil();
$res->data->pid = $this->pid;
}
// editing your own profil - true
$editAllowed = true;
}
// UID is availabe when accessing Profil/View/:uid
@@ -495,12 +495,11 @@ class Profil extends FHCAPI_Controller
*/
private function getPersonInfo($uid, $geburtsInfo = null)
{
$selectClause = ["foto", "anrede", "titelpost as postnomen", "titelpre as titel", "vorname", "nachname"];
$selectClause = ["foto", "foto_sperre", "anrede", "titelpost as postnomen", "titelpre as titel", "vorname", "nachname"];
/** @param integer $geburtsInfo */
if ($geburtsInfo) {
array_push($selectClause, "gebort");
array_push($selectClause, "gebdatum");
array_push($selectClause, "foto_sperre");
}
$this->BenutzerModel->addSelect($selectClause);
$this->BenutzerModel->addJoin("tbl_person", "person_id");
@@ -512,6 +511,12 @@ class Profil extends FHCAPI_Controller
$person_res = hasData($person_res) ? getData($person_res)[0] : null;
}
if( ($person_res->foto === null) || (($this->uid !== $uid) && ($person_res->foto_sperre !== false)) )
{
$dummy_foto = base64_encode(file_get_contents(DOC_ROOT.'skin/images/profilbild_dummy.jpg'));
$person_res->foto = $dummy_foto;
}
return $person_res;
}
+187
View File
@@ -0,0 +1,187 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Tag_Controller extends FHCAPI_Controller
{
private $_uid;
const BERECHTIGUNG_KURZBZ = 'admin:rw';
public function __construct($permissions)
{
$default_permissions = [
'getTag' => self::BERECHTIGUNG_KURZBZ,
'getTags' => self::BERECHTIGUNG_KURZBZ,
'addTag' => self::BERECHTIGUNG_KURZBZ,
'updateTag' => self::BERECHTIGUNG_KURZBZ,
'doneTag' => self::BERECHTIGUNG_KURZBZ,
'deleteTag' => self::BERECHTIGUNG_KURZBZ,
];
$merged_permissions = array_merge($default_permissions, $permissions);
parent::__construct($merged_permissions);
$this->_setAuthUID();
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
}
public function getTag()
{
$id = $this->input->get('id');
$this->NotizModel->addSelect(
'tbl_notiz.titel,
tbl_notiz.text,
array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung,
tbl_notiz.notiz_id,
tbl_notiz_typ.style,
tbl_notiz.erledigt as done,
tbl_notiz.insertamum,
tbl_notiz.updateamum,
tbl_notiz.insertvon,
tbl_notiz.updatevon
'
);
$this->NotizModel->addJoin('public.tbl_notiz_typ', 'public.tbl_notiz.typ = public.tbl_notiz_typ.typ_kurzbz');
$notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id));
$this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array());
}
public function getTags()
{
$this->NotiztypModel->addSelect(
'typ_kurzbz as tag_typ_kurzbz,
array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung,
style,
beschreibung,
tag
'
);
$this->NotiztypModel->addOrder('prioritaet');
$notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true));
$this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array());
}
public function addTag($withZuordnung = true)
{
$postData = $this->getPostJson();
$checkTyp = $this->NotiztypModel->loadWhere(array('typ_kurzbz' => $postData->tag_typ_kurzbz));
if (!hasData($checkTyp))
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
if ($withZuordnung)
{
$return = array();
$checkZuordnungType = $this->NotizzuordnungModel->isValidType($postData->zuordnung_typ);
if (!isSuccess($checkZuordnungType))
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
$values = array_unique($postData->values);
foreach ($values as $value)
{
$insertResult = $this->addNotiz($postData);
if (isError($insertResult))
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
$insertZuordnung = $this->NotizzuordnungModel->insert(array(
'notiz_id' => $insertResult->retval,
$postData->zuordnung_typ => $value
));
if (isError($insertZuordnung))
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
$return[] = [$postData->zuordnung_typ => $value, 'id' => $insertResult->retval];
}
$this->terminateWithSuccess($return);
}
else
{
$insertResult = $this->addNotiz($postData);
if (isError($insertResult))
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
return $insertResult->retval;
}
}
private function addNotiz($postData)
{
return $this->NotizModel->insert(array(
'titel' => 'TAG', //TODO klären
'text' => $postData->notiz,
'verfasser_uid' => $this->_uid,
'erledigt' => false,
'insertamum' => date('Y-m-d H:i:s'),
'insertvon' => $this->_uid,
'typ' => $postData->tag_typ_kurzbz
));
}
public function updateTag()
{
$postData = $this->getPostJson();
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
array('text' => $postData->notiz)
);
$this->terminateWithSuccess($updateData);
}
public function doneTag()
{
$postData = $this->getPostJson();
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
array('erledigt' => !$postData->done)
);
$this->terminateWithSuccess($updateData);
}
public function deleteTag($withZuordnung = true)
{
$postData = $this->getPostJson();
$deleteNotiz = "";
if ($withZuordnung)
{
$deleteZuordnung = $this->NotizzuordnungModel->delete(array(
'notiz_id' => $postData->id
));
if (isSuccess($deleteZuordnung))
{
$deleteNotiz = $this->NotizModel->delete(array(
'notiz_id' => $postData->id
));
}
}
else
{
$deleteNotiz = $this->NotizModel->delete(array(
'notiz_id' => $postData->id
));
}
$this->terminateWithSuccess($deleteNotiz);
}
private function _setAuthUID()
{
$this->_uid = getAuthUID();
if (!$this->_uid)
show_error('User authentification failed');
}
}
+62 -6
View File
@@ -33,7 +33,7 @@ class SearchBarLib
const ERROR_NOT_AUTH = 'ERR005';
// List of allowed types of search
const ALLOWED_TYPES = ['mitarbeiter', 'mitarbeiter_ohne_zuordnung', 'organisationunit', 'raum', 'person', 'student', 'prestudent', 'document', 'cms'];
const ALLOWED_TYPES = ['mitarbeiter', 'mitarbeiter_ohne_zuordnung', 'organisationunit', 'raum', 'person', 'student','studentStv', 'prestudent', 'document', 'cms'];
const PHOTO_IMG_URL = '/cis/public/bild.php?src=person&person_id=';
@@ -362,17 +362,26 @@ EOSC;
private function _student($searchstr, $type)
{
$dbModel = new DB_Model();
$gesperrtes_foto = base64_encode(file_get_contents(DOC_ROOT.'skin/images/profilbild_dummy.jpg'));
$students = $dbModel->execReadOnlyQuery('
SELECT
\''.$type.'\' AS type,
s.student_uid AS uid,
CONCAT(s.student_uid,\'@'.DOMAIN.'\') AS email,
s.matrikelnr,
CONCAT(UPPER(stg.typ),UPPER(stg.kurzbz),\'-\',s.semester,s.verband) as verband,
stg.bezeichnung AS studiengang,
p.person_id AS person_id,
p.vorname || \' \' || p.nachname AS name,
k.kontakt as email ,
p.foto
CASE
when s.student_uid = \''.getAuthUID().'\' then p.foto
when p.foto IS NULL then \''.$gesperrtes_foto.'\'
when p.foto_sperre = false then p.foto
else \''.$gesperrtes_foto.'\'
end as foto,
b.aktiv
FROM public.tbl_student s
JOIN public.tbl_studiengang stg USING(studiengang_kz)
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid)
JOIN public.tbl_person p USING(person_id)
LEFT JOIN (
@@ -380,10 +389,57 @@ EOSC;
FROM public.tbl_kontakt
WHERE kontakttyp = \'email\'
) as k USING(person_id)
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
WHERE
b.aktiv = TRUE
AND (b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\')
GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name,
email, p.foto, s.verband, s.semester, stg.bezeichnung,
stg.typ, stg.kurzbz, b.aktiv
ORDER BY b.aktiv DESC, p.nachname ASC, p.vorname ASC
');
// If something has been found then return it
if (hasData($students)) return getData($students);
// Otherwise return an empty array
return array();
}
private function _studentStv($searchstr, $type)
{
$dbModel = new DB_Model();
$students = $dbModel->execReadOnlyQuery('
SELECT
\''.$type.'\' AS type,
s.student_uid AS uid,
s.matrikelnr,
CONCAT(UPPER(stg.typ),UPPER(stg.kurzbz),\'-\',s.semester,s.verband) as verband,
stg.bezeichnung AS studiengang,
p.person_id AS person_id,
p.vorname || \' \' || p.nachname AS name,
k.kontakt AS email,
p.foto,
b.aktiv
FROM public.tbl_student s
JOIN public.tbl_studiengang stg USING(studiengang_kz)
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid)
JOIN public.tbl_person p USING(person_id)
LEFT JOIN (
SELECT kontakt, person_id
FROM public.tbl_kontakt
WHERE kontakttyp = \'email\'
) as k USING(person_id)
WHERE
b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name,
k.kontakt, p.foto, s.verband, s.semester, stg.bezeichnung,
stg.typ, stg.kurzbz, b.aktiv
ORDER BY b.aktiv DESC, p.nachname ASC, p.vorname ASC
');
// If something has been found then return it
@@ -0,0 +1,14 @@
<?php
class LehrveranstaltungFaktor_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'lehre.tbl_lehrveranstaltung_faktor';
$this->pk = 'lehrveranstaltung_faktor_id';
}
}
+1 -1
View File
@@ -142,7 +142,7 @@ class Notiz_model extends DB_Model
$this->addSelect('public.tbl_notiz.*');
$this->addJoin('public.tbl_notizzuordnung', 'notiz_id');
return $this->loadWhere(array('person_id' => $person_id));
return $this->loadWhere(array('person_id' => $person_id, 'tbl_notiz.typ' => NULL));
}
/**
@@ -0,0 +1,22 @@
<?php
class Projects_Employees_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'sync.tbl_projects_employees';
$this->pk = 'projects_employees_id';
}
public function deleteByProjectTaskId($ids)
{
$qry = "DELETE FROM " . $this->dbTable . "
WHERE project_task_id IN ?";
return $this->execQuery($qry, array($ids));
}
}
@@ -13,5 +13,33 @@ class Stundensatz_model extends DB_Model
$this->pk = 'stundensatz_id';
$this->hasSequence = true;
}
public function getStundensatzByDatum($uid, $beginn, $ende = null, $typ = null)
{
$qry = "SELECT
*
FROM
hr.tbl_stundensatz
WHERE
uid = ?
AND (gueltig_bis >= ? OR gueltig_bis is null)";
$params = array($uid, $beginn);
if (!is_null($ende))
{
$qry .= " AND (gueltig_von <= ?)";
$params[] = $ende;
}
if (!is_null($typ))
{
$qry .= " AND stundensatztyp = ?";
$params[] = $typ;
}
$qry .= " ORDER BY gueltig_bis DESC NULLS FIRST, gueltig_von DESC NULLS LAST LIMIT 1;";
return $this->execQuery($qry, $params);
}
}
@@ -0,0 +1,14 @@
<?php
class Notiztyp_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'public.tbl_notiz_typ';
$this->pk = 'typ_kurzbz';
}
}
@@ -45,3 +45,4 @@
$tablewidget = isset($tablewidget) ? $tablewidget : false;
$udfs = isset($udfs) ? $udfs : false;
$widgets = isset($widgets) ? $widgets : false;
$tags = isset($tags) ? $tags : false;
@@ -119,6 +119,9 @@
// CIS
if ($cis === true) generateCSSsInclude(defined('CIS4') ? 'public/css/cis4.css' : 'public/css/cis_bs5.css');
//Tags
if ($tags === true) generateCSSsInclude('public/css/tags.css');
// Eventually required CSS
generateCSSsInclude($customCSSs); // Eventually required CSS
?>