ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilOnScreenChatUserDataProvider Class Reference

Class ilOnScreenChatUserDataProvider. More...

+ Collaboration diagram for ilOnScreenChatUserDataProvider:

Public Member Functions

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

Protected Attributes

 $db
 
 $user
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOnScreenChatUserDataProvider::__construct ( \ilDBInterface  $db,
\ilObjUser  $user 
)

ilOnScreenChatUserDataProvider constructor.

Parameters
\ilDBInterface$db
\ilObjUser$user

Definition at line 24 of file class.ilOnScreenChatUserDataProvider.php.

References $db, $user, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDataByUserIds()

ilOnScreenChatUserDataProvider::getDataByUserIds ( array  $usrIds)
Parameters
int[]$usrIds
Exceptions
ilWACException
Returns
$data

Definition at line 82 of file class.ilOnScreenChatUserDataProvider.php.

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

Referenced by getInitialUserProfileData().

83  {
84  $usrIds = array_filter(array_map('intval', array_map('trim', $usrIds)));
85 
88 
89  $publicData = \ilUserUtil::getNamePresentation($usrIds, true, false, '', false, true, false, true);
90 
91  $data = [];
92 
93  foreach ($usrIds as $usr_id) {
94  $publicImage = isset($publicData[$usr_id]) && isset($publicData[$usr_id]['img']) ? $publicData[$usr_id]['img'] : '';
95 
96  $publicName = '';
97  if (isset($publicData[$usr_id])) {
98  $login = '';
99  if (isset($publicData[$usr_id]['login'])) {
100  $publicName = $login = $publicData[$usr_id]['login'];
101  }
102 
103  if (isset($publicData[$usr_id]['public_profile']) && $publicData[$usr_id]['public_profile']) {
104  $publicName = implode(', ', [
105  $publicData[$usr_id]['lastname'],
106  $publicData[$usr_id]['firstname'],
107  ]);
108 
109  if ($publicName !== '') {
110  $publicName .= ' [' . $login . ']';
111  } else {
112  $publicName = $login;
113  }
114  }
115  }
116 
117  $data[$usr_id] = array(
118  'public_name' => $publicName,
119  'profile_image' => $publicImage
120  );
121  }
122 
124 
125  return $data;
126  }
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:
Create styles array
The data for the language used.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
static getTokenMaxLifetimeInSeconds()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInitialUserProfileData()

ilOnScreenChatUserDataProvider::getInitialUserProfileData ( )
Returns
int[]
Exceptions

Definition at line 34 of file class.ilOnScreenChatUserDataProvider.php.

References $in, $res, $row, $user, getDataByUserIds(), and user().

35  {
36  $conversationIds = [];
37 
38  $res = $this->db->queryF(
39  'SELECT DISTINCT(conversation_id) FROM osc_activity WHERE user_id = %s',
40  ['integer'],
41  [$this->user->getId()]
42  );
43  while ($row = $this->db->fetchAssoc($res)) {
44  $conversationIds[$row['conversation_id']] = $row['conversation_id'];
45  }
46 
47  $res = $this->db->queryF(
48  'SELECT DISTINCT(conversation_id) FROM osc_messages WHERE user_id = %s',
49  ['integer'],
50  [$this->user->getId()]
51  );
52  while ($row = $this->db->fetchAssoc($res)) {
53  $conversationIds[$row['conversation_id']] = $row['conversation_id'];
54  }
55 
56  if (0 === count($conversationIds)) {
57  return [];
58  }
59 
60  $usrIds = [];
61 
62  $in = $this->db->in('id', $conversationIds, false, 'text');
63  $res = $this->db->query('SELECT DISTINCT(participants) FROM osc_conversation WHERE ' . $in);
64  while ($row = $this->db->fetchAssoc($res)) {
65  $participants = json_decode($row['participants'], true);
66 
67  if (is_array($participants)) {
68  $usrIds = array_unique(array_merge($usrIds, array_map(function ($user) {
69  return $user['id'];
70  }, $participants)));
71  }
72  }
73 
74  return $this->getDataByUserIds($usrIds);
75  }
user()
Definition: user.php:4
foreach($_POST as $key=> $value) $res
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilOnScreenChatUserDataProvider::$db
protected

Definition at line 12 of file class.ilOnScreenChatUserDataProvider.php.

Referenced by __construct().

◆ $user

ilOnScreenChatUserDataProvider::$user
protected

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