ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\OnScreenChat\Repository\Subscriber Class Reference
+ Collaboration diagram for ILIAS\OnScreenChat\Repository\Subscriber:

Public Member Functions

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

Protected Attributes

ilDBInterface $db
 
ilObjUser $user
 

Detailed Description

Definition at line 33 of file Subscriber.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 38 of file Subscriber.php.

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

+ Here is the call graph for this function:

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

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

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

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

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

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

Field Documentation

◆ $db

ilDBInterface ILIAS\OnScreenChat\Repository\Subscriber::$db
protected

Definition at line 35 of file Subscriber.php.

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

◆ $user

ilObjUser ILIAS\OnScreenChat\Repository\Subscriber::$user
protected

Definition at line 36 of file Subscriber.php.

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


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