Elgg
Version 1.11
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
pages
avatar
view.php
Go to the documentation of this file.
1
<?php
6
// page owner library sets this based on URL
7
$user
=
elgg_get_page_owner_entity
();
8
9
// Get the size
10
$size
= strtolower(
get_input
(
'size'
));
11
if
(!in_array(
$size
, array(
'master'
,
'large'
,
'medium'
,
'small'
,
'tiny'
,
'topbar'
))) {
12
$size
=
'medium'
;
13
}
14
15
// If user doesn't exist, return default icon
16
if
(!
$user
) {
17
$url
=
"_graphics/icons/default/{$size}.png"
;
18
$url
=
elgg_normalize_url
(
$url
);
19
forward
(
$url
);
20
}
21
22
$user_guid
=
$user
->getGUID();
23
24
// Try and get the icon
25
$filehandler
=
new
ElggFile
();
26
$filehandler
->owner_guid =
$user_guid
;
27
$filehandler
->setFilename(
"profile/{$user_guid}{$size}.jpg"
);
28
29
$success
=
false
;
30
31
try
{
32
if
(
$filehandler
->open(
"read"
)) {
33
if
(
$contents
=
$filehandler
->read(
$filehandler
->getSize())) {
34
$success
=
true
;
35
}
36
}
37
}
catch
(
InvalidParameterException
$e
) {
38
elgg_log
(
"Unable to get avatar for user with GUID $user_guid"
,
'ERROR'
);
39
}
40
41
42
if
(!
$success
) {
43
$url
=
"_graphics/icons/default/{$size}.png"
;
44
$url
=
elgg_normalize_url
(
$url
);
45
forward
(
$url
);
46
}
47
48
header
(
"Content-type: image/jpeg"
,
true
);
49
header
(
'Expires: '
. gmdate(
'D, d M Y H:i:s \G\M\T'
, strtotime(
"+6 months"
)),
true
);
50
header
(
"Pragma: public"
,
true
);
51
header
(
"Cache-Control: public"
,
true
);
52
header
(
"Content-Length: "
. strlen(
$contents
));
53
54
echo
$contents
;
$success
$success
Definition:
view.php:29
get_input
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition:
input.php:27
elgg_normalize_url
elgg_normalize_url($url)
Definition:
output.php:311
$contents
if($footer) $contents
Definition:
module.php:48
$size
$size
Definition:
view.php:10
$e
$e
Definition:
metadata.php:12
forward
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition:
elgglib.js:419
$url
$url
Definition:
exceptions.php:24
$user_guid
if(!in_array($size, array('master', 'large', 'medium', 'small', 'tiny', 'topbar'))) if(!$user) $user_guid
Definition:
view.php:22
InvalidParameterException
Definition:
InvalidParameterException.php:9
$filehandler
$filehandler
Definition:
view.php:25
echo
elgg echo
Translates a string.
Definition:
languages.js:43
$user
$user
View an avatar.
Definition:
view.php:7
elgg_get_page_owner_entity
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition:
pageowner.php:53
ElggFile
Definition:
ElggFile.php:22
elgg_log
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition:
elgglib.php:933
header
clearfix elgg elgg elgg elgg page header
Definition:
admin.php:127
Generated on Thu Oct 31 2024 00:04:46 for Elgg by
1.8.11