From 925d210bfffdf022e8ad1d83657e7a7590b5fded Mon Sep 17 00:00:00 2001 From: Paminger Date: Fri, 24 Jun 2016 13:08:18 +0200 Subject: [PATCH] Permission Problem workaround --- application/core/DB_Model.php | 38 ++++++++++++++++++++----------- include/benutzer.class.php | 8 ++++++- include/berechtigung.class.php | 8 ++++++- include/funktion.class.php | 7 +++--- include/person.class.php | 2 +- include/statistik.class.php | 2 +- include/studiensemester.class.php | 8 ++++++- 7 files changed, 52 insertions(+), 21 deletions(-) diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index a5bc4d298..0bc610b1b 100644 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -137,9 +137,11 @@ class DB_Model extends FHC_Model return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR); - // Check rights - if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); + // Check rights only if this method is called from a model + //var_dump(get_called_class()); + if (substr(get_called_class(), -6) == '_model') + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); // DB-SELECT // Check for composite Primary Key @@ -173,8 +175,11 @@ class DB_Model extends FHC_Model return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR); // Check rights - if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); + // Check rights only if this method is called from a model + //var_dump(get_called_class()); + if (substr(get_called_class(), -6) == '_model') + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); // DB-SELECT if (is_null($where)) @@ -204,9 +209,11 @@ class DB_Model extends FHC_Model return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR); - // Check rights - if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); + // Check rights only if this method is called from a model + //var_dump(get_called_class()); + if (substr(get_called_class(), -6) == '_model') + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); // DB-SELECT $result = $this->db->get($this->dbTable); @@ -229,8 +236,11 @@ class DB_Model extends FHC_Model return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR); // Check rights for joined table - if (! $this->fhc_db_acl->isBerechtigt($this->acl[$joinTable], 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$joinTable], FHC_MODEL_ERROR); + // Check rights only if this method is called from a model + //var_dump(get_called_class()); + if (substr(get_called_class(), -6) == '_model') + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$joinTable], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$joinTable], FHC_MODEL_ERROR); $this->db->join($joinTable, $cond, $type); @@ -300,9 +310,11 @@ class DB_Model extends FHC_Model if (is_null($this->pk)) return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR); - // Check rights - if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 'd')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); + // Check rights only if this method is called from a model + //var_dump(get_called_class()); + if (substr(get_called_class(), -6) == '_model') + if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 'd')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR); // DB-DELETE // Check for composite Primary Key diff --git a/include/benutzer.class.php b/include/benutzer.class.php index edebb247c..105639175 100644 --- a/include/benutzer.class.php +++ b/include/benutzer.class.php @@ -49,8 +49,14 @@ class benutzer extends person * Laedt Benutzer mit der uebergebenen ID * @param $uid ID der Person die geladen werden soll */ - public function load($uid) + public function load($uid = null) { + if (empty($uid)) + { + $this->errormsg = "UID not set!"; + return false; + } + $qry = "SELECT * FROM public.tbl_benutzer WHERE uid=".$this->db_add_param($uid); if($this->db_query($qry)) diff --git a/include/berechtigung.class.php b/include/berechtigung.class.php index 3e9cc654c..ac140eead 100644 --- a/include/berechtigung.class.php +++ b/include/berechtigung.class.php @@ -50,8 +50,14 @@ class berechtigung extends Berechtigung_model * @param $berechtigung_kurzbz * @return true wenn ok, false im Fehlerfall */ - public function load($berechtigung_kurzbz) + public function load($berechtigung_kurzbz = null) { + if (empty($berechtigung_kurzbz)) + { + $this->errormsg = "berechtigung not set!"; + return false; + } + $result = parent::load($berechtigung_kurzbz); if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval)) diff --git a/include/funktion.class.php b/include/funktion.class.php index 838638079..6e72a9631 100644 --- a/include/funktion.class.php +++ b/include/funktion.class.php @@ -109,9 +109,10 @@ class funktion extends Funktion_model * @param $funktion_kurzbz ID der zu ladenden Funktion * @return true wenn ok, false im Fehlerfall */ - public function load($funktion_kurzbz) + public function load($funktion_kurzbz = null) { - if ($funktion_kurzbz == '') + + if (empty($funktion_kurzbz) || $funktion_kurzbz == '') { $this->errormsg = 'funktion_bz darf nicht leer sein'; return false; @@ -218,4 +219,4 @@ class funktion extends Funktion_model } } } -?> \ No newline at end of file +?> diff --git a/include/person.class.php b/include/person.class.php index 79f98f113..5682d2ee7 100644 --- a/include/person.class.php +++ b/include/person.class.php @@ -87,7 +87,7 @@ class person extends Person_model * @param int $personId ID der Person die geladen werden soll. * @return bool **/ - public function load($personId) + public function load($personId = null) { //person_id auf gueltigkeit pruefen if (is_numeric($personId) && $personId != '') diff --git a/include/statistik.class.php b/include/statistik.class.php index 73be1b34d..c95e5d74a 100644 --- a/include/statistik.class.php +++ b/include/statistik.class.php @@ -80,7 +80,7 @@ class statistik extends Statistik_model * Laedt eine Statistik * @param $statistik_kurzbz */ - public function load($statistik_kurzbz) + public function load($statistik_kurzbz = null) { $result = parent::load($statistik_kurzbz); diff --git a/include/studiensemester.class.php b/include/studiensemester.class.php index 12e48ee1b..b62e2ebff 100644 --- a/include/studiensemester.class.php +++ b/include/studiensemester.class.php @@ -59,8 +59,14 @@ class studiensemester extends Studiensemester_model * * @param $studiensemester_kurzbz Stsem das geladen werden soll */ - public function load($studiensemester_kurzbz) + public function load($studiensemester_kurzbz = null) { + if (empty($studiensemester_kurzbz)) + { + $this->errormsg = "studiensemester not set!"; + return false; + } + $result = parent::load($studiensemester_kurzbz); if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval))