Index: trunk/phase3/includes/specials/SpecialPasswordReset.php |
— | — | @@ -43,6 +43,10 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function userCanExecute( User $user ) { |
| 47 | + return $this->canChangePassword( $user ) === true && parent::userCanExecute( $user ); |
| 48 | + } |
| 49 | + |
| 50 | + public function checkExecutePermissions( User $user ) { |
47 | 51 | $error = $this->canChangePassword( $user ); |
48 | 52 | if ( is_string( $error ) ) { |
49 | 53 | throw new ErrorPageError( 'internalerror', $error ); |
— | — | @@ -50,7 +54,7 @@ |
51 | 55 | throw new ErrorPageError( 'internalerror', 'resetpass_forbidden' ); |
52 | 56 | } |
53 | 57 | |
54 | | - return parent::userCanExecute( $user ); |
| 58 | + return parent::checkExecutePermissions( $user ); |
55 | 59 | } |
56 | 60 | |
57 | 61 | protected function getFormFields() { |
Index: trunk/phase3/includes/specials/SpecialLockdb.php |
— | — | @@ -37,11 +37,11 @@ |
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
41 | | - public function userCanExecute( User $user ) { |
42 | | - parent::userCanExecute( $user ); |
| 41 | + public function checkExecutePermissions( User $user ) { |
| 42 | + global $wgReadOnlyFile; |
43 | 43 | |
| 44 | + parent::checkExecutePermissions( $user ); |
44 | 45 | # If the lock file isn't writable, we can do sweet bugger all |
45 | | - global $wgReadOnlyFile; |
46 | 46 | if ( !is_writable( dirname( $wgReadOnlyFile ) ) ) { |
47 | 47 | throw new ErrorPageError( 'lockdb', 'lockfilenotwritable' ); |
48 | 48 | } |
Index: trunk/phase3/includes/specials/SpecialUnlockdb.php |
— | — | @@ -36,11 +36,11 @@ |
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | | - public function userCanExecute( User $user ) { |
41 | | - parent::userCanExecute( $user ); |
| 40 | + public function checkExecutePermissions( User $user ) { |
| 41 | + global $wgReadOnlyFile; |
42 | 42 | |
| 43 | + parent::checkExecutePermissions( $user ); |
43 | 44 | # If the lock file isn't writable, we can do sweet bugger all |
44 | | - global $wgReadOnlyFile; |
45 | 45 | if ( !file_exists( $wgReadOnlyFile ) ) { |
46 | 46 | throw new ErrorPageError( 'lockdb', 'databasenotlocked' ); |
47 | 47 | } |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -786,7 +786,7 @@ |
787 | 787 | $this->setHeaders(); |
788 | 788 | |
789 | 789 | // This will throw exceptions if there's a problem |
790 | | - $this->userCanExecute( $this->getUser() ); |
| 790 | + $this->checkExecutePermissions( $this->getUser() ); |
791 | 791 | |
792 | 792 | $form = $this->getForm(); |
793 | 793 | if ( $form->show() ) { |
— | — | @@ -801,20 +801,18 @@ |
802 | 802 | protected function setParameter( $par ){} |
803 | 803 | |
804 | 804 | /** |
805 | | - * Checks if the given user (identified by an object) can perform this action. Can be |
806 | | - * overridden by sub-classes with more complicated permissions schemes. Failures here |
807 | | - * must throw subclasses of ErrorPageError |
808 | | - * |
809 | | - * @param $user User: the user to check, or null to use the context user |
| 805 | + * Called from execute() to check if the given user can perform this action. |
| 806 | + * Failures here must throw subclasses of ErrorPageError. |
| 807 | + * @param $user User |
810 | 808 | * @return Bool true |
811 | 809 | * @throws ErrorPageError |
812 | 810 | */ |
813 | | - public function userCanExecute( User $user ) { |
| 811 | + protected function checkExecutePermissions( User $user ) { |
814 | 812 | if ( $this->requiresWrite() && wfReadOnly() ) { |
815 | 813 | throw new ReadOnlyError(); |
816 | 814 | } |
817 | 815 | |
818 | | - if ( $this->getRestriction() !== null && !$user->isAllowed( $this->getRestriction() ) ) { |
| 816 | + if ( !$this->userCanExecute( $this->getUser() ) ) { |
819 | 817 | throw new PermissionsError( $this->getRestriction() ); |
820 | 818 | } |
821 | 819 | |