diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index d31769199..fb20b2a5c 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -4,6 +4,8 @@ class approveAnrechnungDetail extends Auth_Controller { + const BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN = 'lehre/anrechnung_genehmigen'; + const REVIEW_ANRECHNUNG_URI = '/lehre/anrechnung/ReviewAnrechnungUebersicht'; const ANRECHNUNGSTATUS_PROGRESSED_BY_STGL = 'inProgressDP'; @@ -73,6 +75,9 @@ class approveAnrechnungDetail extends Auth_Controller show_error('Missing correct parameter'); } + // Check if user is entitled to read the Anrechnung + self::_checkIfEntitledToReadAnrechnung($anrechnung_id); + // Get Anrechung data if (!$anrechnungData = getData($this->anrechnunglib->getAnrechnungData($anrechnung_id))) { @@ -282,6 +287,9 @@ class approveAnrechnungDetail extends Auth_Controller show_error('Wrong parameter'); } + // Check if user is entitled to read dms doc + self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->dmslib->download($dms_id); } @@ -295,6 +303,68 @@ class approveAnrechnungDetail extends Auth_Controller if (!$this->_uid) show_error('User authentification failed'); } + /** + * Check if user is entitled to read this Anrechnung + * @param $anrechnung_id + */ + private function _checkIfEntitledToReadAnrechnung($anrechnung_id) + { + // Retrieve studiengaenge the user is entitled for + $studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN); + + $result = $this->AnrechnungModel->load($anrechnung_id); + + if(!$result = getData($result)[0]) + { + show_error('Failed retrieving Anrechnung'); + } + + $result = $this->LehrveranstaltungModel->loadWhere(array( + 'lehrveranstaltung_id' => $result->lehrveranstaltung_id + )); + + if($result = getData($result)[0]) + { + if (in_array($result->studiengang_kz, $studiengang_kz_arr)) + { + return; + } + } + + show_error('You are not entitled to read this Anrechnung'); + } + + /** + * Check if user is entitled to read dms doc + * @param $dms_id + */ + private function _checkIfEntitledToReadDMSDoc($dms_id) + { + // Retrieve studiengaenge the user is entitled for + $studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN); + + $result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id)); + + if(!$result = getData($result)[0]) + { + show_error('Failed retrieving Anrechnung'); + } + + $result = $this->LehrveranstaltungModel->loadWhere(array( + 'lehrveranstaltung_id' => $result->lehrveranstaltung_id + )); + + if($result = getData($result)[0]) + { + if (in_array($result->studiengang_kz, $studiengang_kz_arr)) + { + return; + } + } + + show_error('You are not entitled to read this document'); + } + /** * Send mail to student to inform if Anrechnung was approved or rejected * @param $mail_params diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 528cf9ef1..ccf3af2ea 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -252,6 +252,9 @@ class approveAnrechnungUebersicht extends Auth_Controller { show_error('Wrong parameter'); } + + // Check if user is entitled to read dms doc + self::_checkIfEntitledToReadDMSDoc($dms_id); $this->dmslib->download($dms_id); } @@ -267,6 +270,38 @@ class approveAnrechnungUebersicht extends Auth_Controller if (!$this->_uid) show_error('User authentification failed'); } + /** + * Check if user is entitled to read dms doc + * @param $dms_id + */ + private function _checkIfEntitledToReadDMSDoc($dms_id) + { + // Retrieve studiengaenge the user is entitled for + $studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::BERECHTIGUNG_ANRECHNUNG_GENEHMIGEN); + + + $result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id)); + + if(!$result = getData($result)[0]) + { + show_error('Failed retrieving Anrechnung'); + } + + $result = $this->LehrveranstaltungModel->loadWhere(array( + 'lehrveranstaltung_id' => $result->lehrveranstaltung_id + )); + + if($result = getData($result)[0]) + { + if (in_array($result->studiengang_kz, $studiengang_kz_arr)) + { + return; + } + } + + show_error('You are not entitled to read this document'); + } + /** * Send mail to student to inform if Anrechnung was approved or rejected * @param $mail_params diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index 197be0c52..8ed61d9a4 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -211,6 +211,9 @@ class requestAnrechnung extends Auth_Controller show_error('Wrong parameter'); } + // Check if user is entitled to read dms doc + self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->dmslib->download($dms_id); } @@ -265,6 +268,25 @@ class requestAnrechnung extends Auth_Controller return ($today > $start->add((new DateInterval(self::DEADLINE_INTERVAL_NACH_SEMESTERSTART)))); } + /** + * Check if user is entitled to read dms doc + * @param $dms_id + */ + private function _checkIfEntitledToReadDMSDoc($dms_id) + { + $result = $this->AnrechnungModel->loadWhere(array('dms_id' => $dms_id)); + + if($result = getData($result)[0]) + { + if ($result->insertvon == $this->_uid) + { + return; + } + } + + show_error('You are not entitled to read this document'); + } + /** * Get Anrechnung by Lehrveranstaltung * @param $lehrveranstaltung_id diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php index a6cf66919..6fd09b5b1 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php @@ -74,6 +74,9 @@ class reviewAnrechnungDetail extends Auth_Controller show_error('Missing correct parameter'); } + // Check if user is entitled to read this Anrechnung + self::_checkIfEntitledToReadAnrechnung($anrechnung_id); + // Get Anrechung data if (!$anrechnungData = getData($this->anrechnunglib->getAnrechnungData($anrechnung_id))) { @@ -228,6 +231,9 @@ class reviewAnrechnungDetail extends Auth_Controller show_error('Wrong parameter'); } + // Check if user is entitled to read dms doc + self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->dmslib->download($dms_id); } @@ -242,6 +248,64 @@ class reviewAnrechnungDetail extends Auth_Controller if (!$this->_uid) show_error('User authentification failed'); } + /** + * Check if user is entitled to read dms doc + * @param $dms_id + */ + private function _checkIfEntitledToReadAnrechnung($anrechnung_id) + { + $result = $this->AnrechnungModel->load($anrechnung_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'); + + if (in_array($this->_uid, $entitled_lector_arr)) + { + return; + } + } + + show_error('You are not entitled to read this document'); + } + + /** + * Check if user is entitled to read dms doc + * @param $dms_id + */ + 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'); + + if (in_array($this->_uid, $entitled_lector_arr)) + { + 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 diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php index 4f6345d5b..005cde97a 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php @@ -200,6 +200,9 @@ class reviewAnrechnungUebersicht extends Auth_Controller show_error('Wrong parameter'); } + // Check if user is entitled to read dms doc + self::_checkIfEntitledToReadDMSDoc($dms_id); + $this->dmslib->download($dms_id); } @@ -214,6 +217,35 @@ class reviewAnrechnungUebersicht extends Auth_Controller if (!$this->_uid) show_error('User authentification failed'); } + /** + * Check if user is entitled to read dms doc + * @param $dms_id + */ + 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'); + + if (in_array($this->_uid, $entitled_lector_arr)) + { + 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