25$options = [
'list',
'nowarn',
'quiet',
'usage',
'dry' ];
28require_once __DIR__ .
'/commandLine.inc';
66 $list = isset( $opts[
'list'] );
67 $usage = isset( $opts[
'usage'] ) && ( count(
$args ) <= 1 );
68 $change = isset( $opts[
'old'] ) && isset( $opts[
'new'] ) && ( count(
$args ) <= 1 );
71 $isValid = ( ( $list + $usage + $change ) == 1 );
85 $this->mQuick = isset( $opts[
'nowarn'] );
86 $this->mQuiet = isset( $opts[
'quiet'] );
87 $this->mDry = isset( $opts[
'dry'] );
90 if ( isset( $opts[
'list'] ) ) {
91 $this->mMode =
'LISTER';
92 } elseif ( isset( $opts[
'usage'] ) ) {
93 $this->mMode =
'USAGER';
94 $this->mAnOption = isset(
$args[0] ) ?
$args[0] :
false;
95 } elseif ( isset( $opts[
'old'] ) && isset( $opts[
'new'] ) ) {
96 $this->mMode =
'CHANGER';
97 $this->mOldValue = $opts[
'old'];
98 $this->mNewValue = $opts[
'new'];
99 $this->mAnOption =
$args[0];
101 die(
"There is a bug in the software, this should never happen\n" );
112 if ( !$this->mReady ) {
116 $this->{$this->mMode}();
125 $def = User::getDefaultOptions();
129 $maxOpt = max( $maxOpt, strlen(
$opt ) );
141 $defaultOptions = User::getDefaultOptions();
145 $result =
$dbr->select(
'user',
151 foreach ( $result as $id ) {
152 $user = User::newFromId( $id->user_id );
155 if ( $this->mAnOption ) {
156 if ( !array_key_exists( $this->mAnOption, $defaultOptions ) ) {
157 print "Invalid user option. Use --list to see valid choices\n";
161 $userValue = $user->getOption( $this->mAnOption );
162 if ( $userValue <> $defaultOptions[$this->mAnOption] ) {
169 foreach ( $defaultOptions as $name => $defaultValue ) {
170 $userValue = $user->getOption( $name );
171 if ( $userValue <> $defaultValue ) {
180 foreach (
$ret as $optionName => $usageStats ) {
181 print "Usage for <$optionName> (default: '{$defaultOptions[$optionName]}'):\n";
182 foreach ( $usageStats as
$value => $count ) {
183 print " $count user(s): '$value'\n";
197 $result =
$dbr->select(
'user',
203 foreach ( $result as $id ) {
204 $user = User::newFromId( $id->user_id );
206 $curValue = $user->getOption( $this->mAnOption );
209 if ( $curValue == $this->mOldValue ) {
210 if ( !$this->mQuiet ) {
211 print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " .
212 "to '{$this->mNewValue}'): ";
216 $user->setOption( $this->mAnOption, $this->mNewValue );
219 if ( !$this->mDry ) {
220 $user->saveSettings();
222 if ( !$this->mQuiet ) {
225 } elseif ( !$this->mQuiet ) {
226 print "Not changing '$username' using <{$this->mAnOption}> = '$curValue'\n";
236 $def = User::getDefaultOptions();
238 foreach ( $def as $optname => $defaultValue ) {
239 array_push(
$ret, $optname );
248This script pass through all users and change one of their
options.
249The
new option is NOT validated.
252 php userOptions.php --list
253 php userOptions.php [user option] --usage
254 php userOptions.php [
options] <user option> --old <old value> --new <new value>
257 --
list : list available user
options and their
default value
259 --usage : report all
options statistics or just one
if you specify it.
261 --old <old value> : the value to look
for
262 --new <new value> :
new value to update users with
265 --nowarn: hides the 5 seconds warning
266 --quiet :
do not
print what is happening
278 if ( $this->mQuick ) {
283The script is about to change the
skin for ALL USERS in the database.
284Users with option <$this->mAnOption> =
'$this->mOldValue' will be
made to use
'$this->mNewValue'.
286Abort with control-
c in the next five seconds....
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed or on behalf the Licensor for the purpose of discussing and improving the but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work Grant of Copyright License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty irrevocable copyright license to prepare Derivative Works publicly publicly and distribute the Work and such Derivative Works in Source or Object form Grant of Patent License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty have made
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfCountDown( $seconds)
Count down from $seconds to zero on the terminal, with a one-second pause between showing each number...
CHANGER()
Change our users options.
run()
Dumb stuff to run a mode.
initializeOpts( $opts, $args)
load script options in the object
LISTER()
List default options and their value.
checkOpts( $opts, $args)
This is used to check options.
__construct( $opts, $args)
Constructor.
USAGER()
List options usage.
static showUsageAndExit()
static getDefaultOptionsNames()
Return an array of option names.
warn()
The warning message and countdown.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a save
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a skin(according to that user 's preference)
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
this hook is for auditing only or null if authentication failed before getting that far $username
Allows to change the fields on the form that will be generated $name
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings