24 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
52 $this->NOTIFY_DISMISS_SUBSCRIBER = 1;
53 $this->NOTIFY_ACCEPT_SUBSCRIBER = 2;
54 $this->NOTIFY_DISMISS_MEMBER = 3;
55 $this->NOTIFY_BLOCK_MEMBER = 4;
56 $this->NOTIFY_UNBLOCK_MEMBER = 5;
57 $this->NOTIFY_ACCEPT_USER = 6;
58 $this->NOTIFY_ADMINS = 7;
59 $this->NOTIFY_STATUS_CHANGED = 8;
60 $this->NOTIFY_SUBSCRIPTION_REQUEST = 9;
62 $this->NOTIFY_REGISTERED = 10;
63 $this->NOTIFY_UNSUBSCRIBE = 11;
64 $this->NOTIFY_WAITING_LIST = 12;
79 if(isset(self::$instances[$a_obj_id]) and self::$instances[$a_obj_id])
81 return self::$instances[$a_obj_id];
94 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
97 foreach($lrol as $role)
100 switch(substr($title,0,8))
116 global $ilAppEventHandler,
$ilLog;
120 $ilLog->write(__METHOD__.
': Raise new event: Modules/Course addSubscriber');
121 $ilAppEventHandler->raise(
126 'usr_id' => $a_usr_id
140 public function updatePassed($a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
142 $this->participants_status[$a_usr_id][
'passed'] = (int) $a_passed;
157 public static function _updatePassed($a_obj_id, $a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
165 $origin = $ilUser->getId();
168 $query =
"SELECT passed FROM obj_members ".
169 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
170 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer');
175 $old = $ilDB->fetchAssoc(
$res);
176 if((
int)$old[
"passed"] != (
int)$a_passed)
178 $query =
"UPDATE obj_members SET ".
179 "passed = ".$ilDB->quote((
int) $a_passed,
'integer').
", ".
180 "origin = ".$ilDB->quote($origin,
'integer').
", ".
181 "origin_ts = ".$ilDB->quote(time(),
'integer').
" ".
182 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
183 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer');
190 if($a_no_origin && !$a_passed)
200 $query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) ".
202 $ilDB->quote((
int) $a_passed,
'integer').
", ".
203 $ilDB->quote($a_obj_id,
'integer').
", ".
204 $ilDB->quote($a_usr_id,
'integer').
", ".
205 $ilDB->quote(0,
'integer').
", ".
206 $ilDB->quote(0,
'integer').
", ".
207 $ilDB->quote($origin,
'integer').
", ".
208 $ilDB->quote($origin_ts,
'integer').
")";
224 $sql =
"SELECT origin, origin_ts".
226 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
227 " AND usr_id = ".$ilDB->quote($a_usr_id,
"integer");
228 $set = $ilDB->query($sql);
229 $row = $ilDB->fetchAssoc($set);
232 return array(
"user_id" =>
$row[
"origin"],
240 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
242 global $ilObjDataCache,
$ilUser;
246 case $this->NOTIFY_DISMISS_SUBSCRIBER:
249 $mail->setRefId($this->ref_id);
250 $mail->setRecipients(array($a_usr_id));
254 case $this->NOTIFY_ACCEPT_SUBSCRIBER:
257 $mail->setRefId($this->ref_id);
258 $mail->setRecipients(array($a_usr_id));
262 case $this->NOTIFY_DISMISS_MEMBER:
265 $mail->setRefId($this->ref_id);
266 $mail->setRecipients(array($a_usr_id));
270 case $this->NOTIFY_BLOCK_MEMBER:
273 $mail->setRefId($this->ref_id);
274 $mail->setRecipients(array($a_usr_id));
278 case $this->NOTIFY_UNBLOCK_MEMBER:
281 $mail->setRefId($this->ref_id);
282 $mail->setRecipients(array($a_usr_id));
286 case $this->NOTIFY_ACCEPT_USER:
289 $mail->setRefId($this->ref_id);
290 $mail->setRecipients(array($a_usr_id));
294 case $this->NOTIFY_STATUS_CHANGED:
297 $mail->setRefId($this->ref_id);
298 $mail->setRecipients(array($a_usr_id));
302 case $this->NOTIFY_UNSUBSCRIBE:
305 $mail->setRefId($this->ref_id);
306 $mail->setRecipients(array($a_usr_id));
310 case $this->NOTIFY_REGISTERED:
313 $mail->setRefId($this->ref_id);
314 $mail->setRecipients(array($a_usr_id));
318 case $this->NOTIFY_WAITING_LIST:
319 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
321 $pos = $wl->getPosition($a_usr_id);
325 $mail->setRefId($this->ref_id);
326 $mail->setRecipients(array($a_usr_id));
327 $mail->setAdditionalInformation(array(
'position' => $pos));
331 case $this->NOTIFY_SUBSCRIPTION_REQUEST:
335 case $this->NOTIFY_ADMINS:
345 global
$ilDB,$ilObjDataCache;
347 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
350 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
351 $mail->setRefId($this->ref_id);
360 global
$ilDB,$ilObjDataCache;
362 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
365 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
366 $mail->setRefId($this->ref_id);
375 global
$ilDB,$ilObjDataCache;
377 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
380 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
381 $mail->setRefId($this->ref_id);
392 $body = $this->lng->txt(
'crs_status_changed_body').
"\n";
393 $body .= $this->lng->txt(
'login').
': '.$user_obj->getLogin().
"\n";
394 $body .= $this->lng->txt(
'role').
': ';
396 if($this->
isAdmin($user_obj->getId()))
398 $body .= $this->lng->txt(
'crs_admin').
"\n";
400 if($this->
isTutor($user_obj->getId()))
402 $body .= $this->lng->txt(
'crs_tutor').
"\n";
404 if($this->
isMember($user_obj->getId()))
406 $body .= $this->lng->txt(
'crs_member').
"\n";
408 $body .= $this->lng->txt(
'status').
': ';
412 $body .= $this->lng->txt(
"crs_notify").
"\n";
416 $body .= $this->lng->txt(
"crs_no_notify").
"\n";
420 $body .= $this->lng->txt(
"crs_blocked").
"\n";
424 $body .= $this->lng->txt(
"crs_unblocked").
"\n";
426 $passed = $this->
hasPassed($user_obj->getId()) ? $this->lng->txt(
'yes') : $this->lng->txt(
'no');
427 $body .= $this->lng->txt(
'crs_passed').
': '.$passed.
"\n";
436 $sql =
"SELECT origin_ts FROM obj_members".
437 " WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
438 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
439 " AND passed = ".$ilDB->quote(1,
"integer");
440 $res = $ilDB->query($sql);
442 if(
$res[
"origin_ts"])
444 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
454 $sql =
"SELECT usr_id,obj_id FROM obj_members".
455 " WHERE ".$ilDB->in(
"usr_id", $a_usr_ids,
"",
"integer").
456 " AND ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
457 " AND passed = ".$ilDB->quote(1,
"integer");
458 $set = $ilDB->query($sql);
459 while(
$row = $ilDB->fetchAssoc($set))