X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fadminpanelaction.php;h=a927e23336f73b80ab78bc0a98aafbf95778e286;hb=9e3e1d3d5632b2f4690018677e2ba82beb399fca;hp=fa3272f8aad9656159e422e03a2bad95239b4ff3;hpb=76b0e6e6f4151235d5032d1aa90f0937b415bd87;p=quix0rs-gnu-social.git diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php index fa3272f8aa..a927e23336 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -69,8 +69,9 @@ class AdminPanelAction extends Action // User must be logged in. if (!common_logged_in()) { + // TRANS: Client error message $this->clientError(_('Not logged in.')); - return; + return false; } $user = common_current_user(); @@ -93,8 +94,21 @@ class AdminPanelAction extends Action // User must have the right to change admin settings if (!$user->hasRight(Right::CONFIGURESITE)) { + // TRANS: Client error message $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 (!self::canAdmin($name)) { + // TRANS: Client error message + $this->clientError(_('Changes to that panel are not allowed.'), 403); + return false; } return true; @@ -123,6 +137,7 @@ class AdminPanelAction extends Action Config::loadSettings(); $this->success = true; + // TRANS: Message after successful saving of administrative settings. $this->msg = _('Settings saved.'); } catch (Exception $e) { $this->success = false; @@ -132,6 +147,21 @@ class AdminPanelAction extends Action $this->showPage(); } + /** + * Show tabset for this page + * + * Uses the AdminPanelNav widget + * + * @return void + * @see AdminPanelNav + */ + + function showLocalNav() + { + $nav = new AdminPanelNav($this); + $nav->show(); + } + /** * Show the content section of the page * @@ -145,6 +175,24 @@ class AdminPanelAction extends Action $this->showForm(); } + /** + * Show content block. Overrided just to add a special class + * to the content div to allow styling. + * + * @return nothing + */ + function showContentBlock() + { + $this->elementStart('div', array('id' => 'content', 'class' => 'admin')); + $this->showPageTitle(); + $this->showPageNoticeBlock(); + $this->elementStart('div', array('id' => 'content_inner')); + // show the actual content (forms, lists, whatever) + $this->showContent(); + $this->elementEnd('div'); + $this->elementEnd('div'); + } + /** * show human-readable instructions for the page, or * a success/failure on save. @@ -177,6 +225,7 @@ class AdminPanelAction extends Action function showForm() { + // TRANS: Client error message $this->clientError(_('showForm() not implemented.')); return; } @@ -206,7 +255,161 @@ class AdminPanelAction extends Action function saveSettings() { + // TRANS: Client error message $this->clientError(_('saveSettings() not implemented.')); return; } + + /** + * Delete a design setting + * + * // XXX: Maybe this should go in Design? --Z + * + * @return mixed $result false if something didn't work + */ + + function deleteSetting($section, $setting) + { + $config = new Config(); + + $config->section = $section; + $config->setting = $setting; + + if ($config->find(true)) { + $result = $config->delete(); + if (!$result) { + common_log_db_error($config, 'DELETE', __FILE__); + // TRANS: Client error message + $this->clientError(_("Unable to delete design setting.")); + return null; + } + } + + return $result; + } + + function canAdmin($name) + { + $isOK = false; + + if (Event::handle('AdminPanelCheck', array($name, &$isOK))) { + $isOK = in_array($name, common_config('admin', 'panels')); + } + + return $isOK; + } +} + +/** + * Menu for public group of actions + * + * @category Output + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see Widget + */ + +class AdminPanelNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + $action_name = $this->action->trimmed('action'); + + $this->action->elementStart('ul', array('class' => 'nav')); + + if (Event::handle('StartAdminPanelNav', array($this))) { + + if (AdminPanelAction::canAdmin('site')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Basic site configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('siteadminpanel'), _m('MENU', 'Site'), + $menu_title, $action_name == 'siteadminpanel', 'nav_site_admin_panel'); + } + + if (AdminPanelAction::canAdmin('design')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Design configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('designadminpanel'), _m('MENU', 'Design'), + $menu_title, $action_name == 'designadminpanel', 'nav_design_admin_panel'); + } + + if (AdminPanelAction::canAdmin('user')) { + // TRANS: Menu item title/tooltip + $menu_title = _('User configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('useradminpanel'), _('User'), + $menu_title, $action_name == 'useradminpanel', 'nav_user_admin_panel'); + } + + if (AdminPanelAction::canAdmin('access')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Access configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('accessadminpanel'), _('Access'), + $menu_title, $action_name == 'accessadminpanel', 'nav_access_admin_panel'); + } + + if (AdminPanelAction::canAdmin('paths')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Paths configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'), + $menu_title, $action_name == 'pathsadminpanel', 'nav_paths_admin_panel'); + } + + if (AdminPanelAction::canAdmin('sessions')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Sessions configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('sessionsadminpanel'), _('Sessions'), + $menu_title, $action_name == 'sessionsadminpanel', 'nav_sessions_admin_panel'); + } + + if (AdminPanelAction::canAdmin('sitenotice')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Edit site notice'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('sitenoticeadminpanel'), _('Site notice'), + $menu_title, $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel'); + } + + if (AdminPanelAction::canAdmin('snapshot')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Snapshots configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('snapshotadminpanel'), _('Snapshots'), + $menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel'); + } + + Event::handle('EndAdminPanelNav', array($this)); + } + $this->action->elementEnd('ul'); + } + }