Skip to content

Commit

Permalink
Added Craft 4 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
bhashkar007 committed Feb 4, 2023
1 parent 1193f47 commit b06a635
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pluginName":"User Initials Photo","pluginDescription":"A plugin to assign profile picture of user with their name initials.","pluginVersion":"1.0.0","pluginAuthorName":"Hashtag Errors","pluginVendorName":"hashtagerrors","pluginAuthorUrl":"http://www.hashtagerrors.com","pluginAuthorGithub":"hashtagerror","codeComments":"","pluginComponents":["services"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
{"pluginName":"User Initials Photo","pluginDescription":"A plugin to assign profile picture of user with their name initials.","pluginVersion":"1.0.0","pluginAuthorName":"Hashtag Errors","pluginVendorName":"bhashkar007","pluginAuthorUrl":"https://360adaptive.com","pluginAuthorGithub":"bhashkar007","codeComments":"","pluginComponents":["services"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.0 - 2023-02-04
### Added
- Craft 4 support

## 1.1.2 - 2019-04-30
### Fixed
- hasCpSection value changed to true.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Hashtag Errors
Copyright (c) 2023 360Adaptive Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Hashtag Errors
Copyright (c) 2023 360Adaptive Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A plugin to assign profile picture of user with their name initials.

## Requirements

This plugin requires Craft CMS 3.0.0 or later.
This plugin requires Craft CMS 4.0.0 or later.

## Installation

Expand All @@ -21,7 +21,7 @@ To install the plugin, follow these instructions.

2. Then tell Composer to load the plugin:

composer require hashtagerrors/user-initials-photo
composer require bhashkar007/user-initials-photo

3. In the Control Panel, go to Settings → Plugins and click the “Install” button for **User Initials Photo**.

Expand All @@ -42,16 +42,10 @@ To use the plugin make sure a volume is assigned in `User Photo Location` in you
By default the plugin assings Photos to new user only. To assign photos to old users too, uncheck `Assign Images to New User Only` in Plugin Setting page.
To assign photos to all Users at once, Go to plugin section page and click `Assign`.

NOTE: If you are updating plugin from `v1.0.0` to `v1.1.0` or above you must have to do a `composer remove hashtagerrors/hashtagerror/user-initials-photo` and then `composer require hashtagerror/user-initials-photo` to get plugin setting and section page.
NOTE: If you are updating plugin from `v1.1.0` to `v2.0.0` or above you must have to do a `composer remove hashtagerrors/user-initials-photo` and then `composer require bhashkar007/user-initials-photo` to get plugin setting and section page.

## User Initials Photo Roadmap

While there is not a lot to do in this plugin, but new ideas are always welcome. You can post your idea or request [here](https://github.com/hashtagerrors/userinitialsphoto/issues/new)
While there is not a lot to do in this plugin, but new ideas are always welcome. You can post your idea or request [here](https://github.com/bhashkar007/userinitialsphoto/issues/new)

### Loved It?

Show your Love and Support by buying me a cup of Coffee !

<a href="https://ko-fi.com/hashtagerrors" target="_blank"><img src="http://www.hashtagerrors.com/assets/uploads/buy-me-a-coffee.png" alt="Buy Me A Coffee" width="200"></a>

Brought to you by [Hashtag Errors](http://www.hashtagerrors.com)
Brought to you by [360Adaptive Technologies](https://360adaptive.com)
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "hashtagerrors/user-initials-photo",
"name": "bhashkar007/user-initials-photo",
"description": "A plugin to assign profile picture of user with their name initials.",
"type": "craft-plugin",
"version": "1.1.1",
"version": "2.0.0",
"keywords": [
"craft",
"cms",
Expand All @@ -11,33 +11,33 @@
"user initials photo"
],
"support": {
"docs": "https://github.com/hashtagerror/user-initials-photo/blob/master/README.md",
"issues": "https://github.com/hashtagerror/user-initials-photo/issues"
"docs": "https://github.com/bhashkar007/user-initials-photo/blob/master/README.md",
"issues": "https://github.com/bhashkar007/user-initials-photo/issues"
},
"license": "MIT",
"authors": [
{
"name": "Hashtag Errors",
"homepage": "http://www.hashtagerrors.com"
"name": "360Adaptive Technologies",
"homepage": "https://360adaptive.com"
}
],
"require": {
"craftcms/cms": "^3.0.0"
"craftcms/cms": "^4.0.0"
},
"autoload": {
"psr-4": {
"hashtagerrors\\userinitialsphoto\\": "src/"
"bhashkar007\\userinitialsphoto\\": "src/"
}
},
"extra": {
"name": "User Initials Photo",
"handle": "user-initials-photo",
"hasCpSettings": true,
"hasCpSection": true,
"changelogUrl": "https://raw.githubusercontent.com/hashtagerror/user-initials-photo/master/CHANGELOG.md",
"changelogUrl": "https://raw.githubusercontent.com/bhashkar007/user-initials-photo/master/CHANGELOG.md",
"components": {
"userInitialsPhotoService": "hashtagerrors\\userinitialsphoto\\services\\UserInitialsPhotoService"
"userInitialsPhotoService": "bhashkar007\\userinitialsphoto\\services\\UserInitialsPhotoService"
},
"class": "hashtagerrors\\userinitialsphoto\\UserInitialsPhoto"
"class": "bhashkar007\\userinitialsphoto\\UserInitialsPhoto"
}
}
55 changes: 11 additions & 44 deletions src/UserInitialsPhoto.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?php
/**
* User Initials Photo plugin for Craft CMS 3.x
*
* User Initials Photo plugin for Craft CMS 4.x
* A plugin to assign profile picture of user with their name initials.
*
* @link http://www.hashtagerrors.com
* @copyright Copyright (c) 2019 Hashtag Errors
* @link https://360adaptive.com
* @copyright Copyright (c) 2023 360Adaptive Technologies
*/

namespace hashtagerrors\userinitialsphoto;
namespace bhashkar007\userinitialsphoto;

use hashtagerrors\userinitialsphoto\services\UserInitialsPhotoService;
use hashtagerrors\userinitialsphoto\models\Settings;
use bhashkar007\userinitialsphoto\services\UserInitialsPhotoService;
use bhashkar007\userinitialsphoto\models\Settings;

use Craft;
use craft\base\Plugin;
Expand All @@ -21,43 +19,23 @@
use craft\services\Plugins;
use craft\events\PluginEvent;
use craft\events\RegisterUrlRulesEvent;


use yii\base\Event;

/**
* Class UserInitialsPhoto
*
* @author Hashtag Errors
* @author 360Adaptive Technologies
* @package UserInitialsPhoto
* @since 1.0.0
* @since 2.0.0
*
* @property UserInitialsPhotoServiceService $userInitialsPhotoService
*/
class UserInitialsPhoto extends Plugin
{
// Static Properties
// =========================================================================

/**
* @var UserInitialsPhoto
*/
public static $plugin;

// Public Properties
// =========================================================================
public string $schemaVersion = '2.0.0';

/**
* @var string
*/
public $schemaVersion = '1.0.0';

// Public Methods
// =========================================================================

/**
* @inheritdoc
*/
public function init()
{
parent::init();
Expand Down Expand Up @@ -93,7 +71,6 @@ function (RegisterUrlRulesEvent $event) {
}
});

//
Craft::info(
Craft::t(
'user-initials-photo',
Expand All @@ -104,20 +81,11 @@ function (RegisterUrlRulesEvent $event) {
);
}

// Protected Methods
// =========================================================================

/**
* @inheritdoc
*/
protected function createSettingsModel()
protected function createSettingsModel(): ?\craft\base\Model
{
return new Settings();
}

/**
* @inheritdoc
*/
protected function settingsHtml(): string
{
return Craft::$app->view->renderTemplate(
Expand All @@ -127,5 +95,4 @@ protected function settingsHtml(): string
]
);
}

}
}
31 changes: 9 additions & 22 deletions src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
<?php
/**
* User Initials Photo plugin for Craft CMS 3.x
*
* User Initials Photo plugin for Craft CMS 4.x
* A plugin to assign profile picture of user with their name initials.
*
* @link http://www.hashtagerrors.com
* @copyright Copyright (c) 2019 Hashtag Errors
* @link https://360adaptive.com
* @copyright Copyright (c) 2023 360Adaptive Technologies
*/

namespace hashtagerrors\userinitialsphoto\controllers;
namespace bhashkar007\userinitialsphoto\controllers;

use hashtagerrors\userinitialsphoto\UserInitialsPhoto;
use bhashkar007\userinitialsphoto\UserInitialsPhoto;

use Craft;
use craft\web\Controller;

/**
* @author Hashtag Errors
* @author 360Adaptive Technologies
* @package UserInitialsPhoto
* @since 1.1.0
* @since 2.0.0
*/
class DefaultController extends Controller
{

// Protected Properties
// =========================================================================

/**
* @var bool|array Allows anonymous access to this controller's actions.
* The actions must be in 'kebab-case'
* @access protected
*/
protected $allowAnonymous = false;

// Public Methods
// =========================================================================
protected array|int|bool $allowAnonymous = false;

public function actionAssignPhoto()
{
$overwrite = Craft::$app->getRequest()->getParam('ui-overwrite');
UserInitialsPhoto::$plugin->userInitialsPhotoService->assignPhotos($overwrite);
return $this->redirectToPostedUrl();
}
}
}
36 changes: 8 additions & 28 deletions src/jobs/AssignPhotoTask.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
<?php
/**
* User Initials Photo plugin for Craft CMS 3.x
*
* User Initials Photo plugin for Craft CMS 4.x
* A plugin to assign profile picture of user with their name initials.
*
* @link http://www.hashtagerrors.com
* @copyright Copyright (c) 2019 Hashtag Errors
* @link https://360adaptive.com
* @copyright Copyright (c) 2023 360Adaptive Technologies
*/

namespace hashtagerrors\userinitialsphoto\jobs;
namespace bhashkar007\userinitialsphoto\jobs;

use hashtagerrors\userinitialsphoto\UserInitialsPhoto;
use bhashkar007\userinitialsphoto\UserInitialsPhoto;

use Craft;
use craft\queue\BaseJob;

/**
* @author Hashtag Errors
* @author 360Adaptive Technologies
* @package UserInitialsPhoto
* @since 1.1.0
* @since 2.0.0
*/
class AssignPhotoTask extends BaseJob
{
// Public Properties
// =========================================================================

/**
* @var string
*/
public $user;

// Public Methods
// =========================================================================

/**
* @inheritdoc
*/
public function execute($queue)
public function execute($queue): void
{
$errors = [];

Expand All @@ -58,12 +44,6 @@ public function execute($queue)
}
}

// Protected Methods
// =========================================================================

/**
* @inheritdoc
*/
protected function defaultDescription(): string
{
return Craft::t('user-initials-photo', 'Assigning photo to {name}.', [ 'name' => $this->user->name]);
Expand Down
Loading

0 comments on commit b06a635

Please sign in to comment.