X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fadminpanelaction.php;h=7997eb2b1f4b13a7db84f7c78fd3af07d0c44527;hb=7abf48932b35ce178d147cb62a5c83ca0f6d0cfc;hp=2e9261711b8464e386f06a2a6f64e8091706349e;hpb=9d026600a9525ab78a6031b2acbfd388cbde48ff;p=quix0rs-gnu-social.git diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php index 2e9261711b..7997eb2b1f 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -75,6 +75,10 @@ class AdminPanelAction extends Action $user = common_current_user(); + // ...because they're logged in + + assert(!empty($user)); + // It must be a "real" login, not saved cookie login if (!common_is_real_login()) { @@ -88,8 +92,6 @@ class AdminPanelAction extends Action // User must have the right to change admin settings - $user = common_current_user(); - if (!$user->hasRight(Right::CONFIGURESITE)) { $this->clientError(_('You cannot make changes to this site.')); return; @@ -116,6 +118,10 @@ class AdminPanelAction extends Action try { $this->saveSettings(); + // Reload settings + + Config::loadSettings(); + $this->success = true; $this->msg = _('Settings saved.'); } catch (Exception $e) { @@ -126,6 +132,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 * @@ -203,4 +224,92 @@ class AdminPanelAction extends Action $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__); + $this->clientError(_("Unable to delete design setting.")); + return null; + } + } + + return $result; + } +} + +/** + * 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))) { + + $this->out->menuItem(common_local_url('siteadminpanel'), _('Site'), + _('Basic site configuration'), $action_name == 'siteadminpanel', 'nav_site_admin_panel'); + + $this->out->menuItem(common_local_url('designadminpanel'), _('Design'), + _('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel'); + + $this->out->menuItem(common_local_url('useradminpanel'), _('User'), + _('Paths configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel'); + + $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'), + _('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel'); + + Event::handle('EndAdminPanelNav', array($this)); + } + $this->action->elementEnd('ul'); + } }