19declare(strict_types=0);
43 if (isset(self::$instances[$a_obj_id]) && self::$instances[$a_obj_id]) {
44 return self::$instances[$a_obj_id];
49 public function add(
int $a_usr_id,
int $a_role): bool
62 $rbacreview =
$DIC[
'rbacreview'];
63 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
65 foreach ($lrol as $role) {
67 switch (substr($title, 0, 8)) {
82 parent::addSubscriber($a_usr_id);
83 $this->eventHandler->raise(
84 "components/ILIAS/Course",
96 bool $a_manual =
false,
97 bool $a_no_origin =
false
99 $this->participants_status[$a_usr_id][
'passed'] = $a_passed;
107 bool $a_manual =
false,
108 bool $a_no_origin =
false
113 $ilUser =
$DIC[
'ilUser'];
114 $ilAppEventHandler =
$DIC->event();
119 $origin = $ilUser->getId();
122 $query =
"SELECT passed FROM obj_members " .
123 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
124 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
127 if (
$res->numRows()) {
130 if ((
int) $old[
"passed"] !== (
int) $a_passed) {
131 $update_query =
"UPDATE obj_members SET " .
132 "passed = " .
$ilDB->quote($a_passed,
'integer') .
", " .
133 "origin = " .
$ilDB->quote($origin,
'integer') .
", " .
134 "origin_ts = " .
$ilDB->quote(time(),
'integer') .
" " .
135 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
136 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
141 if ($a_no_origin && !$a_passed) {
148 $update_query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) " .
150 $ilDB->quote((
int) $a_passed,
'integer') .
", " .
151 $ilDB->quote($a_obj_id,
'integer') .
", " .
152 $ilDB->quote($a_usr_id,
'integer') .
", " .
153 $ilDB->quote(0,
'integer') .
", " .
154 $ilDB->quote(0,
'integer') .
", " .
155 $ilDB->quote($origin,
'integer') .
", " .
156 $ilDB->quote($origin_ts,
'integer') .
")
157 ON DUPLICATE KEY UPDATE
158 passed = VALUES(passed),
159 origin = VALUES(origin),
160 origin_ts = VALUES(origin_ts)
163 if (strlen($update_query)) {
164 $ilDB->manipulate($update_query);
166 $ilAppEventHandler->raise(
'components/ILIAS/Course',
'participantHasPassedCourse', array(
167 'obj_id' => $a_obj_id,
168 'usr_id' => $a_usr_id,
176 $sql =
"SELECT origin, origin_ts" .
177 " FROM obj_members" .
178 " WHERE obj_id = " . $this->ilDB->quote($this->obj_id,
"integer") .
179 " AND usr_id = " . $this->ilDB->quote($a_usr_id,
"integer");
180 $set = $this->ilDB->query($sql);
181 $row = $this->ilDB->fetchAssoc($set);
182 if ($row && $row[
"origin"]) {
184 "user_id" => (
int) $row[
"origin"],
191 public function sendNotification(
int $a_type,
int $a_usr_id,
bool $a_force_sending_mail =
false): void
194 $mail->forceSendingMail($a_force_sending_mail);
199 $mail->setRefId($this->ref_id);
200 $mail->setRecipients(array($a_usr_id));
206 $mail->setRefId($this->ref_id);
207 $mail->setRecipients(array($a_usr_id));
213 $mail->setRefId($this->ref_id);
214 $mail->setRecipients(array($a_usr_id));
220 $mail->setRefId($this->ref_id);
221 $mail->setRecipients(array($a_usr_id));
227 $mail->setRefId($this->ref_id);
228 $mail->setRecipients(array($a_usr_id));
234 $mail->setRefId($this->ref_id);
235 $mail->setRecipients(array($a_usr_id));
241 $mail->setRefId($this->ref_id);
242 $mail->setRecipients(array($a_usr_id));
248 $mail->setRefId($this->ref_id);
249 $mail->setRecipients(array($a_usr_id));
255 $mail->setRefId($this->ref_id);
256 $mail->setRecipients(array($a_usr_id));
262 $pos = $wl->getPosition($a_usr_id);
265 $mail->setRefId($this->ref_id);
266 $mail->setRecipients(array($a_usr_id));
267 $mail->setAdditionalInformation(array(
'position' => $pos));
272 $this->sendSubscriptionRequestToAdmins($a_usr_id);
276 $this->sendNotificationToAdmins($a_usr_id);
285 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
286 $mail->setRefId($this->ref_id);
287 $mail->setRecipients($this->getNotificationRecipients());
295 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
296 $mail->setRefId($this->ref_id);
297 $mail->setRecipients($this->getNotificationRecipients());
305 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
306 $mail->setRefId($this->ref_id);
307 $mail->setRecipients($this->getNotificationRecipients());
316 $sql =
"SELECT origin_ts FROM obj_members" .
317 " WHERE usr_id = " .
$ilDB->quote($a_usr_id,
"integer") .
318 " AND obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
319 " AND passed = " .
$ilDB->quote(1,
"integer");
322 if ((
$res[
"origin_ts"] ?? 0) > 0) {
323 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
333 $sql =
"SELECT usr_id,obj_id FROM obj_members" .
334 " WHERE " .
$ilDB->in(
"usr_id", $a_usr_ids,
false,
"integer") .
335 " AND " .
$ilDB->in(
"obj_id", $a_obj_ids,
false,
"integer") .
336 " AND passed = " .
$ilDB->quote(1,
"integer");
337 $set =
$ilDB->query($sql);
339 while ($row =
$ilDB->fetchAssoc($set)) {
340 $row[
'usr_id'] = (
int) $row[
'usr_id'];
341 $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