diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2024-01-29 15:16:24 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2024-01-29 15:16:24 +0000 |
| commit | 7c1df847d94d3956bc763b94b73cebfe108dc9a1 (patch) | |
| tree | e18e003bff65c5bf0748c644d6cd3d235cb1feca /lib/models/Course.class.php | |
| parent | da0110d5e85279123e8dde392cb4c926397238bf (diff) | |
StEP 01354, closes #1354
Closes #1354
Merge request studip/studip!2116
Diffstat (limited to 'lib/models/Course.class.php')
| -rw-r--r-- | lib/models/Course.class.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php index ab58219..75dad33 100644 --- a/lib/models/Course.class.php +++ b/lib/models/Course.class.php @@ -80,7 +80,7 @@ * @property-read mixed $config additional field */ -class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, FeedbackRange +class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, FeedbackRange, Studip\Calendar\Owner { protected static function configure($config = []) { @@ -1081,4 +1081,40 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe { return $this->getFullName(); } + + /** + * @inheritDoc + */ + public static function getCalendarOwner(string $owner_id): ?\Studip\Calendar\Owner + { + return self::find($owner_id); + } + + /** + * @inheritDoc + */ + public function isCalendarReadable(?string $user_id = null): bool + { + if ($user_id === null) { + $user_id = self::findCurrent()->id; + } + + //Calendar read permissions are granted for all participants + //that have at least user permissions. + return $GLOBALS['perm']->have_studip_perm('user', $this->id, $user_id); + } + + /** + * @inheritDoc + */ + public function isCalendarWritable(string $user_id = null): bool + { + if ($user_id === null) { + $user_id = self::findCurrent()->id; + } + + //Calendar write permissions are granted for all participants + //that have autor permissions or higher. + return $GLOBALS['perm']->have_studip_perm('autor', $this->id, $user_id); + } } |
