Hi,
For a private wiki, I had the request to add groups of pages to the white-list. Contributors will regularly add (and possibly delete) pages in those groups. So manually editing $wgWhitelistRead appears to be a maintenance nightmare.
So, is there a way to add regexp or namespace (or any other "collection" of pages) in $wgWhitelistRead?
If not (as I think), is there a hook I could use to patch the white-list validation?
Thanks in advance for your answers, Sylvain Leroux
* Sylvain Leroux sylvain@chicoree.fr [Sat, 23 Jan 2010 13:33:20 +0100]:
Hi,
For a private wiki, I had the request to add groups of pages to the white-list. Contributors will regularly add (and possibly delete) pages in those groups. So manually editing $wgWhitelistRead appears to be a maintenance
nightmare.
So, is there a way to add regexp or namespace (or any other "collection" of pages) in $wgWhitelistRead?
If not (as I think), is there a hook I could use to patch the
white-list
validation?
Thanks in advance for your answers, Sylvain Leroux
Before checking for title names in $wgWhitelistRead, includes/Title.php calls $wgUser->isAllowed('read') , which itself calls User::getRights(), which uses the hook 'UserGetRights': http://www.mediawiki.org/wiki/Manual:Hooks/UserGetRights which has the User object as a parameter, but unfortunately no Title object passed, so you have to use global $wgTitle then additionally check $wgTitle instanceof Title, I think. Dmitriy
Thanks Dmitriy.
By looking at the code of Title::userCanReed, I noticed the 'userCan' hook that appears to be here for that exact purpose.
http://www.mediawiki.org/wiki/Manual:Hooks/userCan
I think I will use it with a custom extension to filter pages by title.
I was wondering however if userCanRead() is called only for the viewed page - or for transcluded pages as well? And for redirects: is userCanRead used both for source and target?
Best regards, Sylvain.
Dmitriy Sintsov a écrit :
- Sylvain Leroux sylvain@chicoree.fr [Sat, 23 Jan 2010 13:33:20
+0100]:
Hi,
For a private wiki, I had the request to add groups of pages to the white-list. Contributors will regularly add (and possibly delete) pages in those groups. So manually editing $wgWhitelistRead appears to be a maintenance
nightmare.
So, is there a way to add regexp or namespace (or any other "collection" of pages) in $wgWhitelistRead?
If not (as I think), is there a hook I could use to patch the
white-list
validation?
Thanks in advance for your answers, Sylvain Leroux
Before checking for title names in $wgWhitelistRead, includes/Title.php calls $wgUser->isAllowed('read') , which itself calls User::getRights(), which uses the hook 'UserGetRights': http://www.mediawiki.org/wiki/Manual:Hooks/UserGetRights which has the User object as a parameter, but unfortunately no Title object passed, so you have to use global $wgTitle then additionally check $wgTitle instanceof Title, I think. Dmitriy
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
* Sylvain Leroux sylvain@chicoree.fr [Sat, 23 Jan 2010 20:01:02 +0100]:
Thanks Dmitriy.
By looking at the code of Title::userCanReed, I noticed the 'userCan' hook that appears to be here for that exact purpose.
http://www.mediawiki.org/wiki/Manual:Hooks/userCan
I think I will use it with a custom extension to filter pages by
title.
I had some trouble for 'userCan' not always being called, so my (still unpublished) extension uses both 'userCan' and 'userGetRights' hooks:
# called as the 'UserGetRights' hook to allow user to delete his own page and the subpages of that page static function checkUserPageDelete( &$user, &$aRights ) { global $wgTitle; # enable the deletion of user's page and his subpages if ( self::validLocalTitle( $wgTitle, NS_USER ) ) { $user_name_pq = preg_quote( $user->getName(), '`' ); $title_str = $wgTitle->getText(); if ( preg_match( '`^(' . $user_name_pq . '|' . $user_name_pq . '/.*)$`u', $title_str ) ) { self::addRight( 'delete', $aRights ); } } return true; }
Try 'userCan' first - after all that's an officially recommended way. Probably should be enough for page filtering. Dmitriy
wikitech-l@lists.wikimedia.org