ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilWaitingList Class Reference

Base class for course and group waiting lists. More...

+ Inheritance diagram for ilWaitingList:
+ Collaboration diagram for ilWaitingList:

Public Member Functions

 __construct ($a_obj_id)
 Constructor. More...
 
 getObjId ()
 get obj id More...
 
 addToList ($a_usr_id)
 add to list More...
 
 updateSubscriptionTime ($a_usr_id, $a_subtime)
 update subscription time More...
 
 removeFromList ($a_usr_id)
 remove usr from list More...
 
 isOnList ($a_usr_id)
 check if is on waiting list More...
 
 getCountUsers ()
 get number of users More...
 
 getPosition ($a_usr_id)
 get position More...
 
 getAllUsers ()
 get all users on waiting list More...
 
 getUser ($a_usr_id)
 get user More...
 
 getUserIds ()
 Get all user ids of users on waiting list. More...
 

Static Public Member Functions

static lookupListSize ($a_obj_id)
 Lookup waiting lit size. More...
 
static _deleteAll ($a_obj_id)
 delete all More...
 
static _deleteUser ($a_usr_id)
 Delete user. More...
 
static deleteUserEntry ($a_usr_id, $a_obj_id)
 Delete one user entry. More...
 
static _isOnList ($a_usr_id, $a_obj_id)
 Check if a user on the waiting list. More...
 
static _preloadOnListInfo ($a_usr_ids, $a_obj_ids)
 Preload on list info. More...
 

Static Public Attributes

static $is_on_list = array()
 

Private Member Functions

 read ()
 Read waiting list. More...
 

Private Attributes

 $db = null
 
 $obj_id = 0
 
 $user_ids = array()
 
 $users = array()
 

Detailed Description

Base class for course and group waiting lists.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 33 of file class.ilWaitingList.php.

Constructor & Destructor Documentation

◆ __construct()

ilWaitingList::__construct (   $a_obj_id)

Constructor.

public

Parameters
intobj_id

Definition at line 49 of file class.ilWaitingList.php.

References $DIC, $ilDB, and read().

50  {
51  global $DIC;
52 
53  $ilDB = $DIC['ilDB'];
54 
55  $this->db = $ilDB;
56  $this->obj_id = $a_obj_id;
57 
58  $this->read();
59  }
global $DIC
Definition: saml.php:7
read()
Read waiting list.
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAll()

static ilWaitingList::_deleteAll (   $a_obj_id)
static

delete all

public

Parameters
intobj_id

Definition at line 87 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilMembershipTest\testMembership(), and ilSoapCourseAdministration\updateCourse().

