ILIAS  release_4-4 Revision
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...
 
 _preloadOnListInfo ($a_usr_ids, $a_obj_ids)
 Preload on list info. 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 _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 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 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.
+ 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 66 of file class.ilWaitingList.php.

References $query, and $res.

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

67  {
68  global $ilDB;
69 
70  $query = "DELETE FROM crs_waiting_list WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
71  $res = $ilDB->manipulate($query);
72 
73  return true;
74  }
+ 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 83 of file class.ilWaitingList.php.

References $query, and $res.

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

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

References $query, and $res.

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

208  {
209  global $ilDB;
210 
211  if (isset(self::$is_on_list[$a_usr_id][$a_obj_id]))
212  {
213  return self::$is_on_list[$a_usr_id][$a_obj_id];
214  }
215 
216  $query = "SELECT usr_id ".
217  "FROM crs_waiting_list ".
218  "WHERE obj_id = ".$ilDB->quote($a_obj_id, 'integer')." ".
219  "AND usr_id = ".$ilDB->quote($a_usr_id, 'integer');
220  $res = $ilDB->query($query);
221  return $res->numRows() ? true : false;
222  }
+ Here is the caller graph for this function:

◆ _preloadOnListInfo()

ilWaitingList::_preloadOnListInfo (   $a_usr_ids,
  $a_obj_ids 
)

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

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

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

234  {
235  global $ilDB;
236 
237  if (!is_array($a_usr_ids))
238  {
239  $a_usr_ids = array($a_usr_ids);
240  }
241  if (!is_array($a_obj_ids))
242  {
243  $a_obj_ids = array($a_obj_ids);
244  }
245  foreach ($a_usr_ids as $usr_id)
246  {
247  foreach ($a_obj_ids as $obj_id)
248  {
249  self::$is_on_list[$usr_id][$obj_id] = false;
250  }
251  }
252  $query = "SELECT usr_id, obj_id ".
253  "FROM crs_waiting_list ".
254  "WHERE ".
255  $ilDB->in("obj_id", $a_obj_ids, false, "integer")." AND ".
256  $ilDB->in("usr_id", $a_usr_ids, false, "integer");
257  $res = $ilDB->query($query);
258  while ($rec = $ilDB->fetchAssoc($res))
259  {
260  self::$is_on_list[$rec["usr_id"]][$rec["obj_id"]] = true;
261  }
262  }
+ Here is the caller graph for this function:

◆ addToList()

ilWaitingList::addToList (   $a_usr_id)

add to list

public

Parameters
intusr_id

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

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

Referenced by ilGroupRegistrationGUI\add(), and ilCourseRegistrationGUI\add().

129  {
130  global $ilDB;
131 
132  if($this->isOnList($a_usr_id))
133  {
134  return false;
135  }
136  $query = "INSERT INTO crs_waiting_list (obj_id,usr_id,sub_time) ".
137  "VALUES (".
138  $ilDB->quote($this->getObjId() ,'integer').", ".
139  $ilDB->quote($a_usr_id ,'integer').", ".
140  $ilDB->quote(time() ,'integer')." ".
141  ")";
142  $res = $ilDB->manipulate($query);
143  $this->read();
144 
145  return true;
146  }
read()
Read waiting list.
getObjId()
get obj id
isOnList($a_usr_id)
check if is on waiting list
+ Here is the call graph for this function:
+ Here is the caller 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 99 of file class.ilWaitingList.php.

References $query.

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

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

295  {
296  return $this->users ? $this->users : array();
297  }

◆ getCountUsers()

ilWaitingList::getCountUsers ( )

get number of users

public

Returns
int number of users

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

272  {
273  return count($this->users);
274  }

◆ getObjId()

ilWaitingList::getObjId ( )

get obj id

public

Returns
int obj_id

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

References $obj_id.

Referenced by addToList(), read(), removeFromList(), and updateSubscriptionTime().

118  {
119  return $this->obj_id;
120  }
+ 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 283 of file class.ilWaitingList.php.

284  {
285  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id]['position'] : -1;
286  }

◆ getUser()

ilWaitingList::getUser (   $a_usr_id)

get user

public

Parameters
intusr_id
Returns

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

307  {
308  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id] : false;
309  }

◆ getUserIds()

ilWaitingList::getUserIds ( )

Get all user ids of users on waiting list.

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

317  {
318  return $this->user_ids ? $this->user_ids : array();
319  }

◆ isOnList()

ilWaitingList::isOnList (   $a_usr_id)

check if is on waiting list

public

Parameters
intusr_id
Returns

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

Referenced by addToList().

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

◆ read()

ilWaitingList::read ( )
private

Read waiting list.

private

Parameters

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

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getObjId().

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

330  {
331  global $ilDB;
332 
333  $this->users = array();
334 
335  $query = "SELECT * FROM crs_waiting_list ".
336  "WHERE obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ORDER BY sub_time";
337 
338  $res = $this->db->query($query);
339  $counter = 0;
340  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
341  {
342  ++$counter;
343  $this->users[$row->usr_id]['position'] = $counter;
344  $this->users[$row->usr_id]['time'] = $row->sub_time;
345  $this->users[$row->usr_id]['usr_id'] = $row->usr_id;
346 
347  $this->user_ids[] = $row->usr_id;
348  }
349  return true;
350  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
getObjId()
get obj id
+ 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 174 of file class.ilWaitingList.php.

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

Referenced by ilObjGroupGUI\assignFromWaitingListObject(), ilObjCourseGUI\assignFromWaitingListObject(), ilObjGroupGUI\refuseFromListObject(), and ilObjCourseGUI\refuseFromListObject().

175  {
176  global $ilDB;
177 
178  $query = "DELETE FROM crs_waiting_list ".
179  " WHERE obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ".
180  " AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
181  $res = $ilDB->manipulate($query);
182  $this->read();
183 
184  return true;
185  }
read()
Read waiting list.
getObjId()
get obj id
+ 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 155 of file class.ilWaitingList.php.

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

156  {
157  global $ilDB;
158 
159  $query = "UPDATE crs_waiting_list ".
160  "SET sub_time = ".$ilDB->quote($a_subtime ,'integer')." ".
161  "WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
162  "AND obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ";
163  $res = $ilDB->manipulate($query);
164  return true;
165  }
getObjId()
get obj id
+ 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: