24 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
49 $this->NOTIFY_DISMISS_SUBSCRIBER = 1;
50 $this->NOTIFY_ACCEPT_SUBSCRIBER = 2;
51 $this->NOTIFY_DISMISS_MEMBER = 3;
52 $this->NOTIFY_BLOCK_MEMBER = 4;
53 $this->NOTIFY_UNBLOCK_MEMBER = 5;
54 $this->NOTIFY_ACCEPT_USER = 6;
55 $this->NOTIFY_ADMINS = 7;
56 $this->NOTIFY_STATUS_CHANGED = 8;
57 $this->NOTIFY_SUBSCRIPTION_REQUEST = 9;
59 $this->NOTIFY_REGISTERED = 10;
60 $this->NOTIFY_UNSUBSCRIBE = 11;
61 $this->NOTIFY_WAITING_LIST = 12;
76 if(isset(self::$instances[$a_obj_id]) and self::$instances[$a_obj_id])
78 return self::$instances[$a_obj_id];
91 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
92 $lrol = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
95 foreach($lrol as $role)
121 public function updatePassed($a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
123 $this->participants_status[$a_usr_id][
'passed'] = (int) $a_passed;
138 public static function _updatePassed($a_obj_id, $a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
146 $origin = $ilUser->getId();
149 $query =
"SELECT passed FROM obj_members ".
150 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
151 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer');
156 $old = $ilDB->fetchAssoc(
$res);
157 if((
int)$old[
"passed"] != (
int)$a_passed)
160 $query =
"UPDATE obj_members SET ".
161 "passed = ".$ilDB->quote((
int) $a_passed,
'integer').
", ".
162 "origin = ".$ilDB->quote($origin,
'integer').
", ".
163 "origin_ts = ".$ilDB->quote(time(),
'integer').
" ".
164 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
165 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer');
172 if($a_no_origin && !$a_passed)
182 $query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) ".
184 $ilDB->quote((
int) $a_passed,
'integer').
", ".
185 $ilDB->quote($a_obj_id,
'integer').
", ".
186 $ilDB->quote($a_usr_id,
'integer').
", ".
187 $ilDB->quote(0,
'integer').
", ".
188 $ilDB->quote(0,
'integer').
", ".
189 $ilDB->quote($origin,
'integer').
", ".
190 $ilDB->quote($origin_ts,
'integer').
")";
206 $sql =
"SELECT origin, origin_ts".
208 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
209 " AND usr_id = ".$ilDB->quote($a_usr_id,
"integer");
210 $set = $ilDB->query($sql);
211 $row = $ilDB->fetchAssoc($set);
214 return array(
"user_id" =>
$row[
"origin"],
222 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
224 global $ilObjDataCache,
$ilUser;
228 case $this->NOTIFY_DISMISS_SUBSCRIBER:
231 $mail->setRefId($this->ref_id);
232 $mail->setRecipients(array($a_usr_id));
236 case $this->NOTIFY_ACCEPT_SUBSCRIBER:
239 $mail->setRefId($this->ref_id);
240 $mail->setRecipients(array($a_usr_id));
244 case $this->NOTIFY_DISMISS_MEMBER:
247 $mail->setRefId($this->ref_id);
248 $mail->setRecipients(array($a_usr_id));
252 case $this->NOTIFY_BLOCK_MEMBER:
255 $mail->setRefId($this->ref_id);
256 $mail->setRecipients(array($a_usr_id));
260 case $this->NOTIFY_UNBLOCK_MEMBER:
263 $mail->setRefId($this->ref_id);
264 $mail->setRecipients(array($a_usr_id));
268 case $this->NOTIFY_ACCEPT_USER:
271 $mail->setRefId($this->ref_id);
272 $mail->setRecipients(array($a_usr_id));
276 case $this->NOTIFY_STATUS_CHANGED:
279 $mail->setRefId($this->ref_id);
280 $mail->setRecipients(array($a_usr_id));
284 case $this->NOTIFY_UNSUBSCRIBE:
287 $mail->setRefId($this->ref_id);
288 $mail->setRecipients(array($a_usr_id));
292 case $this->NOTIFY_REGISTERED:
295 $mail->setRefId($this->ref_id);
296 $mail->setRecipients(array($a_usr_id));
300 case $this->NOTIFY_WAITING_LIST:
301 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
303 $pos = $wl->getPosition($a_usr_id);
307 $mail->setRefId($this->ref_id);
308 $mail->setRecipients(array($a_usr_id));
309 $mail->setAdditionalInformation(array(
'position' => $pos));
313 case $this->NOTIFY_SUBSCRIPTION_REQUEST:
317 case $this->NOTIFY_ADMINS:
327 global
$ilDB,$ilObjDataCache;
329 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
332 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
333 $mail->setRefId($this->ref_id);
342 global
$ilDB,$ilObjDataCache;
344 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
347 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
348 $mail->setRefId($this->ref_id);
357 global
$ilDB,$ilObjDataCache;
359 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
362 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
363 $mail->setRefId($this->ref_id);
374 $body = $this->lng->txt(
'crs_status_changed_body').
"\n";
375 $body .= $this->lng->txt(
'login').
': '.$user_obj->getLogin().
"\n";
376 $body .= $this->lng->txt(
'role').
': ';
378 if($this->
isAdmin($user_obj->getId()))
380 $body .= $this->lng->txt(
'crs_admin').
"\n";
382 if($this->
isTutor($user_obj->getId()))
384 $body .= $this->lng->txt(
'crs_tutor').
"\n";
386 if($this->
isMember($user_obj->getId()))
388 $body .= $this->lng->txt(
'crs_member').
"\n";
390 $body .= $this->lng->txt(
'status').
': ';
394 $body .= $this->lng->txt(
"crs_notify").
"\n";
398 $body .= $this->lng->txt(
"crs_no_notify").
"\n";
402 $body .= $this->lng->txt(
"crs_blocked").
"\n";
406 $body .= $this->lng->txt(
"crs_unblocked").
"\n";
408 $passed = $this->
hasPassed($user_obj->getId()) ? $this->lng->txt(
'yes') : $this->lng->txt(
'no');
409 $body .= $this->lng->txt(
'crs_passed').
': '.$passed.
"\n";
418 $sql =
"SELECT origin_ts FROM obj_members".
419 " WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
420 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
421 " AND passed = ".$ilDB->quote(1,
"integer");
422 $res = $ilDB->query($sql);
424 if(
$res[
"origin_ts"])
426 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
436 $sql =
"SELECT usr_id,obj_id FROM obj_members".
437 " WHERE ".$ilDB->in(
"usr_id", $a_usr_ids,
"",
"integer").
438 " AND ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
439 " AND passed = ".$ilDB->quote(1,
"integer");
440 $set = $ilDB->query($sql);
441 while(
$row = $ilDB->fetchAssoc($set))