Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Dec 29, 2020
2 parents 6c6aaee + 340bc2b commit 42262c3
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 193 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<a name="1.7.0"></a>
# [1.7.0](https://github.com/flextype-plugins/acl) (2020-12-29)

### Features

* **core** update code base for new Flextype 0.9.14
* **core** Moving to PHP 7.4
* **core** use new TWIG Plugin 1.7.0

<a name="1.6.0"></a>
# [1.6.0](https://github.com/flextype-plugins/acl) (2020-12-20)

### Features

* **core** update code base for new Flextype 0.9.13

<a name="1.5.0"></a>
# [1.5.0](https://github.com/flextype-plugins/acl) (2020-12-06)

Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">ACL Plugin for <a href="http://flextype.org/">Flextype</a></h1>
<h1 align="center">ACL Plugin for <a href="https://flextype.org/">Flextype</a></h1>

<p align="center">
<a href="https://github.com/flextype-plugins/acl/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/acl.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/acl"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/acl"><img src="https://img.shields.io/github/downloads/flextype-plugins/acl/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.11-green.svg" alt="Flextype"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&color=black&label=Discord%20Chat" alt="Discord"></a>
<a href="https://github.com/flextype-plugins/acl/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/flextype.acl.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/acl"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/acl"><img src="https://img.shields.io/github/downloads/flextype-plugins/acl/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.14-green.svg" alt="Flextype"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&color=black&label=Discord%20Chat" alt="Discord"></a>
</p>

## Features
Expand All @@ -15,7 +15,7 @@ The following dependencies need to be downloaded and installed for ACL Plugin.

