From d50ba773fe4ae033603fb0e6fe56d51b2a525de8 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Tue, 1 Aug 2023 19:26:36 +0200 Subject: [PATCH] UHSTAT 1 form: correct authentification (from bewerbungstool or with permission), beautified success and error messages, added Rechtsbelehrung, simplified parameter checking --- application/controllers/codex/UHSTAT1.php | 52 ++- application/views/codex/uhstat1.php | 419 +++++++++--------- public/css/codex/uhstat1.css | 5 + public/js/codex/uhstat1.js | 11 + ...uhstat1_daten_ueber_das_bewerbungstool.php | 14 + system/phrasesupdate.php | 20 + 6 files changed, 299 insertions(+), 222 deletions(-) create mode 100644 public/css/codex/uhstat1.css create mode 100644 public/js/codex/uhstat1.js diff --git a/application/controllers/codex/UHSTAT1.php b/application/controllers/codex/UHSTAT1.php index 3ba4760a5..0e019672a 100644 --- a/application/controllers/codex/UHSTAT1.php +++ b/application/controllers/codex/UHSTAT1.php @@ -4,6 +4,8 @@ if (! defined("BASEPATH")) exit("No direct script access allowed"); class UHSTAT1 extends FHC_Controller { + const BERECHTIGUNG_UHSTAT_VERWALTEN = 'student/uhstat1daten_verwalten'; + const PERSON_ID_SESSION_INDEX = 'bewerbung/personId'; const CODEX_OESTERREICH = 'A'; const LOWER_BOUNDARY_YEARS = 160; const UPPER_BOUNDARY_YEARS = 20; @@ -12,12 +14,7 @@ class UHSTAT1 extends FHC_Controller public function __construct() { - parent::__construct( - array( - 'index' => 'admin:r', - 'saveUHSTAT1Data' => 'admin:rw' - ) - ); + parent::__construct(); // load ci libs $this->load->library('form_validation'); @@ -25,6 +22,10 @@ class UHSTAT1 extends FHC_Controller // load ci helpers $this->load->helper(array('form', 'url')); + // load libraries + $this->load->library('AuthLib'); + $this->load->library('PermissionLib'); + // load models $this->load->model('codex/Oehbeitrag_model', 'OehbeitragModel'); $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); @@ -93,9 +94,7 @@ class UHSTAT1 extends FHC_Controller */ public function saveUHSTAT1Data() { - $person_id = $this->input->get('person_id'); - - if (!isset($person_id) || !is_numeric($person_id)) show_error("Person Id missing"); + $person_id = $this->_getValidPersonId(); $this->form_validation->set_error_delimiters('', ''); @@ -133,8 +132,10 @@ class UHSTAT1 extends FHC_Controller $uhstatData[$field] = $this->input->post($field); } + // check if entry already exists $uhstat1datenloadRes = $this->Uhstat1datenModel->loadWhere(array('person_id' => $person_id)); + // if yes, update if (hasData($uhstat1datenloadRes)) { $uhstat1datenRes = $this->Uhstat1datenModel->update( @@ -142,7 +143,7 @@ class UHSTAT1 extends FHC_Controller $uhstatData ); } - else + else // otherwise insert { $uhstat1datenRes = $this->Uhstat1datenModel->insert( array_merge($uhstatData, array('person_id' => $person_id)) @@ -210,9 +211,7 @@ class UHSTAT1 extends FHC_Controller */ private function _getFormMetaData() { - $person_id = $this->input->get('person_id'); - - if (!isset($person_id) || !is_numeric($person_id)) return error("Person Id missing"); + $person_id = $this->_getValidPersonId(); $languageIdx = $this->_getLanguageIndex(); @@ -272,9 +271,7 @@ class UHSTAT1 extends FHC_Controller */ private function _getUHSTAT1Data() { - $person_id = $this->input->get('person_id'); - - if (!isset($person_id) || !is_numeric($person_id)) return error("Person Id missing"); + $person_id = $this->_getValidPersonId(); $this->Uhstat1datenModel->addSelect( implode(', ', array_keys($this->_uhstat1Fields)) @@ -303,4 +300,27 @@ class UHSTAT1 extends FHC_Controller return $idx; } + + /** + * Gets Id of person having permissions to manage UHSTAT1 data. + * Can be passed as parameter or be in session. + * @return int person_id + */ + private function _getValidPersonId() + { + // if coming from bewerbungstool - person id is in session (person must be logged in bewerbungstool) + if (isset($_SESSION[self::PERSON_ID_SESSION_INDEX]) && is_numeric($_SESSION[self::PERSON_ID_SESSION_INDEX])) + return $_SESSION[self::PERSON_ID_SESSION_INDEX]; + + // if person id passed directly... + $person_id = $this->input->post('person_id'); + if (!isset($person_id)) $person_id = $this->input->get('person_id'); + + if (!isset($person_id) || !is_numeric($person_id)) show_error("invalid person id"); + + // ...check if there is a permission for editing UHSTAT1 data + if ($this->permissionlib->isBerechtigt(self::BERECHTIGUNG_UHSTAT_VERWALTEN, 'suid')) return $person_id; + + show_error("No permission for managing UHSTAT"); + } } diff --git a/application/views/codex/uhstat1.php b/application/views/codex/uhstat1.php index b60f518a4..b81b0b316 100644 --- a/application/views/codex/uhstat1.php +++ b/application/views/codex/uhstat1.php @@ -6,15 +6,17 @@ $this->load->view( 'jquery3' => true, 'bootstrap3' => true, 'fontawesome4' => true, - 'dialoglib' => true, 'phrases' => array( 'ui' => array('speichern') - ) + ), + 'customCSSs' => array('public/css/codex/uhstat1.css'), + 'customJSs' => array('public/js/codex/uhstat1.js') + ) ); ?> mutter_geburtsjahr) ? $uhstatData->mutter_geburtsjahr : set_value('mutter_geburtsjahr'); $mutter_geburtsstaat = isset($uhstatData->mutter_geburtsstaat) ? $uhstatData->mutter_geburtsstaat : set_value('mutter_geburtsstaat'); $mutter_bildungsstaat = isset($uhstatData->mutter_bildungsstaat) ? $uhstatData->mutter_bildungsstaat : set_value('mutter_bildungsstaat'); @@ -25,219 +27,224 @@ $vater_bildungsstaat = isset($uhstatData->vater_bildungsstaat) ? $uhstatData->va $vater_bildungmax = isset($uhstatData->vater_bildungmax) ? $uhstatData->vater_bildungmax : set_value('vater_bildungmax'); $disabled = $readonly === true ? ' disabled' : ''; ?> -
-
-

- p->t('uhstat', 'uhstat1AnmeldungUeberschrift') ?> -

-

- p->t('uhstat', 'uhstat1AnmeldungEinleitungstext') ?> -

-
-
-
- p->t('uhstat', 'angabenErziehungsberechtigte') ?> -

- p->t('uhstat', 'angabenErziehungsberechtigteEinleitungstext') ?> -

-
-

p->t('uhstat', 'erziehungsberechtigtePersonEins') ?>

-
- -
- +
+

p->t('uhstat', 'uhstat1AnmeldungUeberschrift') ?>

+

+ p->t('uhstat', 'rechtsbelehrung') ?> +

+

+ p->t('uhstat', 'uhstat1AnmeldungEinleitungstext') ?> +

+
+ + ' /> +
+ p->t('uhstat', 'angabenErziehungsberechtigte') ?> +

+ p->t('uhstat', 'angabenErziehungsberechtigteEinleitungstext') ?> +

+
+

p->t('uhstat', 'erziehungsberechtigtePersonEins') ?>

+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+

p->t('uhstat', 'erziehungsberechtigtePersonZwei') ?>

+
+ +
+ - -
+ + +
-
- -
- > + + + - - - -
+ + + +
-
- -
- > + + + - - - -
+ + + +
-
- -
- - -
+
+
+ +
+ +
-
-

p->t('uhstat', 'erziehungsberechtigtePersonZwei') ?>

-
- -
- - -
+
+
+
+
+ +
+ +
-
- -
- - -
+ + +
+ +
+
+ +   + +
-
- -
- - -
-
-
- -
- - -
-
-
-
-
-
-
- - - - -
- - -   - - -
-
-
- -
+
+
+
load->view('templates/FHC-Footer'); ?> diff --git a/public/css/codex/uhstat1.css b/public/css/codex/uhstat1.css new file mode 100644 index 000000000..621ef8547 --- /dev/null +++ b/public/css/codex/uhstat1.css @@ -0,0 +1,5 @@ +/* for removing horizontal scrollbar when form is embedded as i frame */ +#uhstat1Container { + overflow-x:hidden; + height: 100%; +} diff --git a/public/js/codex/uhstat1.js b/public/js/codex/uhstat1.js new file mode 100644 index 000000000..e5e51b09d --- /dev/null +++ b/public/js/codex/uhstat1.js @@ -0,0 +1,11 @@ +/** + * javascript file for UHSTAT1 GUI + */ +$(document).ready(function () +{ + window.setTimeout(function() { + $("#success-alert_uhstat1").fadeTo(500, 0).slideUp(500, function(){ + $(this).remove(); + }); + }, 1000); +}); diff --git a/system/dbupdate_3.4/29835_uhstat1_erfassung_der_uhstat1_daten_ueber_das_bewerbungstool.php b/system/dbupdate_3.4/29835_uhstat1_erfassung_der_uhstat1_daten_ueber_das_bewerbungstool.php index 3afc4083e..ea2ad9e98 100644 --- a/system/dbupdate_3.4/29835_uhstat1_erfassung_der_uhstat1_daten_ueber_das_bewerbungstool.php +++ b/system/dbupdate_3.4/29835_uhstat1_erfassung_der_uhstat1_daten_ueber_das_bewerbungstool.php @@ -120,3 +120,17 @@ if (!$result = @$db->db_query('SELECT 1 FROM bis.tbl_uhstat1daten LIMIT 1')) else echo ' bis.tbl_uhstat1daten: Tabelle hinzugefuegt
'; } + +// Add permission for managing UHSTAT1 data +if($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berechtigung_kurzbz = 'student/uhstat1daten_verwalten';")) +{ + if($db->db_num_rows($result) == 0) + { + $qry = "INSERT INTO system.tbl_berechtigung(berechtigung_kurzbz, beschreibung) VALUES('student/uhstat1daten_verwalten', 'UHSTAT1 Daten verwalten');"; + + if(!$db->db_query($qry)) + echo 'system.tbl_berechtigung '.$db->db_last_error().'
'; + else + echo ' system.tbl_berechtigung: Added permission for student/uhstat1daten_verwalten
'; + } +} diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index f0043ad18..75cfb0179 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -18223,6 +18223,26 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'uhstat', + 'phrase' => 'rechtsbelehrung', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'gemäß § 18 Absätzen 6 und 7 Bildungsdokumentationsgesetz 2020, BGBl. I  Nr. 20/2021, in der gültigen Fassung, sowie § 141 Absatz 3 Universitätsgesetz 2002, BGBl. I  Nr. 120/2002, in der gültigen Fassung.', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'according to section 18 subsections 6 and 7 of the Bildungsdokumentationsgesetz 2020, Federal Law Gazette I  No. 20/2021, in the current version, and section 141 subsection 3 of the Universitätsgesetz 2002, Federal Law Gazette I  No. 120/2002, in the current version.', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'core', 'category' => 'uhstat',