error monitoring (issues): renamded variables, improved comments

This commit is contained in:
KarpAlex
2021-10-13 08:53:12 +02:00
parent 175d75c70d
commit 45bb288127
2 changed files with 15 additions and 14 deletions
@@ -90,7 +90,7 @@ class Issues extends Auth_Controller
private function _getOesForIssues()
{
// get oes of uid for which there is a current funktion
$all_oe_kurzbz_with_funktionen = array();
$all_funktionen_oe_kurzbz = array();
$oe_kurzbz_for_funktion = array();
$benutzerfunktionRes = $this->BenutzerfunktionModel->getBenutzerFunktionByUid($this->_uid, null, date('Y-m-d'), date('Y-m-d'));
@@ -101,13 +101,14 @@ class Issues extends Auth_Controller
{
foreach (getData($benutzerfunktionRes) as $benutzerfunktion)
{
$all_oe_kurzbz_with_funktionen[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz;
$all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz;
// separate oes for the funktion needed for displaying issues
if ($benutzerfunktion->funktion_kurzbz == self::FUNKTION_KURZBZ)
{
$oe_kurzbz_for_funktion[] = $benutzerfunktion->oe_kurzbz;
// permission also for all oes under the oe for which funktion is assigend
$childOesFunktionRes = $this->OrganisationseinheitModel->getChilds($benutzerfunktion->oe_kurzbz);
if (isError($childOesFunktionRes))
@@ -127,14 +128,14 @@ class Issues extends Auth_Controller
}
}
// add oes for which there is the issues_verwalten Berechtigung
// add oes for which there is the "manage issues" Berechtigung
if (!$oe_kurzbz_berechtigt = $this->permissionlib->getOE_isEntitledFor(self::BERECHTIGUNG_KURZBZ))
show_error('Keine Berechtigung oder Fehler bei Berechtigungsprüfung');
$all_oe_kurzbz_berechtigt = array_unique(array_merge($oe_kurzbz_for_funktion, $oe_kurzbz_berechtigt));
return array(
'all_oe_kurzbz_with_funktionen' => $all_oe_kurzbz_with_funktionen,
'all_funktionen_oe_kurzbz' => $all_funktionen_oe_kurzbz,
'all_oe_kurzbz_berechtigt' => $all_oe_kurzbz_berechtigt
);
}
+10 -10
View File
@@ -1,7 +1,7 @@
<?php
$PERSON_ID = getAuthPersonId();
$ALL_OE_KURZBZ = "('" . implode("','", array_keys($all_oe_kurzbz_with_funktionen)) . "')";
$ALL_FUNKTIONEN_OE_KURZBZ = "('" . implode("','", array_keys($all_funktionen_oe_kurzbz)) . "')";
$ALL_OE_KURZBZ_BERECHTIGT = "('" . implode("','", $all_oe_kurzbz_berechtigt) . "')";
$RELEVANT_PRESTUDENT_STATUS = "('Aufgenommener', 'Student', 'Incoming', 'Diplomand', 'Abbrecher', 'Unterbrecher', 'Absolvent')";
@@ -23,12 +23,12 @@ $query = "SELECT issue_id, fehlercode AS \"Fehlercode\", iss.fehlercode_extern A
AND (
person_id = ".$PERSON_ID." /* person_id in fehler_zustaendigkeit for individual persons */";
if (!isEmptyArray($all_oe_kurzbz_with_funktionen))
if (!isEmptyArray($all_funktionen_oe_kurzbz))
{
$query .= " OR (zst.oe_kurzbz IN $ALL_OE_KURZBZ AND zst.funktion_kurzbz IS NULL) /* if oe is specified in fehler_zustaendigkeiten */";
$query .= " OR (zst.oe_kurzbz IN $ALL_FUNKTIONEN_OE_KURZBZ AND zst.funktion_kurzbz IS NULL) /* if oe is specified in fehler_zustaendigkeiten */";
// check for each oe for each function if zustaendig
foreach ($all_oe_kurzbz_with_funktionen as $oe_kurzbz => $funktionen_kurzbz)
foreach ($all_funktionen_oe_kurzbz as $oe_kurzbz => $funktionen_kurzbz)
{
foreach ($funktionen_kurzbz as $funktion_kurzbz)
{
@@ -39,25 +39,25 @@ if (!isEmptyArray($all_oe_kurzbz_with_funktionen))
$query .= "))"; // close AND of exists, and exists
// show issue if it is assigend to oe of uid or to student of oe of uid
// show issue if it is assigend to oe of logged in user or to student of oe of logged in user
if (!isEmptyArray($all_oe_kurzbz_berechtigt))
{
$query .= " OR iss.oe_kurzbz IN $ALL_OE_KURZBZ_BERECHTIGT /* if error is for studiengang oe */";
$query .= " OR iss.oe_kurzbz IN $ALL_OE_KURZBZ_BERECHTIGT /* if issue is for oe */";
$query .= " OR (iss.oe_kurzbz IS NULL AND EXISTS ( /* if person_id of error is a student of studiengang oe */
$query .= " OR (iss.oe_kurzbz IS NULL AND EXISTS ( /* if person_id of issue is a student of studiengang oe */
SELECT 1 FROM public.tbl_prestudent ps
JOIN public.tbl_prestudentstatus pss USING (prestudent_id)
JOIN public.tbl_studiengang stg USING (studiengang_kz)
WHERE person_id = iss.person_id
AND stg.oe_kurzbz IN $ALL_OE_KURZBZ_BERECHTIGT
AND pss.status_kurzbz IN $RELEVANT_PRESTUDENT_STATUS
AND NOT EXISTS (SELECT 1
AND NOT EXISTS (SELECT 1 /* irrelevant if already finished studies and studied a while ago */
FROM public.tbl_prestudentstatus ps_finished
JOIN public.tbl_studiensemester sem_finished USING (studiensemester_kurzbz)
WHERE prestudent_id = ps.prestudent_id /* irrelevant if already finished studies and studied a while ago */
WHERE prestudent_id = ps.prestudent_id
AND status_kurzbz IN ('Absolvent','Abbrecher','Abgewiesener')
AND datum::date + interval '2 months' < NOW()
AND EXISTS (SELECT 1 FROM public.tbl_prestudent /* if more recent prestudent exists, their oe should get the issue */
AND EXISTS (SELECT 1 FROM public.tbl_prestudent /* if more recent prestudent exists, still display the issue */
JOIN public.tbl_prestudentstatus USING (prestudent_id)
JOIN public.tbl_studiensemester USING (studiensemester_kurzbz)
WHERE tbl_prestudentstatus.status_kurzbz IN $RELEVANT_PRESTUDENT_STATUS