ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilChatroomUser Class Reference

Class ilChatroomUser. More...

+ Collaboration diagram for ilChatroomUser:

Public Member Functions

 __construct (ilObjUser $user, ilChatroom $chatroom)
 Constructor Requires ilObjUser and sets $this->user and $this->room using given $user and $chatroom. More...
 
 getUserId ()
 Returns Ilias User ID. More...
 
 getUsername ()
 Returns username from Object or SESSION. More...
 
 setUsername ($username)
 Sets and stores given username in SESSION. More...
 
 getChatNameSuggestions ()
 Returns an array of chat-name suggestions. More...
 
 buildAnonymousName ()
 Returns an anonymous username containing a random number. More...
 
 buildFullname ()
 Returns users first & lastname. More...
 
 buildShortname ()
 Returns first letter of users firstname, followed by dot lastname. More...
 
 buildLogin ()
 Returns user login. 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 36 of file class.ilChatroomUser.php.

37 {
38 $this->user = $user;
39 $this->room = $chatroom;
40 }
user()
Definition: user.php:4

References $user, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildAnonymousName()

ilChatroomUser::buildAnonymousName ( )

Returns an anonymous username containing a random number.

Returns
string

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

129 {
130 $anonymous_name = str_replace(
131 '#', mt_rand(0, 10000), $this->room->getSetting('autogen_usernames')
132 );
133
134 return $anonymous_name;
135 }

Referenced by getChatNameSuggestions().

+ Here is the caller graph for this function:

◆ buildFullname()

ilChatroomUser::buildFullname ( )

Returns users first & lastname.

Returns
string

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

142 {
143 $tmp = $this->user->getPref('public_profile');
144 $this->user->setPref('public_profile', 'y');
145 $pn = $this->user->getPublicName();
146 $this->user->setPref('public_profile', $tmp);
147 return $pn;
148 }

References user().

Referenced by getChatNameSuggestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLogin()

ilChatroomUser::buildLogin ( )

Returns user login.

Returns
string

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

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

References user().

Referenced by getChatNameSuggestions().

+ Here is the call graph for this function:
+ 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 154 of file class.ilChatroomUser.php.

155 {
156 $firstname = $this->user->getFirstname();
157
158 return $firstname{0} . '. ' . $this->user->getLastname();
159 }

References user().

Referenced by getChatNameSuggestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChatNameSuggestions()

ilChatroomUser::getChatNameSuggestions ( )

Returns an array of chat-name suggestions.

Returns
array

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

107 {
108 $options = array();
109
110 if($this->user->isAnonymous())
111 {
112 $options['anonymousName'] = $this->buildAnonymousName();
113 }
114 else
115 {
116 $options['fullname'] = $this->buildFullname();
117 $options['shortname'] = $this->buildShortname();
118 $options['login'] = $this->buildLogin();
119 }
120
121 return $options;
122 }
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(), buildShortname(), and user().

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

49 {
50 $user_id = $this->user->getId();
51
52 if($this->user->isAnonymous())
53 {
54 if(isset($_SESSION['chat'][$this->room->getRoomId()]['user_id']))
55 {
56 return $_SESSION['chat'][$this->room->getRoomId()]['user_id'];
57 }
58 else
59 {
60 $user_id = mt_rand(-99999, -20);
61 $_SESSION['chat'][$this->room->getRoomId()]['user_id'] = $user_id;
62 return $user_id;
63 }
64 }
65 else
66 {
67 return $user_id;
68 }
69 }
$_SESSION["AccountId"]

References $_SESSION, and user().

Referenced by ilChatroom\addPrivateRoom(), ilChatroom\getLastSession(), and ilObjChatroom\getPersonalInformation().

+ Here is the call graph for this function:
+ 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 76 of file class.ilChatroomUser.php.

77 {
78 if($this->username)
79 {
80 return $this->username;
81 }
82 else if($_SESSION['chat'][$this->room->getRoomId()]['username'])
83 {
84 return $_SESSION['chat'][$this->room->getRoomId()]['username'];
85 }
86 else
87 {
88 return $this->user->getLogin();
89 }
90 }

References $_SESSION, $username, and user().

Referenced by ilObjChatroom\getPersonalInformation().

+ Here is the call graph for this function:
+ 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 96 of file class.ilChatroomUser.php.

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

References $_SESSION, and $username.

Field Documentation

◆ $room

ilChatroomUser::$room
private

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

◆ $user

ilChatroomUser::$user
private

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

Referenced by __construct().

◆ $username

ilChatroomUser::$username
private

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

Referenced by getUsername(), and setUsername().


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