Merge branch 'master' into feature-61232/Studierendenverwaltung_Karteireiter_Projektarbeit_portieren

This commit is contained in:
Alexei Karpenko
2025-09-22 13:39:36 +02:00
135 changed files with 3988 additions and 1819 deletions
+17
View File
@@ -21,6 +21,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller
'loadDokumente' => self::DEFAULT_PERMISSION_R,
'getMitarbeiter' => self::DEFAULT_PERMISSION_R,
'isBerechtigt' => self::DEFAULT_PERMISSION_R,
'getCountNotes' => self::DEFAULT_PERMISSION_R,
];
if(!is_array($permissions))
@@ -459,4 +460,20 @@ abstract class Notiz_Controller extends FHCAPI_Controller
return $this->terminateWithSuccess($result);
}
public function getCountNotes($person_id)
{
$this->NotizzuordnungModel->addSelect('COUNT(*) AS anzahl', false);
$result = $this->NotizzuordnungModel->loadWhere(
array('person_id' => $person_id)
);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$anzahl = current(getData($result));
return $this->terminateWithSuccess($anzahl->anzahl ?: 0);
}
}
+126 -24
View File
@@ -29,13 +29,36 @@ class Tag_Controller extends FHCAPI_Controller
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
$this->loadPhrases([
'ui'
]);
}
public function getTag()
public function getTag($readonly_tags = null)
{
$language = $this->_getLanguageIndex();
$id = $this->input->get('id');
if (is_array($readonly_tags) && !isEmptyArray($readonly_tags))
{
$readonly_tags = $this->_filterTag($readonly_tags, true);
foreach ($readonly_tags as $key => $tag)
{
$readonly_tags[$key] = $this->NotizModel->db->escape($tag);
}
$tags = '(' . implode(',', $readonly_tags) . ')';
$this->NotizModel->addSelect("
CASE
WHEN tbl_notiz_typ.typ_kurzbz IN $tags
THEN TRUE
ELSE FALSE
END as readonly
");
}
$this->NotizModel->addSelect(
"tbl_notiz.titel,
tbl_notiz.text,
@@ -54,7 +77,7 @@ class Tag_Controller extends FHCAPI_Controller
$this->NotizModel->addJoin('public.tbl_benutzer verfasserbenutzer', 'tbl_notiz.verfasser_uid = verfasserbenutzer.uid', 'LEFT');
$this->NotizModel->addJoin('public.tbl_person verfasserperson', 'verfasserbenutzer.person_id = verfasserperson.person_id', 'LEFT');
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.verfasser_uid = bearbeiterbenutzer.uid', 'LEFT');
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.bearbeiter_uid = bearbeiterbenutzer.uid', 'LEFT');
$this->NotizModel->addJoin('public.tbl_person bearbeiterperson', 'bearbeiterbenutzer.person_id = bearbeiterperson.person_id', 'LEFT');
$notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id));
@@ -62,7 +85,7 @@ class Tag_Controller extends FHCAPI_Controller
$this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array());
}
public function getTags()
public function getTags($tags = null)
{
$this->NotiztypModel->addSelect(
'typ_kurzbz as tag_typ_kurzbz,
@@ -73,19 +96,36 @@ class Tag_Controller extends FHCAPI_Controller
'
);
$this->NotiztypModel->addOrder('prioritaet');
if (is_array($tags) && !isEmptyArray($tags))
{
$tags = $this->_filterTag($tags, false);
$this->NotiztypModel->db->where_in('typ_kurzbz', $tags);
}
$notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true));
$this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array());
}
public function addTag($withZuordnung = true)
public function addTag($withZuordnung = true, $updatable_tags = null)
{
$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 (isError($checkTyp))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (!hasData($checkTyp))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
{
$tags = $this->_filterTag($updatable_tags, false);
if (!in_array($postData->tag_typ_kurzbz, $tags))
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
}
if ($withZuordnung)
{
@@ -125,48 +165,88 @@ class Tag_Controller extends FHCAPI_Controller
}
}
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()
public function updateTag($updatable_tags = null)
{
$postData = $this->getPostJson();
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
if (isError($post_tag))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (!hasData($post_tag))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
{
$tags = $this->_filterTag($updatable_tags, false);
$post_tag_typ = getData($post_tag)[0]->typ;
if (!in_array($post_tag_typ, $tags))
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
}
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
array('text' => $postData->notiz,
'updateamum' => date('Y-m-d H:i:s'),
'updatevon' => $this->_uid,
'bearbeiter_uid' => $this->_uid,
)
)
);
$this->terminateWithSuccess($updateData);
}
public function doneTag()
public function doneTag($updatable_tags = null)
{
$postData = $this->getPostJson();
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
if (isError($post_tag))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (!hasData($post_tag))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
{
$tags = $this->_filterTag($updatable_tags, false);
$post_tag_typ = getData($post_tag)[0]->typ;
if (!in_array($post_tag_typ, $tags))
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
}
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
array('erledigt' => !$postData->done,
'text' => $postData->notiz,
'updateamum' => date('Y-m-d H:i:s'),
'updatevon' => $this->_uid,
'bearbeiter_uid' => $this->_uid,
)
);
$this->terminateWithSuccess($updateData);
}
public function deleteTag($withZuordnung = true)
public function deleteTag($withZuordnung = true, $updatable_tags = null)
{
$postData = $this->getPostJson();
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
if (isError($post_tag))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (!hasData($post_tag))
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
{
$tags = $this->_filterTag($updatable_tags, false);
$post_tag_typ = getData($post_tag)[0]->typ;
if (!in_array($post_tag_typ, $tags))
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
}
$deleteNotiz = "";
if ($withZuordnung)
@@ -208,5 +288,27 @@ class Tag_Controller extends FHCAPI_Controller
return hasData($result) ? getData($result)[0]->index : 1;
}
private function _filterTag($tags, $readonly = true)
{
$filtered_tags = array_filter($tags, function ($tag) use ($readonly)
{
return isset($tag['readonly']) && $tag['readonly'] === $readonly;
});
return array_keys($filtered_tags);
}
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
));
}
}