let system administrators disallow certain admin panels
This commit is contained in:
parent
4f62d685d0
commit
2aa0ab9777
@ -70,7 +70,7 @@ class AdminPanelAction extends Action
|
|||||||
|
|
||||||
if (!common_logged_in()) {
|
if (!common_logged_in()) {
|
||||||
$this->clientError(_('Not logged in.'));
|
$this->clientError(_('Not logged in.'));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
@ -94,7 +94,18 @@ class AdminPanelAction extends Action
|
|||||||
|
|
||||||
if (!$user->hasRight(Right::CONFIGURESITE)) {
|
if (!$user->hasRight(Right::CONFIGURESITE)) {
|
||||||
$this->clientError(_('You cannot make changes to this site.'));
|
$this->clientError(_('You cannot make changes to this site.'));
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This panel must be enabled
|
||||||
|
|
||||||
|
$name = $this->trimmed('action');
|
||||||
|
|
||||||
|
$name = mb_substr($name, 0, -10);
|
||||||
|
|
||||||
|
if (!in_array($name, common_config('admin', 'panels'))) {
|
||||||
|
$this->clientError(_('Changes to that panel are not allowed.'), 403);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -296,20 +307,33 @@ class AdminPanelNav extends Widget
|
|||||||
|
|
||||||
if (Event::handle('StartAdminPanelNav', array($this))) {
|
if (Event::handle('StartAdminPanelNav', array($this))) {
|
||||||
|
|
||||||
|
if ($this->canAdmin('site')) {
|
||||||
$this->out->menuItem(common_local_url('siteadminpanel'), _('Site'),
|
$this->out->menuItem(common_local_url('siteadminpanel'), _('Site'),
|
||||||
_('Basic site configuration'), $action_name == 'siteadminpanel', 'nav_site_admin_panel');
|
_('Basic site configuration'), $action_name == 'siteadminpanel', 'nav_site_admin_panel');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->canAdmin('design')) {
|
||||||
$this->out->menuItem(common_local_url('designadminpanel'), _('Design'),
|
$this->out->menuItem(common_local_url('designadminpanel'), _('Design'),
|
||||||
_('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel');
|
_('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->canAdmin('user')) {
|
||||||
$this->out->menuItem(common_local_url('useradminpanel'), _('User'),
|
$this->out->menuItem(common_local_url('useradminpanel'), _('User'),
|
||||||
_('Paths configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
|
_('Paths configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->canAdmin('paths')) {
|
||||||
$this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
|
$this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
|
||||||
_('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
|
_('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
|
||||||
|
}
|
||||||
|
|
||||||
Event::handle('EndAdminPanelNav', array($this));
|
Event::handle('EndAdminPanelNav', array($this));
|
||||||
}
|
}
|
||||||
$this->action->elementEnd('ul');
|
$this->action->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canAdmin($name)
|
||||||
|
{
|
||||||
|
return in_array($name, common_config('admin', 'panels'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,5 +246,7 @@ $default =
|
|||||||
'Linkback' => null,
|
'Linkback' => null,
|
||||||
'WikiHashtags' => null,
|
'WikiHashtags' => null,
|
||||||
'OpenID' => null),
|
'OpenID' => null),
|
||||||
)
|
),
|
||||||
|
'admin' =>
|
||||||
|
array('panels' => array('design', 'site', 'user', 'paths')),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user