Elgg  Version 1.9
view.php
Go to the documentation of this file.
1 <?php
6 // page owner library sets this based on URL
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";
19  forward($url);
20 }
21 
22 $user_guid = $user->getGUID();
23 
24 // Try and get the icon
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";
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 
$success
Definition: view.php:29
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($url)
Definition: output.php:290
if($footer) $contents
Definition: module.php:48
$size
Definition: view.php:10
$e
Definition: metadata.php:12
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:419
$url
Definition: exceptions.php:24
if(!in_array($size, array('master', 'large', 'medium', 'small', 'tiny', 'topbar'))) if(!$user) $user_guid
Definition: view.php:22
$filehandler
Definition: view.php:25
elgg echo
Translates a string.
Definition: languages.js:43
$user
View an avatar.
Definition: view.php:7
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:53
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1083
clearfix elgg elgg elgg elgg page header
Definition: admin.php:127