| Item | Version | Download |
|---|---|---|
| [flextype](https://github.com/flextype/flextype) | 0.9.12 | [download](https://github.com/flextype/flextype/releases) |
| [flextype](https://github.com/flextype/flextype) | 0.9.14 | [download](https://github.com/flextype/flextype/releases) |
| [twig](https://github.com/flextype-plugins/twig) | >=1.0.0 | [download](https://github.com/flextype-plugins/twig/releases) |

## Installation
Expand Down Expand Up @@ -447,7 +447,7 @@ You may restrict access for specific users to your specific content inside the T
#### Show private content for logged in users

```
{% if acl.isUserLoggedIn() %}
{% if flextype.acl.isUserLoggedIn() %}
Private content here..
{% else %}
Public content for users is here...
Expand All @@ -457,7 +457,7 @@ You may restrict access for specific users to your specific content inside the T
#### Show private content for users with roles: admin and student

```
{% if acl.isUserLoggedInRolesIn('admin, student') %}
{% if flextype.acl.isUserLoggedInRolesIn('admin, student') %}
Private content here..
{% else %}
Public content for users is here...
Expand All @@ -467,7 +467,7 @@ You may restrict access for specific users to your specific content inside the T
#### Show private content for users with uuids ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2 and d549af27-79a0-44f2-b9b1-e82b47bf87e2

```
{% if acl.isUserLoggedInUuidIn('ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2') %}
{% if flextype.acl.isUserLoggedInUuidIn('ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2') %}
Private content here..
{% else %}
Public content for users is here...
Expand All @@ -477,7 +477,7 @@ You may restrict access for specific users to your specific content inside the T
#### Show private content for users with emails jack@flextype.org, sam@flextype.org

```
{% if acl.isUserLoggedInEmailIn('jack@flextype.org, sam@flextype.org') %}
{% if flextype.acl.isUserLoggedInEmailIn('jack@flextype.org, sam@flextype.org') %}
Public content for users is here...
{% else %}
Public content for users is here...
Expand All @@ -487,22 +487,22 @@ You may restrict access for specific users to your specific content inside the T
#### Show logged in email

```
Hello {{ acl.getUserLoggedInEmail() }}
Hello {{ flextype.acl.getUserLoggedInEmail() }}
```

#### Show logged in uuid

```
Hello {{ acl.getUserLoggedInEmail() }},
your uuid: {{ acl.getUserLoggedInUuid() }}
Hello {{ flextype.acl.getUserLoggedInEmail() }},
your uuid: {{ flextype.acl.getUserLoggedInUuid() }}
```

#### Show logged in roles

```
Hello {{ acl.getUserLoggedInEmail() }},
your uuid: {{ acl.getUserLoggedInUuid() }}
and your roles: {{ acl.getUserLoggedInRoles() }}
Hello {{ flextype.acl.getUserLoggedInEmail() }},
your uuid: {{ flextype.acl.getUserLoggedInUuid() }}
and your roles: {{ flextype.acl.getUserLoggedInRoles() }}
```

### Restrict access in the PHP
Expand Down Expand Up @@ -564,4 +564,4 @@ echo 'and your roles: ' . flextype('acl')->getUserLoggedInRoles();

## LICENSE
[The MIT License (MIT)](https://github.com/flextype-plugins/acl/blob/master/LICENSE.txt)
Copyright (c) 2020 [Sergey Romanenko](https://github.com/Awilum)
Copyright (c) 2021 [Sergey Romanenko](https://github.com/Awilum)
8 changes: 0 additions & 8 deletions app/Models/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@

class Acl
{
/**
* __construct
*/
public function __construct()
{

}

/**
* Check is user logged in
*
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"issues": "https://github.com/flextype-plugins/acl/issues"
},
"require": {
"php": ">=7.3.0",
"php": ">=7.4.0",
"ext-json": "*",
"flextype-components/arrays" : "3.0.1",
"flextype-components/filesystem": "2.0.8"
Expand All @@ -25,7 +25,7 @@
"apcu-autoloader": true,
"optimize-autoloader": true,
"platform": {
"php": "7.3.0"
"php": "7.4.0"
}
},
"autoload": {
Expand Down
13 changes: 8 additions & 5 deletions dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@

use Flextype\Plugin\Acl\Models\Acl;
use Flextype\Plugin\Acl\Twig\AclTwigExtension;
use Flextype\Plugin\Twig\Twig\FlextypeTwig;
use Flextype\Foundation\Entries\Entries;
use Flextype\Plugin\Twig\Twig\FlextypeEntriesTwig;


/**
* Add ACL Model to Flextype container
*/
flextype()->container()['acl'] = static function () {
return new Acl();
};
flextype()->container()['acl'] = fn() => new Acl();


/**
* Add ACL Twig Extension to Flextype container
* Add ACL Model to Flextype Twig
*/
flextype('twig')->addExtension(new AclTwigExtension());
FlextypeTwig::macro('acl', fn() => flextype('acl'));
2 changes: 1 addition & 1 deletion entries_acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



flextype('emitter')->addListener('onEntryAfterInitialized', function() {
flextype('emitter')->addListener('onEntriesFetchSingleHasResult', function() {

// Get current entry
$entry = flextype('entries')->getStorage('fetch.data');
Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInEmailInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInEmailNotInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInRolesInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInRolesNotInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInUuidInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserLoggedInUuidNotInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
2 changes: 1 addition & 1 deletion middlewares/AclIsUserNotLoggedInMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand Down
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ACL
version: 1.5.0
version: 1.7.0
description: ACL plugin for Flextype.
icon: fas fa-users-cog
author:
Expand All @@ -11,5 +11,5 @@ bugs: https://github.com/flextype-plugins/acl/issues
license: MIT

dependencies:
flextype: 0.9.12
flextype: 0.9.14
twig: '>=1.0.0'
2 changes: 1 addition & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
enabled: true

# ACL plugin priority
priority: 95
priority: 40
24 changes: 12 additions & 12 deletions shortcodes/AclShortcodesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand All @@ -12,7 +12,7 @@
use Thunder\Shortcode\Shortcode\ShortcodeInterface;

// Shortcode: [userLoggedInEmail]
flextype('shortcode')->addHandler('userLoggedInEmail', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInEmail', static function (ShortcodeInterface $s) {
if (flextype('acl')->getUserLoggedInEmail()) {
return flextype('acl')->getUserLoggedInEmail();
}
Expand All @@ -21,7 +21,7 @@
});

// Shortcode: [userLoggedInUuid]
flextype('shortcode')->addHandler('userLoggedInUuid', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInUuid', static function (ShortcodeInterface $s) {
if (flextype('acl')->getUserLoggedInUuid()) {
return flextype('acl')->getUserLoggedInUuid();
}
Expand All @@ -30,7 +30,7 @@
});

// Shortcode: [userLoggedInRoles]
flextype('shortcode')->addHandler('userLoggedInRoles', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInRoles', static function (ShortcodeInterface $s) {
if (flextype('acl')->getUserLoggedInRoles()) {
return flextype('acl')->getUserLoggedInRoles();
}
Expand All @@ -39,7 +39,7 @@
});

// Shortcode: [userLoggedIn]Private content here..[/userLoggedIn]
flextype('shortcode')->addHandler('userLoggedIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedIn', static function (ShortcodeInterface $s) {
if (flextype('acl')->isUserLoggedIn()) {
return $s->getContent();
}
Expand All @@ -48,7 +48,7 @@
});

// Shortcode: [userLoggedInRolesIn roles="admin, student"]Private content here..[/userLoggedInRolesIn]
flextype('shortcode')->addHandler('userLoggedInRolesIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInRolesIn', static function (ShortcodeInterface $s) {
if (flextype('acl')->isUserLoggedInRolesIn($s->getParameter('roles'))) {
return $s->getContent();
}
Expand All @@ -57,7 +57,7 @@
});

// Shortcode: [userLoggedInUuidIn uuids="ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2"]Private content here..[/userLoggedInUuidOneOf]
flextype('shortcode')->addHandler('userLoggedInUuidIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInUuidIn', static function (ShortcodeInterface $s) {
if (flextype('acl')->isUserLoggedInUuidIn($s->getParameter('uuids'))) {
return $s->getContent();
}
Expand All @@ -66,7 +66,7 @@
});

// Shortcode: [userLoggedInEmailIn emails="jack@flexype.org, sam@flextype.org"]Private content here..[/userLoggedInUsernameOneOf]
flextype('shortcode')->addHandler('userLoggedInEmailIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInEmailIn', static function (ShortcodeInterface $s) {
if (flextype('acl')->isUserLoggedInEmailIn($s->getParameter('emails'))) {
return $s->getContent();
}
Expand All @@ -75,7 +75,7 @@
});

// Shortcode: [userNotLoggedIn]Content for not logged in user here..[/userNotLoggedIn]
flextype('shortcode')->addHandler('userNotLoggedIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userNotLoggedIn', static function (ShortcodeInterface $s) {
if (! flextype('acl')->isUserLoggedIn()) {
return $s->getContent();
}
Expand All @@ -84,7 +84,7 @@
});

// Shortcode: [userLoggedInRolesNotIn roles="admin, student"]Private content here..[/userLoggedInRolesNotIn]
flextype('shortcode')->addHandler('userLoggedInRolesNotIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInRolesNotIn', static function (ShortcodeInterface $s) {
if (! flextype('acl')->isUserLoggedInRolesNotIn($s->getParameter('roles'))) {
return $s->getContent();
}
Expand All @@ -93,7 +93,7 @@
});

// Shortcode: [userLoggedInUuidNotIn uuids="ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2, d549af27-79a0-44f2-b9b1-e82b47bf87e2"]Private content here..[/userLoggedInUuidNotIn]
flextype('shortcode')->addHandler('userLoggedInUuidNotIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInUuidNotIn', static function (ShortcodeInterface $s) {
if (! flextype('acl')->isUserLoggedInUuidNotIn($s->getParameter('uuids'))) {
return $s->getContent();
}
Expand All @@ -102,7 +102,7 @@
});

// Shortcode: [userLoggedInEmailNotIn emails="jack@flexype.org, sam@flextype.org"]Private content here..[/userLoggedInEmailNotIn]
flextype('shortcode')->addHandler('userLoggedInEmailNotIn', static function (ShortcodeInterface $s) {
flextype('parsers')->shortcode()->addHandler('userLoggedInEmailNotIn', static function (ShortcodeInterface $s) {
if (! flextype('acl')->isUserLoggedInEmailsNotIn($s->getParameter('emails'))) {
return $s->getContent();
}
Expand Down
Loading

0 comments on commit 42262c3

Please sign in to comment.