Skip to content

Commit 6087cf8

Browse files
committed
Use 'modpanel' perms to display admin panel menu
1 parent 6c49943 commit 6087cf8

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

featherbb/Controller/Admin/Bans.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct()
2222
translate('admin/bans');
2323
translate('admin/common');
2424

25-
if (!User::can('mod.bans')) {
25+
if (!User::can('modpanel.bans') || !User::can('mod.ban_users')) {
2626
throw new Error(__('No permission'), '403');
2727
}
2828
}

featherbb/Controller/Admin/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Index
1919
public function __construct()
2020
{
2121
translate('admin/index');
22-
if (!User::can('mod.view')) {
22+
if (!User::can('modpanel.index')) {
2323
throw new Error(__('No permission'), '403');
2424
}
2525
}

featherbb/Controller/Admin/Reports.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
use FeatherBB\Core\AdminUtils;
1313
use FeatherBB\Core\Url;
1414
use FeatherBB\Core\Utils;
15+
use FeatherBB\Core\Error;
1516

1617
class Reports
1718
{
1819
public function __construct()
1920
{
2021
$this->model = new \FeatherBB\Model\Admin\Reports();
2122
translate('admin/reports');
22-
if (!User::can('mod.reports')) {
23+
if (!User::can('modpanel.reports')) {
2324
throw new Error(__('No permission'), '403');
2425
}
2526
}

featherbb/Controller/Admin/Users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct()
2020
{
2121
$this->model = new \FeatherBB\Model\Admin\Users();
2222
translate('admin/users');
23-
if (!User::can('mod.users')) {
23+
if (!User::can('modpanel.users')) {
2424
throw new Error(__('No permission'), '403');
2525
}
2626
}

featherbb/Controller/Install.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,13 @@ public function create_db(array $data)
207207
}
208208

209209
// Init permissions
210-
Container::get('perms')->addParent(4, 3);
210+
Container::get('perms')->addParent(4, array(3));
211211
Container::get('perms')->addParent(2, array(3,4));
212212
Container::get('perms')->addParent(1, array(2,3,4));
213+
213214
Container::get('perms')->allowGroup(3, array('board.read', 'users.view', 'search.topics', 'search.users'));
214215
Container::get('perms')->allowGroup(4, array('topic.reply', 'topic.post', 'topic.delete', 'post.delete', 'post.edit', 'email.send'));
215-
Container::get('perms')->allowGroup(2, array('mod.*', 'board.title.set'));
216+
Container::get('perms')->allowGroup(2, array('modpanel.*', 'mod.is_mod', 'mod.edit_users', 'mod.rename_users', 'mod.change_passwords', 'mod.promote_users', 'mod.ban_users', 'board.title.set'));
216217
Container::get('perms')->allowGroup(1, array('board.*'));
217218
// Init preferences
218219
Container::get('prefs')->set(array(

featherbb/Core/AdminUtils.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ public static function get_content($url)
115115
protected static function load_default_menu()
116116
{
117117
return array(
118-
'mod.index' => array('title' => 'Index', 'url' => 'adminIndex'),
119-
'mod.users' => array('title' => 'Users', 'url' => 'adminUsers'),
120-
'mod.bans' => array('title' => 'Bans', 'url' => 'adminBans'),
121-
'mod.reports' => array('title' => 'Reports', 'url' => 'adminReports'),
118+
'modpanel.index' => array('title' => 'Index', 'url' => 'adminIndex'),
119+
'modpanel.users' => array('title' => 'Users', 'url' => 'adminUsers'),
120+
'modpanel.bans' => array('title' => 'Bans', 'url' => 'adminBans'),
121+
'modpanel.reports' => array('title' => 'Reports', 'url' => 'adminReports'),
122122
'board.options' => array('title' => 'Options', 'url' => 'adminOptions'),
123123
'board.permissions' => array('title' => 'Permissions', 'url' => 'adminPermissions'),
124124
'board.categories' => array('title' => 'Categories', 'url' => 'adminCategories'),

featherbb/View/admin/menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<div class="inbox">
2424
<ul>
2525
<?php foreach ($menu_items as $perm => $data) {
26-
if (preg_match('/^mod\..*$/', $perm)) {
26+
if (preg_match('/^modpanel\..*$/', $perm)) {
2727
if (User::can($perm)) {
2828
// ForumSettings::get('o_report_method') == '0' || ForumSettings::get('o_report_method') == '2')
2929
echo "\t\t\t\t\t\t\t\t".'<li'.($page == strtolower($data['title']) ? ' class="isactive"' : '').'><a href="'.Router::pathFor($data['url']).'">'.__($data['title']).'</a></li>'."\n";

0 commit comments

Comments
 (0)