function newFromName( $name ) {
$u = new User();
+ # Force usernames to capital
+ global $wgContLang;
+ $name = $wgContLang->ucfirst( $name );
+
# Clean up name according to title rules
-
$t = Title::newFromText( $name );
if( is_null( $t ) ) {
- return NULL;
- } else {
- $u->setName( $t->getText() );
- $u->setId( $u->idFromName( $t->getText() ) );
- return $u;
+ return null;
+ }
+
+ # Reject various classes of invalid names
+ $canonicalName = $t->getText();
+ if( !User::isValidUserName( $canonicalName ) ) {
+ return null;
}
+
+ $u->setName( $canonicalName );
+ $u->setId( $u->idFromName( $t->getText() ) );
+ return $u;
}
/**
*
* @param string $name
* @return bool
+ * @static
*/
function isValidUserName( $name ) {
global $wgContLang, $wgMaxNameChars;
if ( $name == ''
- || $this->isIP( $name )
+ || User::isIP( $name )
|| strpos( $name, '/' ) !== false
|| strlen( $name ) > $wgMaxNameChars
|| $name != $wgContLang->ucfirst( $name ) )
*
* @param string $password
* @return bool
+ * @static
*/
function isValidPassword( $password ) {
global $wgMinimalPasswordLength;
(false !== strpos( $addr, '@' ) );
}
+ /**
+ * Count the number of edits of a user
+ *
+ * @param int $uid The user ID to check
+ * @return int
+ */
+ function edits( $uid ) {
+ $fname = 'User::editCount';
+
+ $dbr =& wfGetDB( DB_SLAVE );
+ return $dbr->selectField(
+ 'revision', 'count(*)',
+ array( 'rev_user' => $uid ),
+ $fname
+ );
+ }
+
/**
* probably return a random password
* @return string probably a random password
$this->getBlockedStatus( $bFromSlave );
return $this->mBlockedby !== 0;
}
+
+ /**
+ * Check if user is blocked from editing a particular article
+ */
+ function isBlockedFrom( $title, $bFromSlave = false ) {
+ global $wgBlockAllowsUTEdit;
+ if ( $wgBlockAllowsUTEdit && $title->getText() === $this->getName() &&
+ $title->getNamespace() == NS_USER_TALK )
+ {
+ return false;
+ } else {
+ return $this->isBlocked( $bFromSlave );
+ }
+ }
/**
* Get name of blocker
$fname = 'User::saveNewtalk';
+ $changed = false;
+
if ( wfReadOnly() ) { return ; }
$dbr =& wfGetDB( DB_SLAVE );
$dbw =& wfGetDB( DB_MASTER );
+ $changed = false;
if ( $wgUseEnotif ) {
if ( ! $this->getNewtalk() ) {
# Delete the watchlist entry for user_talk page X watched by user X
$confstr = $this->getOption( 'math' );
$confstr .= '!' . $this->getOption( 'stubthreshold' );
- $confstr .= '!' . $this->getOption( 'editsection' );
$confstr .= '!' . $this->getOption( 'date' );
$confstr .= '!' . $this->getOption( 'numberheadings' );
$confstr .= '!' . $this->getOption( 'language' );