Issues (41)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

code/SiteConfig.php (19 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace SilverStripe\SiteConfig;
4
5
use SilverStripe\CMS\Model\SiteTree;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\FormAction;
8
use SilverStripe\Forms\HiddenField;
9
use SilverStripe\Forms\ListboxField;
10
use SilverStripe\Forms\LiteralField;
11
use SilverStripe\Forms\OptionsetField;
12
use SilverStripe\Forms\Tab;
13
use SilverStripe\Forms\TabSet;
14
use SilverStripe\Forms\TextField;
15
use SilverStripe\ORM\DB;
16
use SilverStripe\ORM\DataObject;
17
use SilverStripe\ORM\ManyManyList;
18
use SilverStripe\Security\Group;
19
use SilverStripe\Security\Member;
20
use SilverStripe\Security\Permission;
21
use SilverStripe\Security\PermissionProvider;
22
use SilverStripe\Security\Security;
23
use SilverStripe\View\TemplateGlobalProvider;
24
use SilverStripe\CMS\Controllers\CMSMain;
25
26
/**
27
 * SiteConfig
28
 *
29
 * @property string Title Title of the website.
30
 * @property string Tagline Tagline of the website.
31
 * @property string CanViewType Type of restriction used for view permissions.
32
 * @property string CanEditType Type of restriction used for edit permissions.
33
 * @property string CanCreateTopLevelType Type of restriction used for creation of root-level pages.
34
 * @method ManyManyList ViewerGroups() List of groups that can view SiteConfig.
35
 * @method ManyManyList EditorGroups() List of groups that can edit SiteConfig.
36
 * @method ManyManyList CreateTopLevelGroups() List of groups that can create root-level pages.
37
 */
38
class SiteConfig extends DataObject implements PermissionProvider, TemplateGlobalProvider
39
{
40
    private static $db = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
41
        "Title" => "Varchar(255)",
42
        "Tagline" => "Varchar(255)",
43
        "CanViewType" => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers', 'Anyone')",
44
        "CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
45
        "CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
46
    ];
47
48
    private static $many_many = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $many_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
49
        "ViewerGroups" => Group::class,
50
        "EditorGroups" => Group::class,
51
        "CreateTopLevelGroups" => Group::class,
52
    ];
53
54
    private static $defaults = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $defaults is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
55
        "CanViewType" => "Anyone",
56
        "CanEditType" => "LoggedInUsers",
57
        "CanCreateTopLevelType" => "LoggedInUsers",
58
    ];
59
60
    private static $table_name = 'SiteConfig';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $table_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
61
62
    /**
63
     * Default permission to check for 'LoggedInUsers' to create or edit pages
64
     *
65
     * @var array
66
     * @config
67
     */
68
    private static $required_permission = [
0 ignored issues
show
The property $required_permission is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
69
        'CMS_ACCESS_CMSMain',
70
        'CMS_ACCESS_LeftAndMain'
71
    ];
72
73
    public function populateDefaults()
74
    {
75
        $this->Title = _t(self::class . '.SITENAMEDEFAULT', "Your Site Name");
76
        $this->Tagline = _t(self::class . '.TAGLINEDEFAULT', "your tagline here");
77
78
        // Allow these defaults to be overridden
79
        parent::populateDefaults();
80
    }
81
82
    /**
83
     * Get the fields that are sent to the CMS.
84
     *
85
     * In your extensions: updateCMSFields($fields).
86
     *
87
     * @return FieldList
88
     */
89
    public function getCMSFields()
