*
* @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;
}
$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;
+ }
+
+ // This panel must be enabled
+
+ $name = $this->trimmed('action');
+
+ $name = mb_substr($name, 0, -10);
+
+ 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 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;
$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
*
*
* @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;
+ }
+
+ static function canAdmin($name)
+ {
+ $isOK = false;
+
+ if (Event::handle('AdminPanelCheck', array($name, &$isOK))) {
+ $isOK = in_array($name, common_config('admin', 'panels'));
+ }
+
+ return $isOK;
+ }
+
+ function showProfileBlock()
+ {
}
}