Added checks if user is entitled to read DMS document / Anrechnung

Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
Cris
2021-02-04 17:05:05 +01:00
committed by cris-technikum
parent 071a6a4ee6
commit c8ceacc972
5 changed files with 223 additions and 0 deletions
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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