From a2a307aadeafa0a9a7f00b0d2d9b2f95df56bf67 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 21 Feb 2022 16:43:44 +0100 Subject: [PATCH 1/8] Changed permission to allow stgl assistance reading Uebersicht- and Detailseite --- .../anrechnung/ApproveAnrechnungDetail.php | 27 +++++++++++++------ .../ApproveAnrechnungUebersicht.php | 4 +-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index 8e1b601aa..e98b09bdb 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -22,8 +22,8 @@ class approveAnrechnungDetail extends Auth_Controller // Set required permissions parent::__construct( array( - 'index' => 'lehre/anrechnung_genehmigen:rw', - 'download' => 'lehre/anrechnung_genehmigen:rw', + 'index' => 'lehre/anrechnung_genehmigen:r', + 'download' => 'lehre/anrechnung_genehmigen:r', 'approve' => 'lehre/anrechnung_genehmigen:rw', 'reject' => 'lehre/anrechnung_genehmigen:rw', 'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw', @@ -421,13 +421,10 @@ class approveAnrechnungDetail extends Auth_Controller 'lehrveranstaltung_id' => getData($result)[0]->lehrveranstaltung_id )); - if(!hasData($result)) - { - show_error('Failed loading Lehrveranstaltung'); - } + $studiengang_kz = getData($result)[0]->studiengang_kz; - // Get STGL - $result = $this->StudiengangModel->getLeitung(getData($result)[0]->studiengang_kz); + // Check if user is STGL + $result = $this->StudiengangModel->getLeitung($studiengang_kz); if (hasData($result)) { @@ -440,6 +437,20 @@ class approveAnrechnungDetail extends Auth_Controller } } + // Check if user is Assistance + $result = $this->StudiengangModel->getAssistance($studiengang_kz); + + if (hasData($result)) + { + foreach (getData($result) as $assistance) + { + if ($assistance->uid == $this->_uid) + { + return; + } + } + } + show_error('You are not entitled to read this Anrechnung'); } diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 25c802caf..311828144 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -19,8 +19,8 @@ class approveAnrechnungUebersicht extends Auth_Controller // Set required permissions parent::__construct( array( - 'index' => 'lehre/anrechnung_genehmigen:rw', - 'download' => 'lehre/anrechnung_genehmigen:rw', + 'index' => 'lehre/anrechnung_genehmigen:r', + 'download' => 'lehre/anrechnung_genehmigen:r', 'approve' => 'lehre/anrechnung_genehmigen:rw', 'reject' => 'lehre/anrechnung_genehmigen:rw', 'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw' From d57a62dbe383e157e729eaa6cd6c2c128f805700 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 21 Feb 2022 16:49:03 +0100 Subject: [PATCH 2/8] Adapted method getLeitung in Studiengang Model to accept studiengang array --- .../models/organisation/Studiengang_model.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index 6358ca81e..d928f4e61 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -450,8 +450,9 @@ class Studiengang_model extends DB_Model } /** - * Get Studiengangsleitung - * @param null $studiengang_kz + * Get Studiengangsleitung/en of Studiengang/Studiengaenge. + * + * @param null $studiengang_kz Numeric or Array * @return array */ public function getLeitung($studiengang_kz = null) @@ -469,13 +470,17 @@ class Studiengang_model extends DB_Model AND ( datum_bis >= NOW() OR datum_bis IS NULL ) '; } - elseif (is_numeric($studiengang_kz)) + elseif (is_numeric($studiengang_kz) || is_array($studiengang_kz)) { + if (is_array($studiengang_kz)) + { + $studiengang_kz = implode(', ', $studiengang_kz); + } $condition = ' funktion_kurzbz = \'Leitung\' AND ( datum_von <= NOW() OR datum_von IS NULL ) AND ( datum_bis >= NOW() OR datum_bis IS NULL ) - AND studiengang_kz = ' . $this->db->escape($studiengang_kz) + AND studiengang_kz IN (' . $this->db->escape($studiengang_kz). ')'; ; } From d2055f759e71fb8bf144b612697c762516411ca5 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 21 Feb 2022 16:52:13 +0100 Subject: [PATCH 3/8] Added method getAssistance in Studiengang Model --- .../models/organisation/Studiengang_model.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index d928f4e61..a27d07f8b 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -487,6 +487,45 @@ class Studiengang_model extends DB_Model return $this->loadWhere($condition); } + /** + * Get Assistance/s of Studiengang/Studiengaenge. + * + * @param null $studiengang_kz String or Array + * @return array + */ + public function getAssistance($studiengang_kz = null) + { + $this->addSelect('uid, studiengang_kz, oe_kurzbz, vorname, nachname, email'); + $this->addJoin('public.tbl_benutzerfunktion', 'oe_kurzbz'); + $this->addJoin('public.tbl_benutzer', 'uid'); + $this->addJoin('public.tbl_person', 'person_id'); + + if (is_null($studiengang_kz)) + { + $condition = ' + funktion_kurzbz = \'Leitung\' + AND ( datum_von <= NOW() OR datum_von IS NULL ) + AND ( datum_bis >= NOW() OR datum_bis IS NULL ) + '; + } + elseif (is_numeric($studiengang_kz) || is_array($studiengang_kz)) + { + if (is_array($studiengang_kz)) + { + $studiengang_kz = implode(', ', $studiengang_kz); + } + + $condition = ' + funktion_kurzbz = \'ass\' + AND ( datum_von <= NOW() OR datum_von IS NULL ) + AND ( datum_bis >= NOW() OR datum_bis IS NULL ) + AND studiengang_kz IN (' . $this->db->escape($studiengang_kz). ')' + ; + } + + return $this->loadWhere($condition); + } + public function getStudiengaengeWithOrgForm($typ, $semester) { $query = "SELECT DISTINCT (UPPER(sg.typ || sg.kurzbz || ':' || sp.orgform_kurzbz)) AS Studiengang From b1f171aee2390befad72b15eff9bcbcb2a17f8b6 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 21 Feb 2022 16:53:30 +0100 Subject: [PATCH 4/8] Changed permission function to allow stgl assistance download on Uebersicht- and Detailseite --- .../anrechnung/ApproveAnrechnungDetail.php | 38 +++++++++++++------ .../ApproveAnrechnungUebersicht.php | 20 +++++++++- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index e98b09bdb..b818546fc 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -471,21 +471,35 @@ class approveAnrechnungDetail extends Auth_Controller 'lehrveranstaltung_id' => $result->lehrveranstaltung_id )); - if(!$result = getData($result)[0]) - { - show_error('Failed loading Lehrveranstaltung'); - } + $studiengang_kz = getData($result)[0]->studiengang_kz; // Get STGL - $result = $this->StudiengangModel->getLeitung($result->studiengang_kz); + $result = $this->StudiengangModel->getLeitung($studiengang_kz); - if($result = getData($result)[0]) - { - if ($result->uid == $this->_uid) - { - return; - } - } + if (hasData($result)) + { + foreach (getData($result) as $stgl) + { + if ($stgl->uid == $this->_uid) + { + return; + } + } + } + + // Check if user is Assistance + $result = $this->StudiengangModel->getAssistance($studiengang_kz); + + if (hasData($result)) + { + foreach (getData($result) as $assistance) + { + if ($assistance->uid == $this->_uid) + { + return; + } + } + } show_error('You are not entitled to read this document'); } diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 311828144..c667c9d33 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -281,9 +281,11 @@ class approveAnrechnungUebersicht extends Auth_Controller { show_error('Failed loading Lehrveranstaltung'); } + + $studiengang_kz = $result->studiengang_kz; - // Get STGL - $result = $this->StudiengangModel->getLeitung($result->studiengang_kz); + // Check if user is STGL + $result = $this->StudiengangModel->getLeitung($studiengang_kz); if (hasData($result)) { @@ -295,6 +297,20 @@ class approveAnrechnungUebersicht extends Auth_Controller } } } + + // Check if user is Assistance + $result = $this->StudiengangModel->getAssistance($studiengang_kz); + + if (hasData($result)) + { + foreach (getData($result) as $assistance) + { + if ($assistance->uid == $this->_uid) + { + return; + } + } + } show_error('You are not entitled to read this document'); } From 9abc018e086c44a8369223ebbd5242b9598db87f Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 21 Feb 2022 17:19:02 +0100 Subject: [PATCH 5/8] Removed db->escape when using getLeitung/getAssistance method ...it throws an error since query was adapted to accept array and anyway, is not necessary anymore. --- application/models/organisation/Studiengang_model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index a27d07f8b..299b24d86 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -480,7 +480,7 @@ class Studiengang_model extends DB_Model funktion_kurzbz = \'Leitung\' AND ( datum_von <= NOW() OR datum_von IS NULL ) AND ( datum_bis >= NOW() OR datum_bis IS NULL ) - AND studiengang_kz IN (' . $this->db->escape($studiengang_kz). ')'; + AND studiengang_kz IN (' . $studiengang_kz. ')'; ; } @@ -519,7 +519,7 @@ class Studiengang_model extends DB_Model funktion_kurzbz = \'ass\' AND ( datum_von <= NOW() OR datum_von IS NULL ) AND ( datum_bis >= NOW() OR datum_bis IS NULL ) - AND studiengang_kz IN (' . $this->db->escape($studiengang_kz). ')' + AND studiengang_kz IN (' . $studiengang_kz. ')' ; } From 339f82291c60f77a26c507a58c6b68c4dbb30b13 Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 22 Feb 2022 16:26:33 +0100 Subject: [PATCH 6/8] Disabled edit elements / create Anrechnung in GUI if user has readonly access / no permission to create Anrechnung --- .../anrechnung/ApproveAnrechnungDetail.php | 7 +++- .../ApproveAnrechnungUebersicht.php | 16 +++++++-- application/libraries/AnrechnungLib.php | 1 + .../anrechnung/approveAnrechnungDetail.php | 5 +-- .../approveAnrechnungUebersicht.php | 7 ++-- .../anrechnung/approveAnrechnungDetail.js | 34 ++++++++++++++++++ .../anrechnung/approveAnrechnungUebersicht.js | 36 +++++++++++++++++++ system/phrasesupdate.php | 22 +++++++++++- 8 files changed, 118 insertions(+), 10 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index b818546fc..5a3c4ba27 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -99,11 +99,16 @@ class approveAnrechnungDetail extends Auth_Controller // Get Genehmigung data $genehmigungData = $this->anrechnunglib->getGenehmigungData($anrechnung_id); + $hasReadOnlyAccess = + $this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's', $antragData->studiengang_kz) + && !$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 'suid', $antragData->studiengang_kz); + $viewData = array( 'antragData' => $antragData, 'anrechnungData' => $anrechnungData, 'empfehlungData' => $empfehlungData, - 'genehmigungData' => $genehmigungData + 'genehmigungData' => $genehmigungData, + 'hasReadOnlyAccess' => $hasReadOnlyAccess ); $this->load->view('lehre/anrechnung/approveAnrechnungDetail.php', $viewData); diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index c667c9d33..2030f9923 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -5,7 +5,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class approveAnrechnungUebersicht extends Auth_Controller { const BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN = 'lehre/anrechnung_genehmigen'; - + const BERECHTIGUNG_ANRECHNUNG_ANLEGEN = 'lehre/anrechnung_anlegen'; + const REVIEW_ANRECHNUNG_URI = '/lehre/anrechnung/ReviewAnrechnungUebersicht'; const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP'; @@ -76,10 +77,19 @@ class approveAnrechnungUebersicht extends Auth_Controller { show_error(getError($studiengang_kz_arr)); } - + + $hasReadOnlyAccess = + $this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's') + && !$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 'suid'); + + // This permission is checked here to disable create Anrechnung button, if permission is not given + $hasCreateAnrechnungAccess = $this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_ANLEGEN, 's'); + $viewData = array( 'studiensemester_selected' => $studiensemester_kurzbz, - 'studiengaenge_entitled' => $studiengang_kz_arr + 'studiengaenge_entitled' => $studiengang_kz_arr, + 'hasReadOnlyAccess' => $hasReadOnlyAccess, + 'hasCreateAnrechnungAccess' => $hasCreateAnrechnungAccess ); $this->load->view('lehre/anrechnung/approveAnrechnungUebersicht.php', $viewData); diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index 3bec62dce..ee197ab05 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -89,6 +89,7 @@ class AnrechnungLib $antrag_data->vorname = $person->vorname; $antrag_data->nachname = $person->nachname; $antrag_data->matrikelnr = $student->matrikelnr; + $antrag_data->studiengang_kz = $studiengang->studiengang_kz; $antrag_data->stg_bezeichnung = $studiengang->bezeichnung; $antrag_data->lektoren = $lv_lektoren_arr; $antrag_data->zgv = $latest_zgv_bezeichnung; diff --git a/application/views/lehre/anrechnung/approveAnrechnungDetail.php b/application/views/lehre/anrechnung/approveAnrechnungDetail.php index 4603708f4..cd38fd9ac 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/approveAnrechnungDetail.php @@ -25,7 +25,8 @@ $this->load->view( 'bitteBegruendungAngeben', 'empfehlungWurdeAngefordert', 'anrechnungenWurdenGenehmigt', - 'anrechnungenWurdenAbgelehnt' + 'anrechnungenWurdenAbgelehnt', + 'nurLeseberechtigung' ), 'person' => array( 'student', @@ -72,7 +73,7 @@ $this->load->view( -
+
diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php index 850affeea..308f702a3 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php @@ -48,7 +48,8 @@ $this->load->view( 'empfehlungWurdeAngefordert', 'empfehlungWurdeAngefordertAusnahmeWoKeineLektoren', 'anrechnungenWurdenGenehmigt', - 'anrechnungenWurdenAbgelehnt' + 'anrechnungenWurdenAbgelehnt', + 'nurLeseberechtigung' ), 'person' => array( 'student', @@ -101,7 +102,7 @@ $this->load->view(
-
+
widgetlib->widget( @@ -226,7 +227,7 @@ $this->load->view( class='fa fa-times'>
- ' target='_blank'> + ' target='_blank'> p->t('global', 'antragAnlegen'); ?>
diff --git a/public/js/lehre/anrechnung/approveAnrechnungDetail.js b/public/js/lehre/anrechnung/approveAnrechnungDetail.js index c2c2899ee..c5c0519f3 100644 --- a/public/js/lehre/anrechnung/approveAnrechnungDetail.js +++ b/public/js/lehre/anrechnung/approveAnrechnungDetail.js @@ -10,6 +10,7 @@ $(function(){ const genehmigung_panel = $('#approveAnrechnungDetail-genehmigung-panel'); const begruendung_panel = $('#approveAnrechnungDetail-begruendung-panel'); + const hasReadOnlyAccess = $('#approveAnrechnungDetail-generell').data('readonly'); // Pruefen ob Promise unterstuetzt wird // Tabulator funktioniert nicht mit IE @@ -21,6 +22,11 @@ $(function(){ return; } + if (hasReadOnlyAccess) + { + approveAnrechnungDetail.disableEditElements(); + } + // Set status alert color approveAnrechnungDetail.setStatusAlertColor(); @@ -417,6 +423,34 @@ var approveAnrechnungDetail = { } ); }, + disableEditElements: function() + { + // Disable: + // ...button Empfehlung anfordern + $('#approveAnrechnungDetail-request-recommendation') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ...button Empfehlung zuruecknehmen + $('#approveAnrechnungDetail-withdraw-request-recommedation') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ...button Genehmigen + $('#approveAnrechnungDetail-approve-anrechnung-ask') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ...button Ablehnen + $('#approveAnrechnungDetail-reject-anrechnung-ask') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ...button Genehmigung zurücknehmen + $('#approveAnrechnungDetail-withdraw-anrechnung-approvement') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ... form Empfehlungsnotiz + $('#form-empfehlungNotiz :input') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + }, copyIntoTextarea: function(elem){ // Find closest textarea diff --git a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js index ff3235e52..fe78217b9 100644 --- a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js +++ b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js @@ -148,6 +148,8 @@ $(function(){ const genehmigung_panel = $('#approveAnrechnungUebersicht-genehmigung-panel'); const begruendung_panel = $('#approveAnrechnungUebersicht-begruendung-panel'); + const hasReadOnlyAccess = $('#formApproveAnrechnungUebersicht').data('readonly'); + const hasCreateAnrechnungAccess = $('#formApproveAnrechnungUebersicht').data('createaccess'); // Pruefen ob Promise unterstuetzt wird // Tabulator funktioniert nicht mit IE @@ -165,6 +167,16 @@ $(function(){ $('#tableWidgetTabulator').tabulator('redraw', true); }); + if (hasReadOnlyAccess) + { + approveAnrechnung.disableEditElements(); + } + + if (!hasCreateAnrechnungAccess) + { + approveAnrechnung.disableCreateAnrechnungButton(); + } + // Set status alert color approveAnrechnung.setStatusAlertColor(); @@ -517,6 +529,30 @@ var approveAnrechnung = { $('#requestAnrechnung-status_kurzbz').closest('div').addClass('alert-warning'); } }, + disableEditElements: function() + { + // Disable: + // ...button Empfehlung anfordern + $('#approveAnrechnungUebersicht-request-recommendation') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ...button Ablehnen + $('#approveAnrechnungUebersicht-reject-anrechnungen-ask') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + // ...button Genehmigen + $('#approveAnrechnungUebersicht-approve-anrechnungen-ask') + .prop('disabled', true) + .attr('title', FHC_PhrasesLib.t("ui", "nurLeseberechtigung")); + + }, + disableCreateAnrechnungButton: function() + { + // Disable button Antrag anlegen + $('#approveAnrechnungUebersicht-create-anrechnung') + .removeAttr('href') + .css({'color': 'grey', 'pointer-events': 'none'}); // property disabled does not work for link + }, copyIntoTextarea: function(elem){ // Find closest textarea diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 1baffa93b..f96b0eb0c 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -13694,7 +13694,27 @@ array( 'insertvon' => 'system' ) ) - ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'nurLeseberechtigung', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => "Nur Leseberechtigung", + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => "Read-Only Access", + 'description' => '', + 'insertvon' => 'system' + ) + ) + ) ); From 09954c479ca08f9d92e8d01781d5c46558050929 Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 23 Feb 2022 09:45:45 +0100 Subject: [PATCH 7/8] Changed: Now checking by permission and not by benutzerfunktion Before, permission for page access and download was checked by benutzerfunktion. This did not allow access by user with corresponding permissions, like admins. Therfore changed to check by permission only. --- .../anrechnung/ApproveAnrechnungDetail.php | 64 +++---------------- .../ApproveAnrechnungUebersicht.php | 32 ++-------- 2 files changed, 12 insertions(+), 84 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index 5a3c4ba27..28edf4824 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -81,7 +81,7 @@ class approveAnrechnungDetail extends Auth_Controller } // Check if user is entitled to read the Anrechnung - self::_checkIfEntitledToReadAnrechnung($anrechnung_id); + $this->_checkIfEntitledToReadAnrechnung($anrechnung_id); // Get Anrechung data $anrechnungData = $this->anrechnunglib->getAnrechnungData($anrechnung_id); @@ -390,7 +390,7 @@ class approveAnrechnungDetail extends Auth_Controller } // Check if user is entitled to read dms doc - self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->_checkIfEntitledToReadDMSDoc($dms_id); // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); @@ -428,35 +428,11 @@ class approveAnrechnungDetail extends Auth_Controller $studiengang_kz = getData($result)[0]->studiengang_kz; - // Check if user is STGL - $result = $this->StudiengangModel->getLeitung($studiengang_kz); - - if (hasData($result)) - { - foreach (getData($result) as $stgl) - { - if ($stgl->uid == $this->_uid) - { - return; - } - } - } - - // Check if user is Assistance - $result = $this->StudiengangModel->getAssistance($studiengang_kz); - - if (hasData($result)) + // Check if user is entitled + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's', $studiengang_kz)) { - foreach (getData($result) as $assistance) - { - if ($assistance->uid == $this->_uid) - { - return; - } - } + show_error('You are not entitled to read this page'); } - - show_error('You are not entitled to read this Anrechnung'); } /** @@ -478,35 +454,11 @@ class approveAnrechnungDetail extends Auth_Controller $studiengang_kz = getData($result)[0]->studiengang_kz; - // Get STGL - $result = $this->StudiengangModel->getLeitung($studiengang_kz); - - if (hasData($result)) + // Check if user is entitled + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's', $studiengang_kz)) { - foreach (getData($result) as $stgl) - { - if ($stgl->uid == $this->_uid) - { - return; - } - } + show_error('You are not entitled to read this document'); } - - // Check if user is Assistance - $result = $this->StudiengangModel->getAssistance($studiengang_kz); - - if (hasData($result)) - { - foreach (getData($result) as $assistance) - { - if ($assistance->uid == $this->_uid) - { - return; - } - } - } - - show_error('You are not entitled to read this document'); } /** diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 2030f9923..053988848 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -249,7 +249,7 @@ class approveAnrechnungUebersicht extends Auth_Controller } // Check if user is entitled to read dms doc - self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->_checkIfEntitledToReadDMSDoc($dms_id); // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); @@ -294,35 +294,11 @@ class approveAnrechnungUebersicht extends Auth_Controller $studiengang_kz = $result->studiengang_kz; - // Check if user is STGL - $result = $this->StudiengangModel->getLeitung($studiengang_kz); - - if (hasData($result)) - { - foreach (getData($result) as $stgl) - { - if ($stgl->uid == $this->_uid) - { - return; - } - } - } - - // Check if user is Assistance - $result = $this->StudiengangModel->getAssistance($studiengang_kz); - - if (hasData($result)) + // Check if user is entitled + if (!$this->permissionlib->isBerechtigt(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN, 's', $studiengang_kz)) { - foreach (getData($result) as $assistance) - { - if ($assistance->uid == $this->_uid) - { - return; - } - } + show_error('You are not entitled to read this document'); } - - show_error('You are not entitled to read this document'); } /** From 18731ede47f7f5fb03d09df8de6fc3f013057f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Fri, 25 Feb 2022 11:59:38 +0100 Subject: [PATCH 8/8] Laden von Studiengangsleitungen angepasst, Error Handling bei fehenden Studiengangsleitungen --- .../anrechnung/ReviewAnrechnungDetail.php | 31 +++-- .../anrechnung/ReviewAnrechnungUebersicht.php | 115 ++++++++++-------- .../models/organisation/Studiengang_model.php | 53 ++------ 3 files changed, 92 insertions(+), 107 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php index 78175f4e6..7981f0ac8 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php @@ -79,7 +79,7 @@ class reviewAnrechnungDetail extends Auth_Controller // Get Anrechung data $anrechnungData = $this->anrechnunglib->getAnrechnungData($anrechnung_id); - + // Get Antrag data $antragData = $this->anrechnunglib->getAntragData( $anrechnungData->prestudent_id, @@ -110,7 +110,7 @@ class reviewAnrechnungDetail extends Auth_Controller { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + // Get lectors person data if (!$person = getData($this->PersonModel->getByUID($this->_uid))[0]) { @@ -218,10 +218,10 @@ class reviewAnrechnungDetail extends Auth_Controller // Check if user is entitled to read dms doc self::_checkIfEntitledToReadDMSDoc($dms_id); - + // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); - + // Download file $this->dmslib->download($dms_id, $filename); } @@ -320,7 +320,12 @@ class reviewAnrechnungDetail extends Auth_Controller foreach ($studiengang_kz_arr as $studiengang_kz) { // Get STGL mail address, if available, otherwise get assistance mail address - list ($to, $vorname) = $this->_getSTGLMailAddress($studiengang_kz); + $stgmail = $this->_getSTGLMailAddress($studiengang_kz); + + if(isSuccess($stgmail) && hasData($stgmail)) + list ($to, $vorname) = getData($stgmail)[0]; + else + show_error ('Failed retrieving DegreeProgram Mail'); // Get full name of lector $this->load->model('person/Person_model', 'PersonModel'); @@ -361,24 +366,28 @@ class reviewAnrechnungDetail extends Auth_Controller $result = $this->StudiengangModel->getLeitung($stg_kz); // Get STGL mail address, if available - if (hasData($result)) + if (isSuccess($result) && hasData($result)) { - return array( + return success(array( $result->retval[0]->uid. '@'. DOMAIN, $result->retval[0]->vorname - ); + )); } // ...otherwise get assistance mail address else { $result = $this->StudiengangModel->load($stg_kz); - if (hasData($result)) + if (isSuccess($result) && hasData($result)) { - return array( + return success(array( $result->retval[0]->email, '' - ); + )); + } + else + { + return error('Keine E-Mail für diesen Stg gefunden'); } } } diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php index cd0b7afaf..e5475d0d0 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php @@ -5,15 +5,15 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class reviewAnrechnungUebersicht extends Auth_Controller { const BERECHTIGUNG_ANRECHNUNG_EMPFEHLEN = 'lehre/anrechnung_empfehlen'; - + const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht'; - + const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP'; const ANRECHNUNGSTATUS_PROGRESSED_BY_KF = 'inProgressKF'; const ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR = 'inProgressLektor'; const ANRECHNUNGSTATUS_APPROVED = 'approved'; const ANRECHNUNGSTATUS_REJECTED = 'rejected'; - + public function __construct() { // Set required permissions @@ -25,24 +25,24 @@ class reviewAnrechnungUebersicht extends Auth_Controller 'dontRecommend' => 'lehre/anrechnung_empfehlen:rw' ) ); - + // Load models $this->load->model('education/Anrechnung_model', 'AnrechnungModel'); $this->load->model('education/Anrechnungstatus_model', 'AnrechnungstatusModel'); $this->load->model('content/DmsVersion_model', 'DmsVersionModel'); $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); - + // Load libraries $this->load->library('WidgetLib'); $this->load->library('PermissionLib'); $this->load->library('AnrechnungLib'); $this->load->library('DmsLib'); - + // Load helpers $this->load->helper('form'); $this->load->helper('url'); $this->load->helper('hlp_sancho_helper'); - + // Load language phrases $this->loadPhrases( array( @@ -54,12 +54,12 @@ class reviewAnrechnungUebersicht extends Auth_Controller 'table' ) ); - + $this->_setAuthUID(); - + $this->setControllerId(); } - + public function index() { // Get study semester @@ -70,14 +70,14 @@ class reviewAnrechnungUebersicht extends Auth_Controller $result = $this->StudiensemesterModel->getNearest(); $studiensemester_kurzbz = getData($result)[0]->studiensemester_kurzbz; } - + $viewData = array( 'studiensemester_selected' => $studiensemester_kurzbz ); - + $this->load->view('lehre/anrechnung/reviewAnrechnungUebersicht.php', $viewData); } - + /** * Recommend Anrechnungen. */ @@ -103,7 +103,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller ); } } - + // Output json to ajax if (isset($json) && !isEmptyArray($json)) { @@ -123,19 +123,19 @@ class reviewAnrechnungUebersicht extends Auth_Controller return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); } } - + /** * Dont recommend Anrechnungen. */ public function dontRecommend() { $data = $this->input->post('data'); - + if(isEmptyArray($data)) { return $this->outputJsonError('Fehler beim Übertragen der Daten.'); } - + foreach ($data as $item) { // Approve Anrechnung @@ -149,7 +149,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller ); } } - + // Output json to ajax if (isset($json) && !isEmptyArray($json)) { @@ -158,7 +158,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller { show_error('Failed sending emails'); } - + return $this->outputJsonSuccess($json); } else @@ -166,7 +166,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller return $this->outputJsonError($this->p->t('ui', 'errorNichtAusgefuehrt')); } } - + /** * Download and open uploaded document (Nachweisdokument). */ @@ -178,28 +178,28 @@ class reviewAnrechnungUebersicht extends Auth_Controller { show_error('Wrong parameter'); } - + // Check if user is entitled to read dms doc self::_checkIfEntitledToReadDMSDoc($dms_id); - + // Set filename to be used on downlaod $filename = $this->anrechnunglib->setFilenameOnDownload($dms_id); - + // Download file $this->dmslib->download($dms_id, $filename); } - - + + /** * Retrieve the UID of the logged user and checks if it is valid */ private function _setAuthUID() { $this->_uid = getAuthUID(); - + if (!$this->_uid) show_error('User authentification failed'); } - + /** * Check if user is entitled to read dms doc * @param $dms_id @@ -207,15 +207,15 @@ class reviewAnrechnungUebersicht extends Auth_Controller private function _checkIfEntitledToReadDMSDoc($dms_id) { $result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id)); - + if(!$result = getData($result)[0]) { show_error('Failed retrieving Anrechnung'); } - + $result = $this->LehrveranstaltungModel ->getLecturersByLv($result->studiensemester_kurzbz, $result->lehrveranstaltung_id); - + if($result = getData($result)) { $entitled_lector_arr = array_column($result, 'uid'); @@ -225,10 +225,10 @@ class reviewAnrechnungUebersicht extends Auth_Controller return; } } - + show_error('You are not entitled to read this document'); } - + /** * Send mails to STGL (if not present then to STGL assistance) * @param $mail_params @@ -239,36 +239,41 @@ class reviewAnrechnungUebersicht extends Auth_Controller { // Get studiengaenge $studiengang_kz_arr = array(); - + foreach ($mail_params as $item) { $this->AnrechnungModel->addSelect('studiengang_kz'); $this->AnrechnungModel->addJoin('public.tbl_prestudent', 'prestudent_id'); - + $studiengang_kz_arr[]= $this->AnrechnungModel->load($item['anrechnung_id'])->retval[0]->studiengang_kz; } - + $studiengang_kz_arr = array_unique($studiengang_kz_arr); - + // Send mail to STGL of each studiengang foreach ($studiengang_kz_arr as $studiengang_kz) { // Get STGL mail address, if available, otherwise get assistance mail address - list ($to, $vorname) = $this->_getSTGLMailAddress($studiengang_kz); - + $stgmail = $this->_getSTGLMailAddress($studiengang_kz); + + if(isSuccess($stgmail) && hasData($stgmail)) + list ($to, $vorname) = getData($stgmail)[0]; + else + show_error ('Failed retrieving DegreeProgram Mail'); + // Get full name of lector $this->load->model('person/Person_model', 'PersonModel'); if (!$lector_name = getData($this->PersonModel->getFullName($this->_uid))) { show_error ('Failed retrieving person'); } - + // Link to Antrag genehmigen $url = CIS_ROOT. 'cis/index.php?menu='. CIS_ROOT. 'cis/menu.php?content_id=&content='. CIS_ROOT. index_page(). self::APPROVE_ANRECHNUNG_URI; - + // Prepare mail content $body_fields = array( 'vorname' => $vorname, @@ -276,7 +281,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller 'empfehlung' => $empfehlung ? 'positive' : 'negative', 'link' => anchor($url, 'Anrechnungsanträge Übersicht') ); - + sendSanchoMail( 'AnrechnungEmpfehlungAbgeben', $body_fields, @@ -284,37 +289,41 @@ class reviewAnrechnungUebersicht extends Auth_Controller 'Anerkennung nachgewiesener Kenntnisse: Empfehlung wurde abgegeben' ); } - + return true; } - + // Get STGL mail address, if available, otherwise get assistance mail address private function _getSTGLMailAddress($stg_kz) { $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); $result = $this->StudiengangModel->getLeitung($stg_kz); - + // Get STGL mail address, if available - if (hasData($result)) + if (isSuccess($result) && hasData($result)) { - return array( + return success(array( $result->retval[0]->uid. '@'. DOMAIN, $result->retval[0]->vorname - ); + )); } // ...otherwise get assistance mail address else { $result = $this->StudiengangModel->load($stg_kz); - - if (hasData($result)) + + if (isSuccess($result) && hasData($result)) { - return array( + return success(array( $result->retval[0]->email, '' - ); + )); + } + else + { + return error('Keine E-Mail für diesen Stg gefunden'); } } } - -} \ No newline at end of file + +} diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index 299b24d86..e2b3bdfb7 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -448,10 +448,10 @@ class Studiengang_model extends DB_Model return $this->execQuery($query, array($typ)); } - + /** * Get Studiengangsleitung/en of Studiengang/Studiengaenge. - * + * * @param null $studiengang_kz Numeric or Array * @return array */ @@ -461,7 +461,12 @@ class Studiengang_model extends DB_Model $this->addJoin('public.tbl_benutzerfunktion', 'oe_kurzbz'); $this->addJoin('public.tbl_benutzer', 'uid'); $this->addJoin('public.tbl_person', 'person_id'); - + + if (!is_numeric($studiengang_kz) && !is_array($studiengang_kz)) + { + return error('Studiengangskennzahl ungültig'); + } + if (is_null($studiengang_kz)) { $condition = ' @@ -474,6 +479,7 @@ class Studiengang_model extends DB_Model { if (is_array($studiengang_kz)) { + $studiengang_kz = array_map(array($this,'escape'), $studiengang_kz); $studiengang_kz = implode(', ', $studiengang_kz); } $condition = ' @@ -483,49 +489,10 @@ class Studiengang_model extends DB_Model AND studiengang_kz IN (' . $studiengang_kz. ')'; ; } - + return $this->loadWhere($condition); } - /** - * Get Assistance/s of Studiengang/Studiengaenge. - * - * @param null $studiengang_kz String or Array - * @return array - */ - public function getAssistance($studiengang_kz = null) - { - $this->addSelect('uid, studiengang_kz, oe_kurzbz, vorname, nachname, email'); - $this->addJoin('public.tbl_benutzerfunktion', 'oe_kurzbz'); - $this->addJoin('public.tbl_benutzer', 'uid'); - $this->addJoin('public.tbl_person', 'person_id'); - - if (is_null($studiengang_kz)) - { - $condition = ' - funktion_kurzbz = \'Leitung\' - AND ( datum_von <= NOW() OR datum_von IS NULL ) - AND ( datum_bis >= NOW() OR datum_bis IS NULL ) - '; - } - elseif (is_numeric($studiengang_kz) || is_array($studiengang_kz)) - { - if (is_array($studiengang_kz)) - { - $studiengang_kz = implode(', ', $studiengang_kz); - } - - $condition = ' - funktion_kurzbz = \'ass\' - AND ( datum_von <= NOW() OR datum_von IS NULL ) - AND ( datum_bis >= NOW() OR datum_bis IS NULL ) - AND studiengang_kz IN (' . $studiengang_kz. ')' - ; - } - - return $this->loadWhere($condition); - } - public function getStudiengaengeWithOrgForm($typ, $semester) { $query = "SELECT DISTINCT (UPPER(sg.typ || sg.kurzbz || ':' || sp.orgform_kurzbz)) AS Studiengang