aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-06-29 18:51:23 -0700
committerCash Costello <cash.costello@gmail.com>2012-06-29 18:51:23 -0700
commit919cc3b9cc851d7746f7cecce09670ebfd87bd85 (patch)
tree41fa80a1b48b3412b68e86f01d3e0238f9a7bc19
parent5f89696ee75400f59ad895758efe046ed8fbe87f (diff)
parentb05caab768f9e1c4cbef4af87670dc87ef4d529f (diff)
downloadelgg-919cc3b9cc851d7746f7cecce09670ebfd87bd85.tar.gz
elgg-919cc3b9cc851d7746f7cecce09670ebfd87bd85.tar.bz2
Merge pull request #288 from mrclay/4634-group-icons-2
Fixes #4634: Restores pre 1.7 group profile pics after update
-rw-r--r--engine/classes/ElggGroup.php2
-rw-r--r--mod/groups/icon.php6
-rw-r--r--mod/groups/start.php13
3 files changed, 17 insertions, 4 deletions
diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php
index f7f67bf41..121186196 100644
--- a/engine/classes/ElggGroup.php
+++ b/engine/classes/ElggGroup.php
@@ -16,8 +16,6 @@ class ElggGroup extends ElggEntity
* Sets the type to group.
*
* @return void
- *
- * @deprecated 1.8 Use initializeAttributes
*/
protected function initializeAttributes() {
parent::initializeAttributes();
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 8eb0d4036..d85bb6492 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -283,12 +283,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";
}