Mediawiki

From WikiMwyann

Jump to: navigation, search

Contents

Tips

  • Change sidebar (navigation): just edit Mediawiki:Sidebar

Scripts

Clean history and cache

Create a php file at your wiki's root and put this in it, then run it from your browser:

<?php

define( 'MEDIAWIKI' , 1);

require 'includes/Defines.php';
require 'LocalSettings.php';

mysql_connect($wgDBserver,$wgDBuser,$wgDBpassword);
mysql_select_db($wgDBname);
mysql_query("truncate table archive");
mysql_query("truncate table filearchive");
mysql_query("truncate table logging");
mysql_query("truncate table objectcache");
mysql_query("truncate table recentchanges");
mysql_query("delete from revision where rev_id not in (select page_latest from page)");
mysql_query("delete from text where old_id not in (select rev_text_id from revision)");
mysql_close();

echo "Clean finished !";

?>

Hacks

Note: this can make display errors, if you changed the files with Windows Notepad. You just have to remove every BOM characters "" at the beginning of php files you changed.

Let anonymous edit discussion (talk) page

Note: If you want to limit edition to some namespaces (for example only article talking), just add the following function in includes/Title.php:

       public function isPublicTalkPage() {
               return $this->getNamespace() == NS_TALK;
       }

Then, replace isTalkPage by isPublicTalkPage in the following steps.

  • includes/Title.php:

Add the following line at the very beginning of public function userCan and private function getUserPermissionsErrorsInternal :

if (($action == 'edit') && ($this->isTalkPage())) $action = 'edittalk';
  • includes/EditPage.php:

Replace the following line:

if ( !$wgUser->isAllowed('edit') ) {

By the following:

if ( (( !$this->mTitle->isTalkPage()) && ( !$wgUser->isAllowed('edit'))) ||  (( $this->mTitle->isTalkPage()) && ( !$wgUser->isAllowed('edittalk'))) ) {
  • LocalSettings.php:

Now you have a new right to use in LocalSettings.php : edittalk. Here is an example :

$wgGroupPermissions['*' ]['edittalk'] = true;
$wgGroupPermissions['*' ]['createtalk'] = true;

Disable history for anonymous

  • includes/PageHistory.php

Add bold parts into the file:

	function history() {
		global $wgOut, $wgRequest, $wgTitle, $wgUser;

		if ($this->mTitle->getUserPermissionsErrors('history', $wgUser)) {
			$wgOut->permissionRequired();
			return;
		}
  • includes/SkinTemplate.php

Same here:

			if ( $this->mTitle->getArticleId() ) {

				if (!$this->mTitle->getUserPermissionsErrors('history', $wgUser)) {
					$content_actions['history'] = array(
						'class' => ($action == 'history') ? 'selected' : false,
						'text' => wfMsg('history_short'),
						'href' => $this->mTitle->getLocalUrl( 'action=history')
					);
				}
  • LocalSettings.php

Now you have a new right to use in LocalSettings.php: history. Here is an example:

$wgGroupPermissions['user' ]['history'] = true;
$wgGroupPermissions['*' ]['history'] = false;
$wgGroupPermissions['sysop' ]['history'] = true;
Personal tools