ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningSequenceParticipants.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 public const COMPONENT_NAME = 'components/ILIAS/LearningSequence';
27
31 protected static array $instances;
34
35 public function __construct(
36 int $obj_id,
40 ) {
42 parent::__construct(self::COMPONENT_NAME, array_pop($refs));
43
44 $this->logger = $logger;
45 $this->app_event_handler = $app_event_handler;
46 $this->settings = $settings;
47 }
48
50 {
51 global $DIC;
52
53 $logger = $DIC["ilLoggerFactory"]->getRootLogger();
54 $app_event_handler = $DIC['ilAppEventHandler'];
55 $settings = $DIC["ilSetting"];
56
57 if (isset(self::$instances[$obj_id]) && self::$instances[$obj_id]) {
58 return self::$instances[$obj_id];
59 }
60
61 return self::$instances[$obj_id] = new ilLearningSequenceParticipants(
62 $obj_id,
63 $logger,
66 );
67 }
68
69 public static function getMemberRoles(int $ref_id): array
70 {
71 global $DIC;
72
73 $rbacreview = $DIC->rbac()->review();
74 $lrol = $rbacreview->getRolesOfRoleFolder($ref_id, false);
75
76 $roles = array();
77 foreach ($lrol as $role) {
78 $title = ilObject::_lookupTitle($role);
79
80 switch (substr($title, 0, 8)) {
81 case 'il_lso_a':
82 case 'il_lso_m':
83 $roles[$role] = $role;
84 // no break
85 default:
86 break;
87 }
88 }
89
90 return $roles;
91 }
92
93 public static function _isParticipant(int $a_ref_id, int $a_usr_id): bool
94 {
95 global $DIC;
96
97 $rbacreview = $DIC->rbac()->review();
98 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
99
100 return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
101 }
102
103 public function add(int $a_usr_id, int $a_role): bool
104 {
105 return parent::add($a_usr_id, $a_role);
106 }
107
108 public function addSubscriber(int $a_usr_id): void
109 {
110 parent::addSubscriber($a_usr_id);
111
112 $this->logger->info('Raise new event: Modules/LearningSequence addSubscriber.');
113 $this->app_event_handler->raise(
114 "components/ILIAS/LearningSequence",
115 'addSubscriber',
116 array(
117 'obj_id' => $this->getObjId(),
118 'usr_id' => $a_usr_id
119 )
120 );
121 }
122
126 public function sendNotification(int $type, int $usr_id, bool $force_sending_mail = false): bool
127 {
129 $mail->forceSendingMail($force_sending_mail);
130
131 switch ($type) {
134 $mail->setRefId($this->ref_id);
135 $mail->setRecipients(array($usr_id));
136 $mail->send();
137 break;
140 $mail->setRefId($this->ref_id);
141 $mail->setRecipients(array($usr_id));
142 $mail->send();
143 break;
146 $mail->setAdditionalInformation(array('usr_id' => $usr_id));
147 $mail->setRefId($this->ref_id);
148 $mail->setRecipients($this->getNotificationRecipients());
149 $mail->send();
150 break;
153 $mail->setRefId($this->ref_id);
154 $mail->setRecipients(array($usr_id));
155 $mail->send();
156 break;
159 $mail->setAdditionalInformation(array('usr_id' => $usr_id));
160 $mail->setRefId($this->ref_id);
161 $mail->setRecipients($this->getNotificationRecipients());
162 $mail->send();
163 break;
166 $mail->setRefId($this->ref_id);
167 $mail->setRecipients(array($usr_id));
168 $mail->send();
169 break;
172 $mail->setAdditionalInformation(array('usr_id' => $usr_id));
173 $mail->setRefId($this->ref_id);
174 $mail->setRecipients($this->getNotificationRecipients());
175 $mail->send();
176 break;
179 $mail->setRefId($this->ref_id);
180 $mail->setRecipients(array($usr_id));
181 $mail->send();
182 break;
185 $mail->setRefId($this->ref_id);
186 $mail->setRecipients(array($usr_id));
187 $mail->send();
188 break;
191 $mail->setRefId($this->ref_id);
192 $mail->setRecipients(array($usr_id));
193 $mail->send();
194 break;
195 }
196 return true;
197 }
198}
Global event handler.
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
__construct(int $obj_id, ilLogger $logger, ilAppEventHandler $app_event_handler, ilSetting $settings)
sendNotification(int $type, int $usr_id, bool $force_sending_mail=false)
Send notification mail.
Component logger with individual log levels by component id.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
Base class for course and group participants.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
ILIAS Setting Class.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26