ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSessionParticipants.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('./Services/Membership/classes/class.ilParticipants.php');
5 include_once './Modules/Session/classes/class.ilEventParticipants.php';
6 
16 {
17  const COMPONENT_NAME = 'Modules/Session';
18 
19  protected static $instances = array();
20 
21  protected $event_part = null;
22 
29  public function __construct($a_ref_id)
30  {
31  $this->event_part = new ilEventParticipants(ilObject::_lookupObjId($a_ref_id));
32  parent::__construct(self::COMPONENT_NAME, $a_ref_id);
33  }
34 
35 
41  public static function _getInstanceByObjId($a_obj_id)
42  {
43  $refs = ilObject::_getAllReferences($a_obj_id);
44  return self::getInstance(array_pop($refs));
45  }
46 
47 
48 
54  public static function getInstance($a_ref_id)
55  {
56  if (self::$instances[$a_ref_id] instanceof self) {
57  return self::$instances[$a_ref_id];
58  }
59  return self::$instances[$a_ref_id] = new self($a_ref_id);
60  }
61 
66  public function getEventParticipants()
67  {
68  return $this->event_part;
69  }
70 
76  public function checkLastAdmin($a_usr_ids)
77  {
78  return false;
79  }
80 
89  public static function _isParticipant($a_ref_id, $a_usr_id)
90  {
91  $obj_id = ilObject::_lookupObjId($a_ref_id);
93  }
94 
98  public function readParticipantsStatus()
99  {
100  $this->participants_status = array();
101  foreach ($this->getMembers() as $mem_uid) {
102  $this->participants_status[$mem_uid]['blocked'] = false;
103  $this->participants_status[$mem_uid]['notification'] = false;
104  $this->participants_status[$mem_uid]['passed'] = false;
105  $this->participants_status[$mem_uid]['contact'] = $this->getEventParticipants()->isContact($mem_uid);
106  }
107  }
108 
114  public function add($a_usr_id, $a_role = "")
115  {
116  if (parent::add($a_usr_id, $a_role)) {
117  return true;
118  }
119  return false;
120  }
121 
127  public function register($a_usr_id)
128  {
129  $this->logger->debug('Registering user: ' . $a_usr_id . ' for session: ' . $this->getObjId());
130  $this->add($a_usr_id, IL_SESS_MEMBER);
131  // in any (already participant since status attended) case register user.
132  $this->getEventParticipants()->register($a_usr_id);
133  return true;
134  }
135 
141  public function unregister($a_usr_id)
142  {
143  // participated users are not dropped from role
144  if ($this->getEventParticipants()->hasParticipated($a_usr_id)) {
145  $this->getEventParticipants()->unregister($a_usr_id);
146  return true;
147  } else {
148  $this->delete($a_usr_id);
149  $this->getEventParticipants()->unregister($a_usr_id);
150  return true;
151  }
152  return false;
153  }
154 
155 
161  public function sendNotification($a_type, $a_usr_id, $a_force_email = false)
162  {
164 
165  switch ($a_type) {
168  $mail->setRefId($this->ref_id);
169  $mail->setRecipients([$a_usr_id]);
170  $mail->send();
171  break;
172 
173  default:
174  $this->logger->warning('Invalid notfication type given: ' . $a_type);
175  $this->logger->logStack(ilLogLevel::WARNING);
176  break;
177  }
178  }
179 }
getObjId()
get current obj_id
getEventParticipants()
Get event particpants object.
Session participation handling.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static _getInstanceByObjId($a_obj_id)
Get instance.
static _isRegistered($a_usr_id, $a_event_id)
static _getAllReferences($a_id)
get all reference ids of object
__construct($a_ref_id)
Constructor.
checkLastAdmin($a_usr_ids)
no last admin restrictions for sessions
$a_type
Definition: workflow.php:92
sendNotification($a_type, $a_usr_id, $a_force_email=false)
getMembers()
Get all members ids (admins and tutors are not members) Use get participants to fetch all...
add($a_usr_id, $a_role="")
Add user to session member role.
static _lookupObjId($a_id)
readParticipantsStatus()
read participant status
add()
Definition: add.php:2
static getInstance($a_ref_id)
Get instance.
const IL_SESS_MEMBER
unregister($a_usr_id)
Unregister user.