aboutsummaryrefslogtreecommitdiff
path: root/lib/activities/ActivityObserver.php
blob: 5bfd4cc6fef6b0a9809908642ceb726842e5dd33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php

/**
 * @author      André Klaßen <klassen@elan-ev.de>
 * @author      Till Glöggler <tgloeggl@uos.de>
 * @license     GPL 2 or later
 */


namespace Studip\Activity;

class ActivityObserver
{
    /**
     * Register for Notifications the providers shall respond to
     *
     */
    public static function initialize()
    {
        \NotificationCenter::addObserver('Studip\Activity\MessageProvider', 'postActivity','MessageDidSend');

        // Notifications for ParticipantsProvider
        \NotificationCenter::addObserver('\Studip\Activity\ParticipantsProvider', 'postActivity','UserDidEnterCourse');
        \NotificationCenter::addObserver('\Studip\Activity\ParticipantsProvider', 'postActivity','UserDidLeaveCourse');

        //Notifications for DocumentsProvider
        \NotificationCenter::addObserver('\Studip\Activity\DocumentsProvider', 'postActivity','FileRefDidCreate');
        \NotificationCenter::addObserver('\Studip\Activity\DocumentsProvider', 'postActivity','FileRefDidUpdate');
        \NotificationCenter::addObserver('\Studip\Activity\DocumentsProvider', 'postActivity','FileRefDidDelete');

        //Notifications for NewsProvider
        \NotificationCenter::addObserver('\Studip\Activity\NewsProvider', 'postActivity','StudipNewsDidCreate');

        //Notifications for WikiProvider
        \NotificationCenter::addObserver('\Studip\Activity\WikiProvider', 'postActivity','WikiPageDidCreate');
        \NotificationCenter::addObserver('\Studip\Activity\WikiProvider', 'postActivity','WikiPageDidDelete');
        //this is rather pointless and annoying
        //\NotificationCenter::addObserver('\Studip\Activity\WikiProvider', 'postActivity','WikiPageDidUpdate');

        //Notifications for ScheduleProvider (Course)
        \NotificationCenter::addObserver('\Studip\Activity\ScheduleProvider', 'postActivity','CourseDidChangeSchedule');


        // Notifications for CoursewareProvider
        foreach (
            [
                \Courseware\Block::class,
                \Courseware\BlockComment::class,
                \Courseware\BlockFeedback::class,
                \Courseware\StructuralElementComment::class,
                \Courseware\StructuralElement::class,
                \Courseware\StructuralElementFeedback::class,
                \Courseware\Task::class,
                \Courseware\TaskFeedback::class,
            ] as $class
        ) {
            \NotificationCenter::addObserver(
                \Studip\Activity\CoursewareProvider::class,
                'postActivity',
                $class . 'DidCreate'
            );
        }

        foreach (
            [
                \Courseware\Block::class,
                \Courseware\TaskFeedback::class
            ] as $class
        ) {
            \NotificationCenter::addObserver(
                \Studip\Activity\CoursewareProvider::class,
                'postActivity',
                $class . 'DidUpdate'
            );
        }
    }
}