82 $this->db = $DIC->database();
83 $this->
ui = $DIC->ui()->factory();
84 $this->lng = $DIC->language();
85 $this->
user = $DIC->user();
87 $this->letter_avatars_activated = (bool) $DIC->settings()->get(
'letter_avatars');
91 private function init() : void
93 $in = $this->db->in(
'usr_pref.keyword', array(
'public_upload',
'public_profile'),
false,
'text');
94 $res = $this->db->queryF(
96 SELECT usr_pref.*, ud.login, ud.firstname, ud.lastname 97 FROM usr_data ud LEFT JOIN usr_pref ON usr_pref.usr_id = ud.usr_id AND $in 98 WHERE ud.usr_id = %s",
100 array($this->user_id)
103 while ($row = $this->db->fetchAssoc(
$res)) {
104 $this->
login = $row[
'login'];
105 $this->firstname = $row[
'firstname'];
106 $this->lastname = $row[
'lastname'];
108 switch ($row[
'keyword']) {
109 case 'public_upload':
110 $this->has_public_upload = $row[
'value'] ===
'y';
112 case 'public_profile':
113 $this->has_public_profile = ($row[
'value'] ===
'y' || $row[
'value'] ===
'g');
120 if (defined(
'ILIAS_MODULE')) {
121 $webspace_dir = (
'.' . $webspace_dir);
125 $image_dir = $webspace_dir .
'/usr_images';
126 $this->uploaded_file = $image_dir .
'/usr_' . $this->user_id .
'.jpg';
128 if ($this->has_public_profile) {
137 return (($this->has_public_upload && $this->has_public_profile) || $this->force_image) && is_file($this->uploaded_file);
148 if ($name_as_set_as_text_closely) {
149 $alternative_text = $this->lng->txt(
"user_avatar");
150 } elseif ($this->user_id == $this->
user->getId() && !$this->user::_isAnonymous($this->user_id)) {
151 $alternative_text = $this->lng->txt(
"current_user_avatar");
153 $alternative_text = $this->lng->txt(
"user_avatar_of") .
" " .
$this->login;
157 return $this->
ui->symbol()->avatar()->picture($this->uploaded_file, $this->
login)
158 ->withAlternativeText($alternative_text);
161 if ($this->letter_avatars_activated ===
false) {
162 return $this->
ui->symbol()->avatar()->picture(
168 return $this->
ui->symbol()->avatar()->letter($this->abbreviation)->withAlternativeText($alternative_text);
171 public function getLegacyPictureURL() :
string 175 return $this->uploaded_file .
'?t=' . rand(1, 99999);
179 $avatar = $DIC[
"user.avatar.factory"]->avatar($this->size);
180 $avatar->setName($this->abbreviation);
181 $avatar->setUsrId($this->user_id);
183 return $avatar->getUrl();
199 if ($size ===
'small' || $size ===
'big') {
static _lookupLogin($a_user_id)
lookup login
$letter_avatars_activated
__construct(int $user_id)
constructor.
static subStr($a_str, $a_start, $a_length=null)
foreach($_POST as $key=> $value) $res
This describes how a letter or a picture avatar could be modified during construction of UI...
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class ilUserAvatarResolver.
if(php_sapi_name() !='cli') $in
getAvatar(bool $name_as_set_as_text_closely=false)
static getWebspaceDir($mode="filesystem")
get webspace directory
setForcePicture(bool $force_image)