ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $ilDB, and read().

50  {
51  global $ilDB;
52 
53  $this->db = $ilDB;
54  $this->obj_id = $a_obj_id;
55 
56  $this->read();
57  }
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 84 of file class.ilWaitingList.php.

References $ilDB, $query, and $res.

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

85  {
86  global $ilDB;
87 
88  $query = "DELETE FROM crs_waiting_list WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
89  $res = $ilDB->manipulate($query);
90 
91  return true;
92  }
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 101 of file class.ilWaitingList.php.

References $ilDB, $query, and $res.

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

102  {
103  global $ilDB;
104 
105  $query = "DELETE FROM crs_waiting_list WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer');
106  $res = $ilDB->manipulate($query);
107 
108  return true;
109  }
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 225 of file class.ilWaitingList.php.

References $ilDB, $query, and $res.

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

226  {
227  global $ilDB;
228 
229  if (isset(self::$is_on_list[$a_usr_id][$a_obj_id]))
230  {
231  return self::$is_on_list[$a_usr_id][$a_obj_id];
232  }
233 
234  $query = "SELECT usr_id ".
235  "FROM crs_waiting_list ".
236  "WHERE obj_id = ".$ilDB->quote($a_obj_id, 'integer')." ".
237  "AND usr_id = ".$ilDB->quote($a_usr_id, 'integer');
238  $res = $ilDB->query($query);
239  return $res->numRows() ? true : false;
240  }
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 251 of file class.ilWaitingList.php.

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

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

252  {
253  global $ilDB;
254 
255  if (!is_array($a_usr_ids))
256  {
257  $a_usr_ids = array($a_usr_ids);
258  }
259  if (!is_array($a_obj_ids))
260  {
261  $a_obj_ids = array($a_obj_ids);
262  }
263  foreach ($a_usr_ids as $usr_id)
264  {
265  foreach ($a_obj_ids as $obj_id)
266  {
267  self::$is_on_list[$usr_id][$obj_id] = false;
268  }
269  }
270  $query = "SELECT usr_id, obj_id ".
271  "FROM crs_waiting_list ".
272  "WHERE ".
273  $ilDB->in("obj_id", $a_obj_ids, false, "integer")." AND ".
274  $ilDB->in("usr_id", $a_usr_ids, false, "integer");
275  $res = $ilDB->query($query);
276  while ($rec = $ilDB->fetchAssoc($res))
277  {
278  self::$is_on_list[$rec["usr_id"]][$rec["obj_id"]] = true;
279  }
280  }
Create styles array
The data for the language used.
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 146 of file class.ilWaitingList.php.

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

147  {
148  global $ilDB;
149 
150  if($this->isOnList($a_usr_id))
151  {
152  return false;
153  }
154  $query = "INSERT INTO crs_waiting_list (obj_id,usr_id,sub_time) ".
155  "VALUES (".
156  $ilDB->quote($this->getObjId() ,'integer').", ".
157  $ilDB->quote($a_usr_id ,'integer').", ".
158  $ilDB->quote(time() ,'integer')." ".
159  ")";
160  $res = $ilDB->manipulate($query);
161  $this->read();
162 
163  return true;
164  }
read()
Read waiting list.
getObjId()
get obj id
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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 117 of file class.ilWaitingList.php.

References $ilDB, and $query.

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

118  {
119  global $ilDB;
120 
121  $query = "DELETE FROM crs_waiting_list ".
122  "WHERE usr_id = ".$ilDB->quote($a_usr_id,'integer').' '.
123  "AND obj_id = ".$ilDB->quote($a_obj_id,'integer');
124  $ilDB->query($query);
125  return true;
126  }
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 312 of file class.ilWaitingList.php.

References array.

313  {
314  return $this->users ? $this->users : array();
315  }
Create styles array
The data for the language used.

◆ getCountUsers()

ilWaitingList::getCountUsers ( )

get number of users

public

Returns
int number of users

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

290  {
291  return count($this->users);
292  }

◆ getObjId()

ilWaitingList::getObjId ( )

get obj id

public

Returns
int obj_id

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

References $obj_id.

Referenced by ilSessionWaitingList\addToList(), ilCourseWaitingList\addToList(), ilGroupWaitingList\addToList(), addToList(), read(), ilCourseWaitingList\removeFromList(), removeFromList(), and updateSubscriptionTime().

136  {
137  return $this->obj_id;
138  }
+ Here is the caller graph for this function:

◆ getPosition()

ilWaitingList::getPosition (   $a_usr_id)

get position

public

Parameters
intusr_id
Returns
position of user otherwise -1

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

302  {
303  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id]['position'] : -1;
304  }

◆ getUser()

ilWaitingList::getUser (   $a_usr_id)

get user

public

Parameters
intusr_id
Returns

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

325  {
326  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id] : false;
327  }

◆ getUserIds()

ilWaitingList::getUserIds ( )

Get all user ids of users on waiting list.

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

References array.

335  {
336  return $this->user_ids ? $this->user_ids : array();
337  }
Create styles array
The data for the language used.

◆ isOnList()

ilWaitingList::isOnList (   $a_usr_id)

check if is on waiting list

public

Parameters
intusr_id
Returns

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

Referenced by addToList().

213  {
214  return isset($this->users[$a_usr_id]) ? true : false;
215  }
+ 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 63 of file class.ilWaitingList.php.

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

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

64  {
65  global $ilDB;
66 
67  $query = 'SELECT count(usr_id) num from crs_waiting_list WHERE obj_id = '. $ilDB->quote($a_obj_id, 'integer');
68  $res = $ilDB->query($query);
69 
70  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
71  {
72  return (int) $row->num;
73  }
74  return 0;
75  }
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilWaitingList::read ( )
private

Read waiting list.

private

Parameters

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

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

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

348  {
349  global $ilDB;
350 
351  $this->users = array();
352 
353  $query = "SELECT * FROM crs_waiting_list ".
354  "WHERE obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ORDER BY sub_time";
355 
356  $res = $this->db->query($query);
357  $counter = 0;
358  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
359  {
360  ++$counter;
361  $this->users[$row->usr_id]['position'] = $counter;
362  $this->users[$row->usr_id]['time'] = $row->sub_time;
363  $this->users[$row->usr_id]['usr_id'] = $row->usr_id;
364 
365  $this->user_ids[] = $row->usr_id;
366  }
367  return true;
368  }
$counter
Create styles array
The data for the language used.
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 192 of file class.ilWaitingList.php.

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

Referenced by ilObjSessionGUI\refuseFromListObject().

193  {
194  global $ilDB;
195 
196  $query = "DELETE FROM crs_waiting_list ".
197  " WHERE obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ".
198  " AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
199  $res = $ilDB->manipulate($query);
200  $this->read();
201 
202  return true;
203  }
read()
Read waiting list.
getObjId()
get obj id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSubscriptionTime()

ilWaitingList::updateSubscriptionTime (   $a_usr_id,
  $a_subtime 
)

update subscription time

public

Parameters
intusr_id
intsubsctription time

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

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

174  {
175  global $ilDB;
176 
177  $query = "UPDATE crs_waiting_list ".
178  "SET sub_time = ".$ilDB->quote($a_subtime ,'integer')." ".
179  "WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
180  "AND obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ";
181  $res = $ilDB->manipulate($query);
182  return true;
183  }
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: