Hooks:UserCan: allow advisory external checks instead of overriding ones
authorDomas Mituzas <midom@users.mediawiki.org>
Tue, 4 Apr 2006 08:46:06 +0000 (08:46 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Tue, 4 Apr 2006 08:46:06 +0000 (08:46 +0000)
This allows targeted rules to be imposed without mocking up with core code too much.

RELEASE-NOTES
docs/hooks.txt
includes/Title.php

index 36e2e5e..f8622a6 100644 (file)
@@ -144,6 +144,7 @@ Images:
 * (bug 4426) Add link to user_talk page on image pages
 * Support a custom convert command for thumbnailing. See DefaultSettings.php
   and the comments for $wgCustomConvertCommand, for more information.
+* UserCan hook now allows advisory return values, rather than mandatory ones.
 
 Installer:
 * (bug 3782) Throw fatal installation warning if mbstring.func_overload on.
index eb48c1e..50ace1e 100644 (file)
@@ -380,11 +380,12 @@ string $saveName: destination file name
 string $tempName: filesystem path to the temporary file for checks
 string &$error: output: HTML error to show if upload canceled by returning false
 
-'UserCan': To interrupt the "user can do X to Y article" check
+'UserCan': To interrupt/advise the "user can do X to Y article" check
 $title: Title object being checked against
 $user : Current user object
 $action: Action being checked
-$result: Pointer to result returned if hook returns false
+$result: Pointer to result returned if hook returns false. If null is returned,
+ UserCan checks are continued by internal code
 
 'UserCreateForm': change to manipulate the login form
 $template: SimpleTemplate instance for the form
index 9001c35..0408f51 100644 (file)
@@ -969,7 +969,9 @@ class Title {
                $result = true;
                if ( !wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) ) ) {
                        wfProfileOut( $fname );
-                       return $result;
+                       // Allow advisory rights checking
+                       if ( $result !== null )
+                               return $result;
                }
 
                if( NS_SPECIAL == $this->mNamespace ) {