mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-16 00:39:32 +00:00
permission ueberpruefung auf basis/lvverwaltung umgebaut
search auf die neue search umgebaut
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
$CI =& get_instance();
|
||||
|
||||
$config['employee'] = $CI->config->item('employee', 'search');
|
||||
|
||||
$config['lehreinheit'] = [
|
||||
'primarykey' => 'lehreinheit_id',
|
||||
'table' => 'lehre.tbl_lehreinheit',
|
||||
'searchfields' => [
|
||||
'leid' => [
|
||||
'alias' => ['lehreinheit_id', 'id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'lehreinheit_id'
|
||||
],
|
||||
'bezeichnung' => [
|
||||
'alias' => ['name', 'title'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'tbl_lehrveranstaltung.bezeichnung',
|
||||
'join' => [
|
||||
'table' => "lehre.tbl_lehrveranstaltung",
|
||||
'using' => "lehrveranstaltung_id"
|
||||
]
|
||||
],
|
||||
'semester' => [
|
||||
'alias' => ['sem'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'tbl_lehrveranstaltung.semester',
|
||||
'join' => [
|
||||
'table' => "lehre.tbl_lehrveranstaltung",
|
||||
'using' => "lehrveranstaltung_id"
|
||||
]
|
||||
],
|
||||
'studiensemester_kurzbz' => [
|
||||
'alias' => ['studiensemester'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'tbl_lehreinheit.studiensemester_kurzbz',
|
||||
],
|
||||
'stg' => [
|
||||
'alias' => ['studiengang'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'lvstg.stg_kuerzel',
|
||||
'join' => [
|
||||
'table' => "(
|
||||
SELECT lehrveranstaltung_id, (typ || tbl_studiengang.kurzbz) AS stg_kuerzel
|
||||
FROM lehre.tbl_lehrveranstaltung
|
||||
JOIN public.tbl_studiengang USING (studiengang_kz)
|
||||
) lvstg",
|
||||
'using' => "lehrveranstaltung_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"le.lehreinheit_id AS id",
|
||||
"le.studiensemester_kurzbz",
|
||||
"lv.bezeichnung",
|
||||
"'lv_table_icon icon-' AS foto",
|
||||
"UPPER(stg.typ || stg.kurzbz) AS studiengang",
|
||||
"le.lehrform_kurzbz",
|
||||
"lv.semester"
|
||||
],
|
||||
'renderer' => 'teachingunit',
|
||||
'resultjoin' => "
|
||||
JOIN lehre.tbl_lehreinheit le USING (lehreinheit_id)
|
||||
JOIN lehre.tbl_lehrveranstaltung lv ON (lv.lehrveranstaltung_id = le.lehrveranstaltung_id)
|
||||
LEFT JOIN lehre.tbl_lehrveranstaltung lehrfach ON (lehrfach.lehrveranstaltung_id = le.lehrfach_id)
|
||||
JOIN public.tbl_studiengang stg ON (stg.studiengang_kz = lv.studiengang_kz)
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM system.vw_berechtigung
|
||||
WHERE vw_berechtigung.uid = (TABLE auth)
|
||||
AND vw_berechtigung.berechtigung_kurzbz = 'basis/lvverwaltung'
|
||||
AND (
|
||||
vw_berechtigung.oe_kurzbz IN (lv.oe_kurzbz, stg.oe_kurzbz, lehrfach.oe_kurzbz)
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM lehre.tbl_studienplan_lehrveranstaltung
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
|
||||
JOIN public.tbl_studiengang spstg USING (studiengang_kz)
|
||||
WHERE tbl_studienplan_lehrveranstaltung.lehrveranstaltung_id = lv.lehrveranstaltung_id
|
||||
AND spstg.oe_kurzbz = vw_berechtigung.oe_kurzbz
|
||||
)
|
||||
)
|
||||
)
|
||||
"
|
||||
];
|
||||
|
||||
$config['lehrveranstaltung'] = [
|
||||
'primarykey' => 'lehrveranstaltung_id',
|
||||
'table' => 'lehre.tbl_lehrveranstaltung',
|
||||
'searchfields' => [
|
||||
'lvid' => [
|
||||
'alias' => ['lehrveranstaltung_id', 'id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'lehrveranstaltung_id'
|
||||
],
|
||||
'bezeichnung' => [
|
||||
'alias' => ['name', 'title'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'bezeichnung'
|
||||
],
|
||||
'semester' => [
|
||||
'alias' => ['sem'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'semester'
|
||||
],
|
||||
'stg' => [
|
||||
'alias' => ['studiengang'],
|
||||
'comparison' => 'similar',
|
||||
'field' => "(tbl_studiengang.typ || tbl_studiengang.kurzbz)",
|
||||
'join' => [
|
||||
'table' => "public.tbl_studiengang",
|
||||
'using' => "studiengang_kz"
|
||||
]
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"lv.lehrveranstaltung_id AS id",
|
||||
"lv.bezeichnung",
|
||||
"'lv_table_icon icon-lv' AS foto",
|
||||
"UPPER(stg.typ::varchar(1) || stg.kurzbz) AS studiengang",
|
||||
"lv.semester",
|
||||
"lv.lehrform_kurzbz",
|
||||
"oe.bezeichnung AS oe_bezeichnung"
|
||||
],
|
||||
'renderer' => 'teachingunit',
|
||||
'resultjoin' => "
|
||||
JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id)
|
||||
JOIN public.tbl_studiengang stg ON (stg.studiengang_kz = lv.studiengang_kz)
|
||||
LEFT JOIN public.tbl_organisationseinheit oe ON (oe.oe_kurzbz = lv.oe_kurzbz)
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM system.vw_berechtigung
|
||||
WHERE vw_berechtigung.uid = (TABLE auth)
|
||||
AND vw_berechtigung.berechtigung_kurzbz = 'basis/lvverwaltung'
|
||||
AND (
|
||||
vw_berechtigung.oe_kurzbz IN (lv.oe_kurzbz, stg.oe_kurzbz)
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM lehre.tbl_lehreinheit le
|
||||
JOIN lehre.tbl_lehrveranstaltung lehrfach ON (lehrfach.lehrveranstaltung_id = le.lehrfach_id)
|
||||
WHERE le.lehrveranstaltung_id = lv.lehrveranstaltung_id
|
||||
AND lehrfach.oe_kurzbz = vw_berechtigung.oe_kurzbz
|
||||
)
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM lehre.tbl_studienplan_lehrveranstaltung
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
|
||||
JOIN public.tbl_studiengang spstg USING (studiengang_kz)
|
||||
WHERE tbl_studienplan_lehrveranstaltung.lehrveranstaltung_id = lv.lehrveranstaltung_id
|
||||
AND spstg.oe_kurzbz = vw_berechtigung.oe_kurzbz
|
||||
)
|
||||
)
|
||||
)
|
||||
"
|
||||
];
|
||||
@@ -21,18 +21,20 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class Lehrveranstaltung extends FHCAPI_Controller
|
||||
{
|
||||
const PERMISSION = 'basis/lvverwaltung';
|
||||
|
||||
private $_ci;
|
||||
private $_uid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getByEmp' => ['admin:r', 'assistenz:r'],
|
||||
'getByLe' => ['admin:r', 'assistenz:r'],
|
||||
'getByLv' => ['admin:r', 'assistenz:r'],
|
||||
'getByStg' => ['admin:r', 'assistenz:r'],
|
||||
'getByStgOrgform' => ['admin:r', 'assistenz:r'],
|
||||
'loadByLV' => ['admin:r', 'assistenz:r'],
|
||||
'getByEmp' => [self::PERMISSION . ':r'],
|
||||
'getByLe' => [self::PERMISSION . ':r'],
|
||||
'getByLv' => [self::PERMISSION . ':r'],
|
||||
'getByStg' => [self::PERMISSION . ':r'],
|
||||
'getByStgOrgform' => [self::PERMISSION . ':r'],
|
||||
'loadByLV' => [self::PERMISSION . ':r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
@@ -43,6 +45,7 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $this->_uid]);
|
||||
$this->_ci->load->library('LVVerwaltungPermissionLib');
|
||||
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
@@ -64,12 +67,36 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
$lehrveranstaltungen = $this->_ci->LehreinheitModel->getLvsByEmployee($mitarbeiter_uid, $studiensemester_kurzbz, $studiengang_kz);
|
||||
$lehrveranstaltungen_data = $this->getDataOrTerminateWithError($lehrveranstaltungen);
|
||||
|
||||
$les_by_lv = array();
|
||||
foreach ($lehrveranstaltungen_data as $lehrveranstaltung)
|
||||
{
|
||||
$lehreinheiten = $this->_ci->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz, $mitarbeiter_uid);
|
||||
$les_by_lv[$lehrveranstaltung->lehrveranstaltung_id] = $this->getDataOrTerminateWithError($lehreinheiten);
|
||||
}
|
||||
|
||||
$alle_le_ids = array();
|
||||
foreach ($les_by_lv as $lehreinheiten)
|
||||
{
|
||||
foreach ($lehreinheiten as $le)
|
||||
$alle_le_ids[] = $le->lehreinheit_id;
|
||||
}
|
||||
|
||||
$erlaubte_le_ids = $this->_ci->lvverwaltungpermissionlib->filterLehreinheitIds($alle_le_ids);
|
||||
$erlaubte_lv_ids = $this->_ci->lvverwaltungpermissionlib->filterLVIds(array_column($lehrveranstaltungen_data, 'lehrveranstaltung_id'), 's', false);
|
||||
|
||||
$tree = [];
|
||||
|
||||
foreach ($lehrveranstaltungen_data as $lehrveranstaltung)
|
||||
{
|
||||
$lehreinheiten = $this->_ci->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz, $mitarbeiter_uid);
|
||||
$lehreinheiten_data = $this->getDataOrTerminateWithError($lehreinheiten);
|
||||
$lehreinheiten_data = array();
|
||||
foreach ($les_by_lv[$lehrveranstaltung->lehrveranstaltung_id] as $le)
|
||||
{
|
||||
if (in_array($le->lehreinheit_id, $erlaubte_le_ids))
|
||||
$lehreinheiten_data[] = $le;
|
||||
}
|
||||
|
||||
if (!in_array($lehrveranstaltung->lehrveranstaltung_id, $erlaubte_lv_ids) && empty($lehreinheiten_data))
|
||||
continue;
|
||||
|
||||
if (!isset($lehrveranstaltung->_children))
|
||||
{
|
||||
@@ -83,9 +110,12 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
|
||||
public function getByLe($studiensemester_kurzbz = null, $lehreinheit_id = null)
|
||||
{
|
||||
if (is_null($lehreinheit_id))
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLehreinheit($lehreinheit_id, 's'))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
|
||||
$studiensemester_kurzbz = $this->getStudiensemesterKurzbz($studiensemester_kurzbz);
|
||||
|
||||
|
||||
@@ -97,9 +127,12 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
|
||||
public function getByLv($studiensemester_kurzbz = null, $lehrveranstaltung_id = null)
|
||||
{
|
||||
if (is_null($lehrveranstaltung_id))
|
||||
if (is_null($lehrveranstaltung_id) || !ctype_digit((string)$lehrveranstaltung_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLV($lehrveranstaltung_id, 's'))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
|
||||
$studiensemester_kurzbz = $this->getStudiensemesterKurzbz($studiensemester_kurzbz);
|
||||
|
||||
$tree = [];
|
||||
@@ -155,9 +188,19 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
$lehreinheiten = $this->_ci->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz);
|
||||
$lehreinheiten_data = $this->getDataOrTerminateWithError($lehreinheiten);
|
||||
|
||||
// nur die LEs, auf die man berechtigt ist (LV selbst ist oben schon geprüft)
|
||||
$erlaubte_le_ids = $this->_ci->lvverwaltungpermissionlib->filterLehreinheitIds(array_column($lehreinheiten_data, 'lehreinheit_id'));
|
||||
|
||||
$erlaubte_lehreinheiten = array();
|
||||
foreach ($lehreinheiten_data as $le)
|
||||
{
|
||||
if (in_array($le->lehreinheit_id, $erlaubte_le_ids))
|
||||
$erlaubte_lehreinheiten[] = $le;
|
||||
}
|
||||
|
||||
if (!isset($lehrveranstaltung->_children))
|
||||
{
|
||||
$lehrveranstaltung->_children = $lehreinheiten_data;
|
||||
$lehrveranstaltung->_children = $erlaubte_lehreinheiten;
|
||||
}
|
||||
$tree[] = $lehrveranstaltung;
|
||||
}
|
||||
@@ -192,17 +235,47 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
|
||||
$lehrveranstaltungen_data = $this->_loadLvRows($studiengang_kz, $studiensemester_kurzbz, $semester, $orgform_kurzbz);
|
||||
|
||||
$les_by_lv = array();
|
||||
foreach ($lehrveranstaltungen_data as $row)
|
||||
{
|
||||
$lehreinheiten_data = $this->_ci->LehreinheitModel->getByLvidStudiensemester($row->lehrveranstaltung_id, $studiensemester_kurzbz);
|
||||
$les_by_lv[$row->lehrveranstaltung_id] = hasData($lehreinheiten_data) ? getData($lehreinheiten_data) : array();
|
||||
}
|
||||
|
||||
$alle_le_ids = array();
|
||||
foreach ($les_by_lv as $lehreinheiten)
|
||||
{
|
||||
foreach ($lehreinheiten as $le)
|
||||
$alle_le_ids[] = $le->lehreinheit_id;
|
||||
}
|
||||
|
||||
$erlaubte_le_ids = $this->_ci->lvverwaltungpermissionlib->filterLehreinheitIds($alle_le_ids);
|
||||
$erlaubte_lv_ids = $this->_ci->lvverwaltungpermissionlib->filterLVIds(array_column($lehrveranstaltungen_data, 'lehrveranstaltung_id'), 's', false);
|
||||
|
||||
$sichtbare_lv_ids = array();
|
||||
foreach ($lehrveranstaltungen_data as $row)
|
||||
{
|
||||
$erlaubte_lehreinheiten = array();
|
||||
foreach ($les_by_lv[$row->lehrveranstaltung_id] as $le)
|
||||
{
|
||||
if (in_array($le->lehreinheit_id, $erlaubte_le_ids))
|
||||
$erlaubte_lehreinheiten[] = $le;
|
||||
}
|
||||
$les_by_lv[$row->lehrveranstaltung_id] = $erlaubte_lehreinheiten;
|
||||
|
||||
if (in_array($row->lehrveranstaltung_id, $erlaubte_lv_ids) || !empty($erlaubte_lehreinheiten))
|
||||
$sichtbare_lv_ids[] = $row->lehrveranstaltung_id;
|
||||
}
|
||||
|
||||
$tree = [];
|
||||
foreach ($lehrveranstaltungen_data as $row)
|
||||
{
|
||||
$rowData = $row;
|
||||
|
||||
$lehreinheiten_data = $this->_ci->LehreinheitModel->getByLvidStudiensemester($row->lehrveranstaltung_id, $studiensemester_kurzbz);
|
||||
$lehreinheiten = $les_by_lv[$row->lehrveranstaltung_id];
|
||||
|
||||
if (hasData($lehreinheiten_data))
|
||||
if (!empty($lehreinheiten))
|
||||
{
|
||||
$lehreinheiten = getData($lehreinheiten_data);
|
||||
|
||||
if (!isset($row->_children))
|
||||
{
|
||||
$row->_children = $lehreinheiten;
|
||||
@@ -246,7 +319,7 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unset($searchParent);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -255,6 +328,8 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$tree = $this->_entferneNichtSichtbareLVs($tree, $sichtbare_lv_ids);
|
||||
|
||||
$counter = 0;
|
||||
$this->assignUniqueIndex($tree, $counter);
|
||||
$this->terminateWithSuccess($tree);
|
||||
@@ -266,6 +341,9 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
if (is_null($lehrveranstaltung_id) || !ctype_digit((string)$lehrveranstaltung_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLV($lehrveranstaltung_id, 's'))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
|
||||
$this->_ci->LehrveranstaltungModel->addSelect('lehrveranstaltung_id, lehrform_kurzbz, lehre, bezeichnung as lvbezeichnung, sprache');
|
||||
$lehrveranstaltung_result = $this->_ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung_id));
|
||||
$lehrveranstaltung_result = $this->getDataOrTerminateWithError($lehrveranstaltung_result);
|
||||
@@ -348,6 +426,33 @@ class Lehrveranstaltung extends FHCAPI_Controller
|
||||
return hasData($lehrveranstaltungen_data) ? getData($lehrveranstaltungen_data) : array();
|
||||
}
|
||||
|
||||
private function _entferneNichtSichtbareLVs($nodes, $sichtbare_lv_ids)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($nodes as $node)
|
||||
{
|
||||
if (isset($node->lehreinheit_id))
|
||||
{
|
||||
$result[] = $node;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($node->_children))
|
||||
{
|
||||
if (!is_array($node->_children))
|
||||
$node->_children = [$node->_children];
|
||||
|
||||
$node->_children = $this->_entferneNichtSichtbareLVs($node->_children, $sichtbare_lv_ids);
|
||||
}
|
||||
|
||||
if (in_array($node->lehrveranstaltung_id, $sichtbare_lv_ids) || !empty($node->_children))
|
||||
$result[] = $node;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
@@ -207,6 +207,10 @@ class LvPlan extends FHCAPI_Controller
|
||||
|
||||
public function getLeEvents($le_id = null, $start_date = null, $end_date = null, $stundenplan = 'stundenplandev')
|
||||
{
|
||||
$this->load->library('LVVerwaltungPermissionLib');
|
||||
|
||||
if (!$this->lvverwaltungpermissionlib->isEntitledForLehreinheit($le_id, 's'))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
|
||||
if (is_null($le_id) || is_null($start_date) || is_null($end_date))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
@@ -224,6 +228,11 @@ class LvPlan extends FHCAPI_Controller
|
||||
|
||||
public function getLvEvents($lv_id = null, $start_date = null, $end_date = null, $stundenplan = 'stundenplandev')
|
||||
{
|
||||
$this->load->library('LVVerwaltungPermissionLib');
|
||||
|
||||
if (!$this->lvverwaltungpermissionlib->isEntitledForLV($lv_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
|
||||
if (is_null($lv_id) || is_null($start_date) || is_null($end_date))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ class Searchbar extends FHCAPI_Controller
|
||||
parent::__construct([
|
||||
'search' => self::PERM_LOGGED,
|
||||
'searchCis' => self::PERM_LOGGED,
|
||||
'searchStv' => self::PERM_LOGGED
|
||||
'searchStv' => self::PERM_LOGGED,
|
||||
'searchLV' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->model('system/Webservicelog_model', 'WebservicelogModel');
|
||||
@@ -87,6 +88,14 @@ class Searchbar extends FHCAPI_Controller
|
||||
return $this->searchAdvanced([ 'config' => 'searchstv' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
public function searchLV()
|
||||
{
|
||||
return $this->searchAdvanced([ 'config' => 'searchlv' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
|
||||
@@ -5,14 +5,15 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class Config extends FHCAPI_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
private $_ci;
|
||||
private $_uid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'set' => ['admin:r', 'assistenz:r'],
|
||||
'get' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'set' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
|
||||
@@ -21,13 +21,15 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class DirektGruppe extends FHCAPI_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'delete' => ['admin:rw', 'assistenz:rw'],
|
||||
'getByLehreinheit' => ['admin:r', 'assistenz:r'],
|
||||
'add' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'delete' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'getByLehreinheit' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
@@ -38,6 +40,7 @@ class DirektGruppe extends FHCAPI_Controller
|
||||
$this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel');
|
||||
$this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->_ci->load->library('LVVerwaltungPermissionLib');
|
||||
}
|
||||
|
||||
public function add()
|
||||
@@ -45,7 +48,7 @@ class DirektGruppe extends FHCAPI_Controller
|
||||
$uid = $this->input->post('uid');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
|
||||
$this->checkPermission($lehreinheit_id, $uid);
|
||||
$this->checkPermission($lehreinheit_id, 'suid', $uid);
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->direktUserAdd($uid, $lehreinheit_id);
|
||||
|
||||
@@ -60,7 +63,7 @@ class DirektGruppe extends FHCAPI_Controller
|
||||
$uid = $this->input->post('uid');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
|
||||
$this->checkPermission($lehreinheit_id, $uid);
|
||||
$this->checkPermission($lehreinheit_id, 'suid', $uid);
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->direktUserDelete($uid, $lehreinheit_id);
|
||||
|
||||
@@ -72,12 +75,12 @@ class DirektGruppe extends FHCAPI_Controller
|
||||
|
||||
public function getByLehreinheit($lehreinheit_id = null)
|
||||
{
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 's');
|
||||
$gruppen = $this->_ci->LehreinheitgruppeModel->getDirectGroup($lehreinheit_id);
|
||||
$this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : array());
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id, $uid = false)
|
||||
private function checkPermission($lehreinheit_id, $art, $uid = false)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
@@ -94,17 +97,7 @@ class DirektGruppe extends FHCAPI_Controller
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLehreinheit($lehreinheit_id, $art))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,20 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class Gruppe extends FHCAPI_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
|
||||
private $_uid;
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'delete' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteFromLVPlan' => ['admin:rw', 'assistenz:rw'],
|
||||
'getBenutzerSearch' => ['admin:r', 'assistenz:r'],
|
||||
'getAllSearch' => ['admin:r', 'assistenz:r'],
|
||||
'getByLehreinheit' => ['admin:r', 'assistenz:r'],
|
||||
'getGruppe' => ['admin:r', 'assistenz:r'],
|
||||
'add' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'delete' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'deleteFromLVPlan' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'getBenutzerSearch' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getAllSearch' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getByLehreinheit' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getGruppe' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
@@ -33,6 +35,10 @@ class Gruppe extends FHCAPI_Controller
|
||||
$this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel');
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel');
|
||||
$this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
|
||||
$this->_ci->load->library('LVVerwaltungPermissionLib');
|
||||
|
||||
}
|
||||
|
||||
public function delete()
|
||||
@@ -43,11 +49,11 @@ class Gruppe extends FHCAPI_Controller
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($lehreinheitgruppe_id) || !ctype_digit((string)$lehreinheitgruppe_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheitgruppe_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheitgruppe_id' => $lehreinheitgruppe_id));
|
||||
$lehreinheitgruppe_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheitgruppe_id' => $lehreinheitgruppe_id, 'lehreinheit_id' => $lehreinheit_id));
|
||||
if (!hasData($lehreinheitgruppe_result) || isError($lehreinheitgruppe_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->deleteGroup($lehreinheit_id, $lehreinheitgruppe_id);
|
||||
|
||||
@@ -66,7 +72,7 @@ class Gruppe extends FHCAPI_Controller
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($gid) || !ctype_digit((string)$gid) || is_null($lehrverband))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->addGroup($lehreinheit_id, $gid, $lehrverband === true || $lehrverband === 'true');
|
||||
|
||||
@@ -146,7 +152,7 @@ class Gruppe extends FHCAPI_Controller
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 's');
|
||||
|
||||
$gruppen = $this->_ci->LehreinheitgruppeModel->getByLehreinheit($lehreinheit_id);
|
||||
$this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : array());
|
||||
@@ -164,7 +170,7 @@ class Gruppe extends FHCAPI_Controller
|
||||
if (!hasData($lehreinheitgruppe_result) || isError($lehreinheitgruppe_result))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
|
||||
$result = $this->_ci->StundenplandevModel->deleteGroupPlanning($lehreinheit_id, $lehreinheitgruppe_id);
|
||||
|
||||
@@ -291,26 +297,15 @@ class Gruppe extends FHCAPI_Controller
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id)
|
||||
private function checkPermission($lehreinheit_id, $art)
|
||||
{
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLehreinheit($lehreinheit_id, $art, array('lv-plan', 'basis/lvverwaltung')))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,28 +4,31 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class Lehreinheit extends FHCAPI_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
|
||||
private $_uid;
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'copy' => ['admin:rw', 'assistenz:rw'],
|
||||
'delete' => ['admin:rw', 'assistenz:rw'],
|
||||
'update' => ['admin:rw', 'assistenz:rw'],
|
||||
'add' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'copy' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'delete' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'update' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r'],
|
||||
'getLehrfach' => ['admin:r', 'assistenz:r'],
|
||||
'getSprache' => ['admin:r', 'assistenz:r'],
|
||||
'getRaumtyp' => ['admin:r', 'assistenz:r'],
|
||||
'getLehrform' => ['admin:r', 'assistenz:r']
|
||||
'get' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getStudiensemester' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLehrfach' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getSprache' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getRaumtyp' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLehrform' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_setAuthUID();
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $this->_uid]);
|
||||
$this->_ci->load->library('PhrasesLib');
|
||||
$this->_ci->load->library('LVVerwaltungPermissionLib');
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
@@ -34,6 +37,7 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
);
|
||||
|
||||
$this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel');
|
||||
$this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
}
|
||||
@@ -41,31 +45,11 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
public function get($lehreinheit_id)
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 's');
|
||||
$lehreinheit->lehrfaecher = $this->getLehrfaecher($lehreinheit);
|
||||
$this->terminateWithSuccess($lehreinheit);
|
||||
}
|
||||
|
||||
private function getLehrfaecher($lehreinheit)
|
||||
{
|
||||
$lehrfacher_array = array($lehreinheit->lehrfach_id);
|
||||
$this->_ci->LehreinheitModel->addSelect('lehrveranstaltung_id_kompatibel');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung_kompatibel', 'lehrveranstaltung_id');
|
||||
$lehrfaecher = $this->_ci->LehreinheitModel->loadWhere(array('lehrveranstaltung_id' => $lehreinheit->lehrveranstaltung_id));
|
||||
|
||||
|
||||
if (hasData($lehrfaecher))
|
||||
$lehrfaecher_array = array_merge($lehrfacher_array, array_column(getData($lehrfaecher), 'lehrveranstaltung_id_kompatibel'));
|
||||
|
||||
$lehrfaecher_array[] = $lehreinheit->lehrveranstaltung_id;
|
||||
|
||||
$this->_ci->LehrveranstaltungModel->addDistinct('lehrfach_id');
|
||||
$this->_ci->LehrveranstaltungModel->addSelect("tbl_lehrveranstaltung.lehrveranstaltung_id, CONCAT(tbl_lehrveranstaltung.bezeichnung || '(' || tbl_lehrveranstaltung.oe_kurzbz || ')') as lehrfach");
|
||||
$this->_ci->LehrveranstaltungModel->db->where_in('tbl_lehrveranstaltung.lehrveranstaltung_id', $lehrfaecher_array);
|
||||
$lehrfaecher_result = $this->_ci->LehrveranstaltungModel->load();
|
||||
|
||||
return hasData($lehrfaecher_result) ? getData($lehrfaecher_result) : array();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$lehrveranstaltung_id = $this->input->post('lehrveranstaltung_id');
|
||||
@@ -78,16 +62,6 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
if (!hasData($lehrveranstaltung_result) || isError($lehrveranstaltung_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehrveranstaltung = getData($lehrveranstaltung_result)[0];
|
||||
|
||||
$oe_result = $this->_ci->LehrveranstaltungModel->getAllOe($lehrveranstaltung->lehrveranstaltung_id);
|
||||
$oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array();
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$this->_ci->load->library('form_validation');
|
||||
|
||||
$updatableFields = array(
|
||||
@@ -164,6 +138,9 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLVUndLehrfach($lehrveranstaltung_id, $this->input->post('lehrfach_id'), 'suid', array('lv-plan', 'basis/lvverwaltung')))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$updateData = array();
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
@@ -186,6 +163,9 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
$updateData
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!isset($updateData['unr']))
|
||||
{
|
||||
$unr = getData($result);
|
||||
@@ -201,7 +181,7 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
$art = $this->input->post('art');
|
||||
|
||||
$lehreinheit_old = $this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_old->lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_old->lehreinheit_id, 'suid');
|
||||
|
||||
$lehreinheit_new = $lehreinheit_old;
|
||||
|
||||
@@ -291,10 +271,13 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
{
|
||||
foreach ($lehreinheit_id as $le_id)
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($le_id);
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id);
|
||||
$this->checkLehreinheit($le_id);
|
||||
$this->checkPermission($le_id, 'suid');
|
||||
}
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->deleteLehreinheit($lehreinheit->lehreinheit_id);
|
||||
foreach ($lehreinheit_id as $le_id)
|
||||
{
|
||||
$result = $this->_ci->LehreinheitModel->deleteLehreinheit($le_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
@@ -305,7 +288,7 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
else
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id,'suid');
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->deleteLehreinheit($lehreinheit->lehreinheit_id);
|
||||
|
||||
@@ -328,12 +311,15 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($this->input->post('lehreinheit_id'));
|
||||
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id, 'suid');
|
||||
|
||||
$this->_ci->load->library('form_validation');
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
if (!is_array($formData))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$updatableFields = array(
|
||||
'lehrveranstaltung_id',
|
||||
'studiensemester_kurzbz',
|
||||
@@ -423,12 +409,18 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$ziel_lv = isset($updateData['lehrveranstaltung_id']) ? $updateData['lehrveranstaltung_id'] : $lehreinheit->lehrveranstaltung_id;
|
||||
$ziel_lehrfach = isset($updateData['lehrfach_id']) ? $updateData['lehrfach_id'] : $lehreinheit->lehrfach_id;
|
||||
|
||||
if (($ziel_lv != $lehreinheit->lehrveranstaltung_id || $ziel_lehrfach != $lehreinheit->lehrfach_id)
|
||||
&& !$this->_ci->lvverwaltungpermissionlib->isEntitledForLVUndLehrfach($ziel_lv, $ziel_lehrfach, 'suid', array('lv-plan', 'basis/lvverwaltung')))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$updateData['updatevon'] = $this->_uid;
|
||||
$updateData['updateamum'] = date('Y-m-d H:i:s');
|
||||
$result = $this->_ci->LehreinheitModel->update(
|
||||
[
|
||||
'lehreinheit_id' => $this->input->post('lehreinheit_id'),
|
||||
'lehreinheit_id' => $lehreinheit->lehreinheit_id,
|
||||
],
|
||||
$updateData
|
||||
);
|
||||
@@ -439,21 +431,30 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
|
||||
private function checkPermission($lehreinheit_id)
|
||||
private function getLehrfaecher($lehreinheit)
|
||||
{
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
$lehrfaecher_array = array($lehreinheit->lehrfach_id);
|
||||
$this->_ci->LehreinheitModel->addSelect('lehrveranstaltung_id_kompatibel');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung_kompatibel', 'lehrveranstaltung_id');
|
||||
$lehrfaecher = $this->_ci->LehreinheitModel->loadWhere(array('lehrveranstaltung_id' => $lehreinheit->lehrveranstaltung_id));
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
if (hasData($lehrfaecher))
|
||||
$lehrfaecher_array = array_merge($lehrfaecher_array,array_column(getData($lehrfaecher), 'lehrveranstaltung_id_kompatibel'));
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
$lehrfaecher_array[] = $lehreinheit->lehrveranstaltung_id;
|
||||
|
||||
$this->_ci->LehrveranstaltungModel->addDistinct('lehrfach_id');
|
||||
$this->_ci->LehrveranstaltungModel->addSelect("tbl_lehrveranstaltung.lehrveranstaltung_id, CONCAT(tbl_lehrveranstaltung.bezeichnung || '(' || tbl_lehrveranstaltung.oe_kurzbz || ')') as lehrfach");
|
||||
$this->_ci->LehrveranstaltungModel->db->where_in('tbl_lehrveranstaltung.lehrveranstaltung_id', $lehrfaecher_array);
|
||||
$lehrfaecher_result = $this->_ci->LehrveranstaltungModel->load();
|
||||
|
||||
return hasData($lehrfaecher_result) ? getData($lehrfaecher_result) : array();
|
||||
}
|
||||
private function checkPermission($lehreinheit_id, $art)
|
||||
{
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLehreinheit($lehreinheit_id, $art, array('lv-plan', 'basis/lvverwaltung')))
|
||||
$this->terminateWithError($this->p->t('ui', 'notAuthorized'));
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
}
|
||||
private function checkLehreinheit($lehreinheit_id)
|
||||
{
|
||||
@@ -475,4 +476,4 @@ class Lehreinheit extends FHCAPI_Controller
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,21 +4,23 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class Lektor extends FHCAPI_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
|
||||
private $_uid;
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'update' => ['admin:rw', 'assistenz:rw'],
|
||||
'cancelVertrag' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteLVPlan' => ['admin:rw', 'assistenz:rw'],
|
||||
'deletePerson' => ['admin:rw', 'assistenz:rw'],
|
||||
'getLehrfunktionen' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorenSearch' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorenByLE' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorDaten' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorVertrag' => ['admin:r', 'assistenz:r'],
|
||||
'add' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'update' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'cancelVertrag' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'deleteLVPlan' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'deletePerson' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'getLehrfunktionen' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLektorenSearch' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLektorenByLE' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLektorDaten' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLektorVertrag' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
|
||||
]);
|
||||
|
||||
@@ -39,17 +41,8 @@ class Lektor extends FHCAPI_Controller
|
||||
$this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel');
|
||||
$this->_ci->load->model('ressource/Stundensatz_model', 'StundensatzModel');
|
||||
|
||||
}
|
||||
$this->_ci->load->library('LVVerwaltungPermissionLib');
|
||||
|
||||
private function checkMitarbeiter($mitarbeiter_uid)
|
||||
{
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
public function add()
|
||||
@@ -59,11 +52,7 @@ class Lektor extends FHCAPI_Controller
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkMitarbeiter($mitarbeiter_uid);
|
||||
$lehrfach_permission = $this->checkLehrfachPermission($lehreinheit_id, array('assistenz', 'admin'));
|
||||
$lehreinheit_permission = $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan'));
|
||||
|
||||
if (!$lehrfach_permission && !$lehreinheit_permission)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
|
||||
$result = $this->_ci->lektorlib->addLektorToLehreinheit($lehreinheit_id, $mitarbeiter_uid);
|
||||
|
||||
@@ -144,10 +133,7 @@ class Lektor extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$lehreinheit_permission = $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan'));
|
||||
|
||||
if (!$lehreinheit_permission)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
|
||||
if (!is_null($this->getLektorVertrag($lehreinheit_id, $mitarbeiter_uid)) && (array_key_exists('mitarbeiter_uid', $formData) && $mitarbeiter_uid !== $formData['mitarbeiter_uid']))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
@@ -247,22 +233,12 @@ class Lektor extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(hasData($result) ? getData($result) : array());
|
||||
}
|
||||
|
||||
private function checkLehreinheit($lehreinheit_id)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
return getData($lehreinheit_result)[0];
|
||||
|
||||
}
|
||||
public function getLektorenByLE($lehreinheit_id = null)
|
||||
{
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 's');
|
||||
|
||||
$le_mitarbeiter_data = $this->_ci->LehreinheitmitarbeiterModel->getLektorenByLe($lehreinheit_id);
|
||||
$this->terminateWithSuccess(hasData($le_mitarbeiter_data) ? getData($le_mitarbeiter_data) : array());
|
||||
}
|
||||
@@ -270,6 +246,7 @@ class Lektor extends FHCAPI_Controller
|
||||
public function getLektorDaten($lehreinheit_id = null, $mitarbeiter_uid = null)
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, 's');
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
@@ -298,56 +275,6 @@ class Lektor extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($le_mitarbeiter_data);
|
||||
}
|
||||
|
||||
private function getLektorVertrag($lehreinheit_id = null, $mitarbeiter_uid = null)
|
||||
{
|
||||
$this->_ci->load->model('accounting/Vertrag_model', 'VertragModel');
|
||||
$vertrag = $this->_ci->VertragModel->getVertrag($mitarbeiter_uid, $lehreinheit_id);
|
||||
return hasData($vertrag) ? getData($vertrag)[0] : null;
|
||||
}
|
||||
|
||||
private function checkLehrfachPermission($lehreinheit_id, $permissions)
|
||||
{
|
||||
$lehrfach_oe_kurzbz = $this->_ci->LehreinheitModel->getLehrfachOe($lehreinheit_id);
|
||||
|
||||
if (isError($lehrfach_oe_kurzbz))
|
||||
$this->terminateWithError(getError($lehrfach_oe_kurzbz), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehrfach_oe_kurzbz = array('');
|
||||
if (hasData($lehrfach_oe_kurzbz))
|
||||
$lehrfach_oe_kurzbz = array_column(getData($lehrfach_oe_kurzbz), 'oe_kurzbz');
|
||||
|
||||
|
||||
return $this->checkPermissionGenerel($permissions, $lehrfach_oe_kurzbz);
|
||||
}
|
||||
|
||||
private function checkPermissionGenerel($permissions, $oe_array)
|
||||
{
|
||||
$hasPermission = false;
|
||||
foreach ($permissions as $permission)
|
||||
{
|
||||
if ($this->_ci->permissionlib->isBerechtigtMultipleOe($permission, $oe_array, 'suid'))
|
||||
{
|
||||
$hasPermission = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $hasPermission;
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id, $permissions)
|
||||
{
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
return $this->checkPermissionGenerel($permissions, $oe_array);
|
||||
}
|
||||
public function cancelVertrag()
|
||||
{
|
||||
$vertrag_id = $this->input->post('vertrag_id');
|
||||
@@ -355,7 +282,9 @@ class Lektor extends FHCAPI_Controller
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, array('admin', 'lehre/lehrauftrag_bestellen'));
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
$this->checkPermission($lehreinheit_id, 'suid', 'lehre/lehrauftrag_bestellen');
|
||||
|
||||
|
||||
if (is_null($vertrag_id) || !ctype_digit((string)$vertrag_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
@@ -373,6 +302,10 @@ class Lektor extends FHCAPI_Controller
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$vertrag = $this->getLektorVertrag($lehreinheit_id, $mitarbeiter_uid);
|
||||
if (is_null($vertrag) || (string)$vertrag->vertrag_id !== (string)$vertrag_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$result = $this->_ci->VertragModel->cancelVertrag($vertrag_id, $mitarbeiter_uid);
|
||||
|
||||
if (isError($result))
|
||||
@@ -387,7 +320,7 @@ class Lektor extends FHCAPI_Controller
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan'));
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
@@ -411,7 +344,8 @@ class Lektor extends FHCAPI_Controller
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, array('lv-plan/lektorentfernen'));
|
||||
$this->checkPermission($lehreinheit_id, 'suid');
|
||||
$this->checkPermission($lehreinheit_id, 'suid', 'lv-plan/lektorentfernen');
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
@@ -430,6 +364,43 @@ class Lektor extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($delete_result);
|
||||
}
|
||||
|
||||
private function checkLehreinheit($lehreinheit_id)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
return getData($lehreinheit_result)[0];
|
||||
|
||||
}
|
||||
|
||||
private function getLektorVertrag($lehreinheit_id = null, $mitarbeiter_uid = null)
|
||||
{
|
||||
$this->_ci->load->model('accounting/Vertrag_model', 'VertragModel');
|
||||
$vertrag = $this->_ci->VertragModel->getVertrag($mitarbeiter_uid, $lehreinheit_id);
|
||||
return hasData($vertrag) ? getData($vertrag)[0] : null;
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id, $art, $berechtigung = null)
|
||||
{
|
||||
if (!$this->_ci->lvverwaltungpermissionlib->isEntitledForLehreinheit($lehreinheit_id, $art, $berechtigung))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
}
|
||||
private function checkMitarbeiter($mitarbeiter_uid)
|
||||
{
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
@@ -437,4 +408,4 @@ class Lektor extends FHCAPI_Controller
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,18 +23,19 @@ use CI3_Events as Events;
|
||||
|
||||
class Setup extends FHCAPI_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
private $_ci;
|
||||
private $_uid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getLETabs' => ['admin:r', 'assistenz:r'],
|
||||
'getLVTabs' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r'],
|
||||
'getSprache' => ['admin:r', 'assistenz:r'],
|
||||
'getRaumtyp' => ['admin:r', 'assistenz:r'],
|
||||
'getLehrform' => ['admin:r', 'assistenz:r'],
|
||||
'getLETabs' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLVTabs' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getStudiensemester' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getSprache' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getRaumtyp' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getLehrform' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
|
||||
@@ -5,20 +5,20 @@ if (!defined('BASEPATH'))
|
||||
|
||||
class Tags extends Tag_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = ['admin:rw', 'assistenz:r'];
|
||||
const BERECHTIGUNG_KURZBZ = 'basis/lvverwaltung';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'getTags' => self::BERECHTIGUNG_KURZBZ,
|
||||
'addTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'updateTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'doneTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'deleteTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'updateLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
'doneLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
'deleteLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
'getTag' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'getTags' => [self::BERECHTIGUNG_KURZBZ . ':r'],
|
||||
'addTag' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'updateTag' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'doneTag' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'deleteTag' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'updateLehre' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'doneLehre' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
'deleteLehre' => [self::BERECHTIGUNG_KURZBZ . ':rw'],
|
||||
]);
|
||||
|
||||
$this->config->load('lvverwaltung');
|
||||
|
||||
@@ -4,18 +4,20 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class NotizLehreinheit extends Notiz_Controller
|
||||
{
|
||||
const PERMISSION = 'basis/lvverwaltung';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getUid' => ['admin:r', 'assistenz:r'],
|
||||
'getNotizen' => ['admin:r', 'assistenz:r'],
|
||||
'loadNotiz' => ['admin:r', 'assistenz:r'],
|
||||
'addNewNotiz' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateNotiz' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteNotiz' => ['admin:rw', 'assistenz:rw'],
|
||||
'loadDokumente' => ['admin:r', 'assistenz:r'],
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r'],
|
||||
'isBerechtigt' => ['admin:r', 'assistenz:r'],
|
||||
'getUid' => [self::PERMISSION . ':r'],
|
||||
'getNotizen' => [self::PERMISSION . ':r'],
|
||||
'loadNotiz' => [self::PERMISSION . ':r'],
|
||||
'addNewNotiz' => [self::PERMISSION . ':rw'],
|
||||
'updateNotiz' => [self::PERMISSION . ':rw'],
|
||||
'deleteNotiz' => [self::PERMISSION . ':rw'],
|
||||
'loadDokumente' => [self::PERMISSION . ':r'],
|
||||
'getMitarbeiter' => [self::PERMISSION . ':r'],
|
||||
'isBerechtigt' => [self::PERMISSION . ':r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
@@ -25,9 +27,7 @@ class NotizLehreinheit extends Notiz_Controller
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
//Permission checks for allowed Oes
|
||||
$allowedOes = $this->permissionlib->getOE_isEntitledFor('assistenz') ?: [];
|
||||
$this->load->library('LVVerwaltungPermissionLib');
|
||||
|
||||
if ($this->router->method == 'addNewNotiz')
|
||||
{
|
||||
@@ -39,7 +39,7 @@ class NotizLehreinheit extends Notiz_Controller
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->_checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes);
|
||||
$this->_checkAllowedOesFromLehreinheit($lehreinheit_id);
|
||||
}
|
||||
|
||||
if ($this->router->method == 'updateNotiz')
|
||||
@@ -63,7 +63,7 @@ class NotizLehreinheit extends Notiz_Controller
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->_checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes);
|
||||
$this->_checkAllowedOesFromLehreinheit($lehreinheit_id);
|
||||
}
|
||||
|
||||
if ($this->router->method == 'deleteNotiz')
|
||||
@@ -80,7 +80,7 @@ class NotizLehreinheit extends Notiz_Controller
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Lehreinheit ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->_checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes);
|
||||
$this->_checkAllowedOesFromLehreinheit($lehreinheit_id);
|
||||
}
|
||||
|
||||
// Load language phrases
|
||||
@@ -91,25 +91,18 @@ class NotizLehreinheit extends Notiz_Controller
|
||||
|
||||
private function _checkAllowedOesFromLehreinheit($lehreinheit_id, $allowedOes)
|
||||
{
|
||||
//get oe from lehreinheit
|
||||
$result = $this->LehreinheitModel->getOes($lehreinheit_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$oes = current($data);
|
||||
|
||||
if (!in_array($oes, $allowedOes))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg') . " " . $oes, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!$this->lvverwaltungpermissionlib->isEntitledForLehreinheit($lehreinheit_id, 'suid'))
|
||||
return $this->terminateWithError($this->p->t('ui', 'notAuthorized'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
public function isBerechtigt($id, $typeId)
|
||||
{
|
||||
if($typeId != "lehreinheit_id")
|
||||
if($typeId != "lehreinheit_id")
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui','error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
|
||||
if(!$this->lvverwaltungpermissionlib->isEntitledForLehreinheit($id, 'suid'))
|
||||
{
|
||||
$result = $this->p->t('lehre','error_keineSchreibrechte');
|
||||
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class LVVerwaltungPermissionLib
|
||||
{
|
||||
const BERECHTIGUNG = 'basis/lvverwaltung';
|
||||
|
||||
private $_ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
$this->_ci->load->library('PermissionLib');
|
||||
}
|
||||
|
||||
/**
|
||||
* Überprüft, ob man auf die Lehreinheit berechtigt ist
|
||||
* Berechtigt, wenn man Rechte hat auf:
|
||||
* die OE der LV der Lehreinheit
|
||||
* ODER die OE des Studiengangs der LV
|
||||
* ODER die OE des Lehrfachs der Lehreinheit
|
||||
* ODER die OE eines Studiengangs, in dessen Studienplan die LV hängt
|
||||
*/
|
||||
public function isEntitledForLehreinheit($lehreinheit_id, $art = 's', $berechtigungen = null)
|
||||
{
|
||||
return !empty($this->filterLehreinheitIds(array($lehreinheit_id), $art, $berechtigungen));
|
||||
}
|
||||
|
||||
/**
|
||||
* Überprüft, ob man auf die Lehrveranstaltung berechtigt ist
|
||||
* Berechtigt, wenn man Rechte hat auf:
|
||||
* die OE der LV
|
||||
* ODER die OE des Studiengangs der LV
|
||||
* ODER die OE des Lehrfachs irgendeiner Lehreinheit der LV
|
||||
* ODER die OE eines Studiengangs, in dessen Studienplan die LV hängt
|
||||
*/
|
||||
public function isEntitledForLV($lehrveranstaltung_id, $art = 's', $berechtigungen = null)
|
||||
{
|
||||
return !empty($this->filterLVIds(array($lehrveranstaltung_id), $art, true, $berechtigungen));
|
||||
}
|
||||
|
||||
/**
|
||||
* Überprüft, ob man eine Lehreinheit mit dieser LV und diesem Lehrfach anlegen bzw. darauf ändern darf
|
||||
* Berechtigt, wenn man Rechte hat auf:
|
||||
* die OE der LV
|
||||
* ODER die OE des Studiengangs der LV
|
||||
* ODER die OE des übergebenen Lehrfachs
|
||||
* ODER die OE eines Studiengangs, in dessen Studienplan die LV hängt
|
||||
*/
|
||||
public function isEntitledForLVUndLehrfach($lehrveranstaltung_id, $lehrfach_id, $art = 'suid', $berechtigungen = null)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
$result = $dbModel->execReadOnlyQuery("
|
||||
SELECT lv.oe_kurzbz
|
||||
FROM lehre.tbl_lehrveranstaltung lv
|
||||
WHERE lv.lehrveranstaltung_id = ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT stg.oe_kurzbz
|
||||
FROM lehre.tbl_lehrveranstaltung lv
|
||||
JOIN public.tbl_studiengang stg ON (stg.studiengang_kz = lv.studiengang_kz)
|
||||
WHERE lv.lehrveranstaltung_id = ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT lehrfach.oe_kurzbz
|
||||
FROM lehre.tbl_lehrveranstaltung lehrfach
|
||||
WHERE lehrfach.lehrveranstaltung_id = ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT stg.oe_kurzbz
|
||||
FROM lehre.tbl_studienplan_lehrveranstaltung
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
|
||||
JOIN public.tbl_studiengang stg USING (studiengang_kz)
|
||||
WHERE lehrveranstaltung_id = ?
|
||||
", array($lehrveranstaltung_id, $lehrveranstaltung_id, $lehrfach_id, $lehrveranstaltung_id));
|
||||
|
||||
if (isError($result) || !hasData($result))
|
||||
return false;
|
||||
|
||||
$oes = array_filter(array_column(getData($result), 'oe_kurzbz'));
|
||||
|
||||
if (empty($oes))
|
||||
return false;
|
||||
|
||||
return $this->_isBerechtigt(array_values($oes), $art, $berechtigungen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt aus einer Liste von Lehreinheiten die zurück, auf die man berechtigt ist
|
||||
* Gleiche Regel wie isEntitledForLehreinheit
|
||||
*/
|
||||
public function filterLehreinheitIds($lehreinheit_ids, $art = 's', $berechtigungen = null)
|
||||
{
|
||||
if (empty($lehreinheit_ids))
|
||||
return array();
|
||||
|
||||
$dbModel = new DB_Model();
|
||||
$result = $dbModel->execReadOnlyQuery("
|
||||
SELECT le.lehreinheit_id AS id, lv.oe_kurzbz
|
||||
FROM lehre.tbl_lehreinheit le
|
||||
JOIN lehre.tbl_lehrveranstaltung lv ON (lv.lehrveranstaltung_id = le.lehrveranstaltung_id)
|
||||
WHERE le.lehreinheit_id IN ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT le.lehreinheit_id AS id, stg.oe_kurzbz
|
||||
FROM lehre.tbl_lehreinheit le
|
||||
JOIN lehre.tbl_lehrveranstaltung lv ON (lv.lehrveranstaltung_id = le.lehrveranstaltung_id)
|
||||
JOIN public.tbl_studiengang stg ON (stg.studiengang_kz = lv.studiengang_kz)
|
||||
WHERE le.lehreinheit_id IN ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT le.lehreinheit_id AS id, lehrfach.oe_kurzbz
|
||||
FROM lehre.tbl_lehreinheit le
|
||||
JOIN lehre.tbl_lehrveranstaltung lehrfach ON (lehrfach.lehrveranstaltung_id = le.lehrfach_id)
|
||||
WHERE le.lehreinheit_id IN ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT le.lehreinheit_id AS id, stg.oe_kurzbz
|
||||
FROM lehre.tbl_lehreinheit le
|
||||
JOIN lehre.tbl_studienplan_lehrveranstaltung USING (lehrveranstaltung_id)
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
|
||||
JOIN public.tbl_studiengang stg USING (studiengang_kz)
|
||||
WHERE le.lehreinheit_id IN ?
|
||||
", array($lehreinheit_ids, $lehreinheit_ids, $lehreinheit_ids, $lehreinheit_ids));
|
||||
|
||||
return $this->_filter($result, $art, $berechtigungen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt aus einer Liste von LVs die zurück, auf die man berechtigt ist
|
||||
* Gleiche Regel wie isEntitledForLV, aber eine Abfrage für alle
|
||||
* $auchUeberLehrfach = false: Lehrfach-OEs der Lehreinheiten zählen nicht
|
||||
*/
|
||||
public function filterLVIds($lehrveranstaltung_ids, $art = 's', $auchUeberLehrfach = true, $berechtigungen = null)
|
||||
{
|
||||
if (empty($lehrveranstaltung_ids))
|
||||
return array();
|
||||
|
||||
$qry = "
|
||||
SELECT lv.lehrveranstaltung_id AS id, lv.oe_kurzbz
|
||||
FROM lehre.tbl_lehrveranstaltung lv
|
||||
WHERE lv.lehrveranstaltung_id IN ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT lv.lehrveranstaltung_id AS id, stg.oe_kurzbz
|
||||
FROM lehre.tbl_lehrveranstaltung lv
|
||||
JOIN public.tbl_studiengang stg ON (stg.studiengang_kz = lv.studiengang_kz)
|
||||
WHERE lv.lehrveranstaltung_id IN ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT lehrveranstaltung_id AS id, stg.oe_kurzbz
|
||||
FROM lehre.tbl_studienplan_lehrveranstaltung
|
||||
JOIN lehre.tbl_studienplan USING (studienplan_id)
|
||||
JOIN lehre.tbl_studienordnung USING (studienordnung_id)
|
||||
JOIN public.tbl_studiengang stg USING (studiengang_kz)
|
||||
WHERE lehrveranstaltung_id IN ?
|
||||
";
|
||||
$params = array($lehrveranstaltung_ids, $lehrveranstaltung_ids, $lehrveranstaltung_ids);
|
||||
|
||||
if ($auchUeberLehrfach)
|
||||
{
|
||||
$qry .= "
|
||||
UNION
|
||||
|
||||
SELECT le.lehrveranstaltung_id AS id, lehrfach.oe_kurzbz
|
||||
FROM lehre.tbl_lehreinheit le
|
||||
JOIN lehre.tbl_lehrveranstaltung lehrfach ON (lehrfach.lehrveranstaltung_id = le.lehrfach_id)
|
||||
WHERE le.lehrveranstaltung_id IN ?
|
||||
";
|
||||
$params[] = $lehrveranstaltung_ids;
|
||||
}
|
||||
|
||||
$dbModel = new DB_Model();
|
||||
$result = $dbModel->execReadOnlyQuery($qry, $params);
|
||||
|
||||
return $this->_filter($result, $art, $berechtigungen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die ids zurück, bei denen man auf mind. eine der OEs berechtigt ist
|
||||
*/
|
||||
private function _filter($result, $art, $berechtigungen)
|
||||
{
|
||||
if (isError($result) || !hasData($result))
|
||||
return array();
|
||||
|
||||
$oe_berechtigt = array();
|
||||
$ids = array();
|
||||
|
||||
foreach (getData($result) as $row)
|
||||
{
|
||||
$oe = $row->oe_kurzbz;
|
||||
|
||||
if (isEmptyString($oe))
|
||||
continue;
|
||||
|
||||
if (!isset($oe_berechtigt[$oe]))
|
||||
$oe_berechtigt[$oe] = $this->_isBerechtigt(array($oe), $art, $berechtigungen);
|
||||
|
||||
if ($oe_berechtigt[$oe])
|
||||
$ids[$row->id] = $row->id;
|
||||
}
|
||||
|
||||
return array_values($ids);
|
||||
}
|
||||
|
||||
private function _isBerechtigt($oes, $art, $berechtigungen)
|
||||
{
|
||||
if (is_null($berechtigungen))
|
||||
$berechtigungen = array(self::BERECHTIGUNG);
|
||||
|
||||
foreach ((array)$berechtigungen as $berechtigung)
|
||||
{
|
||||
if ($this->_ci->permissionlib->isBerechtigtMultipleOe($berechtigung, $oes, $art))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -164,10 +164,7 @@ class LvVwLib
|
||||
|
||||
protected function getPermittedStudiengangKzs()
|
||||
{
|
||||
$permittedStgs = $this->_ci->permissionlib->getSTG_isEntitledFor('admin') ?: [];
|
||||
$permittedStgs = array_merge($permittedStgs, $this->_ci->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
|
||||
|
||||
return $permittedStgs;
|
||||
return $this->_ci->permissionlib->getSTG_isEntitledFor('basis/lvverwaltung') ?: [];
|
||||
}
|
||||
|
||||
protected function getStgFromUrl($stg)
|
||||
|
||||
@@ -36,5 +36,12 @@ export default {
|
||||
url: '/api/frontend/v1/searchbar/searchStv',
|
||||
params
|
||||
};
|
||||
},
|
||||
searchLv(params) {
|
||||
return {
|
||||
method: 'post',
|
||||
url: '/api/frontend/v1/searchbar/searchLV',
|
||||
params
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -73,12 +73,9 @@ export default {
|
||||
cssclass: "position-relative",
|
||||
calcheightonly: true,
|
||||
types: [
|
||||
"mitarbeiter",
|
||||
"mitarbeiter_ohne_zuordnung",
|
||||
/*
|
||||
"employee",
|
||||
"lehreinheit",
|
||||
"lehrveranstaltung",
|
||||
*/
|
||||
],
|
||||
actions: {
|
||||
employee: {
|
||||
@@ -312,7 +309,7 @@ export default {
|
||||
}
|
||||
},
|
||||
searchfunction(params, config) {
|
||||
return this.$api.call(ApiSearchbar.search(params), config);
|
||||
return this.$api.call(ApiSearchbar.searchLv(params), config);
|
||||
},
|
||||
studiensemesterChanged(stdsem) {
|
||||
if (!stdsem) {
|
||||
|
||||
@@ -104,6 +104,7 @@ require_once('dbupdate_3.4/77080_tabulator_presets_table.php');
|
||||
require_once('dbupdate_3.4/78292_gehaltsanpassungtyp.php');
|
||||
require_once('dbupdate_3.4/54225_reihungstest_ablauf_fuer_quereinsteiger.php');
|
||||
require_once('dbupdate_3.4/77757_widgets_berechtigungen.php');
|
||||
require_once('dbupdate_3.4/84021_lvverwaltung_suche_und_rechte.php');
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
<?php
|
||||
if (! defined('DB_NAME')) exit('No direct script access allowed');
|
||||
|
||||
if($result = $db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berechtigung_kurzbz='basis/lvverwaltung'"))
|
||||
{
|
||||
if($db->db_num_rows($result)==0)
|
||||
{
|
||||
$qry = "INSERT INTO system.tbl_berechtigung(berechtigung_kurzbz, beschreibung) VALUES('basis/lvverwaltung', 'LVVerwaltung Recht');";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>Berechtigung: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Neue Berechtigung basis/lvverwaltung zu system.tbl_berechtigung hinzugefügt';
|
||||
}
|
||||
}
|
||||
@@ -2094,6 +2094,26 @@ $phrases = array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'notAuthorized',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Sie sind nicht berechtigt.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'You are not authorized.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
|
||||
Reference in New Issue
Block a user