Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/NssMySQLAuth.alias.php |
— | — | @@ -1,109 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Aliases for special pages |
5 | | - */ |
6 | | - |
7 | | -$aliases = array(); |
8 | | - |
9 | | -/** English |
10 | | - * @author Bryan Tong Minh |
11 | | - */ |
12 | | -$aliases['en'] = array( |
13 | | - 'AccountManager' => array( 'AccountManager' ), |
14 | | -); |
15 | | - |
16 | | -/** Arabic (العربية) */ |
17 | | -$aliases['ar'] = array( |
18 | | - 'AccountManager' => array( 'مدير_الحسابات' ), |
19 | | -); |
20 | | - |
21 | | -/** Egyptian Spoken Arabic (مصرى) */ |
22 | | -$aliases['arz'] = array( |
23 | | - 'AccountManager' => array( 'مدير_الحسابات' ), |
24 | | -); |
25 | | - |
26 | | -/** Bosnian (Bosanski) */ |
27 | | -$aliases['bs'] = array( |
28 | | - 'AccountManager' => array( 'UpravljanjeRacunima' ), |
29 | | -); |
30 | | - |
31 | | -/** German (Deutsch) */ |
32 | | -$aliases['de'] = array( |
33 | | - 'AccountManager' => array( 'Account-Manager' ), |
34 | | -); |
35 | | - |
36 | | -/** Lower Sorbian (Dolnoserbski) */ |
37 | | -$aliases['dsb'] = array( |
38 | | - 'AccountManager' => array( 'Kontowy zastojnik' ), |
39 | | -); |
40 | | - |
41 | | -/** French (Français) */ |
42 | | -$aliases['fr'] = array( |
43 | | - 'AccountManager' => array( 'Gestionnaire de compte', 'GestionnaireDeCompte' ), |
44 | | -); |
45 | | - |
46 | | -/** Galician (Galego) */ |
47 | | -$aliases['gl'] = array( |
48 | | - 'AccountManager' => array( 'Xestor de contas' ), |
49 | | -); |
50 | | - |
51 | | -/** Upper Sorbian (Hornjoserbsce) */ |
52 | | -$aliases['hsb'] = array( |
53 | | - 'AccountManager' => array( 'Kontowy zrjadowak' ), |
54 | | -); |
55 | | - |
56 | | -/** Interlingua (Interlingua) */ |
57 | | -$aliases['ia'] = array( |
58 | | - 'AccountManager' => array( 'Gestion de contos' ), |
59 | | -); |
60 | | - |
61 | | -/** Japanese (日本語) */ |
62 | | -$aliases['ja'] = array( |
63 | | - 'AccountManager' => array( 'アカウントマネージャー' ), |
64 | | -); |
65 | | - |
66 | | -/** Khmer (ភាសាខ្មែរ) */ |
67 | | -$aliases['km'] = array( |
68 | | - 'AccountManager' => array( 'គ្រប់គ្រងគណនី' ), |
69 | | -); |
70 | | - |
71 | | -/** Nedersaksisch (Nedersaksisch) */ |
72 | | -$aliases['nds-nl'] = array( |
73 | | - 'AccountManager' => array( 'Gebrukersbeheer' ), |
74 | | -); |
75 | | - |
76 | | -/** Dutch (Nederlands) */ |
77 | | -$aliases['nl'] = array( |
78 | | - 'AccountManager' => array( 'Gebruikersbeheer' ), |
79 | | -); |
80 | | - |
81 | | -/** Norwegian (bokmål) (Norsk (bokmål)) */ |
82 | | -$aliases['no'] = array( |
83 | | - 'AccountManager' => array( 'Kontobehandling' ), |
84 | | -); |
85 | | - |
86 | | -/** Brazilian Portuguese (Português do Brasil) */ |
87 | | -$aliases['pt-br'] = array( |
88 | | - 'AccountManager' => array( 'Gerenciador de contas' ), |
89 | | -); |
90 | | - |
91 | | -/** Sanskrit (संस्कृत) */ |
92 | | -$aliases['sa'] = array( |
93 | | - 'AccountManager' => array( 'उपयोजकसंज्ञाप्रबन्धक' ), |
94 | | -); |
95 | | - |
96 | | -/** Albanian (Shqip) */ |
97 | | -$aliases['sq'] = array( |
98 | | - 'AccountManager' => array( 'MenaxhuesLlogarie' ), |
99 | | -); |
100 | | - |
101 | | -/** Swahili (Kiswahili) */ |
102 | | -$aliases['sw'] = array( |
103 | | - 'AccountManager' => array( 'AkauntiKuu' ), |
104 | | -); |
105 | | - |
106 | | -/** Tagalog (Tagalog) */ |
107 | | -$aliases['tl'] = array( |
108 | | - 'AccountManager' => array( 'Tagapamahala ng akawnt' ), |
109 | | -); |
110 | | - |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/SpecialAccountManager.php |
— | — | @@ -1,390 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class SpecialAccountManager extends SpecialPage { |
5 | | - function __construct() { |
6 | | - parent::__construct( 'AccountManager', 'accountmanager', false ); |
7 | | - $this->mErrors = array(); |
8 | | - } |
9 | | - |
10 | | - function execute() { |
11 | | - global $wgUser; |
12 | | - if( !$this->userCanExecute( $wgUser ) ) |
13 | | - return $this->displayRestrictionError(); |
14 | | - |
15 | | - $this->setHeaders(); |
16 | | - |
17 | | - $this->users = UserProps::fetchAllUsers(); |
18 | | - if( $this->processData() === true ) |
19 | | - $this->showSuccess(); |
20 | | - if( $this->processCreateAccount() === true ) |
21 | | - $this->showSuccessCreate(); |
22 | | - |
23 | | - $this->showErrors(); |
24 | | - |
25 | | - $this->constructForm(); |
26 | | - $this->constructCreateForm(); |
27 | | - } |
28 | | - |
29 | | - function showSuccess() { |
30 | | - global $wgOut; |
31 | | - $wgOut->addHTML( Xml::element('p', array(), wfMsg( 'am-updated' ) ) ); |
32 | | - } |
33 | | - function showSuccessCreate() { |
34 | | - return $this->showSuccess(); |
35 | | - } |
36 | | - |
37 | | - function constructForm() { |
38 | | - global $wgOut, $wgScript, $wgUser; |
39 | | - global $wgUserProperties, $wgActivityModes; |
40 | | - |
41 | | - // TODO: wfMsg etc. |
42 | | - $wgOut->addHTML( Xml::openElement( 'form', array( |
43 | | - 'action' => $this->getTitle()->getLocalURL(), |
44 | | - 'method' => 'post' ) |
45 | | - ) ); |
46 | | - |
47 | | - $wgOut->addHTML("<table id=\"userprops\" border=\"1\">\n\t<tr>". |
48 | | - "<th>".wfMsgHtml( 'am-username' ). |
49 | | - "</th><th></th><th>".wfMsgHtml( 'am-email' ). |
50 | | - "</th><th>".wfMsgHtml( 'am-active' )."</th>"); |
51 | | - foreach( $wgUserProperties as $i ) { |
52 | | - $msg = 'am-'.$i; |
53 | | - $wgOut->addHTML( Xml::element( 'th', null, |
54 | | - wfEmptyMsg( $msg, wfMsg( $msg ) ) ? $i : wfMsgHtml( $msg ) ) ); |
55 | | - } |
56 | | - $wgOut->addHTML("</tr>\n\n"); |
57 | | - |
58 | | - $sk = $wgUser->getSkin(); |
59 | | - foreach( $this->users as $user ) { |
60 | | - $name = $user->getName(); |
61 | | - $row = "\t<tr>"; |
62 | | - $row .= Xml::element( 'td', null, $name ); |
63 | | - $row .= "<td>".$sk->link( SpecialPage::getTitleFor( 'Userrights' ), |
64 | | - wfMsg( 'nss-rights' ), array(), array( 'user' => $name ) )."</td>"; |
65 | | - $row .= "<td>".Xml::input( "am-{$name}-email", 30, $user->getEmail() )."</td>"; |
66 | | - $select = new XmlSelect( "am-{$name}-active" ); |
67 | | - $select->setDefault( $user->getActive() ); |
68 | | - foreach( $wgActivityModes as $key ) |
69 | | - $select->addOption( $key ); |
70 | | - $row .= "<td>".$select->getHTML()."</td>"; |
71 | | - |
72 | | - $props = $user->getProps(); |
73 | | - foreach( $wgUserProperties as $key ) { |
74 | | - $value = isset( $props[$key] ) ? $props[$key] : ''; |
75 | | - $row .= "<td>".Xml::input( |
76 | | - "am-{$name}-".str_replace( ' ', '_', $key ), 30, $value |
77 | | - )."</td>"; |
78 | | - } |
79 | | - $row .= "</tr>\n"; |
80 | | - $wgOut->addHTML( $row ); |
81 | | - } |
82 | | - |
83 | | - $wgOut->addHTML( "</table>\n" ); |
84 | | - $wgOut->addHTML( "<div id=\"userprops-submit\">\n". |
85 | | - Xml::hidden( 'action', 'submit' ). |
86 | | - Xml::element( 'input', array( |
87 | | - 'type' => 'submit', |
88 | | - 'value' => wfMsg( 'nss-save-changes' ) |
89 | | - ) ). |
90 | | - "</div>\n</form>" |
91 | | - ); |
92 | | - } |
93 | | - |
94 | | - function constructCreateForm() { |
95 | | - global $wgOut, $wgScript; |
96 | | - global $wgUserProperties, $wgActivityModes; |
97 | | - |
98 | | - $wgOut->addHTML( Xml::openElement( 'form', array( |
99 | | - 'action' => $this->getTitle()->getLocalURL(), |
100 | | - 'method' => 'post' ) |
101 | | - ) ); |
102 | | - |
103 | | - $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'nss-create-account-header' ) )."\n" ); |
104 | | - |
105 | | - $wgOut->addHTML( "<table border=\"1\" id=\"newuser\">\n" ); |
106 | | - |
107 | | - $props = array_merge( array( 'username', 'email' ), $wgUserProperties ); |
108 | | - foreach( $props as $i ) { |
109 | | - $msg = 'am-'.$i; |
110 | | - $wgOut->addHTML( "\t<tr><th>". |
111 | | - (wfEmptyMsg( $msg, wfMsg( $msg ) ) ? $i : wfMsgHtml( $msg )). |
112 | | - "</th><td>".Xml::input( "am-".str_replace( ' ', '_', $i ), 40 ). |
113 | | - "</td></tr>\n" |
114 | | - ); |
115 | | - } |
116 | | - |
117 | | - global $wgActivityModes; |
118 | | - $select = new XmlSelect( "am-active" ); |
119 | | - $select->setDefault( 'active' ); |
120 | | - $select->setAttribute( 'width', '100%' ); |
121 | | - foreach( $wgActivityModes as $key ) |
122 | | - $select->addOption( $key ); |
123 | | - $wgOut->addHTML( "\t<tr><th>".wfMsgHtml( 'am-active' ). |
124 | | - "</th><td>".$select->getHTML()."</td></tr>\n" ); |
125 | | - |
126 | | - $wgOut->addHTML( "</table>\n" ); |
127 | | - $wgOut->addHTML( "<div id=\"newaccount-submit\">\n". |
128 | | - Xml::hidden( 'action', 'create' ). |
129 | | - Xml::checkLabel( wfMsg( 'nss-no-mail' ), 'nss-no-mail', 'nss-no-mail' ). |
130 | | - "<br />\n". |
131 | | - Xml::element( 'input', array( |
132 | | - 'type' => 'submit', |
133 | | - 'value' => wfMsg( 'nss-create-account' ) |
134 | | - ) ). |
135 | | - "</div>\n</form>\n" |
136 | | - ); |
137 | | - |
138 | | - $wgOut->addHTML( Xml::openElement( 'form', array( |
139 | | - 'action' => $this->getTitle()->getLocalURL(), |
140 | | - 'method' => 'post' ) |
141 | | - ) ); |
142 | | - $wgOut->addHTML( "<div id=\"newaccount-raw\">\n". |
143 | | - Xml::textarea( 'nss-create-account-raw', '' )."\n". |
144 | | - Xml::hidden( 'action', 'create-raw' ). |
145 | | - Xml::checkLabel( wfMsg( 'nss-no-mail' ), 'nss-no-mail', 'nss-no-mail' ). |
146 | | - "<br />\n". |
147 | | - Xml::element( 'input', array( |
148 | | - 'type' => 'submit', |
149 | | - 'value' => wfMsg( 'nss-create-account' ) |
150 | | - ) ). |
151 | | - "</div>\n</form>\n" |
152 | | - ); |
153 | | - |
154 | | - } |
155 | | - |
156 | | - function processData() { |
157 | | - global $wgRequest, $wgUserProperties; |
158 | | - if( !$wgRequest->wasPosted() || $wgRequest->getVal('action') != 'submit' ) |
159 | | - return; |
160 | | - |
161 | | - $post = $wgRequest->getValues(); |
162 | | - foreach( $post as $key => $value ) { |
163 | | - if( substr( $key, 0, 3 ) != 'am-' ) |
164 | | - continue; |
165 | | - $parts = explode( '-', $key, 3 ); |
166 | | - if( count( $parts ) != 3 ) |
167 | | - continue; |
168 | | - |
169 | | - $username = strtolower( $parts[1] ); |
170 | | - $keyname = str_replace( '_', ' ', strtolower( $parts[2] ) ); |
171 | | - |
172 | | - if( !isset( $this->users[$username] ) ) |
173 | | - continue; |
174 | | - |
175 | | - if( !in_array( $keyname, $wgUserProperties ) && |
176 | | - !in_array( $keyname, array( 'email', 'active' ) ) ) |
177 | | - continue; |
178 | | - |
179 | | - $this->users[$username]->set( $keyname, $value ); |
180 | | - } |
181 | | - |
182 | | - foreach( $this->users as $user ) |
183 | | - $user->update(); |
184 | | - return true; |
185 | | - } |
186 | | - |
187 | | - function processCreateAccount() { |
188 | | - global $wgRequest, $wgUserProperties; |
189 | | - if( !$wgRequest->wasPosted() || $wgRequest->getVal('action') != 'create' ) |
190 | | - return; |
191 | | - |
192 | | - $options = array(); |
193 | | - |
194 | | - $post = $wgRequest->getValues(); |
195 | | - foreach( $post as $key => $value ) { |
196 | | - if( substr( $key, 0, 3 ) != 'am-' ) |
197 | | - continue; |
198 | | - $parts = explode( '-', $key, 2 ); |
199 | | - if( count( $parts ) != 2 ) |
200 | | - continue; |
201 | | - |
202 | | - $keyname = str_replace( '_', '-', strtolower( $parts[1] ) ); |
203 | | - $options[$keyname] = $value; |
204 | | - } |
205 | | - return $this->internalProcessCreateAccount( $options, |
206 | | - $wgRequest->getCheck( 'nss-no-mail') ); |
207 | | - |
208 | | - } |
209 | | - function processCreateAccountRaw() { |
210 | | - global $wgRequest, $wgUserProperties; |
211 | | - if( !$wgRequest->wasPosted() || $wgRequest->getVal('action') != 'create-raw' ) |
212 | | - return; |
213 | | - |
214 | | - $data = $wgRequest->getText( 'nss-create-account-raw' ); |
215 | | - $nomail = $wgRequest->getCheck( 'nss-no-mail'); |
216 | | - $lines = explode( "\n", $data ); |
217 | | - foreach ( $lines as $line ) { |
218 | | - $line = trim( $line ); |
219 | | - $items = explode( "\t", $line ); |
220 | | - if ( count( $items ) == $wgUserProperties + 1 ) { |
221 | | - $username = array_shift( $items ); |
222 | | - $options = array_combine( $wgUserProperties, $items ); |
223 | | - $options['username'] = $username; |
224 | | - $this->internalProcessCreateAccount( $options, $nomail ); |
225 | | - } |
226 | | - |
227 | | - } |
228 | | - |
229 | | - } |
230 | | - |
231 | | - function internalProcessCreateAccount( $options, $nomail = false ) { |
232 | | - if( empty( $options['username'] ) ) { |
233 | | - $this->mErrors[] = 'noname'; |
234 | | - return false; |
235 | | - } |
236 | | - $username = $options['username']; |
237 | | - unset( $options['username'] ); |
238 | | - |
239 | | - global $wgAuth; |
240 | | - $password = $wgAuth->createAccount($username, $options); |
241 | | - |
242 | | - $userprops = UserProps::loadFromDb( $username ); |
243 | | - if ( !$userprops ) { |
244 | | - $this->mErrors[] = 'nss-db-error'; |
245 | | - return false; |
246 | | - } |
247 | | - $this->users[$userprops->getName()] = $userprops; |
248 | | - |
249 | | - if ( $nomail ) |
250 | | - return true; |
251 | | - |
252 | | - global $wgPasswordSender; |
253 | | - $email = wfMsg( 'nss-welcome-mail', $username, $password ); |
254 | | - $mailSubject = wfMsg( 'nss-welcome-mail-subject' ); |
255 | | - $mailFrom = new MailAddress( $wgPasswordSender ); |
256 | | - $mailTo = new MailAddress( User::newFromName( $username ) ); |
257 | | - |
258 | | - $mailResult = UserMailer::send( $mailTo, $mailFrom, $mailSubject, $email ); |
259 | | - |
260 | | - if ( WikiError::isError( $mailResult ) ) { |
261 | | - $this->mErrors[] = $mailResult->getMessage(); |
262 | | - return false; |
263 | | - } |
264 | | - |
265 | | - return true; |
266 | | - } |
267 | | - |
268 | | - function showErrors() { |
269 | | - if ( !$this->mErrors ) |
270 | | - return; |
271 | | - global $wgOut; |
272 | | - foreach( $this->mErrors as $error ) |
273 | | - $wgOut->addHTML( |
274 | | - Xml::element( 'p', |
275 | | - array( 'class' => 'error' ), |
276 | | - wfMsg( $error ) |
277 | | - )."\n" |
278 | | - ); |
279 | | - } |
280 | | -} |
281 | | - |
282 | | -class UserProps { |
283 | | - static function fetchAllUsers() { |
284 | | - $users = array(); |
285 | | - $res = self::select(); |
286 | | - while( $row = $res->fetchObject() ) { |
287 | | - if( !isset( $users[$row->pwd_name] ) ) |
288 | | - $users[$row->pwd_name] = new self( $row->pwd_name, $row->pwd_email ); |
289 | | - $users[$row->pwd_name]->setInternal($row->up_name, $row->up_value); |
290 | | - } |
291 | | - $res->free(); |
292 | | - return $users; |
293 | | - } |
294 | | - static function loadFromDb( $username ) { |
295 | | - $res = self::select( $username ); |
296 | | - $row = $res->fetchObject(); |
297 | | - if ( !$row ) |
298 | | - return false; |
299 | | - return new self( $row->pwd_name, $row->pwd_email, $row->pwd_active ); |
300 | | - } |
301 | | - |
302 | | - function __construct( $username, $email = null, $active = null ) { |
303 | | - $this->username = $username; |
304 | | - $this->props = array(); |
305 | | - $this->email = $email; |
306 | | - $this->setInternal( 'email', $email ); |
307 | | - $this->active = $active; |
308 | | - $this->setInternal( 'active', $active ); |
309 | | - } |
310 | | - function getProps() { |
311 | | - return $this->props; |
312 | | - } |
313 | | - function getName() { |
314 | | - return $this->username; |
315 | | - } |
316 | | - function getEmail() { |
317 | | - return $this->email; |
318 | | - } |
319 | | - function setEmail( $email ) { |
320 | | - $this->email = $email; |
321 | | - } |
322 | | - function getActive() { |
323 | | - return $this->active; |
324 | | - } |
325 | | - function setActive( $active ) { |
326 | | - $this->active = $active; |
327 | | - } |
328 | | - |
329 | | - static function select($username = null) { |
330 | | - global $wgAuth; |
331 | | - $dbr = $wgAuth->getDB( DB_READ ); |
332 | | - $where = is_null( $username ) ? array() : array( 'pwd_name' => $username ); |
333 | | - |
334 | | - return $dbr->select( |
335 | | - array( 'user_props', 'passwd' ), |
336 | | - array( 'up_name', 'up_value', 'pwd_name', 'pwd_email', 'pwd_active' ), |
337 | | - $where, |
338 | | - __METHOD__, |
339 | | - array( 'ORDER BY' => 'pwd_name ASC, up_timestamp ASC' ), |
340 | | - array( 'passwd' => array( 'RIGHT JOIN', 'pwd_name = up_user' ) ) |
341 | | - ); |
342 | | - } |
343 | | - |
344 | | - function set($name, $value) { |
345 | | - wfDebug( "{$this->username}: $name => $value\n" ); |
346 | | - $this->props[$name] = $value; |
347 | | - } |
348 | | - function setInternal($name, $value) { |
349 | | - if( is_null( $this->props ) ) { |
350 | | - $this->props = array(); |
351 | | - $this->old_props = array(); |
352 | | - } |
353 | | - $this->old_props[$name] = $this->props[$name] = $value; |
354 | | - if( $name == 'active' ) |
355 | | - $this->active = $value; |
356 | | - if( $name == 'email' ) |
357 | | - $this->email = $value; |
358 | | - } |
359 | | - |
360 | | - function update() { |
361 | | - $diff = array_diff_assoc($this->props, $this->old_props); |
362 | | - if( !count( $diff ) ) return; |
363 | | - |
364 | | - |
365 | | - global $wgAuth; |
366 | | - $dbw = $wgAuth->getDB( DB_WRITE ); |
367 | | - $timestamp = $dbw->timestamp(); |
368 | | - |
369 | | - if( isset( $diff['email'] ) || isset( $diff['active'] ) ) { |
370 | | - if ( isset( $diff['email'] ) ) $this->email = $diff['email']; |
371 | | - if ( isset( $diff['active'] ) ) $this->active = $diff['active']; |
372 | | - $dbw->update( 'passwd', |
373 | | - array( 'pwd_email' => $this->email, 'pwd_active' => $this->active ), |
374 | | - array( 'pwd_name' => $this->username ), |
375 | | - __METHOD__ |
376 | | - ); |
377 | | - // Put it into user_props as well for history |
378 | | - } |
379 | | - |
380 | | - $insert = array(); |
381 | | - foreach( $diff as $key => $value ) |
382 | | - $insert[] = array( |
383 | | - 'up_timestamp' => $timestamp, |
384 | | - 'up_user' => $this->username, |
385 | | - 'up_name' => $key, |
386 | | - 'up_value' => $value, |
387 | | - ); |
388 | | - |
389 | | - $dbw->insert( 'user_props', $insert, __METHOD__ ); |
390 | | - } |
391 | | -} |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/NssMySQLAuth.php |
— | — | @@ -24,10 +24,8 @@ |
25 | 25 | 'descriptionmsg' => 'nss-desc', |
26 | 26 | 'url' => 'http://www.mediawiki.org/wiki/Extension:NssMySQLAuth', |
27 | 27 | ); |
28 | | - |
29 | 28 | $dir = dirname( __FILE__ ) . '/'; |
30 | 29 | $wgExtensionMessagesFiles['nssmysqlauth'] = $dir . 'NssMySQLAuth.i18n.php'; |
31 | | -$wgExtensionAliasesFiles['nssmysqlauth'] = $dir . 'NssMySQLAuth.alias.php'; |
32 | 30 | |
33 | 31 | $wgAutoloadClasses['NssMySQLAuthPlugin'] = $dir . 'NssMySQLAuthPlugin.php'; |
34 | 32 | $wgAutoloadClasses['Md5crypt'] = $dir . 'Md5crypt.php'; |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/UserView.php |
— | — | @@ -0,0 +1,5 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class NssUserView { |
| 5 | + |
| 6 | +} |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/UserView.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 7 | + native |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.alias.php |
— | — | @@ -0,0 +1,109 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for special pages |
| 5 | + */ |
| 6 | + |
| 7 | +$aliases = array(); |
| 8 | + |
| 9 | +/** English |
| 10 | + * @author Bryan Tong Minh |
| 11 | + */ |
| 12 | +$aliases['en'] = array( |
| 13 | + 'AccountManager' => array( 'AccountManager' ), |
| 14 | +); |
| 15 | + |
| 16 | +/** Arabic (العربية) */ |
| 17 | +$aliases['ar'] = array( |
| 18 | + 'AccountManager' => array( 'مدير_الحسابات' ), |
| 19 | +); |
| 20 | + |
| 21 | +/** Egyptian Spoken Arabic (مصرى) */ |
| 22 | +$aliases['arz'] = array( |
| 23 | + 'AccountManager' => array( 'مدير_الحسابات' ), |
| 24 | +); |
| 25 | + |
| 26 | +/** Bosnian (Bosanski) */ |
| 27 | +$aliases['bs'] = array( |
| 28 | + 'AccountManager' => array( 'UpravljanjeRacunima' ), |
| 29 | +); |
| 30 | + |
| 31 | +/** German (Deutsch) */ |
| 32 | +$aliases['de'] = array( |
| 33 | + 'AccountManager' => array( 'Account-Manager' ), |
| 34 | +); |
| 35 | + |
| 36 | +/** Lower Sorbian (Dolnoserbski) */ |
| 37 | +$aliases['dsb'] = array( |
| 38 | + 'AccountManager' => array( 'Kontowy zastojnik' ), |
| 39 | +); |
| 40 | + |
| 41 | +/** French (Français) */ |
| 42 | +$aliases['fr'] = array( |
| 43 | + 'AccountManager' => array( 'Gestionnaire de compte', 'GestionnaireDeCompte' ), |
| 44 | +); |
| 45 | + |
| 46 | +/** Galician (Galego) */ |
| 47 | +$aliases['gl'] = array( |
| 48 | + 'AccountManager' => array( 'Xestor de contas' ), |
| 49 | +); |
| 50 | + |
| 51 | +/** Upper Sorbian (Hornjoserbsce) */ |
| 52 | +$aliases['hsb'] = array( |
| 53 | + 'AccountManager' => array( 'Kontowy zrjadowak' ), |
| 54 | +); |
| 55 | + |
| 56 | +/** Interlingua (Interlingua) */ |
| 57 | +$aliases['ia'] = array( |
| 58 | + 'AccountManager' => array( 'Gestion de contos' ), |
| 59 | +); |
| 60 | + |
| 61 | +/** Japanese (日本語) */ |
| 62 | +$aliases['ja'] = array( |
| 63 | + 'AccountManager' => array( 'アカウントマネージャー' ), |
| 64 | +); |
| 65 | + |
| 66 | +/** Khmer (ភាសាខ្មែរ) */ |
| 67 | +$aliases['km'] = array( |
| 68 | + 'AccountManager' => array( 'គ្រប់គ្រងគណនី' ), |
| 69 | +); |
| 70 | + |
| 71 | +/** Nedersaksisch (Nedersaksisch) */ |
| 72 | +$aliases['nds-nl'] = array( |
| 73 | + 'AccountManager' => array( 'Gebrukersbeheer' ), |
| 74 | +); |
| 75 | + |
| 76 | +/** Dutch (Nederlands) */ |
| 77 | +$aliases['nl'] = array( |
| 78 | + 'AccountManager' => array( 'Gebruikersbeheer' ), |
| 79 | +); |
| 80 | + |
| 81 | +/** Norwegian (bokmål) (Norsk (bokmål)) */ |
| 82 | +$aliases['no'] = array( |
| 83 | + 'AccountManager' => array( 'Kontobehandling' ), |
| 84 | +); |
| 85 | + |
| 86 | +/** Brazilian Portuguese (Português do Brasil) */ |
| 87 | +$aliases['pt-br'] = array( |
| 88 | + 'AccountManager' => array( 'Gerenciador de contas' ), |
| 89 | +); |
| 90 | + |
| 91 | +/** Sanskrit (संस्कृत) */ |
| 92 | +$aliases['sa'] = array( |
| 93 | + 'AccountManager' => array( 'उपयोजकसंज्ञाप्रबन्धक' ), |
| 94 | +); |
| 95 | + |
| 96 | +/** Albanian (Shqip) */ |
| 97 | +$aliases['sq'] = array( |
| 98 | + 'AccountManager' => array( 'MenaxhuesLlogarie' ), |
| 99 | +); |
| 100 | + |
| 101 | +/** Swahili (Kiswahili) */ |
| 102 | +$aliases['sw'] = array( |
| 103 | + 'AccountManager' => array( 'AkauntiKuu' ), |
| 104 | +); |
| 105 | + |
| 106 | +/** Tagalog (Tagalog) */ |
| 107 | +$aliases['tl'] = array( |
| 108 | + 'AccountManager' => array( 'Tagapamahala ng akawnt' ), |
| 109 | +); |
| 110 | + |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.alias.php |
___________________________________________________________________ |
Name: svn:keywords |
1 | 111 | + Id |
Name: svn:mergeinfo |
2 | 112 | + |
Name: svn:eol-style |
3 | 113 | + native |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssGroup.php |
— | — | @@ -0,0 +1,18 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class NssGroup { |
| 5 | + private static $groupsByGid = array(); |
| 6 | + public static function nameFromGid( $gid ) { |
| 7 | + if ( isset( self::$groupsByGid( $gid ) ) ) |
| 8 | + return self::$groupsByGid( $gid ); |
| 9 | + |
| 10 | + global $wgAuth; |
| 11 | + $dbr = $wgAuth->getDB( DB_READ ); |
| 12 | + $res = $dbr->select( 'groups', 'grp_name', array( 'grp_gid' => $gid ), __METHOD__ ); |
| 13 | + |
| 14 | + $row = $res->fetchObject(); |
| 15 | + self::$groupsByGid[$gid] = $row ? $row->grp_name : strval( $gid ); |
| 16 | + |
| 17 | + return self::$groupsByGid( $gid ); |
| 18 | + } |
| 19 | +} |
\ No newline at end of file |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssGroup.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 20 | + native |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssProperties.php |
— | — | @@ -0,0 +1,56 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class NssProperties { |
| 5 | + private static $users = array(); |
| 6 | + public static function forUser( $username ) { |
| 7 | + if ( isset( self::$users[$username] ) ) |
| 8 | + return self::$users[$username]; |
| 9 | + |
| 10 | + global $wgAuth; |
| 11 | + $dbr = $wgAuth->getDB( DB_READ ); |
| 12 | + $res = $dbr->select( 'user_props', |
| 13 | + array( 'up_name', 'up_value' ), |
| 14 | + array( 'up_user' => $username ), |
| 15 | + __METHOD__, |
| 16 | + array( 'ORDER BY' => 'up_timestamp ASC' ) |
| 17 | + ); |
| 18 | + |
| 19 | + $props = array(); |
| 20 | + while ( $row = $res->fetchObject() ) { |
| 21 | + $props[$row->up_name] = $row->up_value; |
| 22 | + } |
| 23 | + |
| 24 | + $propObj = new self( $username ); |
| 25 | + $propObj->props = $props; |
| 26 | + self::$users[$username] = $propObj; |
| 27 | + return $propObj; |
| 28 | + } |
| 29 | + |
| 30 | + function __construct( $name = null ) { |
| 31 | + $this->name = $name; |
| 32 | + $this->props = array(); |
| 33 | + $this->changed = array(); |
| 34 | + } |
| 35 | + function set( $name, $value ) { |
| 36 | + $this->changed[] = $name; |
| 37 | + $this->props[$name] = $value; |
| 38 | + } |
| 39 | + |
| 40 | + function commit() { |
| 41 | + global $wgAuth; |
| 42 | + $dbw = $wgAuth->getDB( DB_WRITE ); |
| 43 | + |
| 44 | + $insert = array(); |
| 45 | + $timestamp = $dbw->timestamp(); |
| 46 | + |
| 47 | + foreach ( $this->props as $name => $value ) { |
| 48 | + $insert[] = array( |
| 49 | + 'up_timestamp' => $timestamp, |
| 50 | + 'up_user' => $this->name, |
| 51 | + 'up_name' => $name, |
| 52 | + 'up_value' => $value |
| 53 | + ); |
| 54 | + } |
| 55 | + $dbw->insert( 'user_props', $insert, __METHOD__ ); |
| 56 | + } |
| 57 | +} |
\ No newline at end of file |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssProperties.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 58 | + native |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssUser.php |
— | — | @@ -0,0 +1,80 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class NssUser { |
| 5 | + function __construct( $name ) { |
| 6 | + $this->name = $name; |
| 7 | + |
| 8 | + $this->loaded = false; |
| 9 | + |
| 10 | + // Set default values to null |
| 11 | + $this->uid = $this->gid = $this->home = $this->active = $this->email = null; |
| 12 | + $this->exists = false; } |
| 13 | + |
| 14 | + function load() { |
| 15 | + if ( $this->loaderd ) |
| 16 | + return; |
| 17 | + |
| 18 | + global $wgAuth; |
| 19 | + $dbw = $wgAuth->getDB( DB_READ ); |
| 20 | + |
| 21 | + // Load the user existence from passwd |
| 22 | + $result = $dbw->select( 'passwd', |
| 23 | + array( 'pwd_uid', 'pwd_gid', 'pwd_home', 'pwd_active', 'pwd_email' ), |
| 24 | + array( 'pwd_name', $this->name ), |
| 25 | + __METHOD__ |
| 26 | + ); |
| 27 | + $row = $result->fetchObject(); |
| 28 | + $this->loadFromRow( $row ); |
| 29 | + } |
| 30 | + |
| 31 | + function loadFromRow( $row ) { |
| 32 | + $this->exists = (bool)$row; |
| 33 | + if ($this->exists) { |
| 34 | + // Extract props from row |
| 35 | + $this->uid = $row->pwd_uid; |
| 36 | + $this->gid = $row->pwd_home; |
| 37 | + $this->home = $row->pwd_home; |
| 38 | + $this->active = $row->pwd_active; |
| 39 | + $this->email = $row->pwd_home; |
| 40 | + |
| 41 | + $this->group = NssGroup::nameFromGid( $this->gid ); |
| 42 | + $this->properties = NssProperties::forUser( $this->name ); |
| 43 | + } else { |
| 44 | + $this->group = ''; |
| 45 | + $this->properties = new NssProperties(); |
| 46 | + } |
| 47 | + |
| 48 | + $this->loaded = true; |
| 49 | + } |
| 50 | + |
| 51 | + function setHome( $home ) { |
| 52 | + $this->home = $home; |
| 53 | + $this->properties->set( 'home', $home ); |
| 54 | + } |
| 55 | + function setActive( $active ) { |
| 56 | + $this->active = $active; |
| 57 | + $this->properties->set( 'active', $active ); |
| 58 | + } |
| 59 | + function setEmail( $email ) { |
| 60 | + $this->email = $email; |
| 61 | + $this->properties->set( 'email', $email ); |
| 62 | + } |
| 63 | + function set( $name, $value ) { |
| 64 | + $this->properties->set( $name, $value ); |
| 65 | + } |
| 66 | + |
| 67 | + function commit() { |
| 68 | + global $wgAuth; |
| 69 | + $dbw = $wgAuth->getDB( DB_WRITE ); |
| 70 | + |
| 71 | + $dbw->update( 'passwd', |
| 72 | + array( 'pwd_email' => $this->email, 'pwd_active' => $this->active ), |
| 73 | + array( 'pwd_name' => $this->name ), |
| 74 | + __METHOD__ |
| 75 | + ); |
| 76 | + |
| 77 | + $this->properties->commit(); |
| 78 | + $dbw->immediateCommit(); |
| 79 | + } |
| 80 | +} |
| 81 | + |
\ No newline at end of file |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/NssUser.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 82 | + native |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.php |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +<?php |
| 3 | +$dir = dirname( __FILE__ ) . '/'; |
| 4 | + |
| 5 | +$wgExtensionMessagesFiles['AccountManager'] = $dir . 'AccountManager.i18n.php'; |
| 6 | +$wgExtensionAliasesFiles['AccountManager'] = $dir . 'AccountManager.alias.php'; |
| 7 | + |
| 8 | +$wgAutoloadClasses['SpecialAccountManager'] = $dir . 'SpecialAccountManager.php'; |
| 9 | +$wgSpecialPages['AccountManager'] = 'SpecialAccountManager'; |
| 10 | + |
| 11 | +$wgUserProperties = array( 'address', 'city' ); |
| 12 | +$wgActivityModes = array( 'active', 'inactive' ); |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/AccountManager.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 13 | + native |
Index: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/SpecialAccountManager.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SpecialAccountManager extends SpecialPage { |
| 5 | + function __construct() { |
| 6 | + parent::__construct( 'AccountManager', 'accountmanager', false ); |
| 7 | + $this->mErrors = array(); |
| 8 | + } |
| 9 | + |
| 10 | + function processData() { |
| 11 | + global $wgRequest; |
| 12 | + |
| 13 | + |
| 14 | + } |
| 15 | + |
| 16 | + |
| 17 | +} |
Property changes on: branches/NssMySQLAuth-rewrite/NssMySQLAuth/AccountManager/SpecialAccountManager.php |
___________________________________________________________________ |
Name: svn:mergeinfo |
1 | 18 | + |
Name: svn:eol-style |
2 | 19 | + native |