From 38c46098853ac8d79360fbf120cf4cbc8ea471a1 Mon Sep 17 00:00:00 2001 From: TickTackk Date: Thu, 23 Jul 2020 19:18:09 +0530 Subject: [PATCH 1/3] Increase version --- addon.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon.json b/addon.json index 941d88d..23e6c2e 100644 --- a/addon.json +++ b/addon.json @@ -2,8 +2,8 @@ "legacy_addon_id": "", "title": "Upload Avatar From URL", "description": "This add-on allows users with permission to upload avatar from URL.", - "version_id": 1000170, - "version_string": "1.0.1", + "version_id": 1000270, + "version_string": "1.0.2", "dev": "TickTackk", "dev_url": "https://xenforo.com/community/members/ticktackk.90375/", "faq_url": "", From 4d4b5702582bb4735cbeccd004811b9244434577 Mon Sep 17 00:00:00 2001 From: TickTackk Date: Thu, 23 Jul 2020 19:18:21 +0530 Subject: [PATCH 2/3] closes #6 --- CHANGELOG.md | 4 ++++ XF/Pub/Controller/Account.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e016487..cb0b0d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========================== +## 1.0.2 (`1000270`) + +- **Change:** Throw exception reply when resizing existing avatar (#6) + ## 1.0.1 (`1000170`) - **Fix:** Errors from avatar service are not correctly returned (#4) diff --git a/XF/Pub/Controller/Account.php b/XF/Pub/Controller/Account.php index 07464e0..2dc6617 100644 --- a/XF/Pub/Controller/Account.php +++ b/XF/Pub/Controller/Account.php @@ -95,7 +95,7 @@ public function actionAvatar() $avatarService->setCrop($cropX, $cropY); if (!$avatarService->updateAvatar()) { - return $this->error(\XF::phrase('new_avatar_could_not_be_processed')); + throw $this->exception($this->error(\XF::phrase('new_avatar_could_not_be_processed'))); } } else From 8dc3e1948f7b5b53d22d2d12518c32db1df149e2 Mon Sep 17 00:00:00 2001 From: TickTackk Date: Thu, 23 Jul 2020 19:30:02 +0530 Subject: [PATCH 3/3] closes #7 --- CHANGELOG.md | 2 +- Setup.php | 20 ------------------ XF/Entity/User.php | 11 +--------- XF/Pub/Controller/Account.php | 38 ++++------------------------------- 4 files changed, 6 insertions(+), 65 deletions(-) delete mode 100644 Setup.php diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0b0d2..71af519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ CHANGELOG ## 1.0.2 (`1000270`) -- **Change:** Throw exception reply when resizing existing avatar (#6) +- **Change:** Minor code improvement and clean up (#7) ## 1.0.1 (`1000170`) diff --git a/Setup.php b/Setup.php deleted file mode 100644 index c5a9cab..0000000 --- a/Setup.php +++ /dev/null @@ -1,20 +0,0 @@ -user_id) { diff --git a/XF/Pub/Controller/Account.php b/XF/Pub/Controller/Account.php index 2dc6617..a031afd 100644 --- a/XF/Pub/Controller/Account.php +++ b/XF/Pub/Controller/Account.php @@ -3,22 +3,13 @@ namespace TickTackk\UploadAvatarFromUrl\XF\Pub\Controller; use TickTackk\UploadAvatarFromUrl\XF\Entity\User as ExtendedUserEntity; -use XF\Mvc\Reply\AbstractReply; use XF\Mvc\Reply\View as ViewReply; use XF\Mvc\Reply\Redirect as RedirectReply; -use XF\Mvc\Reply\Reroute as RerouteReply; -use XF\Mvc\Reply\Message as MessageReply; use XF\Mvc\Reply\Exception as ExceptionReply; use XF\Mvc\Reply\Error as ErrorReply; use XF\Util\File as FileUtil; +use XF\Service\User\Avatar as UserAvatarChangerSvc; -/** - * Class Account - * - * Extends \XF\Pub\Controller\Account - * - * @package TickTackk\UploadAvatarFromUrl\XF\Pub\Controller - */ class Account extends XFCP_Account { /** @@ -47,7 +38,7 @@ public function actionAvatar() throw $this->exception($this->noPermission($error)); } - /** @var \XF\Service\User\Avatar $avatarService */ + /** @var UserAvatarChangerSvc $avatarService */ $avatarService = $this->service('XF:User\Avatar', $visitor); if (\strlen($input['url'])) @@ -79,29 +70,8 @@ public function actionAvatar() { return $this->view('XF:Account\AvatarUpdate', ''); } - else - { - return $this->redirect($this->buildLink('account/avatar')); - } - } - else if ($visitor->avatar_date) - { - // recrop existing avatar - $cropX = $this->filter('avatar_crop_x', 'uint'); - $cropY = $this->filter('avatar_crop_y', 'uint'); - if ($cropX != $visitor->Profile->avatar_crop_x || $cropY != $visitor->Profile->avatar_crop_y) - { - $avatarService->setImageFromExisting(); - $avatarService->setCrop($cropX, $cropY); - if (!$avatarService->updateAvatar()) - { - throw $this->exception($this->error(\XF::phrase('new_avatar_could_not_be_processed'))); - } - } - else - { - $avatarService->removeGravatar(); - } + + return $this->redirect($this->buildLink('account/avatar')); } } }