ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilForumAuthorInformationCache.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
16 protected static $user_instances = array();
17
22 protected static $requested_usr_ids = array();
23
28 protected static $requested_usr_ids_key_map = array();
29
34 public static function preloadUserObjects(array $usr_ids)
35 {
36 global $DIC;
37 $ilDB = $DIC->database();
38
39 $usr_ids_to_request = array_diff($usr_ids, self::$requested_usr_ids);
40 self::$requested_usr_ids = array_merge(self::$requested_usr_ids, $usr_ids_to_request);
41 self::$requested_usr_ids_key_map = array_flip(self::$requested_usr_ids);
42
43 if ($usr_ids_to_request) {
44 $in = $ilDB->in('ud.usr_id', $usr_ids_to_request, false, 'integer');
45 $query = "
46 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
47 FROM usr_data ud
48 INNER JOIN object_data od ON od.obj_id = ud.usr_id
49 LEFT JOIN usr_pref pprof ON pprof.usr_id = ud.usr_id AND pprof.keyword = %s
50 LEFT JOIN usr_pref pgen ON pgen.usr_id = ud.usr_id AND pgen.keyword = %s
51 LEFT JOIN usr_pref pup ON pup.usr_id = ud.usr_id AND pup.keyword = %s
52 WHERE $in
53 ";
54
55 $res = $ilDB->queryF(
56 $query,
57 array('text', 'text', 'text'),
58 array('public_profile', 'public_gender', 'public_upload')
59 );
60
61 while ($row = $ilDB->fetchAssoc($res)) {
62 $user = new ilObjUser;
63 $user->setId($row['usr_id']);
64 $user->setLogin($row['login']);
65 $user->setGender($row['gender']);
66 $user->setTitle($row['title']);
67 $user->setFirstname($row['firstname']);
68 $user->setLastname($row['lastname']);
69 $user->create_date = $row['create_date']; // create_date is currently a public member, has to be changed in future evtl.
70 $user->setPref('public_profile', $row['public_profile']);
71 $user->setPref('public_gender', $row['public_gender']);
72 $user->setPref('public_upload', $row['public_upload']);
73
74 self::$user_instances[$row['usr_id']] = $user;
75 }
76 }
77 }
78
84 public static function getUserObjectById($usr_id)
85 {
86 if (!$usr_id) {
87 return null;
88 }
89
90 if (!isset(self::$requested_usr_ids_key_map[$usr_id])) {
91 self::preloadUserObjects(array($usr_id));
92 }
93
94 return isset(self::$user_instances[$usr_id]) ? self::$user_instances[$usr_id] : null;
95 }
96}
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
An exception for terminatinating execution or to throw for unit testing.
$user
Definition: migrateto20.php:57
$row
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB