From 3f4efbcd163089e6f557ed500bdc65517e246953 Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 11 Jan 2023 18:05:49 +0100 Subject: [PATCH] Added function isEmpfehlungsberechtigt to AnrechnungLib Checks if user is allowed to recommend Anrechnung. --- application/libraries/AnrechnungLib.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index d5168910b..7a0a4b892 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -762,6 +762,21 @@ class AnrechnungLib // Continue, if LV has no lector (there is no one to ask for recommendation) return hasData($result) ? true : false; } + + /** + * Check if user is allowed to recommend Anrechnung. + * + * @param $anrechnung_id + * @return bool + */ + public function isEmpfehlungsberechtigt($anrechnung_id) + { + // Get lv-leitungen or, if not present, all lectors of lv. + $lector_arr = $this->getLectors($anrechnung_id); + + // Return false if lv-leitung is present and user is not lv-leitung. Otherways return always true. + return in_array(getAuthUID(), array_column($lector_arr, 'uid')); + } /** * Get LV Leitung. If not present, get all LV lectors.