summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2013-08-30 09:00:37 +0200
committerkondou <kondou@ts.unde.re>2013-08-30 09:00:37 +0200
commitecf187393becc7dc613b4fd1322e40eb58f9f0fd (patch)
tree4e4b28955ae74fe81c4a6763ecd28ad4ac95cfe8 /lib
parentc533b8068292e2b265c3c73f3ad9e5de0e98a81d (diff)
downloadnextcloud-server-ecf187393becc7dc613b4fd1322e40eb58f9f0fd.tar.gz
nextcloud-server-ecf187393becc7dc613b4fd1322e40eb58f9f0fd.zip
Finish cropper, Get rid of TODOs, Improve \OCP\Avatar and "fix" unitests
Diffstat (limited to 'lib')
-rw-r--r--lib/avatar.php10
-rw-r--r--lib/public/avatar.php16
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/avatar.php b/lib/avatar.php
index 3621b96e103..eb1f2e18295 100644
--- a/lib/avatar.php
+++ b/lib/avatar.php
@@ -40,9 +40,14 @@ class OC_Avatar {
* @throws Exception if the provided file is not a jpg or png image
* @throws Exception if the provided image is not valid
* @throws \OC\NotSquareException if the image is not square
- * @return true on success
+ * @return void
*/
public function set ($user, $data) {
+ if (\OC_Appconfig::getValue('files_encryption', 'enabled') === "yes") {
+ $l = \OC_L10N::get('lib');
+ throw new \Exception($l->t("Custom avatars don't work with encryption yet"));
+ }
+
$view = new \OC\Files\View('/'.$user);
$img = new OC_Image($data);
@@ -55,7 +60,7 @@ class OC_Avatar {
if (!$img->valid()) {
$l = \OC_L10N::get('lib');
- throw new \Excpeption($l->t("Invalid image"));
+ throw new \Exception($l->t("Invalid image"));
}
if (!($img->height() === $img->width())) {
@@ -65,7 +70,6 @@ class OC_Avatar {
$view->unlink('avatar.jpg');
$view->unlink('avatar.png');
$view->file_put_contents('avatar.'.$type, $data);
- return true;
}
/**
diff --git a/lib/public/avatar.php b/lib/public/avatar.php
index 649f3240e93..f229da19543 100644
--- a/lib/public/avatar.php
+++ b/lib/public/avatar.php
@@ -9,8 +9,20 @@
namespace OCP;
class Avatar {
- public static function get ($user, $size = 64) {
- $avatar = new \OC_Avatar();
+ private $avatar;
+
+ public function __construct () {
+ $this->avatar = new \OC_Avatar();
+
+ public function get ($user, $size = 64) {
return $avatar->get($user, $size);
}
+
+ public function set ($user, $data) {
+ return $avatar->set($user, $data);
+ }
+
+ public function remove ($user) {
+ return $avatar->remove($user);
+ }
}