ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  }
106  }
107 
113  public function add($a_usr_id, $a_role = "")
114  {
115  if (parent::add($a_usr_id, $a_role)) {
116  return true;
117  }
118  return false;
119  }
120 
126  public function register($a_usr_id)
127  {
128  $this->logger->debug('Registering user: ' . $a_usr_id . ' for session: ' . $this->getObjId());
129  $this->add($a_usr_id, IL_SESS_MEMBER);
130  // in any (already participant since status attended) case register user.
131  $this->getEventParticipants()->register($a_usr_id);
132  return true;
133  }
134 
140  public function unregister($a_usr_id)
141  {
142  // participated users are not dropped from role
143  if ($this->getEventParticipants()->hasParticipated($a_usr_id)) {
144  $this->getEventParticipants()->unregister($a_usr_id);
145  return true;
146  } else {
147  $this->delete($a_usr_id);
148  $this->getEventParticipants()->unregister($a_usr_id);
149  return true;
150  }
151  return false;
152  }
153 
154 
160  public function sendNotification($a_type, $a_usr_id, $a_force_email = false)
161  {
163 
164  switch ($a_type) {
167  $mail->setRefId($this->ref_id);
168  $mail->setRecipients([$a_usr_id]);
169  $mail->send();
170  break;
171 
172  default:
173  $this->logger->warning('Invalid notfication type given: ' . $a_type);
174  $this->logger->logStack(ilLogLevel::WARNING);
175  break;
176  }
177  }
178 }
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()
Definition: add.php:2
add($a_usr_id, $a_role="")
Add user to session member role.
static _lookupObjId($a_id)
readParticipantsStatus()
read participant status
Create styles array
The data for the language used.
static getInstance($a_ref_id)
Get instance.
const IL_SESS_MEMBER
unregister($a_usr_id)
Unregister user.