aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-06-28 21:52:30 -0400
committerSteve Clay <steve@mrclay.org>2012-06-28 21:52:30 -0400
commitb05caab768f9e1c4cbef4af87670dc87ef4d529f (patch)
tree27e6d89b09cbbb3cfbabc1ba04db1611bc9cce9c /mod
parentdbf78a975d2979ebeb50bd914b4ebc2c076ae09b (diff)
downloadelgg-b05caab768f9e1c4cbef4af87670dc87ef4d529f.tar.gz
elgg-b05caab768f9e1c4cbef4af87670dc87ef4d529f.tar.bz2
Fixes #4634: Restores pre 1.7 group profile pics after update
Diffstat (limited to 'mod')
-rw-r--r--mod/groups/icon.php6
-rw-r--r--mod/groups/start.php13
2 files changed, 17 insertions, 2 deletions
diff --git a/mod/groups/icon.php b/mod/groups/icon.php
index f86f84fa5..1bd240ea6 100644
--- a/mod/groups/icon.php
+++ b/mod/groups/icon.php
@@ -8,7 +8,13 @@
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
$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;
+}
// If is the same ETag, content didn't changed.
$etag = $group->icontime . $group_guid;
diff --git a/mod/groups/start.php b/mod/groups/start.php
index c8198371b..d6c2a47d2 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -284,12 +284,21 @@ function groups_url($entity) {
* @return string Relative URL
*/
function groups_icon_url_override($hook, $type, $returnvalue, $params) {
+ /* @var ElggGroup $group */
$group = $params['entity'];
$size = $params['size'];
- if (isset($group->icontime)) {
+ $icontime = $group->icontime;
+ // handle missing metadata (pre 1.7 installations)
+ if (null === $icontime) {
+ $file = new ElggFile();
+ $file->owner_guid = $group->owner_guid;
+ $file->setFilename("groups/" . $group->guid . "large.jpg");
+ $icontime = $file->exists() ? time() : 0;
+ create_metadata($group->guid, 'icontime', $icontime, 'integer', $group->owner_guid, ACCESS_PUBLIC);
+ }
+ if ($icontime) {
// return thumbnail
- $icontime = $group->icontime;
return "groupicon/$group->guid/$size/$icontime.jpg";
}