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)
98 switch(substr($title,0,8))
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)
159 $query =
"UPDATE obj_members SET ".
160 "passed = ".$ilDB->quote((
int) $a_passed,
'integer').
", ".
161 "origin = ".$ilDB->quote($origin,
'integer').
", ".
162 "origin_ts = ".$ilDB->quote(time(),
'integer').
" ".
163 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
164 "AND usr_id = ".$ilDB->quote($a_usr_id,
'integer');
171 if($a_no_origin && !$a_passed)
181 $query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) ".
183 $ilDB->quote((
int) $a_passed,
'integer').
", ".
184 $ilDB->quote($a_obj_id,
'integer').
", ".
185 $ilDB->quote($a_usr_id,
'integer').
", ".
186 $ilDB->quote(0,
'integer').
", ".
187 $ilDB->quote(0,
'integer').
", ".
188 $ilDB->quote($origin,
'integer').
", ".
189 $ilDB->quote($origin_ts,
'integer').
")";
205 $sql =
"SELECT origin, origin_ts".
207 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
208 " AND usr_id = ".$ilDB->quote($a_usr_id,
"integer");
209 $set = $ilDB->query($sql);
210 $row = $ilDB->fetchAssoc($set);
213 return array(
"user_id" =>
$row[
"origin"],
221 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
223 global $ilObjDataCache,
$ilUser;
227 case $this->NOTIFY_DISMISS_SUBSCRIBER:
230 $mail->setRefId($this->ref_id);
231 $mail->setRecipients(array($a_usr_id));
235 case $this->NOTIFY_ACCEPT_SUBSCRIBER:
238 $mail->setRefId($this->ref_id);
239 $mail->setRecipients(array($a_usr_id));
243 case $this->NOTIFY_DISMISS_MEMBER:
246 $mail->setRefId($this->ref_id);
247 $mail->setRecipients(array($a_usr_id));
251 case $this->NOTIFY_BLOCK_MEMBER:
254 $mail->setRefId($this->ref_id);
255 $mail->setRecipients(array($a_usr_id));
259 case $this->NOTIFY_UNBLOCK_MEMBER:
262 $mail->setRefId($this->ref_id);
263 $mail->setRecipients(array($a_usr_id));
267 case $this->NOTIFY_ACCEPT_USER:
270 $mail->setRefId($this->ref_id);
271 $mail->setRecipients(array($a_usr_id));
275 case $this->NOTIFY_STATUS_CHANGED:
278 $mail->setRefId($this->ref_id);
279 $mail->setRecipients(array($a_usr_id));
283 case $this->NOTIFY_UNSUBSCRIBE:
286 $mail->setRefId($this->ref_id);
287 $mail->setRecipients(array($a_usr_id));
291 case $this->NOTIFY_REGISTERED:
294 $mail->setRefId($this->ref_id);
295 $mail->setRecipients(array($a_usr_id));
299 case $this->NOTIFY_WAITING_LIST:
300 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
302 $pos = $wl->getPosition($a_usr_id);
306 $mail->setRefId($this->ref_id);
307 $mail->setRecipients(array($a_usr_id));
308 $mail->setAdditionalInformation(array(
'position' => $pos));
312 case $this->NOTIFY_SUBSCRIPTION_REQUEST:
316 case $this->NOTIFY_ADMINS:
326 global
$ilDB,$ilObjDataCache;
328 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
331 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
332 $mail->setRefId($this->ref_id);
341 global
$ilDB,$ilObjDataCache;
343 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
346 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
347 $mail->setRefId($this->ref_id);
356 global
$ilDB,$ilObjDataCache;
358 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
361 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
362 $mail->setRefId($this->ref_id);
373 $body = $this->lng->txt(
'crs_status_changed_body').
"\n";
374 $body .= $this->lng->txt(
'login').
': '.$user_obj->getLogin().
"\n";
375 $body .= $this->lng->txt(
'role').
': ';
377 if($this->
isAdmin($user_obj->getId()))
379 $body .= $this->lng->txt(
'crs_admin').
"\n";
381 if($this->
isTutor($user_obj->getId()))
383 $body .= $this->lng->txt(
'crs_tutor').
"\n";
385 if($this->
isMember($user_obj->getId()))
387 $body .= $this->lng->txt(
'crs_member').
"\n";
389 $body .= $this->lng->txt(
'status').
': ';
393 $body .= $this->lng->txt(
"crs_notify").
"\n";
397 $body .= $this->lng->txt(
"crs_no_notify").
"\n";
401 $body .= $this->lng->txt(
"crs_blocked").
"\n";
405 $body .= $this->lng->txt(
"crs_unblocked").
"\n";
407 $passed = $this->
hasPassed($user_obj->getId()) ? $this->lng->txt(
'yes') : $this->lng->txt(
'no');
408 $body .= $this->lng->txt(
'crs_passed').
': '.$passed.
"\n";
417 $sql =
"SELECT origin_ts FROM obj_members".
418 " WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
419 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
420 " AND passed = ".$ilDB->quote(1,
"integer");
421 $res = $ilDB->query($sql);
423 if(
$res[
"origin_ts"])
425 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
435 $sql =
"SELECT usr_id,obj_id FROM obj_members".
436 " WHERE ".$ilDB->in(
"usr_id", $a_usr_ids,
"",
"integer").
437 " AND ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
438 " AND passed = ".$ilDB->quote(1,
"integer");
439 $set = $ilDB->query($sql);
440 while(
$row = $ilDB->fetchAssoc($set))