/**
* Get the groups for the given user based on the given criteria.
- *
+ *
* Does not return groups the user already belongs to or has once belonged.
- *
+ *
* @param $user The user to get the groups for
* @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
*
switch( $cond[0] ) {
case APCOND_EMAILCONFIRMED:
- if ( User::isValidEmailAddr( $user->getEmail() ) ) {
+ if ( Sanitizer::validateEmail( $user->getEmail() ) ) {
if ( $wgEmailAuthentication ) {
return (bool)$user->getEmailAuthenticationTimestamp();
} else {
/**
* Add the user to the group if he/she meets given criteria.
- *
- * Contrary to autopromotion by \ref $wgAutopromote, the group will be
+ *
+ * Contrary to autopromotion by \ref $wgAutopromote, the group will be
* possible to remove manually via Special:UserRights. In such case it
* will not be re-added automatically. The user will also not lose the
* group if they no longer meet the criteria.
- *
+ *
* @param $event String key in $wgAutopromoteOnce (each one has groups/criteria)
- *
- * @return array Array of groups the user has been promoted to.
- *
+ *
+ * @return array Array of groups the user has been promoted to.
+ *
* @see $wgAutopromoteOnce
*/
public function addAutopromoteOnceGroups( $event ) {
);
}
}
- return $toPromote;
+ return $toPromote;
}
/**
$this->mSkin = null;
$this->mRights = null;
$this->mEffectiveGroups = null;
- $this->mOptions = null;
+ $this->mOptions = null;
if ( $reloadFrom ) {
$this->mLoadedItems = array();
}
return $this->mEffectiveGroups;
}
-
+
/**
- * Returns the groups the user has belonged to.
- *
+ * Returns the groups the user has belonged to.
+ *
* The user may still belong to the returned groups. Compare with getGroups().
- *
+ *
* The function will not return groups the user had belonged to before MW 1.17
- *
- * @return array Names of the groups the user has belonged to.
+ *
+ * @return array Names of the groups the user has belonged to.
*/
function getFormerGroups() {
if( is_null( $this->mFormerGroups ) ) {
foreach( $res as $row ) {
$this->mFormerGroups[] = $row->ufg_group;
}
- }
+ }
return $this->mFormerGroups;
}
-
+
/**
* Get the user's edit count.
* @return Int
$this->load();
$confirmed = true;
if( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
- if( $this->isAnon() )
+ if( $this->isAnon() ) {
return false;
- if( !self::isValidEmailAddr( $this->mEmail ) )
+ }
+ if( !Sanitizer::validateEmail( $this->mEmail ) ) {
return false;
- if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() )
+ }
+ if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
return false;
+ }
return true;
} else {
return $confirmed;
/**
* Get a special type of connection
- * @param $type See openPgConnection() for details.
+ * @param $type string See openPgConnection() for details.
* @return Status
*/
protected function getPgConnection( $type ) {
* Get a connection of a specific PostgreSQL-specific type. Connections
* of a given type are cached.
*
- * PostgreSQL lacks cross-database operations, so after the new database is
- * created, you need to make a separate connection to connect to that
- * database and add tables to it.
+ * PostgreSQL lacks cross-database operations, so after the new database is
+ * created, you need to make a separate connection to connect to that
+ * database and add tables to it.
*
- * New tables are owned by the user that creates them, and MediaWiki's
- * PostgreSQL support has always assumed that the table owner will be
- * $wgDBuser. So before we create new tables, we either need to either
- * connect as the other user or to execute a SET ROLE command. Using a
- * separate connection for this allows us to avoid accidental cross-module
+ * New tables are owned by the user that creates them, and MediaWiki's
+ * PostgreSQL support has always assumed that the table owner will be
+ * $wgDBuser. So before we create new tables, we either need to either
+ * connect as the other user or to execute a SET ROLE command. Using a
+ * separate connection for this allows us to avoid accidental cross-module
* dependencies.
*
* @param $type The type of connection to get:
* - create-db: A connection for creating DBs, suitable for pre-
* installation.
- * - create-schema: A connection to the new DB, for creating schemas and
+ * - create-schema: A connection to the new DB, for creating schemas and
* other similar objects in the new DB.
* - create-tables: A connection with a role suitable for creating tables.
*
- * @return A Status object. On success, a connection object will be in the
+ * @return A Status object. On success, a connection object will be in the
* value member.
*/
protected function openPgConnection( $type ) {
switch ( $type ) {
case 'create-db':
return $this->openConnectionToAnyDB(
- $this->getVar( '_InstallUser' ),
+ $this->getVar( '_InstallUser' ),
$this->getVar( '_InstallPassword' ) );
case 'create-schema':
- return $this->openConnectionWithParams(
+ return $this->openConnectionWithParams(
$this->getVar( '_InstallUser' ),
$this->getVar( '_InstallPassword' ),
$this->getVar( 'wgDBname' ) );
$conn = $status->value;
$superuser = $this->getVar( '_InstallUser' );
- $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
+ $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
array( 'rolname' => $superuser ), __METHOD__ );
return $row;
}
if ( !$perms ) {
return false;
}
- return $perms->rolsuper === 't';
+ return $perms->rolsuper === 't';
}
public function getSettingsForm() {
}
// Existing web account. Test the connection.
- $status = $this->openConnectionToAnyDB(
+ $status = $this->openConnectionToAnyDB(
$this->getVar( 'wgDBuser' ),
$this->getVar( 'wgDBpassword' ) );
if ( !$status->isOK() ) {
return $status;
}
- // The web user is conventionally the table owner in PostgreSQL
- // installations. Make sure the install user is able to create
+ // The web user is conventionally the table owner in PostgreSQL
+ // installations. Make sure the install user is able to create
// objects on behalf of the web user.
if ( $same || $this->canCreateObjectsForWebUser() ) {
return Status::newGood();
try {
$conn->query( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
} catch ( DBQueryError $e ) {
- return Status::newFatal( 'config-install-pg-schema-failed',
+ return Status::newFatal( 'config-install-pg-schema-failed',
$this->getVar( '_InstallUser' ), $schema );
}
}
// If we created a user, alter it now to search the new schema by default
if ( $this->getVar( '_CreateDBAccount' ) ) {
- $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public",
+ $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public",
__METHOD__ );
}
// Create the user
try {
$sql = "CREATE ROLE $safeuser NOCREATEDB LOGIN PASSWORD $safepass";
-
- // If the install user is not a superuser, we need to make the install
+
+ // If the install user is not a superuser, we need to make the install
// user a member of the new user's group, so that the install user will
// be able to create a schema and other objects on behalf of the new user.
if ( !$this->isSuperUser() ) {
$conn->query( $sql, __METHOD__ );
} catch ( DBQueryError $e ) {
- return Status::newFatal( 'config-install-user-create-failed',
+ return Status::newFatal( 'config-install-user-create-failed',
$this->getVar( 'wgDBuser' ), $e->getMessage() );
}
}
}
public function setupPLpgSQL() {
- // Connect as the install user, since it owns the database and so is
+ // Connect as the install user, since it owns the database and so is
// the user that needs to run "CREATE LANGAUGE"
$status = $this->getPgConnection( 'create-schema' );
if ( !$status->isOK() ) {
return Status::newGood();
}
- // plpgsql is not installed, but if we have a pg_pltemplate table, we
+ // plpgsql is not installed, but if we have a pg_pltemplate table, we
// should be able to create it
$exists = $conn->selectField(
array( '"pg_catalog"."pg_class"', '"pg_catalog"."pg_namespace"' ),
// Validate e-mail if provided
$email = $this->getVar( '_AdminEmail' );
- if( $email && !User::isValidEmailAddr( $email ) ) {
+ if( $email && !Sanitizer::validateEmail( $email ) ) {
$this->parent->showError( 'config-admin-error-bademail' );
$retVal = false;
}
* MediaHanlder::METADATA_COMPATIBLE if metadata is old but backwards
* compatible (which may or may not trigger a metadata reload).
*/
- function isMetadataValid( $image, $metadata ) {
+ function isMetadataValid( $image, $metadata ) {
return self::METADATA_GOOD;
}
function getThumbType( $ext, $mime, $params = null ) {
$magic = MimeMagic::singleton();
if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
- // The extension is not valid for this mime type and we do
+ // The extension is not valid for this mime type and we do
// recognize the mime type
$extensions = $magic->getExtensionsForType( $mime );
if ( $extensions ) {
return array( strtok( $extensions, ' ' ), $mime );
}
}
-
+
// The extension is correct (true) or the mime type is unknown to
// MediaWiki (null)
return array( $ext, $mime );
/**
* This is used to generate an array element for each metadata value
* That array is then used to generate the table of metadata values
- * on the image page
+ * on the image page
*
* @param &$array Array An array containing elements for each type of visibility
* and each of those elements being an array of metadata items. This function adds
* a value to that array.
- * @param $visibility string ('visible' or 'collapsed') if this value is hidden
+ * @param $visbility string ('visible' or 'collapsed') if this value is hidden
* by default.
* @param $type String type of metadata tag (currently always 'exif')
* @param $id String the name of the metadata tag (like 'artist' for example).
$msgName = "$type-$id";
if ( wfEmptyMsg( $msgName ) ) {
// This is for future compatibility when using instant commons.
- // So as to not display as ugly a name if a new metadata
+ // So as to not display as ugly a name if a new metadata
// property is defined that we don't know about
// (not a major issue since such a property would be collapsed
// by default).
/**
* File validation hook called on upload.
*
- * If the file at the given local path is not valid, or its MIME type does not
+ * If the file at the given local path is not valid, or its MIME type does not
* match the handler class, a Status object should be returned containing
* relevant errors.
- *
+ *
* @param $fileName The local path to the file.
* @return Status object
*/
if( empty( $code ) ) {
if( $wgUser->isLoggedIn() ) {
- if( User::isValidEmailAddr( $wgUser->getEmail() ) ) {
+ if( Sanitizer::validateEmail( $wgUser->getEmail() ) ) {
$this->showRequestForm();
} else {
$wgOut->addWikiMsg( 'confirmemail_noemail' );
}
# Send out an email authentication message if needed
- if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) ) {
+ if( $wgEmailAuthentication && Sanitizer::validateEmail( $u->getEmail() ) ) {
$status = $u->sendConfirmationMail();
if( $status->isGood() ) {
$wgOut->addWikiMsg( 'confirmemail_oncreate' );
return false;
}
- if( !empty( $this->mEmail ) && !User::isValidEmailAddr( $this->mEmail ) ) {
+ if( !empty( $this->mEmail ) && !Sanitizer::validateEmail( $this->mEmail ) ) {
$this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
return false;
}
# Run any hooks; display injected HTML
$injected_html = '';
$welcome_creation_msg = 'welcomecreation';
-
+
wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) );
-
+
//let any extensions change what message is shown
wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) );
-
+
$this->displaySuccessfulLogin( $welcome_creation_msg, $injected_html );
}
if( $msgname ){
$wgOut->addWikiMsg( $msgname, wfEscapeWikiText( $wgUser->getName() ) );
}
-
+
$wgOut->addHTML( $injected_html );
if ( !empty( $this->mReturnTo ) ) {
$block_reason,
$block->getBlocker()->getName()
);
-
+
$wgOut->returnToMain( false );
}