ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilWaitingList Class Reference

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

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

Public Member Functions

 __construct (int $a_obj_id)
 
 getObjId ()
 
 addToList (int $a_usr_id)
 
 updateSubscriptionTime (int $a_usr_id, int $a_subtime)
 
 removeFromList (int $a_usr_id)
 
 isOnList (int $a_usr_id)
 
 getCountUsers ()
 
 getPosition (int $a_usr_id)
 
 getAllUsers ()
 get all users on waiting list public More...
 
 getUser (int $a_usr_id)
 get user More...
 
 getUserIds ()
 

Static Public Member Functions

static lookupListSize (int $a_obj_id)
 
static _deleteAll (int $a_obj_id)
 
static _deleteUser (int $a_usr_id)
 
static deleteUserEntry (int $a_usr_id, int $a_obj_id)
 
static _isOnList (int $a_usr_id, int $a_obj_id)
 
static _preloadOnListInfo (array $a_usr_ids, array $a_obj_ids)
 Preload on list info. More...
 

Static Public Attributes

static array $is_on_list = []
 

Protected Attributes

ilDBInterface $db
 
ilAppEventHandler $eventHandler
 

Private Member Functions

 read ()
 

Private Attributes

int $obj_id = 0
 
array $user_ids = []
 
array $users = []
 

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

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

Constructor & Destructor Documentation

◆ __construct()

ilWaitingList::__construct ( int  $a_obj_id)

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

References $DIC, and read().

