Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AmExport.php |
— | — | @@ -6,9 +6,10 @@ |
7 | 7 | return false;
|
8 | 8 |
|
9 | 9 | $data = NssProperties::getAllUsers();
|
10 | | - $result = call_user_func( $this, array(
|
| 10 | +
|
| 11 | + $result = call_user_func( array( $this,
|
11 | 12 | 'format'.ucfirst( strtolower( $format ) )
|
12 | | - ) );
|
| 13 | + ), $data );
|
13 | 14 |
|
14 | 15 | global $wgOut;
|
15 | 16 | $wgOut->disable();
|
— | — | @@ -22,13 +23,18 @@ |
23 | 24 |
|
24 | 25 | function formatCsv( $data ) {
|
25 | 26 | $props = NssProperties::getAll();
|
| 27 | + $users = NssUser::fetchAll();
|
26 | 28 |
|
27 | 29 | $result = '';
|
28 | | - foreach ( $data as $line ) {
|
| 30 | + foreach ( $data as $username => $line ) {
|
29 | 31 | $dataline = array();
|
30 | 32 | foreach ( $props as $name ) {
|
31 | | - $field = isset( $props[$name] ) ? $props[$name] : '';
|
| 33 | + $field = isset( $line[$name] ) ? $line[$name] : '';
|
32 | 34 |
|
| 35 | + if ( !$field && in_array( $name, array( 'username', 'home', 'active', 'email' ) ) ) {
|
| 36 | + $field = $users[$username]->get( $name );
|
| 37 | + }
|
| 38 | +
|
33 | 39 | $escape = false;
|
34 | 40 | if ( strpos( $field, '"' ) !== false ) {
|
35 | 41 | $field = str_replace( '"', '""' , $field );
|
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssProperties.php |
— | — | @@ -6,11 +6,19 @@ |
7 | 7 | if ( isset( self::$users[$username] ) ) |
8 | 8 | return self::$users[$username]; |
9 | 9 | |
| 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 | + |
10 | 18 | global $wgAuth; |
11 | 19 | $dbr = $wgAuth->getDB( DB_READ ); |
12 | 20 | $res = $dbr->select( 'user_props', |
13 | 21 | array( 'up_name', 'up_value' ), |
14 | | - array( 'up_user' => $username ), |
| 22 | + array( 'up_user' => $this->name ), |
15 | 23 | __METHOD__, |
16 | 24 | array( 'ORDER BY' => 'up_timestamp ASC' ) |
17 | 25 | ); |
— | — | @@ -20,10 +28,8 @@ |
21 | 29 | $props[$row->up_name] = $row->up_value; |
22 | 30 | } |
23 | 31 | |
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; |
28 | 34 | } |
29 | 35 | public static function getAllUsers() { |
30 | 36 | global $wgAuth; |
— | — | @@ -48,12 +54,15 @@ |
49 | 55 | $this->name = $name; |
50 | 56 | $this->props = array(); |
51 | 57 | $this->changed = array(); |
| 58 | + $this->loaded = false; |
52 | 59 | } |
53 | 60 | |
54 | 61 | function get( $name ) { |
| 62 | + $this->load(); |
55 | 63 | return $this->props[$name]; |
56 | 64 | } |
57 | 65 | function set( $name, $value ) { |
| 66 | + $this->load(); |
58 | 67 | if ( $this->props[$name] == $value ) |
59 | 68 | return false; |
60 | 69 | $this->changed[] = $name; |
— | — | @@ -62,6 +71,8 @@ |
63 | 72 | } |
64 | 73 | |
65 | 74 | function commit() { |
| 75 | + $this->load(); |
| 76 | + |
66 | 77 | global $wgAuth; |
67 | 78 | $dbw = $wgAuth->getDB( DB_WRITE ); |
68 | 79 | |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.php |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | $wgAutoloadClasses['SpecialAccountManager'] = $dir . 'SpecialAccountManager.php'; |
13 | 13 | $wgAutoloadClasses['AmUserListView'] = $dir . 'AmUserListView.php'; |
14 | 14 | $wgAutoloadClasses['AmUserView'] = $dir . 'AmUserView.php'; |
| 15 | +$wgAutoloadClasses['AmExport'] = $dir . 'AmExport.php'; |
15 | 16 | |
16 | 17 | $wgSpecialPages['AccountManager'] = 'SpecialAccountManager'; |
17 | 18 | |