Skip to content

Commit

Permalink
Merge pull request #8 from ticktackk/develop
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
ticktackk authored Jul 23, 2020
2 parents 603bc3c + 8dc3e19 commit c75755b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 66 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
==========================

## 1.0.2 (`1000270`)

- **Change:** Minor code improvement and clean up (#7)

## 1.0.1 (`1000170`)

- **Fix:** Errors from avatar service are not correctly returned (#4)
Expand Down
20 changes: 0 additions & 20 deletions Setup.php

This file was deleted.

11 changes: 1 addition & 10 deletions XF/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@

namespace TickTackk\UploadAvatarFromUrl\XF\Entity;

use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure as EntityStructure;
use XF\Phrase;

/**
* Class User
*
* Extends \XF\Entity\User
*
* @package TickTackk\UploadAvatarFromUrl\XF\Entity
*/
class User extends XFCP_User
{
/**
* @param Phrase|null $error
*
* @return bool
*/
public function canUploadAvatarFromUrl(Phrase &$error = null) : bool
public function canUploadAvatarFromUrl(/** @noinspection PhpUnusedParameterInspection */ Phrase &$error = null) : bool
{
if (!$this->user_id)
{
Expand Down
38 changes: 4 additions & 34 deletions XF/Pub/Controller/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down Expand Up @@ -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']))
Expand Down Expand Up @@ -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())
{
return $this->error(\XF::phrase('new_avatar_could_not_be_processed'));
}
}
else
{
$avatarService->removeGravatar();
}

return $this->redirect($this->buildLink('account/avatar'));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down

0 comments on commit c75755b

Please sign in to comment.