Skip to content

Commit

Permalink
Merge pull request #400 from niektenhoopen/v4
Browse files Browse the repository at this point in the history
Bugfix permission settings #399 and Graphql #401
  • Loading branch information
Tam authored May 18, 2022
2 parents adf052d + 29d222a commit d97b130
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
32 changes: 14 additions & 18 deletions src/Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 3 additions & 1 deletion src/gql/SeoSocialData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit d97b130

Please sign in to comment.