36  {
37  global $DIC;
38 
39  $this->db = $DIC->database();
40  $this->eventHandler = $DIC->event();
41  $this->obj_id = $a_obj_id;
42  if ($a_obj_id) {
43  $this->read();
44  }
45  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteAll()

static ilWaitingList::_deleteAll ( int  $a_obj_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilSoapCourseAdministration\excludeCourseMember().

60  : void
61  {
62  global $DIC;
63 
64  $ilDB = $DIC->database();
65 
66  $query = "DELETE FROM crs_waiting_list WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
67  $res = $ilDB->manipulate($query);
68  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ _deleteUser()

static ilWaitingList::_deleteUser ( int  $a_usr_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilParticipants\_deleteUser().

70  : void
71  {
72  global $DIC;
73 
74  $ilDB = $DIC->database();
75  $query = "DELETE FROM crs_waiting_list WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
76  $res = $ilDB->manipulate($query);
77  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ _isOnList()

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

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

References $DIC, $ilDB, and $res.

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

135  : bool
136  {
137  global $DIC;
138 
139  $ilDB = $DIC['ilDB'];
140  if (isset(self::$is_on_list[$a_usr_id][$a_obj_id])) {
141  return self::$is_on_list[$a_usr_id][$a_obj_id];
142  }
143 
144  $query = "SELECT usr_id " .
145  "FROM crs_waiting_list " .
146  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
147  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
148  $res = $ilDB->query($query);
149  return (bool) $res->numRows();
150  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ _preloadOnListInfo()

static ilWaitingList::_preloadOnListInfo ( array  $a_usr_ids,
array  $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.

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

References $DIC, $ilDB, $obj_id, $res, and ILIAS\Repository\int().

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

158  : void
159  {
160  global $DIC;
161 
162  $ilDB = $DIC['ilDB'];
163  foreach ($a_usr_ids as $usr_id) {
164  foreach ($a_obj_ids as $obj_id) {
165  self::$is_on_list[$usr_id][$obj_id] = false;
166  }
167  }
168  $query = "SELECT usr_id, obj_id " .
169  "FROM crs_waiting_list " .
170  "WHERE " .
171  $ilDB->in("obj_id", $a_obj_ids, false, "integer") . " AND " .
172  $ilDB->in("usr_id", $a_usr_ids, false, "integer");
173  $res = $ilDB->query($query);
174  while ($rec = $ilDB->fetchAssoc($res)) {
175  self::$is_on_list[(int) $rec["usr_id"]][(int) $rec["obj_id"]] = true;
176  }
177  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addToList()

ilWaitingList::addToList ( int  $a_usr_id)

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

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

95  : bool
96  {
97  if ($this->isOnList($a_usr_id)) {
98  return false;
99  }
100  $query = "INSERT INTO crs_waiting_list (obj_id,usr_id,sub_time) " .
101  "VALUES (" .
102  $this->db->quote($this->getObjId(), 'integer') . ", " .
103  $this->db->quote($a_usr_id, 'integer') . ", " .
104  $this->db->quote(time(), 'integer') . " " .
105  ")";
106  $res = $this->db->manipulate($query);
107  $this->read();
108  return true;
109  }
$res
Definition: ltiservices.php:66
isOnList(int $a_usr_id)
+ Here is the call graph for this function:

◆ deleteUserEntry()

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

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

References $DIC, and $ilDB.

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

79  : void
80  {
81  global $DIC;
82 
83  $ilDB = $DIC->database();
84  $query = "DELETE FROM crs_waiting_list " .
85  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . ' ' .
86  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
87  $ilDB->query($query);
88  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getAllUsers()

ilWaitingList::getAllUsers ( )

get all users on waiting list public

Returns
array<int, array<{position: int, time: int, usr_id: int}>>

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

References $users.

Referenced by ilCourseXMLWriter\__buildWaitingList().

194  : array
195  {
196  return $this->users;
197  }
+ Here is the caller graph for this function:

◆ getCountUsers()

ilWaitingList::getCountUsers ( )

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

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

179  : int
180  {
181  return count($this->users);
182  }
+ Here is the caller graph for this function:

◆ getObjId()

ilWaitingList::getObjId ( )

◆ getPosition()

ilWaitingList::getPosition ( int  $a_usr_id)

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

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

184  : int
185  {
186  return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id]['position'] : -1;
187  }
+ Here is the caller graph for this function:

◆ getUser()

ilWaitingList::getUser ( int  $a_usr_id)

get user

Parameters
intusr_id
Returns
array<{position: int, time: int, usr_id: int}>

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

204  : array
205  {
206  return $this->users[$a_usr_id] ?? [];
207  }

◆ getUserIds()

ilWaitingList::getUserIds ( )
Returns
int[]

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

References $user_ids.

212  : array
213  {
214  return $this->user_ids;
215  }

◆ isOnList()

ilWaitingList::isOnList ( int  $a_usr_id)

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

Referenced by addToList(), ilGroupRegistrationGUI\fillMaxMembers(), and ilCourseRegistrationGUI\fillMaxMembers().

130  : bool
131  {
132  return isset($this->users[$a_usr_id]);
133  }
+ Here is the caller graph for this function:

◆ lookupListSize()

static ilWaitingList::lookupListSize ( int  $a_obj_id)
static

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

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

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

47  : int
48  {
49  global $DIC;
50 
51  $ilDB = $DIC->database();
52  $query = 'SELECT count(usr_id) num from crs_waiting_list WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
53  $res = $ilDB->query($query);
54  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
55  return (int) $row->num;
56  }
57  return 0;
58  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ read()

ilWaitingList::read ( )
private

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

References $res, ilDBConstants\FETCHMODE_OBJECT, getObjId(), and ILIAS\Repository\int().

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

217  : void
218  {
219  $this->users = [];
220  $query = "SELECT * FROM crs_waiting_list " .
221  "WHERE obj_id = " . $this->db->quote($this->getObjId(), 'integer') . " ORDER BY sub_time";
222 
223  $res = $this->db->query($query);
224  $counter = 0;
225  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
226  ++$counter;
227  $this->users[(int) $row->usr_id]['position'] = $counter;
228  $this->users[(int) $row->usr_id]['time'] = (int) $row->sub_time;
229  $this->users[(int) $row->usr_id]['usr_id'] = (int) $row->usr_id;
230 
231  $this->user_ids[] = (int) $row->usr_id;
232  }
233  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFromList()

ilWaitingList::removeFromList ( int  $a_usr_id)

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

References getObjId(), and read().

120  : bool
121  {
122  $query = "DELETE FROM crs_waiting_list " .
123  " WHERE obj_id = " . $this->db->quote($this->getObjId(), 'integer') . " " .
124  " AND usr_id = " . $this->db->quote($a_usr_id, 'integer') . " ";
125  $affected = $this->db->manipulate($query);
126  $this->read();
127  return $affected > 0;
128  }
+ Here is the call graph for this function:

◆ updateSubscriptionTime()

ilWaitingList::updateSubscriptionTime ( int  $a_usr_id,
int  $a_subtime 
)

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

References $res, and getObjId().

111  : void
112  {
113  $query = "UPDATE crs_waiting_list " .
114  "SET sub_time = " . $this->db->quote($a_subtime, 'integer') . " " .
115  "WHERE usr_id = " . $this->db->quote($a_usr_id, 'integer') . " " .
116  "AND obj_id = " . $this->db->quote($this->getObjId(), 'integer') . " ";
117  $res = $this->db->manipulate($query);
118  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilWaitingList::$db
protected

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

◆ $eventHandler

ilAppEventHandler ilWaitingList::$eventHandler
protected

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

◆ $is_on_list

array ilWaitingList::$is_on_list = []
static

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

◆ $obj_id

int ilWaitingList::$obj_id = 0
private

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

Referenced by _preloadOnListInfo(), and getObjId().

◆ $user_ids

array ilWaitingList::$user_ids = []
private

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

Referenced by getUserIds().

◆ $users

array ilWaitingList::$users = []
private

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

Referenced by getAllUsers().


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