From 570cee4d35b0a8d43b3d1aeaf540c4c276afcb26 Mon Sep 17 00:00:00 2001 From: Niek ten Hoopen Date: Fri, 13 May 2022 18:40:32 +0200 Subject: [PATCH 1/2] Bugfix permission settings #399 --- src/Seo.php | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Seo.php b/src/Seo.php index 03aef16..c21f3a5 100644 --- a/src/Seo.php +++ b/src/Seo.php @@ -198,10 +198,6 @@ public function getCpNavItem (): ?array $subNav['redirects'] = ['label' => 'Redirects', 'url' => 'seo/redirects']; - /*if ($currentUser->getIsAdmin() || $currentUser->checkPermission('manageSchema')) - $subNav['schema'] = - ['label' => 'Schema', 'url' => 'seo/schema'];*/ - if (Craft::$app->getConfig()->general->allowAdminChanges && $currentUser->getIsAdmin()) $subNav['settings'] = ['label' => 'Settings', 'url' => 'seo/settings']; @@ -232,20 +228,20 @@ public function getSettingsResponse(): mixed // Events // ========================================================================= - public function onRegisterPermissions (RegisterUserPermissionsEvent $event): void - { - $event->permissions['SEO'] = [ - 'manageSitemap' => [ - 'label' => Craft::t('seo', 'Manage Sitemap'), - ], - 'manageRedirects' => [ - 'label' => Craft::t('seo', 'Manage Redirects'), - ], -// 'manageSchema' => [ -// 'label' => \Craft::t('seo', 'Manage Schema'), -// ], - ]; - } + public function onRegisterPermissions (RegisterUserPermissionsEvent $event): void + { + $event->permissions[] = [ + 'heading' => 'SEO', + 'permissions' => [ + 'manageSitemap' => [ + 'label' => Craft::t('seo', 'Manage Sitemap'), + ], + 'manageRedirects' => [ + 'label' => Craft::t('seo', 'Manage Redirects'), + ], + ] + ]; + } public function onRegisterCPUrlRules (RegisterUrlRulesEvent $event): void { From 29d222a90d8e4d6bfa9438919270bce8f456f114 Mon Sep 17 00:00:00 2001 From: Niek ten Hoopen Date: Sat, 14 May 2022 15:27:45 +0200 Subject: [PATCH 2/2] Bugfix Graphql: retrieving asset volumes with public URLs fixes #401 --- src/gql/SeoSocialData.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gql/SeoSocialData.php b/src/gql/SeoSocialData.php index 0b25915..ccc513a 100644 --- a/src/gql/SeoSocialData.php +++ b/src/gql/SeoSocialData.php @@ -8,6 +8,7 @@ use craft\gql\GqlEntityRegistry; use craft\gql\interfaces\elements\Asset as AssetInterface; use craft\helpers\Gql; +use craft\models\Volume; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; @@ -53,11 +54,12 @@ public static function getType(): ObjectType /** * Get fields which may only be used depending on the craft Gql config * + * @throws \yii\base\InvalidConfigException */ protected static function getConditionalFields(): array { // Images may be in any public volume, so verify them all. - $volumes = Craft::$app->volumes->getViewableVolumes(); + $volumes = array_filter(Craft::$app->volumes->getAllVolumes(), static fn (Volume $volume) => $volume->getFs()->hasUrls); $awareOfAllPublicVolumes = false; if (!empty($volumes)) {