ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilParticipant Class Reference

Base class for course and group participant. More...

+ Inheritance diagram for ilParticipant:
+ Collaboration diagram for ilParticipant:

Public Member Functions

 getUserId ()
 get user id
 isBlocked ()
 isAssigned ()
 isMember ()
 isAdmin ()
 isTutor ()
 isParticipant ()
 getNumberOfMembers ()
 add ($a_usr_id, $a_role)
 Add user to course.
 delete ($a_usr_id)
 Drop user from all roles.
 deleteSubscriber ($a_usr_id)
 Delete subsciber.
 addDesktopItem ($a_usr_id)
 Add desktop item.
 dropDesktopItem ($a_usr_id)
 Drop desktop item.
 updateNotification ($a_usr_id, $a_notification)
 Update notification status.
 checkLastAdmin ($a_usr_ids)
 Check if user for deletion are last admins.

Protected Member Functions

 __construct ($a_obj_id, $a_usr_id)
 Singleton Constructor.
 readParticipant ()
 Read participant.
 readParticipantStatus ()
 Read participant status ilDB $ilDB.

Protected Attributes

 $type = ''

Private Attributes

 $obj_id = 0
 $usr_id = 0
 $ref_id = 0
 $participants = false
 $admins = false
 $tutors = false
 $members = false
 $numMembers = 0
 $participants_status = array()

Detailed Description

Base class for course and group participant.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 34 of file class.ilParticipant.php.

Constructor & Destructor Documentation

ilParticipant::__construct (   $a_obj_id,
  $a_usr_id 
)
protected

Singleton Constructor.

protected

Parameters
intobj_id of container

Reimplemented in ilCourseParticipant.

Definition at line 56 of file class.ilParticipant.php.

References $lng, ilObject\_getAllReferences(), ilObject\_lookupType(), readParticipant(), and readParticipantStatus().

{
global $ilDB,$lng;
$this->obj_id = $a_obj_id;
$this->usr_id = $a_usr_id;
$this->type = ilObject::_lookupType($a_obj_id);
$ref_ids = ilObject::_getAllReferences($this->obj_id);
$this->ref_id = current($ref_ids);
$this->readParticipant();
}

+ Here is the call graph for this function:

Member Function Documentation

ilParticipant::add (   $a_usr_id,
  $a_role 
)

Add user to course.

public

Parameters
intuser id
introle IL_CRS_ADMIN || IL_CRS_TUTOR || IL_CRS_MEMBER

global ilRbacReview $rbacreview

Definition at line 239 of file class.ilParticipant.php.

References $ilLog, addDesktopItem(), deleteSubscriber(), ilWaitingList\deleteUserEntry(), IL_CRS_ADMIN, IL_CRS_MEMBER, IL_CRS_TUTOR, IL_GRP_ADMIN, and IL_GRP_MEMBER.

{
global $rbacadmin,$ilLog,$ilAppEventHandler,$rbacreview;
if($rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id,$this->roles))
{
return false;
}
switch($a_role)
{
$this->admins = true;
break;
$this->tutors = true;
break;
$this->members = true;
break;
$this->admins = true;
break;
$this->members = true;
break;
}
$rbacadmin->assignUser($this->role_data[$a_role],$a_usr_id);
$this->addDesktopItem($a_usr_id);
// Delete subscription request
$this->deleteSubscriber($a_usr_id);
include_once './Services/Membership/classes/class.ilWaitingList.php';
ilWaitingList::deleteUserEntry($a_usr_id,$this->obj_id);
if($this->type == 'crs')
{
// Add event: used for ecs accounts
$ilLog->write(__METHOD__.': Raise new event: Modules/Course addParticipant');
$ilAppEventHandler->raise("Modules/Course", "addParticipant", array('obj_id' => $this->obj_id, 'usr_id' => $a_usr_id,'role_id' => $a_role));
}
return true;
}

+ Here is the call graph for this function:

ilParticipant::addDesktopItem (   $a_usr_id)

Add desktop item.

public

Parameters
intusr_id

Definition at line 345 of file class.ilParticipant.php.

References ilObjUser\_addDesktopItem(), and ilObjUser\_isDesktopItem().

Referenced by add().

