r52204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52203‎ | r52204 | r52205 >
Date:16:30, 20 June 2009
Author:btongminh
Status:deferred
Tags:
Comment:
Fixes for exporting.
Modified paths:
  • /branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.php (modified) (history)
  • /branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AmExport.php (modified) (history)
  • /branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssProperties.php (modified) (history)

Diff [purge]

Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AmExport.php
@@ -6,9 +6,10 @@
77 return false;
88
99 $data = NssProperties::getAllUsers();
10 - $result = call_user_func( $this, array(
 10+
 11+ $result = call_user_func( array( $this,
1112 'format'.ucfirst( strtolower( $format ) )
12 - ) );
 13+ ), $data );
1314
1415 global $wgOut;
1516 $wgOut->disable();
@@ -22,13 +23,18 @@
2324
2425 function formatCsv( $data ) {
2526 $props = NssProperties::getAll();
 27+ $users = NssUser::fetchAll();
2628
2729 $result = '';
28 - foreach ( $data as $line ) {
 30+ foreach ( $data as $username => $line ) {
2931 $dataline = array();
3032 foreach ( $props as $name ) {
31 - $field = isset( $props[$name] ) ? $props[$name] : '';
 33+ $field = isset( $line[$name] ) ? $line[$name] : '';
3234
 35+ if ( !$field && in_array( $name, array( 'username', 'home', 'active', 'email' ) ) ) {
 36+ $field = $users[$username]->get( $name );
 37+ }
 38+
3339 $escape = false;
3440 if ( strpos( $field, '"' ) !== false ) {
3541 $field = str_replace( '"', '""' , $field );
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssProperties.php
@@ -6,11 +6,19 @@
77 if ( isset( self::$users[$username] ) )
88 return self::$users[$username];
99
 10+ $propObj = new self( $username );
 11+ self::$users[$username] = $propObj;
 12+ return $propObj;
 13+ }
 14+
 15+ public function load() {
 16+ if ( $this->loaded ) return;
 17+
1018 global $wgAuth;
1119 $dbr = $wgAuth->getDB( DB_READ );
1220 $res = $dbr->select( 'user_props',
1321 array( 'up_name', 'up_value' ),
14 - array( 'up_user' => $username ),
 22+ array( 'up_user' => $this->name ),
1523 __METHOD__,
1624 array( 'ORDER BY' => 'up_timestamp ASC' )
1725 );
@@ -20,10 +28,8 @@
2129 $props[$row->up_name] = $row->up_value;
2230 }
2331
24 - $propObj = new self( $username );
25 - $propObj->props = $props;
26 - self::$users[$username] = $propObj;
27 - return $propObj;
 32+ $this->props = $props;
 33+ $this->loaded = true;
2834 }
2935 public static function getAllUsers() {
3036 global $wgAuth;
@@ -48,12 +54,15 @@
4955 $this->name = $name;
5056 $this->props = array();
5157 $this->changed = array();
 58+ $this->loaded = false;
5259 }
5360
5461 function get( $name ) {
 62+ $this->load();
5563 return $this->props[$name];
5664 }
5765 function set( $name, $value ) {
 66+ $this->load();
5867 if ( $this->props[$name] == $value )
5968 return false;
6069 $this->changed[] = $name;
@@ -62,6 +71,8 @@
6372 }
6473
6574 function commit() {
 75+ $this->load();
 76+
6677 global $wgAuth;
6778 $dbw = $wgAuth->getDB( DB_WRITE );
6879
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.php
@@ -11,6 +11,7 @@
1212 $wgAutoloadClasses['SpecialAccountManager'] = $dir . 'SpecialAccountManager.php';
1313 $wgAutoloadClasses['AmUserListView'] = $dir . 'AmUserListView.php';
1414 $wgAutoloadClasses['AmUserView'] = $dir . 'AmUserView.php';
 15+$wgAutoloadClasses['AmExport'] = $dir . 'AmExport.php';
1516
1617 $wgSpecialPages['AccountManager'] = 'SpecialAccountManager';
1718

Status & tagging log