ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

References $user.

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

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.

Referenced by getChatNameSuggestions().

139  {
140  $anonymous_name = str_replace(
141  '#', mt_rand( 0, 10000 ), $this->room->getSetting('autogen_usernames')
142  );
143 
144  return $anonymous_name;
145  }
+ 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.

Referenced by getChatNameSuggestions().

163  {
164  return $this->user->getPublicName();
165  }
+ 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.

Referenced by getChatNameSuggestions().

153  {
154  return $this->user->getLogin();
155  }
+ 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.

Referenced by getChatNameSuggestions().

173  {
174  $firstname = $this->user->getFirstname();
175 
176  return $firstname{0} . '. ' . $this->user->getLastname();
177  }
+ 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.

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

Referenced by ilChatroomViewTask\cancelJoin().

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  }
buildAnonymousName()
Returns an anonymous username containing a random number.
buildFullname()
Returns users first & lastname.
buildShortname()
Returns first letter of users firstname, followed by dot lastname.
if(!is_array($argv)) $options
buildLogin()
Returns user login.
+ Here is the call graph for this function:
+ Here is the caller 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.

References $_SESSION.

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

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  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
+ 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.

References $_SESSION, and $username.

Referenced by ilChatroom\addHistoryEntry(), ilChatroomViewTask\cancelJoin(), and ilObjChatroom\getPersonalInformation().

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  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
+ 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.

References $_SESSION, and $username.

Referenced by ilChatroomViewTask\cancelJoin().

83  {
84  $this->username = htmlspecialchars( $username );
85  $_SESSION['chat'][$this->room->getRoomId()]['username'] = $this->username;
86  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
+ Here is the caller graph for this function:

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: