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 $lrol = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
110 foreach ($lrol as $role) {
112 switch (substr(
$title, 0, 8)) {
127 global $ilAppEventHandler,
$ilLog;
129 parent::addSubscriber($a_usr_id);
131 $ilLog->write(__METHOD__ .
': Raise new event: Modules/Course addSubscriber');
132 $ilAppEventHandler->raise(
137 'usr_id' => $a_usr_id
151 public function updatePassed($a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
153 $this->participants_status[$a_usr_id][
'passed'] = (int) $a_passed;
155 return self::_updatePassed($this->obj_id, $a_usr_id, $a_passed, $a_manual, $a_no_origin);
172 public static function _updatePassed($a_obj_id, $a_usr_id, $a_passed, $a_manual =
false, $a_no_origin =
false)
182 $origin = $ilUser->getId();
185 $query =
"SELECT passed FROM obj_members " .
186 "WHERE obj_id = " . $ilDB->quote($a_obj_id,
'integer') .
" " .
187 "AND usr_id = " . $ilDB->quote($a_usr_id,
'integer');
190 if (
$res->numRows()) {
193 if ((
int)
$old[
"passed"] != (
int) $a_passed) {
194 $update_query =
"UPDATE obj_members SET " .
195 "passed = " . $ilDB->quote((
int) $a_passed,
'integer') .
", " .
196 "origin = " . $ilDB->quote($origin,
'integer') .
", " .
197 "origin_ts = " . $ilDB->quote(
time(),
'integer') .
" " .
198 "WHERE obj_id = " . $ilDB->quote($a_obj_id,
'integer') .
" " .
199 "AND usr_id = " . $ilDB->quote($a_usr_id,
'integer');
204 if ($a_no_origin && !$a_passed) {
211 $update_query =
"INSERT INTO obj_members (passed,obj_id,usr_id,notification,blocked,origin,origin_ts) " .
213 $ilDB->quote((
int) $a_passed,
'integer') .
", " .
214 $ilDB->quote($a_obj_id,
'integer') .
", " .
215 $ilDB->quote($a_usr_id,
'integer') .
", " .
216 $ilDB->quote(0,
'integer') .
", " .
217 $ilDB->quote(0,
'integer') .
", " .
218 $ilDB->quote($origin,
'integer') .
", " .
219 $ilDB->quote($origin_ts,
'integer') .
")";
221 if (strlen($update_query)) {
222 $ilDB->manipulate($update_query);
224 $ilAppEventHandler->raise(
'Modules/Course',
'participantHasPassedCourse',
array(
225 'obj_id' => $a_obj_id,
226 'usr_id' => $a_usr_id,
243 $sql =
"SELECT origin, origin_ts" .
244 " FROM obj_members" .
245 " WHERE obj_id = " . $ilDB->quote($this->obj_id,
"integer") .
246 " AND usr_id = " . $ilDB->quote($a_usr_id,
"integer");
247 $set = $ilDB->query($sql);
248 $row = $ilDB->fetchAssoc($set);
249 if (
$row[
"origin"]) {
250 return array(
"user_id" =>
$row[
"origin"],
258 global $ilObjDataCache,
$ilUser;
260 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
262 $mail->forceSendingMail($a_force_sending_mail);
265 case $this->NOTIFY_DISMISS_SUBSCRIBER:
267 $mail->setRefId($this->ref_id);
268 $mail->setRecipients(
array($a_usr_id));
272 case $this->NOTIFY_ACCEPT_SUBSCRIBER:
274 $mail->setRefId($this->ref_id);
275 $mail->setRecipients(
array($a_usr_id));
279 case $this->NOTIFY_DISMISS_MEMBER:
281 $mail->setRefId($this->ref_id);
282 $mail->setRecipients(
array($a_usr_id));
286 case $this->NOTIFY_BLOCK_MEMBER:
288 $mail->setRefId($this->ref_id);
289 $mail->setRecipients(
array($a_usr_id));
293 case $this->NOTIFY_UNBLOCK_MEMBER:
295 $mail->setRefId($this->ref_id);
296 $mail->setRecipients(
array($a_usr_id));
300 case $this->NOTIFY_ACCEPT_USER:
302 $mail->setRefId($this->ref_id);
303 $mail->setRecipients(
array($a_usr_id));
307 case $this->NOTIFY_STATUS_CHANGED:
309 $mail->setRefId($this->ref_id);
310 $mail->setRecipients(
array($a_usr_id));
314 case $this->NOTIFY_UNSUBSCRIBE:
316 $mail->setRefId($this->ref_id);
317 $mail->setRecipients(
array($a_usr_id));
321 case $this->NOTIFY_REGISTERED:
323 $mail->setRefId($this->ref_id);
324 $mail->setRecipients(
array($a_usr_id));
328 case $this->NOTIFY_WAITING_LIST:
329 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
331 $pos = $wl->getPosition($a_usr_id);
334 $mail->setRefId($this->ref_id);
335 $mail->setRecipients(
array($a_usr_id));
336 $mail->setAdditionalInformation(
array(
'position' => $pos));
340 case $this->NOTIFY_SUBSCRIPTION_REQUEST:
344 case $this->NOTIFY_ADMINS:
354 global
$ilDB,$ilObjDataCache;
356 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
359 $mail->setAdditionalInformation(
array(
'usr_id' => $a_usr_id));
360 $mail->setRefId($this->ref_id);
369 global
$ilDB,$ilObjDataCache;
371 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
374 $mail->setAdditionalInformation(
array(
'usr_id' => $a_usr_id));
375 $mail->setRefId($this->ref_id);
384 global
$ilDB,$ilObjDataCache;
386 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
389 $mail->setAdditionalInformation(
array(
'usr_id' => $a_usr_id));
390 $mail->setRefId($this->ref_id);
401 $body = $this->lng->txt(
'crs_status_changed_body') .
"\n";
402 $body .= $this->lng->txt(
'login') .
': ' . $user_obj->getLogin() .
"\n";
403 $body .= $this->lng->txt(
'role') .
': ';
405 if ($this->
isAdmin($user_obj->getId())) {
406 $body .= $this->lng->txt(
'crs_admin') .
"\n";
408 if ($this->
isTutor($user_obj->getId())) {
409 $body .= $this->lng->txt(
'crs_tutor') .
"\n";
411 if ($this->
isMember($user_obj->getId())) {
412 $body .= $this->lng->txt(
'crs_member') .
"\n";
414 $body .= $this->lng->txt(
'status') .
': ';
417 $body .= $this->lng->txt(
"crs_notify") .
"\n";
419 $body .= $this->lng->txt(
"crs_no_notify") .
"\n";
421 if ($this->
isBlocked($user_obj->getId())) {
422 $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"]) {
443 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
453 $sql =
"SELECT usr_id,obj_id FROM obj_members" .
454 " WHERE " . $ilDB->in(
"usr_id", $a_usr_ids,
"",
"integer") .
455 " AND " . $ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer") .
456 " AND passed = " . $ilDB->quote(1,
"integer");
457 $set = $ilDB->query($sql);
458 while (
$row = $ilDB->fetchAssoc($set)) {
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
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getPassedInfo($a_usr_id)
Get info about passed status.
isBlocked($a_usr_id)
Check if user is blocked.
Create styles array
The data for the language used.
__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.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
const TYPE_UNSUBSCRIBE_MEMBER
const TYPE_SUBSCRIBE_MEMBER
isTutor($a_usr_id)
is user tutor