19 declare(strict_types=1);
36 $this->room = $chatroom;
51 $user_id = $this->
user->getId();
53 if ($this->
user->isAnonymous()) {
55 if (isset(
$session[$this->room->getRoomId()][
'user_id'])) {
56 return $session[$this->room->getRoomId()][
'user_id'];
59 $user_id = random_int(-99999, -20);
61 $session[$this->room->getRoomId()][
'user_id'] = $user_id;
75 if ($this->username) {
82 isset(
$session[$this->room->getRoomId()][
'username']) &&
83 $session[$this->room->getRoomId()][
'username']
85 return $session[$this->room->getRoomId()][
'username'];
88 return $this->
user->getLogin();
97 $this->username = htmlspecialchars($username);
112 if ($this->
user->isAnonymous()) {
127 (
string) random_int(0, 10000),
128 $this->room->getSetting(
'autogen_usernames')
134 $tmp = $this->
user->getPref(
'public_profile');
135 $this->
user->setPref(
'public_profile',
'y');
136 $public_name = $this->
user->getPublicName();
137 $this->
user->setPref(
'public_profile', $tmp);
148 $firstname = $this->
user->getFirstname();
150 return $firstname[0] .
'. ' . $this->
user->getLastname();
155 return $this->
user->getLogin();
162 $username = htmlspecialchars(trim($username));
166 $rset = $DIC->database()->query(
167 'SELECT * FROM chatroom_users WHERE ' .
168 $DIC->database()->like(
'userdata',
'text',
'%"login":"' . $username .
'%') .
169 ' AND room_id = ' . $DIC->database()->quote($this->room->getRoomId(),
'integer')
172 while (($row = $DIC->database()->fetchAssoc($rset))) {
173 $json = json_decode($row[
'userdata'],
true, 512, JSON_THROW_ON_ERROR);
174 $usernames[] = $json[
'login'];
178 if (in_array($uniqueName, $usernames,
true)) {
179 $uniqueName = sprintf(
'%s_%d', $username,
$index);
199 FROM chatroom_users WHERE ' . $DIC->database()->in(
'user_id', $usrIds,
false,
'integer');
201 if (null !== $roomId) {
202 $query .=
' AND room_id = ' . $DIC->database()->quote($roomId,
'integer');
206 while ($row = $DIC->database()->fetchAssoc(
$res)) {
207 $users[] = json_decode($row[
'userdata'],
false, 512, JSON_THROW_ON_ERROR);
static get(string $a_var)
getUserId()
Returns Ilias User ID.
static getUserInformation(array $usrIds, ?int $roomId=null)
setUsername(string $username)
Sets and stores given username in SESSION.
buildShortname()
Returns first letter of users firstname, followed by dot lastname.
buildUniqueUsername(string $username)
getChatNameSuggestions()
Returns an array of chat-name suggestions.
static yn2tf(string $a_yn)
getUsername()
Returns username from Object or SESSION.
__construct(ilObjUser $user, ilChatroom $chatroom)
static set(string $a_var, $a_val)
Set a value.