ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 33 of file Subscriber.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 35 of file Subscriber.php.

36  {
37  }

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 93 of file Subscriber.php.

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

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

93  : array
94  {
95  $usrIds = array_filter(array_map('intval', array_map('trim', $usrIds)));
96 
99 
100  $publicData = ilUserUtil::getNamePresentation($usrIds, true, false, '', false, true, false, true);
101 
102  $data = [];
103 
104  foreach ($usrIds as $usr_id) {
105  $publicImage = $publicData[$usr_id]['img'] ?? '';
106  $publicName = '';
107 
108  if (isset($publicData[$usr_id])) {
109  $login = '';
110  if (isset($publicData[$usr_id]['login'])) {
111  $publicName = $login = $publicData[$usr_id]['login'];
112  }
113 
114  if (isset($publicData[$usr_id]['public_profile']) && $publicData[$usr_id]['public_profile']) {
115  $publicName = implode(' ', array_filter(array_map('trim', [
116  (string) ($publicData[$usr_id]['firstname'] ?? ''),
117  (string) ($publicData[$usr_id]['lastname'] ?? ''),
118  ])));
119 
120  if ($publicName === '') {
121  $publicName = $login;
122  }
123  }
124  }
125 
126  $data[$usr_id] = [
127  'public_name' => $publicName,
128  'profile_image' => $publicImage
129  ];
130  }
131 
133 
134  return $data;
135  }
static setTokenMaxLifetimeInSeconds(int $token_max_lifetime_in_seconds)
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='ilpublicuserprofilegui')
Default behaviour is:
static getTokenMaxLifetimeInSeconds()
+ 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 42 of file Subscriber.php.

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

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

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