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;
66 parent::__construct(self::COMPONENT_NAME,$a_obj_id);
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;
118 parent::addSubscriber($a_usr_id);
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;
144 return self::_updatePassed($this->obj_id, $a_usr_id, $a_passed, $a_manual, $a_no_origin);
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');
176 if((
int)
$old[
"passed"] != (
int)$a_passed)
178 $update_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 $update_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').
")";
210 if(strlen($update_query))
212 $ilDB->manipulate($update_query);
227 $sql =
"SELECT origin, origin_ts".
229 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer").
230 " AND usr_id = ".$ilDB->quote($a_usr_id,
"integer");
231 $set = $ilDB->query($sql);
232 $row = $ilDB->fetchAssoc($set);
235 return array(
"user_id" =>
$row[
"origin"],
244 global $ilObjDataCache,
$ilUser;
246 include_once
'./Modules/Course/classes/class.ilCourseMembershipMailNotification.php';
248 $mail->forceSendingMail($a_force_sending_mail);
252 case $this->NOTIFY_DISMISS_SUBSCRIBER:
254 $mail->setRefId($this->ref_id);
255 $mail->setRecipients(
array($a_usr_id));
259 case $this->NOTIFY_ACCEPT_SUBSCRIBER:
261 $mail->setRefId($this->ref_id);
262 $mail->setRecipients(
array($a_usr_id));
266 case $this->NOTIFY_DISMISS_MEMBER:
268 $mail->setRefId($this->ref_id);
269 $mail->setRecipients(
array($a_usr_id));
273 case $this->NOTIFY_BLOCK_MEMBER:
275 $mail->setRefId($this->ref_id);
276 $mail->setRecipients(
array($a_usr_id));
280 case $this->NOTIFY_UNBLOCK_MEMBER:
282 $mail->setRefId($this->ref_id);
283 $mail->setRecipients(
array($a_usr_id));
287 case $this->NOTIFY_ACCEPT_USER:
289 $mail->setRefId($this->ref_id);
290 $mail->setRecipients(
array($a_usr_id));
294 case $this->NOTIFY_STATUS_CHANGED:
296 $mail->setRefId($this->ref_id);
297 $mail->setRecipients(
array($a_usr_id));
301 case $this->NOTIFY_UNSUBSCRIBE:
303 $mail->setRefId($this->ref_id);
304 $mail->setRecipients(
array($a_usr_id));
308 case $this->NOTIFY_REGISTERED:
310 $mail->setRefId($this->ref_id);
311 $mail->setRecipients(
array($a_usr_id));
315 case $this->NOTIFY_WAITING_LIST:
316 include_once(
'./Modules/Course/classes/class.ilCourseWaitingList.php');
318 $pos = $wl->getPosition($a_usr_id);
321 $mail->setRefId($this->ref_id);
322 $mail->setRecipients(
array($a_usr_id));
323 $mail->setAdditionalInformation(
array(
'position' => $pos));
327 case $this->NOTIFY_SUBSCRIPTION_REQUEST:
331 case $this->NOTIFY_ADMINS:
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);
371 global
$ilDB,$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 $body = $this->lng->txt(
'crs_status_changed_body').
"\n";
389 $body .= $this->lng->txt(
'login').
': '.$user_obj->getLogin().
"\n";
390 $body .= $this->lng->txt(
'role').
': ';
392 if($this->
isAdmin($user_obj->getId()))
394 $body .= $this->lng->txt(
'crs_admin').
"\n";
396 if($this->
isTutor($user_obj->getId()))
398 $body .= $this->lng->txt(
'crs_tutor').
"\n";
400 if($this->
isMember($user_obj->getId()))
402 $body .= $this->lng->txt(
'crs_member').
"\n";
404 $body .= $this->lng->txt(
'status').
': ';
408 $body .= $this->lng->txt(
"crs_notify").
"\n";
412 $body .= $this->lng->txt(
"crs_no_notify").
"\n";
416 $body .= $this->lng->txt(
"crs_blocked").
"\n";
420 $body .= $this->lng->txt(
"crs_unblocked").
"\n";
422 $passed = $this->
hasPassed($user_obj->getId()) ? $this->lng->txt(
'yes') : $this->lng->txt(
'no');
423 $body .= $this->lng->txt(
'crs_passed').
': '.$passed.
"\n";
432 $sql =
"SELECT origin_ts FROM obj_members".
433 " WHERE usr_id = ".$ilDB->quote($a_usr_id,
"integer").
434 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
435 " AND passed = ".$ilDB->quote(1,
"integer");
436 $res = $ilDB->query($sql);
438 if(
$res[
"origin_ts"])
440 return date(
"Y-m-d H:i:s",
$res[
"origin_ts"]);
450 $sql =
"SELECT usr_id,obj_id FROM obj_members".
451 " WHERE ".$ilDB->in(
"usr_id", $a_usr_ids,
"",
"integer").
452 " AND ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
453 " AND passed = ".$ilDB->quote(1,
"integer");
454 $set = $ilDB->query($sql);
455 while(
$row = $ilDB->fetchAssoc($set))
getObjId()
get current obj_id
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)
sendNotificationToAdmins($a_usr_id)
sendNotification($a_type, $a_usr_id, $a_force_sending_mail=false)
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
static _updatePassed($a_obj_id, $a_usr_id, $a_passed, $a_manual=false, $a_no_origin=false)
Update passed status (static)
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