88  {
89  global $DIC;
90 
91  $ilDB = $DIC['ilDB'];
92 
93  $query = "DELETE FROM crs_waiting_list WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
94  $res = $ilDB->manipulate($query);
95 
96  return true;
97  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _deleteUser()

static ilWaitingList::_deleteUser (   $a_usr_id)
static

Delete user.

public

Parameters
intuser_id

Definition at line 106 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilParticipants\_deleteUser(), and ilMembershipTest\testMembership().

107  {
108  global $DIC;
109 
110  $ilDB = $DIC['ilDB'];
111 
112  $query = "DELETE FROM crs_waiting_list WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
113  $res = $ilDB->manipulate($query);
114 
115  return true;
116  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _isOnList()

static ilWaitingList::_isOnList (   $a_usr_id,
  $a_obj_id 
)
static

Check if a user on the waiting list.

Returns
bool
Parameters
object$a_usr_id
object$a_obj_idpublic

Definition at line 239 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, and $res.

Referenced by ilObjGroupAccess\_checkAccess(), ilObjCourseAccess\_checkAccess(), ilObjSessionAccess\_checkAccess(), ilObjCourseListGUI\getProperties(), ilObjGroupListGUI\getProperties(), ilObjGroupGUI\getTabs(), ilObjCourseGUI\getTabs(), and ilObjSessionGUI\showJoinRequestButton().

240  {
241  global $DIC;
242 
243  $ilDB = $DIC['ilDB'];
244 
245  if (isset(self::$is_on_list[$a_usr_id][$a_obj_id])) {
246  return self::$is_on_list[$a_usr_id][$a_obj_id];
247  }
248 
249  $query = "SELECT usr_id " .
250  "FROM crs_waiting_list " .
251  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
252  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
253  $res = $ilDB->query($query);
254  return $res->numRows() ? true : false;
255  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _preloadOnListInfo()

static ilWaitingList::_preloadOnListInfo (   $a_usr_ids,
  $a_obj_ids 
)
static

Preload on list info.

This is used, e.g. in the repository to prevent multiple reads on the waiting list table. The function is triggered in the preload functions of ilObjCourseAccess and ilObjGroupAccess.

Parameters
array$a_usr_idsarray of user ids
array$a_obj_idsarray of object ids

Definition at line 266 of file class.ilWaitingList.php.

References $DIC, $ilDB, $obj_id, $query, and $res.

Referenced by ilObjGroupAccess\_preloadData(), and ilObjCourseAccess\_preloadData().

267  {
268  global $DIC;
269 
270  $ilDB = $DIC['ilDB'];
271 
272  if (!is_array($a_usr_ids)) {
273  $a_usr_ids = array($a_usr_ids);
274  }
275  if (!is_array($a_obj_ids)) {
276  $a_obj_ids = array($a_obj_ids);
277  }
278  foreach ($a_usr_ids as $usr_id) {
279  foreach ($a_obj_ids as $obj_id) {
280  self::$is_on_list[$usr_id][$obj_id] = false;
281  }
282  }
283  $query = "SELECT usr_id, obj_id " .
284  "FROM crs_waiting_list " .
285  "WHERE " .
286  $ilDB->in("obj_id", $a_obj_ids, false, "integer") . " AND " .
287  $ilDB->in("usr_id", $a_usr_ids, false, "integer");
288  $res = $ilDB->query($query);
289  while ($rec = $ilDB->fetchAssoc($res)) {
290  self::$is_on_list[$rec["usr_id"]][$rec["obj_id"]] = true;
291  }
292  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ addToList()

ilWaitingList::addToList (   $a_usr_id)

add to list

public

Parameters
intusr_id

Definition at line 155 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, $res, getObjId(), isOnList(), and read().

156  {
157  global $DIC;
158 
159  $ilDB = $DIC['ilDB'];
160 
161  if ($this->isOnList($a_usr_id)) {
162  return false;
163  }
164  $query = "INSERT INTO crs_waiting_list (obj_id,usr_id,sub_time) " .
165  "VALUES (" .
166  $ilDB->quote($this->getObjId(), 'integer') . ", " .
167  $ilDB->quote($a_usr_id, 'integer') . ", " .
168  $ilDB->quote(time(), 'integer') . " " .
169  ")";
170  $res = $ilDB->manipulate($query);
171  $this->read();
172 
173  return true;
174  }
global $DIC
Definition: saml.php:7
read()
Read waiting list.
foreach($_POST as $key=> $value) $res
$query
getObjId()
get obj id
global $ilDB
isOnList($a_usr_id)
check if is on waiting list
+ Here is the call graph for this function:

◆ deleteUserEntry()

static ilWaitingList::deleteUserEntry (   $a_usr_id,
  $a_obj_id 
)
static

Delete one user entry.

Parameters
int$a_usr_id
int$a_obj_id
Returns

Definition at line 124 of file class.ilWaitingList.php.

References $DIC, $ilDB, and $query.

Referenced by ilParticipant\add(), ilParticipants\add(), and ilObjSessionGUI\unregisterObject().

125  {
126  global $DIC;
127 
128  $ilDB = $DIC['ilDB'];
129 
130  $query = "DELETE FROM crs_waiting_list " .
131  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . ' ' .
132  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
133  $ilDB->query($query);
134  return true;
135  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getAllUsers()

ilWaitingList::getAllUsers ( )

get all users on waiting list

public

Returns
array array(position,time,usr_id)

Definition at line 324 of file class.ilWaitingList.php.

Referenced by ilCourseXMLWriter\__buildWaitingList().

325  {
326  return $this->users ? $this->users : array();
327  }
+ Here is the caller graph for this function:

◆ getCountUsers()

ilWaitingList::getCountUsers ( )

get number of users

public

Returns
int number of users

Definition at line 301 of file class.ilWaitingList.php.

302  {
303  return count($this->users);
304  }

◆ getObjId()

ilWaitingList::getObjId ( )

◆ getPosition()

ilWaitingList::getPosition (   $a_usr_id)

get position

public

Parameters
intusr_id
Returns
position of user otherwise -1

Definition at line 313 of file class.ilWaitingList.php.

314  {
315  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id]['position'] : -1;
316  }

◆ getUser()

ilWaitingList::getUser (   $a_usr_id)

get user

public

Parameters
intusr_id
Returns

Definition at line 336 of file class.ilWaitingList.php.

337  {
338  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id] : false;
339  }

◆ getUserIds()

ilWaitingList::getUserIds ( )

Get all user ids of users on waiting list.

Definition at line 346 of file class.ilWaitingList.php.

347  {
348  return $this->user_ids ? $this->user_ids : array();
349  }

◆ isOnList()

ilWaitingList::isOnList (   $a_usr_id)

check if is on waiting list

public

Parameters
intusr_id
Returns

Definition at line 226 of file class.ilWaitingList.php.

Referenced by addToList().

227  {
228  return isset($this->users[$a_usr_id]) ? true : false;
229  }
+ Here is the caller graph for this function:

◆ lookupListSize()

static ilWaitingList::lookupListSize (   $a_obj_id)
static

Lookup waiting lit size.

Parameters
int$a_obj_id

Definition at line 65 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjGroupAccess\lookupRegistrationInfo(), and ilObjCourseAccess\lookupRegistrationInfo().

66  {
67  global $DIC;
68 
69  $ilDB = $DIC['ilDB'];
70 
71  $query = 'SELECT count(usr_id) num from crs_waiting_list WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
72  $res = $ilDB->query($query);
73 
74  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
75  return (int) $row->num;
76  }
77  return 0;
78  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilWaitingList::read ( )
private

Read waiting list.

private

Parameters

Definition at line 359 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and getObjId().

Referenced by __construct(), addToList(), and removeFromList().

360  {
361  global $DIC;
362 
363  $ilDB = $DIC['ilDB'];
364 
365  $this->users = array();
366 
367  $query = "SELECT * FROM crs_waiting_list " .
368  "WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " ORDER BY sub_time";
369 
370  $res = $this->db->query($query);
371  $counter = 0;
372  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
373  ++$counter;
374  $this->users[$row->usr_id]['position'] = $counter;
375  $this->users[$row->usr_id]['time'] = $row->sub_time;
376  $this->users[$row->usr_id]['usr_id'] = $row->usr_id;
377 
378  $this->user_ids[] = $row->usr_id;
379  }
380  return true;
381  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
getObjId()
get obj id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFromList()

ilWaitingList::removeFromList (   $a_usr_id)

remove usr from list

public

Parameters
intusr_id
Returns

Definition at line 204 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, $res, getObjId(), and read().

205  {
206  global $DIC;
207 
208  $ilDB = $DIC['ilDB'];
209 
210  $query = "DELETE FROM crs_waiting_list " .
211  " WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " " .
212  " AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
213  $res = $ilDB->manipulate($query);
214  $this->read();
215 
216  return true;
217  }
global $DIC
Definition: saml.php:7
read()
Read waiting list.
foreach($_POST as $key=> $value) $res
$query
getObjId()
get obj id
global $ilDB
+ Here is the call graph for this function:

◆ updateSubscriptionTime()

ilWaitingList::updateSubscriptionTime (   $a_usr_id,
  $a_subtime 
)

update subscription time

public

Parameters
intusr_id
intsubsctription time

Definition at line 183 of file class.ilWaitingList.php.

References $DIC, $ilDB, $query, $res, and getObjId().

184  {
185  global $DIC;
186 
187  $ilDB = $DIC['ilDB'];
188 
189  $query = "UPDATE crs_waiting_list " .
190  "SET sub_time = " . $ilDB->quote($a_subtime, 'integer') . " " .
191  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
192  "AND obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " ";
193  $res = $ilDB->manipulate($query);
194  return true;
195  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
getObjId()
get obj id
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilWaitingList::$db = null
private

Definition at line 35 of file class.ilWaitingList.php.

◆ $is_on_list

ilWaitingList::$is_on_list = array()
static

Definition at line 40 of file class.ilWaitingList.php.

◆ $obj_id

ilWaitingList::$obj_id = 0
private

Definition at line 36 of file class.ilWaitingList.php.

Referenced by _preloadOnListInfo(), and getObjId().

◆ $user_ids

ilWaitingList::$user_ids = array()
private

Definition at line 37 of file class.ilWaitingList.php.

◆ $users

ilWaitingList::$users = array()
private

Definition at line 38 of file class.ilWaitingList.php.


The documentation for this class was generated from the following file: