Skip to content

Commit

Permalink
Merge pull request #48 from venveo/develop
Browse files Browse the repository at this point in the history
Finish 4.0.1
  • Loading branch information
Mosnar authored Nov 28, 2022
2 parents 8682aec + 49b6387 commit fd22572
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 37 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Bulk Edit Changelog

## 4.0.1 - 2022-10-28

### Fixed
- Fixed "Element query executed before Craft is fully initialized." warning

## 4.0.0 - 2022-10-24

### Added
Expand Down
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "venveo/craft-bulkedit",
"description": "Bulk edit Craft CMS element fields",
"type": "craft-plugin",
"version": "4.0.0",
"keywords": [
"craft",
"cms",
Expand Down Expand Up @@ -35,5 +34,15 @@
"handle": "venveo-bulk-edit",
"changelogUrl": "https://raw.githubusercontent.com/venveo/craft-bulkedit/master/CHANGELOG.md",
"class": "venveo\\bulkedit\\Plugin"
},
"config": {
"sort-packages": true,
"platform": {
"php": "8.0.2"
},
"allow-plugins": {
"yiisoft/yii2-composer": true,
"craftcms/plugin-installer": true
}
}
}
74 changes: 38 additions & 36 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use craft\events\RegisterElementActionsEvent;
use craft\events\RegisterUserPermissionsEvent;
use craft\services\UserPermissions;
use craft\web\Application;
use venveo\bulkedit\elements\actions\BulkEditElementAction;
use venveo\bulkedit\services\BulkEdit;
use yii\base\Event;
Expand Down Expand Up @@ -78,50 +79,51 @@ public function init()
'permissions' => $permissions
];
});
Craft::$app->on(Application::EVENT_INIT, function() {
if (Craft::$app->request->isCpRequest) {
if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_ENTRIES)) {
Event::on(Entry::class, Element::EVENT_REGISTER_ACTIONS,
function (RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}

if (Craft::$app->request->isCpRequest) {
if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_ENTRIES)) {
Event::on(Entry::class, Element::EVENT_REGISTER_ACTIONS,
function(RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}

if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_CATEGORIES)) {
Event::on(Category::class, Element::EVENT_REGISTER_ACTIONS,
function(RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}

if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_ASSETS)) {
Event::on(Asset::class, Element::EVENT_REGISTER_ACTIONS,
function(RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}
if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_CATEGORIES)) {
Event::on(Category::class, Element::EVENT_REGISTER_ACTIONS,
function (RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}

if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_USERS)) {
Event::on(User::class, Element::EVENT_REGISTER_ACTIONS,
function(RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}
if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_ASSETS)) {
Event::on(Asset::class, Element::EVENT_REGISTER_ACTIONS,
function (RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}

if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_PRODUCTS)) {
if (Craft::$app->plugins->isPluginInstalled('commerce') && class_exists(Product::class)) {
Event::on(Product::class, Element::EVENT_REGISTER_ACTIONS,
function(RegisterElementActionsEvent $event) {
if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_USERS)) {
Event::on(User::class, Element::EVENT_REGISTER_ACTIONS,
function (RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}

if (Craft::$app->user->checkPermission(self::PERMISSION_BULKEDIT_PRODUCTS)) {
if (Craft::$app->plugins->isPluginInstalled('commerce') && class_exists(Product::class)) {
Event::on(Product::class, Element::EVENT_REGISTER_ACTIONS,
function (RegisterElementActionsEvent $event) {
$event->actions[] = BulkEditElementAction::class;
}
);
}
}
}
}
});
}

/**
Expand Down

0 comments on commit fd22572

Please sign in to comment.