18declare(strict_types=0);
42 if (isset(self::$instances[$a_obj_id]) && self::$instances[$a_obj_id]) {
43 return self::$instances[$a_obj_id];
48 public function add(
int $a_usr_id,
int $a_role): bool
61 $rbacreview =
$DIC[
'rbacreview'];
62 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
64 foreach ($lrol as $role) {
66 switch (substr($title, 0, 8)) {
81 parent::addSubscriber($a_usr_id);
82 $this->eventHandler->raise(
83 "components/ILIAS/Course",
95 bool $a_manual =
false,
96 bool $a_no_origin =
false
98 $this->participants_status[$a_usr_id][
'passed'] = $a_passed;
106 bool $a_manual =
false,
107 bool $a_no_origin =
false
112 $ilUser =
$DIC[
'ilUser'];
113 $ilAppEventHandler =
$DIC->event();
118 $origin = $ilUser->getId();
121 $query =
"SELECT passed FROM obj_members " .
122 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
123 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
126 if (
$res->numRows()) {
129 if ((
int) $old[
"passed"] !== (
int) $a_passed) {
130 $update_query =
"UPDATE obj_members SET " .
131 "passed = " .
$ilDB->quote($a_passed,
'integer') .
", " .
132 "origin = " .
$ilDB->quote($origin,
'integer') .
", " .
133 "origin_ts = " .
$ilDB->quote(time(),
'integer') .
" " .
134 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
135 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
140 if ($a_no_origin && !$a_passed) {
147 $update_query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) " .
149 $ilDB->quote((
int) $a_passed,
'integer') .
", " .
150 $ilDB->quote($a_obj_id,
'integer') .
", " .
151 $ilDB->quote($a_usr_id,
'integer') .
", " .
152 $ilDB->quote(0,
'integer') .
", " .
153 $ilDB->quote(0,
'integer') .
", " .
154 $ilDB->quote($origin,
'integer') .
", " .
155 $ilDB->quote($origin_ts,
'integer') .
")
156 ON DUPLICATE KEY UPDATE
157 passed = VALUES(passed),
158 origin = VALUES(origin),
159 origin_ts = VALUES(origin_ts)
162 if (strlen($update_query)) {
163 $ilDB->manipulate($update_query);
165 $ilAppEventHandler->raise(
'components/ILIAS/Course',
'participantHasPassedCourse', array(
166 'obj_id' => $a_obj_id,
167 'usr_id' => $a_usr_id,
175 $sql =
"SELECT origin, origin_ts" .
176 " FROM obj_members" .
177 " WHERE obj_id = " . $this->ilDB->quote($this->obj_id,
"integer") .
178 " AND usr_id = " . $this->ilDB->quote($a_usr_id,
"integer");
179 $set = $this->ilDB->query($sql);
180 $row = $this->ilDB->fetchAssoc($set);
181 if ($row && $row[
"origin"]) {
183 "user_id" => (
int) $row[
"origin"],
190 public function sendNotification(
int $a_type,
int $a_usr_id,
bool $a_force_sending_mail =
false): void
193 $mail->forceSendingMail($a_force_sending_mail);
198 $mail->setRefId($this->ref_id);
199 $mail->setRecipients(array($a_usr_id));
205 $mail->setRefId($this->ref_id);
206 $mail->setRecipients(array($a_usr_id));
212 $mail->setRefId($this->ref_id);
213 $mail->setRecipients(array($a_usr_id));
219 $mail->setRefId($this->ref_id);
220 $mail->setRecipients(array($a_usr_id));
226 $mail->setRefId($this->ref_id);
227 $mail->setRecipients(array($a_usr_id));
233 $mail->setRefId($this->ref_id);
234 $mail->setRecipients(array($a_usr_id));
240 $mail->setRefId($this->ref_id);
241 $mail->setRecipients(array($a_usr_id));
247 $mail->setRefId($this->ref_id);
248 $mail->setRecipients(array($a_usr_id));
254 $mail->setRefId($this->ref_id);
255 $mail->setRecipients(array($a_usr_id));
261 $pos = $wl->getPosition($a_usr_id);
264 $mail->setRefId($this->ref_id);
265 $mail->setRecipients(array($a_usr_id));
266 $mail->setAdditionalInformation(array(
'position' => $pos));
271 $this->sendSubscriptionRequestToAdmins($a_usr_id);
275 $this->sendNotificationToAdmins($a_usr_id);
284 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
285 $mail->setRefId($this->ref_id);
286 $mail->setRecipients($this->getNotificationRecipients());
294 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
295 $mail->setRefId($this->ref_id);
296 $mail->setRecipients($this->getNotificationRecipients());
304 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
305 $mail->setRefId($this->ref_id);
306 $mail->setRecipients($this->getNotificationRecipients());
315 $sql =
"SELECT origin_ts FROM obj_members" .
316 " WHERE usr_id = " .
$ilDB->quote($a_usr_id,
"integer") .
317 " AND obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
318 " AND passed = " .
$ilDB->quote(1,
"integer");
321 if ((
$res[
"origin_ts"] ?? 0) > 0) {
322 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
332 $sql =
"SELECT usr_id,obj_id FROM obj_members" .
333 " WHERE " .
$ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer") .
334 " AND " .
$ilDB->in(
"obj_id", $a_obj_ids,
false,
"integer") .
335 " AND passed = " .
$ilDB->quote(1,
"integer");
336 $set =
$ilDB->query($sql);
338 while ($row =
$ilDB->fetchAssoc($set)) {
339 $row[
'usr_id'] = (
int) $row[
'usr_id'];
340 $row[
'obj_id'] = (
int) $row[
'obj_id'];
const TYPE_UNBLOCKED_MEMBER
const TYPE_NOTIFICATION_REGISTRATION
const TYPE_STATUS_CHANGED
const TYPE_REFUSED_SUBSCRIPTION_MEMBER
const TYPE_BLOCKED_MEMBER
const TYPE_ACCEPTED_SUBSCRIPTION_MEMBER
const TYPE_ADMISSION_MEMBER
const TYPE_NOTIFICATION_ADMINS
const TYPE_NOTIFICATION_REGISTRATION_REQUEST
const TYPE_WAITING_LIST_MEMBER
const TYPE_SUBSCRIBE_MEMBER
const TYPE_NOTIFICATION_UNSUBSCRIBE
const TYPE_DISMISS_MEMBER
const TYPE_UNSUBSCRIBE_MEMBER
const TYPE_NOTIFICATION_ADMINS_REGISTRATION_REQUEST
static getDateTimeOfPassed(int $a_obj_id, int $a_usr_id)
static _getInstanceByObjId(int $a_obj_id)
updatePassed(int $a_usr_id, bool $a_passed, bool $a_manual=false, bool $a_no_origin=false)
sendNotification(int $a_type, int $a_usr_id, bool $a_force_sending_mail=false)
addSubscriber(int $a_usr_id)
getPassedInfo(int $a_usr_id)
sendSubscriptionRequestToAdmins(int $a_usr_id)
__construct(int $a_obj_id)
static getMemberRoles(int $a_ref_id)
add(int $a_usr_id, int $a_role)
static _updatePassed(int $a_obj_id, int $a_usr_id, bool $a_passed, bool $a_manual=false, bool $a_no_origin=false)
sendUnsubscribeNotificationToAdmins(int $a_usr_id)
sendNotificationToAdmins(int $a_usr_id)
static getPassedUsersForObjects(array $a_obj_ids, array $a_usr_ids)
@classDescription Date and time handling
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
Base class for course and group participants.
addRecommendation(int $a_usr_id)
Add desktop item @access public.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc