MediaWiki  1.23.8
RevisionDeleteUser.php
Go to the documentation of this file.
1 <?php
33 
42  private static function setUsernameBitfields( $name, $userId, $op, $dbw ) {
43  if ( !$userId || ( $op !== '|' && $op !== '&' ) ) {
44  return false; // sanity check
45  }
46  if ( !$dbw instanceof DatabaseBase ) {
47  $dbw = wfGetDB( DB_MASTER );
48  }
49 
50  # To suppress, we OR the current bitfields with Revision::DELETED_USER
51  # to put a 1 in the username *_deleted bit. To unsuppress we AND the
52  # current bitfields with the inverse of Revision::DELETED_USER. The
53  # username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x).
54  # The same goes for the sysop-restricted *_deleted bit.
57  if ( $op == '&' ) {
58  $delUser = "~{$delUser}";
59  $delAction = "~{$delAction}";
60  }
61 
62  # Normalize user name
63  $userTitle = Title::makeTitleSafe( NS_USER, $name );
64  $userDbKey = $userTitle->getDBkey();
65 
66  # Hide name from live edits
67  $dbw->update(
68  'revision',
69  array( "rev_deleted = rev_deleted $op $delUser" ),
70  array( 'rev_user' => $userId ),
71  __METHOD__ );
72 
73  # Hide name from deleted edits
74  $dbw->update(
75  'archive',
76  array( "ar_deleted = ar_deleted $op $delUser" ),
77  array( 'ar_user_text' => $name ),
78  __METHOD__
79  );
80 
81  # Hide name from logs
82  $dbw->update(
83  'logging',
84  array( "log_deleted = log_deleted $op $delUser" ),
85  array( 'log_user' => $userId, "log_type != 'suppress'" ),
86  __METHOD__
87  );
88  $dbw->update(
89  'logging',
90  array( "log_deleted = log_deleted $op $delAction" ),
91  array( 'log_namespace' => NS_USER, 'log_title' => $userDbKey,
92  "log_type != 'suppress'" ),
93  __METHOD__
94  );
95 
96  # Hide name from RC
97  $dbw->update(
98  'recentchanges',
99  array( "rc_deleted = rc_deleted $op $delUser" ),
100  array( 'rc_user_text' => $name ),
101  __METHOD__
102  );
103  $dbw->update(
104  'recentchanges',
105  array( "rc_deleted = rc_deleted $op $delAction" ),
106  array( 'rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0' ),
107  __METHOD__
108  );
109 
110  # Hide name from live images
111  $dbw->update(
112  'oldimage',
113  array( "oi_deleted = oi_deleted $op $delUser" ),
114  array( 'oi_user_text' => $name ),
115  __METHOD__
116  );
117 
118  # Hide name from deleted images
119  $dbw->update(
120  'filearchive',
121  array( "fa_deleted = fa_deleted $op $delUser" ),
122  array( 'fa_user_text' => $name ),
123  __METHOD__
124  );
125  # Done!
126  return true;
127  }
128 
129  public static function suppressUserName( $name, $userId, $dbw = null ) {
130  return self::setUsernameBitfields( $name, $userId, '|', $dbw );
131  }
132 
133  public static function unsuppressUserName( $name, $userId, $dbw = null ) {
134  return self::setUsernameBitfields( $name, $userId, '&', $dbw );
135  }
136 }
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:67
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:68
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
RevisionDeleteUser\unsuppressUserName
static unsuppressUserName( $name, $userId, $dbw=null)
Definition: RevisionDeleteUser.php:133
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:33
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
DatabaseBase
Database abstraction object.
Definition: Database.php:219
RevisionDeleteUser
Backend functions for suppressing and unsuppressing all references to a given user,...
Definition: RevisionDeleteUser.php:32
RevisionDeleteUser\setUsernameBitfields
static setUsernameBitfields( $name, $userId, $op, $dbw)
Update *_deleted bitfields in various tables to hide or unhide usernames.
Definition: RevisionDeleteUser.php:42
NS_USER
const NS_USER
Definition: Defines.php:81
RevisionDeleteUser\suppressUserName
static suppressUserName( $name, $userId, $dbw=null)
Definition: RevisionDeleteUser.php:129