24 include_once(
'./Services/Membership/classes/class.ilParticipants.php');
50 $this->NOTIFY_DISMISS_SUBSCRIBER = 1;
51 $this->NOTIFY_ACCEPT_SUBSCRIBER = 2;
52 $this->NOTIFY_DISMISS_MEMBER = 3;
53 $this->NOTIFY_BLOCK_MEMBER = 4;
54 $this->NOTIFY_UNBLOCK_MEMBER = 5;
55 $this->NOTIFY_ACCEPT_USER = 6;
56 $this->NOTIFY_ADMINS = 7;
57 $this->NOTIFY_STATUS_CHANGED = 8;
58 $this->NOTIFY_SUBSCRIPTION_REQUEST = 9;
60 $this->NOTIFY_REGISTERED = 10;
61 $this->NOTIFY_UNSUBSCRIBE = 11;
62 $this->NOTIFY_WAITING_LIST = 12;
66 parent::__construct(self::COMPONENT_NAME, array_pop($refs));
79 if (isset(self::$instances[$a_obj_id])
and self::$instances[$a_obj_id]) {
80 return self::$instances[$a_obj_id];
90 public function add($a_usr_id, $a_role)
107 $rbacreview = $DIC[
'rbacreview'];
109 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
112 foreach ($lrol as $role) {
114 switch (substr(
$title, 0, 8)) {
131 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
134 parent::addSubscriber($a_usr_id);
136 $ilLog->write(__METHOD__ .
': Raise new event: Modules/Course addSubscriber');
137 $ilAppEventHandler->raise(
142 'usr_id' => $a_usr_id
156 public function updatePassed($a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
158 $this->participants_status[$a_usr_id][
'passed'] = (int) $a_passed;
160 return self::_updatePassed($this->obj_id, $a_usr_id, $a_passed, $a_manual, $a_no_origin);
177 public static function _updatePassed($a_obj_id, $a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
181 $ilDB = $DIC[
'ilDB'];
183 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
194 $query =
"SELECT passed FROM obj_members " .
195 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
196 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
199 if (
$res->numRows()) {
202 if ((
int) $old[
"passed"] != (
int) $a_passed) {
203 $update_query =
"UPDATE obj_members SET " .
204 "passed = " .
$ilDB->quote((
int) $a_passed,
'integer') .
", " .
205 "origin = " .
$ilDB->quote($origin,
'integer') .
", " .
206 "origin_ts = " .
$ilDB->quote(time(),
'integer') .
" " .
207 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" " .
208 "AND usr_id = " .
$ilDB->quote($a_usr_id,
'integer');
213 if ($a_no_origin && !$a_passed) {
220 $update_query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) " .
222 $ilDB->quote((
int) $a_passed,
'integer') .
", " .
223 $ilDB->quote($a_obj_id,
'integer') .
", " .
224 $ilDB->quote($a_usr_id,
'integer') .
", " .
225 $ilDB->quote(0,
'integer') .
", " .
226 $ilDB->quote(0,
'integer') .
", " .
227 $ilDB->quote($origin,
'integer') .
", " .
228 $ilDB->quote($origin_ts,
'integer') .
")";
230 if (strlen($update_query)) {
231 $ilDB->manipulate($update_query);
233 $ilAppEventHandler->raise(
'Modules/Course',
'participantHasPassedCourse', array(
234 'obj_id' => $a_obj_id,
235 'usr_id' => $a_usr_id,
252 $ilDB = $DIC[
'ilDB'];
254 $sql =
"SELECT origin, origin_ts" .
255 " FROM obj_members" .
256 " WHERE obj_id = " .
$ilDB->quote($this->obj_id,
"integer") .
257 " AND usr_id = " .
$ilDB->quote($a_usr_id,
"integer");
258 $set =
$ilDB->query($sql);
260 if (
$row[
"origin"]) {
261 return array(
"user_id" =>
$row[
"origin"],
271 $ilObjDataCache = $DIC[
'ilObjDataCache'];
274 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
276 $mail->forceSendingMail($a_force_sending_mail);
279 case $this->NOTIFY_DISMISS_SUBSCRIBER:
281 $mail->setRefId($this->ref_id);
282 $mail->setRecipients(array($a_usr_id));
286 case $this->NOTIFY_ACCEPT_SUBSCRIBER:
288 $mail->setRefId($this->ref_id);
289 $mail->setRecipients(array($a_usr_id));
293 case $this->NOTIFY_DISMISS_MEMBER:
295 $mail->setRefId($this->ref_id);
296 $mail->setRecipients(array($a_usr_id));
300 case $this->NOTIFY_BLOCK_MEMBER:
302 $mail->setRefId($this->ref_id);
303 $mail->setRecipients(array($a_usr_id));
307 case $this->NOTIFY_UNBLOCK_MEMBER:
309 $mail->setRefId($this->ref_id);
310 $mail->setRecipients(array($a_usr_id));
314 case $this->NOTIFY_ACCEPT_USER:
316 $mail->setRefId($this->ref_id);
317 $mail->setRecipients(array($a_usr_id));
321 case $this->NOTIFY_STATUS_CHANGED:
323 $mail->setRefId($this->ref_id);
324 $mail->setRecipients(array($a_usr_id));
328 case $this->NOTIFY_UNSUBSCRIBE:
330 $mail->setRefId($this->ref_id);
331 $mail->setRecipients(array($a_usr_id));
335 case $this->NOTIFY_REGISTERED:
337 $mail->setRefId($this->ref_id);
338 $mail->setRecipients(array($a_usr_id));
342 case $this->NOTIFY_WAITING_LIST:
343 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
345 $pos = $wl->getPosition($a_usr_id);
348 $mail->setRefId($this->ref_id);
349 $mail->setRecipients(array($a_usr_id));
350 $mail->setAdditionalInformation(array(
'position' => $pos));
354 case $this->NOTIFY_SUBSCRIPTION_REQUEST:
358 case $this->NOTIFY_ADMINS:
370 $ilDB = $DIC[
'ilDB'];
371 $ilObjDataCache = $DIC[
'ilObjDataCache'];
373 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
376 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
377 $mail->setRefId($this->ref_id);
388 $ilDB = $DIC[
'ilDB'];
389 $ilObjDataCache = $DIC[
'ilObjDataCache'];
391 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
394 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
395 $mail->setRefId($this->ref_id);
406 $ilDB = $DIC[
'ilDB'];
407 $ilObjDataCache = $DIC[
'ilObjDataCache'];
409 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
412 $mail->setAdditionalInformation(array(
'usr_id' => $a_usr_id));
413 $mail->setRefId($this->ref_id);
424 $ilDB = $DIC[
'ilDB'];
426 $body = $this->lng->txt(
'crs_status_changed_body') .
"\n";
427 $body .= $this->lng->txt(
'login') .
': ' . $user_obj->getLogin() .
"\n";
428 $body .= $this->lng->txt(
'role') .
': ';
430 if ($this->
isAdmin($user_obj->getId())) {
431 $body .= $this->lng->txt(
'crs_admin') .
"\n";
433 if ($this->
isTutor($user_obj->getId())) {
434 $body .= $this->lng->txt(
'crs_tutor') .
"\n";
436 if ($this->
isMember($user_obj->getId())) {
437 $body .= $this->lng->txt(
'crs_member') .
"\n";
439 $body .= $this->lng->txt(
'status') .
': ';
442 $body .= $this->lng->txt(
"crs_notify") .
"\n";
444 $body .= $this->lng->txt(
"crs_no_notify") .
"\n";
446 if ($this->
isBlocked($user_obj->getId())) {
447 $body .= $this->lng->txt(
"crs_blocked") .
"\n";
449 $body .= $this->lng->txt(
"crs_unblocked") .
"\n";
451 $passed = $this->
hasPassed($user_obj->getId()) ? $this->lng->txt(
'yes') : $this->lng->txt(
'no');
452 $body .= $this->lng->txt(
'crs_passed') .
': ' . $passed .
"\n";
461 $ilDB = $DIC[
'ilDB'];
463 $sql =
"SELECT origin_ts FROM obj_members" .
464 " WHERE usr_id = " .
$ilDB->quote($a_usr_id,
"integer") .
465 " AND obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
466 " AND passed = " .
$ilDB->quote(1,
"integer");
469 if (
$res[
"origin_ts"]) {
470 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
478 $ilDB = $DIC[
'ilDB'];
482 $sql =
"SELECT usr_id,obj_id FROM obj_members" .
483 " WHERE " .
$ilDB->in(
"usr_id", $a_usr_ids,
"",
"integer") .
484 " AND " .
$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer") .
485 " AND passed = " .
$ilDB->quote(1,
"integer");
486 $set =
$ilDB->query($sql);
getObjId()
get current obj_id
addDesktopItem($a_usr_id)
Add desktop item.
const TYPE_NOTIFICATION_UNSUBSCRIBE
const TYPE_ADMISSION_MEMBER
const TYPE_STATUS_CHANGED
sendUnsubscribeNotificationToAdmins($a_usr_id)
const TYPE_BLOCKED_MEMBER
const TYPE_ACCEPTED_SUBSCRIPTION_MEMBER
const TYPE_WAITING_LIST_MEMBER
static getDateTimeOfPassed($a_obj_id, $a_usr_id)
const TYPE_DISMISS_MEMBER
const TYPE_REFUSED_SUBSCRIPTION_MEMBER
isAdmin($a_usr_id)
is user admin
const TYPE_NOTIFICATION_REGISTRATION_REQUEST
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
isNotificationEnabled($a_usr_id)
check if notification is enabled
__construct($a_obj_id)
Singleton constructor.
static _lookupTitle($a_id)
lookup object title
isMember($a_usr_id)
is user member
const TYPE_UNBLOCKED_MEMBER
static getMemberRoles($a_ref_id)
Get member roles.
static getPassedUsersForObjects(array $a_obj_ids, array $a_usr_ids)
sendSubscriptionRequestToAdmins($a_usr_id)
static _getAllReferences($a_id)
get all reference ids of object
sendNotificationToAdmins($a_usr_id)
sendNotification($a_type, $a_usr_id, $a_force_sending_mail=false)
foreach($_POST as $key=> $value) $res
getPassedInfo($a_usr_id)
Get info about passed status.
isBlocked($a_usr_id)
Check if user is blocked.
__buildStatusBody(&$user_obj)
hasPassed($a_usr_id)
Check if user has passed course.
const TYPE_NOTIFICATION_REGISTRATION
add($a_usr_id, $a_role)
Add user to role.
updatePassed($a_usr_id, $a_passed, $a_manual=false, $a_no_origin=false)
Update passed status.
getNotificationRecipients()
Get admin, tutor which have notification enabled.
const TYPE_UNSUBSCRIBE_MEMBER
const TYPE_SUBSCRIBE_MEMBER
isTutor($a_usr_id)
is user tutor