4require_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 '
186 .
' AND room_id = ' .
$ilDB->quote($this->room->getRoomId(),
'integer')
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))
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
__construct(ilObjUser $user, ilChatroom $chatroom)
Constructor Requires ilObjUser and sets $this->user and $this->room using given $user and $chatroom.
getChatNameSuggestions()
Returns an array of chat-name suggestions.
buildFullname()
Returns users first & lastname.
getUserId()
Returns Ilias User ID.
buildAnonymousName()
Returns an anonymous username containing a random number.
buildShortname()
Returns first letter of users firstname, followed by dot lastname.
setUsername($username)
Sets and stores given username in SESSION.
buildLogin()
Returns user login.
getUsername()
Returns username from Object or SESSION.
if(!is_array($argv)) $options