diff --git a/composer.json b/composer.json index 70a7fd0dd52155dbede892b42fa6f14ad46ec0bd..961d234dda8c48c01b355781be618df3a51bfe73 100644 --- a/composer.json +++ b/composer.json @@ -105,7 +105,6 @@ "drupal/config_ignore": "2.3", "drupal/config_update": "1.7", "drupal/console": "1.9.7", - "drupal/content_access": "1.0-alpha3", "drupal/core-composer-scaffold": "^9.0", "drupal/core-recommended": "9.5.9", "drupal/crop": "2.3", diff --git a/composer.lock b/composer.lock index 7d3f9816104f22c0d2df78cac65b04e346c62569..53de60ed08bdf3381fb3b13081df6819a781d87a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e7563b426a09017f8207d3ccff7d6732", + "content-hash": "d6979f4dc346b0c39eb44fdefd25e7bc", "packages": [ { "name": "alchemy/zippy", @@ -1416,25 +1416,29 @@ }, { "name": "doctrine/deprecations", - "version": "v1.0.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -1453,9 +1457,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" }, - "time": "2022-05-02T15:47:09+00:00" + "time": "2023-06-03T09:27:29+00:00" }, { "name": "doctrine/lexer", @@ -2965,57 +2969,6 @@ }, "time": "2020-11-18T00:15:28+00:00" }, - { - "name": "drupal/content_access", - "version": "1.0.0-alpha3", - "source": { - "type": "git", - "url": "https://git.drupalcode.org/project/content_access.git", - "reference": "8.x-1.0-alpha3" - }, - "dist": { - "type": "zip", - "url": "https://ftp.drupal.org/files/projects/content_access-8.x-1.0-alpha3.zip", - "reference": "8.x-1.0-alpha3", - "shasum": "38715d271d166cbf7ed801acd6cee6010962bc79" - }, - "require": { - "drupal/core": "^8 || ^9" - }, - "require-dev": { - "drupal/acl": "~1.0" - }, - "type": "drupal-module", - "extra": { - "drupal": { - "version": "8.x-1.0-alpha3", - "datestamp": "1600327861", - "security-coverage": { - "status": "not-covered", - "message": "Project has not opted into security advisory coverage!" - } - } - }, - "notification-url": "https://packages.drupal.org/8/downloads", - "license": [ - "GPL-2.0" - ], - "authors": [ - { - "name": "fago", - "homepage": "https://www.drupal.org/user/16747" - }, - { - "name": "gisle", - "homepage": "https://www.drupal.org/user/409554" - } - ], - "description": "Provides flexible content access control.", - "homepage": "https://drupal.org/project/content_access", - "support": { - "source": "https://git.drupalcode.org/project/content_access" - } - }, { "name": "drupal/core", "version": "9.5.9", @@ -8627,16 +8580,16 @@ }, { "name": "egulias/email-validator", - "version": "3.2.5", + "version": "3.2.6", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "b531a2311709443320c786feb4519cfaf94af796" + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/b531a2311709443320c786feb4519cfaf94af796", - "reference": "b531a2311709443320c786feb4519cfaf94af796", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", "shasum": "" }, "require": { @@ -8682,7 +8635,7 @@ ], "support": { "issues": "https://github.com/egulias/EmailValidator/issues", - "source": "https://github.com/egulias/EmailValidator/tree/3.2.5" + "source": "https://github.com/egulias/EmailValidator/tree/3.2.6" }, "funding": [ { @@ -8690,7 +8643,7 @@ "type": "github" } ], - "time": "2023-01-02T17:26:14+00:00" + "time": "2023-06-01T07:04:22+00:00" }, { "name": "enlightn/security-checker", @@ -16085,16 +16038,16 @@ }, { "name": "symfony/var-dumper", - "version": "v5.4.23", + "version": "v5.4.25", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "9a8a5b6d6508928174ded2109e29328a55342a42" + "reference": "82269f73c0f0f9859ab9b6900eebacbe54954ede" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/9a8a5b6d6508928174ded2109e29328a55342a42", - "reference": "9a8a5b6d6508928174ded2109e29328a55342a42", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/82269f73c0f0f9859ab9b6900eebacbe54954ede", + "reference": "82269f73c0f0f9859ab9b6900eebacbe54954ede", "shasum": "" }, "require": { @@ -16103,7 +16056,6 @@ "symfony/polyfill-php80": "^1.16" }, "conflict": { - "phpunit/phpunit": "<5.4.3", "symfony/console": "<4.4" }, "require-dev": { @@ -16154,7 +16106,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.23" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.25" }, "funding": [ { @@ -16170,7 +16122,7 @@ "type": "tidelift" } ], - "time": "2023-04-18T09:26:27+00:00" + "time": "2023-06-20T20:56:26+00:00" }, { "name": "symfony/var-exporter", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 2cbb06db5d41e8612ab66c49a2262581812749bb..22d2e333ecc76e7d5a950d5669b9fbc8935d67d3 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1461,31 +1461,35 @@ }, { "name": "doctrine/deprecations", - "version": "v1.0.0", - "version_normalized": "1.0.0.0", + "version": "v1.1.1", + "version_normalized": "1.1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" }, - "time": "2022-05-02T15:47:09+00:00", + "time": "2023-06-03T09:27:29+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1501,7 +1505,7 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" }, "install-path": "../doctrine/deprecations" }, @@ -3062,64 +3066,6 @@ "description": "Drupal Console Extend Plugin", "install-path": "../drupal/console-extend-plugin" }, - { - "name": "drupal/content_access", - "version": "1.0.0-alpha3", - "version_normalized": "1.0.0.0-alpha3", - "source": { - "type": "git", - "url": "https://git.drupalcode.org/project/content_access.git", - "reference": "8.x-1.0-alpha3" - }, - "dist": { - "type": "zip", - "url": "https://ftp.drupal.org/files/projects/content_access-8.x-1.0-alpha3.zip", - "reference": "8.x-1.0-alpha3", - "shasum": "38715d271d166cbf7ed801acd6cee6010962bc79" - }, - "require": { - "drupal/core": "^8 || ^9" - }, - "require-dev": { - "drupal/acl": "~1.0" - }, - "type": "drupal-module", - "extra": { - "drupal": { - "version": "8.x-1.0-alpha3", - "datestamp": "1600327861", - "security-coverage": { - "status": "not-covered", - "message": "Project has not opted into security advisory coverage!" - } - } - }, - "installation-source": "dist", - "notification-url": "https://packages.drupal.org/8/downloads", - "license": [ - "GPL-2.0" - ], - "authors": [ - { - "name": "fago", - "homepage": "https://www.drupal.org/user/16747" - }, - { - "name": "gisle", - "homepage": "https://www.drupal.org/user/409554" - }, - { - "name": "good_man", - "homepage": "https://www.drupal.org/user/265439" - } - ], - "description": "Provides flexible content access control.", - "homepage": "https://drupal.org/project/content_access", - "support": { - "source": "https://git.drupalcode.org/project/content_access" - }, - "install-path": "../../web/modules/content_access" - }, { "name": "drupal/core", "version": "9.5.9", @@ -8947,17 +8893,17 @@ }, { "name": "egulias/email-validator", - "version": "3.2.5", - "version_normalized": "3.2.5.0", + "version": "3.2.6", + "version_normalized": "3.2.6.0", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "b531a2311709443320c786feb4519cfaf94af796" + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/b531a2311709443320c786feb4519cfaf94af796", - "reference": "b531a2311709443320c786feb4519cfaf94af796", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", + "reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7", "shasum": "" }, "require": { @@ -8972,7 +8918,7 @@ "suggest": { "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" }, - "time": "2023-01-02T17:26:14+00:00", + "time": "2023-06-01T07:04:22+00:00", "type": "library", "extra": { "branch-alias": { @@ -9005,7 +8951,7 @@ ], "support": { "issues": "https://github.com/egulias/EmailValidator/issues", - "source": "https://github.com/egulias/EmailValidator/tree/3.2.5" + "source": "https://github.com/egulias/EmailValidator/tree/3.2.6" }, "funding": [ { @@ -16689,17 +16635,17 @@ }, { "name": "symfony/var-dumper", - "version": "v5.4.23", - "version_normalized": "5.4.23.0", + "version": "v5.4.25", + "version_normalized": "5.4.25.0", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "9a8a5b6d6508928174ded2109e29328a55342a42" + "reference": "82269f73c0f0f9859ab9b6900eebacbe54954ede" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/9a8a5b6d6508928174ded2109e29328a55342a42", - "reference": "9a8a5b6d6508928174ded2109e29328a55342a42", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/82269f73c0f0f9859ab9b6900eebacbe54954ede", + "reference": "82269f73c0f0f9859ab9b6900eebacbe54954ede", "shasum": "" }, "require": { @@ -16708,7 +16654,6 @@ "symfony/polyfill-php80": "^1.16" }, "conflict": { - "phpunit/phpunit": "<5.4.3", "symfony/console": "<4.4" }, "require-dev": { @@ -16723,7 +16668,7 @@ "ext-intl": "To show region name in time zone dump", "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script" }, - "time": "2023-04-18T09:26:27+00:00", + "time": "2023-06-20T20:56:26+00:00", "bin": [ "Resources/bin/var-dump-server" ], @@ -16761,7 +16706,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.23" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.25" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index c11be1243039d62536daf0b33c90c3305c848473..7f1415a8857fa83d5f86fec72e41415edc9c537a 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'osu-asc-webservices/d8-upstream', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '8322ffc7651bab972d71fa671738ac3969b0eb9b', + 'reference' => '467f19657ab91922f4980095ea79aed35fa6633d', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -236,9 +236,9 @@ 'dev_requirement' => false, ), 'doctrine/deprecations' => array( - 'pretty_version' => 'v1.0.0', - 'version' => '1.0.0.0', - 'reference' => '0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de', + 'pretty_version' => 'v1.1.1', + 'version' => '1.1.1.0', + 'reference' => '612a3ee5ab0d5dd97b7cf3874a6efe24325efac3', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/deprecations', 'aliases' => array(), @@ -466,15 +466,6 @@ 'aliases' => array(), 'dev_requirement' => false, ), - 'drupal/content_access' => array( - 'pretty_version' => '1.0.0-alpha3', - 'version' => '1.0.0.0-alpha3', - 'reference' => '8.x-1.0-alpha3', - 'type' => 'drupal-module', - 'install_path' => __DIR__ . '/../../web/modules/content_access', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'drupal/core' => array( 'pretty_version' => '9.5.9', 'version' => '9.5.9.0', @@ -1400,9 +1391,9 @@ 'dev_requirement' => false, ), 'egulias/email-validator' => array( - 'pretty_version' => '3.2.5', - 'version' => '3.2.5.0', - 'reference' => 'b531a2311709443320c786feb4519cfaf94af796', + 'pretty_version' => '3.2.6', + 'version' => '3.2.6.0', + 'reference' => 'e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7', 'type' => 'library', 'install_path' => __DIR__ . '/../egulias/email-validator', 'aliases' => array(), @@ -1621,7 +1612,7 @@ 'osu-asc-webservices/d8-upstream' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '8322ffc7651bab972d71fa671738ac3969b0eb9b', + 'reference' => '467f19657ab91922f4980095ea79aed35fa6633d', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -2523,9 +2514,9 @@ 'dev_requirement' => false, ), 'symfony/var-dumper' => array( - 'pretty_version' => 'v5.4.23', - 'version' => '5.4.23.0', - 'reference' => '9a8a5b6d6508928174ded2109e29328a55342a42', + 'pretty_version' => 'v5.4.25', + 'version' => '5.4.25.0', + 'reference' => '82269f73c0f0f9859ab9b6900eebacbe54954ede', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/var-dumper', 'aliases' => array(), diff --git a/vendor/doctrine/deprecations/README.md b/vendor/doctrine/deprecations/README.md index 22f0cced3e65712d5f62b41f931ee15b15b138ab..93caf83f821755f39bea54026d4cc52b9e5976ae 100644 --- a/vendor/doctrine/deprecations/README.md +++ b/vendor/doctrine/deprecations/README.md @@ -19,13 +19,16 @@ Enable Doctrine deprecations to be sent to a PSR3 logger: ``` Enable Doctrine deprecations to be sent as `@trigger_error($message, E_USER_DEPRECATED)` -messages. +messages by setting the `DOCTRINE_DEPRECATIONS` environment variable to `trigger`. +Alternatively, call: ```php \Doctrine\Deprecations\Deprecation::enableWithTriggerError(); ``` -If you only want to enable deprecation tracking, without logging or calling `trigger_error` then call: +If you only want to enable deprecation tracking, without logging or calling `trigger_error` +then set the `DOCTRINE_DEPRECATIONS` environment variable to `track`. +Alternatively, call: ```php \Doctrine\Deprecations\Deprecation::enableTrackingDeprecations(); diff --git a/vendor/doctrine/deprecations/composer.json b/vendor/doctrine/deprecations/composer.json index c79e38cdcd41e75faf3a0a56bc7b6d7922701fee..f8319f9a2a113c7c192271378ead2efe8d39db66 100644 --- a/vendor/doctrine/deprecations/composer.json +++ b/vendor/doctrine/deprecations/composer.json @@ -1,22 +1,28 @@ { "name": "doctrine/deprecations", - "type": "library", "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", "license": "MIT", + "type": "library", + "homepage": "https://www.doctrine-project.org/", "require": { - "php": "^7.1|^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3", - "doctrine/coding-standard": "^9" + "doctrine/coding-standard": "^9", + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" }, "autoload": { - "psr-4": {"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"} + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } }, "autoload-dev": { "psr-4": { diff --git a/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php b/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php index 1029372faa62b61f0244bd9de2389ff63c64309e..07cb43b6ce30e97dd9f0d927bd0d6abfe8976da2 100644 --- a/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php +++ b/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php @@ -8,6 +8,7 @@ use function array_key_exists; use function array_reduce; +use function assert; use function debug_backtrace; use function sprintf; use function strpos; @@ -46,8 +47,8 @@ class Deprecation private const TYPE_TRIGGER_ERROR = 2; private const TYPE_PSR_LOGGER = 4; - /** @var int */ - private static $type = self::TYPE_NONE; + /** @var int-mask-of<self::TYPE_*>|null */ + private static $type; /** @var LoggerInterface|null */ private static $logger; @@ -56,6 +57,9 @@ class Deprecation private static $ignoredPackages = []; /** @var array<string,int> */ + private static $triggeredDeprecations = []; + + /** @var array<string,bool> */ private static $ignoredLinks = []; /** @var bool */ @@ -68,21 +72,27 @@ class Deprecation * deprecation. It is additionally used to de-duplicate the trigger of the * same deprecation during a request. * - * @param mixed $args + * @param float|int|string $args */ public static function trigger(string $package, string $link, string $message, ...$args): void { - if (self::$type === self::TYPE_NONE) { + $type = self::$type ?? self::getTypeFromEnv(); + + if ($type === self::TYPE_NONE) { + return; + } + + if (isset(self::$ignoredLinks[$link])) { return; } - if (array_key_exists($link, self::$ignoredLinks)) { - self::$ignoredLinks[$link]++; + if (array_key_exists($link, self::$triggeredDeprecations)) { + self::$triggeredDeprecations[$link]++; } else { - self::$ignoredLinks[$link] = 1; + self::$triggeredDeprecations[$link] = 1; } - if (self::$deduplication === true && self::$ignoredLinks[$link] > 1) { + if (self::$deduplication === true && self::$triggeredDeprecations[$link] > 1) { return; } @@ -114,18 +124,20 @@ public static function trigger(string $package, string $link, string $message, . * deprecation tracking is enabled even during deduplication, because it * needs to call {@link debug_backtrace()} * - * @param mixed $args + * @param float|int|string $args */ public static function triggerIfCalledFromOutside(string $package, string $link, string $message, ...$args): void { - if (self::$type === self::TYPE_NONE) { + $type = self::$type ?? self::getTypeFromEnv(); + + if ($type === self::TYPE_NONE) { return; } $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); // first check that the caller is not from a tests folder, in which case we always let deprecations pass - if (strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) { + if (isset($backtrace[1]['file'], $backtrace[0]['file']) && strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) { $path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR; if (strpos($backtrace[0]['file'], $path) === false) { @@ -137,13 +149,17 @@ public static function triggerIfCalledFromOutside(string $package, string $link, } } - if (array_key_exists($link, self::$ignoredLinks)) { - self::$ignoredLinks[$link]++; + if (isset(self::$ignoredLinks[$link])) { + return; + } + + if (array_key_exists($link, self::$triggeredDeprecations)) { + self::$triggeredDeprecations[$link]++; } else { - self::$ignoredLinks[$link] = 1; + self::$triggeredDeprecations[$link] = 1; } - if (self::$deduplication === true && self::$ignoredLinks[$link] > 1) { + if (self::$deduplication === true && self::$triggeredDeprecations[$link] > 1) { return; } @@ -157,31 +173,35 @@ public static function triggerIfCalledFromOutside(string $package, string $link, } /** - * @param array<mixed> $backtrace + * @param list<array{function: string, line?: int, file?: string, class?: class-string, type?: string, args?: mixed[], object?: object}> $backtrace */ private static function delegateTriggerToBackend(string $message, array $backtrace, string $link, string $package): void { - if ((self::$type & self::TYPE_PSR_LOGGER) > 0) { + $type = self::$type ?? self::getTypeFromEnv(); + + if (($type & self::TYPE_PSR_LOGGER) > 0) { $context = [ - 'file' => $backtrace[0]['file'], - 'line' => $backtrace[0]['line'], + 'file' => $backtrace[0]['file'] ?? null, + 'line' => $backtrace[0]['line'] ?? null, 'package' => $package, 'link' => $link, ]; + assert(self::$logger !== null); + self::$logger->notice($message, $context); } - if (! ((self::$type & self::TYPE_TRIGGER_ERROR) > 0)) { + if (! (($type & self::TYPE_TRIGGER_ERROR) > 0)) { return; } $message .= sprintf( ' (%s:%d called by %s:%d, %s, package %s)', - self::basename($backtrace[0]['file']), - $backtrace[0]['line'], - self::basename($backtrace[1]['file']), - $backtrace[1]['line'], + self::basename($backtrace[0]['file'] ?? 'native code'), + $backtrace[0]['line'] ?? 0, + self::basename($backtrace[1]['file'] ?? 'native code'), + $backtrace[1]['line'] ?? 0, $link, $package ); @@ -205,16 +225,19 @@ private static function basename(string $filename): string public static function enableTrackingDeprecations(): void { + self::$type = self::$type ?? 0; self::$type |= self::TYPE_TRACK_DEPRECATIONS; } public static function enableWithTriggerError(): void { + self::$type = self::$type ?? 0; self::$type |= self::TYPE_TRIGGER_ERROR; } public static function enableWithPsrLogger(LoggerInterface $logger): void { + self::$type = self::$type ?? 0; self::$type |= self::TYPE_PSR_LOGGER; self::$logger = $logger; } @@ -229,9 +252,10 @@ public static function disable(): void self::$type = self::TYPE_NONE; self::$logger = null; self::$deduplication = true; + self::$ignoredLinks = []; - foreach (self::$ignoredLinks as $link => $count) { - self::$ignoredLinks[$link] = 0; + foreach (self::$triggeredDeprecations as $link => $count) { + self::$triggeredDeprecations[$link] = 0; } } @@ -243,13 +267,13 @@ public static function ignorePackage(string $packageName): void public static function ignoreDeprecations(string ...$links): void { foreach ($links as $link) { - self::$ignoredLinks[$link] = 0; + self::$ignoredLinks[$link] = true; } } public static function getUniqueTriggeredDeprecationsCount(): int { - return array_reduce(self::$ignoredLinks, static function (int $carry, int $count) { + return array_reduce(self::$triggeredDeprecations, static function (int $carry, int $count) { return $carry + $count; }, 0); } @@ -261,6 +285,28 @@ public static function getUniqueTriggeredDeprecationsCount(): int */ public static function getTriggeredDeprecations(): array { - return self::$ignoredLinks; + return self::$triggeredDeprecations; + } + + /** + * @return int-mask-of<self::TYPE_*> + */ + private static function getTypeFromEnv(): int + { + switch ($_SERVER['DOCTRINE_DEPRECATIONS'] ?? $_ENV['DOCTRINE_DEPRECATIONS'] ?? null) { + case 'trigger': + self::$type = self::TYPE_TRIGGER_ERROR; + break; + + case 'track': + self::$type = self::TYPE_TRACK_DEPRECATIONS; + break; + + default: + self::$type = self::TYPE_NONE; + break; + } + + return self::$type; } } diff --git a/vendor/doctrine/deprecations/phpstan.neon b/vendor/doctrine/deprecations/phpstan.neon new file mode 100644 index 0000000000000000000000000000000000000000..4ee286b8a779691c0ccd5a75f2776e169e63210c --- /dev/null +++ b/vendor/doctrine/deprecations/phpstan.neon @@ -0,0 +1,9 @@ +parameters: + level: 6 + paths: + - lib + - tests + +includes: + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-phpunit/rules.neon diff --git a/vendor/doctrine/deprecations/psalm.xml b/vendor/doctrine/deprecations/psalm.xml new file mode 100644 index 0000000000000000000000000000000000000000..ad76e32e3c87ea485a23721e6ed785a6826f560f --- /dev/null +++ b/vendor/doctrine/deprecations/psalm.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<psalm + errorLevel="1" + resolveFromConfigFile="true" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="https://getpsalm.org/schema/config" + xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + findUnusedBaselineEntry="true" + findUnusedCode="false" +> + <projectFiles> + <directory name="lib/Doctrine/Deprecations" /> + <directory name="tests/Doctrine/Deprecations" /> + <ignoreFiles> + <directory name="vendor" /> + </ignoreFiles> + </projectFiles> + <plugins> + <pluginClass class="Psalm\PhpUnitPlugin\Plugin"/> + </plugins> + <issueHandlers> + <DeprecatedMethod> + <errorLevel type="suppress"> + <!-- Remove when dropping support for PHPUnit 9.6 --> + <referencedMethod name="PHPUnit\Framework\TestCase::expectDeprecation"/> + <referencedMethod name="PHPUnit\Framework\TestCase::expectDeprecationMessage"/> + </errorLevel> + </DeprecatedMethod> + </issueHandlers> +</psalm> diff --git a/vendor/egulias/email-validator/src/EmailLexer.php b/vendor/egulias/email-validator/src/EmailLexer.php index 6add6bd2b9e39e5fc28dc04cd3aab32e14b2796c..4099758ce5d2453e124f270c85ac7aee78f8f9af 100644 --- a/vendor/egulias/email-validator/src/EmailLexer.php +++ b/vendor/egulias/email-validator/src/EmailLexer.php @@ -213,13 +213,11 @@ public function find($type) : bool public function moveNext() : bool { if ($this->hasToRecord && $this->previous === self::$nullToken) { - $this->accumulator .= $this->token['value']; + $this->accumulator .= ((array) $this->token)['value']; } - $this->previous = $this->token instanceof Token - ? ['value' => $this->token->value, 'type' => $this->token->type, 'position' => $this->token->position] - : $this->token; - + $this->previous = (array) $this->token; + if($this->lookahead === null) { $this->lookahead = self::$nullToken; } @@ -227,7 +225,7 @@ public function moveNext() : bool $hasNext = parent::moveNext(); if ($this->hasToRecord) { - $this->accumulator .= $this->token['value']; + $this->accumulator .= ((array) $this->token)['value']; } return $hasNext; diff --git a/vendor/egulias/email-validator/src/Parser.php b/vendor/egulias/email-validator/src/Parser.php index b1905f9abf9b34e3e1d283bbc24eb65a3c6e2cd3..4e5ac7d1f6da036b753936a4f89082c4b5017506 100644 --- a/vendor/egulias/email-validator/src/Parser.php +++ b/vendor/egulias/email-validator/src/Parser.php @@ -29,7 +29,7 @@ abstract protected function preLeftParsing() : Result; public function __construct(EmailLexer $lexer) { - $this->lexer = $lexer; + $this->lexer = $lexer; } public function parse(string $str) : Result @@ -51,7 +51,7 @@ public function parse(string $str) : Result return $localPartResult; } - $domainPartResult = $this->parseRightFromAt(); + $domainPartResult = $this->parseRightFromAt(); if ($domainPartResult->isInvalid()) { return $domainPartResult; @@ -73,6 +73,6 @@ protected function hasAtToken() : bool $this->lexer->moveNext(); $this->lexer->moveNext(); - return $this->lexer->token['type'] !== EmailLexer::S_AT; + return ((array) $this->lexer->token)['type'] !== EmailLexer::S_AT; } } diff --git a/vendor/egulias/email-validator/src/Parser/Comment.php b/vendor/egulias/email-validator/src/Parser/Comment.php index d6f3032fc3c66924854aad7ded9f7463cf6c1398..34ef97263de85675e17c8ea93760c481ef2df7e8 100644 --- a/vendor/egulias/email-validator/src/Parser/Comment.php +++ b/vendor/egulias/email-validator/src/Parser/Comment.php @@ -31,15 +31,15 @@ public function __construct(EmailLexer $lexer, CommentStrategy $commentStrategy) public function parse() : Result { - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS) { $this->openedParenthesis++; if($this->noClosingParenthesis()) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']); + return new InvalidEmail(new UnclosedComment(), ((array) $this->lexer->token)['value']); } } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + return new InvalidEmail(new UnOpenedComment(), ((array) $this->lexer->token)['value']); } $this->warnings[WarningComment::CODE] = new WarningComment(); @@ -58,10 +58,10 @@ public function parse() : Result } if($this->openedParenthesis >= 1) { - return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']); + return new InvalidEmail(new UnclosedComment(), ((array) $this->lexer->token)['value']); } if ($this->openedParenthesis < 0) { - return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); + return new InvalidEmail(new UnOpenedComment(), ((array) $this->lexer->token)['value']); } $finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer); @@ -78,7 +78,7 @@ public function parse() : Result private function warnEscaping() : bool { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (((array) $this->lexer->token)['type'] !== EmailLexer::S_BACKSLASH) { return false; } @@ -87,12 +87,12 @@ private function warnEscaping() : bool } $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + new QuotedPart($this->lexer->getPrevious()['type'], ((array) $this->lexer->token)['type']); return true; } - private function noClosingParenthesis() : bool + private function noClosingParenthesis() : bool { try { $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); diff --git a/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php b/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php index cbbe3f201b0fe1dc3c79924e1090b74c375c4c3e..17b686be1c6c72218c5cacd6da7c9d55e4fe0342 100644 --- a/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php +++ b/vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php @@ -23,7 +23,7 @@ public function endOfLoopValidations(EmailLexer $lexer) : Result { //test for end of string if (!$lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), ((array) $lexer->token)['value']); } //add warning //Address is valid within the message but cannot be used unmodified for the envelope diff --git a/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php b/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php index e72319a215013ed93927fb217dbb4c9d849bce55..179802b8334db88ab4223d51a897be319545a134 100644 --- a/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php +++ b/vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php @@ -24,7 +24,7 @@ public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool public function endOfLoopValidations(EmailLexer $lexer) : Result { if (!$lexer->isNextToken(EmailLexer::S_AT)) { - return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), ((array) $lexer->token)['value']); } $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); return new ValidEmail(); diff --git a/vendor/egulias/email-validator/src/Parser/DomainLiteral.php b/vendor/egulias/email-validator/src/Parser/DomainLiteral.php index e6d66d0bd80fc88cfcead5571648a0b0fc87ea1e..10486346ad6000d8eb79a21a45b48a0883d1a181 100644 --- a/vendor/egulias/email-validator/src/Parser/DomainLiteral.php +++ b/vendor/egulias/email-validator/src/Parser/DomainLiteral.php @@ -39,14 +39,14 @@ public function parse() : Result $addressLiteral = ''; do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) { + return new InvalidEmail(new ExpectingDTEXT(), ((array) $this->lexer->token)['value']); } $this->addObsoleteWarnings(); if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENBRACKET, EmailLexer::S_OPENBRACKET))) { - return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingDTEXT(), ((array) $this->lexer->token)['value']); } if ($this->lexer->isNextTokenAny( @@ -57,21 +57,21 @@ public function parse() : Result } if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + return new InvalidEmail(new CRNoLF(), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { - return new InvalidEmail(new UnusualElements($this->lexer->token['value']), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH) { + return new InvalidEmail(new UnusualElements(((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_IPV6TAG) { $IPv6TAG = true; } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEBRACKET) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEBRACKET) { break; } - $addressLiteral .= $this->lexer->token['value']; + $addressLiteral .= ((array) $this->lexer->token)['value']; } while ($this->lexer->moveNext()); @@ -144,7 +144,7 @@ public function checkIPV6Tag($addressLiteral, $maxGroups = 8) : void $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); } } - + public function convertIPv4ToIPv6(string $addressLiteralIPv4) : string { $matchesIP = []; @@ -189,7 +189,7 @@ protected function checkIPV4Tag($addressLiteral) : bool private function addObsoleteWarnings() : void { - if(in_array($this->lexer->token['type'], self::OBSOLETE_WARNINGS)) { + if(in_array(((array) $this->lexer->token)['type'], self::OBSOLETE_WARNINGS)) { $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); } } diff --git a/vendor/egulias/email-validator/src/Parser/DomainPart.php b/vendor/egulias/email-validator/src/Parser/DomainPart.php index e1f5b3bef3e0606b1ccf1f3e62006e7e4756b97d..84a4180f3689a61e40a138cb1d90d912bf41314b 100644 --- a/vendor/egulias/email-validator/src/Parser/DomainPart.php +++ b/vendor/egulias/email-validator/src/Parser/DomainPart.php @@ -50,8 +50,8 @@ public function parse() : Result return $domainChecks; } - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return new InvalidEmail(new ConsecutiveAt(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_AT) { + return new InvalidEmail(new ConsecutiveAt(), ((array) $this->lexer->token)['value']); } $result = $this->doParseDomainPart(); @@ -69,7 +69,7 @@ public function parse() : Result $length = strlen($this->domainPart); if ($length > self::DOMAIN_MAX_LENGTH) { - return new InvalidEmail(new DomainTooLong(), $this->lexer->token['value']); + return new InvalidEmail(new DomainTooLong(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -79,13 +79,13 @@ private function checkEndOfDomain() : Result { $prev = $this->lexer->getPrevious(); if ($prev['type'] === EmailLexer::S_DOT) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtEnd(), ((array) $this->lexer->token)['value']); } if ($prev['type'] === EmailLexer::S_HYPHEN) { return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_SP) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_SP) { return new InvalidEmail(new CRLFAtTheEnd(), $prev['value']); } return new ValidEmail(); @@ -98,13 +98,13 @@ private function performDomainStartChecks() : Result if ($invalidTokens->isInvalid()) { return $invalidTokens; } - + $missingDomain = $this->checkEmptyDomain(); if ($missingDomain->isInvalid()) { return $missingDomain; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS) { $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); } return new ValidEmail(); @@ -112,12 +112,12 @@ private function performDomainStartChecks() : Result private function checkEmptyDomain() : Result { - $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || - ($this->lexer->token['type'] === EmailLexer::S_SP && + $thereIsNoDomain = ((array) $this->lexer->token)['type'] === EmailLexer::S_EMPTY || + (((array) $this->lexer->token)['type'] === EmailLexer::S_SP && !$this->lexer->isNextToken(EmailLexer::GENERIC)); if ($thereIsNoDomain) { - return new InvalidEmail(new NoDomainPart(), $this->lexer->token['value']); + return new InvalidEmail(new NoDomainPart(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -125,11 +125,11 @@ private function checkEmptyDomain() : Result private function checkInvalidTokensAfterAT() : Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT) { + return new InvalidEmail(new DotAtStart(), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_HYPHEN) { + return new InvalidEmail(new DomainHyphened('After AT'), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } @@ -156,8 +156,8 @@ protected function doParseDomainPart() : Result return $notAllowedChars; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS || + ((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { $hasComments = true; $commentsResult = $this->parseComments(); @@ -172,7 +172,7 @@ protected function doParseDomainPart() : Result return $dotsResult; } - if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENBRACKET) { $literalResult = $this->parseDomainLiteral(); $this->addTLDWarnings($tldMissing); @@ -189,9 +189,9 @@ protected function doParseDomainPart() : Result return $FwsResult; } - $domain .= $this->lexer->token['value']; + $domain .= ((array) $this->lexer->token)['value']; - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::GENERIC)) { $tldMissing = false; } @@ -201,7 +201,7 @@ protected function doParseDomainPart() : Result } $this->lexer->moveNext(); - } while (null !== $this->lexer->token['type']); + } while (null !== ((array) $this->lexer->token)['type']); $labelCheck = $this->checkLabelLength(true); if ($labelCheck->isInvalid()) { @@ -219,8 +219,8 @@ protected function doParseDomainPart() : Result private function checkNotAllowedChars($token) : Result { $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; - if (isset($notAllowed[$token['type']])) { - return new InvalidEmail(new CharNotAllowed(), $token['value']); + if (isset($notAllowed[((array) $token)['type']])) { + return new InvalidEmail(new CharNotAllowed(), ((array) $token)['value']); } return new ValidEmail(); } @@ -233,7 +233,7 @@ protected function parseDomainLiteral() : Result try { $this->lexer->find(EmailLexer::S_CLOSEBRACKET); } catch (\RuntimeException $e) { - return new InvalidEmail(new ExpectingDomainLiteralClose(), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingDomainLiteralClose(), ((array) $this->lexer->token)['value']); } $domainLiteralParser = new DomainLiteralParser($this->lexer); @@ -244,17 +244,17 @@ protected function parseDomainLiteral() : Result protected function checkDomainPartExceptions(array $prev, bool $hasComments) : Result { - if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET && $prev['type'] !== EmailLexer::S_AT) { - return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENBRACKET && $prev['type'] !== EmailLexer::S_AT) { + return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH + if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::GENERIC)) { - return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), ((array) $this->lexer->token)['value']); } return $this->validateTokens($hasComments); @@ -273,8 +273,8 @@ protected function validateTokens(bool $hasComments) : Result $validDomainTokens[EmailLexer::S_CLOSEPARENTHESIS] = true; } - if (!isset($validDomainTokens[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']); + if (!isset($validDomainTokens[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . ((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -282,13 +282,13 @@ protected function validateTokens(bool $hasComments) : Result private function checkLabelLength(bool $isEndOfDomain = false) : Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT || $isEndOfDomain) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT || $isEndOfDomain) { if ($this->isLabelTooLong($this->label)) { - return new InvalidEmail(new LabelTooLong(), $this->lexer->token['value']); + return new InvalidEmail(new LabelTooLong(), ((array) $this->lexer->token)['value']); } $this->label = ''; } - $this->label .= $this->lexer->token['value']; + $this->label .= ((array) $this->lexer->token)['value']; return new ValidEmail(); } diff --git a/vendor/egulias/email-validator/src/Parser/DoubleQuote.php b/vendor/egulias/email-validator/src/Parser/DoubleQuote.php index b32e2b6b23afc612cd434f9b1bc7539d7cb0f410..d722292d4ea1dc07796d8ee98b76fd2aa7ae6a22 100644 --- a/vendor/egulias/email-validator/src/Parser/DoubleQuote.php +++ b/vendor/egulias/email-validator/src/Parser/DoubleQuote.php @@ -30,24 +30,24 @@ public function parse() : Result EmailLexer::S_CR => true, EmailLexer::S_LF => true ]; - + $setSpecialsWarning = true; $this->lexer->moveNext(); - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { - if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { + while (((array) $this->lexer->token)['type'] !== EmailLexer::S_DQUOTE && null !== ((array) $this->lexer->token)['type']) { + if (isset($special[((array) $this->lexer->token)['type']]) && $setSpecialsWarning) { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); $setSpecialsWarning = false; } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { $this->lexer->moveNext(); } $this->lexer->moveNext(); - if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']); + if (!$this->escaped() && isset($invalid[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), ((array) $this->lexer->token)['value']); } } @@ -59,7 +59,7 @@ public function parse() : Result } if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { - return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT("Expecting ATEXT between DQUOTE"), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -71,15 +71,15 @@ protected function checkDQUOTE() : Result if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { $description = 'https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit'; - return new InvalidEmail(new ExpectingATEXT($description), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT($description), ((array) $this->lexer->token)['value']); } try { $this->lexer->find(EmailLexer::S_DQUOTE); } catch (\Exception $e) { - return new InvalidEmail(new UnclosedQuotedString(), $this->lexer->token['value']); + return new InvalidEmail(new UnclosedQuotedString(), ((array) $this->lexer->token)['value']); } - $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); + $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], ((array) $this->lexer->token)['value']); return new ValidEmail(); } diff --git a/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php b/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php index fff6ec3ef5b54e2948b0d4c9810ad4505686c298..be4b05b82f5c68b3aaf58ea06a9450a795b2f247 100644 --- a/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php +++ b/vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php @@ -36,16 +36,16 @@ public function parse() : Result return $resultCRLF; } - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_CR) { + return new InvalidEmail(new CRNoLF(), ((array) $this->lexer->token)['value']); } if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { - return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token['value']); + return new InvalidEmail(new AtextAfterCFWS(), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { - return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_LF || ((array) $this->lexer->token)['type'] === EmailLexer::C_NUL) { + return new InvalidEmail(new ExpectingCTEXT(), ((array) $this->lexer->token)['value']); } if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { @@ -59,28 +59,28 @@ public function parse() : Result protected function checkCRLFInFWS() : Result { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + if (((array) $this->lexer->token)['type'] !== EmailLexer::CRLF) { return new ValidEmail(); } if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - return new InvalidEmail(new CRLFX2(), $this->lexer->token['value']); + return new InvalidEmail(new CRLFX2(), ((array) $this->lexer->token)['value']); } //this has no coverage. Condition is repeated from above one if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - return new InvalidEmail(new CRLFAtTheEnd(), $this->lexer->token['value']); + return new InvalidEmail(new CRLFAtTheEnd(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } - + protected function isFWS() : bool { if ($this->escaped()) { return false; } - return in_array($this->lexer->token['type'], self::FWS_TYPES); + return in_array(((array) $this->lexer->token)['type'], self::FWS_TYPES); } } diff --git a/vendor/egulias/email-validator/src/Parser/IDLeftPart.php b/vendor/egulias/email-validator/src/Parser/IDLeftPart.php index 5fd9cdf9929d06aba5e9d5dda33f8fcb8f6f871d..3b01ae290244461aa8b3e3c2d9a4946c2fcda002 100644 --- a/vendor/egulias/email-validator/src/Parser/IDLeftPart.php +++ b/vendor/egulias/email-validator/src/Parser/IDLeftPart.php @@ -10,6 +10,6 @@ class IDLeftPart extends LocalPart { protected function parseComments(): Result { - return new InvalidEmail(new CommentsInIDRight(), $this->lexer->token['value']); + return new InvalidEmail(new CommentsInIDRight(), ((array) $this->lexer->token)['value']); } } diff --git a/vendor/egulias/email-validator/src/Parser/IDRightPart.php b/vendor/egulias/email-validator/src/Parser/IDRightPart.php index 1a1268f2dfb006aaefe9facf39ce55c35b8a95b1..d19e05ab6fe6f9653009272a3926bbe9f34feb02 100644 --- a/vendor/egulias/email-validator/src/Parser/IDRightPart.php +++ b/vendor/egulias/email-validator/src/Parser/IDRightPart.php @@ -20,9 +20,9 @@ protected function validateTokens(bool $hasComments) : Result EmailLexer::S_GREATERTHAN => true, EmailLexer::S_LOWERTHAN => true, ]; - - if (isset($invalidDomainTokens[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']); + + if (isset($invalidDomainTokens[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . ((array) $this->lexer->token)['value']), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } diff --git a/vendor/egulias/email-validator/src/Parser/LocalPart.php b/vendor/egulias/email-validator/src/Parser/LocalPart.php index 154521b27f869fcbe1ff13182edf9f19ff22c3bc..3f2ef7d8ed99eeb263ba052cf17c9d40096bfae7 100644 --- a/vendor/egulias/email-validator/src/Parser/LocalPart.php +++ b/vendor/egulias/email-validator/src/Parser/LocalPart.php @@ -36,12 +36,12 @@ public function parse() : Result { $this->lexer->startRecording(); - while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { + while (((array) $this->lexer->token)['type'] !== EmailLexer::S_AT && null !== ((array) $this->lexer->token)['type']) { if ($this->hasDotAtStart()) { - return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtStart(), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_DQUOTE) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DQUOTE) { $dquoteParsingResult = $this->parseDoubleQuote(); //Invalid double quote parsing @@ -50,8 +50,8 @@ public function parse() : Result } } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS || - $this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { + if (((array) $this->lexer->token)['type'] === EmailLexer::S_OPENPARENTHESIS || + ((array) $this->lexer->token)['type'] === EmailLexer::S_CLOSEPARENTHESIS ) { $commentsResult = $this->parseComments(); //Invalid comment parsing @@ -60,14 +60,14 @@ public function parse() : Result } } - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), ((array) $this->lexer->token)['value']); } - if ($this->lexer->token['type'] === EmailLexer::S_DOT && + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_AT) ) { - return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']); + return new InvalidEmail(new DotAtEnd(), ((array) $this->lexer->token)['value']); } $resultEscaping = $this->validateEscaping(); @@ -99,8 +99,8 @@ public function parse() : Result protected function validateTokens(bool $hasComments) : Result { - if (isset(self::INVALID_TOKENS[$this->lexer->token['type']])) { - return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->token['value']); + if (isset(self::INVALID_TOKENS[((array) $this->lexer->token)['type']])) { + return new InvalidEmail(new ExpectingATEXT('Invalid token found'), ((array) $this->lexer->token)['value']); } return new ValidEmail(); } @@ -110,7 +110,7 @@ public function localPart() : string return $this->localPart; } - private function parseLocalFWS() : Result + private function parseLocalFWS() : Result { $foldingWS = new FoldingWhiteSpace($this->lexer); $resultFWS = $foldingWS->parse(); @@ -122,7 +122,7 @@ private function parseLocalFWS() : Result private function hasDotAtStart() : bool { - return $this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']; + return ((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']; } private function parseDoubleQuote() : Result @@ -148,12 +148,12 @@ protected function parseComments(): Result private function validateEscaping() : Result { //Backslash found - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + if (((array) $this->lexer->token)['type'] !== EmailLexer::S_BACKSLASH) { return new ValidEmail(); } if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { - return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->token['value']); + return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), ((array) $this->lexer->token)['value']); } if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { diff --git a/vendor/egulias/email-validator/src/Parser/PartParser.php b/vendor/egulias/email-validator/src/Parser/PartParser.php index a75a172acb42ed3c4ec542d00cd5cccaf24a47ea..7fc6d7bf31e9cfa15c447b47881548674cb4ddc2 100644 --- a/vendor/egulias/email-validator/src/Parser/PartParser.php +++ b/vendor/egulias/email-validator/src/Parser/PartParser.php @@ -45,8 +45,8 @@ protected function parseFWS() : Result protected function checkConsecutiveDots() : Result { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']); + if (((array) $this->lexer->token)['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + return new InvalidEmail(new ConsecutiveDot(), ((array) $this->lexer->token)['value']); } return new ValidEmail(); @@ -58,6 +58,6 @@ protected function escaped() : bool return $previous && $previous['type'] === EmailLexer::S_BACKSLASH && - $this->lexer->token['type'] !== EmailLexer::GENERIC; + ((array) $this->lexer->token)['type'] !== EmailLexer::GENERIC; } } diff --git a/vendor/symfony/var-dumper/Caster/DateCaster.php b/vendor/symfony/var-dumper/Caster/DateCaster.php index 18641fbc1d348c2de4d9121f887f6db9eb206f9d..d07bac583147d5846688ab842894d4744cf95d8e 100644 --- a/vendor/symfony/var-dumper/Caster/DateCaster.php +++ b/vendor/symfony/var-dumper/Caster/DateCaster.php @@ -27,7 +27,7 @@ class DateCaster public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter) { $prefix = Caster::PREFIX_VIRTUAL; - $location = $d->getTimezone()->getLocation(); + $location = $d->getTimezone() ? $d->getTimezone()->getLocation() : null; $fromNow = (new \DateTime())->diff($d); $title = $d->format('l, F j, Y') diff --git a/vendor/symfony/var-dumper/composer.json b/vendor/symfony/var-dumper/composer.json index dc46f58d99ecae911ba8940310d7afa619099cda..fc127d721ab1616ac26016c1ab81b7b8ca5e0c9e 100644 --- a/vendor/symfony/var-dumper/composer.json +++ b/vendor/symfony/var-dumper/composer.json @@ -28,7 +28,6 @@ "twig/twig": "^2.13|^3.0.4" }, "conflict": { - "phpunit/phpunit": "<5.4.3", "symfony/console": "<4.4" }, "suggest": { diff --git a/web/modules/content_access/LICENSE.txt b/web/modules/content_access/LICENSE.txt deleted file mode 100644 index d159169d1050894d3ea3b98e1c965c4058208fe1..0000000000000000000000000000000000000000 --- a/web/modules/content_access/LICENSE.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/web/modules/content_access/README.md b/web/modules/content_access/README.md deleted file mode 100644 index 9a65869bc11d54b4ffe3e0b0c339b1f7fdc49983..0000000000000000000000000000000000000000 --- a/web/modules/content_access/README.md +++ /dev/null @@ -1,207 +0,0 @@ -# CONTENTS OF THIS FILE - -* Introduction -* Requirements -* Recommended modules -* Installation -* Configuration -* Maintainers -* Notes - - -# INTRODUCTION - -The **Content Access** module let you content manage access permission -in a flexible and transparant way. - -It provides two new permissions: *view all* (allows anyone to view the -content) and *view own* (allows only the content creator to see -his/her own content). It also gives access to the existing core -permissions *edit* and *delete* on the same settings page. - -It provides the following modalities: - -* Each *content type* can have its own default content access settings - by role. -* Optionally you can enable role based access control settings per - *content node*. -* Access control can be further customized per *user* if you have the - **ACL** module enabled. - -For more information and reporting, please visit: - -* For a description of the module, visit the [project page][1]. -* For on-screen documentation, visit the [documentation page][2], - or enable [**Advanced Help**][6]. -* To submit bug reports and feature suggestions, or to track changes - visit the project's [issue tracker][3]. - -Features: - -* It comes with sensible defaults, so you need not configure anything - and everything stays working. -* It is as flexible as you want. It can work with per content type - settings, per content node settings as well as with flexible Access - Control Lists with the help of the **ACL** module - ([see Note 1](#ACL) at the end). -* It reuses existing functionality instead of reimplementing it. So - one can install the **ACL** module and set per user access control - settings per content node. -* The project provides conditions and actions for the **Rules** - module, which allows one to configure rule-based access permissions. -* It optimizes the written content node grants, so that only the - necessary grants are written. This is important for the - performance of your site. -* The module has a comes with automated testing to ensure everything - stays working correctly. -* It respects and makes use of Drupal's core permissions. This means - that the "Access Control" tab provided by this module takes them - into account and provides you a good overview of *all* applied - access control settings on a single page (but see [Note 2](#adv) at - the end). - -The module is designed to be simple to use, but can be configured to -provide really fine-grained content access permissions. - - -# REQUIREMENTS - -None. - -# RECOMMENDED MODULES - -* [**ACL**][4]: - To use Access Control Lists for per user access control. -* [**Advanced Help Hint**][7]: - Links help text provided by `hook_help` to online help and - **Advanced Help**. -* [**Advanced Help**][6]: - When this module is enabled, the project's `README.md` will be - displayed when you visit `help/content_access/README.md`. -* [**Markdown**][8]: - When this module is enabled, display of the project's `README.md` - will be rendered with the markdown filter. -* [**Node Export**][N] - To export content access rules. -* [**Rules**][5]: - To configure rule-based access permissions. - - -# INSTALLATION - -To install, do the following: - -1. Install as you would normally install a contributed drupal - module. See: [Installing modules][9] for further information. -2. Enable the **Content Access** module on the *Modules* list - page. -3. If you want to use access control lists, download, install and - configure the **ACL** module. - -To install with *composer*, do the following in the CLI: - - composer require 'drupal/content_access:^1.0' - -There is `composer.json` in the project's top directory. You can -safely delete this. This project has no third party dependencies. The -sole purpose of this file is to keep the Drupal.org **SimpleTest** -testbot happy. - - -# CONFIGURATION - -Note that users need at least the permission "View published content" -to be able to access published content. Furthermore note that content -which is not published is treated in a different way by Drupal: It can -be viewed only by its author or users with "Bypass content access -control" permission. You can *not* use this project to manage -access to unpublished content. - -To inspect and change those permissions, navigate to *Administration » -People » Permisions* and scroll down to the "Node" section. - -## Role based access control - -To set up access control for a content type, navigate to -*Administration » Structure* and click on "edit" for the content type -you want to set up. There will be a new tab named "Access Control" -that let you control access. - -To set up role based access control, tick the boxes under "Role based -access control settings". Note that only the "View" permissions are -new permissions provided by this module. The "Edit" and "Delete" -permissions are provided by the Drupal core, and can also be found if -you navigate to *Administration » People » Permisions*. They are -shown here to provide the full picture of what permission is set for -the content type and role. It does not matter where you change these. - -## Per content node access control - -There is a a checkbox to enable per content node access control -settings. If enabled, a new tab for the content access settings -appears when viewing content. - -To configure permission to access these settings, navigate to -*Administration » People » Permisions* and set the "Grant content -access" permission for the relevant roles. - -## Advanced access control - -The "Advanced" settings are only relevant if you are running multiple -node access modules on a site. - -A Drupal node access module can only grant access to content nodes, -but not deny it. So if you are using multiple node access modules, -access will be granted to a node as soon as one of the module grants -access to it. - -However you can influence the behaviour by changing the priority of -the content access module as drupal applies *only* the grants with the -highest priority. So if content access has the highest priority -*alone*, only its grants will be applied. - -By default node access modules should use priority 0 (zero). - - -## Using access control lists - -To make use of access control lists you'll need to enable per content -node access control settings for the content type. At the access control -tab of such a content node you are able to grant view, edit or delete -permission for specific users.. - - -# MAINTAINERS - -**Content Access** was created by [fago][10] (Wolfgang Ziegler). -It contains a lot of contributions from [good_man][11] (Khaled Al Hourani). -The current maintainer is [gisle][12] (Gisle Hannemyr). - -Development and maintenance is sponsored by [Hannemyr Nye Medier AS][13]. - -Any help with development (patches, reviews, comments) are welcome. - -# NOTES - -**Note 1**<a id="ACL"></a>: ACL integration is not yet working right. - -**Note 2**<a id="adv"></a>: Note that this overview can't take other -modules into account, which might also alter node access. If you have -multiple modules installed that alter node access, read the paragraph -about "Advanced access control". - - -[1]: https://drupal.org/project/content_access -[2]: https://drupal.org/node/1194974 -[3]: https://drupal.org/project/issues/content_access -[4]: https://www.drupal.org/project/acl -[5]: https://www.drupal.org/project/rules -[6]: https://www.drupal.org/project/advanced_help -[7]: https://www.drupal.org/project/advanced_help_hint -[8]: https://www.drupal.org/project/markdown -[N]: https://www.drupal.org/project/node_export -[9]: https://www.drupal.org/docs/extending-drupal/installing-drupal-modules -[10]: https://www.drupal.org/u/fago -[11]: https://www.drupal.org/u/good_man -[12]: https://www.drupal.org/u/gisle -[13]: https://hannemyr.no diff --git a/web/modules/content_access/composer.json b/web/modules/content_access/composer.json deleted file mode 100644 index adbb73fc00bc257e9491ff7765a9426e5bde0470..0000000000000000000000000000000000000000 --- a/web/modules/content_access/composer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "drupal/content_access", - "type": "drupal-module", - "description": "Provides flexible content access control.", - "homepage": "https://drupal.org/project/content_access", - "license": "GPL-2.0", - "minimum-stability": "dev", - "require-dev": { - "drupal/acl": "~1.0" - } -} diff --git a/web/modules/content_access/config/install/content_access.settings.yml b/web/modules/content_access/config/install/content_access.settings.yml deleted file mode 100644 index 716b6c732d1bdf4750f6aed04cc7828fb3fd1788..0000000000000000000000000000000000000000 --- a/web/modules/content_access/config/install/content_access.settings.yml +++ /dev/null @@ -1 +0,0 @@ -content_access_roles_gids: [] diff --git a/web/modules/content_access/config/schema/content_access.schema.yml b/web/modules/content_access/config/schema/content_access.schema.yml deleted file mode 100644 index e19013eba9f19d3f09016f6e7144f81908bee994..0000000000000000000000000000000000000000 --- a/web/modules/content_access/config/schema/content_access.schema.yml +++ /dev/null @@ -1,16 +0,0 @@ -content_access.settings: - type: config_object - label: 'Content Access settings' - mapping: - content_access_roles_gids: - type: sequence - label: 'Role - Grant Id mapping array' - sequence: - type: integer - label: 'Grant ID' - content_access_node_type: - type: sequence - label: 'Content Access node type settings' - sequence: - type: string - label: 'Grants' diff --git a/web/modules/content_access/content_access.info.yml b/web/modules/content_access/content_access.info.yml deleted file mode 100644 index 8a39a1f231a7ec3c565904f3331a70d423c6d13a..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.info.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Content Access -type: module -description: 'Provides flexible content access control.' -core: 8.x -core_version_requirement: ^8 || ^9 -package: 'Access control' - -dependencies: - - drupal:node - -test_dependencies: - - drupal:acl - -# Information added by Drupal.org packaging script on 2020-09-17 -version: '8.x-1.0-alpha3' -project: 'content_access' -datestamp: 1600327759 diff --git a/web/modules/content_access/content_access.install b/web/modules/content_access/content_access.install deleted file mode 100644 index d9752bfb3c1156dc82bc6ce2aff505bd723a0164..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.install +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -/** - * @file - * Content access install file. - */ - -use Drupal\user\Entity\Role; - -/** - * Implements hook_install(). - */ -function content_access_install() { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - $roles_gids = []; - - $roles = Role::loadMultiple(); - $i = 1; - foreach ($roles as $role) { - $roles_gids[$i] = $role->id(); - $i++; - } - - $config - ->set('content_access_roles_gids', array_flip($roles_gids)) - ->save(); -} - -/** - * Implements hook_uninstall(). - */ -function content_access_uninstall() { - content_access_disabling(TRUE); -} - -/** - * Implements hook_schema(). - */ -function content_access_schema() { - $schema['content_access'] = [ - 'fields' => [ - 'nid' => [ - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ], - 'settings' => [ - 'type' => 'text', - 'not null' => FALSE, - 'size' => 'medium', - ], - ], - 'primary key' => ['nid'], - ]; - - return $schema; -} diff --git a/web/modules/content_access/content_access.libraries.yml b/web/modules/content_access/content_access.libraries.yml deleted file mode 100644 index 3d0312d06118620b59c627d5095115856823a8e4..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.libraries.yml +++ /dev/null @@ -1,8 +0,0 @@ -drupal.content_access: - version: VERSION - css: - theme: - css/content_access.css: {} - dependencies: - - core/jquery - - core/drupal diff --git a/web/modules/content_access/content_access.links.contextual.yml b/web/modules/content_access/content_access.links.contextual.yml deleted file mode 100644 index 1620a0d8ea9a2f6a9cbb66cf47065e932443a0e4..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.links.contextual.yml +++ /dev/null @@ -1,4 +0,0 @@ -entity.node.content_access: - route_name: entity.node.content_access - group: node - title: 'Access control' diff --git a/web/modules/content_access/content_access.links.task.yml b/web/modules/content_access/content_access.links.task.yml deleted file mode 100644 index 79fed2ef66ba2c4da8a92c9bc412ddcef05b05e5..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.links.task.yml +++ /dev/null @@ -1,9 +0,0 @@ -entity.node.content_access: - route_name: entity.node.content_access - base_route: entity.node.canonical - title: 'Access control' - -entity.node_type.content_access_form: - route_name: entity.node_type.content_access_form - base_route: entity.node_type.edit_form - title: 'Access control' diff --git a/web/modules/content_access/content_access.module b/web/modules/content_access/content_access.module deleted file mode 100644 index 9962177c4ec9aab08367385b51386640c18cf0a7..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.module +++ /dev/null @@ -1,819 +0,0 @@ -<?php - -/** - * @file - * Content access module file. - */ - -use Drupal\Core\Session\AccountInterface; -use Drupal\node\NodeInterface; -use Drupal\node\NodeTypeInterface; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Cache\Cache; -use Drupal\user\RoleInterface; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Url; -use Drupal\user\Entity\Role; -use Drupal\node\Entity\Node; -use Drupal\content_access\ContentAccessInterface; - -/** - * Implements hook_help(). - */ -function content_access_help($route_name, RouteMatchInterface $route_match) { - switch ($route_name) { - case 'help.page.content_access': - case 'entity.node.content_access': - case 'entity.node_type.content_access_form': - $hint_service = FALSE; - if (!empty(\Drupal::hasService('advanced_help_hint.gethint'))) { - $hint_service = \Drupal::service('advanced_help_hint.gethint'); - } - $output = '<h3>' . t('About') . '</h3>'; - $output .= '<p>' . t('The <strong>Content Access</strong> module let you content manage access permission in a flexible and transparant way.') . '</p>'; - $output .= '<h3>' . t('Use') . '</h3>'; - $output .= '<p>' . t('It provides two new permissions: <em>view all</em> (allows anyone to view the content) and <em>view own</em> (allows only the content creator to see his/her own content). It also gives access to the existing core permissions <em>edit</em> and <em>delete</em> on the same settings page.') . '</p>'; - $output .= '<p>' . t('It provides the following modalities:') . '</p><ul>'; - $output .= '<li>' . t('Each <a href=":url"><em>content type</em></a> can have its own default content access settings by role.', [ - ':url' => Url::fromRoute('entity.node_type.collection')->toString(), - ] - ) . '</li>'; - $output .= '<li>' . t('Optionally you can enable role based access control settings per <em>content node</em>.') . '</li>'; - $output .= '<li>' . t('Access control can be further customized per <em>user</em> if you have the <a href=":url"><strong>ACL</strong></a> module enabled.', [ - ':url' => Url::fromUri('https://www.drupal.org/project/acl/')->toString(), - ] - ) . '</li></ul>'; - if ($hint_service) { - $output .= '<p>' . $hint_service->produceHint('content_access', - 'https://www.drupal.org/docs/7/modules/content-access', TRUE) . '</p>'; - } - else { - $output .= '<p>' . t('If you install and enable the module <a href=":url"><strong>Advanced Help Hint</strong></a>, you will get more help for <strong>Content Access</strong>.', [ - ':url' => Url::fromUri('https://www.drupal.org/project/advanced_help_hint')->toString(), - ] - ) . '</p>'; - } - return $output; - } -} - -/** - * Implements hook_node_grants(). - */ -function content_access_node_grants(AccountInterface $account, $op) { - $gids = []; - $roles = $account->getRoles(); - foreach ($roles as $role) { - $gids[] = content_access_get_role_gid($role); - } - - return [ - 'content_access_author' => [$account->id()], - 'content_access_roles' => $gids, - ]; -} - -/** - * Implements hook_node_access_records(). - */ -function content_access_node_access_records(NodeInterface $node) { - if (content_access_disabling() || !$node->isPublished()) { - return; - } - - // Apply per node settings if necessary. - if (content_access_get_settings('per_node', $node->getType())) { - $grants = []; - foreach (['view', 'update', 'delete'] as $op) { - foreach (content_access_get_rids_per_node_op($op, $node) as $rid) { - $gid = content_access_get_role_gid($rid); - $grants[$gid]['grant_' . $op] = 1; - } - } - foreach ($grants as $gid => $grant) { - $grants[$gid] = content_access_proccess_grant($grant, $gid, $node); - } - - // Care for the author grant. - $grant = []; - foreach (['view', 'update', 'delete'] as $op) { - // Get all roles that have access to use $op on this node. - $per_node_settings = content_access_per_node_setting($op, $node); - $any_roles = array_combine($per_node_settings, $per_node_settings); - $any_roles = $any_roles ? $any_roles : []; - $any_roles += ($op != 'view') ? content_access_get_settings($op, $node->getType()) : []; - $grant['grant_' . $op] = content_access_own_op($node, $any_roles, content_access_get_rids_per_node_op($op . '_own', $node)); - } - - if (array_filter($grant)) { - $grant['realm'] = 'content_access_author'; - $grants[] = content_access_proccess_grant($grant, $node->getOwnerId(), $node); - } - } - else { - // Apply the content type defaults. - $grants = content_access_get_type_grant($node); - } - - if (empty($grants)) { - // This means we grant no access. - $grants[] = content_access_proccess_grant([], 0, $node); - } - else { - content_access_optimize_grants($grants, $node); - } - - return $grants; -} - -/** - * Implements hook_node_delete(). - */ -function content_access_node_delete(NodeInterface $node) { - \Drupal::database()->delete('content_access') - ->condition('nid', $node->id()) - ->execute(); -} - -/** - * Implements hook_entity_insert(). - */ -function content_access_entity_insert(EntityInterface $entity) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - - if ($entity instanceof RoleInterface) { - $roles_gids = array_flip($config->get('content_access_roles_gids')); - $roles_gids[] = $entity->id(); - $config->set('content_access_roles_gids', array_flip($roles_gids)); - $config->save(); - } -} - -/** - * Implements hook_entity_operation(). - */ -function content_access_entity_operation(EntityInterface $entity) { - $operations = []; - $info = $entity->getEntityType(); - - if ($info->getBundleOf() == 'node') { - $account = \Drupal::currentUser(); - - if ($account->hasPermission('bypass node access') && $account->hasPermission('administer content types')) { - $operations['access-control'] = [ - 'title' => t('Access control'), - 'weight' => 25, - 'url' => Url::fromRoute('entity.node_type.content_access_form', [ - 'node_type' => $entity->id(), - ]), - ]; - } - } - - return $operations; -} - -/** - * Implements hook_entity_delete(). - */ -function content_access_entity_delete(EntityInterface $entity) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - - if ($entity instanceof RoleInterface) { - $roles_gids = $config->get('content_access_roles_gids'); - unset($roles_gids[$entity->id()]); - $config - ->set('content_access_roles_gids', $roles_gids) - ->save(); - } -} - -/** - * Used by the ACL module. - */ -function content_access_enabled() { - return !content_access_disabling(); -} - -/** - * Remembers if we have disabled access. - */ -function content_access_disabling($set = NULL) { - static $disabling = FALSE; - - if (isset($set)) { - $disabling = $set; - } - return $disabling; -} - -/** - * Return content_access' settings. - * - * @param string $setting - * One of the content_access_available_settings(), e.g. 'view' or 'per_node'. - * If 'all' is passed, all available settings are returned. - * @param string $type_name - * The name of the content type to return settings for. - * - * @return mixed - * The value of the given setting or an array of all settings. - */ -function content_access_get_settings($setting, $type_name) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - $settings = unserialize($config->get('content_access_node_type.' . $type_name)); - if (empty($settings)) { - $settings = []; - } - $settings += content_access_get_setting_defaults($type_name); - - if ($setting == 'all') { - return $settings; - } - - return isset($settings[$setting]) ? $settings[$setting] : NULL; -} - -/** - * Save content_access settings of a content type. - */ -function content_access_set_settings($settings, $type_name) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - - // Do not store default values so we do not have to care about syncing our - // settings with the permissions. - foreach (content_access_get_setting_defaults($type_name) as $setting => $default_value) { - if (isset($settings[$setting]) && $settings[$setting] == $default_value) { - unset($settings[$setting]); - } - } - $config->set('content_access_node_type.' . $type_name, serialize($settings)); - $config->save(); -} - -/** - * Return an array containing all available content_access settings. - */ -function content_access_available_settings() { - return [ - 'view', - 'update', - 'delete', - 'view_own', - 'update_own', - 'delete_own', - 'per_node', - 'priority', - ]; -} - -/** - * Defines default values for settings. - */ -function content_access_get_setting_defaults($type) { - $defaults = []; - $defaults['view'] = $defaults['view_own'] = [ - AccountInterface::ANONYMOUS_ROLE, - AccountInterface::AUTHENTICATED_ROLE, - ]; - foreach (['update', 'delete'] as $op) { - $defaults[$op] = content_access_get_permission_access(content_access_get_permission_by_op($op, $type)); - $defaults[$op . '_own'] = content_access_get_permission_access(content_access_get_permission_by_op($op . '_own', $type)); - } - $defaults['priority'] = 0; - $defaults['per_node'] = FALSE; - - return $defaults; -} - -/** - * Returns an array of role ids that contain the given permission. - */ -function content_access_get_permission_access($perm, $reset = FALSE) { - $roles = &drupal_static(__FUNCTION__, []); - - if ($reset) { - $roles = []; - } - if (!isset($roles[$perm]) && $perm) { - $user_roles = Role::loadMultiple(); - foreach ($user_roles as $role) { - if ($role->hasPermission($perm)) { - $roles[$perm][] = $role->id(); - } - } - } - return isset($roles[$perm]) ? $roles[$perm] : []; -} - -/** - * Gets the name of a perm for the given operation, if there is a suiting one. - */ -function content_access_get_permission_by_op($op, $type) { - switch ($op) { - case 'update': - return 'edit any ' . $type . ' content'; - - case 'update_own': - return 'edit own ' . $type . ' content'; - - case 'delete': - return 'delete any ' . $type . ' content'; - - case 'delete_own': - return 'delete own ' . $type . ' content'; - - default: - return FALSE; - - } -} - -/** - * Returns the default grants for a given node type. - */ -function content_access_get_type_grant(NodeInterface $node) { - // Cache per type default grants in a static array. - static $defaults = []; - - $node_type = $node->getType(); - - if (!isset($defaults[$node_type])) { - $grants = []; - - // Only process the 'view' op as node_access() will take care of - // edit and delete. - foreach (content_access_get_settings('view', $node_type) as $rid) { - $gid = content_access_get_role_gid($rid); - $grant['grant_view'] = 1; - $grants[] = content_access_proccess_grant($grant, $gid, $node); - } - $defaults[$node_type] = $grants; - } - - // Care for the author grant. - $grant = $grants = []; - $settings = [ - 'view' => content_access_get_settings('view', $node_type), - 'view_own' => content_access_get_settings('view_own', $node_type), - ]; - $grant['grant_view'] = content_access_own_op($node, $settings['view'], $settings['view_own']); - if ($grant['grant_view']) { - $grant['realm'] = 'content_access_author'; - $grants = [ - 'author' => content_access_proccess_grant($grant, $node->getOwnerId(), $node), - ]; - } - - return $defaults[$node_type] + $grants; -} - -/** - * Process a grant, which means add priority, realm and other properties. - */ -function content_access_proccess_grant($grant, $gid, NodeInterface $node) { - $grant += [ - 'grant_view' => 0, - 'grant_update' => 0, - 'grant_delete' => 0, - 'realm' => 'content_access_roles', - ]; - $grant['gid'] = $gid; - $grant['priority'] = content_access_get_settings('priority', $node->getType()); - - return $grant; -} - -/** - * Determines grant for node author and the gives allowed roles of operation. - * - * @param array $any_roles - * The roles with which anybody has access (not optimized!). - * @param array $own_roles - * The roles with which only the author has access (optimized!). - * - * @return int - * Returns 0 if permission is granted, otherwise 1. - */ -function content_access_own_op(NodeInterface $node, array $any_roles, array $own_roles) { - static $roles = []; - - $owner = $node->getOwner(); - if (!isset($roles[$owner->id()])) { - $roles[$owner->id()] = $owner->id() ? [AccountInterface::AUTHENTICATED_ROLE] : [AccountInterface::ANONYMOUS_ROLE]; - - $result = $owner->get('roles'); - - foreach ($result as $role) { - $roles[$owner->id()][] = $role->target_id; - } - } - if (array_intersect($roles[$owner->id()], $any_roles)) { - // If there is access due to "any permissions" there is no need to - // add an author grant. - return 0; - } - - return array_intersect($roles[$owner->id()], $own_roles) ? 1 : 0; -} - -/** - * Get rids per node. - * - * Returns optimized role ids for the given operation and node to - * grant access for. - * - * If to a role access is granted by permissions, it's not necessary - * to write a grant for it. So it won't be returned. - * - * @param string $op - * One of the supported operations. - * @param \Drupal\node\NodeInterface $node - * The node object. - */ -function content_access_get_rids_per_node_op($op, NodeInterface $node) { - $rids = content_access_per_node_setting($op, $node); - - if ($permission = content_access_get_permission_by_op($op, $node->getType())) { - $perm_roles = content_access_get_permission_access($permission); - $rids = array_diff($rids, $perm_roles); - - if (in_array(AccountInterface::AUTHENTICATED_ROLE, $perm_roles)) { - if (in_array(AccountInterface::ANONYMOUS_ROLE, $rids)) { - return [ - AccountInterface::ANONYMOUS_ROLE, - AccountInterface::AUTHENTICATED_ROLE, - ]; - } - else { - return [AccountInterface::AUTHENTICATED_ROLE]; - } - } - } - - return $rids; -} - -/** - * Access per node setting. - * - * Returns the per node role settings. If no per node settings are available, - * it will return the content type settings. - * - * @param string $op - * One of the supported operations. - * @param \Drupal\node\NodeInterface $node - * The node object. - * @param array $settings - * Optional array used to update the settings cache with the given settings. - * - * @return array - * An array of role ids which have access. - */ -function content_access_per_node_setting($op, NodeInterface $node, array $settings = NULL) { - static $grants = []; - - if (isset($settings)) { - // Update settings cache. - $grants[$node->id()] = $settings; - return $settings; - } - - if (!isset($grants[$node->id()]) || $grants[$node->id()] === FALSE) { - $grants[$node->id()] = content_access_get_per_node_settings($node); - } - - // Return the content type defaults if no per node settings are available. - return isset($grants[$node->id()][$op]) ? $grants[$node->id()][$op] : content_access_get_settings($op, $node->getType()); -} - -/** - * Gets the per node settings of a node. - * - * @note - * This function won't apply defaults, so if there are no other settings - * it will return an empty array. - */ -function content_access_get_per_node_settings(NodeInterface $node) { - $query = \Drupal::database()->query("SELECT settings FROM {content_access} WHERE nid = :nid", [ - ':nid' => $node->id(), - ]); - $result = $query->fetch(PDO::FETCH_OBJ); - - if (!empty($result->settings)) { - return unserialize($result->settings); - } - - return []; -} - -/** - * Saves custom per node settings in the own content_access table. - */ -function content_access_save_per_node_settings(NodeInterface $node, $settings) { - $database = \Drupal::database(); - - $count = $database->select('content_access') - ->fields('c', ['settings']) - ->condition('nid', $node->id()) - ->countQuery() - ->execute() - ->fetchField(); - - if ($count > 0) { - $database->update('content_access') - ->condition('nid', $node->id()) - ->fields(['settings' => serialize($settings)]) - ->execute(); - } - else { - $database->insert('content_access') - ->fields(['nid' => $node->id(), 'settings' => serialize($settings)]) - ->execute(); - } - - // Make content_access_per_node_setting() use the new settings. - content_access_per_node_setting(NULL, $node, $settings); -} - -/** - * Delete per node settings. - * - * Deletes all custom per node settings, so that content type defaults - * are used again. - */ -function content_access_delete_per_node_settings(NodeInterface $node) { - \Drupal::database()->delete('content_access') - ->condition('nid', $node->id()) - ->execute(); - - // Clear the cache. - content_access_per_node_setting(NULL, $node, FALSE); - - // Delete possible acl settings. - if (\Drupal::moduleHandler()->moduleExists('acl')) { - module_load_include('inc', 'content_access', 'content_access.admin'); - foreach (['view', 'update', 'delete'] as $op) { - $acl_id = content_access_get_acl_id($node, $op); - acl_delete_acl($acl_id); - } - } -} - -/** - * Removes grants that doesn't change anything. - * - * @note - * The grants are compared with the normal access control settings. - */ -function content_access_optimize_grants(&$grants, NodeInterface $node) { - $rids = ['view' => [], 'update' => [], 'delete' => []]; - - foreach ($grants as $key => $grant) { - foreach (['view', 'update', 'delete'] as $op) { - if (!empty($grant['grant_' . $op])) { - $rids[$op][] = $grant['gid']; - } - } - } - - // Detect if all are allowed to view. - $anonymous_gid = content_access_get_role_gid(AccountInterface::ANONYMOUS_ROLE); - $authenticated_gid = content_access_get_role_gid(AccountInterface::AUTHENTICATED_ROLE); - $all = [$anonymous_gid, $authenticated_gid]; - if (empty(array_diff($all, $rids['view']))) { - // Grant view access to all instead of single roles. - $rids['view'] = ['all']; - $grants['all'] = [ - 'realm' => 'all', - 'gid' => 0, - 'grant_view' => 1, - 'grant_update' => 0, - 'grant_delete' => 0, - 'priority' => content_access_get_settings('priority', $node->getType()), - ]; - } - - // If authenticated users are involved, remove unnecessary other roles. - foreach (['view', 'update', 'delete'] as $op) { - if (in_array($authenticated_gid, $rids[$op])) { - $rids[$op] = in_array($anonymous_gid, $rids[$op]) - ? [$anonymous_gid, $authenticated_gid] : [$authenticated_gid]; - } - } - - // Now let's remove unnecessary grants, if any. - foreach ($grants as $key => $grant) { - if (!is_numeric($key)) { - continue; - } - - foreach (['view', 'update', 'delete'] as $op) { - if ($grant['grant_' . $op] && in_array($grant['gid'], $rids[$op])) { - // It is still here, so we cannot remove this grant. - continue 2; - } - } - // ok, remove it. - unset($grants[$key]); - } -} - -/** - * Implements hook_node_type_delete(). - */ -function content_access_node_type_delete(NodeTypeInterface $info) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - - $config - ->clear('content_access_node_type.' . $info->id()) - ->save(); -} - -/** - * Implements hook_node_type_update(). - * - * Updates settings on node type name change. - */ -function content_access_node_type_update(NodeTypeInterface $info) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - - $original_id = $info->getOriginalId(); - if (!empty($original_id) && $info->getOriginalId() != $info->id()) { - $settings = content_access_get_settings('all', $info->getOriginalId()); - content_access_set_settings($settings, $info->id()); - $config - ->clear('content_access_node_type.' . $info->getOriginalId()) - ->save(); - } -} - -/** - * Implements hook_node_access_explain(). - */ -function content_access_node_access_explain($row) { - static $roles; - - if (!isset($roles)) { - $roles = user_roles(); - } - - if (!$row->gid && $row->realm == 'content_access_roles') { - return t('Content access: No access is granted.'); - } - - switch ($row->realm) { - case 'content_access_author': - return t('Content access: author of the content can access'); - - case 'content_access_roles': - return t('Content access: %role can access', ['%role' => $roles[$row->gid]]); - - } -} - -/** - * Implements hook_form_alter(). - */ -function content_access_form_alter(&$form, FormStateInterface $form_state, $form_id) { - if ($form_id == 'user_admin_perm') { - $build_info = $form_state->getBuildInfo(); - $build_info['files'][] = [ - 'module' => 'content_access', - 'type' => 'inc', - 'name' => 'content_access.admin', - ]; - $form_state->setBuildInfo($build_info); - $form['actions']['submit']['#submit'][] = 'content_access_user_admin_perm_submit'; - } -} - -/** - * Returns an array of possible operations on content and their labels. - */ -function _content_access_get_operations($type = NULL) { - $operations = [ - 'view' => t('View any @type content', ['@type' => $type]), - 'view_own' => t('View own @type content', ['@type' => $type]), - 'update' => t('Edit any @type content', ['@type' => $type]), - 'update_own' => t('Edit own @type content', ['@type' => $type]), - 'delete' => t('Delete any @type content', ['@type' => $type]), - 'delete_own' => t('Delete own @type content', ['@type' => $type]), - ]; - - return $operations; -} - -/** - * Gets node's access permissions. - */ -function _content_access_get_node_permissions($type) { - return array_filter(array_map('content_access_get_permission_by_op', array_flip(_content_access_get_operations()), array_fill(0, 6, $type))); -} - -/** - * Helper providing numeric id for role. - */ -function content_access_get_role_gid($role) { - $config = \Drupal::configFactory()->getEditable('content_access.settings'); - $roles_gids = $config->get('content_access_roles_gids'); - - return $roles_gids[$role]; -} - -/** - * Gets the content access acl id of the node. - */ -function content_access_get_acl_id(NodeInterface $node, $op) { - $acl_id = acl_get_id_by_name('content_access', $op . '_' . $node->id()); - if (!$acl_id) { - $acl_id = acl_create_acl('content_access', $op . '_' . $node->id()); - } - - return $acl_id; -} - -/** - * Detaches all our ACLs for the nodes of the given type. - */ -function _content_access_remove_acls($type) { - $result = \Drupal::database()->query("SELECT n.nid FROM {node} n WHERE type = :type", [ - 'type' => $type, - ]); - - foreach ($result as $node) { - acl_node_clear_acls($node->nid, 'content_access'); - } -} - -/** - * Mass updates node access records for nodes of the given types. - * - * @param array $types - * An array of content type names. - * - * @return bool - * Whether the operation has been processed successfully or postponed. - */ -function content_access_mass_update(array $types) { - $query = \Drupal::database()->select('node', 'n') - ->fields('n', ['nid']) - ->condition('n.type', $types, 'IN'); - - $count = $query->countQuery()->execute()->fetchField(); - - node_access_needs_rebuild(TRUE); - - // If there not too much nodes affected, try to do it. - if ($count <= ContentAccessInterface::CONTENT_ACCESS_MASS_UPDATE_THRESHOLD) { - $records = $query->execute(); - - foreach ($records as $node) { - $node = Node::load($node->nid); - $grants = \Drupal::entityTypeManager()->getAccessControlHandler('node')->acquireGrants($node); - \Drupal::service('node.grant_storage')->write($node, $grants); - } - - foreach (Cache::getBins() as $cache_backend) { - $cache_backend->deleteAll(); - } - - node_access_needs_rebuild(FALSE); - - return TRUE; - } - - return FALSE; -} - -/** - * Submit callback for the user permissions form. - * - * Trigger changes to node permissions to rebuild our grants. - */ -function content_access_user_admin_perm_submit($form, FormStateInterface $form_state) { - // Check for each content type, which has per node access activated - // whether permissions have been changed. - $types = []; - foreach (array_filter(content_access_get_settings('per_node', 'all')) as $type => $value) { - foreach (_content_access_get_node_permissions($type) as $perm) { - foreach (user_roles() as $rid => $role) { - $values = $form_state->getValues(); - if (isset($values[$rid]) && in_array($perm, $form['checkboxes'][$rid]['#default_value']) != in_array($perm, $values[$rid])) { - // Permission changed. - $types[$type] = node_type_get_names(); - continue 2; - - } - } - } - } - if ($types && content_access_mass_update(array_keys($types))) { - \Drupal::messenger()->addMessage(\Drupal::translation()->formatPlural(count($types), - 'Permissions have been successfully rebuilt for the content type @types.', - 'Permissions have been successfully rebuilt for the content types @types.', - ['@types' => implode(', ', $types)] - )); - } -} diff --git a/web/modules/content_access/content_access.permissions.yml b/web/modules/content_access/content_access.permissions.yml deleted file mode 100644 index 2b14c0de1905e9936f0107f3762c2071a070c39a..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.permissions.yml +++ /dev/null @@ -1,7 +0,0 @@ -grant content access: - title: 'Grant content access' - description: 'View and modify content access for any nodes' - -grant own content access: - title: 'Grant own content access' - description: 'View and modify content access for own nodes' diff --git a/web/modules/content_access/content_access.routing.yml b/web/modules/content_access/content_access.routing.yml deleted file mode 100644 index 067c7bbf4f87846bf73e6e11246079c0a0b2465e..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.routing.yml +++ /dev/null @@ -1,18 +0,0 @@ -entity.node.content_access: - path: '/node/{node}/access' - defaults: - _title_callback: '\Drupal\content_access\Controller\ContentAccessController::getContentAccessTitle' - _form: '\Drupal\content_access\Form\ContentAccessPageForm' - requirements: - _content_access_node_page_access: 'TRUE' - options: - _node_operation_route: TRUE - _admin_route: TRUE - -entity.node_type.content_access_form: - path: '/admin/structure/types/manage/{node_type}/access' - defaults: - _title: 'Access control' - _form: '\Drupal\content_access\Form\ContentAccessAdminSettingsForm' - requirements: - _content_access_admin_settings_access: 'TRUE' diff --git a/web/modules/content_access/content_access.rules.events.yml b/web/modules/content_access/content_access.rules.events.yml deleted file mode 100644 index 5e55770e26fa738eef2f8593626ecb59b00e4c69..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.rules.events.yml +++ /dev/null @@ -1,12 +0,0 @@ -content_access_content_type: - label: 'Content type access control was changed' - category: 'Content Access' - -content_access_per_node: - label: 'Per node access control was changed' - category: 'Content Access' - -content_access_user_acl: - label: 'User was added to ACL' - category: 'Content Access' - deriver: '\Drupal\content_access\Plugin\Deriver\RulesEventUserAclDeriver' diff --git a/web/modules/content_access/content_access.services.yml b/web/modules/content_access/content_access.services.yml deleted file mode 100644 index ed4a33b3fa602dfa3878407b53f1ef340264dfec..0000000000000000000000000000000000000000 --- a/web/modules/content_access/content_access.services.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - access_check.content_access_node_page_access: - class: Drupal\content_access\Access\ContentAccessNodePageAccessCheck - tags: - - { name: access_check, applies_to: _content_access_node_page_access } - - access_check.content_access_admin_settings_access: - class: Drupal\content_access\Access\ContentAccessAdminSettingsAccessCheck - arguments: ['@entity_type.manager'] - tags: - - { name: access_check, applies_to: _content_access_admin_settings_access } diff --git a/web/modules/content_access/css/content_access.css b/web/modules/content_access/css/content_access.css deleted file mode 100644 index 2c6b023f7f893e72677e71cd984d1cd1c5fc1046..0000000000000000000000000000000000000000 --- a/web/modules/content_access/css/content_access.css +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file - * Styles for Content Access administration pages. - */ - -.content_access-div { - width: 25%; - margin: 0; - padding: 0; - float: left; - overflow: hidden; -} - -form.content-access-page, -form.content-access-admin-settings { - position: static; -} diff --git a/web/modules/content_access/help/content_access.help.yml b/web/modules/content_access/help/content_access.help.yml deleted file mode 100644 index 288cd69c9f61474b98cdc7b3ff6d330bc2e9532c..0000000000000000000000000000000000000000 --- a/web/modules/content_access/help/content_access.help.yml +++ /dev/null @@ -1,11 +0,0 @@ -rules: - title: Rules - weight: -11 - -nodeexport: - title: Node Export - weight: -10 - -integration: - title: Integration with other modules - weight: -9 diff --git a/web/modules/content_access/help/integration.html b/web/modules/content_access/help/integration.html deleted file mode 100644 index c4d0805c84ac473d9cb34d7b261f2829ffb86c46..0000000000000000000000000000000000000000 --- a/web/modules/content_access/help/integration.html +++ /dev/null @@ -1,59 +0,0 @@ -<h2>Introduction</h2> - -<p>This section contains notes about how to integrate <strong>Content -Access</strong> with other modules.</p> - -<p>I have not tested these myself, so I do not guarantee that the -suggestion collected below actually work. They are just to keep the -links to the workarounds posted somewhere on the web in a single -file.</p> - -<p>If you spot link rot, or wrong information, on this page, please -report it using the project's -<a href="https://drupal.org/project/issues/content_access">issue queue</a>.</p> - - -<h2>Varnish, Cachewall</h2> - -<p><em>Varnish</em> and other cache systems such as <em>Cachewall</em> -by default will delete cookies before they reach Drupal, so everybody -becomes an anonymous user. This precludes access to private file -attachments.</p> - -<p>Below are settings for <em>Varnish</em> to prevent this for some -file types:</p> - -<pre> -# Always cache the following file types for all users. This list of extensions -# appears twice, once here and again in vcl_fetch so make sure you edit both -# and keep them equal. - -if (req.url ~ "(?i)\.(pdf|txt|csv|png|gif|jpg|ico|swf|css|js)(\?.*)?$") { - unset req.http.Cookie; -} -</pre> - -<ul> -<li>Drupal.org: <a href="https://www.drupal.org/project/content_access/issues/2682635">Issue #2682635</a></li> -<li>Drupal.org: <a href="https://www.drupal.org/project/webform/issues/2421429#comment-9667677">Issue #2421429, comment #4</a></li> -</ul> - - -<h2>Views and Workbench</h2> - -<p>If you have problems intgrating <strong>Views</strong> and/or <strong>Workbench</strong>, -in particular in connection with the “<em>View own unpublished content</em>” permission, -one of these links may help:</p> - -<ul> -<li>Drupal.org: <a href="https://www.drupal.org/project/content_access/issues/2204609">Issue #2205609</a></li> -<li>Drupal Answers: <a href="https://drupal.stackexchange.com/q/41997/12076">Problem with “Content Access” and permission “View own unpublished content”</a>.</li> -<li>Drupalprimer: <a href="http://drupalprimer.com/node/2">Drupal 7's Access Control module prevents view of user's own unpublished content</a>.</li> -</ul> - -<p>Problems using relationships in <strong>Views</strong> may be solved by patching core:</p> - -<ul> -<li>Drupal.org: <a href="https://www.drupal.org/project/content_access/issues/2020453">Issue #2020453</a></li> -<li>Drupal.org: <a href="https://www.drupal.org/project/drupal/issues/1349080#comment-10953027">Issue #1349080, comment #332</a></li> -</ul> diff --git a/web/modules/content_access/help/nodeexport.html b/web/modules/content_access/help/nodeexport.html deleted file mode 100644 index 3b277dada3b2c9ca1e29a63d215635fe07be325b..0000000000000000000000000000000000000000 --- a/web/modules/content_access/help/nodeexport.html +++ /dev/null @@ -1,10 +0,0 @@ -<h2>Introduction</h2> - -<p>This page is just a placeholder. Until it is populated, please see:</p> - -<ul> -<li>Drupal.org: <a href="https://www.drupal.org/project/content_access/issues/2661872">Issue #2661872</a></li> -</ul> - - - diff --git a/web/modules/content_access/help/rules.html b/web/modules/content_access/help/rules.html deleted file mode 100644 index f51402e552cdfdf1a3416710ae9232bdaf9a85a9..0000000000000000000000000000000000000000 --- a/web/modules/content_access/help/rules.html +++ /dev/null @@ -1,90 +0,0 @@ -<h2>Introduction</h2> - -<p>This section contains notes about how to -integrate with <strong>Rules</strong>.</p> - -<p><strong>Note</strong>: This only work on individual nodes. The -rules for access control that you set up will not be -executed <em>unless</em> you have enabled per content node access -control settings.</p> - -<h2>Rules integrations example</h2> - -<p>In this example, there will be two user roles: “writer” and -“editor”. There will also be two users: A writer named “Bob” and an -editor named “Ben”. There will also be a third user named “Alice” -that will not belong to any of there roles. We shall set up a workflow -where “Bob” creates content, and when that content is saved, only -users with the “editor” user role (e.g. “Ben”) will be allowed to see -it.</p> - -<p>Set up:</p> - -<ul> -<li>Ensure <strong>Content Access</strong> is enabled (if you can read this in the browser, it is).</li> -<li>Enable the <strong>Rules</strong> module.</li> -<li>Create the roles: “writer” and “editor” and the users “Bob”, “Ben” and “Alice”. Assign roles.</li> -<li>Set up default role based access control settings. Give the “anonymous user” role and the “authenticated user” role access to “View any article content” and “View own article content”.</li> -<li>Check “Enable per content node access control settings”. You find this checkbox under the “Access Control” tab located on the settings page for the content type.</li> -</ul> - -<p>Create the rules:</p> - -<ul> -<li>Navigate to <span class="nav">Configuration » Workflow » Rules<span>.</li> -<li>Click “Add reaction rule”.</li> -<li>In the pulldown menu for “React on event”, select “After saving a new content item”.</li> -<li>Label the rule “editor oversight”.</li> -<li>Leave the field “Tags” and “Description” fields empty.</li> -<li>Click “Save”.</li> -</ul> - -<div class="help-imgpos-center" style="max-width:620px"> -<img class="help-img" alt="ahelp_tab.png" title="New reaction rule: Editor oversight" src="&path&rules01d8.png" width="640" /> -<div class="help-img-caption" style="max-width:620px">Adding a new reaction rule</div> -</div> - -<p>This sets up a new rule named “editor oversight” that triggers when a new node is saved.</p> - -<ul> - <li>Under “Conditions”, click “Add condition”,</li> - <li>From the pulldown menu “Select <em>condition</em> to add”, select “User has role(s)”.</li> - <li>After making the selection, you automatically continue to a new page to set up a data selector.</li> - <li>For the “Data selector” field, enter “node:author”.</li> - <li>Under “Roles”, for “Value”, enter “writer”.</li> - <li>Click “Save”.</li> -</ul> - -<p>This sets up a contition for following the rule. The rule is only -followed when the user with the role “writer” triggers an event that -matches “After saving new contents”.</p> - -<p>The final step adds an action that happens when the rule is -triggered and the conditions are met.</p> - -<ul> - <li>Under “Actions”, click “Add action”,</li> - <li>From the pulldown menu “Select <em>action</em> to add”, select “Grant Access by role”.</li> - <li>After making the selection, you automatically continue to a new page to set up role based access settings.</li> - <li>[From this point. Instructions missing or wrong - please help add them.]</li> -</ul> - -<p>The instructions below are copied from the Drupal 7 versions of the project. They need to be corrected for Drupal 8 and later. -To help out, please vist <a href="https://www.drupal.org/project/content_access/issues/3151287">Issue #3151287@Drupal.org</a>.</p> - -<ul> - <li>Look under “Content”.</li> - <li>Look under “Role-based access control settings”. Give the “editor” the right to “View any content” “View own content”. Checking a box grants the access.</li> - <li>Under “Actions”, again click “Add action”,</li> - <li>From the pulldown menu “Select <em>action</em> to add”, select “Revoke Access by role”.</li> - <li>After making the selection, you automatically continue to a new page to set up role based access settings.</li> - <li>Look under “Role-based access control settings”. Revoke “View any content” “View own content” for the “anonymous user” role and the the “authenticated user” role. Checking a box revokes the access.</li> - <li>Click “Save”.</li> -</ul> - -<p>Verify that it works:</p> - -<ul> -<li>Create an artcle as “Alice” (no special role). Verify that is viewable by everyone.</li> -<li>Create an artcle as “Bob” (the writer). Verify that is viewable by “Ben” (the editor), but not by “Alice”.</li> -</ul> diff --git a/web/modules/content_access/help/rules01d8.png b/web/modules/content_access/help/rules01d8.png deleted file mode 100644 index 93adddbe570f87ac9d2fb04c655ec900a5da6835..0000000000000000000000000000000000000000 --- a/web/modules/content_access/help/rules01d8.png +++ /dev/null @@ -1,59 +0,0 @@ -�PNG - -��� IHDR�����X����~�S���PLTE��������������̇Xl�8fа�e2ZmXl66L2L�U�ue�mX��kƣ�����--f6XX�22Lmm�XXl������23=^p�;<@Qt�2FzXm��:�6Z�0M�Ll�>HZ8sIx�`������K�Z�1m�m��m�ۇ���a��_�1f�L��By�l���v�)x�Z��c��\��s��e�a�T��`��i�!��z���y��v��u��s��q��N�q�n�������n��m���������7EL����t�!��v��J�����~��b���o�������X}�u�������և�����m�����������������65Plk��������������������������٬�����������Ѩu�����������LOL����������ݭ���oqn��}�����������ʢ�l������ߝ���mmU�����������������������������������������������������������������������������������������������������������������������ʆ�h�ܵ�����������}����������������������o3��l�Ȕ�������}�؏�������ݢ���ڴt��\ݩhӝ_��j��Y543���6K��G��lߣmݢl����mU�j3��XXE6ܿ��Q*yJ3�6�mX���<42�PGۛ����L32�����KJe))6�XX�XXmXX522������������������XXX222���k�h���tRNS����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������S�%��� pHYs����������iTXtXML:com.adobe.xmp�����<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 6.0-c002 79.164360, 2020/02/13-01:07:22 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmp:CreatorTool="Adobe Photoshop 21.1 (Windows)" xmp:CreateDate="2020-06-12T19:03:27+02:00" xmp:MetadataDate="2020-06-12T19:03:27+02:00" xmp:ModifyDate="2020-06-12T19:03:27+02:00" dc:format="image/png" xmpMM:InstanceID="xmp.iid:39bb1941-03d9-6248-8fe9-61ff06fda2a0" xmpMM:DocumentID="xmp.did:39bb1941-03d9-6248-8fe9-61ff06fda2a0" xmpMM:OriginalDocumentID="xmp.did:39bb1941-03d9-6248-8fe9-61ff06fda2a0" photoshop:ColorMode="2"> <xmpMM:History> <rdf:Seq> <rdf:li stEvt:action="created" stEvt:instanceID="xmp.iid:39bb1941-03d9-6248-8fe9-61ff06fda2a0" stEvt:when="2020-06-12T19:03:27+02:00" stEvt:softwareAgent="Adobe Photoshop 21.1 (Windows)"/> </rdf:Seq> </xmpMM:History> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>C�ҙ��9�IDATx��|Tՙ�w&qѭk���u�]��(1�.iV%"�|Y��k?�����`�����[��ULd�u��-������*�HUDB[Kb�3�RE��3|��y�9���M23�I@~?���{ϟ���9�ν�?(��!�� �@��<��eӦ-�/�o%�����dr��گ�=��s��@�m��}�ؙl ���V�l:|x��x����d����l$��W��>8��B�?/��g����ǘ��>ә<k_�o"�5����[6n����W$�ۓ��w�~?yF���W��֨_:#�[�C�ޗÿ}�P�̑2{|����_�F����>59�ރ��5��+觩�䙥�4��K��>�6�l)��^��M2y�M��o��G���md=��������o����+<���;�F\��/[0�8㬛hW2�5�s<�Wm)z��������|���_PkJq�,+�X�G}����K��B�/q�7~����pg�y ��!'��b��B���ݭ:�#{�H#z�M�����w0t�oH�vL�x�,���I �ѷ؇�Q��}{M��U��+�H�� �;�*��T8֫B���/�!w������e{«-`%~�ֱi�C�R|��V�;-�:�pn�U�͚*��1IQ�t�U��H�x��^2����7��t{�H��^�F�#�oT����uH���e�L�X)��I����:�KW�� ��CiУBE�5�{~�3�� @zZ_KP���^�X�:&c��z���`�9L:<dx�)h�!/���p�7�Z�1�t�����4맡���V�"D��4e�%����VA�����B��B�I@L��;�yQy�vh�Z�>����ZX�j��"�y��9�#]J>�����е�C0f���s�ߢ��К@�ȳ5�╃2��j�X���Ś�ݻϬk����ծu�� -��0�{������4��B���U��M��x�Y�q /AtX�'�,z�;{�����g\���_z����l�oy��_�����-�=S��Fe�5�w�.��Y�s&�< -�oyw_�98^[�ŧ���w��a�:���-�n<���g��Y�� @=�r��_�bb�%�2���S:�T�x|��?��]�'[Kgu��}��r>�ŝQ��/!�z��^� ㈠��*� -�k��6=�?�=��9�B����3Y�/z��>k�~�=�|�A���!�A���!�A����c@���N���� �@��� �@��� �@��� �@�����pyp��ؿ<X;m~�+)>�U�ec�G�s���zx�̅Yv��!���w��^�I��'����������1�o-҆������@�,�,�ʊkI3`�,�a!�����gz���FtW2��@F��Z�SY�udb�L_/�.�eD;g�?a�� -���/E�:y�;�<}��熫�����V[3��s���M��yC�� -�a*>��c��b��"����ΣC�9�S&$��w�����\;�:� ����+L�4���R�p��2�� ~�������a��ە���'������(�]`�Y�eq��3�����RTO@�?�7��M��GR�x�ɳ����8��������e�p�����5��� -�ƹ2���6_1s1?"��k��SuVUV�w�3N�� ���k���U��By��9a��c���[`��*#G����QdG厒z�aBPuI@l�3���Vt�Bi�#�4L�/�����R 63"ɘ*�@I۸�-�-OH�Q3�p^ `�f\��u�aM#��&��j7�Y-�{�E���?����;B�8~�3|���7f.4�<y�5�i������c��{@� ���㘙R?��K�;��u�0�s�����<���A�<�U#ZNչ<`Z:̈́e��+�T-��~j�][fF��6�]#����ư��������rOI}D�Y<u�ϲ�s�cc擕3�`���H��O����������k�s(RΛ�/�S| � -�6���m����ɚ�����\��T+c^���Z��E�"æ^4�U�Of�d�]��`�� �3kf�g j6iV,z(F�B(�g�P�s@��l&�?�%����f���֠����5d�����KKg��1�V���S�����G2�r�R�00�1�*s@���͘�Ys�@�^��֨.��5q?���˾ -7mj��_h����%��x�l�`�9�p^���ټyVp�yI�|�G<�W����V]�,�S��K�6B-P��9��9�1ʬ���������D�O�"��Upħ��8=Y���s�5R�:���3�y}��d�S� �IkM��w�)��ص�̤i��mkK�?Жn���j��y����#ƶlkI�vm��|����%���[��~r��`������T�U��� �!�B��� �!�B��� �!�B��� �!�A��T����oh���pg�Gž���{���BV��G���!O�K�wHVy�Yڙ�̹�����G�;b!/�[K�$��Or�l������0z�֒_&�NAQ������c�����q`�w:(I%T���� ;�����A��N������V2���f{@�PN.m�w���PPr���ѷ�͎de�!���Z|��PU�$W����G��@�8��[١Ev`O8bvDQ�C1f(���� � ^�\R��JЖ|����|l��C��b>(��:�e�2GY^������@��0��P�-'�d)���_����d�P�< @�sc �#wh�"�r}[�0�L+�Ūe:m#�(�!��]�T�$O��������m���UF�+����Qy@���&��U��U+/l�!�C1�pSW��}u�5��ko�S�V梪��P���"��"�3~"u(bm{>Ƚ3��A�؇�4��B��� @�B���H�����|��E@*��d�=�{ �����G� �r�q(?���(������S��sÝP����Ko�~��sp���e������i�2{H�s�N�u��8�>�G��4c����P��<v��kԧ[�_�������v��˒�y퓣GO�[�s��t�o��Qu=Zr�k֣x��� ��m�n�G���9�]��#�S�bߤ4wG�g���P*� '�\�oS��ݩ�v�y���i�N�v_�Z���q��0(���.z� k����^$��_�?o����~}��k��������t��#|��2��q;�J<�i�Q��k�q��BKo�$�T�O�=N��*��%o^�9�����箃�l�8:f�k�L\����/��L5�2��?o�m�ϻ�Δ{��g�����C4|/v����U4�O�֚��$:��ûO��s����ߞxl;�9%�D7&��ޘ&2�����AX��Û;�g��K�l���1����"v8;�'�"��(���qb�4n����l�Y���>��ƶ)���8���@���M������_EC�j�=�L\����*~�V���*y�17һ�y���M�N�ґq�i�D�)���R��ɱ�Ja�]�y�}������J�����V���VI21��<�a�PJ"���D��i�2�e.�*+���{`�X�������߸ի�:���9fѭ��ݬP����O�F -�ۘJ���Y�\��N9ϺQ�us� ��0�n�]�O%7v~m��휖��f���!Pv4<���vޱ�= �� ��ܭ����d����p����O�~�چ7O�~���4��wQP��̚��i&�����o�yo�V�p��V��N,�ȅ�nW�|^m�0Ů|�6����}��V�[�89N�����]�V�$�$� '�d?�ڲ.�ܥ���ՅҊ-g��������9����|��� +W���89�(��#��&c�q��W0g���O2�os���s�=�g�b�)���D�q����{�n*�A���+YA$��RP�b��v��ںTsW��$��,�6<��0�07�WXbBo?b��>�Is�'�Ɏ4��d<�#���n]���r�W� ��EpN|����qJ*���d����Ja�}�f�V��e����@N�l_�j�<�f.d܃?���Ͳ�OƮxr7!up�ts;�[)������wn��]/��k����}a�+��[W�౭:�}�ї(�K/ܹ����x�v�X��Η��Tʮ;}�_��F~�[o]������bņ�R샛�� ?��a�� �V��:6�jݵy��7<��f6��G_�%;�|}3Y���*�.��]/��+��0�F�&�tB ������&�n�z������� -� ������� ���#�����G�0'�_��|�7%� n���m�xq.��נ!�� �!�B��� �!hP��%��s��˺��/_���{{���iȳ��������r3Κ]��,͢g�\��a�`��O��C��#��yP���c3pp��_�?=7B^P^���D�\��DH ]��h}��2�z%��k����S�x�_6aݤ����t�ץ�f(��<�T�&9Uײ�k?e3$e��m1��9�>�k��u�t:H�?���ٮ�֖r�\A��b��W�Sǔq�)(�M��Q�J�4Ct~��kSy�u]�e:�g��t�ڲz���2s@EG�:�/�ho0��͊��k9�ۼE#����5a1Jz -�� ����ևmף<�b�:N�L�-�v$NT]˺h���i(��s��$��kJg���OK���*�����3���H�+��1ۗZ�t���(�VCt���SH�]�5r���kw�t�O>9{��_�?�<�L���#��k��.���� �9o����@иz�[m EK��Lv(�?�N����2�.�ԟM����Oz~�m]sL���I��1B�he�^��Ѫ���c�O�~� ]��#&n1����$u^>&�WW(�Ѡ&\�{�7�Q�!��Q���K�<7u^�r����o -�z����Ѡ���0dM�kO}z�����+יҥ����\�RUE�@��g=�0� �S��L3�䏟���� ���@��U;O���c�0�%�*ۧe⪗�u�!�9��0���� -�=!�����Wd�8U!2�.� � -����>#~ǹƓ?�25��h�ԧå��B�^�p� -��u��4CL��w�~�7@�� -�C���fV�}z�.蠞J� �aWw={���Q�q/S�k��t#���E u�p�u��Z���kih����wZ!��K�]n�1&����!�2:f-;�@�^Χ��hʩ�Ls�<אL���"&�Peq,B�;r�|:zX�o����H$��թm�x�dT�A�q&2ըlv��D����ve��� -�9=��;�����H���A�N!'ɮ�H�Drnjd`]�C_t�!�B��� �!�B��� �!�B��� �!�B��� t�X��0 �����A���-�8�<���Uٺ�N��!�`�B������ �@��� �@����!��餩���ߦ�7=E<?���L?gA�?F����tSu6t840��b���v�O�KY�|�����K!��>�v|0��ol,,{w�7�K)�$�l�p(�����)��0���ɳ�m"[Λ>_�������2���S��l����gk���O��J�"��=�: `�#4�` -�� ���ǝ� (+�����ɹ'�����&y� �ی�K��B�����sfC�CY�s�����}�~S����_����q��[��"�x�M��f�'�dC�C�-Bv�tކ�ԅH�Y�/�瀣����0Li�9��l���Pv�����=�Ĝ�}{x��p��e�&GHaZ�l��P��a�R�c����.XX�\�Xs��"a���6�u���q(K�� -�I��a��K�5����V���o������R������MgC�C0�l4��B��� @�B��� @�B��� @�B��B���!�A���!�ؿ�?.��p�P���w?*���� -��#f;��$K����>��>FBypIg�2��������}�����P�L����;w~H�~��B��a��#�L����$���iU!���O�?�|{�} -�=ɪF�^|�u���d��;[+9��9`�ůP��� -� �*~5џ�=PR��C��ݶ������ - ��֤�ȟ�H���������K:[ˉ�*~�)��Z��9 tH�U�8 p������:iE��\F/B���ѿ�E�;�����|�O��_���W���)k��,�U�l -���/TP�!�B��� �!h0,�ʯ��]6�)��B��ϊ���l��l�z(����� -��k�A�����0K�ס��u��@��!���S�������������"�*�y ����T��Q����|A��d��؎��k{���X�Y���>��g�ɮ�����jkk�_@���5 ��ڠJ0H�F� ���$J�V0�H���% �(V�� -�R"A��y+Z!��xi}cw"Q�`���q.E�u"���t�����k�vJ�{F�8Qj&��I� ��M�f�.�sp����'/<+�gp�����b�MKO�8�å]�i|�"��o<i�8 �L�r��rɐ?<�<��}� �O�W�7�w|�aՎ�_�����w$�ګ���Uu$����W$+�~ ~8�"Mm��w��8@�|�D9��ѐ��K`� *Uz���UV���_�}��?:��Z�yH���x�Ua��`�� ��kk�_�xr��A�Z4f��P���[�?t�Y��2G�0y1�O̵�V������Ϧ ����ѿ���z_U���%��e�����G�UI ���^�[E�ʦv�7l�"����h//>(!��7t�������>�K��mTt{y�*����҅��(OG�6J�K'�l<�XMM�\�{�,;�y�\���S^�ʑU|�@ �8���U��Qq����r��Ϧ`����������;�W�}j�Es���r��ӚT7��j����SR��.����x���s@B�?Qr{N�Β��˗��lUzSGe�I=ҋ�K�<�6������?��*O�����~�$������~���sx�y����:��?2�uw�tKc&�7�LΚ��|dI'�(>��<��Rf~�}�)�.\j���ގ/��t�ڻM�e{��M�λ@Ny���x����O�����qP�j��ӽ�`�14��9 ;� -�L���jxM9��\'�;w��aǁ�%��(�4�t��+̌�W��Qn-O0H*�*H����Xg4����*X{@��"��[��HV6���ڷ�}�{�%��8���9�6r}��e�=���e�KX�ۨ��y��k\o��K� ����@;����K���6��N���߬�er�O�j��<`��%��k(G��;�U�N�))�5u�7hq־*��Ћ�0���&P!�M{J�t���ջ������"�ʎC�MV�9`���ck�V�{�9�p��A �����[�)��Q9q�+�lP#'�oh�Omm�����n݆�fe�z�<m��|��d -h��f�>R�mnb�������M�_�o^.�4=�dy��|������c�~�a��Ӑ��ߓ˄�v~�E*TM�)O%5�%�8̳dU]��ǚ�\ZS[�g,+l�v�x� -�@�� � �����c�#p_p^�ހ'#d�SG>��#O�l�� �@��� ��8��uS����b��ۃL� 17"�U�^���ڔ�;e�y���>o���� ��_5��3�x��n��l�,������|<�(����-K�y&��v�K/��0���23�!f`c�5���H�i�ݟ��q�mG�y�ҧ����[�uIW���n97W@[e�+�c�w�g��!�K��J�<Ug�R����*������o��։��F?G��i.E"��F�������T=^$�+b7�m�c�fLݱ�����R툎zY�o� -5]d��?9�' *��+�.U��1��W������G*����LRVJ^�_ ����"�bdcwi=�wC�Isx���i��:H���ˑs8��CP�/�B�Y!D-��;�aSo��tA�rs�E�u�`�f��<U����;-�u�r[��Ib7�<��u($�������Héu��j�u���>I��07�:�Tݡ�OUa}Uig�� 9 -N�n�����)����0�@Pwf�7���q��)/�07K�'+��6�Gs�K���W�nUO���ep���"�08�c�����El4ha{�E��d�2�0�}[�!y�C�j�@ޮv���<�zST�1�sbbbmJ���A���!��d7VJz�0��9B�:�����GT���ѻ��4�����j�!�T�j������Nж. ��S~|j���]s�"�0�zH2�{0ؐ��ژ�m��Uw�5^�D�h�sF����P��������;���NG���%r�� -;~�����6kz.��Q�F�NM��+W8C�DUy�V�W��Ps+r4ᰂ�[��(oT=�P�pjQ�����h�~�i__�J�Ԏ���.Om�����b���!g�'d4L��x�������6K7*��&���#��%:�{r���P�����U���z�e�"�[���9� `��duS�]?���TTk��px�zN���d�`iaz�M���zJ�L�zжV���Q=A��7�{�`�ӝ!X �i��haO�藐����]4g|�iY����O-�Ұ�8�����(��0�?�5e�oheϏr��sϴn:J8�� �@��� �@��� �@��� �@�� ��#��|���������^� � IV�ʿ#����?�C�w�O�C� ���@%1W����|I硒������A0�'��;����C�=��O(BPa<�Z�T2{a�Ӟ���ؑ}�x���=�%�d�04�.dXNs@���\��~��:��AY���7Y��wО�$B04(�*5�! A��C��s���ȡ�� �� �@*8�E�C�U���#E?�O(�Y������l�z(����� -��k�A�����0K�ס��u��@��!�� ����@�� ����@�� ����@�� ������@�@��!�� ��� �������ܘ���7��Y�ԑϠ|��S�.�!�B��� �!�B'�K��Di}���J�vU�v��;1jp���X&��2n^o���.��6����؊�7)���Ձ��G1�Q/۩��u�1 oc�?��� x48�_��pԫ���y۶��0��*]��ޔ�����~Z�˴/g�����Vi������{���7C<ۜ���U���e��6v_ӝ�c��C������{*�76��x�ǭح>Q89DZ� -��HTD��ҮK����w���-i�&�ّ$:�ץ�Q)�*����M���ɘIW�P��ڀ��m�tq�s\[���Ξ>���B(��F�ar�~e��c��,�f;0���- �嵴��n��*G� -�ܝ\�i��˕oWx"��s_�5^� -UI��͔z���� -)d�F�@��1���`��m�.�o9e��x�����v��/��S�m/ -!K��̨`��ZzB�� ���S-���*���9\��ⵜV�Lpͺ�2id�N�Y�n��*��)1�WH֨&�?�J��:{:���mHL����[��Ŵ�)tǨf�e�����ki�*G�Sr� ���ݔ���7�%��x�+\���@SWP]�30��/���x��$�8]m<a;�� ١Cޥ� ��"��������!U[7��q���L�e$ª{�g��۟��RY�uII��6%$b�4�Z� �]��zMI��P:H�@��R�i��ⰘR��1�v� x_<��/S��q�2���JL6O���{��{%��^��kϧBH�����@e�5Q�e٫`��r��g�Ү�{r��G�U�D�$Q�Zay@�* ��=��ܘ���������*���~$��K����T�Utf�`l��rݍ��t7ӪK�0�2�Uķ��> c��\ �ծܣ�a/�V��(��I'�� -�����U* �N���2�H�+9c�������ٽ��P� -�Վ�XxP� O�FJ�%�[~٧a�H�=�J����F���^��v4�v���uI0P68!�|P�_6�bHHO\-�i�t��W��=2i��!�POa�E�g���|��s/�!�B'����U�*O������LJy�IsK"c���C��l!�^�%��R��!b�s��%�b6ǵ1��.y�O̢"(�f�^{����L��N��?.7Ǭ �Y��������^�i�`B0��{٪���D�ݎ9�����%���9�d ٕ�}�L��pj�����T���̌O��L)K)љ��������9�hE�ya���A/�..�Ӟ���{�k`cY������,c3�E���a�����L�hE�ۥ���Ĥ�����W�u� -�S������!�A�:���S���r�;�+}8�}��������>�K��h\?�Ez9�W�����-���M����S�0��ۂ�-�����@��ۅ�����/�0��eHm��,���_��WC�����y٦�2�.�t\��.~�_�c��� �f˾�R�g2��9���+4u�Nu���3f.I���1Wj��ϖNc+��9������?������@O�L}�������m��w���x%��Մ�Q�ĉ�����s���Qݺl�Iu��R�G���˥|ifH��ÁF�U*�Kǥ��M�U��b!s����S]�����%�as����P�=�6Ve�;@ ɵ ���@S�ޚ�1�5��u �}���HG�ʵ -0���ܫ����Z[����:/�4Cg� �����6��^��U�l]7���q駹f�}���X�����!s���r})���u.�,E'�_M�A�R:sM���N�g��ܩF�����V�M�:^�[]���r��Y"��<` -��e����/~�/t��y���f_7��`sL��0���Rs�\�M\��V�u�A��\��n���>�����3�p���A`_�u٦��������wO��RT�&[�%��K?uv_�)��+4��=�PԺ�� �}�h2��{mս}h}2йCp������<�1P���1�f9�8���!X]�i�Z]�Ȉ�+E�ٲ/����+�w���X��鋉e�u�`��S���+D-<�V�.dM\ާԗf��Jz��X�"�@Φ��5����V�Z]��J�痐̯<�{�a�p�� -glz�n���e`R>#���m����`fR��YP��/��!�A���!�A���!�A���!��>\ҙd���W!��ҽgO���A���jO&��*%��^��@Gr���[��O,g�H��#6�&��-���C��|�)K�*�����P���C�ʭ}�(c��-Ꮭb{��\(e.��g�=N8b6�X��Vu0����q`ď��/>Ȁ y��vr�����_�zOk�?��M�l��d�N� @�h/s@%_&��ʬ;�%���3���ۦ=&?4����U~� lXNNP�qML]I���u�����B�������i:G��;���=����]O��R����������]���*�1���i,A� -��@�鼰waC8��@��MM�Ѳ����6�3�+���_��Љ `�����A���X�9�GE��x��g� A�ϊ���g�CP>�᳜�\�v \k���:L��<h��� � �!��!�@�@�@�B��B��������� @�B��� @�B��� @�B��� @�B��� � �!��!�@�@�@�B��B��������� @�B��� @�B��� @�B��� @�B��� @�B��B��������� ��� � �!��!�@�@�B��� @�B��� @�B��� @�X�����B0������B�B�А�?x@�B��xd��u4p��p$��:��CG��@*��B�������c ��]�D��>�c}�n���mM$z90j���b��GWػ��1��N3��W����*zi��K�j&&�`(}��O��'���c����>�j9eN/�@g7�ugA�L�"��L�]�3����-��6v_ӝ�c ��-=��?�P� cS<��$�&1���#;K�%9[+�;��PE��r��\ҥ������Yը�託�Hn5�������ҧ�]��Үk�e���C�.�F���Re�N�z[*�]��퍎��u� -��� -�|U}��Y��+���6T����xj������z�# M�pݺC�,��ͦf�\�t�j���4Ͷ� ���UiV"�tg_R�+���0D�֫N]$2�]�7��N��q�� -�i���R�$���VQ��E�di��9�:�ύ�v5�Rf*����"�� �!FV�?J�A�'��Z�`jL�&���J�Қ -eo"dm�c�L���d�Y)�3��E��l)}���2mA���Tjw��a�m� ��m��#U�Tz�4����V�Dl���?���w�0��@��W�8��-n�t\����Prݛ�\y�z�ݴ-��h���M�������Ւ���4K�����1Nƃ��ԍ��n��1 @�ܔMF9K����,ΦP������ܕ�{��i������x�6:��)-3cƿ�) �j�n�cМ�;���v�\�K�V:g�W��զ9�7��Z_�˨?�����l��P?�j����6�2c��4���cԢT�U20� ��6��G3���݂3�{����ީ�MƲ�s<<��̨���v�u�� -�ݑ�*�մp�*���th{ø ���.�!��Ȯq�#�a �n�U���0l�?� -�*�k08b%�D*uH7�W�Mr�pK��-����eF�3X!�æJЙ�9�e{�@�`�����CO] �j�n�c��4i��洜�9�.�$�C0e�!X�8����j���Sp �U�5n�Y�Q͍y��<����Q�p����\�k��^��,K*�!XJ���Wz��;Ԥؚ��C�V�Q�0}K[�p�MR��D{�k�(��]�"D7������܋��?$/c���e�qҼ�tL�z��j�G����9-pw������-籾��A+�2Ƚ�b�uo����477[�� -�p�'�<�ŜڿUa��G�p�U����i��ܯ��~,Ϫ����E��F3O9��@��`��� �@��� �@��� �@��� �@��� �@��1 -�Z�4�Z�p˖�4��m��`���4�������A�PHA���!�A���!�A����/,�������N��W� -�jh��Ξ2~��5S�S͌ɓ��l ���I3����g�ћP�����4yjΚv�)p�P���}a���8��FB9�2@���)��Pn�fM�x��8A������ߴ�����\�L�4-��� �@(���/���.��O���������c�iN��.���z�'�e8f���Y�8�] -e�w�)�����6m%��/_���/��m�x�`�`(k�#�fx�4�G�j��+|����������?��˾|��{e���.������֤��[�\��ȟ�L�>�iW�kv�����W\�|���ʊj�t��@O��.S�����ɠ/ж�m����_�mk��@������n��|�g�-;�<`�_,|`�o��^�[��1cƜ㕧�B9�8iFM/>�/��-��{�Ue�k�E���n���|�/��Γ��B9,B�_\Ӌ����2y�+�۹��� -�o�p�з��5���^<] -e��'צ�Fζ�����N����Y<����m�����1r�z��&W�4�=��&ե�t�Qʹo���<���(���s<���/!P.���_�Aӥ�u�uu�Θ1C>]ZWg\Z����[0��02��:X����N�zI6i -���r����O��p= ��rE���xr�� �x���(G�#�^8@/�]qP����I�N�4���ПP�������I�g݊30�@���=eҤI����3f\<�rM9�� @���ry:Vy�������;�����D�>(o��@4��B��� ��?u&�ͧ������IEND�B`� \ No newline at end of file diff --git a/web/modules/content_access/src/Access/ContentAccessAdminSettingsAccessCheck.php b/web/modules/content_access/src/Access/ContentAccessAdminSettingsAccessCheck.php deleted file mode 100644 index 3e00c7f3c4b73ca4547e88358ad0de16c15081c1..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Access/ContentAccessAdminSettingsAccessCheck.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace Drupal\content_access\Access; - -use Drupal\Core\Routing\Access\AccessInterface; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Access\AccessResult; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; - -/** - * Class ContentAccessAdminSettingsAccessCheck. - * - * Determines access to routes based on permissions defined via - * $module.permissions.yml files. - */ -class ContentAccessAdminSettingsAccessCheck implements AccessInterface { - - /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - - /** - * Constructs a ContentAccessAdminSettingsAccessCheck object. - * - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - */ - public function __construct(EntityTypeManagerInterface $entity_type_manager) { - $this->entityTypeManager = $entity_type_manager; - } - - /** - * {@inheritdoc} - */ - public function access(AccountInterface $account, RouteMatchInterface $route_match) { - $node_type_id = $route_match->getParameter('node_type'); - $node_type = $this->entityTypeManager->getStorage('node_type')->load($node_type_id); - - $permission_match = $account->hasPermission('bypass node access') && $account->hasPermission('administer content types'); - return AccessResult::allowedIf($permission_match && $node_type); - } - -} diff --git a/web/modules/content_access/src/Access/ContentAccessNodePageAccessCheck.php b/web/modules/content_access/src/Access/ContentAccessNodePageAccessCheck.php deleted file mode 100644 index cacb522a6ccb7783d241a004d37270a5728493de..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Access/ContentAccessNodePageAccessCheck.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Drupal\content_access\Access; - -use Drupal\Core\Routing\Access\AccessInterface; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Access\AccessResult; -use Drupal\Core\Routing\RouteMatchInterface; - -/** - * Class ContentAccessNodePageAccessCheck. - * - * Determines access to routes based on permissions defined via - * $module.permissions.yml files. - */ -class ContentAccessNodePageAccessCheck implements AccessInterface { - - /** - * {@inheritdoc} - */ - public function access(AccountInterface $account, RouteMatchInterface $route_match) { - $node = $route_match->getParameter('node'); - $all_nodes_access = $account->hasPermission('grant content access'); - $own_node_access = $account->hasPermission('grant own content access') && ($account->id() == $node->getOwnerId()); - - return AccessResult::allowedIf(content_access_get_settings('per_node', $node->getType()) && ($all_nodes_access || $own_node_access)); - } - -} diff --git a/web/modules/content_access/src/ContentAccessInterface.php b/web/modules/content_access/src/ContentAccessInterface.php deleted file mode 100644 index 21a7458a62a999065c52b74c5c2c8df6042bbf81..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/ContentAccessInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -namespace Drupal\content_access; - -/** - * Provides an interface for content_access constants. - */ -interface ContentAccessInterface { - - /** - * The threshold until we try to mass update node grants immediately. - */ - const CONTENT_ACCESS_MASS_UPDATE_THRESHOLD = 1000; - -} diff --git a/web/modules/content_access/src/Controller/ContentAccessController.php b/web/modules/content_access/src/Controller/ContentAccessController.php deleted file mode 100644 index 0c2615490d3ee067539757dace4d165cc2f2e444..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Controller/ContentAccessController.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -namespace Drupal\content_access\Controller; - -use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Routing\RouteMatchInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Controller routines for user routes. - */ -class ContentAccessController extends ControllerBase { - - /** - * The route match. - * - * @var \Drupal\Core\Routing\RouteMatchInterface - */ - protected $routeMatch; - - /** - * Constructs a ContentAccessController object. - * - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The current route match. - */ - public function __construct(RouteMatchInterface $route_match) { - $this->routeMatch = $route_match; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('current_route_match') - ); - } - - /** - * Returns content access settings page title. - */ - public function getContentAccessTitle() { - $node = $this->routeMatch->getParameter('node'); - $title = $this->t('Access control for <em>@title</em>', ['@title' => $node->getTitle()]); - - return $title; - } - -} diff --git a/web/modules/content_access/src/Form/ContentAccessAdminSettingsForm.php b/web/modules/content_access/src/Form/ContentAccessAdminSettingsForm.php deleted file mode 100644 index aa0f86d6c92d9a7754f8a10a700ee67a009787d2..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Form/ContentAccessAdminSettingsForm.php +++ /dev/null @@ -1,203 +0,0 @@ -<?php - -namespace Drupal\content_access\Form; - -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Form\FormBase; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Url; -use Drupal\user\PermissionHandlerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Node Access settings form. - */ -class ContentAccessAdminSettingsForm extends FormBase { - - use ContentAccessRoleBasedFormTrait; - - /** - * The permission handler. - * - * @var \Drupal\user\PermissionHandlerInterface - */ - protected $permissionHandler; - - /** - * The module handler service. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * Constructs a new ContentAccessAdminSettingsForm. - * - * @param \Drupal\user\PermissionHandlerInterface $permission_handler - * The permission handler. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. - */ - public function __construct(PermissionHandlerInterface $permission_handler, ModuleHandlerInterface $module_handler) { - $this->permissionHandler = $permission_handler; - $this->moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('user.permissions'), - $container->get('module_handler') - ); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'content_access_admin_settings'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, $node_type = NULL) { - $storage = [ - 'node_type' => $node_type, - ]; - - $form_state->setStorage($storage); - - // Add role based per content type settings. - $defaults = []; - foreach (_content_access_get_operations() as $op => $label) { - $defaults[$op] = content_access_get_settings($op, $node_type); - } - - $this->roleBasedForm($form, $defaults, $node_type); - - // Per node: - $form['node'] = [ - '#type' => 'fieldset', - '#title' => $this->t('Per content node access control settings'), - '#collapsible' => TRUE, - '#description' => $this->t('Optionally you can enable per content node access control settings. If enabled, a new tab for the content access settings appears when viewing content. You have to configure permission to access these settings at the <a href=":url">permissions</a> page.', [ - ':url' => Url::fromRoute('user.admin_permissions')->toString(), - ]), - ]; - $form['node']['per_node'] = [ - '#type' => 'checkbox', - '#title' => $this->t('Enable per content node access control settings'), - '#default_value' => content_access_get_settings('per_node', $node_type), - ]; - - $form['advanced'] = [ - '#type' => 'fieldset', - '#title' => $this->t('Advanced'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ]; - $form['advanced']['priority'] = [ - '#type' => 'weight', - '#title' => $this->t('Give content node grants priority'), - '#default_value' => content_access_get_settings('priority', $node_type), - '#description' => $this->t('If you are only using this access control module, you can safely ignore this. If you are using multiple access control modules you can adjust the priority of this module.'), - ]; - $form['submit'] = [ - '#type' => 'submit', - '#value' => $this->t('Submit'), - '#weight' => 10, - ]; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $values = $form_state->getValues(); - $storage = $form_state->getStorage(); - $roles = array_keys(user_roles()); - $roles_permissions = user_role_permissions($roles); - $permissions = $this->permissionHandler->getPermissions(); - $node_type = $storage['node_type']; - - // Remove disabled modules permissions, so they can't raise exception - // in ::savePermissions(). - foreach ($roles_permissions as $rid => $role_permissions) { - foreach ($role_permissions as $permission => $value) { - if (!array_key_exists($permission, $permissions)) { - unset($roles_permissions[$rid][$permission]); - } - } - } - - foreach (['update', 'update_own', 'delete', 'delete_own'] as $op) { - foreach ($values[$op] as $rid => $value) { - $permission = content_access_get_permission_by_op($op, $node_type); - if ($value) { - $roles_permissions[$rid][$permission] = TRUE; - } - else { - $roles_permissions[$rid][$permission] = FALSE; - } - } - // Don't save the setting, so its default value (get permission) is - // applied always. - unset($values[$op]); - } - - $this->savePermissions($roles_permissions); - - // Update content access settings. - $settings = content_access_get_settings('all', $node_type); - foreach (content_access_available_settings() as $setting) { - if (isset($values[$setting])) { - $settings[$setting] = is_array($values[$setting]) ? array_keys(array_filter($values[$setting])) : $values[$setting]; - } - } - content_access_set_settings($settings, $node_type); - - // Mass update the nodes, but only if necessary. - if (content_access_get_settings('per_node', $node_type) || - content_access_get_settings('view', $node_type) != $form['per_role']['view']['#default_value'] || - content_access_get_settings('view_own', $node_type) != $form['per_role']['view_own']['#default_value'] || - content_access_get_settings('priority', $node_type) != $form['advanced']['priority']['#default_value'] || - content_access_get_settings('per_node', $node_type) != $form['node']['per_node']['#default_value'] - ) { - - // If per node has been disabled and we use the ACL integration, we have - // to remove possible ACLs now. - if (!content_access_get_settings('per_node', $node_type) && $form['node']['per_node']['#default_value'] && $this->moduleHandler->moduleExists('acl')) { - _content_access_remove_acls($node_type); - } - - if (content_access_mass_update([$node_type])) { - $node_types = node_type_get_names(); - // This does not gurantee a rebuild. - $this->messenger()->addMessage($this->t('Permissions have been changed for the content type @types.<br />You may have to <a href=":rebuild">rebuild permisions</a> for your changes to take effect.', - [ - '@types' => $node_types[$node_type], - ':rebuild' => Url::FromRoute('node.configure_rebuild_confirm')->ToString(), - ])); - } - } - else { - $this->messenger()->addMessage($this->t('No change.')); - } - - } - - /** - * Saves the given permissions by role to the database. - */ - protected function savePermissions($roles_permissions) { - foreach ($roles_permissions as $rid => $permissions) { - user_role_change_permissions($rid, $permissions); - } - } - -} diff --git a/web/modules/content_access/src/Form/ContentAccessPageForm.php b/web/modules/content_access/src/Form/ContentAccessPageForm.php deleted file mode 100644 index 986c73efa3e3bdb03892b20a2fc2d814432c0e9f..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Form/ContentAccessPageForm.php +++ /dev/null @@ -1,236 +0,0 @@ -<?php - -namespace Drupal\content_access\Form; - -use Drupal\Core\Cache\Cache; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Form\FormBase; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Template\Attribute; -use Drupal\node\NodeGrantDatabaseStorageInterface; -use Drupal\node\NodeInterface; -use Drupal\Core\Url; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Node Access settings form. - * - * @package Drupal\content_access\Form - */ -class ContentAccessPageForm extends FormBase { - use ContentAccessRoleBasedFormTrait; - - /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - * The entity type manager. - */ - protected $entityTypeManager; - - /** - * The module handler service. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * The node grant storage. - * - * @var \Drupal\node\NodeGrantDatabaseStorageInterface - */ - protected $grantStorage; - - /** - * ContentAccessPageForm constructor. - * - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. - * @param \Drupal\node\NodeGrantDatabaseStorageInterface $grant_storage - * The node grant storage. - */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, NodeGrantDatabaseStorageInterface $grant_storage) { - $this->entityTypeManager = $entity_type_manager; - $this->moduleHandler = $module_handler; - $this->grantStorage = $grant_storage; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity_type.manager'), - $container->get('module_handler'), - $container->get('node.grant_storage') - ); - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'content_access_page'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) { - $defaults = []; - - foreach (_content_access_get_operations() as $op => $label) { - $defaults[$op] = content_access_per_node_setting($op, $node); - } - - $this->roleBasedForm($form, $defaults, $node->getType()); - - // Add an after_build handler that disables checkboxes, which are enforced - // by permissions. - $build_info = $form_state->getBuildInfo(); - $build_info['files'][] = [ - 'module' => 'content_access', - 'type' => 'inc', - 'name' => 'content_access.admin', - ]; - $form_state->setBuildInfo($build_info); - - foreach (['update', 'update_own', 'delete', 'delete_own'] as $op) { - $form['per_role'][$op]['#process'][] = '::forcePermissions'; - } - - // ACL form. - if ($this->moduleHandler->moduleExists('acl')) { - // This is disabled when there is no node passed. - $form['acl'] = [ - '#type' => 'fieldset', - '#title' => $this->t('User access control lists'), - '#description' => $this->t('These settings allow you to grant access to specific users.'), - '#collapsible' => TRUE, - '#tree' => TRUE, - ]; - - foreach (['view', 'update', 'delete'] as $op) { - $acl_id = content_access_get_acl_id($node, $op); - - $view = (int) ($op == 'view'); - $update = (int) ($op == 'update'); - acl_node_add_acl($node->id(), $acl_id, $view, $update, (int) ($op == 'delete'), content_access_get_settings('priority', $node->getType())); - - $form['acl'][$op] = acl_edit_form($form_state, $acl_id, $this->t('Grant @op access', ['@op' => $op])); - - $post_acl_id = $this->getRequest()->request->get('acl_' . $acl_id, NULL); - $form['acl'][$op]['#collapsed'] = !isset($post_acl_id) && !unserialize($form['acl'][$op]['user_list']['#default_value']); - } - } - - $storage['node'] = $node; - $form_state->setStorage($storage); - - $form['reset'] = [ - '#type' => 'submit', - '#value' => $this->t('Reset to defaults'), - '#weight' => 10, - '#submit' => ['::pageResetSubmit'], - '#access' => !empty(content_access_get_per_node_settings($node)), - ]; - $form['submit'] = [ - '#type' => 'submit', - '#value' => $this->t('Submit'), - '#weight' => 10, - ]; - - // @todo not true anymore? - // http://drupal.org/update/modules/6/7#hook_node_access_records - if (!$node->isPublished()) { - $this->messenger()->addError($this->t("Warning: Your content is not published, so this settings are not taken into account as long as the content remains unpublished.")); - } - - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $settings = []; - $storage = $form_state->getStorage(); - $values = $form_state->getValues(); - $node = $storage['node']; - - foreach (_content_access_get_operations() as $op => $label) { - // Set the settings so that further calls will return this settings. - $filtered_values = array_filter($values[$op]); - $settings[$op] = array_keys($filtered_values); - } - - // Save per-node settings. - content_access_save_per_node_settings($node, $settings); - - if ($this->moduleHandler->moduleExists('acl')) { - foreach (['view', 'update', 'delete'] as $op) { - $values = $form_state->getValues(); - acl_save_form($values['acl'][$op]); - $this->moduleHandler->invokeAll('user_acl', $settings); - } - } - - // Apply new settings. - $grants = $this->entityTypeManager->getAccessControlHandler('node')->acquireGrants($node); - $this->grantStorage->write($node, $grants); - $this->moduleHandler->invokeAll('per_node', $settings); - - foreach (Cache::getBins() as $cache_backend) { - $cache_backend->deleteAll(); - } - // xxxx - // route: node.configure_rebuild_confirm: - // path: '/admin/reports/status/rebuild'. - $this->messenger()->addMessage($this->t('Your changes have been saved. You may have to <a href=":rebuild">rebuild permisions</a> for your changes to take effect.', - [':rebuild' => Url::FromRoute('node.configure_rebuild_confirm')->ToString()])); - } - - /** - * Submit callback for reset on content_access_page(). - */ - public function pageResetSubmit(array &$form, FormStateInterface $form_state) { - $storage = $form_state->getStorage(); - content_access_delete_per_node_settings($storage['node']); - $node = $storage['node']; - $grants = $this->entityTypeManager->getAccessControlHandler('node')->acquireGrants($node); - $this->grantStorage->write($node, $grants); - - $this->messenger()->addMessage($this->t('The permissions have been reset to the content type defaults.')); - } - - /** - * Checkboxes access for content. - * - * Formapi #process callback, that disables checkboxes for roles without - * access to content. - */ - public function forcePermissions($element, FormStateInterface $form_state, &$complete_form) { - $storage = $form_state->getStorage(); - if (!empty($storage['node'] && is_array($element['#parents']))) { - $node = $storage['node']; - foreach (content_access_get_settings(reset($element['#parents']), $node->getType()) as $rid) { - $element[$rid]['#disabled'] = TRUE; - $element[$rid]['#attributes']['disabled'] = 'disabled'; - $element[$rid]['#value'] = TRUE; - $element[$rid]['#checked'] = TRUE; - - $prefix_attr = new Attribute([ - 'title' => $this->t("Permission is granted due to the content type\'s access control settings."), - ]); - $element[$rid]['#prefix'] = '<span ' . $prefix_attr . '>'; - $element[$rid]['#suffix'] = "</span>"; - } - } - return $element; - } - -} diff --git a/web/modules/content_access/src/Form/ContentAccessRoleBasedFormTrait.php b/web/modules/content_access/src/Form/ContentAccessRoleBasedFormTrait.php deleted file mode 100644 index 707b0f91aacd432e07e8bde09dcc55c53e3c2c8a..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Form/ContentAccessRoleBasedFormTrait.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php - -namespace Drupal\content_access\Form; - -use Drupal\user\Entity\Role; -use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Render\Element; -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Template\Attribute; - -/** - * Common components for Content Access forms. - */ -trait ContentAccessRoleBasedFormTrait { - - /** - * Builds the role based permission form for the given defaults. - * - * @param array $form - * An associative array containing the structure of the form. - * @param array $defaults - * Array of defaults for all operations. - * @param string $type - * The node type id. - */ - protected function roleBasedForm(array &$form, array $defaults = [], $type = NULL) { - $description = [ - t('Note that users need at least the %access_content permission to be able to deal in any way with content.', [ - '%access_content' => t('access content'), - ]), - t('Furthermore note that content which is not published is treated in a different way by Drupal: It can be viewed only by its author or users with the %perm permission.', [ - '%perm' => t('bypass node access'), - ]), - ]; - $form['per_role'] = [ - '#type' => 'fieldset', - '#title' => t('Role based access control settings'), - '#collapsible' => TRUE, - '#description' => implode(' ', $description), - ]; - - $operations = _content_access_get_operations($type); - $user_roles = Role::loadMultiple(); - $roles = []; - foreach ($user_roles as $role) { - $roles[$role->id()] = $role->get('label'); - } - foreach ($operations as $op => $label) { - // Make sure defaults are set properly. - $defaults += [$op => []]; - - $form['per_role'][$op] = [ - '#type' => 'checkboxes', - '#prefix' => '<div class="content_access-div">', - '#suffix' => '</div>', - '#options' => $roles, - '#title' => $label, - '#default_value' => $defaults[$op], - ]; - - $form['per_role'][$op]['#process'] = [ - [ - '\Drupal\Core\Render\Element\Checkboxes', - 'processCheckboxes', - ], - [ - '\Drupal\content_access\Form\ContentAccessRoleBasedFormTrait', - 'disableCheckboxes', - ], - ]; - } - - $form['per_role']['clearer'] = [ - '#value' => '<br clear="all" />', - ]; - - $form['#attached']['library'][] = 'content_access/drupal.content_access'; - - return $form; - } - - /** - * Checkboxes access for content. - * - * Formapi #process callback, that disables checkboxes for roles without - * access to content. - */ - public static function disableCheckboxes(&$element, FormStateInterface $form_state, &$complete_form) { - $access_roles = content_access_get_permission_access('access content'); - $admin_roles = content_access_get_permission_access('bypass node access'); - - foreach (Element::children($element) as $key) { - if (!in_array($key, $access_roles) && - $key == AccountInterface::ANONYMOUS_ROLE && - !in_array(AccountInterface::AUTHENTICATED_ROLE, $access_roles) - ) { - $element[$key]['#disabled'] = TRUE; - $element[$key]['#default_value'] = FALSE; - $element[$key]['#prefix'] = '<span ' . new Attribute([ - 'title' => t("This role is lacking the permission '@perm', so it has no access.", ['@perm' => t('access content')]), - ]) . '>'; - $element[$key]['#suffix'] = "</span>"; - } - elseif (in_array($key, $admin_roles) || ($key != AccountInterface::ANONYMOUS_ROLE && in_array(AccountInterface::AUTHENTICATED_ROLE, $admin_roles))) { - // Fix the checkbox to be enabled for users with administer node - // privileges. - $element[$key]['#disabled'] = TRUE; - $element[$key]['#default_value'] = TRUE; - $element[$key]['#prefix'] = '<span ' . new Attribute([ - 'title' => t("This role has '@perm' permission, so access is granted.", ['@perm' => t('bypass node access')]), - ]) . '>'; - $element[$key]['#suffix'] = "</span>"; - } - } - - return $element; - } - -} diff --git a/web/modules/content_access/src/Plugin/Deriver/RulesActionUserAclDeriver.php b/web/modules/content_access/src/Plugin/Deriver/RulesActionUserAclDeriver.php deleted file mode 100644 index 14fcb0e22c508b2b6dfa5bf96b2380fbb88d10c3..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/Deriver/RulesActionUserAclDeriver.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\Deriver; - -use Drupal\Component\Plugin\Derivative\DeriverBase; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\StringTranslation\TranslationInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Derives Content Access User plugin definitions. - */ -class RulesActionUserAclDeriver extends DeriverBase implements ContainerDeriverInterface { - use StringTranslationTrait; - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * Creates a new RulesActionUserAclDeriver object. - * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module_handler. - * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation - * The string translation service. - */ - public function __construct(ModuleHandlerInterface $module_handler, TranslationInterface $string_translation) { - $this->moduleHandler = $module_handler; - $this->stringTranslation = $string_translation; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, $base_plugin_id) { - return new static($container->get('module_handler'), $container->get('string_translation')); - } - - /** - * {@inheritdoc} - */ - public function getDerivativeDefinitions($base_plugin_definition) { - if ($this->moduleHandler->moduleExists('acl')) { - $id = $base_plugin_definition['id']; - $this->derivatives[$id] = $base_plugin_definition; - } - - return $this->derivatives; - } - -} diff --git a/web/modules/content_access/src/Plugin/Deriver/RulesEventUserAclDeriver.php b/web/modules/content_access/src/Plugin/Deriver/RulesEventUserAclDeriver.php deleted file mode 100644 index 167b61b98170bec0288e1a52f32e31932693cd69..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/Deriver/RulesEventUserAclDeriver.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\Deriver; - -use Drupal\Component\Plugin\Derivative\DeriverBase; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Derives 'User was added to ACL' plugin definition. - */ -class RulesEventUserAclDeriver extends DeriverBase implements ContainerDeriverInterface { - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * Creates a new RulesEventUserAclDeriver object. - * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. - */ - public function __construct(ModuleHandlerInterface $module_handler) { - $this->moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, $base_plugin_id) { - return new static($container->get('module_handler')); - } - - /** - * {@inheritdoc} - */ - public function getDerivativeDefinitions($base_plugin_definition) { - if ($this->moduleHandler->moduleExists('acl')) { - $this->derivatives['content_access_user_acl'] = $base_plugin_definition; - } - - return $this->derivatives; - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ActionCommonTrait.php b/web/modules/content_access/src/Plugin/RulesAction/ActionCommonTrait.php deleted file mode 100644 index 1836b48fff7fef4f161f581c74d85c68054bf24f..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ActionCommonTrait.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -use Drupal\node\NodeInterface; -use Psr\Log\LogLevel; - -/** - * Provides common functionality for Content Access Rules actions. - */ -trait ActionCommonTrait { - - /** - * The entity type manager. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - * The entity type manager. - */ - protected $entityTypeManager; - - /** - * Verifies that per content settings are activated for the given node. - */ - protected function checkSetting(NodeInterface $node) { - $config = $this->configFactory->getEditable('content_access.settings'); - - $type = $node->getType(); - $settings = unserialize($config->get('content_access_node_type.' . $type)); - - if (isset($settings['per_node']) && $settings['per_node']) { - return TRUE; - } - - // If we didn't find any settings in content access for this type return - // false as we don't want to process it. - $this->logger->log(LogLevel::WARNING, $this->t("Can't set per content permissions for content type @type. Make sure to have per content settings activated for content types you want to alter access control for.", ['@type' => $node->getType()])); - - return FALSE; - } - - /** - * Transforms the array of text values to an array keyed by $op and $rid. - */ - protected function transformRulesValue($value) { - $array = []; - foreach ($value as $op_role) { - $parts = explode(':', $op_role); - // The first item is $op and the second $rid. - $array[$parts[0]][] = $parts[1]; - } - - return $array; - } - - /** - * Apply the new grants to the affected node. - */ - protected function aquireGrants(NodeInterface $node) { - $this->entityTypeManager->getAccessControlHandler('node')->writeGrants($node); - } - - /** - * Process Rule's param, and grant by the passed operation. - */ - protected function actionUser(array $params, $type) { - $ops = ['view', 'update', 'delete']; - $settings = []; - $node = $params['node']; - - foreach ($ops as $op) { - if ($params['content_access_user_' . $op]) { - $settings[$op] = $params['content_access_user_' . $op]->id(); - } - } - - foreach ($settings as $op => $uid) { - $acl_id = content_access_get_acl_id($node, $op); - acl_node_add_acl($node->id(), $acl_id, (int) ($op == 'view'), (int) ($op == 'update'), (int) ($op == 'delete'), content_access_get_settings('priority', $node->getType())); - - $this->database->delete('acl_user') - ->condition('acl_id', $acl_id) - ->condition('uid', $uid) - ->execute(); - - if ($type == 'grant') { - $this->database->insert('acl_user') - ->fields([ - 'acl_id' => $acl_id, - 'uid' => $uid, - ]) - ->execute(); - } - } - - $this->aquireGrants($node); - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ActionGrantNodePermissions.php b/web/modules/content_access/src/Plugin/RulesAction/ActionGrantNodePermissions.php deleted file mode 100644 index 56cd85fce7955bea203b457b55f1ea87bf6bbb8f..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ActionGrantNodePermissions.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\rules\Core\RulesActionBase; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Provides a 'Grant access by role' action. - * - * @RulesAction( - * id = "content_access_action_grant_node_permissions", - * label = @Translation("Grant access by role"), - * category = @Translation("Content Access"), - * context = { - * "node" = @ContextDefinition("entity:node", - * label = @Translation("Content"), - * description = @Translation("Grant access to the following content.") - * ), - * "permissions" = @ContextDefinition("string", - * label = @Translation("Role-based access control settings."), - * required = FALSE - * ) - * } - * ) - * - * @todo: Add option_list parameter to permissions after it becomes available. - */ -class ActionGrantNodePermissions extends RulesActionBase implements ContainerFactoryPluginInterface { - use ActionCommonTrait; - - /** - * Defined $logger. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory') - ); - } - - /** - * {@inheritdoc} - */ - public function execute() { - $node = $this->getContextValue('node'); - $permissions = $this->getContextValue('permissions'); - - if (!empty($node->id()) && $this->checkSetting($node)) { - // Transform the value to the content-access format. - $settings = $this->transformRulesValue($permissions); - $ca_settings = []; - foreach (_content_access_get_operations() as $op => $label) { - // Merge in the array of role-ids for each operation. - $settings += [$op => []]; - $ca_settings[$op] = array_keys(array_flip(content_access_per_node_setting($op, $node)) + array_flip($settings[$op])); - } - content_access_save_per_node_settings($node, $ca_settings); - $this->aquireGrants($node); - } - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ActionResetNodePermissions.php b/web/modules/content_access/src/Plugin/RulesAction/ActionResetNodePermissions.php deleted file mode 100644 index 75b5268df8e98ed07809da4a9e41a0bb2d7cc3ea..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ActionResetNodePermissions.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -use Drupal\rules\Core\RulesActionBase; - -/** - * Provides a 'Reset access by role' action. - * - * @RulesAction( - * id = "content_access_action_reset_node_permissions", - * label = @Translation("Reset access to content type defaults"), - * category = @Translation("Content Access"), - * context = { - * "node" = @ContextDefinition("entity:node", - * label = @Translation("Content"), - * description = @Translation("Reset node permissions to default permissions.") - * ) - * } - * ) - */ -class ActionResetNodePermissions extends RulesActionBase { - use ActionCommonTrait; - - /** - * {@inheritdoc} - */ - public function execute() { - $node = $this->getContextValue('node'); - - content_access_delete_per_node_settings($node); - $this->aquireGrants($node); - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ActionRevokeNodePermissions.php b/web/modules/content_access/src/Plugin/RulesAction/ActionRevokeNodePermissions.php deleted file mode 100644 index 50b252edfd47a85483233a92797794c767468fec..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ActionRevokeNodePermissions.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\rules\Core\RulesActionBase; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Provides a 'Revoke access by role' action. - * - * @RulesAction( - * id = "content_access_action_revoke_node_permissions", - * label = @Translation("Revoke access by role"), - * category = @Translation("Content Access"), - * context = { - * "node" = @ContextDefinition("entity:node", - * label = @Translation("Content"), - * description = @Translation("Revoke access from the following content.") - * ), - * "permissions" = @ContextDefinition("string", - * label = @Translation("Role-based access control settings."), - * required = FALSE - * ) - * } - * ) - * - * @todo: Add option_list parameter to permissions after it becomes available. - */ -class ActionRevokeNodePermissions extends RulesActionBase implements ContainerFactoryPluginInterface { - use ActionCommonTrait; - - /** - * Defined $logger. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory') - ); - } - - /** - * {@inheritdoc} - */ - public function execute() { - $node = $this->getContextValue('node'); - $permissions = $this->getContextValue('permissions'); - - if (!empty($node->id()) && $this->checkSetting($node)) { - // Transform the value to the content-access format. - $settings = $this->transformRulesValue($permissions); - - $ca_settings = []; - foreach (_content_access_get_operations() as $op => $label) { - $settings += [$op => []]; - $ca_settings[$op] = array_diff(content_access_per_node_setting($op, $node), $settings[$op]); - } - content_access_save_per_node_settings($node, $ca_settings); - $this->aquireGrants($node); - } - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ActionUserGrant.php b/web/modules/content_access/src/Plugin/RulesAction/ActionUserGrant.php deleted file mode 100644 index de6f9d997217388b158b100215a7ab2bcf04b8ce..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ActionUserGrant.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -/** - * Provides a 'Grant access by user' action. - * - * @RulesAction( - * id = "content_access_action_user_grant", - * label = @Translation("Grant access by user"), - * category = @Translation("Content Access User"), - * context = { - * "node" = @ContextDefinition("entity:node", - * label = @Translation("Content"), - * description = @Translation("Grant access to the following content.") - * ), - * "content_access_user_view" = @ContextDefinition("entity:user", - * label = @Translation("Grant view access"), - * description = @Translation("Grant view access to the following user."), - * required = FALSE - * ), - * "content_access_user_update" = @ContextDefinition("entity:user", - * label = @Translation("Grant edit access"), - * description = @Translation("Grant edit access to the following user."), - * required = FALSE - * ), - * "content_access_user_delete" = @ContextDefinition("entity:user", - * label = @Translation("Grant delete access"), - * description = @Translation("Grant delete access to the following user."), - * required = FALSE - * ) - * }, - * deriver = "\Drupal\content_access\Plugin\Deriver\RulesActionUserAclDeriver" - * ) - */ -class ActionUserGrant extends ContentAccessUserRulesActionBase { - use ActionCommonTrait; - - /** - * {@inheritdoc} - */ - public function execute() { - $params = $this->getContextValues(); - $this->actionUser($params, 'grant'); - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ActionUserRevoke.php b/web/modules/content_access/src/Plugin/RulesAction/ActionUserRevoke.php deleted file mode 100644 index 981a518419917ed163ee19887b7d05f963e9fdc3..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ActionUserRevoke.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -/** - * Provides a 'Revoke access by user' action. - * - * @RulesAction( - * id = "content_access_action_user_revoke", - * label = @Translation("Revoke access by user"), - * category = @Translation("Content Access User"), - * context = { - * "node" = @ContextDefinition("entity:node", - * label = @Translation("Content"), - * description = @Translation("Revoke access to the following content."), - * ), - * "content_access_user_view" = @ContextDefinition("entity:user", - * label = @Translation("Revoke view access"), - * description = @Translation("Revoke view access to the following user."), - * required = FALSE - * ), - * "content_access_user_update" = @ContextDefinition("entity:user", - * label = @Translation("Revoke edit access"), - * description = @Translation("Revoke edit access to the following user."), - * required = FALSE - * ), - * "content_access_user_delete" = @ContextDefinition("entity:user", - * label = @Translation("Revoke delete access"), - * description = @Translation("Revoke delete access to the following user."), - * required = FALSE - * ) - * }, - * deriver = "\Drupal\content_access\Plugin\Deriver\RulesActionUserAclDeriver" - * ) - */ -class ActionUserRevoke extends ContentAccessUserRulesActionBase { - use ActionCommonTrait; - - /** - * {@inheritdoc} - */ - public function execute() { - $params = $this->getContextValues(); - $this->actionUser($params, 'revoke'); - } - -} diff --git a/web/modules/content_access/src/Plugin/RulesAction/ContentAccessUserRulesActionBase.php b/web/modules/content_access/src/Plugin/RulesAction/ContentAccessUserRulesActionBase.php deleted file mode 100644 index 19e83a8126e78667639492d2088c041db3baf2de..0000000000000000000000000000000000000000 --- a/web/modules/content_access/src/Plugin/RulesAction/ContentAccessUserRulesActionBase.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -namespace Drupal\content_access\Plugin\RulesAction; - -use Drupal\Core\Database\Connection; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\rules\Core\RulesActionBase; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Provides a base class for ACL-based Content Access Rules actions. - */ -class ContentAccessUserRulesActionBase extends RulesActionBase implements ContainerFactoryPluginInterface { - - /** - * Active database connection. - * - * @var \Drupal\Core\Database\Connection - */ - protected $database; - - /** - * Defined $logger. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger, Connection $database) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->logger = $logger; - $this->database = $database; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory'), - $container->get('database') - ); - } - -} diff --git a/web/modules/content_access/tests/src/Functional/ContentAccessAclTest.php b/web/modules/content_access/tests/src/Functional/ContentAccessAclTest.php deleted file mode 100644 index abf73e222a79131408f537e4e32da0aa5306e85e..0000000000000000000000000000000000000000 --- a/web/modules/content_access/tests/src/Functional/ContentAccessAclTest.php +++ /dev/null @@ -1,244 +0,0 @@ -<?php - -namespace Drupal\Tests\content_access\Functional; - -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Tests\BrowserTestBase; - -/** - * Automated BrowserTest Case for using content access module with acl module. - * - * @group Access - */ -class ContentAccessAclTest extends BrowserTestBase { - use ContentAccessTestHelperTrait; - use StringTranslationTrait; - - /** - * Modules to enable. - * - * @var array - */ - public static $modules = ['content_access', 'acl']; - - /** - * A user with permission to non administer. - * - * @var \Drupal\user\Entity\User - */ - protected $testUser; - - /** - * A user with permission to administer. - * - * @var \Drupal\user\Entity\User - */ - protected $adminUser; - - /** - * Content type for test. - * - * @var \Drupal\node\Entity\NodeType - */ - protected $contentType; - - /** - * Node object to perform test. - * - * @var \Drupal\node\Entity\Node - */ - protected $node1; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'classy'; - - /** - * Setup configuration before each test. - */ - protected function setUp() { - parent::setUp(); - - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Create test user with separate role. - $this->testUser = $this->drupalCreateUser(); - - // Get the value of the new role. - // @see drupalCreateUser(). - $testUserRoles = $this->testUser->getRoles(); - foreach ($testUserRoles as $role) { - if (!in_array($role, [AccountInterface::AUTHENTICATED_ROLE])) { - $this->rid = $role; - break; - } - } - - // Create admin user. - $this->adminUser = $this->drupalCreateUser([ - 'access content', - 'administer content types', - 'grant content access', - 'grant own content access', - 'bypass node access', - 'access administration pages', - ]); - $this->drupalLogin($this->adminUser); - - // Rebuild content access permissions. - node_access_rebuild(); - - // Create test content type. - $this->contentType = $this->drupalCreateContentType(); - - // Create test node. - $this->node1 = $this->drupalCreateNode(['type' => $this->contentType->id()]); - } - - /** - * Test Viewing accessibility with permissions for single users. - */ - public function testViewAccess() { - // Exit test if ACL module could not be enabled. - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Restrict access to this content type. - // Enable per node access control. - $accessPermissions = [ - 'view[anonymous]' => FALSE, - 'view[authenticated]' => FALSE, - 'per_node' => TRUE, - ]; - $this->changeAccessContentType($accessPermissions); - - // Allow access for test user. - $edit = [ - 'acl[view][add]' => $this->testUser->getAccountName(), - ]; - $this->drupalPostForm('node/' . $this->node1->id() . '/access', $edit, $this->t('edit-acl-view-add-button')); - $this->drupalPostForm(NULL, [], $this->t('Submit')); - - // Logout admin, try to access the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view access should be allowed now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Login admin and disable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(FALSE); - - // Logout admin, try to access the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view access should be denied now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - } - - /** - * Test Editing accessibility with permissions for single users. - */ - public function testEditAccess() { - // Exit test if ACL module could not be enabled. - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Enable per node access control. - $this->changeAccessPerNode(); - - // Allow edit access for test user. - $edit = [ - 'acl[update][add]' => $this->testUser->getAccountName(), - ]; - $this->drupalPostForm('node/' . $this->node1->id() . '/access', $edit, $this->t('edit-acl-update-add-button')); - $this->drupalPostForm(NULL, [], $this->t('Submit')); - - // Logout admin, try to edit the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, edit access should be allowed now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Login admin and disable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(FALSE); - - // Logout admin, try to edit the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, edit access should be denied now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - } - - /** - * Test Deleting accessibility with permissions for single users. - */ - public function testDeleteAccess() { - // Exit test if ACL module could not be enabled. - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Enable per node access control. - $this->changeAccessPerNode(); - - // Allow delete access for test user. - $edit = [ - 'acl[delete][add]' => $this->testUser->getAccountName(), - ]; - $this->drupalPostForm('node/' . $this->node1->id() . '/access', $edit, $this->t('edit-acl-delete-add-button')); - $this->drupalPostForm(NULL, [], $this->t('Submit')); - - // Logout admin, try to delete the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, delete access should be allowed now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Login admin and disable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(FALSE); - - // Logout admin, try to delete the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, delete access should be denied now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - } - -} diff --git a/web/modules/content_access/tests/src/Functional/ContentAccessModuleTest.php b/web/modules/content_access/tests/src/Functional/ContentAccessModuleTest.php deleted file mode 100644 index 0e5e781b2df9f01ec29dcfe6a3ab6621c84b1e11..0000000000000000000000000000000000000000 --- a/web/modules/content_access/tests/src/Functional/ContentAccessModuleTest.php +++ /dev/null @@ -1,409 +0,0 @@ -<?php - -namespace Drupal\Tests\content_access\Functional; - -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Tests\BrowserTestBase; - -/** - * Automated BrowserTest Case for content access module. - * - * @group Access - */ -class ContentAccessModuleTest extends BrowserTestBase { - use ContentAccessTestHelperTrait; - use StringTranslationTrait; - - /** - * Modules to enable. - * - * @var array - */ - public static $modules = ['content_access']; - - /** - * A user with permission to non administer. - * - * @var \Drupal\user\Entity\User - */ - protected $testUser; - - /** - * A user with permission to administer. - * - * @var \Drupal\user\Entity\User - */ - protected $adminUser; - - /** - * Content type for test. - * - * @var \Drupal\node\Entity\NodeType - */ - protected $contentType; - - /** - * Node object to perform test. - * - * @var \Drupal\node\Entity\Node - */ - protected $node1; - - /** - * Node object to perform test. - * - * @var \Drupal\node\Entity\Node - */ - protected $node2; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'classy'; - - /** - * {@inheritdoc} - */ - public function setUp() { - parent::setUp(); - - // Create test user with separate role. - $this->testUser = $this->drupalCreateUser(); - - // Create admin user. - $this->adminUser = $this->drupalCreateUser([ - 'access content', - 'administer content types', - 'grant content access', - 'grant own content access', - 'bypass node access', - 'access administration pages', - ]); - $this->drupalLogin($this->adminUser); - - // Rebuild content access permissions. - node_access_rebuild(); - - // Create test content type. - $this->contentType = $this->drupalCreateContentType(); - - // Create test nodes. - $this->node1 = $this->drupalCreateNode(['type' => $this->contentType->id()]); - $this->node2 = $this->drupalCreateNode(['type' => $this->contentType->id()]); - } - - /** - * Test for viewing nodes. - */ - public function testViewAccess() { - // Restrict access to the content type. - $accessPermissions = [ - 'view[anonymous]' => FALSE, - 'view[authenticated]' => FALSE, - ]; - $this->changeAccessContentType($accessPermissions); - - // Logout admin and try to access the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view node, access must be denied. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login admin and grant access for viewing to the test user. - $this->drupalLogin($this->adminUser); - $this->changeAccessContentTypeKeyword('view'); - - // Logout admin and try to access the node anonymously - // access must be denied again. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view node, access must be granted. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Login admin and enable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(); - - // Restrict access on node2 for the test user role. - $this->changeAccessNodeKeyword($this->node2, 'view', FALSE); - - // Logout admin and try to access both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view node1, access must be granted. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // View node2, access must be denied. - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login admin, swap permissions between content type and node2. - $this->drupalLogin($this->adminUser); - - // Restrict access to content type. - $this->changeAccessContentTypeKeyword('view', FALSE); - - // Grant access to node2. - $this->changeAccessNodeKeyword($this->node2, 'view'); - - // Logout admin and try to access both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view node1, access must be denied. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // View node2, access must be granted. - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - } - - /** - * Test for editing nodes. - */ - public function testEditAccess() { - // Logout admin and try to edit the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, edit node, access must be denied. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login admin and grant access for editing to the test user. - $this->drupalLogin($this->adminUser); - $this->changeAccessContentTypeKeyword('update'); - - // Logout admin and try to edit the node anonymously - // access must be denied again. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, edit node, access must be granted. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Login admin and enable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(); - - // Restrict access for this content type for the test user. - $this->changeAccessContentTypeKeyword('update', FALSE); - - // Allow acces for node1 only. - $this->changeAccessNodeKeyword($this->node1, 'update'); - $this->changeAccessNodeKeyword($this->node2, 'update', FALSE); - - // Logout admin and try to edit both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, edit node1, access must be granted. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Edit node2, access must be denied. - $this->drupalGet('node/' . $this->node2->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login admin, swap permissions between node1 and node2. - $this->drupalLogin($this->adminUser); - - // Grant edit access to node2. - $this->changeAccessNodeKeyword($this->node2, 'update'); - // Restrict edit access to node1. - $this->changeAccessNodeKeyword($this->node1, 'update', FALSE); - - // Logout admin and try to edit both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, edit node1, access must be denied. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Edit node2, access must be granted. - $this->drupalGet('node/' . $this->node2->id() . '/edit'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - } - - /** - * Test for deleting nodes. - */ - public function testDeleteAccess() { - // Logout admin and try to delete the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, delete node, access must be denied. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login admin and grant access for deleting to the test user. - $this->drupalLogin($this->adminUser); - - $this->changeAccessContentTypeKeyword('delete'); - - // Logout admin and try to edit the node anonymously - // access must be denied again. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, delete node, access must be granted. - $this->drupalLogin($this->testUser); - $this->drupalPostForm( - 'node/' . $this->node1->id() . '/delete', - [], - 'Delete' - ); - $this->assertRaw( - $this->t('%node has been deleted', ['%node' => $this->node1->getTitle()]), - 'Test node was deleted successfully by test user' - ); - - // Login admin and recreate test node1. - $this->drupalLogin($this->adminUser); - $this->node1 = $this->drupalCreateNode( - ['type' => $this->contentType->id()] - ); - - // Enable per node access. - $this->changeAccessPerNode(); - - // Restrict access for this content type for the test user. - $this->changeAccessContentTypeKeyword('delete', FALSE); - - // Allow acces for node1 only. - $this->changeAccessNodeKeyword($this->node1, 'delete'); - $this->changeAccessNodeKeyword($this->node2, 'delete', FALSE); - - // Logout admin and try to delete both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, delete node1, access must be granted. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Delete node2, access must be denied. - $this->drupalGet('node/' . $this->node2->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login admin, swap permissions between node1 and node2. - $this->drupalLogin($this->adminUser); - - // Grant delete access to node2. - $this->changeAccessNodeKeyword($this->node2, 'delete'); - // Restrict delete acces to node1. - $this->changeAccessNodeKeyword($this->node1, 'delete', FALSE); - - // Logout admin and try to delete both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, delete node1, access must be denied. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Delete node2, access must be granted. - $this->drupalGet('node/' . $this->node2->id() . '/delete'); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - } - - /** - * Test own view access. - */ - public function testOwnViewAccess() { - // Setup 2 test users. - $testUser1 = $this->testUser; - $testUser2 = $this->drupalCreateUser(); - - // Change ownership of test nodes to test users. - $this->node1->setOwner($testUser1); - $this->node1->save(); - - $this->node2->setOwner($testUser2); - $this->node2->save(); - - // Remove all view permissions for this content type. - $accessPermissions = [ - 'view[anonymous]' => FALSE, - 'view[authenticated]' => FALSE, - 'view_own[anonymous]' => FALSE, - 'view_own[authenticated]' => FALSE, - ]; - $this->changeAccessContentType($accessPermissions); - - // Allow view own content for test user 1 and 2 roles. - $this->changeAccessContentTypeKeyword('view_own', TRUE, $testUser1); - $this->changeAccessContentTypeKeyword('view_own', TRUE, $testUser2); - - // Logout admin and try to access both nodes anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user 1, view node1, access must be granted. - $this->drupalLogin($testUser1); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // View node2, access must be denied. - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user 2, view node1, access must be denied. - $this->drupalLogin($testUser2); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // View node2, access must be granted. - $this->drupalGet('node/' . $this->node2->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - } - -} diff --git a/web/modules/content_access/tests/src/Functional/ContentAccessTestHelperTrait.php b/web/modules/content_access/tests/src/Functional/ContentAccessTestHelperTrait.php deleted file mode 100644 index 4a9939bf445a71b8b5a43ffda9101c24269c1999..0000000000000000000000000000000000000000 --- a/web/modules/content_access/tests/src/Functional/ContentAccessTestHelperTrait.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -namespace Drupal\Tests\content_access\Functional; - -use Drupal\Core\Session\AccountInterface; -use Drupal\node\NodeInterface; -use Drupal\user\Entity\Role; - -/** - * Helper class with auxiliary functions for content access module tests. - */ -trait ContentAccessTestHelperTrait { - - /** - * Role ID for authenticated users. - * - * @var string - */ - protected $rid = AccountInterface::AUTHENTICATED_ROLE; - - /** - * Change access permissions for a content type. - */ - public function changeAccessContentType($accessSettings) { - $this->drupalPostForm( - 'admin/structure/types/manage/' . $this->contentType->id() . '/access', - $accessSettings, - t('Submit') - ); - // Both these may be printed: - // 'Permissions have been changed' || 'No change' => 'change'. - $this->assertSession()->pageTextContains(t('change')); - } - - /** - * Access keyword for content type. - * - * Change access permissions for a content type by a given keyword for the - * role of the user. - */ - public function changeAccessContentTypeKeyword($keyword, $access = TRUE, AccountInterface $user = NULL) { - $roles = []; - - if ($user === NULL) { - $role = Role::load($this->rid); - $roles[$role->id()] = $role->id(); - } - else { - $userRoles = $user->getRoles(); - foreach ($userRoles as $role) { - $roles[$role] = $role; - break; - } - } - - $accessSettings = [ - $keyword . '[' . key($roles) . ']' => $access, - ]; - - $this->changeAccessContentType($accessSettings); - } - - /** - * Change the per node access setting for a content type. - */ - public function changeAccessPerNode($access = TRUE) { - $accessPermissions = [ - 'per_node' => $access, - ]; - $this->changeAccessContentType($accessPermissions); - } - - /** - * Access keyword for node. - * - * Change access permissions for a node by a given keyword (view, update - * or delete). - */ - public function changeAccessNodeKeyword(NodeInterface $node, $keyword, $access = TRUE) { - $user = $this->testUser; - $userRoles = $user->getRoles(); - foreach ($userRoles as $rid) { - $role = Role::load($rid); - $roles[$role->id()] = $role->get('label'); - } - - $accessSettings = [ - $keyword . '[' . key($roles) . ']' => $access, - ]; - - $this->changeAccessNode($node, $accessSettings); - } - - /** - * Change access permission for a node. - */ - public function changeAccessNode(NodeInterface $node, $accessSettings) { - $this->drupalPostForm('node/' . $node->id() . '/access', $accessSettings, t('Submit')); - $this->assertSession()->pageTextContains(t('Your changes have been saved.')); - } - -} diff --git a/web/modules/content_access/tests/src/Functional/ContentAccessTinyTest.php b/web/modules/content_access/tests/src/Functional/ContentAccessTinyTest.php deleted file mode 100644 index 0ed48d170252741ce3691f7f01a7de1f54a1b76e..0000000000000000000000000000000000000000 --- a/web/modules/content_access/tests/src/Functional/ContentAccessTinyTest.php +++ /dev/null @@ -1,250 +0,0 @@ -<?php - -namespace Drupal\Tests\content_access\Functional; - -use Drupal\Core\Session\AccountInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Tests\BrowserTestBase; - -/** - * Automated BrowserTest Case for having a tiny test to run fast. - * - * @group Access - */ -class ContentAccessTinyTest extends BrowserTestBase { - use ContentAccessTestHelperTrait; - use StringTranslationTrait; - - /** - * Modules to enable. - * - * @var array - */ - public static $modules = ['content_access', 'acl']; - - /** - * A user with permission to non administer. - * - * @var \Drupal\user\Entity\User - */ - protected $testUser; - - /** - * A user with permission to administer. - * - * @var \Drupal\user\Entity\User - */ - protected $adminUser; - - /** - * Content type for test. - * - * @var \Drupal\node\Entity\NodeType - */ - protected $contentType; - - /** - * Node object to perform test. - * - * @var \Drupal\node\Entity\Node - */ - protected $node1; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'classy'; - - /** - * Setup configuration before each test. - */ - protected function setUp() { - parent::setUp(); - - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Create test user with separate role. - $this->testUser = $this->drupalCreateUser(); - - // Get the value of the new role. - // @see drupalCreateUser(). - $testUserRoles = $this->testUser->getRoles(); - foreach ($testUserRoles as $role) { - if (!in_array($role, [AccountInterface::AUTHENTICATED_ROLE])) { - $this->rid = $role; - break; - } - } - - // Create admin user. - $this->adminUser = $this->drupalCreateUser([ - 'access content', - 'administer content types', - 'grant content access', - 'grant own content access', - 'bypass node access', - 'access administration pages', - ]); - $this->drupalLogin($this->adminUser); - - // Rebuild content access permissions. - node_access_rebuild(); - - // Create test content type. - $this->contentType = $this->drupalCreateContentType(); - - // Create test node. - $this->node1 = $this->drupalCreateNode(['type' => $this->contentType->id()]); - } - - /** - * Test Viewing accessibility with permissions for single users. - */ - public function testViewAccess() { - // Exit test if ACL module could not be enabled. - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Restrict access to this content type. - // Enable per node access control. - $accessPermissions = [ - 'view[anonymous]' => FALSE, - 'view[authenticated]' => FALSE, - 'per_node' => TRUE, - ]; - $this->changeAccessContentType($accessPermissions); - - // Allow access for test user. - $edit = [ - 'acl[view][add]' => $this->testUser->getAccountName(), - ]; - $this->drupalPostForm('node/' . $this->node1->id() . '/access', $edit, $this->t('Add User')); - $this->drupalPostForm(NULL, [], $this->t('Submit')); - - // Logout admin, try to access the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view access should be allowed now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextNotContains($this->t('Access denied')); - - // Login admin and disable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(FALSE); - - // Logout admin, try to access the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - - // Login test user, view access should be denied now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id()); - $this->assertSession()->pageTextContains($this->t('Access denied')); - } - - /* - * Test Editing accessibility with permissions for single users. - */ - /* - public function testEditAccess() { - // Exit test if ACL module could not be enabled. - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Enable per node access control. - $this->changeAccessPerNode(); - - // Allow edit access for test user. - $edit = [ - 'acl[update][add]' => $this->testUser->getAccountName(), - ]; - $this->drupalPostForm('node/' . $this->node1->id() . '/access', $edit, - t('Add User')); - $this->drupalPostForm(NULL, [], t('Submit')); - - // Logout admin, try to edit the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains(t('Access denied')); - - // Login test user, edit access should be allowed now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextNotContains(t('Access denied')); - - // Login admin and disable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(FALSE); - - // Logout admin, try to edit the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains(t('Access denied')); - - // Login test user, edit access should be denied now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/edit'); - $this->assertSession()->pageTextContains(t('Access denied')); - } - */ - - /* - * Test Deleting accessibility with permissions for single users. - */ - /* - public function testDeleteAccess() { - // Exit test if ACL module could not be enabled. - if (!\Drupal::moduleHandler()->moduleExists('acl')) { - $this->pass('No ACL module present, skipping test'); - return; - } - - // Enable per node access control. - $this->changeAccessPerNode(); - - // Allow delete access for test user. - $edit = [ - 'acl[delete][add]' => $this->testUser->getAccountName(), - ]; - $this->drupalPostForm('node/' . $this->node1->id() . '/access', $edit, - t('Add User')); - $this->drupalPostForm(NULL, [], t('Submit')); - - // Logout admin, try to delete the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains(t('Access denied')); - - // Login test user, delete access should be allowed now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextNotContains(t('Access denied')); - - // Login admin and disable per node access. - $this->drupalLogin($this->adminUser); - $this->changeAccessPerNode(FALSE); - - // Logout admin, try to delete the node anonymously. - $this->drupalLogout(); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains(t('Access denied')); - - // Login test user, delete access should be denied now. - $this->drupalLogin($this->testUser); - $this->drupalGet('node/' . $this->node1->id() . '/delete'); - $this->assertSession()->pageTextContains(t('Access denied')); - } - */ - -}