From ba051b68a79c29c938f50bdcc5c28786ffd1cc5b Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 6 Dec 2020 23:52:29 +0300 Subject: [PATCH] ACL 1.5.0 --- .gitignore | 20 ++++++++++++++++++++ CHANGELOG.md | 7 +++++++ LICENSE.txt | 2 +- app/Models/Acl.php | 18 +++++++++--------- composer.json | 4 +++- entries_acl.php | 10 +++++----- plugin.yaml | 4 ++-- 7 files changed, 47 insertions(+), 18 deletions(-) create mode 100755 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..c00a8d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Global +.composer +composer.lock +package-lock.json +vendor/ +node_modules/ +dist/ + +# Flextype Site Specific +var/ + +# OS Generated +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db +*.swp + +# phpstorm +.idea/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d3f21..cbae7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +# [1.5.0](https://github.com/flextype-plugins/acl) (2020-12-06) + +### Features + +* **core** update code base for new Flextype 0.9.12 + # [1.4.0](https://github.com/flextype-plugins/acl) (2020-08-25) diff --git a/LICENSE.txt b/LICENSE.txt index cacc3f0..6b05ac2 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Sergey Romanenko +Copyright (c) 2021 Sergey Romanenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/Models/Acl.php b/app/Models/Acl.php index 5854c26..17adef9 100644 --- a/app/Models/Acl.php +++ b/app/Models/Acl.php @@ -11,7 +11,7 @@ namespace Flextype\Plugin\Acl\Models; -use Flextype\Component\Session\Session; + use function array_intersect; use function array_map; use function explode; @@ -36,7 +36,7 @@ public function __construct() */ public function isUserLoggedIn() : bool { - if (Session::exists('user_logged_in')) { + if (flextype('session')->has('user_logged_in')) { return true; } @@ -109,7 +109,7 @@ public function isUserLoggedInUuidIn(string $uuids) : bool */ public function getUserLoggedInEmail() : string { - return Session::exists('user_email') ? Session::get('user_email') : ''; + return flextype('session')->has('user_email') ? flextype('session')->get('user_email') : ''; } /** @@ -121,7 +121,7 @@ public function getUserLoggedInEmail() : string */ public function getUserLoggedInRoles() : string { - return Session::exists('user_roles') ? Session::get('user_roles') : ''; + return flextype('session')->has('user_roles') ? flextype('session')->get('user_roles') : ''; } /** @@ -133,7 +133,7 @@ public function getUserLoggedInRoles() : string */ public function getUserLoggedInUuid() : string { - return Session::exists('user_uuid') ? Session::get('user_uuid') : ''; + return flextype('session')->has('user_uuid') ? flextype('session')->get('user_uuid') : ''; } /** @@ -145,7 +145,7 @@ public function getUserLoggedInUuid() : string */ public function setUserLoggedIn(bool $logged_in) { - Session::set('user_logged_in', $logged_in); + flextype('session')->set('user_logged_in', $logged_in); } /** @@ -157,7 +157,7 @@ public function setUserLoggedIn(bool $logged_in) */ public function setUserLoggedInUuid(string $uuid) { - Session::set('user_uuid', $uuid); + flextype('session')->set('user_uuid', $uuid); } /** @@ -169,7 +169,7 @@ public function setUserLoggedInUuid(string $uuid) */ public function setUserLoggedInEmail(string $email) { - Session::set('user_email', $email); + flextype('session')->set('user_email', $email); } /** @@ -181,6 +181,6 @@ public function setUserLoggedInEmail(string $email) */ public function setUserLoggedInRoles(string $roles) { - Session::set('user_roles', $roles); + flextype('session')->set('user_roles', $roles); } } diff --git a/composer.json b/composer.json index 36d6fd1..188b0e2 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,9 @@ }, "require": { "php": ">=7.3.0", - "ext-json": "*" + "ext-json": "*", + "flextype-components/arrays" : "3.0.1", + "flextype-components/filesystem": "2.0.8" }, "config": { "apcu-autoloader": true, diff --git a/entries_acl.php b/entries_acl.php index d074ebe..16576f7 100644 --- a/entries_acl.php +++ b/entries_acl.php @@ -2,31 +2,31 @@ namespace Flextype\Plugin\Acl; -use Flextype\Component\Session\Session; + flextype('emitter')->addListener('onEntryAfterInitialized', function() { // Get current entry - $entry = flextype('entries')->entry; + $entry = flextype('entries')->getStorage('fetch.data'); // Set ACL rules based on accounts uuids if (isset($entry['acl']['accounts']['uuids'])) { if (!flextype('acl')->isUserLoggedInUuidsIn($entry['acl']['accounts']['uuids'])) { - flextype('entries')->entry = []; + flextype('entries')->setStorage('fetch.data', []); } } // Set ACL rules based on accounts emails if (isset($entry['acl']['accounts']['emails'])) { if (!flextype('acl')->isUserLoggedInEmailsIn($entry['acl']['accounts']['emails'])) { - flextype('entries')->entry = []; + flextype('entries')->setStorage('fetch.data', []); } } // Set ACL rules based on accounts roles if (isset($entry['acl']['accounts']['roles'])) { if (!flextype('acl')->isUserLoggedInRolesIn($entry['acl']['accounts']['roles'])) { - flextype('entries')->entry = []; + flextype('entries')->setStorage('fetch.data', []); } } }); diff --git a/plugin.yaml b/plugin.yaml index 4c3c007..c144c06 100755 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: ACL -version: 1.4.0 +version: 1.5.0 description: ACL plugin for Flextype. icon: fas fa-users-cog author: @@ -11,5 +11,5 @@ bugs: https://github.com/flextype-plugins/acl/issues license: MIT dependencies: - flextype: 0.9.11 + flextype: 0.9.12 twig: '>=1.0.0'