diff options
author | kondou <kondou@ts.unde.re> | 2013-08-24 00:35:32 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2013-08-25 21:06:44 +0200 |
commit | 9a8908b643c69451118ab76ca36e5fa0e704bd0a (patch) | |
tree | 4a03ad1c0884000ff6e543a2c22e7ec37be709be /lib | |
parent | f19f8d1088a97bcb6d8dcbe519aa03249cdb42d0 (diff) | |
download | nextcloud-server-9a8908b643c69451118ab76ca36e5fa0e704bd0a.tar.gz nextcloud-server-9a8908b643c69451118ab76ca36e5fa0e704bd0a.zip |
Use Jcrop, have inline errormsg, work on cropping, clean up, WIP
Diffstat (limited to 'lib')
-rw-r--r-- | lib/avatar.php | 13 | ||||
-rw-r--r-- | lib/notsquareexception.php | 12 | ||||
-rw-r--r-- | lib/public/avatar.php | 4 |
3 files changed, 21 insertions, 8 deletions
diff --git a/lib/avatar.php b/lib/avatar.php index 86be0ea2635..9ab905c852e 100644 --- a/lib/avatar.php +++ b/lib/avatar.php @@ -26,7 +26,7 @@ class OC_Avatar { $ext = 'png'; } else { return false; - } + } $avatar = new OC_Image($view->file_get_contents('avatar.'.$ext)); $avatar->resize($size); @@ -38,7 +38,8 @@ class OC_Avatar { * @param $user string user to set the avatar for * @param $data mixed imagedata or path to set a new avatar * @throws Exception if the provided file is not a jpg or png image - * @throws Exception if the provided image is not valid, or not a square + * @throws Exception if the provided image is not valid + * @throws \OC\NotSquareException if the image is not square * @return true on success */ public static function set ($user, $data) { @@ -52,9 +53,13 @@ class OC_Avatar { throw new \Exception($l->t("Unknown filetype")); } - if (!( $img->valid() && ($img->height() === $img->width()) )) { + if (!$img->valid()) { $l = \OC_L10N::get('lib'); - throw new \Exception($l->t("Invalid image, or the provided image is not square")); + throw new \Excpeption($l->t("Invalid image")); + } + + if (!($img->height() === $img->width())) { + throw new \OC\NotSquareException(); } $view->unlink('avatar.jpg'); diff --git a/lib/notsquareexception.php b/lib/notsquareexception.php new file mode 100644 index 00000000000..03dba8fb25f --- /dev/null +++ b/lib/notsquareexception.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC; + +class NotSquareException extends \Exception { +} diff --git a/lib/public/avatar.php b/lib/public/avatar.php index 768d292346f..55eff57d161 100644 --- a/lib/public/avatar.php +++ b/lib/public/avatar.php @@ -12,8 +12,4 @@ class Avatar { public static function get ($user, $size = 64) { return \OC_Avatar::get($user, $size); } - - public static function getMode () { - return \OC_Avatar::getMode(); - } } |