Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix permission settings #399 and Graphql #401 #400

Merged
merged 2 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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