return;
}
- if ((!$wgUser->isAllowed('delete'))) {
- $wgOut->permissionRequired( 'delete' );
- return;
- }
+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
- if (wfReadOnly()) {
- $wgOut->readOnlyPage();
+ if (count($permission_errors)>0)
+ {
+ $wgOut->showPermissionsErrorPage( $permission_errors );
return;
}
# This code desperately needs to be totally rewritten
# Check permissions
- if( $wgUser->isAllowed( 'delete' ) ) {
- if( $wgUser->isBlocked( !$confirm ) ) {
- $wgOut->blockedPage();
- return;
- }
- } else {
- $wgOut->permissionRequired( 'delete' );
- return;
- }
+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
- if( wfReadOnly() ) {
- $wgOut->readOnlyPage();
+ if (count($permission_errors)>0)
+ {
+ $wgOut->showPermissionsErrorPage( $permission_errors );
return;
}
* @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
* @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
*/
- public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true ) {
+ public function getUserPermissionsErrors( $action, $user = null, $doExpensiveQueries = true ) {
$errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
global $wgContLang;
global $wgLang;
+ # Be kinder to people who forget to supply a user, assuming they mean $wgUser
+ if (!$user)
+ $user = $wgUser;
+
if ( wfReadOnly() && $action != 'read' ) {
global $wgReadOnly;
$errors[] = array( 'readonlytext', $wgReadOnly );
global $wgEmailConfirmToEdit, $wgUser;
- if ( $wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed() )
+ if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() )
{
$errors[] = array( 'confirmedittext' );
}