ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilChatroomUser Class Reference

Class ilChatroomUser. More...

+ Collaboration diagram for ilChatroomUser:

Public Member Functions

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

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

◆ __construct()

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.

40 {
41 require_once 'Services/User/classes/class.ilObjUser.php';
42
43 $this->user = $user;
44 $this->room = $chatroom;
45 }

References $user.

Member Function Documentation

◆ buildAnonymousName()

ilChatroomUser::buildAnonymousName ( )

Returns an anonymous username containing a random number.

Returns
string

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

139 {
140 $anonymous_name = str_replace(
141 '#', mt_rand( 0, 10000 ), $this->room->getSetting('autogen_usernames')
142 );
143
144 return $anonymous_name;
145 }

Referenced by getChatNameSuggestions().

+ Here is the caller graph for this function:

◆ buildFullname()

ilChatroomUser::buildFullname ( )

Returns users first & lastname.

Returns
string

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

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

Referenced by getChatNameSuggestions().

+ Here is the caller graph for this function:

◆ buildLogin()

ilChatroomUser::buildLogin ( )

Returns user login.

Returns
string

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

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

Referenced by getChatNameSuggestions().

+ Here is the caller graph for this function:

◆ buildShortname()

ilChatroomUser::buildShortname ( )

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

Returns
string

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

173 {
174 $firstname = $this->user->getFirstname();
175
176 return $firstname{0} . '. ' . $this->user->getLastname();
177 }

Referenced by getChatNameSuggestions().

+ Here is the caller graph for this function:

◆ getChatNameSuggestions()

ilChatroomUser::getChatNameSuggestions ( )

Returns an array of chat-name suggestions.

Returns
array

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

116 {
117 $options = array();
118
119 if($this->user->isAnonymous())
120 {
121 $options['anonymousName'] = $this->buildAnonymousName();
122 }
123 else
124 {
125 $options['fullname'] = $this->buildFullname();
126 $options['shortname'] = $this->buildShortname();
127 $options['login'] = $this->buildLogin();
128 }
129
130 return $options;
131 }
buildFullname()
Returns users first & lastname.
buildAnonymousName()
Returns an anonymous username containing a random number.
buildShortname()
Returns first letter of users firstname, followed by dot lastname.
buildLogin()
Returns user login.
if(!is_array($argv)) $options

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

+ Here is the call graph for this function:

◆ getUserId()

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.

55 {
56 $user_id = $this->user->getId();
57
58 if($this->user->isAnonymous())
59 {
60 if(isset($_SESSION['chat'][$this->room->getRoomId()]['user_id']))
61 {
62 return $_SESSION['chat'][$this->room->getRoomId()]['user_id'];
63 }
64 else
65 {
66 $user_id = mt_rand(-99999, -20);
67 $_SESSION['chat'][$this->room->getRoomId()]['user_id'] = $user_id;
68 return $user_id;
69 }
70 }
71 else
72 {
73 return $user_id;
74 }
75 }
$_SESSION["AccountId"]

References $_SESSION.

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

+ Here is the caller graph for this function:

◆ getUsername()

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.

95 {
96 if($this->username)
97 {
98 return $this->username;
99 }
100 else if($_SESSION['chat'][$this->room->getRoomId()]['username'])
101 {
102 return $_SESSION['chat'][$this->room->getRoomId()]['username'];
103 }
104 else
105 {
106 return $this->user->getLogin();
107 }
108 }

References $_SESSION, and $username.

Referenced by ilObjChatroom\getPersonalInformation().

+ Here is the caller graph for this function:

◆ setUsername()

ilChatroomUser::setUsername (   $username)

Sets and stores given username in SESSION.

Parameters
string$username

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

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

References $_SESSION, and $username.

Field Documentation

◆ $room

ilChatroomUser::$room
private

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

◆ $user

ilChatroomUser::$user
private

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

Referenced by __construct().

◆ $username

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: