ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilForumAuthorInformationCache Class Reference

ilForumAuthorInformationCache More...

+ Collaboration diagram for ilForumAuthorInformationCache:

Static Public Member Functions

static preloadUserObjects (array $usr_ids)
 
static getUserObjectById (int $usr_id)
 

Static Protected Attributes

static array $user_instances = []
 
static array $requested_usr_ids = []
 
static array $requested_usr_ids_key_map = []
 

Detailed Description

Member Function Documentation

◆ getUserObjectById()

static ilForumAuthorInformationCache::getUserObjectById ( int  $usr_id)
static

Definition at line 83 of file class.ilForumAuthorInformationCache.php.

83 : ?ilObjUser
84 {
85 if ($usr_id === 0) {
86 return null;
87 }
88
89 if (!isset(self::$requested_usr_ids_key_map[$usr_id])) {
90 self::preloadUserObjects([$usr_id]);
91 }
92
93 return self::$user_instances[$usr_id] ?? null;
94 }
User class.

References preloadUserObjects().

Referenced by ilForumAuthorInformation\initUserInstance().

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

◆ preloadUserObjects()

static ilForumAuthorInformationCache::preloadUserObjects ( array  $usr_ids)
static
Parameters
int[]$usr_ids

Definition at line 39 of file class.ilForumAuthorInformationCache.php.

39 : void
40 {
41 global $DIC;
42 $ilDB = $DIC->database();
43
44 $usr_ids_to_request = array_diff($usr_ids, self::$requested_usr_ids);
45 self::$requested_usr_ids = array_merge(self::$requested_usr_ids, $usr_ids_to_request);
46 self::$requested_usr_ids_key_map = array_flip(self::$requested_usr_ids);
47
48 if ($usr_ids_to_request !== []) {
49 $in = $ilDB->in('ud.usr_id', $usr_ids_to_request, false, 'integer');
50 $query = "
51 SELECT ud.usr_id, od.create_date, login, firstname, lastname, ud.title, gender, pprof.value public_profile, pgen.value public_gender, pup.value public_upload
52 FROM usr_data ud
53 INNER JOIN object_data od ON od.obj_id = ud.usr_id
54 LEFT JOIN usr_pref pprof ON pprof.usr_id = ud.usr_id AND pprof.keyword = %s
55 LEFT JOIN usr_pref pgen ON pgen.usr_id = ud.usr_id AND pgen.keyword = %s
56 LEFT JOIN usr_pref pup ON pup.usr_id = ud.usr_id AND pup.keyword = %s
57 WHERE $in
58 ";
59
60 $res = $ilDB->queryF(
61 $query,
62 ['text', 'text', 'text'],
63 ['public_profile', 'public_gender', 'public_upload']
64 );
65
66 while ($row = $ilDB->fetchAssoc($res)) {
67 $user = new ilObjUser();
68 $user->setId((int) $row['usr_id']);
69 $user->setLogin($row['login']);
70 $user->setGender($row['gender'] ?? '');
71 $user->setUTitle($row['title'] ?? '');
72 $user->setFirstname($row['firstname'] ?? '');
73 $user->setLastname($row['lastname'] ?? '');
74 $user->setPref('public_profile', $row['public_profile']);
75 $user->setPref('public_gender', $row['public_gender']);
76 $user->setPref('public_upload', $row['public_upload']);
77
78 self::$user_instances[(int) $row['usr_id']] = $user;
79 }
80 }
81 }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26

References $DIC, $ilDB, $res, and ILIAS\Repository\int().

Referenced by ilForumTopic\getNestedSetPostChildren(), ilForumTopic\getPostTree(), getUserObjectById(), and ilForumCronNotification\sendCronForumNotification().

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

Field Documentation

◆ $requested_usr_ids

array ilForumAuthorInformationCache::$requested_usr_ids = []
staticprotected

Definition at line 32 of file class.ilForumAuthorInformationCache.php.

◆ $requested_usr_ids_key_map

array ilForumAuthorInformationCache::$requested_usr_ids_key_map = []
staticprotected

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

◆ $user_instances

array ilForumAuthorInformationCache::$user_instances = []
staticprotected

Definition at line 30 of file class.ilForumAuthorInformationCache.php.


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