[Mediawiki-l] Users can not 'talk'

asselarain-mediawikil at yahoo.com asselarain-mediawikil at yahoo.com
Thu Sep 14 21:44:59 UTC 2006


Obviously usercan is a very much better way of handling  restrictions compared with custom modifications to User.php (My experience with losing the mods @ upgrade is good evidence). 

Sadly, though, usercan seems NOT to work with 1.7.1 ! (I have attached my LocalSettings.php part below: 

// No anonymous editing allowed -
$wgGroupPermissions['*'    ]['read']            = true;
$wgGroupPermissions['*'    ]['edit']            = false;
$wgGroupPermissions['*'    ]['talk']            = false;
$wgGroupPermissions['user' ]['edit']            = false;
$wgGroupPermissions['user' ]['move']            = false;
$wgGroupPermissions['user'    ]['talk']            = true;

# Edit restrictions
function wfSetEditRestrictions( &$title, &$user, $action, &$result ) {
  if( $action != 'edit' ) {
    return;
  }
  if(
      ( $title->isTalkPage() && !$user->isAllowed( 'talk' )) ||
      (!$title->isTalkPage() && !$user->isAllowed( 'edit' ))
    ) {
      return false;
    } else {
      return true;
  }
}
# Set userCan hook
$wgHooks['userCan'][] = 'wfSetEditRestrictions';


----- Original Message ----
From: Rotem Liss <rotemliss_net at fastmail.fm>
To: MediaWiki announcements and site admin list <mediawiki-l at Wikimedia.org>
Sent: Friday, September 15, 2006 2:25:20 AM
Subject: Re: [Mediawiki-l] Users can not 'talk'

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alexis Moinet wrote:
> asselarain-mediawikil-/E1597aS9LQAvxtiuMwx3w at public.gmane.org a écrit :
>> Hm...doesn't these two lines mean that "Users (logged in or not) can't edit PAGES"? I want that to be like that -- users should not edit pages since this is a web page, but they should be able to participate by contributing to 'talk' pages. 
>>
> 
> I think the 'talk' right doesn't exist in mediawiki default installation, you need to create it by changing a little bit the *isAllowed()* function in "includes/User.php " folder.
> 

You should not handle the talk pages editing in User::isAllowed ? it's a general
function for *all* the permissions, and editing talk pages is not a "special
case"! The right way would be to add the restrictions to Title::userCan via the
hook userCan. Something like that in LocalSettings.php may work (I didn't check
it), and will not be removed in upgrades:

# Set group edit restrictions
$wgGroupPermissions['*']['editpage'] = false;
$wgGroupPermissions['user']['editpage'] = true;
$wgGruopPermissions['*']['edittalk'] = true;

# Set userCan hook
$wgHooks['userCan'][] = 'wfSetEditRestrictions';

# Edit restrictions
function wfSetEditRestrictions( &$title, &$user, $action, &$result ) {
    if( $action != 'edit' ) {
        return;
    }
    if( $title->isTalkPage() && !$user->isAllowed( 'edittalk' ) ||
!$title->isTalkPage() && !$user->isAllowed( 'editpage' ) {
        return false;
    } else {
        return true;
    }
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org

iD8DBQFFCZCAqahN/0dU8mcRAtFGAJ0UvyVq5quX/AehHX6Jsht5KCkNOgCgurYO
LoEbLAbGxAHz4GvsEwrdSIk=
=8ell
-----END PGP SIGNATURE-----
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l at Wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l







More information about the MediaWiki-l mailing list