*/
public function getLocalURL( $query = '', $variant = false ) {
global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
- global $wgVariantArticlePath, $wgContLang, $wgUser;
+ global $wgVariantArticlePath, $wgContLang, $wgUser, $wgArticlePathForCurid;
if( is_array( $query ) ) {
$query = wfArrayToCGI( $query );
}
} else {
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
- if ( $query == '' ) {
+ if ( $query == '' || ($wgArticlePathForCurid && substr_count( $query, '&' ) == 0 && strpos( $query, 'curid=' ) === 0 ) ) {
if( $variant != false && $wgContLang->hasVariants() ) {
if( $wgVariantArticlePath == false ) {
$variantArticlePath = "$wgScript?title=$1&variant=$2"; // default
} else {
$url = str_replace( '$1', $dbkey, $wgArticlePath );
}
+ $url = wfAppendQuery( $url, $query );
} else {
global $wgActionPaths;
$url = false;
}
$errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
- global $wgContLang;
- global $wgLang;
- global $wgEmailConfirmToEdit;
+ global $wgContLang, $wgLang, $wgEmailConfirmToEdit;
if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount' ) {
$errors[] = array( 'confirmedittext' );
}
- if ( $user->isBlockedFrom( $this ) && $action != 'createaccount' ) {
+ // Edit blocks should not affect reading. Account creation blocks handled at userlogin.
+ if ( $user->isBlockedFrom( $this ) && $action != 'read' && $action != 'createaccount' ) {
$block = $user->mBlock;
// This is from OutputPage::blockedPage
$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, ':' ) == false )
- continue;
-
- list ($show, $value) = explode( ":", $option );
-
- if ( $value == 'infinite' || $value == 'indefinite' ) {
- $blockExpiry = $show;
- break;
- }
- }
+ $blockExpiry = wfMsg( 'ipbinfinite' );
} else {
$blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
}
$errors[] = array( ($block->mAuto ? 'autoblockedtext' : 'blockedtext'), $link, $reason, $ip, $name,
$blockid, $blockExpiry, $intended, $blockTimestamp );
}
-
+
// Remove the errors being ignored.
-
+
foreach( $errors as $index => $error ) {
$error_key = is_array($error) ? $error[0] : $error;
* @return \type{\array} Array of arrays of the arguments to wfMsg to explain permissions problems.
*/
private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
+ global $wgLang;
+
wfProfileIn( __METHOD__ );
$errors = array();
$errors[] = $return;
}
+ // Check per-user restrictions
+ if( $action != 'read' ) {
+ $r = $user->getRestrictionForPage( $this );
+ if( !$r )
+ $r = $user->getRestrictionForNamespace( $this->getNamespace() );
+ if( $r ) {
+ $start = $wgLang->timeanddate( $r->getTimestamp() );
+ $end = $r->getExpiry() == 'infinity' ?
+ wfMsg( 'ipbinfinite' ) :
+ $wgLang->timeanddate( $r->getExpiry() );
+ if( $r->isPage() )
+ $errors[] = array( 'userrestricted-page', $this->getFullText(),
+ $r->getBlockerText(), $r->getReason(), $start, $end );
+ elseif( $r->isNamespace() ) {
+ $errors[] = array( 'userrestricted-namespace', $wgLang->getDisplayNsText( $this->getNamespace() ),
+ $r->getBlockerText(), $r->getReason(), $start, $end );
+ }
+ }
+ }
+
wfProfileOut( __METHOD__ );
return $errors;
}
: array();
}
+ /**
+ * Get the expiry time for the restriction against a given action
+ * @return 14-char timestamp, or 'infinity' if the page is protected forever
+ * or not protected at all, or false if the action is not recognised.
+ */
+ public function getRestrictionExpiry( $action ) {
+ if( !$this->mRestrictionsLoaded ) {
+ $this->loadRestrictions();
+ }
+ return isset( $this->mRestrictionsExpiry[$action] ) ? $this->mRestrictionsExpiry[$action] : false;
+ }
+
/**
* Is there a version of this page in the deletion archive?
* @return \type{\int} the number of archived revisions
}
$pageid = $this->getArticleID();
+ $protected = $this->isProtected();
if( $nt->exists() ) {
$err = $this->moveOverExistingRedirect( $nt, $reason, $createRedirect );
$pageCountChange = ($createRedirect ? 0 : -1);
'cl_sortkey' => $this->getPrefixedText() ),
__METHOD__ );
- # Update watchlists
+ if( $protected ) {
+ # Protect the redirect title as the title used to be...
+ $dbw->insertSelect( 'page_restrictions', 'page_restrictions',
+ array(
+ 'pr_page' => $redirid,
+ 'pr_type' => 'pr_type',
+ 'pr_level' => 'pr_level',
+ 'pr_cascade' => 'pr_cascade',
+ 'pr_user' => 'pr_user',
+ 'pr_expiry' => 'pr_expiry'
+ ),
+ array( 'pr_page' => $pageid ),
+ __METHOD__,
+ array( 'IGNORE' )
+ );
+ # Update the protection log
+ $log = new LogPage( 'protect' );
+ $comment = wfMsgForContent('1movedto2',$this->getPrefixedText(), $nt->getPrefixedText() );
+ $log->addEntry( 'protect', $nt, $comment, array() ); // FIXME: $params?
+ }
+ # Update watchlists
$oldnamespace = $this->getNamespace() & ~1;
$newnamespace = $nt->getNamespace() & ~1;
$oldtitle = $this->getDBkey();
$latest = $this->getLatestRevID();
$dbw = wfGetDB( DB_MASTER );
- $dbw->begin();
# Delete the old redirect. We don't save it to history since
# by definition if we've got here it's rather uninteresting.
}
}
}
- $dbw->commit();
# Log the move
$log = new LogPage( 'move' );
$latest = $this->getLatestRevId();
$dbw = wfGetDB( DB_MASTER );
- $dbw->begin();
$now = $dbw->timestamp();
# Save a null revision in the page's history notifying of the move
}
}
}
- $dbw->commit();
# Log the move
$log = new LogPage( 'move' );