r33368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33367‎ | r33368 | r33369 >
Date:17:07, 15 April 2008
Author:gri6507
Status:old
Tags:
Comment:
v0.8.7
* Highlight the expiry dates that have expired in red
* When a wildcard is used to enable access to a set of pages, it may pull in one too many pages. Currently, there is no easy way to work around that. One possibility is to allow managers to also define BlackListed pages which would take precedence over whitelisted pages. This way, the manager could define a generic wildcard pattern and then also specify the couple of pages that must be explicitly blacklisted.
* restricted users cannot upload a new image even if that image is should already be whitelisted.
Modified paths:
  • /trunk/extensions/WhiteList/SpecialWhitelistEdit.php (modified) (history)
  • /trunk/extensions/WhiteList/WhitelistAuth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WhiteList/WhitelistAuth.php
@@ -219,7 +219,16 @@
220220 AND wl_allow_edit = " . $dbr->addQuotes('1');
221221 }
222222 #print $sql;
223 -
 223+
 224+ // We should also check that $title is not a redirect to a whitelisted page
 225+ $redirecttitle = NULL;
 226+ $article = new Article($title);
 227+ if (is_object($article))
 228+ {
 229+ $pagetext = $article->getContent();
 230+ $redirecttitle = Title::newFromRedirect($pagetext);
 231+ }
 232+
224233 /* Loop through each result returned and
225234 * check for matches.
226235 */
@@ -232,6 +241,15 @@
233242 #wfDebug("\n\nAccess granted based on PAGE [" . $db_result->wl_page_title . "]\n\n");
234243 return WHITELIST_GRANT;
235244 }
 245+ if ($redirecttitle)
 246+ {
 247+ if( self::RegexCompare($redirecttitle, $db_result->wl_page_title) )
 248+ {
 249+ $dbr->freeResult($db_results);
 250+ #wfDebug("\n\nAccess granted based on REDIRECT to PAGE [" . $db_result->wl_page_title . "]\n\n");
 251+ return WHITELIST_GRANT;
 252+ }
 253+ }
236254 }
237255 $dbr->freeResult($db_results);
238256
@@ -241,6 +259,8 @@
242260 /* Returns true if hit, false otherwise */
243261 static function RegexCompare(&$title, $sql_regex)
244262 {
 263+ global $wgWhitelistWildCardInsensitive;
 264+
245265 $ret_val = false;
246266
247267 /* Convert regex to PHP format */
@@ -249,14 +269,14 @@
250270 $php_regex = ltrim($php_regex, ":");
251271
252272 /* Generate regex; use | as delimiter as it is an illegal title character. */
253 - $php_regex_full = '|' . $php_regex . '|';
 273+ $php_regex_full = '|^' . $php_regex . '$|';
254274 if ($wgWhitelistWildCardInsensitive)
255275 $php_regex_full .= 'i';
256276
257 - #print( $php_regex_full . " [" . $title->getPrefixedText() . "]<br />\n");
 277+#print( $php_regex_full . " [" . $title->getPrefixedText() . "]<br />\n");
258278 if (self::preg_test($php_regex_full)) {
259279 if( preg_match( $php_regex_full, $title->getPrefixedText() ) ) {
260 - #print("MATCH!!");
 280+#print("MATCH!!");
261281 $ret_val = true;
262282 }
263283 }
Index: trunk/extensions/WhiteList/SpecialWhitelistEdit.php
@@ -31,7 +31,7 @@
3232
3333 $wgExtensionCredits['specialpage'][] = array(
3434 'name' => 'WhiteListEdit',
35 - 'version' => 'v0.8.6',
 35+ 'version' => 'v0.8.7',
3636 'author' => array('Paul Grinberg', 'Mike Sullivan'),
3737 'email' => 'gri6507 at yahoo dot com, ms-mediawiki AT umich DOT edu',
3838 'description' => 'Edit the access permissions of restricted users',

Status & tagging log