blob: d438425eae63220e9f9e4a2eef35ec5bcc643d21 (
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
|
<?php
/**
* @author André Klaßen <klassen@elan-ev.de>
* @author Till Glöggler <gloeggler@elan-ev.de>
* @license GPL 2 or later
*/
namespace Studip\Activity;
class UserContext extends Context
{
private $user;
/**
* create new user-context
*
* @param string $user_id
*/
public function __construct($user, $observer)
{
$this->user = $user;
$this->observer = $observer;
}
/**
* {@inheritdoc}
*/
public function getRangeId()
{
return $this->user->id;
}
/**
* {@inheritdoc}
*/
protected function getProvider()
{
if (!$this->provider) {
$this->addProvider('Studip\Activity\NewsProvider');
if ($this->user->id === $this->observer->id) {
$this->addProvider('Studip\Activity\MessageProvider');
}
foreach (\PluginManager::getInstance()->getPlugins(ActivityProvider::class) as $plugin) {
if ($plugin instanceof \HomepagePlugin
&& $plugin->isActivated($this->user->id, 'user')
) {
$this->provider[] = $plugin;
}
}
}
return $this->provider;
}
/**
* {@inheritdoc}
*/
public function getContextType()
{
return \Context::USER;
}
/**
* {@inheritdoc}
*/
public function getContextFullname($format = 'default')
{
return $this->user->getFullName($format);
}
}
|