ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\OnScreenChat\Repository\Subscriber Class Reference
+ Collaboration diagram for ILIAS\OnScreenChat\Repository\Subscriber:

Public Member Functions

 __construct (\ilDBInterface $db, \ilObjUser $user)
 Subscriber constructor. More...
 
 getInitialUserProfileData ()
 
 getDataByUserIds (array $usrIds)
 

Protected Attributes

 $db
 
 $user
 

Detailed Description

Definition at line 10 of file Subscriber.php.

Constructor & Destructor Documentation

◆ __construct()

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

Subscriber constructor.

Parameters
\ilDBInterface$db
\ilObjUser$user

Definition at line 22 of file Subscriber.php.

References ILIAS\OnScreenChat\Repository\Subscriber\$db, ILIAS\OnScreenChat\Repository\Subscriber\$user, and 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
Exceptions

ilWACException

Definition at line 80 of file Subscriber.php.

80 : array
81 {
82 $usrIds = array_filter(array_map('intval', array_map('trim', $usrIds)));
83
86
87 $publicData = \ilUserUtil::getNamePresentation($usrIds, true, false, '', false, true, false, true);
88
89 $data = [];
90
91 foreach ($usrIds as $usr_id) {
92 $publicImage = isset($publicData[$usr_id]) && isset($publicData[$usr_id]['img']) ? $publicData[$usr_id]['img'] : '';
93
94 $publicName = '';
95 if (isset($publicData[$usr_id])) {
96 $login = '';
97 if (isset($publicData[$usr_id]['login'])) {
98 $publicName = $login = (string) $publicData[$usr_id]['login'];
99 }
100
101 if (isset($publicData[$usr_id]['public_profile']) && $publicData[$usr_id]['public_profile']) {
102 $publicName = implode(' ', array_filter(array_map('trim', [
103 (string) $publicData[$usr_id]['firstname'],
104 (string) $publicData[$usr_id]['lastname'],
105 ])));
106
107 if ($publicName === '') {
108 $publicName = $login;
109 }
110 }
111 }
112
113 $data[$usr_id] = array(
114 'public_name' => $publicName,
115 'profile_image' => $publicImage
116 );
117 }
118
120
121 return $data;
122 }
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()
$login
Definition: cron.php:13
$data
Definition: storeScorm.php:23

References $data, $login, 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
int[]
Exceptions

ilWACException

Definition at line 32 of file Subscriber.php.

32 : array
33 {
34 $conversationIds = [];
35
36 $res = $this->db->queryF(
37 'SELECT DISTINCT(conversation_id) FROM osc_activity WHERE user_id = %s',
38 ['integer'],
39 [$this->user->getId()]
40 );
41 while ($row = $this->db->fetchAssoc($res)) {
42 $conversationIds[$row['conversation_id']] = $row['conversation_id'];
43 }
44
45 $res = $this->db->queryF(
46 'SELECT DISTINCT(conversation_id) FROM osc_messages 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 if (0 === count($conversationIds)) {
55 return [];
56 }
57
58 $usrIds = [];
59
60 $in = $this->db->in('id', $conversationIds, false, 'text');
61 $res = $this->db->query('SELECT DISTINCT(participants) FROM osc_conversation WHERE ' . $in);
62 while ($row = $this->db->fetchAssoc($res)) {
63 $participants = json_decode($row['participants'], true);
64
65 if (is_array($participants)) {
66 $usrIds = array_unique(array_merge($usrIds, array_map(function ($user) {
67 return $user['id'];
68 }, $participants)));
69 }
70 }
71
72 return $this->getDataByUserIds($usrIds);
73 }
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

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

Definition at line 13 of file Subscriber.php.

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

◆ $user

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

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