<?php
-if (!defined( 'MEDIAWIKI' ))
+if( !defined( 'MEDIAWIKI' ) )
die;
class ChangeTags {
static function formatSummaryRow( $tags, $page ) {
- if (!$tags)
- return array('',array());
+ if( !$tags )
+ return array( '', array() );
$classes = array();
-
+
$tags = explode( ',', $tags );
$displayTags = array();
foreach( $tags as $tag ) {
- $displayTags[] = Xml::tags( 'span',
- array( 'class' => "mw-tag-marker ".
- Sanitizer::escapeClass("mw-tag-marker-$tag") ),
- self::tagDescription( $tag ) );
+ $displayTags[] = Xml::tags(
+ 'span',
+ array( 'class' => 'mw-tag-marker ' .
+ Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ),
+ self::tagDescription( $tag )
+ );
$classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
}
static function tagDescription( $tag ) {
$msg = wfMsgExt( "tag-$tag", 'parseinline' );
if ( wfEmptyMsg( "tag-$tag", $msg ) ) {
- return htmlspecialchars($tag);
+ return htmlspecialchars( $tag );
}
return $msg;
}
## Basic utility method to add tags to a particular change, given its rc_id, rev_id and/or log_id.
- static function addTags( $tags, $rc_id=null, $rev_id=null, $log_id=null, $params = null ) {
- if ( !is_array($tags) ) {
+ static function addTags( $tags, $rc_id = null, $rev_id = null, $log_id = null, $params = null ) {
+ if ( !is_array( $tags ) ) {
$tags = array( $tags );
}
$tags = array_filter( $tags ); // Make sure we're submitting all tags...
- if (!$rc_id && !$rev_id && !$log_id) {
+ if( !$rc_id && !$rev_id && !$log_id ) {
throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" );
}
$dbr = wfGetDB( DB_SLAVE );
// Might as well look for rcids and so on.
- if (!$rc_id) {
+ if( !$rc_id ) {
$dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
- if ($log_id) {
+ if( $log_id ) {
$rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ );
- } elseif ($rev_id) {
+ } elseif( $rev_id ) {
$rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ );
}
- } elseif (!$log_id && !$rev_id) {
+ } elseif( !$log_id && !$rev_id ) {
$dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
$log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ );
$rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ );
$prevTags = $prevTags ? $prevTags : '';
$prevTags = array_filter( explode( ',', $prevTags ) );
$newTags = array_unique( array_merge( $prevTags, $tags ) );
- sort($prevTags);
- sort($newTags);
+ sort( $prevTags );
+ sort( $newTags );
if ( $prevTags == $newTags ) {
// No change.
}
$dbw = wfGetDB( DB_MASTER );
- $dbw->replace( 'tag_summary', array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ), array_filter( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ), __METHOD__ );
+ $dbw->replace(
+ 'tag_summary',
+ array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ),
+ array_filter( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ),
+ __METHOD__
+ );
// Insert the tags rows.
$tagsRows = array();
foreach( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally.
- $tagsRows[] = array_filter( array( 'ct_tag' => $tag, 'ct_rc_id' => $rc_id, 'ct_log_id' => $log_id, 'ct_rev_id' => $rev_id, 'ct_params' => $params ) );
+ $tagsRows[] = array_filter(
+ array(
+ 'ct_tag' => $tag,
+ 'ct_rc_id' => $rc_id,
+ 'ct_log_id' => $log_id,
+ 'ct_rev_id' => $rev_id,
+ 'ct_params' => $params
+ )
+ );
}
- $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array('IGNORE') );
+ $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array( 'IGNORE' ) );
return true;
}
* Applies all tags-related changes to a query.
* Handles selecting tags, and filtering.
* Needs $tables to be set up properly, so we can figure out which join conditions to use.
- */
+ */
static function modifyDisplayQuery( &$tables, &$fields, &$conds,
&$join_conds, &$options, $filter_tag = false ) {
global $wgRequest, $wgUseTagFilter;
-
- if ($filter_tag === false) {
+
+ if( $filter_tag === false ) {
$filter_tag = $wgRequest->getVal( 'tagfilter' );
}
// Figure out which conditions can be done.
$join_field = '';
- if ( in_array('recentchanges', $tables) ) {
+ if ( in_array( 'recentchanges', $tables ) ) {
$join_cond = 'rc_id';
- } elseif( in_array('logging', $tables) ) {
+ } elseif( in_array( 'logging', $tables ) ) {
$join_cond = 'log_id';
- } elseif ( in_array('revision', $tables) ) {
+ } elseif ( in_array( 'revision', $tables ) ) {
$join_cond = 'rev_id';
} else {
- throw new MWException( "Unable to determine appropriate JOIN condition for tagging." );
+ throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
}
// JOIN on tag_summary
$tables[] = 'tag_summary';
$join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
$fields[] = 'ts_tags';
-
- if ($wgUseTagFilter && $filter_tag) {
+
+ if( $wgUseTagFilter && $filter_tag ) {
// Somebody wants to filter on a tag.
// Add an INNER JOIN on change_tag
*/
static function buildTagFilterSelector( $selected='', $fullForm = false /* used to put a full form around the selector */ ) {
global $wgUseTagFilter;
-
+
if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) )
return $fullForm ? '' : array();
-
+
global $wgTitle;
-
+
$data = array( wfMsgExt( 'tag-filter', 'parseinline' ), Xml::input( 'tagfilter', 20, $selected ) );
- if (!$fullForm) {
+ if ( !$fullForm ) {
return $data;
}
global $wgMemc;
$key = wfMemcKey( 'valid-tags' );
- if ($tags = $wgMemc->get( $key ))
+ if ( $tags = $wgMemc->get( $key ) )
return $tags;
-
+
$emptyTags = array();
// Some DB stuff
while( $row = $res->fetchObject() ) {
$emptyTags[] = $row->vt_tag;
}
-
- wfRunHooks( 'ListDefinedTags', array(&$emptyTags) );
+
+ wfRunHooks( 'ListDefinedTags', array( &$emptyTags ) );
$emptyTags = array_filter( array_unique( $emptyTags ) );
# Illegal name
return null;
}
-
- if ( isset(self::$idCacheByName[$name]) ) {
+
+ if ( isset( self::$idCacheByName[$name] ) ) {
return self::$idCacheByName[$name];
}
-
+
$dbr = wfGetDB( DB_SLAVE );
$s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ );
} else {
$result = $s->user_id;
}
-
+
self::$idCacheByName[$name] = $result;
-
- if ( count(self::$idCacheByName) > 1000 ) {
+
+ if ( count( self::$idCacheByName ) > 1000 ) {
self::$idCacheByName = array();
}
-
+
return $result;
}
return false;
# Clean up name according to title rules
- $t = ($validate === 'valid') ?
+ $t = ( $validate === 'valid' ) ?
Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name );
# Check for invalid titles
if( is_null( $t ) ) {
}
break;
default:
- throw new MWException( 'Invalid parameter value for $validate in '.__METHOD__ );
+ throw new MWException( 'Invalid parameter value for $validate in ' . __METHOD__ );
}
return $name;
}
$l = strlen( $pwchars ) - 1;
$pwlength = max( 7, $wgMinimalPasswordLength );
- $digit = mt_rand(0, $pwlength - 1);
+ $digit = mt_rand( 0, $pwlength - 1 );
$np = '';
for ( $i = 0; $i < $pwlength; $i++ ) {
- $np .= $i == $digit ? chr( mt_rand(48, 57) ) : $pwchars{ mt_rand(0, $l)};
+ $np .= $i == $digit ? chr( mt_rand( 48, 57 ) ) : $pwchars{ mt_rand( 0, $l ) };
}
return $np;
}
$variant = $wgContLang->getPreferredVariant( false );
$defOpt['variant'] = $variant;
$defOpt['language'] = $variant;
- foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
- $defOpt['searchNs'.$nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
+ foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
+ $defOpt['searchNs'.$nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
}
$defOpt['skin'] = $wgDefaultSkin;
# Check if we are looking at an IP or a logged-in user
if ( $this->isIP( $this->getName() ) ) {
$ip = $this->getName();
- }
- else {
+ } else {
# Check if we are looking at the current user
# If we don't, and the user is logged in, we don't know about
# his IP / autoblock status, so ignore autoblock of current user's IP
if ( $this->getID() != $wgUser->getID() ) {
$ip = '';
- }
- else {
+ } else {
# Get IP of current user
$ip = wfGetIP();
}
$this->mBlock = new Block();
$this->mBlock->fromMaster( !$bFromSlave );
if ( $this->mBlock->load( $ip , $this->mId ) ) {
- wfDebug( __METHOD__.": Found block.\n" );
+ wfDebug( __METHOD__ . ": Found block.\n" );
$this->mBlockedby = $this->mBlock->mBy;
$this->mBlockreason = $this->mBlock->mReason;
$this->mHideName = $this->mBlock->mHideName;
}
# Proxy blocking
- if ( !$this->isAllowed('proxyunbannable') && !in_array( $ip, $wgProxyWhitelist ) ) {
+ if ( !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) {
# Local list
if ( wfIsLocallyBlockedProxy( $ip ) ) {
$this->mBlockedby = wfMsg( 'proxyblocker' );
$found = false;
$host = '';
// FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170)
- if( IP::isIPv4($ip) ) {
+ if( IP::isIPv4( $ip ) ) {
# Make hostname
$host = "$ip.$base";
// Deprecated, but kept for backwards-compatibility config
return false;
}
- return !$this->isAllowed('noratelimit');
+ return !$this->isAllowed( 'noratelimit' );
}
/**
* @param $action \string Action to enforce; 'edit' if unspecified
* @return \bool True if a rate limiter was tripped
*/
- function pingLimiter( $action='edit' ) {
-
+ function pingLimiter( $action = 'edit' ) {
# Call the 'PingLimiter' hook
$result = false;
if( !wfRunHooks( 'PingLimiter', array( &$this, $action, $result ) ) ) {
}
// Set the user limit key
if ( $userLimit !== false ) {
- wfDebug( __METHOD__.": effective user limit: $userLimit\n" );
+ wfDebug( __METHOD__ . ": effective user limit: $userLimit\n" );
$keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit;
}
$count = $wgMemc->get( $key );
if( $count ) {
if( $count > $max ) {
- wfDebug( __METHOD__.": tripped! $key at $count $summary\n" );
+ wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
if( $wgRateLimitLog ) {
@error_log( wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog );
}
$triggered = true;
} else {
- wfDebug( __METHOD__.": ok. $key at $count $summary\n" );
+ wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );
}
} else {
- wfDebug( __METHOD__.": adding record for $key $summary\n" );
+ wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
$wgMemc->add( $key, 1, intval( $period ) );
}
$wgMemc->incr( $key );
function isBlockedFrom( $title, $bFromSlave = false ) {
global $wgBlockAllowsUTEdit;
wfProfileIn( __METHOD__ );
- wfDebug( __METHOD__.": enter\n" );
+ wfDebug( __METHOD__ . ": enter\n" );
- wfDebug( __METHOD__.": asking isBlocked()\n" );
+ wfDebug( __METHOD__ . ": asking isBlocked()\n" );
$blocked = $this->isBlocked( $bFromSlave );
- $allowUsertalk = ($wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false);
+ $allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false );
# If a user's name is suppressed, they cannot make edits anywhere
if ( !$this->mHideName && $allowUsertalk && $title->getText() === $this->getName() &&
$title->getNamespace() == NS_USER_TALK ) {
$blocked = false;
- wfDebug( __METHOD__.": self-talk page, ignoring any blocks\n" );
+ wfDebug( __METHOD__ . ": self-talk page, ignoring any blocks\n" );
}
wfProfileOut( __METHOD__ );
return $blocked;
*/
function getBlockId() {
$this->getBlockedStatus();
- return ($this->mBlock ? $this->mBlock->mId : false);
+ return ( $this->mBlock ? $this->mBlock->mId : false );
}
/**
*/
function getNewMessageLinks() {
$talks = array();
- if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
+ if( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) )
return $talks;
- if (!$this->getNewtalk())
+ if( !$this->getNewtalk() )
return array();
$up = $this->getUserPage();
$utp = $up->getTalkPage();
- return array(array("wiki" => wfWikiID(), "link" => $utp->getLocalURL()));
+ return array( array( 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL() ) );
}
-
/**
* Internal uncached check for new messages
*
__METHOD__,
'IGNORE' );
if ( $dbw->affectedRows() ) {
- wfDebug( __METHOD__.": set on ($field, $id)\n" );
+ wfDebug( __METHOD__ . ": set on ($field, $id)\n" );
return true;
} else {
- wfDebug( __METHOD__." already set ($field, $id)\n" );
+ wfDebug( __METHOD__ . " already set ($field, $id)\n" );
return false;
}
}
array( $field => $id ),
__METHOD__ );
if ( $dbw->affectedRows() ) {
- wfDebug( __METHOD__.": killed on ($field, $id)\n" );
+ wfDebug( __METHOD__ . ": killed on ($field, $id)\n" );
return true;
} else {
- wfDebug( __METHOD__.": already gone ($field, $id)\n" );
+ wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
return false;
}
}
*/
function validateCache( $timestamp ) {
$this->load();
- return ($timestamp >= $this->mTouched);
+ return ( $timestamp >= $this->mTouched );
}
/**
function setOption( $oname, $val ) {
$this->load();
$this->loadOptions();
-
+
if ( $oname == 'skin' ) {
# Clear cached skin, so the new one displays immediately in Special:Preferences
unset( $this->mSkin );
}
-
+
// Explicitly NULL values should refer to defaults
global $wgDefaultUserOptions;
- if( is_null($val) && isset($wgDefaultUserOptions[$oname]) ) {
+ if( is_null( $val ) && isset( $wgDefaultUserOptions[$oname] ) ) {
$val = $wgDefaultUserOptions[$oname];
}
-
+
$this->mOptions[$oname] = $val;
}
* @return \int User'e edit count
*/
function getEditCount() {
- if ($this->getId()) {
+ if( $this->getId() ) {
if ( !isset( $this->mEditCount ) ) {
/* Populate the count, if it has not been populated yet */
- $this->mEditCount = User::edits($this->mId);
+ $this->mEditCount = User::edits( $this->mId );
}
return $this->mEditCount;
} else {
$this->invalidateCache();
}
-
/**
* Get whether the user is logged in
* @return \bool True or false
}
/**
- * Check whether to enable recent changes patrol features for this user
- * @return \bool True or false
- */
+ * Check whether to enable recent changes patrol features for this user
+ * @return \bool True or false
+ */
public function useRCPatrol() {
global $wgUseRCPatrol;
- return( $wgUseRCPatrol && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
+ return( $wgUseRCPatrol && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
}
/**
- * Check whether to enable new pages patrol features for this user
- * @return \bool True or false
- */
+ * Check whether to enable new pages patrol features for this user
+ * @return \bool True or false
+ */
public function useNPPatrol() {
global $wgUseRCPatrol, $wgUseNPPatrol;
- return( ($wgUseRCPatrol || $wgUseNPPatrol) && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
+ return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
}
/**
* @todo FIXME : need to check the old failback system [AV]
*/
function &getSkin( $t = null ) {
- if ( ! isset( $this->mSkin ) ) {
+ if ( !isset( $this->mSkin ) ) {
wfProfileIn( __METHOD__ );
global $wgHiddenPrefs;
# get the user skin
global $wgRequest;
$userSkin = $this->getOption( 'skin' );
- $userSkin = $wgRequest->getVal('useskin', $userSkin);
+ $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
} else {
# if we're not allowing users to override, then use the default
global $wgDefaultSkin;
return;
}
- if ($title->getNamespace() == NS_USER_TALK &&
+ if( $title->getNamespace() == NS_USER_TALK &&
$title->getText() == $this->getName() ) {
- if (!wfRunHooks('UserClearNewTalkNotification', array(&$this)))
+ if( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) )
return;
$this->setNewtalk( false );
}
// The query to find out if it is watched is cached both in memcached and per-invocation,
// and when it does have to be executed, it can be on a slave
// If this is the user's newtalk page, we always update the timestamp
- if ($title->getNamespace() == NS_USER_TALK &&
- $title->getText() == $wgUser->getName())
+ if( $title->getNamespace() == NS_USER_TALK &&
+ $title->getText() == $wgUser->getName() )
{
$watched = true;
} elseif ( $this->getId() == $wgUser->getId() ) {
* @private
*/
function decodeOptions( $str ) {
- if (!$str)
+ if( !$str )
return;
-
+
$this->mOptionsLoaded = true;
$this->mOptionOverrides = array();
-
+
$this->mOptions = array();
$a = explode( "\n", $str );
foreach ( $a as $s ) {
* @param $exp \int Expiration time, as a UNIX time value;
* if 0 or not specified, use the default $wgCookieExpiration
*/
- protected function setCookie( $name, $value, $exp=0 ) {
+ protected function setCookie( $name, $value, $exp = 0 ) {
global $wgRequest;
$wgRequest->response()->setcookie( $name, $value, $exp );
}
* Log this user out.
*/
function logout() {
- if( wfRunHooks( 'UserLogout', array(&$this) ) ) {
+ if( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
$this->doLogout();
}
}
'user_email' => $this->mEmail,
'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
'user_options' => '',
- 'user_touched' => $dbw->timestamp($this->mTouched),
+ 'user_touched' => $dbw->timestamp( $this->mTouched ),
'user_token' => $this->mToken,
'user_email_token' => $this->mEmailToken,
'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
* they've successfully logged in from.
*/
function spreadBlock() {
- wfDebug( __METHOD__."()\n" );
+ wfDebug( __METHOD__ . "()\n" );
$this->load();
if ( $this->mId == 0 ) {
return;
return;
}
- $userblock->doAutoblock( wfGetIp() );
-
+ $userblock->doAutoblock( wfGetIP() );
}
/**
if ( $wgUseDynamicDates ) {
$confstr .= '!' . $this->getDatePreference();
}
- $confstr .= '!' . ($this->getOption( 'numberheadings' ) ? '1' : '');
+ $confstr .= '!' . ( $this->getOption( 'numberheadings' ) ? '1' : '' );
$confstr .= '!' . $wgLang->getCode();
$confstr .= '!' . $this->getOption( 'thumbsize' );
// add in language specific options, if any
function confirmationTokenUrl( $token ) {
return $this->getTokenUrl( 'ConfirmEmail', $token );
}
+
/**
* Return a URL the user can use to invalidate their email address.
* @param $token \string Accepts the email confirmation token
array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
}
}
- return array_unique($rights);
+ return array_unique( $rights );
}
/**
global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$groups = array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() );
- if( empty($wgAddGroups[$group]) ) {
+ if( empty( $wgAddGroups[$group] ) ) {
// Don't add anything to $groups
} elseif( $wgAddGroups[$group] === true ) {
// You get everything
$groups['add'] = self::getAllGroups();
- } elseif( is_array($wgAddGroups[$group]) ) {
+ } elseif( is_array( $wgAddGroups[$group] ) ) {
$groups['add'] = $wgAddGroups[$group];
}
// Same thing for remove
- if( empty($wgRemoveGroups[$group]) ) {
- } elseif($wgRemoveGroups[$group] === true ) {
+ if( empty( $wgRemoveGroups[$group] ) ) {
+ } elseif( $wgRemoveGroups[$group] === true ) {
$groups['remove'] = self::getAllGroups();
- } elseif( is_array($wgRemoveGroups[$group]) ) {
+ } elseif( is_array( $wgRemoveGroups[$group] ) ) {
$groups['remove'] = $wgRemoveGroups[$group];
}
// Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
- if( empty($wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
- foreach($wgGroupsAddToSelf as $key => $value) {
- if( is_int($key) ) {
+ if( empty( $wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
+ foreach( $wgGroupsAddToSelf as $key => $value ) {
+ if( is_int( $key ) ) {
$wgGroupsAddToSelf['user'][] = $value;
}
}
}
- if( empty($wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
- foreach($wgGroupsRemoveFromSelf as $key => $value) {
- if( is_int($key) ) {
+ if( empty( $wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
+ foreach( $wgGroupsRemoveFromSelf as $key => $value ) {
+ if( is_int( $key ) ) {
$wgGroupsRemoveFromSelf['user'][] = $value;
}
}
}
// Now figure out what groups the user can add to him/herself
- if( empty($wgGroupsAddToSelf[$group]) ) {
+ if( empty( $wgGroupsAddToSelf[$group] ) ) {
} elseif( $wgGroupsAddToSelf[$group] === true ) {
// No idea WHY this would be used, but it's there
$groups['add-self'] = User::getAllGroups();
- } elseif( is_array($wgGroupsAddToSelf[$group]) ) {
+ } elseif( is_array( $wgGroupsAddToSelf[$group] ) ) {
$groups['add-self'] = $wgGroupsAddToSelf[$group];
}
- if( empty($wgGroupsRemoveFromSelf[$group]) ) {
+ if( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
} elseif( $wgGroupsRemoveFromSelf[$group] === true ) {
$groups['remove-self'] = User::getAllGroups();
- } elseif( is_array($wgGroupsRemoveFromSelf[$group]) ) {
+ } elseif( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
$groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
}
// Okay, it's not so simple, we will have to go through the arrays
$groups = array(
- 'add' => array(),
- 'remove' => array(),
- 'add-self' => array(),
- 'remove-self' => array() );
+ 'add' => array(),
+ 'remove' => array(),
+ 'add-self' => array(),
+ 'remove-self' => array()
+ );
$addergroups = $this->getEffectiveGroups();
- foreach ($addergroups as $addergroup) {
+ foreach( $addergroups as $addergroup ) {
$groups = array_merge_recursive(
- $groups, $this->changeableByGroup($addergroup)
+ $groups, $this->changeableByGroup( $addergroup )
);
$groups['add'] = array_unique( $groups['add'] );
$groups['remove'] = array_unique( $groups['remove'] );
*/
public function addNewUserLogEntry( $byEmail = false ) {
global $wgUser, $wgContLang, $wgNewUserLog;
- if( empty($wgNewUserLog) ) {
+ if( empty( $wgNewUserLog ) ) {
return true; // disabled
}
$talk = $wgContLang->getFormattedNsText( NS_TALK );
*/
public function addNewUserLogEntryAutoCreate() {
global $wgNewUserLog;
- if( empty($wgNewUserLog) ) {
+ if( empty( $wgNewUserLog ) ) {
return true; // disabled
}
$log = new LogPage( 'newusers', false );
$log->addEntry( 'autocreate', $this->getUserPage(), '', array( $this->getId() ) );
return true;
}
-
+
protected function loadOptions() {
$this->load();
- if ($this->mOptionsLoaded || !$this->getId() )
+ if ( $this->mOptionsLoaded || !$this->getId() )
return;
-
+
$this->mOptions = self::getDefaultOptions();
-
+
// Maybe load from the object
-
- if ( !is_null($this->mOptionOverrides) ) {
- wfDebug( "Loading options for user ".$this->getId()." from override cache.\n" );
+ if ( !is_null( $this->mOptionOverrides ) ) {
+ wfDebug( "Loading options for user " . $this->getId() . " from override cache.\n" );
foreach( $this->mOptionOverrides as $key => $value ) {
$this->mOptions[$key] = $value;
}
} else {
- wfDebug( "Loading options for user ".$this->getId()." from database.\n" );
+ wfDebug( "Loading options for user " . $this->getId() . " from database.\n" );
// Load from database
$dbr = wfGetDB( DB_SLAVE );
-
- $res = $dbr->select( 'user_properties',
- '*',
- array('up_user' => $this->getId()),
- __METHOD__
- );
-
+
+ $res = $dbr->select(
+ 'user_properties',
+ '*',
+ array( 'up_user' => $this->getId() ),
+ __METHOD__
+ );
+
while( $row = $dbr->fetchObject( $res ) ) {
$this->mOptionOverrides[$row->up_property] = $row->up_value;
$this->mOptions[$row->up_property] = $row->up_value;
}
}
-
+
$this->mOptionsLoaded = true;
-
+
wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) );
}
-
+
protected function saveOptions() {
global $wgAllowPrefChange;
// Allow hooks to abort, for instance to save to a global profile.
// Reset options to default state before saving.
- if (!wfRunHooks( 'UserSaveOptions', array($this, &$saveOptions) ) )
+ if( !wfRunHooks( 'UserSaveOptions', array( $this, &$saveOptions ) ) )
return;
-
+
foreach( $saveOptions as $key => $value ) {
# Don't bother storing default values
if ( ( is_null( self::getDefaultOption( $key ) ) &&
}
if ( $extuser && isset( $wgAllowPrefChange[$key] ) ) {
switch ( $wgAllowPrefChange[$key] ) {
- case 'local': case 'message':
+ case 'local':
+ case 'message':
break;
- case 'semiglobal': case 'global':
+ case 'semiglobal':
+ case 'global':
$extuser->setPref( $key, $value );
}
}
}
-
+
$dbw->begin();
$dbw->delete( 'user_properties', array( 'up_user' => $this->getId() ), __METHOD__ );
$dbw->insert( 'user_properties', $insert_rows, __METHOD__ );