+ return $errors;
+ }
+
+ /**
+ * Check that the user isn't blocked from editting.
+ *
+ * @param $action String the action to check
+ * @param $user User user to check
+ * @param $errors Array list of current errors
+ * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
+ * @param $short Boolean short circuit on first error
+ *
+ * @return Array list of errors
+ */
+ private function checkUserBlock( $action, $user, $errors, $doExpensiveQueries, $short ) {
+ if( $short && count( $errors ) > 0 ) {
+ return $errors;
+ }
+
+ global $wgContLang, $wgLang, $wgEmailConfirmToEdit;
+
+ if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount' ) {
+ $errors[] = array( 'confirmedittext' );
+ }
+
+ // Edit blocks should not affect reading. Account creation blocks handled at userlogin.
+ if ( $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this ) ) {
+ $block = $user->mBlock;
+
+ // This is from OutputPage::blockedPage
+ // Copied at r23888 by werdna
+
+ $id = $user->blockedBy();
+ $reason = $user->blockedFor();
+ if ( $reason == '' ) {
+ $reason = wfMsg( 'blockednoreason' );
+ }
+ $ip = wfGetIP();
+
+ if ( is_numeric( $id ) ) {
+ $name = User::whoIs( $id );
+ } else {
+ $name = $id;
+ }
+
+ $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
+ $blockid = $block->mId;
+ $blockExpiry = $user->mBlock->mExpiry;
+ $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
+ if ( $blockExpiry == 'infinity' ) {
+ // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
+ $scBlockExpiryOptions = wfMsg( 'ipboptions' );
+
+ foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
+ if ( !strpos( $option, ':' ) )
+ continue;
+
+ list( $show, $value ) = explode( ':', $option );
+
+ if ( $value == 'infinite' || $value == 'indefinite' ) {
+ $blockExpiry = $show;
+ break;
+ }
+ }
+ } else {
+ $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
+ }
+
+ $intended = $user->mBlock->mAddress;
+
+ $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
+ $blockid, $blockExpiry, $intended, $blockTimestamp );
+ }
+
+ return $errors;
+ }
+
+ /**
+ * Can $user perform $action on this page? This is an internal function,
+ * which checks ONLY that previously checked by userCan (i.e. it leaves out
+ * checks on wfReadOnly() and blocks)
+ *
+ * @param $action String action that permission needs to be checked for
+ * @param $user User to check
+ * @param $doExpensiveQueries Bool Set this to false to avoid doing unnecessary queries.
+ * @param $short Bool Set this to true to stop after the first permission error.
+ * @return Array of arrays of the arguments to wfMsg to explain permissions problems.
+ */
+ protected function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true, $short = false ) {
+ wfProfileIn( __METHOD__ );
+
+ $errors = array();
+ $checks = array(
+ 'checkQuickPermissions',
+ 'checkPermissionHooks',
+ 'checkSpecialsAndNSPermissions',
+ 'checkCSSandJSPermissions',
+ 'checkPageRestrictions',
+ 'checkCascadingSourcesRestrictions',
+ 'checkActionPermissions',
+ 'checkUserBlock'
+ );
+
+ while( count( $checks ) > 0 &&
+ !( $short && count( $errors ) > 0 ) ) {
+ $method = array_shift( $checks );
+ $errors = $this->$method( $action, $user, $errors, $doExpensiveQueries, $short );
+ }