From a91052710992559a9974a5567a8fe48db9e72d43 Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 24 Sep 2019 10:13:08 +0200 Subject: [PATCH] Added method isLektor() This method checks if a given user is a lector (and eventually if is fix employed) --- .../models/ressource/Mitarbeiter_model.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/application/models/ressource/Mitarbeiter_model.php b/application/models/ressource/Mitarbeiter_model.php index 1e03a0ecd..2397f9c7e 100644 --- a/application/models/ressource/Mitarbeiter_model.php +++ b/application/models/ressource/Mitarbeiter_model.php @@ -11,4 +11,33 @@ class Mitarbeiter_model extends DB_Model $this->dbTable = 'public.tbl_mitarbeiter'; $this->pk = 'mitarbeiter_uid'; } + + /** + * Checks if the user is a lector. + * @param string $uid + * @param boolean null $fixangestellt + * @return bool + */ + public function isLektor($uid, $fixangestellt = null) + { + $this->addSelect('1'); + + if (is_bool($fixangestellt)) + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid, 'lektor' => true, 'fixangestellt' => $fixangestellt)); + } + else // Default: if lektor is true + { + $result = $this->loadWhere(array('mitarbeiter_uid' => $uid, 'lektor' => true)); + } + + if(hasData($result)) + { + return true; + } + else + { + return false; + } + } }