Skip to content

Commit

Permalink
Warn users when they are viewing a wiki's configuration without write…
Browse files Browse the repository at this point in the history
… access
  • Loading branch information
AgentIsai authored Oct 21, 2024
1 parent 2373ddf commit a8606f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
17 changes: 12 additions & 5 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,21 @@
"managewiki-error-disallowednamespace": "The namespace \"$1\" is not allowed.",
"managewiki-error-emptygroup": "You cannot create a group without any permissions assigned.",
"managewiki-error-install": "The extension \"$1\" failed to be enabled. If this keeps occurring, please ",
"managewiki-error-nopermission": "You may view this wiki's configuration but you do not have permission to edit it.",
"managewiki-error-nopermission-remote": "You are remotely viewing a wiki's configuration. If you are a wiki operator, please navigate to your wiki to modify its configuration. You may not edit it from here.",
"managewiki-error-requirements": "The extension \"$1\" cannot be enabled because it fails to meet its requirements.",
"managewiki-extension-name": "[$1 $2]",
"managewiki-extension-settings": "Manage available configuration options for this extension",
"managewiki-header-core": "Select what you would like to manage below, and click the save button to save your changes.",
"managewiki-header-extensions": "The extensions here are the ones that are currently installed, but you can always <span class=\"plainlinks\">[https://meta.miraheze.org/wiki/Request_features request]</span> another one to be added. <br> Once you are done, press the \"save\" button to save your changes.",
"managewiki-header-namespaces": "Select a namespace to edit below (talk namespaces are associated to their main namespace) or press the button to create a new main namespace.",
"managewiki-header-permissions": "Select a group below that already exists to modify or create a new user group in the box below.",
"managewiki-header-settings": "This page is used to manage the wiki settings of wiki <b>'$1'</b>. If a feature you would like is not available here yet, please use <span class=\"plainlinks\">[https://meta.miraheze.org/wiki/Request_features Phorge]</span> to request it. <br> Once you are done, press the \"save\" button to save your changes.",
"managewiki-header-core": "You can manage this wiki's core settings (such as the name and language) from this panel. Greyed out options may only be changed by farm operators. Once done, click 'Save' and your preferences will reflect in a few seconds.\n\nYou may manage additional settings such as logo and more at [[Special:ManageWiki/settings]].",
"managewiki-header-core-view": "You may view this wiki's core settings from this panel but '''you do not have permission to change them'''.\n\nYou may view additional settings such as logo and more at [[Special:ManageWiki/settings]].",
"managewiki-header-extensions": "You may manage this wiki's extensions and skins from this panel. This panel reflects all available extensions and skins. If you do not see the extension or skin you need, please contact your system administrator.\n\nOnce done, click 'Save' and your extension or skin will be installed in a few seconds.",
"managewiki-header-extensions-view": "You may view this wiki's extensions and skins from this panel but '''you do not have permission to manage them'''. If you need an extension or skin enabled, please contact this wiki's operators.",
"managewiki-header-namespaces": "You may manage this wiki's namespace configurations from this panel. Some settings will only reflect once you enable an extension. Consult MediaWiki documenation for further information. Once done, click 'Save' and your preferences will reflect in a few seconds.",
"managewiki-header-namespaces-view": "You may view this wiki's namespace configurations from this panel but '''you do not have permission to change them'''. Contact wiki operators if you need further assistence.",
"managewiki-header-permissions": "You may manage this wiki's user group configurations from this panel (such as permissions, group assignments and autopromotion). Please read the documentation very carefully and do not delete groups brazenly or your wiki may break. Once done, click 'Save' and your preferences will reflect in a few seconds.\n\nNot all permissions may be assignable. Certain user permissions may be reserved only for farm operators. Contact your farm if you do not find certain permissions.",
"managewiki-header-permissions-view": "You may view this wiki's user group configurations from this panel (such as permissions, group assignments and autopromotion) but '''you do not have permission to change them'''. Contact wiki operators if you need further assistence.",
"managewiki-header-settings": "You may manage this wiki's settings (such as logo, styling, and more) from this panel. Be careful! Make sure to carefully read setting descriptions and do not toggle random settings indiscriminately unless you understand what it does. Once done, click 'Save' and your preferences will reflect in a few seconds. \n\nGreyed out options may only be changed by farm operators. You may manage core settings such as wiki name and language at [[Special:ManageWiki/core]].",
"managewiki-header-settings-view": "You may view this wiki's settings (such as logo, styling, and more) from this panel but '''you do not have permission to change them'''.\n\nAdditional core settings such as wiki name and language are available at [[Special:ManageWiki/core]].",
"managewiki-invalid-database": "$1 is an invalid database. Given by <code>&dollar;$2</code>.",
"managewiki-label-category": "Category",
"managewiki-label-closed": "Closed",
Expand Down
14 changes: 14 additions & 0 deletions includes/Specials/SpecialManageWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ public function execute( $par ) {

if ( !$this->getContext()->getUser()->isAllowed( 'managewiki-' . $module ) ) {
$out->setPageTitle( $this->msg( 'managewiki-link-' . $module . '-view' )->text() );
$out->addHTML(
Html::errorBox( $this->context->msg( 'managewiki-error-nopermission' )->escaped() )
);
$out->addWikiMsg( "managewiki-header-{$module}-view", $wiki );
} else {
$out->setPageTitle( $this->msg( 'managewiki-link-' . $module )->text() );
$out->addWikiMsg( "managewiki-header-{$module}", $wiki );
}

$additional = $par[1] ?? '';
Expand All @@ -68,6 +73,15 @@ public function execute( $par ) {
$this->showInputBox();
} elseif ( $module == 'core' ) {
$dbName = $par[1] ?? $this->config->get( 'DBname' );
if ( !$this->getContext()->getUser()->isAllowed( 'managewiki-' . $module ) && WikiMap::isCurrentWikiId( $this->config->get( 'CreateWikiGlobalWiki' ) ) ) {
$out->addHTML(
Html::errorBox( $this->context->msg( 'managewiki-error-nopermission-remote' )->escaped() )
);
} elseif ( !$this->getContext()->getUser()->isAllowed( 'managewiki-' . $module ) && !WikiMap::isCurrentWikiId( $this->config->get( 'CreateWikiGlobalWiki' ) ) ) {
$out->addHTML(
Html::errorBox( $this->context->msg( 'managewiki-error-nopermission' )->escaped() )
);
}
$this->showWikiForm( strtolower( $dbName ), 'core', '', '' );
} else {
$this->showWikiForm( $this->config->get( 'DBname' ), $module, $additional, $filtered );
Expand Down

0 comments on commit a8606f4

Please sign in to comment.