ILIAS  Release_4_2_x_branch Revision 61807
 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 13 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 33 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 142 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 166 of file class.ilChatroomUser.php.

Referenced by getChatNameSuggestions().

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

+ Here is the caller graph for this function:

ilChatroomUser::buildLogin ( )

Returns user login.

Returns
string

Definition at line 156 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 176 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 117 of file class.ilChatroomUser.php.

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

Referenced by ilChatroomViewTask\showNameSelection().

{
$firstname = $this->user->getFirstname();
$lastname = $this->user->getLastname();
$options = array();
if( $this->user->getId() == ANONYMOUS_USER_ID )
{
$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:

+ Here is the caller 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 48 of file class.ilChatroomUser.php.

References $_SESSION.

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

{
$user_id = $this->user->getId();
if( $user_id == ANONYMOUS_USER_ID )
{
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 89 of file class.ilChatroomUser.php.

References $_SESSION, and $username.

Referenced by ilChatroom\connectUser(), ilObjChatroom\getPersonalInformation(), and ilChatroomViewTask\showRoom().

{
/*
if( !isset( $this->username ) &&
!$_SESSION['chat'][$this->room->getRoomId()]['username'] )
{
throw new Exception( 'no username set' );
}
*/
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 77 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 22 of file class.ilChatroomUser.php.

ilChatroomUser::$user
private

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

Referenced by __construct().

ilChatroomUser::$username
private

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

Referenced by getUsername(), and setUsername().


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