19 declare(strict_types=1);
49 if ($this->
user->isAnonymous()) {
51 if (isset($session[$this->room->getRoomId()][
'user_id'])) {
52 return $session[$this->room->getRoomId()][
'user_id'];
57 $session[$this->room->getRoomId()][
'user_id'] =
$user_id;
70 if ($this->username) {
77 isset($session[$this->room->getRoomId()][
'username']) &&
78 $session[$this->room->getRoomId()][
'username']
80 return $session[$this->room->getRoomId()][
'username'];
83 return $this->
user->getPublicName();
91 $this->username = htmlspecialchars($username);
100 if ($this->profile_picture_visible ===
null) {
101 $this->profile_picture_visible =
ilSession::get(
'chat')[$this->room->getRoomId()][
'profile-picture-visible'] ??
false;
109 $session[$this->room->getRoomId()][
'profile-picture-visible'] = $show_it;
121 if ($this->
user->isAnonymous()) {
136 (
string) random_int(0, 10000),
137 $this->room->getSetting(
'autogen_usernames')
143 $tmp = $this->
user->getPref(
'public_profile');
144 $this->
user->setPref(
'public_profile',
'y');
145 $public_name = $this->
user->getPublicName();
146 $this->
user->setPref(
'public_profile', $tmp);
156 $firstname = $this->
user->getFirstname();
158 return $firstname[0] .
'. ' . $this->
user->getLastname();
163 return $this->
user->getLogin();
170 $username = htmlspecialchars(trim($username));
174 $rset = $DIC->database()->query(
175 'SELECT * FROM chatroom_users WHERE ' .
176 $DIC->database()->like(
'userdata',
'text',
'%"login":"' . $username .
'%') .
177 ' AND room_id = ' . $DIC->database()->quote($this->room->getRoomId(),
'integer')
180 while (($row = $DIC->database()->fetchAssoc($rset))) {
181 $json = json_decode($row[
'userdata'],
true, 512, JSON_THROW_ON_ERROR);
182 $usernames[] = $json[
'login'];
185 for ($index = 1, $indexMax = count($usernames); $index <= $indexMax; $index++) {
186 if (in_array($uniqueName, $usernames,
true)) {
187 $uniqueName = sprintf(
'%s_%d', $username, $index);
205 FROM chatroom_users WHERE ' . $DIC->database()->in(
'user_id', $usrIds,
false,
'integer');
207 if (
null !== $roomId) {
208 $query .=
' AND room_id = ' . $DIC->database()->quote($roomId,
'integer');
211 $res = $DIC->database()->query($query);
212 while ($row = $DIC->database()->fetchAssoc(
$res)) {
213 $users[] = json_decode($row[
'userdata'],
false, 512, JSON_THROW_ON_ERROR);
static get(string $a_var)
__construct(private readonly ilObjUser $user, private readonly ilChatroom $room)
getUserId()
Returns Ilias User ID.
setProfilePictureVisible(bool $show_it)
bool $profile_picture_visible
isProfilePictureVisible()
static getUserInformation(array $usrIds, ?int $roomId=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return 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.
static set(string $a_var, $a_val)
Set a value.