Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AmExport.php |
— | — | @@ -14,14 +14,16 @@ |
15 | 15 | global $wgOut;
|
16 | 16 | $wgOut->disable();
|
17 | 17 | wfResetOutputBuffers();
|
18 | | - header( 'Content-Type: application/octet-stream' );
|
19 | 18 | echo $result;
|
20 | 19 | return true;
|
21 | 20 | }
|
22 | 21 |
|
23 | | - static $formats = array('csv');
|
| 22 | + static $formats = array('csv', 'csvexcel' );
|
24 | 23 |
|
25 | | - function formatCsv( $data ) {
|
| 24 | + function formatCsvexcel( $data ) {
|
| 25 | + return $this->formatCsv( $data, ';' );
|
| 26 | + }
|
| 27 | + function formatCsv( $data, $separator = ',' ) {
|
26 | 28 | $props = NssProperties::getAll();
|
27 | 29 | $users = NssUser::fetchAll();
|
28 | 30 |
|
— | — | @@ -32,6 +34,8 @@ |
33 | 35 | $field = isset( $line[$name] ) ? $line[$name] : '';
|
34 | 36 |
|
35 | 37 | if ( !$field && in_array( $name, array( 'username', 'home', 'active', 'email' ) ) ) {
|
| 38 | + if ( !isset( $users[$username] ) )
|
| 39 | + continue;
|
36 | 40 | $field = $users[$username]->get( $name );
|
37 | 41 | }
|
38 | 42 |
|
— | — | @@ -50,8 +54,10 @@ |
51 | 55 | else
|
52 | 56 | $dataline[] = $field;
|
53 | 57 | }
|
54 | | - $result .= implode( ',', $dataline )."\r\n";
|
| 58 | + $result .= implode( $separator, $dataline )."\r\n";
|
55 | 59 | }
|
| 60 | +
|
| 61 | + header( "Content-Disposition: inline;filename*=utf-8'en'export.csv" );
|
56 | 62 | return $result;
|
57 | 63 | }
|
58 | 64 | }
|
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssUser.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class NssUser { |
5 | | - static $passwdFields = array( 'pwd_uid', 'pwd_gid', 'pwd_home', 'pwd_active', 'pwd_email' ); |
| 5 | + static $passwdFields = array( 'pwd_name', 'pwd_uid', 'pwd_gid', 'pwd_home', 'pwd_active', 'pwd_email' ); |
6 | 6 | |
7 | 7 | function __construct( $name ) { |
8 | 8 | $this->name = $name; |
— | — | @@ -119,6 +119,21 @@ |
120 | 120 | $names[] = $row->pwd_name; |
121 | 121 | return $names; |
122 | 122 | } |
| 123 | + public static function fetchByActive() { |
| 124 | + global $wgAuth; |
| 125 | + $dbr = $wgAuth->getDB( DB_READ ); |
| 126 | + |
| 127 | + $res = $dbr->select( 'passwd', array( 'pwd_name', 'pwd_active' ), array(), __METHOD__ ); |
| 128 | + |
| 129 | + $actives = array(); |
| 130 | + while ( $row = $res->fetchObject() ) { |
| 131 | + if ( !isset( $actives[$row->pwd_active] ) ) |
| 132 | + $actives[$row->pwd_active] = array(); |
| 133 | + |
| 134 | + $actives[$row->pwd_active] = $row->pwd_name; |
| 135 | + } |
| 136 | + return $actives; |
| 137 | + } |
123 | 138 | |
124 | 139 | public static function fetchAll() { |
125 | 140 | global $wgAuth; |
— | — | @@ -129,6 +144,7 @@ |
130 | 145 | while ( $row = $res->fetchObject() ) { |
131 | 146 | $user = new self( $row->pwd_name ); |
132 | 147 | $user->loadFromRow( $row ); |
| 148 | + $users[$row->pwd_name] = $user; |
133 | 149 | } |
134 | 150 | return $users; |
135 | 151 | } |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AmUserListView.php |
— | — | @@ -4,21 +4,25 @@ |
5 | 5 | function execute() {
|
6 | 6 | global $wgOut, $wgUser;
|
7 | 7 |
|
8 | | - $users = NssUser::fetchNames();
|
| 8 | + $actives = NssUser::fetchByActive();
|
| 9 | +
|
9 | 10 | $title = SpecialPage::getTitleFor( 'AccountManager' );
|
10 | 11 | $sk = $wgUser->getSkin();
|
11 | 12 |
|
12 | | - $wgOut->addHtml( Xml::element( 'ul', array(
|
13 | | - 'id' => 'nss-user-listview'
|
14 | | - ) ) . "\n" );
|
15 | | -
|
16 | | - foreach ( $users as $name ) {
|
17 | | - $wgOut->addHtml( "\t<li>" .
|
18 | | - $sk->link( $title, $name, /* html attribs */ array(),
|
19 | | - array( 'user' => $name ), 'known'
|
20 | | - ) . "</li>\n" );
|
| 13 | + foreach ( $actives as $active => $users ) {
|
| 14 | + $wgOut->addHtml( Xml::element( 'h2', null, $active ).
|
| 15 | + Xml::openElement( 'ul', array(
|
| 16 | + 'id' => 'nss-user-listview'
|
| 17 | + ) ) . "\n" );
|
| 18 | +
|
| 19 | + foreach ( $users as $name ) {
|
| 20 | + $wgOut->addHtml( "\t<li>" .
|
| 21 | + $sk->link( $title, $name, /* html attribs */ array(),
|
| 22 | + array( 'user' => $name ), 'known'
|
| 23 | + ) . "</li>\n" );
|
| 24 | + }
|
| 25 | +
|
| 26 | + $wgOut->addHtml( "</ul>\n" );
|
21 | 27 | }
|
22 | | -
|
23 | | - $wgOut->addHtml( "</ul>\n" );
|
24 | 28 | }
|
25 | 29 | } |
\ No newline at end of file |