mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 15:04:04 +00:00
Merge branch 'feature-61601/Issue_Liste_hartcoded_eingeschraenkt'
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
|
// apps for which issues should be displayed
|
||||||
|
$config['issues_list_apps'] = array('core', 'dvuh');
|
||||||
|
|
||||||
|
// functions which enable users to see issues
|
||||||
|
$config['issues_list_functions'] = array('ass');
|
||||||
|
|
||||||
|
// functions which enable users to see issues
|
||||||
|
$config['issues_list_status'] = array('Aufgenommener', 'Student', 'Incoming', 'Diplomand', 'Abbrecher', 'Unterbrecher', 'Absolvent');
|
||||||
@@ -6,7 +6,6 @@ class Issues extends Auth_Controller
|
|||||||
{
|
{
|
||||||
private $_uid;
|
private $_uid;
|
||||||
|
|
||||||
const FUNKTION_KURZBZ = 'ass'; // user having this funktion can see issues for oes assigned with this funktion
|
|
||||||
const BERECHTIGUNG_KURZBZ = 'system/issues_verwalten'; // user having this permission can see issues for oes assigned with this permission
|
const BERECHTIGUNG_KURZBZ = 'system/issues_verwalten'; // user having this permission can see issues for oes assigned with this permission
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -28,6 +27,9 @@ class Issues extends Auth_Controller
|
|||||||
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
||||||
$this->load->model('system/Sprache_model', 'SpracheModel');
|
$this->load->model('system/Sprache_model', 'SpracheModel');
|
||||||
|
|
||||||
|
// load config
|
||||||
|
$this->load->config('issueList');
|
||||||
|
|
||||||
$this->loadPhrases(
|
$this->loadPhrases(
|
||||||
array(
|
array(
|
||||||
'global',
|
'global',
|
||||||
@@ -47,10 +49,12 @@ class Issues extends Auth_Controller
|
|||||||
{
|
{
|
||||||
$oes_for_issues = $this->_getOesForIssues();
|
$oes_for_issues = $this->_getOesForIssues();
|
||||||
$language_index = $this->_getLanguageIndex();
|
$language_index = $this->_getLanguageIndex();
|
||||||
|
$apps = $this->config->item('issues_list_apps');
|
||||||
|
$status = $this->config->item('issues_list_status');
|
||||||
|
|
||||||
$this->load->view(
|
$this->load->view(
|
||||||
'system/issues/issues',
|
'system/issues/issues',
|
||||||
array_merge($oes_for_issues, array('language_index' => $language_index))
|
array_merge($oes_for_issues, array('language_index' => $language_index, 'apps' => $apps, 'status' => $status))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +125,8 @@ class Issues extends Auth_Controller
|
|||||||
$oe_kurzbz_for_funktion = array();
|
$oe_kurzbz_for_funktion = array();
|
||||||
$benutzerfunktionRes = $this->BenutzerfunktionModel->getBenutzerFunktionByUid($this->_uid, null, date('Y-m-d'), date('Y-m-d'));
|
$benutzerfunktionRes = $this->BenutzerfunktionModel->getBenutzerFunktionByUid($this->_uid, null, date('Y-m-d'), date('Y-m-d'));
|
||||||
|
|
||||||
|
$functions = $this->config->item('issues_list_functions');
|
||||||
|
|
||||||
if (isError($benutzerfunktionRes))
|
if (isError($benutzerfunktionRes))
|
||||||
show_error(getError($benutzerfunktionRes));
|
show_error(getError($benutzerfunktionRes));
|
||||||
|
|
||||||
@@ -130,8 +136,8 @@ class Issues extends Auth_Controller
|
|||||||
{
|
{
|
||||||
$all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz;
|
$all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz;
|
||||||
|
|
||||||
// separate oes for the additional funktion which enables displaying issues
|
// separate oes for the additional functions which enables displaying issues
|
||||||
if ($benutzerfunktion->funktion_kurzbz == self::FUNKTION_KURZBZ)
|
if (in_array($benutzerfunktion->funktion_kurzbz, $functions))
|
||||||
{
|
{
|
||||||
$oe_kurzbz_for_funktion[] = $benutzerfunktion->oe_kurzbz;
|
$oe_kurzbz_for_funktion[] = $benutzerfunktion->oe_kurzbz;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$PERSON_ID = getAuthPersonId();
|
$PERSON_ID = getAuthPersonId();
|
||||||
|
|
||||||
// all oe kurzbz for which logged user has a funktion
|
// all oe kurzbz for which logged user has a funktion
|
||||||
$ALL_FUNKTIONEN_OE_KURZBZ = "('" . implode("','", array_keys($all_funktionen_oe_kurzbz)) . "')";
|
$ALL_FUNKTIONEN_OE_KURZBZ = isEmptyArray($all_funktionen_oe_kurzbz) ? "(NULL)"
|
||||||
|
: "(" . implode(",", array_map(function($string) { return $this->db->escape($string); }, array_keys($all_funktionen_oe_kurzbz))) . ")";
|
||||||
|
|
||||||
// all oes for which logged user has issues permissions, including permissions for "special" issue funktion
|
// all oes for which logged user has issues permissions, including permissions for "special" issue funktion
|
||||||
$ALL_OE_KURZBZ_BERECHTIGT = "('" . implode("','", $all_oe_kurzbz_berechtigt) . "')";
|
$ALL_OE_KURZBZ_BERECHTIGT = isEmptyArray($all_oe_kurzbz_berechtigt) ? "(NULL)"
|
||||||
$RELEVANT_PRESTUDENT_STATUS = "('Aufgenommener', 'Student', 'Incoming', 'Diplomand', 'Abbrecher', 'Unterbrecher', 'Absolvent')";
|
: "(" . implode(",", array_map(function($string) { return $this->db->escape($string); }, $all_oe_kurzbz_berechtigt)) . ")";
|
||||||
|
|
||||||
|
// app apps for which issues should be displayed
|
||||||
|
$APPS = isEmptyArray($apps) ? "" : "(" . implode(",", array_map(function($string) { return $this->db->escape($string); }, $apps)) . ")";
|
||||||
|
|
||||||
|
// all prestudent status for which issues should be displayed
|
||||||
|
$RELEVANT_PRESTUDENT_STATUS = isEmptyArray($status) ? ""
|
||||||
|
: "(" . implode(",", array_map(function($string) { return $this->db->escape($string); }, $status)) . ")";
|
||||||
|
|
||||||
// get issues for the oes of the logged user or for the persons (students, oe-zuordnung) of the oes
|
// get issues for the oes of the logged user or for the persons (students, oe-zuordnung) of the oes
|
||||||
$query = "WITH zustaendigkeiten AS (
|
$query = "WITH zustaendigkeiten AS (
|
||||||
@@ -37,8 +47,8 @@ $query .= "
|
|||||||
SELECT
|
SELECT
|
||||||
issue_id, fehlercode AS \"Fehlercode\", fehler_kurzbz AS \"Fehler Kurzbezeichnung\", iss.fehlercode_extern AS \"Fehlercode extern\", datum AS \"Datum\",
|
issue_id, fehlercode AS \"Fehlercode\", fehler_kurzbz AS \"Fehler Kurzbezeichnung\", iss.fehlercode_extern AS \"Fehlercode extern\", datum AS \"Datum\",
|
||||||
inhalt AS \"Inhalt\", inhalt_extern AS \"Inhalt extern\", iss.person_id AS \"PersonId\", iss.oe_kurzbz AS \"OE\",
|
inhalt AS \"Inhalt\", inhalt_extern AS \"Inhalt extern\", iss.person_id AS \"PersonId\", iss.oe_kurzbz AS \"OE\",
|
||||||
ftyp.bezeichnung_mehrsprachig[".$language_index."] AS \"Fehlertyp\",
|
ftyp.bezeichnung_mehrsprachig[".$this->db->escape($language_index)."] AS \"Fehlertyp\",
|
||||||
stat.bezeichnung_mehrsprachig[".$language_index."] AS \"Fehlerstatus\",
|
stat.bezeichnung_mehrsprachig[".$this->db->escape($language_index)."] AS \"Fehlerstatus\",
|
||||||
verarbeitetvon AS \"Verarbeitet von\",verarbeitetamum AS \"Verarbeitet am\", fr.app AS \"Applikation\",
|
verarbeitetvon AS \"Verarbeitet von\",verarbeitetamum AS \"Verarbeitet am\", fr.app AS \"Applikation\",
|
||||||
fr.fehlertyp_kurzbz AS \"Fehlertypcode\", iss.status_kurzbz AS \"Statuscode\",
|
fr.fehlertyp_kurzbz AS \"Fehlertypcode\", iss.status_kurzbz AS \"Statuscode\",
|
||||||
pers.vorname AS \"Vorname\", pers.nachname AS \"Nachname\",
|
pers.vorname AS \"Vorname\", pers.nachname AS \"Nachname\",
|
||||||
@@ -118,44 +128,48 @@ $query .= "
|
|||||||
JOIN system.tbl_issue_status stat USING (status_kurzbz)
|
JOIN system.tbl_issue_status stat USING (status_kurzbz)
|
||||||
LEFT JOIN public.tbl_person pers ON iss.person_id = pers.person_id
|
LEFT JOIN public.tbl_person pers ON iss.person_id = pers.person_id
|
||||||
WHERE
|
WHERE
|
||||||
fr.app IN ('core', 'dvuh')
|
(
|
||||||
AND (
|
|
||||||
EXISTS ( /* if oe or person is specified in fehler_zustaendigkeiten */
|
EXISTS ( /* if oe or person is specified in fehler_zustaendigkeiten */
|
||||||
SELECT 1 FROM zustaendigkeiten
|
SELECT 1 FROM zustaendigkeiten
|
||||||
WHERE fehlercode = iss.fehlercode
|
WHERE fehlercode = iss.fehlercode
|
||||||
AND zustaendig = TRUE)";
|
AND zustaendig = TRUE)";
|
||||||
|
|
||||||
// show issue if it is assigend to oe of logged in user or to student of oe of logged in user
|
// 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 issue is for 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 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;
|
||||||
|
|
||||||
|
if (!isEmptyString($RELEVANT_PRESTUDENT_STATUS)) $query .= " AND pss.status_kurzbz IN ".$RELEVANT_PRESTUDENT_STATUS;
|
||||||
|
|
||||||
|
$query .= " 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
|
||||||
|
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, still display the issue */
|
||||||
|
JOIN public.tbl_prestudentstatus USING (prestudent_id)
|
||||||
|
JOIN public.tbl_studiensemester USING (studiensemester_kurzbz)
|
||||||
|
WHERE person_id = ps.person_id
|
||||||
|
AND prestudent_id <> ps_finished.prestudent_id
|
||||||
|
AND tbl_studiensemester.start::date > sem_finished.start::date";
|
||||||
|
|
||||||
|
if (!isEmptyString($RELEVANT_PRESTUDENT_STATUS)) $query .= " AND tbl_prestudentstatus.status_kurzbz IN ".$RELEVANT_PRESTUDENT_STATUS;
|
||||||
|
|
||||||
|
$query .= ")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)";
|
||||||
|
|
||||||
$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 /* 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
|
|
||||||
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, 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
|
|
||||||
AND person_id = ps.person_id
|
|
||||||
AND prestudent_id <> ps_finished.prestudent_id
|
|
||||||
AND tbl_studiensemester.start::date > sem_finished.start::date)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)";
|
|
||||||
}
|
|
||||||
$query .= ") ";
|
$query .= ") ";
|
||||||
|
|
||||||
|
if (!isEmptyString($APPS)) $query .= " AND fr.app IN ".$APPS;
|
||||||
|
|
||||||
$query .= " ORDER BY
|
$query .= " ORDER BY
|
||||||
CASE
|
CASE
|
||||||
WHEN fehlertyp_kurzbz = '".IssuesLib::ERRORTYPE_CODE."' THEN 0
|
WHEN fehlertyp_kurzbz = '".IssuesLib::ERRORTYPE_CODE."' THEN 0
|
||||||
|
|||||||
Reference in New Issue
Block a user