90
    {
91
        $mapFn = function ($groups = []) {
92
            $map = [];
93
            foreach ($groups as $group) {
94
                // Listboxfield values are escaped, use ASCII char instead of &raquo;
95
                $map[$group->ID] = $group->getBreadcrumbs(' > ');
96
            }
97
            asort($map);
98
            return $map;
99
        };
100
        $groupsMap = $mapFn(Group::get());
101
        $viewAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_VIEW_ALL', 'ADMIN']));
102
        $editAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_EDIT_ALL', 'ADMIN']));
103
104
        $fields = new FieldList(
105
            new TabSet(
106
                "Root",
107
                $tabMain = new Tab(
108
                    'Main',
109
                    $titleField = new TextField("Title", _t(self::class . '.SITETITLE', "Site title")),
110
                    $taglineField = new TextField("Tagline", _t(self::class . '.SITETAGLINE', "Site Tagline/Slogan"))
111
                ),
112
                $tabAccess = new Tab(
113
                    'Access',
114
                    $viewersOptionsField = new OptionsetField(
115
                        "CanViewType",
116
                        _t(self::class . '.VIEWHEADER', "Who can view pages on this site?")
117
                    ),
118
                    $viewerGroupsField = ListboxField::create(
119
                        "ViewerGroups",
120
                        _t(SiteTree::class . '.VIEWERGROUPS', "Viewer Groups")
121
                    )
122
                        ->setSource($groupsMap)
123
                        ->setAttribute(
124
                            'data-placeholder',
125
                            _t(SiteTree::class . '.GroupPlaceholder', 'Click to select group')
126
                        ),
127
                    $editorsOptionsField = new OptionsetField(
128
                        "CanEditType",
129
                        _t(self::class . '.EDITHEADER', "Who can edit pages on this site?")
130
                    ),
131
                    $editorGroupsField = ListboxField::create(
132
                        "EditorGroups",
133
                        _t(SiteTree::class . '.EDITORGROUPS', "Editor Groups")
134
                    )
135
                        ->setSource($groupsMap)
136
                        ->setAttribute(
137
                            'data-placeholder',
138
                            _t(SiteTree::class . '.GroupPlaceholder', 'Click to select group')
139
                        ),
140
                    $topLevelCreatorsOptionsField = new OptionsetField(
141
                        "CanCreateTopLevelType",
142
                        _t(self::class . '.TOPLEVELCREATE', "Who can create pages in the root of the site?")
143
                    ),
144
                    $topLevelCreatorsGroupsField = ListboxField::create(
145
                        "CreateTopLevelGroups",
146
                        _t(self::class . '.TOPLEVELCREATORGROUPS', "Top level creators")
147
                    )
148
                        ->setSource($groupsMap)
149
                        ->setAttribute(
150
                            'data-placeholder',
151
                            _t(SiteTree::class . '.GroupPlaceholder', 'Click to select group')
152
                        )
153
                )
154
            ),
155
            new HiddenField('ID')
156
        );
157
158
        $viewersOptionsSource = [];
159
        $viewersOptionsSource["Anyone"] = _t(SiteTree::class . '.ACCESSANYONE', "Anyone");
160
        $viewersOptionsSource["LoggedInUsers"] = _t(
161
            SiteTree::class . '.ACCESSLOGGEDIN',
162
            "Logged-in users"
163
        );
164
        $viewersOptionsSource["OnlyTheseUsers"] = _t(
165
            SiteTree::class . '.ACCESSONLYTHESE',
166
            "Only these groups (choose from list)"
167
        );
168
        $viewersOptionsField->setSource($viewersOptionsSource);
169
170 View Code Duplication
        if ($viewAllGroupsMap) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
171
            $viewerGroupsField->setDescription(_t(
172
                SiteTree::class . '.VIEWER_GROUPS_FIELD_DESC',
173
                'Groups with global view permissions: {groupList}',
174
                ['groupList' => implode(', ', array_values($viewAllGroupsMap))]
175
            ));
176
        }
177
178 View Code Duplication
        if ($editAllGroupsMap) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
179
            $editorGroupsField->setDescription(_t(
180
                SiteTree::class . '.EDITOR_GROUPS_FIELD_DESC',
181
                'Groups with global edit permissions: {groupList}',
182
                ['groupList' => implode(', ', array_values($editAllGroupsMap))]
183
            ));
184
        }
185
186
        $editorsOptionsSource = [];
187
        $editorsOptionsSource["LoggedInUsers"] = _t(
188
            SiteTree::class . '.EDITANYONE',
189
            "Anyone who can log-in to the CMS"
190
        );
191
        $editorsOptionsSource["OnlyTheseUsers"] = _t(
192
            SiteTree::class . '.EDITONLYTHESE',
193
            "Only these groups (choose from list)"
194
        );
195
        $editorsOptionsField->setSource($editorsOptionsSource);
196
197
        $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
