ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

@access public

Parameters
intobj_id

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

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

References $ilDB, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAll()

static ilWaitingList::_deleteAll (   $a_obj_id)
static

delete all

@access public

Parameters
intobj_id

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

84 {
85 global $ilDB;
86
87 $query = "DELETE FROM crs_waiting_list WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
88 $res = $ilDB->manipulate($query);
89
90 return true;
91 }
$query
foreach($_POST as $key=> $value) $res

References $ilDB, $query, and $res.

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

+ Here is the caller graph for this function:

◆ _deleteUser()

static ilWaitingList::_deleteUser (   $a_usr_id)
static

Delete user.

@access public

Parameters
intuser_id

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

101 {
102 global $ilDB;
103
104 $query = "DELETE FROM crs_waiting_list WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
105 $res = $ilDB->manipulate($query);
106
107 return true;
108 }

References $ilDB, $query, and $res.

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

+ 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_id@access public

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

224 {
225 global $ilDB;
226
227 if (isset(self::$is_on_list[$a_usr_id][$a_obj_id])) {
228 return self::$is_on_list[$a_usr_id][$a_obj_id];
229 }
230
231 $query = "SELECT usr_id " .
232 "FROM crs_waiting_list " .
233 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
234 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
235 $res = $ilDB->query($query);
236 return $res->numRows() ? true : false;
237 }

References $ilDB, $query, and $res.

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

+ 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 248 of file class.ilWaitingList.php.

249 {
250 global $ilDB;
251
252 if (!is_array($a_usr_ids)) {
253 $a_usr_ids = array($a_usr_ids);
254 }
255 if (!is_array($a_obj_ids)) {
256 $a_obj_ids = array($a_obj_ids);
257 }
258 foreach ($a_usr_ids as $usr_id) {
259 foreach ($a_obj_ids as $obj_id) {
260 self::$is_on_list[$usr_id][$obj_id] = false;
261 }
262 }
263 $query = "SELECT usr_id, obj_id " .
264 "FROM crs_waiting_list " .
265 "WHERE " .
266 $ilDB->in("obj_id", $a_obj_ids, false, "integer") . " AND " .
267 $ilDB->in("usr_id", $a_usr_ids, false, "integer");
268 $res = $ilDB->query($query);
269 while ($rec = $ilDB->fetchAssoc($res)) {
270 self::$is_on_list[$rec["usr_id"]][$rec["obj_id"]] = true;
271 }
272 }

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

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

+ Here is the caller graph for this function:

◆ addToList()

ilWaitingList::addToList (   $a_usr_id)

add to list

@access public

Parameters
intusr_id

Reimplemented in ilCourseWaitingList, ilGroupWaitingList, and ilSessionWaitingList.

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

146 {
147 global $ilDB;
148
149 if ($this->isOnList($a_usr_id)) {
150 return false;
151 }
152 $query = "INSERT INTO crs_waiting_list (obj_id,usr_id,sub_time) " .
153 "VALUES (" .
154 $ilDB->quote($this->getObjId(), 'integer') . ", " .
155 $ilDB->quote($a_usr_id, 'integer') . ", " .
156 $ilDB->quote(time(), 'integer') . " " .
157 ")";
158 $res = $ilDB->manipulate($query);
159 $this->read();
160
161 return true;
162 }
isOnList($a_usr_id)
check if is on waiting list

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

+ 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 116 of file class.ilWaitingList.php.

117 {
118 global $ilDB;
119
120 $query = "DELETE FROM crs_waiting_list " .
121 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . ' ' .
122 "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
123 $ilDB->query($query);
124 return true;
125 }

References $ilDB, and $query.

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

+ Here is the caller graph for this function:

◆ getAllUsers()

ilWaitingList::getAllUsers ( )

get all users on waiting list

@access public

Returns
array array(position,time,usr_id)

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

305 {
306 return $this->users ? $this->users : array();
307 }

◆ getCountUsers()

ilWaitingList::getCountUsers ( )

get number of users

@access public

Returns
int number of users

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

282 {
283 return count($this->users);
284 }

◆ getObjId()

ilWaitingList::getObjId ( )

get obj id

@access public

Returns
int obj_id

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

135 {
136 return $this->obj_id;
137 }

References $obj_id.

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

+ Here is the caller graph for this function:

◆ getPosition()

ilWaitingList::getPosition (   $a_usr_id)

get position

@access public

Parameters
intusr_id
Returns
position of user otherwise -1

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

294 {
295 return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id]['position'] : -1;
296 }

◆ getUser()

ilWaitingList::getUser (   $a_usr_id)

get user

@access public

Parameters
intusr_id
Returns

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

317 {
318 return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id] : false;
319 }

◆ getUserIds()

ilWaitingList::getUserIds ( )

Get all user ids of users on waiting list.

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

327 {
328 return $this->user_ids ? $this->user_ids : array();
329 }

◆ isOnList()

ilWaitingList::isOnList (   $a_usr_id)

check if is on waiting list

@access public

Parameters
intusr_id
Returns

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

211 {
212 return isset($this->users[$a_usr_id]) ? true : false;
213 }

Referenced by addToList().

+ 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.

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 return (int) $row->num;
72 }
73 return 0;
74 }

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

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

+ Here is the caller graph for this function:

◆ read()

ilWaitingList::read ( )
private

Read waiting list.

@access private

Parameters

return

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

340 {
341 global $ilDB;
342
343 $this->users = array();
344
345 $query = "SELECT * FROM crs_waiting_list " .
346 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " ORDER BY sub_time";
347
348 $res = $this->db->query($query);
349 $counter = 0;
350 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
351 ++$counter;
352 $this->users[$row->usr_id]['position'] = $counter;
353 $this->users[$row->usr_id]['time'] = $row->sub_time;
354 $this->users[$row->usr_id]['usr_id'] = $row->usr_id;
355
356 $this->user_ids[] = $row->usr_id;
357 }
358 return true;
359 }
$counter

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

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

+ 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

@access public

Parameters
intusr_id
Returns

Reimplemented in ilCourseWaitingList.

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

191 {
192 global $ilDB;
193
194 $query = "DELETE FROM crs_waiting_list " .
195 " WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " " .
196 " AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
197 $res = $ilDB->manipulate($query);
198 $this->read();
199
200 return true;
201 }

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

+ Here is the call graph for this function:

◆ updateSubscriptionTime()

ilWaitingList::updateSubscriptionTime (   $a_usr_id,
  $a_subtime 
)

update subscription time

@access public

Parameters
intusr_id
intsubsctription time

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

172 {
173 global $ilDB;
174
175 $query = "UPDATE crs_waiting_list " .
176 "SET sub_time = " . $ilDB->quote($a_subtime, 'integer') . " " .
177 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
178 "AND obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " ";
179 $res = $ilDB->manipulate($query);
180 return true;
181 }

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

+ 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: