ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLearningSequenceParticipants.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
11{
12 const COMPONENT_NAME = 'Modules/LearningSequence';
13
17 protected static $instances;
18
19 public function __construct(
20 int $obj_id,
22 ilAppEventHandler $app_event_handler,
23 ilSetting $settings
24 ) {
26 parent::__construct(self::COMPONENT_NAME, array_pop($refs));
27
28 $this->logger = $logger;
29 $this->app_event_handler = $app_event_handler;
30 $this->settings = $settings;
31 }
32
34 {
35 global $DIC;
36
37 $logger = $DIC["ilLoggerFactory"]->getRootLogger();
38 $app_event_handler = $DIC['ilAppEventHandler'];
39 $settings = $DIC["ilSetting"];
40
41 if (isset(self::$instances[$obj_id]) and self::$instances[$obj_id]) {
42 return self::$instances[$obj_id];
43 }
44
45 return self::$instances[$obj_id] = new ilLearningSequenceParticipants(
46 $obj_id,
47 $logger,
48 $app_event_handler,
49 $settings
50 );
51 }
52
53 public static function getMemberRoles($ref_id) : array
54 {
55 global $DIC;
56
57 $rbacreview = $DIC->rbac()->review();
58 $lrol = $rbacreview->getRolesOfRoleFolder($ref_id, false);
59
60 $roles = array();
61 foreach ($lrol as $role) {
63
64 switch (substr($title, 0, 8)) {
65 case 'il_lso_a':
66 case 'il_lso_m':
67 $roles[$role] = $role;
68 // no break
69 default:
70 break;
71 }
72 }
73
74 return $roles;
75 }
76
77 public static function _isParticipant($ref_id, $usr_id) : bool
78 {
79 global $DIC;
80
81 $rbacreview = $DIC->rbac()->review();
82 $local_roles = $rbacreview->getRolesOfRoleFolder($ref_id, false);
83
84 return $rbacreview->isAssignedToAtLeastOneGivenRole($usr_id, $local_roles);
85 }
86
87 public function add($usr_id, $role) : bool
88 {
89 if (parent::add($usr_id, $role)) {
90 $this->addDesktopItem($usr_id);
91 return true;
92 }
93
94 return false;
95 }
96
97 public function addSubscriber($usr_id)
98 {
99 parent::addSubscriber($usr_id);
100
101 $this->log->lso()->info('Raise new event: Modules/LearningSequence addSubscriber.');
102 $this->app_event_handler->raise(
103 "Modules/LearningSequence",
104 'addSubscriber',
105 array(
106 'obj_id' => $this->getObjId(),
107 'usr_id' => $usr_id
108 )
109 );
110 }
111
115 public function sendNotification($type, $usr_id, $force_sending_mail = false) : bool
116 {
117 $mail = new ilLearningSequenceMembershipMailNotification($this->logger, $this->settings);
118 $mail->forceSendingMail($force_sending_mail);
119
120 switch ($type) {
123 $mail->setRefId($this->ref_id);
124 $mail->setRecipients(array($usr_id));
125 $mail->send();
126 break;
129 $mail->setRefId($this->ref_id);
130 $mail->setRecipients(array($usr_id));
131 $mail->send();
132 break;
135 $mail->setAdditionalInformation(array('usr_id' => $usr_id));
136 $mail->setRefId($this->ref_id);
137 $mail->setRecipients($this->getNotificationRecipients());
138 $mail->send();
139 break;
142 $mail->setRefId($this->ref_id);
143 $mail->setRecipients(array($usr_id));
144 $mail->send();
145 break;
148 $mail->setAdditionalInformation(array('usr_id' => $usr_id));
149 $mail->setRefId($this->ref_id);
150 $mail->setRecipients($this->getNotificationRecipients());
151 $mail->send();
152 break;
155 $mail->setRefId($this->ref_id);
156 $mail->setRecipients(array($usr_id));
157 $mail->send();
158 break;
161 $mail->setAdditionalInformation(array('usr_id' => $usr_id));
162 $mail->setRefId($this->ref_id);
163 $mail->setRecipients($this->getNotificationRecipients());
164 $mail->send();
165 break;
168 $mail->setRefId($this->ref_id);
169 $mail->setRecipients(array($usr_id));
170 $mail->send();
171 break;
174 $mail->setRefId($this->ref_id);
175 $mail->setRecipients(array($usr_id));
176 $mail->send();
177 break;
180 $mail->setRefId($this->ref_id);
181 $mail->setRecipients(array($usr_id));
182 $mail->send();
183 break;
184 }
185 return true;
186 }
187}
An exception for terminatinating execution or to throw for unit testing.
Global event handler.
sendNotification($type, $usr_id, $force_sending_mail=false)
Send notification mail.
__construct(int $obj_id, ilLogger $logger, ilAppEventHandler $app_event_handler, ilSetting $settings)
static _isParticipant($ref_id, $usr_id)
Static function to check if a user is a participant of the container object.
Component logger with individual log levels by component id.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
addDesktopItem($a_usr_id)
Add desktop item.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
getObjId()
get current obj_id
ILIAS Setting Class.
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
add()
Definition: add.php:2