-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(groups): group avatars now use serve-file handler
Group avatars are now served with elgg_get_inline_url()
- Loading branch information
1 parent
c2b2f7f
commit ac57e99
Showing
2 changed files
with
42 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* Icon display | ||
* | ||
* @package ElggGroups | ||
* @deprecated 2.2 | ||
*/ | ||
elgg_deprecated_notice('icon.php has been depreated and should not be included. Use elgg_get_inline_url() instead.', '2.2'); | ||
|
||
if (!isset($page)) { | ||
die('This file cannot be called directly.'); | ||
} | ||
|
||
$group_guid = get_input('group_guid'); | ||
|
||
/* @var ElggGroup $group */ | ||
$group = get_entity($group_guid); | ||
if (!($group instanceof ElggGroup)) { | ||
header("HTTP/1.1 404 Not Found"); | ||
exit; | ||
$guid = get_input('group_guid'); | ||
$size = get_input('size'); | ||
if (!isset($size) || $size === '') { | ||
$size = 'medium'; | ||
} | ||
|
||
// If is the same ETag, content didn't changed. | ||
$etag = $group->icontime . $group_guid; | ||
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"$etag\"") { | ||
header("HTTP/1.1 304 Not Modified"); | ||
exit; | ||
} | ||
|
||
$size = strtolower(get_input('size')); | ||
if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar'))) | ||
$size = "medium"; | ||
elgg_entity_gatekeeper($guid, 'group'); | ||
|
||
$success = false; | ||
$group = get_entity($guid); | ||
|
||
$filehandler = new ElggFile(); | ||
$filehandler->owner_guid = $group->owner_guid; | ||
$filehandler->setFilename("groups/" . $group->guid . $size . ".jpg"); | ||
|
||
$success = false; | ||
if ($filehandler->open("read")) { | ||
if ($contents = $filehandler->read($filehandler->getSize())) { | ||
$success = true; | ||
} | ||
} | ||
$icon = new ElggFile(); | ||
$icon->owner_guid = $group->owner_guid; | ||
$icon->setFilename("groups/{$group->guid}{$size}.jpg"); | ||
|
||
if (!$success) { | ||
$contents = elgg_view("groups/default{$size}.gif"); | ||
header("Content-type: image/gif"); | ||
} else { | ||
header("Content-type: image/jpeg"); | ||
$url = elgg_get_inline_url($icon, true); | ||
if (!$url) { | ||
$url = elgg_get_simplecache_url("groups/default{$size}.gif"); | ||
} | ||
|
||
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true); | ||
header("Pragma: public"); | ||
header("Cache-Control: public"); | ||
header("Content-Length: " . strlen($contents)); | ||
header("ETag: \"$etag\""); | ||
echo $contents; | ||
forward($url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters