Extension:Talkright
From MediaWiki.org
|
Talkright Release status: stable |
|||
|---|---|---|---|
| Implementation | User rights | ||
| Description | Makes the editing of talk pages a distinct action from article editing. | ||
| Author(s) | P Leveque, Marc Noirot, James Montalvo | ||
| Last version | 1.4.1 (2013-05-06) | ||
| MediaWiki | 1.19+ | ||
| Database changes | No | ||
| License | GPL v2+ | ||
| Download | see below | ||
|
|||
|
|||
| Check usage and version matrix | |||
The Talkright extension makes the editing of talk pages a distinct action from the editing of articles to create finer permissions, by adding the talk right.
Contents |
Usage [edit]
On a semi private wiki, a user can be allowed to read but not to edit the content of a page as well as its talk page. This is done by setting:
$wgGroupPermissions['user']['read'] = true; $wgGroupPermissions['user']['edit'] = false;
Now, if you want to encourage comments to your wiki from a group of persons, by giving them rights to edit the talk pages only, you need to install this Talkright extension and to add, for example, the following two lines:
$wgGroupPermissions['commentators']['edit'] = false; $wgGroupPermissions['commentators']['talk'] = true;
Installation [edit]
- Obtain the code and extract the files in a directory called "
Talkright" in your extensions/ folder. - Add the following code to your LocalSettings.php (at the bottom)
require_once( "$IP/extensions/Talkright/Talkright.php" );
Done – Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.
Code [edit]
- MediaWiki 1.19.x and 1.20.x
Tested with MW 1.20.2 - skins: Vector, monobook
<?php /** * Talkright MediaWiki extension * @author Marc Noirot - marc dot noirot at gmail * @author P.Levêque - User:Phillev * @author James Montalvo - User:Jamesmontalvo3 * * This extension makes the editing of talk pages a distinct action from * the editing of articles, to create finer permissions by adding the 'talk' right. * */ if ( !defined( 'MEDIAWIKI' ) ) { die( 'This file is an extension to MediaWiki and thus not a valid entry point.' ); } $wgExtensionCredits['other'][] = array( 'name' => 'TalkRight', 'version' => '1.4.1', 'author' => array('P.Levêque', 'Marc Noirot', 'James Montalvo'), 'description' => 'Adds a <code>talk</code> permission independent from article edition', 'url' => 'https://www.mediawiki.org/wiki/Extension:Talkright', ); # Register hooks $wgHooks['AlternateEdit'][] = 'TalkRight::alternateEdit'; $wgHooks['ParserBeforeStrip'][] = 'TalkRight::giveEditRightsWhenViewingTalkPages'; # Global 'talk' right $wgAvailableRights[] = 'talk'; class TalkRight { /** * Bypass edit restriction when EDITING pages if user has 'talk' right and page is a talk (discussion) page. * @param $&editPage the page edition object * @return true to resume edition to normal operation */ static function alternateEdit( $editPage ) { global $wgOut, $wgUser, $wgRequest, $wgTitle; if ( $wgTitle->isTalkPage() && $wgUser->isAllowed( 'talk' ) ) { array_push( $wgUser->mRights, 'edit' ); } return true; } /** * Bypass edit restriction when VIEWING pages if user has 'talk' right and page is a talk (discussion) page. * This is probably not the ideal hook to use. I just needed one earlier than creation of section links, edit tab and add topic tab * @param &$parser parser object, used to gain access to User and Title objects * @param &$text unused * @param &$strip_state unused * @return true and false both seemed to work. [[Manual:Hooks/ParserBeforeStrip]] doesn't indicate what return value affects */ static function giveEditRightsWhenViewingTalkPages ( &$parser, &$test, &$test ) { $user = $parser->getUser(); if ( $parser->getTitle()->isTalkPage() && $user->isAllowed( 'talk' ) ) { array_push( $user->mRights, 'edit' ); } return true; } }
History [edit]
| Date | Version | Notes |
|---|---|---|
| 06 May 2013 | Version 1.4.1 | updated for MW1.19. added new topic and edit section link. |
| 24 November 2011 | Version 1.3 | No need to modify 'includes/SkinTemplate.php' to edit "view source" button. |
| 05 August 2008 | Version 1.1 | Added credits for MediaWiki version 1.12, 1.13. |
| 20 June 2006 | Version 1.0.1 | Added credits and extension version information. |
| 07 June 2006 | Version 1.0 | First release. |
| Language: | English • 日本語 |
|---|