ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups 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 ($a_obj_id)
 Constructor.
 getObjId ()
 get obj id
 addToList ($a_usr_id)
 add to list
 updateSubscriptionTime ($a_usr_id, $a_subtime)
 update subscription time
 removeFromList ($a_usr_id)
 remove usr from list
 isOnList ($a_usr_id)
 check if is on waiting list
 _preloadOnListInfo ($a_usr_ids, $a_obj_ids)
 Preload on list info.
 getCountUsers ()
 get number of users
 getPosition ($a_usr_id)
 get position
 getAllUsers ()
 get all users on waiting list
 getUser ($a_usr_id)
 get user
 getUserIds ()
 Get all user ids of users on waiting list.

Static Public Member Functions

static _deleteAll ($a_obj_id)
 delete all
static _deleteUser ($a_usr_id)
 Delete user.
static deleteUserEntry ($a_usr_id, $a_obj_id)
 Delete one user entry.
static _isOnList ($a_usr_id, $a_obj_id)
 Check if a user on the waiting list.

Static Public Attributes

static $is_on_list = array()

Private Member Functions

 read ()
 Read waiting list.

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

ilWaitingList::__construct (   $a_obj_id)

Constructor.

public

Parameters
intobj_id

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

References $ilDB, and read().

{
global $ilDB;
$this->db = $ilDB;
$this->obj_id = $a_obj_id;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

static ilWaitingList::_deleteAll (   $a_obj_id)
static

delete all

public

Parameters
intobj_id

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

References $ilDB, $query, and $res.

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

{
global $ilDB;
$query = "DELETE FROM crs_waiting_list WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

static ilWaitingList::_deleteUser (   $a_usr_id)
static

Delete user.

public

Parameters
intuser_id

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

References $ilDB, $query, and $res.

Referenced by ilMembershipTest\testMembership().

{
global $ilDB;
$query = "DELETE FROM crs_waiting_list WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer');
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

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 $ilDB, $query, and $res.

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

{
global $ilDB;
if (isset(self::$is_on_list[$a_usr_id][$a_obj_id]))
{
return self::$is_on_list[$a_usr_id][$a_obj_id];
}
$query = "SELECT usr_id ".
"FROM crs_waiting_list ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id, 'integer')." ".
"AND usr_id = ".$ilDB->quote($a_usr_id, 'integer');
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

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 $ilDB, $obj_id, $query, $res, and $usr_id.

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

{
global $ilDB;
if (!is_array($a_usr_ids))
{
$a_usr_ids = array($a_usr_ids);
}
if (!is_array($a_obj_ids))
{
$a_obj_ids = array($a_obj_ids);
}
foreach ($a_usr_ids as $usr_id)
{
foreach ($a_obj_ids as $obj_id)
{
self::$is_on_list[$usr_id][$obj_id] = false;
}
}
$query = "SELECT usr_id, obj_id ".
"FROM crs_waiting_list ".
"WHERE ".
$ilDB->in("obj_id", $a_obj_ids, false, "integer")." AND ".
$ilDB->in("usr_id", $a_usr_ids, false, "integer");
$res = $ilDB->query($query);
while ($rec = $ilDB->fetchAssoc($res))
{
self::$is_on_list[$rec["usr_id"]][$rec["obj_id"]] = true;
}
}

+ Here is the caller graph for this function:

ilWaitingList::addToList (   $a_usr_id)

add to list

public

Parameters
intusr_id

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

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

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

{
global $ilDB;
if($this->isOnList($a_usr_id))
{
return false;
}
$query = "INSERT INTO crs_waiting_list (obj_id,usr_id,sub_time) ".
"VALUES (".
$ilDB->quote($this->getObjId() ,'integer').", ".
$ilDB->quote($a_usr_id ,'integer').", ".
$ilDB->quote(time() ,'integer')." ".
")";
$res = $ilDB->manipulate($query);
$this->read();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Delete one user entry.

Parameters
object$a_usr_id
object$a_obj_id
Returns

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

References $ilDB, and $query.

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

{
global $ilDB;
$query = "DELETE FROM crs_waiting_list ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id,'integer').' '.
"AND obj_id = ".$ilDB->quote($a_obj_id,'integer');
$ilDB->query($query);
return true;
}

+ Here is the caller graph for this function:

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.

{
return $this->users ? $this->users : array();
}
ilWaitingList::getCountUsers ( )

get number of users

public

Returns
int number of users

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

{
return count($this->users);
}
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().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

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.

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

get user

public

Parameters
intusr_id
Returns

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

{
return isset($this->users[$a_usr_id]) ? $this->users[$a_usr_id] : false;
}
ilWaitingList::getUserIds ( )

Get all user ids of users on waiting list.

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

{
return $this->user_ids ? $this->user_ids : array();
}
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().

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

+ Here is the caller graph for this function:

ilWaitingList::read ( )
private

Read waiting list.

private

Parameters
@return

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

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

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

{
global $ilDB;
$this->users = array();
$query = "SELECT * FROM crs_waiting_list ".
"WHERE obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ORDER BY sub_time";
$res = $this->db->query($query);
$counter = 0;
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
++$counter;
$this->users[$row->usr_id]['position'] = $counter;
$this->users[$row->usr_id]['time'] = $row->sub_time;
$this->users[$row->usr_id]['usr_id'] = $row->usr_id;
$this->user_ids[] = $row->usr_id;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilWaitingList::removeFromList (   $a_usr_id)

remove usr from list

public

Parameters
intusr_id
Returns

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

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

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

{
global $ilDB;
$query = "DELETE FROM crs_waiting_list ".
" WHERE obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ".
" AND usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ";
$res = $ilDB->manipulate($query);
$this->read();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 $ilDB, $query, $res, and getObjId().

{
global $ilDB;
$query = "UPDATE crs_waiting_list ".
"SET sub_time = ".$ilDB->quote($a_subtime ,'integer')." ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
"AND obj_id = ".$ilDB->quote($this->getObjId() ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilWaitingList::$db = null
private

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

ilWaitingList::$is_on_list = array()
static

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

ilWaitingList::$obj_id = 0
private

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

Referenced by _preloadOnListInfo(), and getObjId().

ilWaitingList::$user_ids = array()
private

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

ilWaitingList::$users = array()
private

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


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