Jump to content

Extension talk:TalkRight

Add topic
From mediawiki.org
(Redirected from Extension talk:Talkright)
Latest comment: 1 month ago by 2A02:810A:180:17AC:A8D0:2A4F:D139:141E in topic Fixes for MW 1.36+


The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

Nifty. I just installed this and it appears to work. What more can you ask for? :) --pfctdayelise 11:46, 1 August 2006 (UTC)Reply

Bug: the extension uses the userCan hook, but returns always false (more accurately, doesn't return anything). this causes further processing to stop, thus preventing other extensions from working. it should return false when user is not allowed and true otherwise Ittayd 10:30, 11 January 2007 (UTC)Reply

Patched. Now should work. Platonides 13:10, 20 March 2007 (UTC)Reply

Large bug: this extension makes it impossible to protect talk pages. If a user has the talk right, then userCan will say that they can edit talk pages, whether they're protected or not. The userCan hook should only ever set $result to false... setting it to true will break things like page protection, setting it to null can break other extensions that have userCan hooks by clobbering their results... it should set it to false if we want to restrict access, and leave it unchanged if we want to allow it, or don't care. I've taken the liberty of fixing this, since it smells like a security hole... Phlip 11:07, 26 March 2007 (UTC)Reply

I think the closing ?> has been missed. 87.218.103.201 14:11, 23 September 2007 (UTC)Reply

No...see rev:23531. It's a feature, not a bug. --Sayuri 14:53, 23 September 2007 (UTC)Reply
Thank you! I've just found the omission extrange. 193.41.227.170 10:57, 24 September 2007 (UTC)Reply

Mediawiki 1.9.0 tweaks

[edit]

Hi there, I found I had to change a couple of things to make this work in MediaWiki 1.9.0.

  1. In alternateEdit() replace "mRights" with "getRights()"
  2. In LocalSettings.php use
require_once("./extensions/talkright.php");

instead of

include_once("extensions/talkright.php");

Does anyone have examples of what Extension:Talkright looks like when implemented?

[edit]

I already have a few wikis setup where the global default in LocalSettings.php is that articles are only editable by admins, and therefor all talk pages are open for anyone else. That way we can publish our agency's "rules" and keep them sacrosanct on article pages, but allow discussions about them in the discussion/talk page behind each article (http://en.citizendium.org/ uses "draft" sub-pages to accomplish this goal). The goal is to consider those discussions when next updating the rules / articles pages. Thanks! -- Peter Blaise peterblaise 14:26, 17 July 2007 (UTC)Reply



Edit tab in talk page

[edit]

Hi, I found that after enabling this extension there was only a "view source" button on existing discussions. To fix this problem, modify includes/SkinTemplate.php on line 672 changing

if ( $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) {

to

if ( ($this->mTitle->quickUserCan( 'edit' ) || ($this->mTitle->isTalkPage() && $wgUser->isAllowed('talk'))) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) {


--Mwlazlo 04:59, 1 April 2008 (UTC)Reply

Mediawiki 1.12

[edit]

Doesn't work with mediawiki 1.12 for me. And i don't think i can point out the problem myself. Anybody some ideas how to fix this? --Wupme 15:14, 21 April 2008 (UTC)Reply

media wiki 1.14

[edit]

Couldn't get this to work after upgrading from 1.13.3 to 1.14.

did get edit_talk rights to work using the other extension..

anyone else have problems with this as 1.14?

Edit tab in 1.16

[edit]

If you use Vector skin, you have also change Skins/Vector.php in line 117 to

"( $this->mTitle->quickUserCan( 'edit' ) ||  ($this->mTitle->isTalkPage() && $wgUser->isAllowed('talk')) )"

Adjustment to talkright.php to fix error To get this extension to work in 1.16, I had to change the parameter passed to alternateEdit from reference to value. That is, remove the '&' in front of the parameter.

Cannot Edit in 1.16 with PHP 5.3.8

[edit]

change line 59, by removeing '&'

from

function alternateEdit(&$editPage) {

to

function alternateEdit($editPage) {

MW 1.20

[edit]

Has anyone made this work with MW 1.20? I've just upgraded to 1.20, and users with the talk permission can edit discussion pages as well as initiate them, and cannot edit articles. So all that is working properly. However, there are three issues I see:

  1. When someone with talk-right starts a new discussion page, they do have the "add topic" button in the top right. After the discussion page is created, however, the "add topic" button is no longer shown.
  2. Discussion pages do not show "edit section" links
  3. Special:Version is all messed up (contents of the header and sidebar are displayed over the body of the page)

Any suggestions on how to fix this? Thanks!

--Jamesmontalvo3 (talk) 21:30, 2 May 2013 (UTC)Reply


Update 1: I fixed the issue with Special:Version by changing the author from "P.LevĂȘque" to "P.Leveque". I have no idea why that would matter, since plenty of my other extensions have authors with accented characters.
--Jamesmontalvo3 (talk) 14:55, 3 May 2013 (UTC)Reply


Update 2: So evidently on our pre-upgrade load (MediaWiki 1.17) people with only the "talk" right also did not see the section edit links or the "add topic" link. Looking through the code I couldn't figure out where those features were added in. Apparently the answer is: they're not! Anyone know how to add them in?
--Jamesmontalvo3 (talk) 15:17, 3 May 2013 (UTC)Reply


Update 3: Thanks to User:2nd-player for updating the code for MW 1.19+ and making the "Add Topic" link work. Now all that is required is to add edit-section links. I've been trying to figure out why it's not working. In Article.php at line 567 it uses Title::quickUserCan() to check to see if the edit section links should be displayed. I thought since quickUserCan() is less exhaustive in checking permissions than userCan(), changing to userCan() in Article.php would temporarily solve the problem. It did not.
Next I commented out $wgHooks['userCan'][] = 'TalkRight::userCanTalk'; from TalkRight.php and saw no effect. Users without edit-rights but with talk-rights could still edit. So I realized userCanTalk() isn't actually doing anything.
TalkRight::alternateEdit() explicitly sets User->mRights, whereas TalkRight::userCanTalk() seems to be attempting to indirectly influence the Title::userCan() method (I don't understand the table at the bottom of Manual:Hooks/userCan so I'm not really sure). It seems to me that doing the same thing as alternateEdit (explicitly setting User->mRights) prior to page parsing should do the trick. To test it out I chose the hook ParserBeforeStrip. This is probably not the best hook to use, and I chose it pretty arbitrarily because I don't know enough about the MediaWiki architecture. It just sounded like it was early enough in the page generation cycle. Manual:Hooks/ParserBeforeStrip says that this is not called on cached content, so that could pose a problem.
My code is below, and note that I removed userCan and SkinTemplateNavigation hooks and related TalkRight methods. As mentioned, userCan didn't appear to do anything. SkinTemplateNavigation wasn't necessary anymore once the ParserBeforeStrip hook was used.
<?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' ) ) {
    echo <<<EOT
To install the TalkRight extension, put the following line in LocalSettings.php:
require_once( "\$IP/extensions/TalkRight/TalkRight.php" );
EOT;
    exit( 1 );
}
 
$wgExtensionCredits['other'][] = array(
    'name' => 'TalkRight',
    'version' => '1.4.1',
    'author' => array('P.Lev&ecirc;que', 'Marc Noirot', 'James Montalvo'),
    'description' => 'Adds a <tt>talk</tt> permission independent from article edition',
    'url' => 'http://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;
    }
    
}
--Jamesmontalvo3 (talk) 19:17, 6 May 2013 (UTC)Reply

Mediawiki 1.3 Moving Pages

[edit]

I'm trying to create a group that can comment on the talk pages but not edit:

 $wgGroupPermissions['talkers']['edit'] = false;
 $wgGroupPermissions['talkers']['talk'] = true;

but it seems that the 'talkers' group can still move a page! I tried adding:

 $wgGroupPermissions['talkers']['move'] = false;

but it still seems to be there. Anyone have a fix?

Mediawiki 1.29.2

[edit]

This seems to only produce a fatal 500 error in MW version 1.29. Has anyone found a way to make it work? The extension results in unexpected variables in the localsettings.php

Solution

[edit]

This can be fixed by changing following line in TalkRight.class.php

 static function giveEditRightsWhenViewingTalkPages ( &$parser, &$test, &$test ) {

to

 static function giveEditRightsWhenViewingTalkPages ( &$parser ) {

Those parameters are unused and generate an error because of the duplication. Tested with Mediawiki 1.31.0 and PHP 7.0.31

--178.83.48.145 12:44, 17 September 2018 (UTC)Reply

Make Anon users able to only edit/create talk pages?

[edit]
There seems to be a problem for anon users with this extension. I am trying to make anon users able to use discussion pages, but not edit the articles on my site. Using this extension was a last resort after trying all other suggestions, so i am hoping someone might know a way to do that?

Fixes for MW 1.36+

[edit]

Making the following code fixes allows this extension to continue working with recent releases:

  • In extension.json, replace "ParserBeforeStrip" with "ParserBeforeInternalParse".
  • In TalkRight.class.php, replace "$parser->getUser()" with "$parser->getUserIdentity()".

-Stelio (talk) 08:48, 2 January 2022 (UTC)Reply

I've loaded a code fix to GitHub and submitted a pull request: https://github.com/enterprisemediawiki/TalkRight/pull/3 -Stelio (talk) 10:02, 2 January 2022 (UTC)Reply
Does the Extesion + your changes still work with 1.42.3? 2A02:810A:180:17AC:A8D0:2A4F:D139:141E 16:44, 3 November 2024 (UTC)Reply