r39631 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39630‎ | r39631 | r39632 >
Date:02:46, 19 August 2008
Author:krimpet
Status:old
Tags:
Comment:
Record plugin autocreation data in the CU logs, e.g. for SUL
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser.i18n.php (modified) (history)
  • /trunk/extensions/CheckUser/CheckUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/CheckUser.i18n.php
@@ -70,6 +70,7 @@
7171 'checkuser-log-ipusers-xff' => '$1 got users for XFF $2',
7272 'checkuser-log-useredits' => '$1 got edits for $2',
7373
 74+ 'checkuser-autocreate-action' => 'was automatically created',
7475 'checkuser-email-action' => 'sent an email to user "$1"',
7576 'checkuser-reset-action' => 'reset password for user "$1"',
7677
Index: trunk/extensions/CheckUser/CheckUser.php
@@ -36,6 +36,7 @@
3737 # Recent changes data hook
3838 global $wgHooks;
3939 $wgHooks['RecentChange_save'][] = 'efUpdateCheckUserData';
 40+$wgHooks['AuthPluginAutoCreate'][] = 'efUpdateAutoCreateData';
4041 $wgHooks['EmailUser'][] = 'efUpdateCUEmailData';
4142 $wgHooks['User::mailPasswordInternal'][] = 'efUpdateCUPasswordResetData';
4243
@@ -113,6 +114,48 @@
114115 }
115116
116117 /**
 118+ * Hook function to store autocreation data from the auth plugin
 119+ * Saves user data into the cu_changes table
 120+ */
 121+function efUpdateAutoCreateData( $user ) {
 122+ wfLoadExtensionMessages( 'CheckUser' );
 123+ // Get IP
 124+ $ip = wfGetIP();
 125+ // Get XFF header
 126+ $xff = wfGetForwardedFor();
 127+ list($xff_ip,$trusted) = efGetClientIPfromXFF( $xff );
 128+ // Our squid XFFs can flood this up sometimes
 129+ $isSquidOnly = efXFFChainIsSquid( $xff );
 130+ // Get agent
 131+ $agent = wfGetAgent();
 132+ $dbw = wfGetDB( DB_MASTER );
 133+ $cuc_id = $dbw->nextSequenceValue( 'cu_changes_cu_id_seq' );
 134+ $rcRow = array(
 135+ 'cuc_id' => $cuc_id,
 136+ 'cuc_page_id' => 0,
 137+ 'cuc_namespace' => NS_USER,
 138+ 'cuc_title' => '',
 139+ 'cuc_minor' => 0,
 140+ 'cuc_user' => User::idFromName($user),
 141+ 'cuc_user_text' => $user,
 142+ 'cuc_actiontext' => wfMsgForContent('checkuser-autocreate-action'),
 143+ 'cuc_comment' => '',
 144+ 'cuc_this_oldid' => 0,
 145+ 'cuc_last_oldid' => 0,
 146+ 'cuc_type' => RC_LOG,
 147+ 'cuc_timestamp' => $dbw->timestamp( wfTimestampNow() ),
 148+ 'cuc_ip' => IP::sanitizeIP($ip),
 149+ 'cuc_ip_hex' => $ip ? IP::toHex( $ip ) : null,
 150+ 'cuc_xff' => !$isSquidOnly ? $xff : '',
 151+ 'cuc_xff_hex' => ($xff_ip && !$isSquidOnly) ? IP::toHex( $xff_ip ) : null,
 152+ 'cuc_agent' => $agent
 153+ );
 154+ $dbw->insert( 'cu_changes', $rcRow, __METHOD__ );
 155+
 156+ return true;
 157+}
 158+
 159+/**
117160 * Hook function to store password reset
118161 * Saves user data into the cu_changes table
119162 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r39667Fix reversion -- r39631 was the basic broken bit, other one was just adjustme...brion22:24, 19 August 2008

Status & tagging log