4 require_once
'Services/User/classes/class.ilObjUser.php';
39 $this->room = $chatroom;
50 $user_id = $this->
user->getId();
52 if($this->
user->isAnonymous())
54 if(isset(
$_SESSION[
'chat'][$this->room->getRoomId()][
'user_id']))
56 return $_SESSION[
'chat'][$this->room->getRoomId()][
'user_id'];
60 $user_id = mt_rand(-99999, -20);
61 $_SESSION[
'chat'][$this->room->getRoomId()][
'user_id'] = $user_id;
82 else if(
$_SESSION[
'chat'][$this->room->getRoomId()][
'username'])
84 return $_SESSION[
'chat'][$this->room->getRoomId()][
'username'];
88 return $this->
user->getLogin();
98 $this->username = htmlspecialchars(
$username);
110 if($this->
user->isAnonymous())
130 $anonymous_name = str_replace(
131 '#', mt_rand(0, 10000), $this->room->getSetting(
'autogen_usernames')
134 return $anonymous_name;
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);
156 $firstname = $this->
user->getFirstname();
158 return $firstname{0} .
'. ' . $this->
user->getLastname();
167 return $this->
user->getLogin();
174 public function buildUniqueUsername(
$username)
181 $usernames =
array();
184 $rset = $ilDB->query(
'SELECT * FROM chatroom_users WHERE ' 185 . $ilDB->like(
'userdata',
'text',
'%"login":"' .
$username .
'%')
186 .
' AND room_id = ' . $ilDB->quote($this->room->getRoomId(),
'integer')
189 while((
$row = $ilDB->fetchAssoc($rset)))
191 $json = json_decode(
$row[
'userdata'],
true);
192 $usernames[] = $json[
'login'];
195 for($index = 1; $index <= \count($usernames); $index++)
197 if(in_array($uniqueName, $usernames))
199 $uniqueName = sprintf(
'%s_%d',
$username, $index);
buildAnonymousName()
Returns an anonymous username containing a random number.
getUserId()
Returns Ilias User ID.
setUsername($username)
Sets and stores given username in SESSION.
buildFullname()
Returns users first & lastname.
buildShortname()
Returns first letter of users firstname, followed by dot lastname.
if(!is_array($argv)) $options
Create styles array
The data for the language used.
getChatNameSuggestions()
Returns an array of chat-name suggestions.
getUsername()
Returns username from Object or SESSION.
__construct(ilObjUser $user, ilChatroom $chatroom)
Constructor Requires ilObjUser and sets $this->user and $this->room using given $user and $chatroom...
buildLogin()
Returns user login.