]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4350 (Edit Avatar - Crop button is misleading, should be hidden if
authorJanek Lasocki-Biczysko <j.lasocki-biczysko@intrallect.com>
Fri, 3 Feb 2012 09:27:31 +0000 (09:27 +0000)
committerCash Costello <cash.costello@gmail.com>
Wed, 8 Feb 2012 12:23:07 +0000 (07:23 -0500)
avatar hasn't been created yet)

actions/avatar/crop.php
pages/avatar/edit.php

index f2b812c4f3db0d9b729d5c571338d4f080884093..b9a80f331d61c33df33f14862f4921cd5c08e430 100644 (file)
@@ -22,6 +22,12 @@ $filehandler->owner_guid = $owner->getGUID();
 $filehandler->setFilename("profile/" . $owner->guid . "master" . ".jpg");
 $filename = $filehandler->getFilenameOnFilestore();
 
+// ensuring the avatar image exists in the first place
+if (!file_exists($filename)) {
+       register_error(elgg_echo('avatar:crop:fail'));
+       forward(REFERER);
+}
+
 $icon_sizes = elgg_get_config('icon_sizes');
 unset($icon_sizes['master']);
 
index eef8f8f8be9e58676c66a369b6c66bd7cd9ae16b..c71633b8bec44cce383d33cd74e85a2b31c18603 100644 (file)
@@ -10,8 +10,13 @@ elgg_set_context('profile_edit');
 
 $title = elgg_echo('avatar:edit');
 
-$content = elgg_view('core/avatar/upload', array('entity' => elgg_get_page_owner_entity()));
-$content .= elgg_view('core/avatar/crop', array('entity' => elgg_get_page_owner_entity()));
+$entity = elgg_get_page_owner_entity();
+$content = elgg_view('core/avatar/upload', array('entity' => $entity));
+
+// only offer the crop view if an avatar has been uploaded
+if (isset($entity->icontime)) {
+       $content .= elgg_view('core/avatar/crop', array('entity' => $entity));
+}
 
 $params = array(
        'content' => $content,