From: Domas Mituzas Date: Tue, 4 Apr 2006 08:46:06 +0000 (+0000) Subject: Hooks:UserCan: allow advisory external checks instead of overriding ones X-Git-Tag: 1.6.0~33 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=9a146b181dc7676a8ae3c6e43473b684b246b7cb;p=lhc%2Fweb%2Fwiklou.git Hooks:UserCan: allow advisory external checks instead of overriding ones This allows targeted rules to be imposed without mocking up with core code too much. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 36e2e5ee39..f8622a6e31 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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. diff --git a/docs/hooks.txt b/docs/hooks.txt index eb48c1ec6c..50ace1ef85 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/Title.php b/includes/Title.php index 9001c35891..0408f51409 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 ) {