*
* @todo Find some commonalities with SettingsAction and combine
*/
-
class AdminPanelAction extends Action
{
var $success = true;
*
* @return boolean success flag
*/
-
- function prepare($args)
+ function prepare(array $args = array())
{
parent::prepare($args);
// User must be logged in.
if (!common_logged_in()) {
+ // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
- return false;
}
$user = common_current_user();
// User must have the right to change admin settings
if (!$user->hasRight(Right::CONFIGURESITE)) {
+ // TRANS: Client error message thrown when a user tries to change admin settings but has no access rights.
$this->clientError(_('You cannot make changes to this site.'));
- return false;
}
// This panel must be enabled
$name = mb_substr($name, 0, -10);
- if (!in_array($name, common_config('admin', 'panels'))) {
+ if (!self::canAdmin($name)) {
+ // TRANS: Client error message throw when a certain panel's settings cannot be changed.
$this->clientError(_('Changes to that panel are not allowed.'), 403);
- return false;
}
return true;
*
* @return void
*/
-
- function handle($args)
+ function handle()
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkSessionToken();
Config::loadSettings();
$this->success = true;
+ // TRANS: Message after successful saving of administrative settings.
$this->msg = _('Settings saved.');
} catch (Exception $e) {
$this->success = false;
* @return void
* @see AdminPanelNav
*/
-
function showLocalNav()
{
$nav = new AdminPanelNav($this);
*
* @return void.
*/
-
function showContent()
{
$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.
*
* @return void
*/
-
function showPageNotice()
{
if ($this->msg) {
*
* @return void
*/
-
function showForm()
{
+ // TRANS: Client error message.
$this->clientError(_('showForm() not implemented.'));
- return;
}
/**
*
* @return void
*/
-
function getInstructions()
{
return '';
*
* @return void
*/
-
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)
+ static function canAdmin($name)
{
- $config = new Config();
-
- $config->section = $section;
- $config->setting = $setting;
+ $isOK = false;
- 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;
- }
+ if (Event::handle('AdminPanelCheck', array($name, &$isOK))) {
+ $isOK = in_array($name, common_config('admin', 'panels'));
}
- return $result;
- }
-}
-
-/**
- * Menu for public group of actions
- *
- * @category Output
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @author Sarven Capadisli <csarven@status.net>
- * @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 ($this->canAdmin('site')) {
- $this->out->menuItem(common_local_url('siteadminpanel'), _('Site'),
- _('Basic site configuration'), $action_name == 'siteadminpanel', 'nav_site_admin_panel');
- }
-
- if ($this->canAdmin('design')) {
- $this->out->menuItem(common_local_url('designadminpanel'), _('Design'),
- _('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel');
- }
-
- if ($this->canAdmin('user')) {
- $this->out->menuItem(common_local_url('useradminpanel'), _('User'),
- _('User configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
- }
-
- if ($this->canAdmin('access')) {
- $this->out->menuItem(common_local_url('accessadminpanel'), _('Access'),
- _('Access configuration'), $action_name == 'accessadminpanel', 'nav_design_admin_panel');
- }
-
- if ($this->canAdmin('paths')) {
- $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
- _('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
- }
-
- if ($this->canAdmin('sessions')) {
- $this->out->menuItem(common_local_url('sessionsadminpanel'), _('Sessions'),
- _('Sessions configuration'), $action_name == 'sessionsadminpanel', 'nav_design_admin_panel');
- }
-
- Event::handle('EndAdminPanelNav', array($this));
- }
- $this->action->elementEnd('ul');
+ return $isOK;
}
- function canAdmin($name)
+ function showProfileBlock()
{
- return in_array($name, common_config('admin', 'panels'));
}
}