Skip to content

Commit

Permalink
Fixed #9
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 3, 2017
1 parent d18f847 commit f6a572b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Craft CMS 3.0 Working Changelog
- Fixed some asterisk icons.
- Fixed a bug where it was impossible to upload user photo, site logo or site icon.
- #8: Fixed a bug where it was possible to select multiple default options for Dropdown and Radio Buttons fields.
- #9: Fixed a bug where the “Globals” Control Panel nav item would link to a 404 right after deleting the first global set in Settings → Globals.

## 3.0.0-beta.2 - 2017-02-02

Expand Down
1 change: 1 addition & 0 deletions src/config/cproutes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'entries/<sectionHandle:{handle}>/<entryId:\d+><slug:(?:-{slug})?>/<siteHandle:{handle}>' => 'entries/edit-entry',
'entries/<sectionHandle:{handle}>/<entryId:\d+><slug:(?:-{slug}?)?>/drafts/<draftId:\d+>' => 'entries/edit-entry',
'entries/<sectionHandle:{handle}>/<entryId:\d+><slug:(?:-{slug})?>/versions/<versionId:\d+>' => 'entries/edit-entry',
'globals' => 'globals',
'globals/<globalSetHandle:{handle}>' => 'globals/edit-content',
'globals/<siteHandle:{handle}>/<globalSetHandle:{handle}>' => 'globals/edit-content',
'updates' => 'update/index',
Expand Down
17 changes: 17 additions & 0 deletions src/controllers/GlobalsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ class GlobalsController extends Controller
// Public Methods
// =========================================================================

/**
* Index
*
* @return Response
* @throws ForbiddenHttpException if the user isn't authorized to edit any global sets
*/
public function actionIndex()
{
$editableSets = Craft::$app->getGlobals()->getEditableSets();

if (empty($editableSets)) {
throw new ForbiddenHttpException('User not permitted to edit any global content');
}

return $this->redirect('globals/'.$editableSets[0]->handle);
}

/**
* Saves a global set.
*
Expand Down
6 changes: 2 additions & 4 deletions src/web/twig/variables/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ public function nav(): array
];
}

$globals = Craft::$app->getGlobals()->getEditableSets();

if (!empty($globals)) {
if (!empty(Craft::$app->getGlobals()->getEditableSets())) {
$navItems[] = [
'label' => Craft::t('app', 'Globals'),
'url' => 'globals/'.$globals[0]->handle,
'url' => 'globals',
'icon' => 'globe'
];
}
Expand Down

0 comments on commit f6a572b

Please sign in to comment.