198
199
        if (!Permission::check('EDIT_SITECONFIG')) {
200
            $fields->makeFieldReadonly($viewersOptionsField);
201
            $fields->makeFieldReadonly($viewerGroupsField);
202
            $fields->makeFieldReadonly($editorsOptionsField);
203
            $fields->makeFieldReadonly($editorGroupsField);
204
            $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
205
            $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
206
            $fields->makeFieldReadonly($taglineField);
207
            $fields->makeFieldReadonly($titleField);
208
        }
209
210
        if (file_exists(BASE_PATH . '/install.php')) {
211
            $fields->addFieldToTab(
212
                "Root.Main",
213
                new LiteralField(
214
                    "InstallWarningHeader",
215
                    "<p class=\"message warning\">" . _t(
216
                        SiteTree::class . 'REMOVE_INSTALL_WARNING',
217
                        'Warning: You should remove install.php from this SilverStripe install for security reasons.'
218
                    ) . "</p>"
219
                ),
220
                "Title"
221
            );
222
        }
223
224
        $tabMain->setTitle(_t(self::class . '.TABMAIN', "Main"));
225
        $tabAccess->setTitle(_t(self::class . '.TABACCESS', "Access"));
226
        $this->extend('updateCMSFields', $fields);
227
228
        return $fields;
229
    }
230
231
    /**
232
     * Get the actions that are sent to the CMS.
233
     *
234
     * In your extensions: updateEditFormActions($actions)
235
     *
236
     * @return FieldList
237
     */
238
    public function getCMSActions()
239
    {
240
        if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) {
241
            $actions = new FieldList(
242
                FormAction::create(
243
                    'save_siteconfig',
244
                    _t(CMSMain::class . '.SAVE', 'Save')
245
                )->addExtraClass('btn-primary font-icon-save')
246
            );
247
        } else {
248
            $actions = new FieldList();
249
        }
250
251
        $this->extend('updateCMSActions', $actions);
252
253
        return $actions;
254
    }
255
256
    /**
257
     * @return string
258
     */
259
    public function CMSEditLink()
260
    {
261
        return SiteConfigLeftAndMain::singleton()->Link();
262
    }
263
264
    /**
265
     * Get the current sites SiteConfig, and creates a new one through
266
     * {@link make_site_config()} if none is found.
267
     *
268
     * @return SiteConfig
269
     */
270
    public static function current_site_config()
271
    {
272
        /** @var SiteConfig $siteConfig */
273
        $siteConfig = DataObject::get_one(SiteConfig::class);
274
        if ($siteConfig) {
275
            return $siteConfig;
276
        }
277
278
        return self::make_site_config();
279
    }
280
281
    /**
282
     * Setup a default SiteConfig record if none exists.
283
     */
284
    public function requireDefaultRecords()
285
    {
286
        parent::requireDefaultRecords();
287
288
        $config = DataObject::get_one(SiteConfig::class);
289
290
        if (!$config) {
291
            self::make_site_config();
292
293
            DB::alteration_message("Added default site config", "created");
294
        }
295
    }
296
297
    /**
298
     * Create SiteConfig with defaults from language file.
299
     *
300
     * @return SiteConfig
301
     */
302
    public static function make_site_config()
303
    {
304
        $config = SiteConfig::create();
305
        $config->write();
306
307
        return $config;
308
    }
309
310
    /**
311
     * Can a user view this SiteConfig instance?
312
     *
313
     * @param Member $member
314
     * @return boolean
315
     */
