Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssProperties.php |
— | — | @@ -36,8 +36,11 @@ |
37 | 37 | return $this->props[$name]; |
38 | 38 | } |
39 | 39 | function set( $name, $value ) { |
| 40 | + if ( $this->props[$name] == $value ) |
| 41 | + return false; |
40 | 42 | $this->changed[] = $name; |
41 | 43 | $this->props[$name] = $value; |
| 44 | + return true; |
42 | 45 | } |
43 | 46 | |
44 | 47 | function commit() { |
— | — | @@ -47,12 +50,12 @@ |
48 | 51 | $insert = array(); |
49 | 52 | $timestamp = $dbw->timestamp(); |
50 | 53 | |
51 | | - foreach ( $this->props as $name => $value ) { |
| 54 | + foreach ( $this->changed as $name ) { |
52 | 55 | $insert[] = array( |
53 | 56 | 'up_timestamp' => $timestamp, |
54 | 57 | 'up_user' => $this->name, |
55 | 58 | 'up_name' => $name, |
56 | | - 'up_value' => $value |
| 59 | + 'up_value' => $this->props[$name] |
57 | 60 | ); |
58 | 61 | } |
59 | 62 | $dbw->insert( 'user_props', $insert, __METHOD__ ); |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssUser.php |
— | — | @@ -36,10 +36,10 @@ |
37 | 37 | if ($this->exists) { |
38 | 38 | // Extract props from row |
39 | 39 | $this->uid = $row->pwd_uid; |
40 | | - $this->gid = $row->pwd_home; |
| 40 | + $this->gid = $row->pwd_gid; |
41 | 41 | $this->home = $row->pwd_home; |
42 | 42 | $this->active = $row->pwd_active; |
43 | | - $this->email = $row->pwd_home; |
| 43 | + $this->email = $row->pwd_email; |
44 | 44 | |
45 | 45 | $this->group = NssGroup::nameFromGid( $this->gid ); |
46 | 46 | $this->properties = NssProperties::forUser( $this->name ); |
— | — | @@ -81,10 +81,13 @@ |
82 | 82 | return; |
83 | 83 | case 'home': |
84 | 84 | $this->home = $value; |
| 85 | + break; |
85 | 86 | case 'active': |
86 | 87 | $this->active = $value; |
| 88 | + break; |
87 | 89 | case 'email': |
88 | 90 | $this->email = $value; |
| 91 | + break; |
89 | 92 | } |
90 | 93 | return $this->properties->set( $name, $value ); |
91 | 94 | } |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.php |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | $dir = dirname( __FILE__ ) . '/'; |
4 | 4 | |
5 | | -$wgExtensionMessagesFiles['AccountManager'] = $dir . 'AccountManager.i18n.php'; |
6 | | -$wgExtensionAliasesFiles['AccountManager'] = $dir . 'AccountManager.alias.php'; |
| 5 | +$wgExtensionMessagesFiles['accountmanager'] = $dir . 'AccountManager.i18n.php'; |
| 6 | +$wgExtensionAliasesFiles['accountmanager'] = $dir . 'AccountManager.alias.php'; |
7 | 7 | |
8 | 8 | $wgAutoloadClasses['NssUser'] = $dir . 'NssUser.php'; |
9 | 9 | $wgAutoloadClasses['NssGroup'] = $dir . 'NssGroup.php'; |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AmUserView.php |
— | — | @@ -33,29 +33,30 @@ |
34 | 34 | function createHeader() { |
35 | 35 | global $wgOut; |
36 | 36 | |
37 | | - $wgOut->addHtml( Xml::element( 'form', array( |
| 37 | + $wgOut->addHtml( Xml::openElement( 'form', array( |
38 | 38 | 'action' => $this->title->getLocalUrl( array( |
39 | 39 | 'action' => $this->action, |
40 | 40 | 'user' => $this->username, |
41 | 41 | ) ), |
42 | 42 | 'method' => 'post', |
43 | 43 | ) ) . "\n" ); |
44 | | - $wgOut->addHtml( Xml::element( 'table', array( |
| 44 | + $wgOut->addHtml( Xml::openElement( 'table', array( |
45 | 45 | 'class' => "am-{$this->action}" |
46 | 46 | ) ) . "\n" ); |
47 | 47 | } |
48 | 48 | |
49 | 49 | function makeRow( $prop ) { |
50 | | - $label = wfMsg( "am-$prop" ); |
51 | | - if ( wfEmptyMsg( "am-$prop", $label ) ) |
52 | | - $label = "am-$prop"; |
| 50 | + $amName = 'am-'.str_replace( ' ', '-', $prop ); |
| 51 | + $label = wfMsg( $amName ); |
| 52 | + if ( wfEmptyMsg( $amName, $label ) ) |
| 53 | + $label = $prop; |
53 | 54 | |
54 | 55 | return ( "\t<tr><td>" . |
55 | | - Xml::label( $label, "am-$prop" ) . |
| 56 | + Xml::label( $label, $amName ) . |
56 | 57 | "</td><td>" . |
57 | | - Xml::input( /* $name */ "am-$prop", /* $size */ false, |
| 58 | + Xml::input( /* $name */ $amName, /* $size */ false, |
58 | 59 | /* $value */ $this->user->get( $prop ), |
59 | | - array( 'id' => "am-$prop" ) ) . |
| 60 | + array( 'id' => $amName ) ) . |
60 | 61 | "</td></tr>\n" |
61 | 62 | ); |
62 | 63 | } |
— | — | @@ -63,7 +64,7 @@ |
64 | 65 | function createFooter() { |
65 | 66 | global $wgOut; |
66 | 67 | $wgOut->addHtml( "</table>\n" . |
67 | | - Xml::element( 'p', array( |
| 68 | + Xml::openElement( 'p', array( |
68 | 69 | 'id' => '' |
69 | 70 | ) ) ); |
70 | 71 | $wgOut->addHtml( Xml::submitButton( wfMsg( 'am-save-changes' ) ) ); |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/SpecialAccountManager.php |
— | — | @@ -2,16 +2,18 @@ |
3 | 3 | |
4 | 4 | class SpecialAccountManager extends SpecialPage { |
5 | 5 | function __construct() { |
| 6 | + wfLoadExtensionMessages( 'accountmanager' ); |
| 7 | + |
6 | 8 | parent::__construct( 'AccountManager', 'accountmanager', false ); |
7 | 9 | $this->error = false; |
8 | 10 | } |
9 | 11 | |
10 | | - function processData( $action ) { |
11 | | - global $wgRequest; |
| 12 | + function processData() { |
| 13 | + global $wgRequest, $wgAuth; |
12 | 14 | $action = $wgRequest->getVal( 'action' ); |
13 | 15 | $username = $wgRequest->getVal( 'user' ); |
14 | 16 | |
15 | | - if ( !( $action == 'create' || $action == 'submit' ) ) |
| 17 | + if ( !( $action == 'create' || $action == 'submit' ) || !$wgRequest->wasPosted() ) |
16 | 18 | return; |
17 | 19 | |
18 | 20 | $user = new NssUser( $username ); |
— | — | @@ -23,20 +25,18 @@ |
24 | 26 | // Extract post data |
25 | 27 | $post = $wgRequest->getValues(); |
26 | 28 | foreach( $post as $key => $value ) { |
27 | | - if( substr( $key, 0, 3 ) != 'am-' ) |
| 29 | + // Only am-* data is proper data |
| 30 | + if( substr( $key, 0, 3 ) != 'am-' || strlen( $key ) <= 3 ) |
28 | 31 | continue; |
29 | | - $parts = explode( '-', $key, 2 ); |
30 | | - if( count( $parts ) != 2 ) |
31 | | - continue; |
32 | | - |
33 | | - $keyname = str_replace( '_', '-', strtolower( $parts[1] ) ); |
| 32 | + // Split off the am- prefix |
| 33 | + $keyname = str_replace( '-', ' ', strtolower( substr( $key, 3 ) ) ); |
34 | 34 | $user->set( $keyname, $value ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | if ( $action == 'submit' ) { |
38 | 38 | $user->commit(); |
39 | 39 | } else { |
40 | | - global $wgAuth, $wgPasswordSender; |
| 40 | + global $wgPasswordSender; |
41 | 41 | |
42 | 42 | $password = $wgAuth->createAccount( $username ); |
43 | 43 | $user->insert(); |