diff options
| author | Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> | 2024-06-18 13:18:06 +0000 |
|---|---|---|
| committer | Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> | 2024-06-18 13:18:06 +0000 |
| commit | 33fd1358507b4a5abb3dcebe78d407d0567717c1 (patch) | |
| tree | 6bd8f6959da4c3fc1b8907c0bbc28eb9e10d4a5a /lib/modules/ConsultationModule.class.php | |
| parent | 42d46671c0309bddb71a91bbfdc5f2fa2e44384e (diff) | |
Deprecate `StudipAutoloader` and use composer's `autoload`
Closes #4282
Merge request studip/studip!3099
Diffstat (limited to 'lib/modules/ConsultationModule.class.php')
| -rw-r--r-- | lib/modules/ConsultationModule.class.php | 202 |
1 files changed, 0 insertions, 202 deletions
diff --git a/lib/modules/ConsultationModule.class.php b/lib/modules/ConsultationModule.class.php deleted file mode 100644 index c68f8ca..0000000 --- a/lib/modules/ConsultationModule.class.php +++ /dev/null @@ -1,202 +0,0 @@ -<?php -/** - * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> - * @license GPL2 or any later version - */ -class ConsultationModule extends CorePlugin implements StudipModule, SystemPlugin, PrivacyPlugin, HomepagePlugin -{ - public function __construct() - { - parent::__construct(); - - // Update consultation events for the course when a member changes - foreach (['UserDidEnterCourse', 'UserDidLeaveCourse'] as $event) { - NotificationCenter::on($event, function ($event, $course_id) { - $course = Course::find($course_id); - if ($course) { - ConsultationSlot::findEachBySQL( - function (ConsultationSlot $slot) { - $slot->updateEvents(); - }, - "JOIN consultation_blocks USING (block_id) - WHERE range_id = ? AND range_type = 'course'", - [$course_id] - ); - } - }); - } - - // Update consultation events for the course when a member changes - foreach (['InstituteMemberDidCreate', 'InstituteMemberDidDelete'] as $event) { - NotificationCenter::on($event, function ($event, InstituteMember $member) { - ConsultationSlot::findEachBySQL( - function (ConsultationSlot $slot) { - $slot->updateEvents(); - }, - "JOIN consultation_blocks USING (block_id) - WHERE range_id = ? AND range_type = 'institute'", - [$member->institut_id] - ); - }); - } - - NotificationCenter::on('UserDidLeaveCourse', function ($event, $course_id) { - // Delete consultation events for the user and course - $course = Course::find($course_id); - if ($course) { - ConsultationSlot::findEachBySQL( - function (ConsultationSlot $slot) { - $slot->updateEvents(); - }, - "JOIN consultation_blocks USING (block_id) - WHERE range_id = ? AND range_type = 'course'", - [$course_id] - ); - } - }); - - NotificationCenter::on('UserDidDelete', function ($event, $user) { - // Delete consultation bookings and slots - ConsultationBooking::deleteByUser_id($user->id); - ConsultationBlock::deleteBySQL("range_id = ? AND range_type = 'user'", [$user->id]); - }); - NotificationCenter::on('CourseDidDelete', function ($event, $course) { - // Delete consultation blocks - ConsultationBlock::deleteBySQL("range_id = ? AND range_type = 'course'", [$course->id]); - }); - NotificationCenter::on('InstituteDidDelete', function ($event, $institute) { - // Delete consultation blocks - ConsultationBlock::deleteBySQL("range_id = ? AND range_type = 'institute'", [$institute->id]); - }); - } - - /** - * {@inheritdoc} - */ - public function isActivatableForContext(Range $context) - { - // Consultations globally disabled? - if (!Config::get()->CONSULTATION_ENABLED) { - return false; - } - - // Context is user and current user has required permission? - if ($context instanceof User) { - return $GLOBALS['perm']->have_perm(Config::get()->CONSULTATION_REQUIRED_PERMISSION, $context->getRangeId()); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function getIconNavigation($course_id, $last_visit, $user_id) - { - // TODO - - return null; - } - - /** - * {@inheritdoc} - */ - public function getTabNavigation($course_id) - { - if ($GLOBALS['user']->id !== 'nobody') { - $navigation = new ConsultationNavigation(RangeFactory::find($course_id)); - $navigation->setImage(Icon::create('consultation', Icon::ROLE_INFO_ALT)); - return ['consultation' => $navigation]; - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function getInfoTemplate($course_id) - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getHomepageTemplate($user_id) - { - return null; - } - - - /** - * {@inheritdoc} - */ - public function getMetadata() - { - return [ - 'summary' => _('Generische Terminvergabe'), - 'description' => _('Über die generische Terminvergabe können jegliche Formen von Terminen ' . - 'angeboten werden, zu denen sich Personen oder auch Gruppen von Personen ' . - 'anmelden können.'), - 'category' => _('Kommunikation und Zusammenarbeit'), - 'keywords' => _('Terminvergabe, Sprechstunden'), - 'displayname' => _('Terminvergabe'), - 'icon' => Icon::create('consultation', Icon::ROLE_INFO), - 'icon_clickable' => Icon::create('consultation', Icon::ROLE_CLICKABLE), - 'screenshots' => [ - 'path' => 'assets/images/plus/screenshots/Terminvergabe', - 'pictures' => [ - [ - 'source' => 'uebersicht.png', - 'title' => _('Übersicht der erstellten Termine'), - ], - [ - 'source' => 'anlegen.png', - 'title' => _('Erstellen neuer Termine'), - ], - ] - ] - ]; - } - - /** - * {@inheritdoc} - */ - public function exportUserData(StoredUserData $storage) - { - $storage->addTabularData( - _('Terminblöcke'), - 'consultation_blocks', - ConsultationBlock::findAndMapBySQL( - function ($block) { - return $block->toRawArray(); - }, - "range_id = :user_id AND range_type = 'user'", - [':user_id' => $storage->user_id] - ) - ); - $storage->addTabularData( - _('Terminbuchungen'), - 'consultation_bookings', - ConsultationBooking::findAndMapBySQL( - function ($booking) { - return $booking->toRawArray(); - }, - 'user_id = :user_id', - [':user_id' => $storage->user_id] - ) - ); - $storage->addTabularData( - _('Terminverantwortlichkeiten'), - 'consultation_responsibilities', - ConsultationResponsibility::findAndMapBySQL( - function ($responsibility) { - return $responsibility->toRawArray(); - }, - "range_id = :user_id AND range_type = 'user'", - [':user_id' => $storage->user_id] - ) - ); - } -} |