316 View Code Duplication
    public function canView($member = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
317
    {
318
        if (!$member) {
319
            $member = Security::getCurrentUser();
320
        }
321
322
        $extended = $this->extendedCan('canView', $member);
0 ignored issues
show
It seems like $member can be null; however, extendedCan() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
323
        if ($extended !== null) {
324
            return $extended;
325
        }
326
327
        // Assuming all that can edit this object can also view it
328
        return $this->canEdit($member);
329
    }
330
331
    /**
332
     * Can a user view pages on this site? This method is only
333
     * called if a page is set to Inherit, but there is nothing
334
     * to inherit from.
335
     *
336
     * @param Member $member
337
     * @return boolean
338
     */
339
    public function canViewPages($member = null)
340
    {
341
        if (!$member) {
342
            $member = Security::getCurrentUser();
343
        }
344
345
        if ($member && Permission::checkMember($member, "ADMIN")) {
346
            return true;
347
        }
348
349
        $extended = $this->extendedCan('canViewPages', $member);
0 ignored issues
show
It seems like $member can be null; however, extendedCan() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
350
        if ($extended !== null) {
351
            return $extended;
352
        }
353
354
        if (!$this->CanViewType || $this->CanViewType == 'Anyone') {
355
            return true;
356
        }
357
358
        // check for any logged-in users
359
        if ($this->CanViewType === 'LoggedInUsers' && $member) {
360
            return true;
361
        }
362
363
        // check for specific groups
364
        if ($this->CanViewType === 'OnlyTheseUsers' && $member && $member->inGroups($this->ViewerGroups())) {
365
            return true;
366
        }
367
368
        return false;
369
    }
370
371
    /**
372
     * Can a user edit pages on this site? This method is only
373
     * called if a page is set to Inherit, but there is nothing
374
     * to inherit from, or on new records without a parent.
375
     *
376
     * @param Member $member
377
     * @return boolean
378
     */
379 View Code Duplication
    public function canEditPages($member = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
380
    {
381
        if (!$member) {
382
            $member = Security::getCurrentUser();
383
        }
384
385
        if ($member && Permission::checkMember($member, "ADMIN")) {
386
            return true;
387
        }
388
389
        $extended = $this->extendedCan('canEditPages', $member);
0 ignored issues
show
It seems like $member can be null; however, extendedCan() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
390
        if ($extended !== null) {
391
            return $extended;
392
        }
393
394
        // check for any logged-in users with CMS access
395
        if ($this->CanEditType === 'LoggedInUsers'
396
            && Permission::checkMember($member, $this->config()->get('required_permission'))
397
        ) {
398
            return true;
399
        }
400
401
            // check for specific groups
402
        if ($this->CanEditType === 'OnlyTheseUsers' && $member && $member->inGroups($this->EditorGroups())) {
403
            return true;
404
        }
405
406
        return false;
407
    }
408
409 View Code Duplication
    public function canEdit($member = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
410
    {
411
        if (!$member) {
412
            $member = Security::getCurrentUser();
413
        }
414
415
        $extended = $this->extendedCan('canEdit', $member);
416
        if ($extended !== null) {
417
            return $extended;
418
        }
419
420
        return Permission::checkMember($member, "EDIT_SITECONFIG");
421
    }
422
423
    /**
424
     * @return array
425
     */
426
    public function providePermissions()
427
    {
428
        return [
429
            'EDIT_SITECONFIG' => [
430
                'name' => _t(self::class . '.EDIT_PERMISSION', 'Manage site configuration'),
431
                'category' => _t(Permission::class . '.PERMISSIONS_CATEGORY', 'Roles and access permissions'),
432
                'help' => _t(
433
                    self::class . '.EDIT_PERMISSION_HELP',
434
                    'Ability to edit global access settings/top-level page permissions.'
435
                ),
436
                'sort' => 400
437
            ]
438
        ];
439
    }
440
441
    /**
442
     * Can a user create pages in the root of this site?
443
     *
444
     * @param Member $member
445
     * @return boolean
446
     */
447 View Code Duplication
    public function canCreateTopLevel($member = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448
    {
449
        if (!$member) {
450
            $member = Security::getCurrentUser();
451
        }
452
453
        if ($member && Permission::checkMember($member, "ADMIN")) {
454
            return true;
455
        }
456
457
        $extended = $this->extendedCan('canCreateTopLevel', $member);
0 ignored issues
show
It seems like $member can be null; however, extendedCan() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
458
        if ($extended !== null) {
459
            return $extended;
460
        }
461
462
        // check for any logged-in users with CMS permission
463
        if ($this->CanCreateTopLevelType === 'LoggedInUsers'
464
            && Permission::checkMember($member, $this->config()->get('required_permission'))
465
        ) {
466
            return true;
467
        }
468
469
        // check for specific groups
470
        if ($this->CanCreateTopLevelType === 'OnlyTheseUsers'
471
            && $member
472
            && $member->inGroups($this->CreateTopLevelGroups())
473
        ) {
474
            return true;
475
        }
476
477
        return false;
478
    }
479
480
    /**
481
     * Add $SiteConfig to all SSViewers
482
     */
483
    public static function get_template_global_variables()
484
    {
485
        return [
486
            'SiteConfig' => 'current_site_config',
487
        ];
488
    }
489
}
490