$this->setHeaders();
// This will throw exceptions if there's a problem
- $this->userCanExecute( $this->getUser() );
+ $this->checkExecutePermissions( $this->getUser() );
$form = $this->getForm();
if ( $form->show() ) {
protected function setParameter( $par ){}
/**
- * Checks if the given user (identified by an object) can perform this action. Can be
- * overridden by sub-classes with more complicated permissions schemes. Failures here
- * must throw subclasses of ErrorPageError
- *
- * @param $user User: the user to check, or null to use the context user
+ * Called from execute() to check if the given user can perform this action.
+ * Failures here must throw subclasses of ErrorPageError.
+ * @param $user User
* @return Bool true
* @throws ErrorPageError
*/
- public function userCanExecute( User $user ) {
+ protected function checkExecutePermissions( User $user ) {
if ( $this->requiresWrite() && wfReadOnly() ) {
throw new ReadOnlyError();
}
- if ( $this->getRestriction() !== null && !$user->isAllowed( $this->getRestriction() ) ) {
+ if ( !$this->userCanExecute( $this->getUser() ) ) {
throw new PermissionsError( $this->getRestriction() );
}
return false;
}
- public function userCanExecute( User $user ) {
- parent::userCanExecute( $user );
+ public function checkExecutePermissions( User $user ) {
+ global $wgReadOnlyFile;
+ parent::checkExecutePermissions( $user );
# If the lock file isn't writable, we can do sweet bugger all
- global $wgReadOnlyFile;
if ( !is_writable( dirname( $wgReadOnlyFile ) ) ) {
throw new ErrorPageError( 'lockdb', 'lockfilenotwritable' );
}
}
public function userCanExecute( User $user ) {
+ return $this->canChangePassword( $user ) === true && parent::userCanExecute( $user );
+ }
+
+ public function checkExecutePermissions( User $user ) {
$error = $this->canChangePassword( $user );
if ( is_string( $error ) ) {
throw new ErrorPageError( 'internalerror', $error );
throw new ErrorPageError( 'internalerror', 'resetpass_forbidden' );
}
- return parent::userCanExecute( $user );
+ return parent::checkExecutePermissions( $user );
}
protected function getFormFields() {
return false;
}
- public function userCanExecute( User $user ) {
- parent::userCanExecute( $user );
+ public function checkExecutePermissions( User $user ) {
+ global $wgReadOnlyFile;
+ parent::checkExecutePermissions( $user );
# If the lock file isn't writable, we can do sweet bugger all
- global $wgReadOnlyFile;
if ( !file_exists( $wgReadOnlyFile ) ) {
throw new ErrorPageError( 'lockdb', 'databasenotlocked' );
}