ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\OnScreenChat\Repository\Subscriber Class Reference
+ Collaboration diagram for ILIAS\OnScreenChat\Repository\Subscriber:

Public Member Functions

 __construct (protected ilDBInterface $db, protected ilObjUser $user)
 
 getInitialUserProfileData ()
 
 getDataByUserIds (array $usrIds)
 

Detailed Description

Definition at line 32 of file Subscriber.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\OnScreenChat\Repository\Subscriber::__construct ( protected ilDBInterface  $db,
protected ilObjUser  $user 
)

Definition at line 34 of file Subscriber.php.

35 {
36 }

Member Function Documentation

◆ getDataByUserIds()

ILIAS\OnScreenChat\Repository\Subscriber::getDataByUserIds ( array  $usrIds)
Parameters
int[]$usrIds
Returns
array<int, array{public_name: string, profile_image: string}>

Definition at line 92 of file Subscriber.php.

92 : array
93 {
94 $usrIds = array_filter(array_map('intval', array_map('trim', $usrIds)));
95
98
99 $publicData = ilUserUtil::getNamePresentation($usrIds, true, false, '', false, true, false, true);
100
101 $data = [];
102
103 foreach ($usrIds as $usr_id) {
104 $publicImage = $publicData[$usr_id]['img'] ?? '';
105 $publicName = '';
106
107 if (isset($publicData[$usr_id])) {
108 $login = '';
109 if (isset($publicData[$usr_id]['login'])) {
110 $publicName = $login = $publicData[$usr_id]['login'];
111 }
112
113 if (isset($publicData[$usr_id]['public_profile']) && $publicData[$usr_id]['public_profile']) {
114 $publicName = implode(' ', array_filter(array_map('trim', [
115 (string) ($publicData[$usr_id]['firstname'] ?? ''),
116 (string) ($publicData[$usr_id]['lastname'] ?? ''),
117 ])));
118
119 if ($publicName === '') {
120 $publicName = $login;
121 }
122 }
123 }
124
125 $data[$usr_id] = [
126 'public_name' => $publicName,
127 'profile_image' => $publicImage
128 ];
129 }
130
132
133 return $data;
134 }
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()

References $data, ilUserUtil\getNamePresentation(), ilWACSignedPath\getTokenMaxLifetimeInSeconds(), and ilWACSignedPath\setTokenMaxLifetimeInSeconds().

Referenced by ILIAS\OnScreenChat\Repository\Subscriber\getInitialUserProfileData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInitialUserProfileData()

ILIAS\OnScreenChat\Repository\Subscriber::getInitialUserProfileData ( )
Returns
array<int, array{public_name: string, profile_image: string}>

Definition at line 41 of file Subscriber.php.

41 : array
42 {
43 $conversationIds = [];
44
45 $res = $this->db->queryF(
46 'SELECT DISTINCT(conversation_id) FROM osc_activity WHERE user_id = %s',
47 ['integer'],
48 [$this->user->getId()]
49 );
50 while ($row = $this->db->fetchAssoc($res)) {
51 $conversationIds[$row['conversation_id']] = $row['conversation_id'];
52 }
53
54 $res = $this->db->queryF(
55 'SELECT DISTINCT(conversation_id) FROM osc_messages WHERE user_id = %s',
56 ['integer'],
57 [$this->user->getId()]
58 );
59 while ($row = $this->db->fetchAssoc($res)) {
60 $conversationIds[$row['conversation_id']] = $row['conversation_id'];
61 }
62
63 if (0 === count($conversationIds)) {
64 return [];
65 }
66
67 $usrIds = [];
68
69 $in = $this->db->in('id', $conversationIds, false, 'text');
70 $res = $this->db->query('SELECT DISTINCT(participants) FROM osc_conversation WHERE ' . $in);
71 while ($row = $this->db->fetchAssoc($res)) {
72 $participants = json_decode((string) $row['participants'], true, 512, JSON_THROW_ON_ERROR);
73
74 if (is_array($participants)) {
75 $usrIds = array_unique(array_merge($usrIds, array_filter(array_map(static function ($user): int {
76 if (is_array($user) && isset($user['id'])) {
77 return (int) $user['id'];
78 }
79
80 return 0;
81 }, $participants))));
82 }
83 }
84
85 return $this->getDataByUserIds($usrIds);
86 }
$res
Definition: ltiservices.php:69

References $res, ILIAS\OnScreenChat\Repository\Subscriber\getDataByUserIds(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: