r29593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29592‎ | r29593 | r29594 >
Date:13:37, 11 January 2008
Author:siebrand
Status:old
Tags:
Comment:
* use wfLoadExtensionMessages for NewUserNotif
* delay message loading
* bump version, update README
* update Translate extension
Modified paths:
  • /trunk/extensions/NewUserNotif/NewUserNotif.class.php (modified) (history)
  • /trunk/extensions/NewUserNotif/NewUserNotif.i18n.php (modified) (history)
  • /trunk/extensions/NewUserNotif/NewUserNotif.php (modified) (history)
  • /trunk/extensions/NewUserNotif/README (modified) (history)
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewUserNotif/NewUserNotif.class.php
@@ -10,10 +10,10 @@
1111 require_once( 'UserMailer.php' );
1212
1313 class NewUserNotifier {
14 -
 14+
1515 private $sender;
1616 private $user;
17 -
 17+
1818 /**
1919 * Constructor
2020 */
@@ -29,6 +29,7 @@
3030 */
3131 public function execute( $user ) {
3232 $this->user = $user;
 33+ wfLoadExtensionMessages( 'NewUserNotifier' );
3334 $this->sendExternalMails();
3435 $this->sendInternalMails();
3536 }
@@ -47,7 +48,7 @@
4849 );
4950 }
5051 }
51 -
 52+
5253 /**
5354 * Send email to users
5455 */
@@ -64,7 +65,7 @@
6566 }
6667 }
6768 }
68 -
 69+
6970 /**
7071 * Initialise a user from an identifier or a username
7172 *
@@ -95,7 +96,7 @@
9697 $wgContLang->timeAndDate( wfTimestampNow() )
9798 );
9899 }
99 -
 100+
100101 /**
101102 * Hook account creation
102103 *
@@ -107,5 +108,4 @@
108109 $notifier->execute( $user );
109110 return true;
110111 }
111 -
112 -}
\ No newline at end of file
 112+}
Index: trunk/extensions/NewUserNotif/NewUserNotif.i18n.php
@@ -1,154 +1,147 @@
22 <?php
3 -
43 /**
5 - * Internationalisation file for the New User Email Notification extension
6 - *
 4+ * Internationalisation file for the extension New User Email Notification
75 * @addtogroup Extensions
86 * @author Rob Church <robchur@gmail.com>
97 */
108
11 -function efNewUserNotifMessages() {
12 - $messages = array(
13 -
14 -'en' => array(
 9+$messages = array();
 10+
 11+/* English
 12+ * @author Rob Church
 13+ */
 14+$messages['en'] = array(
1515 'newusernotifsubj' => 'New User Notification for $1',
1616 'newusernotifbody' => "Hello $1,\n\nA new user account, $2, has been created on $3 at $4.",
17 -),
 17+);
1818
19 -'ar' => array(
 19+$messages['ar'] = array(
2020 'newusernotifsubj' => 'إخطار مستخدم جديد ل$1',
2121 'newusernotifbody' => 'مرحبا يا $1،
2222
2323 حساب مستخدم جديد، $2، تم إنشاؤه على $3 في $4.',
24 -),
 24+);
2525
2626 /** Bulgarian (Български)
2727 * @author DCLXVI
2828 */
29 -'bg' => array(
 29+$messages['bg'] = array(
3030 'newusernotifsubj' => 'Съобщение за нов потребител в $1',
3131 'newusernotifbody' => 'Здравейте $1,
3232
3333 В $3 беше регистрирана нова потребителска сметка, $2, на $4.',
34 -),
 34+);
3535
36 -'de' => array(
 36+$messages['de'] = array(
3737 'newusernotifsubj' => 'Benachrichtung für $1 über die Einrichtung eines neuen Benutzerskontos',
3838 'newusernotifbody' => "Hallo $1,\n\nEin neues Benutzerkonto, $2, wurde am $4 auf $3 angelegt.",
39 -),
 39+);
4040
41 -'fr' => array(
 41+$messages['fr'] = array(
4242 'newusernotifsubj' => 'Notification d’un nouvel utilisateur pour $1',
4343 'newusernotifbody' => "Bonjour $1,\n\nUn nouveau compte utilisateur, $2, a été créé sur $3 le $4.",
44 -),
 44+);
4545
46 -'gl' => array(
 46+$messages['gl'] = array(
4747 'newusernotifsubj' => 'Notificación de novo usuario para $1',
4848 'newusernotifbody' => 'Ola $1,
4949
5050 Unha nova conta de usuario, $2, foi creada sobre $3 en $4.',
51 -),
 51+);
5252
53 -'hsb' => array(
 53+$messages['hsb'] = array(
5454 'newusernotifsubj' => 'Zdźělenka za noweho wužiwarja $1',
5555 'newusernotifbody' => 'Witaj $1,
5656
5757 Nowe wužiwarske konto, $2, bu dnja $4 na $3 wutworjene.',
58 -),
 58+);
5959
60 -'hy' => array(
 60+$messages['hy'] = array(
6161 'newusernotifsubj' => 'Նոր Մասնակցի Տեղեկացում $1 մասնակցի համար',
6262 'newusernotifbody' => 'Ողջո՜ւյն, $1։
6363
6464 $3 կայքում ստեղծվել է նոր մասնակցային հաշիվ՝ $2, $4-ին։',
65 -),
 65+);
6666
67 -'nl' => array(
 67+$messages['nl'] = array(
6868 'newusernotifsubj' => 'Melding van een nieuwe gebruiker op $1',
6969 'newusernotifbody' => 'Hallo $1.
7070
7171 Er is een nieuwe gebruiker $2 aangemaakt om $3 op $4.',
72 -),
 72+);
7373
74 -'no' => array(
 74+$messages['no'] = array(
7575 'newusernotifsubj' => 'Beskjed om ny bruker for $1',
7676 'newusernotifbody' => 'Hei, $1. En ny brukerkonto, $2, ble opprettet på $3 $4.',
77 -),
 77+);
7878
79 -'oc' => array(
 79+$messages['oc'] = array(
8080 'newusernotifsubj' => 'Notificacion d’un utilizaire novèl per $1',
8181 'newusernotifbody' => 'Adissiatz $1, Un compte novèl d\'utilizaire, $2, es estat creat sus $3 lo $4.',
82 -),
 82+);
8383
84 -'pl' => array(
 84+$messages['pl'] = array(
8585 'newusernotifsubj' => 'Powiadamianie użytkownika $1 o nowych użytkownikach',
8686 'newusernotifbody' => 'Witaj $1, nowe konto użytkownika, $2, zostało stworzone w dniu $3 o $4.',
87 -),
 87+);
8888
89 -'pms' => array(
 89+$messages['pms'] = array(
9090 'newusernotifsubj' => 'Notìfica d\'utent neuv për $1',
9191 'newusernotifbody' => 'Bondì $1, un neuv utent, $2, a l\'é stait creà ansima a $3 dël $4.',
92 -),
 92+);
9393
9494 /** Slovak (Slovenčina)
9595 * @author Helix84
9696 */
97 -'sk' => array(
 97+$messages['sk'] = array(
9898 'newusernotifsubj' => 'Upozornenie na nových používateľov pre $1',
9999 'newusernotifbody' => 'Ahoj $1,
100100
101101 $3 na $4 bol vytvorený nový používateľský účet $2.',
102 -),
 102+);
103103
104104 /** ћирилица (ћирилица)
105105 * @author Sasa Stefanovic
106106 */
107 -'sr-ec' => array(
 107+$messages['sr-ec'] = array(
108108 'newusernotifsubj' => 'Нови корисник за $1',
109109 'newusernotifbody' => 'Здраво $1
110110 Нови кориснички налог, $2, је направљен на $3 у $4.',
111 -),
 111+);
112112
113113 /** Seeltersk (Seeltersk)
114114 * @author Pyt
115115 */
116 -'stq' => array(
 116+$messages['stq'] = array(
117117 'newusernotifsubj' => 'Bescheedtällen foar $1 uur ju Iengjuchtenge fon n näi Benutserkonto',
118118 'newusernotifbody' => 'Hallo $1,
119119
120120 N näi Benutserkonto, $2, wuude ap n $4 ap $3 anlaid.',
121 -),
 121+);
122122
123 -'tet' => array(
 123+$messages['tet'] = array(
124124 'newusernotifsubj' => 'Mensajen kona-ba uza-na\'in foun ba $1',
125125 'newusernotifbody' => 'Olá $1,\n\nuza-na\'in foun, $2, registrar tiha iha $3 iha loron $4.',
126 -),
 126+);
127127
128 -'yue' => array(
 128+$messages['yue'] = array(
129129 'newusernotifsubj' => '$1嘅新用戶通知',
130130 'newusernotifbody' => "你好 $1,\n\n一個新嘅用戶戶口$2,已經響$4喺$3度開咗。",
131 -),
 131+);
132132
133 -'zh-hans' => array(
 133+$messages['zh-hans'] = array(
134134 'newusernotifsubj' => '$1的新用户通知',
135135 'newusernotifbody' => "你好 $1,\n\n一个新的用户账号$2,已经在$4于$3创建。",
136 -),
 136+);
137137
138 -'zh-hant' => array(
 138+$messages['zh-hant'] = array(
139139 'newusernotifsubj' => '$1的新用戶通知',
140140 'newusernotifbody' => "你好 $1,\n\n一個新的用戶帳號$2,已經在$4於$3創建。",
141 -),
142 -
143 - );
 141+);
144142
145 - /* Chinese defaults, fallback to zh-hans or zh-hant */
146 - $messages['zh'] = $messages['zh-hans'];
147 - $messages['zh-cn'] = $messages['zh-hans'];
148 - $messages['zh-hk'] = $messages['zh-hant'];
149 - $messages['zh-sg'] = $messages['zh-hans'];
150 - $messages['zh-tw'] = $messages['zh-hant'];
151 - /* Cantonese default, fallback to yue */
152 - $messages['zh-yue'] = $messages['yue'];
153 -
154 - return $messages;
155 -}
 143+$messages['zh'] = $messages['zh-hans'];
 144+$messages['zh-cn'] = $messages['zh-hans'];
 145+$messages['zh-hk'] = $messages['zh-hant'];
 146+$messages['zh-sg'] = $messages['zh-hans'];
 147+$messages['zh-tw'] = $messages['zh-hant'];
 148+$messages['zh-yue'] = $messages['yue'];
Index: trunk/extensions/NewUserNotif/README
@@ -1,6 +1,6 @@
22 NEW USER EMAIL NOTIFICATION EXTENSION
33
4 - Version 1.4
 4+ Version 1.5
55 © 2006-2007 Rob Church
66
77 This is free software licenced under the GNU General Public Licence. Please
Index: trunk/extensions/NewUserNotif/NewUserNotif.php
@@ -1,4 +1,6 @@
22 <?php
 3+if ( ! defined( 'MEDIAWIKI' ) )
 4+ die();
35
46 /**
57 * Extension to provide customisable email notification of new user creation
@@ -9,54 +11,48 @@
1012 * @licence GNU General Public Licence 2.0 or later
1113 */
1214
13 -if( defined( 'MEDIAWIKI' ) ) {
 15+$wgExtensionCredits['other'][] = array(
 16+ 'name' => 'New User Email Notification',
 17+ 'version' => '1.5',
 18+ 'author' => 'Rob Church',
 19+ 'url' => 'http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification',
 20+ 'description' => 'Sends email notification when user accounts are created',
 21+);
1422
15 - $wgAutoloadClasses['NewUserNotifier'] = dirname( __FILE__ ) . '/NewUserNotif.class.php';
16 - $wgExtensionFunctions[] = 'efNewUserNotifSetup';
17 - $wgExtensionCredits['other'][] = array(
18 - 'name' => 'New User Email Notification',
19 - 'author' => 'Rob Church',
20 - 'url' => 'http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification',
21 - 'description' => 'Sends email notification when user accounts are created',
22 - );
 23+$dir = dirname(__FILE__) . '/';
 24+$wgExtensionMessagesFiles['NewUserNotifier'] = $dir . 'NewUserNotif.i18n.php';
 25+$wgAutoloadClasses['NewUserNotifier'] = $dir . 'NewUserNotif.class.php';
 26+$wgExtensionFunctions[] = 'efNewUserNotifSetup';
2327
24 - /**
25 - * Email address to use as the sender
26 - */
27 - $wgNewUserNotifSender = $wgPasswordSender;
28 -
29 - /**
30 - * Users who should receive notification mails
31 - */
32 - $wgNewUserNotifTargets[] = 1;
33 -
34 - /**
35 - * Additional email addresses to send mails to
36 - */
37 - $wgNewUserNotifEmailTargets = array();
 28+/**
 29+ * Email address to use as the sender
 30+ */
 31+$wgNewUserNotifSender = $wgPasswordSender;
3832
39 - /**
40 - * Extension setup
41 - */
42 - function efNewUserNotifSetup() {
43 - global $wgHooks, $wgMessageCache;
44 - $wgHooks['AddNewAccount'][] = 'efNewUserNotif';
45 - require_once( dirname( __FILE__ ) . '/NewUserNotif.i18n.php' );
46 - foreach( efNewUserNotifMessages() as $lang => $messages )
47 - $wgMessageCache->addMessages( $messages, $lang );
48 - }
49 -
50 - /**
51 - * Hook account creation
52 - *
53 - * @param User $user User account that was created
54 - * @return bool
55 - */
56 - function efNewUserNotif( $user ) {
57 - return NewUserNotifier::hook( $user );
58 - }
59 -
60 -} else {
61 - echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
62 - exit( 1 );
63 -}
\ No newline at end of file
 33+/**
 34+ * Users who should receive notification mails
 35+ */
 36+$wgNewUserNotifTargets[] = 1;
 37+
 38+/**
 39+ * Additional email addresses to send mails to
 40+ */
 41+$wgNewUserNotifEmailTargets = array();
 42+
 43+/**
 44+ * Extension setup
 45+ */
 46+function efNewUserNotifSetup() {
 47+ global $wgHooks;
 48+ $wgHooks['AddNewAccount'][] = 'efNewUserNotif';
 49+}
 50+
 51+/**
 52+ * Hook account creation
 53+ *
 54+ * @param User $user User account that was created
 55+ * @return bool
 56+ */
 57+function efNewUserNotif( $user ) {
 58+ return NewUserNotifier::hook( $user );
 59+}
Index: trunk/extensions/Translate/MessageGroups.php
@@ -1412,17 +1412,11 @@
14131413 }
14141414
14151415 class NewUserNotifMessageGroup extends ExtensionMessageGroup {
1416 - protected $fileExporter = null;
14171416 protected $label = 'New User Notification';
14181417 protected $id = 'ext-newusernotif';
14191418
1420 - protected $functionName = 'efNewUserNotifMessages';
 1419+ protected $arrName = 'messages';
14211420 protected $messageFile = 'NewUserNotif/NewUserNotif.i18n.php';
1422 -
1423 - protected $exportStart = '\'$CODE\' => array(';
1424 - protected $exportPrefix= '';
1425 - protected $exportLineP = "\t";
1426 - protected $exportEnd = '),';
14271421 }
14281422
14291423 class NukeMessageGroup extends ExtensionMessageGroup {

Status & tagging log