{
if(!ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id,$this->type))
{
ilObjUser::_addDesktopItem($a_usr_id, $this->ref_id,$this->type);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilParticipant::checkLastAdmin (   $a_usr_ids)

Check if user for deletion are last admins.

public

Parameters
arrayarray of user ids for deletion

Definition at line 419 of file class.ilParticipant.php.

References $data, $query, $res, IL_CRS_ADMIN, and IL_GRP_ADMIN.

{
global $ilDB;
$admin_role_id =
$this->type == 'crs' ?
$this->role_data[IL_CRS_ADMIN] :
$this->role_data[IL_GRP_ADMIN];
$query = "
SELECT COUNT(rolesusers.usr_id) cnt
FROM object_data rdata
LEFT JOIN rbac_ua rolesusers
ON rolesusers.rol_id = rdata.obj_id
WHERE rdata.obj_id = %s
";
$query .= ' AND '.$ilDB->in('rolesusers.usr_id', $a_usr_ids, true, 'integer');
$res = $ilDB->queryF($query, array('integer'), array($admin_role_id));
$data = $ilDB->fetchAssoc($res);
return (int)$data['cnt'] > 0;
}
ilParticipant::delete (   $a_usr_id)

Drop user from all roles.

public

Parameters
intusr_id

Definition at line 297 of file class.ilParticipant.php.

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

{
global $rbacadmin,$ilDB, $ilAppEventHandler;
$this->dropDesktopItem($a_usr_id);
foreach($this->roles as $role_id)
{
$rbacadmin->deassignUser($role_id,$a_usr_id);
}
$query = "DELETE FROM obj_members ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
"AND obj_id = ".$ilDB->quote($this->obj_id ,'integer');
$res = $ilDB->manipulate($query);
if($this->type == 'crs')
{
// Add event: used for ecs accounts
$ilAppEventHandler->raise("Modules/Course", "deleteParticipant", array('obj_id' => $this->obj_id, 'usr_id' => $a_usr_id));
}
return true;
}

+ Here is the call graph for this function:

ilParticipant::deleteSubscriber (   $a_usr_id)

Delete subsciber.

public

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

References $query, and $res.

Referenced by add().

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

+ Here is the caller graph for this function:

ilParticipant::dropDesktopItem (   $a_usr_id)

Drop desktop item.

public

Parameters
intusr_id

Definition at line 361 of file class.ilParticipant.php.

References ilObjUser\_dropDesktopItem(), and ilObjUser\_isDesktopItem().

Referenced by delete().

{
if(ilObjUser::_isDesktopItem($a_usr_id, $this->ref_id,$this->type))
{
ilObjUser::_dropDesktopItem($a_usr_id, $this->ref_id,$this->type);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilParticipant::getNumberOfMembers ( )

Definition at line 109 of file class.ilParticipant.php.

References $numMembers.

{
}
ilParticipant::getUserId ( )

get user id

Returns
int

Definition at line 74 of file class.ilParticipant.php.

References $usr_id.

Referenced by isBlocked(), and readParticipantStatus().

{
return $this->usr_id;
}

+ Here is the caller graph for this function:

ilParticipant::isAdmin ( )

Definition at line 94 of file class.ilParticipant.php.

References $admins.

{
return $this->admins;
}
ilParticipant::isAssigned ( )

Definition at line 84 of file class.ilParticipant.php.

References $participants.

{
return (bool) $this->participants;
}
ilParticipant::isBlocked ( )

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

References getUserId().

{
return (bool) $this->participants_status[$this->getUserId()]['blocked'];
}

+ Here is the call graph for this function:

ilParticipant::isMember ( )

Definition at line 89 of file class.ilParticipant.php.

References $members.

{
return (bool) $this->members;
}
ilParticipant::isParticipant ( )

Definition at line 104 of file class.ilParticipant.php.

References $participants.

{
return (bool) $this->participants;
}
ilParticipant::isTutor ( )

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

References $tutors.

{
return (bool) $this->tutors;
}
ilParticipant::readParticipant ( )
protected

Read participant.

Returns
void

Definition at line 119 of file class.ilParticipant.php.

References $ilLog, $title, IL_CRS_ADMIN, IL_CRS_MEMBER, IL_CRS_TUTOR, IL_GRP_ADMIN, and IL_GRP_MEMBER.

Referenced by __construct().

{
global $rbacreview,$ilObjDataCache,$ilLog;
$rolf = $rbacreview->getRoleFolderOfObject($this->ref_id);
if(!isset($rolf['ref_id']) or !$rolf['ref_id'])
{
$title = $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->ref_id));
#$ilLog->write(__METHOD__.': Found object without role folder. Ref_id: '.$this->ref_id.', title: '.$title);
#$ilLog->logStack();
return false;
}
$this->roles = $rbacreview->getRolesOfRoleFolder($rolf['ref_id'],false);
$users = array();
$this->participants = array();
$this->members = $this->admins = $this->tutors = array();
$member_roles = array();
foreach($this->roles as $role_id)
{
$title = $ilObjDataCache->lookupTitle($role_id);
switch(substr($title,0,8))
{
case 'il_crs_m':
$member_roles[] = $role_id;
$this->role_data[IL_CRS_MEMBER] = $role_id;
if($rbacreview->isAssigned($this->getUserId(),$role_id))
{
$this->participants = true;
$this->members = true;
}
break;
case 'il_crs_a':
$this->role_data[IL_CRS_ADMIN] = $role_id;
if($rbacreview->isAssigned($this->getUserId(),$role_id))
{
$this->participants = true;
$this->admins = true;
}
break;
case 'il_crs_t':
$this->role_data[IL_CRS_TUTOR] = $role_id;
if($rbacreview->isAssigned($this->getUserId(),$role_id))
{
$this->participants = true;
$this->tutors = true;
}
break;
case 'il_grp_a':
$this->role_data[IL_GRP_ADMIN] = $role_id;
if($rbacreview->isAssigned($this->getUserId(),$role_id))
{
$this->participants = true;
$this->admins = true;
}
break;
case 'il_grp_m':
$member_roles[] = $role_id;
$this->role_data[IL_GRP_MEMBER] = $role_id;
if($rbacreview->isAssigned($this->getUserId(),$role_id))
{
$this->participants = true;
$this->members = true;
}
break;
default:
$member_roles[] = $role_id;
if($rbacreview->isAssigned($this->getUserId(),$role_id))
{
$this->participants = true;
$this->members = true;
}
break;
}
}
$this->numMembers = $rbacreview->getNumberOfAssignedUsers((array) $member_roles);
}

+ Here is the caller graph for this function:

ilParticipant::readParticipantStatus ( )
protected

Read participant status ilDB $ilDB.

Definition at line 211 of file class.ilParticipant.php.

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

Referenced by __construct().

{
global $ilDB;
$query = "SELECT * FROM obj_members ".
"WHERE obj_id = ".$ilDB->quote($this->obj_id ,'integer')." ".
'AND usr_id = '.$ilDB->quote($this->getUserId(),'integer');
$res = $ilDB->query($query);
$this->participants_status = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->participants_status[$this->getUserId()]['blocked'] = $row->blocked;
$this->participants_status[$this->getUserId()]['notification'] = $row->notification;
$this->participants_status[$this->getUserId()]['passed'] = $row->passed;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilParticipant::updateNotification (   $a_usr_id,
  $a_notification 
)

Update notification status.

public

Parameters
intusr_id
boolpassed

Definition at line 379 of file class.ilParticipant.php.

References $query, and $res.

{
global $ilDB;
$this->participants_status[$a_usr_id]['notification'] = (int) $a_notification;
$query = "SELECT * FROM obj_members ".
"WHERE obj_id = ".$ilDB->quote($this->obj_id ,'integer')." ".
"AND usr_id = ".$ilDB->quote($a_usr_id ,'integer');
$res = $ilDB->query($query);
if($res->numRows())
{
$query = "UPDATE obj_members SET ".
"notification = ".$ilDB->quote((int) $a_notification ,'integer')." ".
"WHERE obj_id = ".$ilDB->quote($this->obj_id ,'integer')." ".
"AND usr_id = ".$ilDB->quote($a_usr_id ,'integer');
}
else
{
$query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) ".
"VALUES ( ".
$ilDB->quote((int) $a_notification ,'integer').", ".
$ilDB->quote($this->obj_id ,'integer').", ".
$ilDB->quote($a_usr_id ,'integer').", ".
$ilDB->quote(0,'integer').", ".
$ilDB->quote(0,'integer').
")";
}
$res = $ilDB->manipulate($query);
return true;
}

Field Documentation

ilParticipant::$admins = false
private

Definition at line 42 of file class.ilParticipant.php.

Referenced by isAdmin().

ilParticipant::$members = false
private

Definition at line 44 of file class.ilParticipant.php.

Referenced by isMember().

ilParticipant::$numMembers = 0
private

Definition at line 46 of file class.ilParticipant.php.

Referenced by getNumberOfMembers().

ilParticipant::$obj_id = 0
private

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

ilParticipant::$participants = false
private

Definition at line 41 of file class.ilParticipant.php.

Referenced by isAssigned(), and isParticipant().

ilParticipant::$participants_status = array()
private

Definition at line 48 of file class.ilParticipant.php.

ilParticipant::$ref_id = 0
private

Definition at line 39 of file class.ilParticipant.php.

ilParticipant::$tutors = false
private

Definition at line 43 of file class.ilParticipant.php.

Referenced by isTutor().

ilParticipant::$type = ''
protected

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

ilParticipant::$usr_id = 0
private

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

Referenced by getUserId().


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