ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomUser Class Reference

Class ilChatroomUser. More...

+ Collaboration diagram for ilChatroomUser:

Public Member Functions

 __construct (ilObjUser $user, ilChatroom $chatroom)
 Constructor.
 getUserId ()
 Returns Ilias User ID.
 setUsername ($username)
 Sets and stores given username in SESSION.
 getUsername ()
 Returns username from Object or SESSION.
 getChatNameSuggestions ()
 Returns an array of chat-name suggestions.
 buildAnonymousName ()
 Returns an anonymous username containing a random number.
 buildLogin ()
 Returns user login.
 buildFullname ()
 Returns users first & lastname.
 buildShortname ()
 Returns first letter of users firstname, followed by dot lastname.

Private Attributes

 $user
 $username
 $room

Detailed Description

Class ilChatroomUser.

Author
Andreas Kordosz akord.nosp@m.osz@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilChatroomUser.php.

Constructor & Destructor Documentation

ilChatroomUser::__construct ( ilObjUser  $user,
ilChatroom  $chatroom 
)

Constructor.

Requires ilObjUser and sets $this->user and $this->room using given $user and $chatroom.

Parameters
ilObjUser$user
ilChatroom$chatroom

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

References $user.

{
require_once 'Services/User/classes/class.ilObjUser.php';
$this->user = $user;
$this->room = $chatroom;
}

Member Function Documentation

ilChatroomUser::buildAnonymousName ( )

Returns an anonymous username containing a random number.

Returns
string

Definition at line 138 of file class.ilChatroomUser.php.

Referenced by getChatNameSuggestions().

{
$anonymous_name = str_replace(
'#', mt_rand( 0, 10000 ), $this->room->getSetting('autogen_usernames')
);
return $anonymous_name;
}

+ Here is the caller graph for this function:

ilChatroomUser::buildFullname ( )

Returns users first & lastname.

Returns
string

Definition at line 162 of file class.ilChatroomUser.php.

Referenced by getChatNameSuggestions().

{
return $this->user->getPublicName();
}

+ Here is the caller graph for this function:

ilChatroomUser::buildLogin ( )

Returns user login.

Returns
string

Definition at line 152 of file class.ilChatroomUser.php.

Referenced by getChatNameSuggestions().

{
return $this->user->getLogin();
}

+ Here is the caller graph for this function:

ilChatroomUser::buildShortname ( )

Returns first letter of users firstname, followed by dot lastname.

Returns
string

Definition at line 172 of file class.ilChatroomUser.php.

Referenced by getChatNameSuggestions().

{
$firstname = $this->user->getFirstname();
return $firstname{0} . '. ' . $this->user->getLastname();
}

+ Here is the caller graph for this function:

ilChatroomUser::getChatNameSuggestions ( )

Returns an array of chat-name suggestions.

Returns
array

Definition at line 115 of file class.ilChatroomUser.php.

References $options, buildAnonymousName(), buildFullname(), buildLogin(), and buildShortname().

{
$options = array();
if($this->user->isAnonymous())
{
$options['anonymousName'] = $this->buildAnonymousName();
}
else
{
$options['fullname'] = $this->buildFullname();
$options['shortname'] = $this->buildShortname();
$options['login'] = $this->buildLogin();
}
return $options;
}

+ Here is the call graph for this function:

ilChatroomUser::getUserId ( )

Returns Ilias User ID.

If user is anonymous, a random negative User ID is created, stored in SESSION, and returned.

Parameters
ilObjUser$user
Returns
integer

Definition at line 54 of file class.ilChatroomUser.php.

References $_SESSION.

Referenced by ilChatroom\addPrivateRoom(), ilChatroomPrivateRoomTask\buildMessage(), ilChatroomServerConnector\createPrivateRoom(), ilChatroom\getLastSession(), and ilObjChatroom\getPersonalInformation().

{
$user_id = $this->user->getId();
if($this->user->isAnonymous())
{
if(isset($_SESSION['chat'][$this->room->getRoomId()]['user_id']))
{
return $_SESSION['chat'][$this->room->getRoomId()]['user_id'];
}
else
{
$user_id = mt_rand(-99999, -20);
$_SESSION['chat'][$this->room->getRoomId()]['user_id'] = $user_id;
return $user_id;
}
}
else
{
return $user_id;
}
}

+ Here is the caller graph for this function:

ilChatroomUser::getUsername ( )

Returns username from Object or SESSION.

If no Username is set, the login name will be returned.

Returns
string

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

References $_SESSION, and $username.

Referenced by ilObjChatroom\getPersonalInformation().

{
if($this->username)
{
}
else if($_SESSION['chat'][$this->room->getRoomId()]['username'])
{
return $_SESSION['chat'][$this->room->getRoomId()]['username'];
}
else
{
return $this->user->getLogin();
}
}

+ Here is the caller graph for this function:

ilChatroomUser::setUsername (   $username)

Sets and stores given username in SESSION.

Parameters
string$username

Definition at line 82 of file class.ilChatroomUser.php.

References $_SESSION, and $username.

{
$this->username = htmlspecialchars( $username );
$_SESSION['chat'][$this->room->getRoomId()]['username'] = $this->username;
}

Field Documentation

ilChatroomUser::$room
private

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

ilChatroomUser::$user
private

Definition at line 18 of file class.ilChatroomUser.php.

Referenced by __construct().

ilChatroomUser::$username
private

Definition at line 23 of file class.ilChatroomUser.php.

Referenced by getUsername(), and setUsername().


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