r94257 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94256‎ | r94257 | r94258 >
Date:17:18, 11 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on v0.3
Modified paths:
  • /trunk/extensions/SemanticSignup/INSTALL (modified) (history)
  • /trunk/extensions/SemanticSignup/SemanticSignup.i18n.aliases.php (modified) (history)
  • /trunk/extensions/SemanticSignup/SemanticSignup.i18n.php (modified) (history)
  • /trunk/extensions/SemanticSignup/SemanticSignup.php (modified) (history)
  • /trunk/extensions/SemanticSignup/SemanticSignup.settings.php (modified) (history)
  • /trunk/extensions/SemanticSignup/includes/SES_Special.php (modified) (history)
  • /trunk/extensions/SemanticSignup/release-notes (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticSignup/SemanticSignup.php
@@ -25,18 +25,22 @@
2626 }
2727
2828 if ( version_compare( $wgVersion, '1.16', '<' ) ) {
29 - die( '<b>Error:</b> Semantic Signup requires MediaWiki 1.16 or above.' );
 29+ die( '<b>Error:</b> SemanticSignup requires MediaWiki 1.16 or above.' );
3030 }
3131
3232 // Show a warning if Semantic MediaWiki is not loaded.
33 -if ( ! defined( 'SMW_VERSION' ) ) {
34 - die( '<b>Error:</b> You need to have <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> installed in order to use Semantic Watchlist.' );
 33+if ( !defined( 'SMW_VERSION' ) ) {
 34+ die( '<b>Error:</b> You need to have <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> installed in order to use SemanticSignup.' );
3535 }
3636
3737 if ( version_compare( SMW_VERSION, '1.6 alpha', '<' ) ) {
3838 die( '<b>Error:</b> Semantic Signup requires Semantic MediaWiki 1.6 or above.' );
3939 }
4040
 41+if ( !defined( 'SF_VERSION' ) ) {
 42+ die( '<b>Error:</b> You need to have <a href="http://semantic-mediawiki.org/wiki/Semantic_Forms">Semantic Forms</a> installed in order to use SemanticSignup.' );
 43+}
 44+
4145 define( 'SemanticSignup_VERSION', '0.3 alpha' );
4246
4347 $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array(
@@ -54,6 +58,7 @@
5559 $wgExtensionMessagesFiles['SemanticSignup'] = dirname( __FILE__ ) . '/SemanticSignup.i18n.php';
5660 $wgExtensionAliasesFiles['SemanticSignup'] = dirname( __FILE__ ) . '/SemanticSignup.i18n.aliases.php';
5761
 62+$wgAutoloadClasses['SemanticSignupSettings'] = dirname( __FILE__ ) . '/SemanticSignup.settings.php';
5863 $wgAutoloadClasses['SemanticSignupHooks'] = dirname( __FILE__ ) . '/SemanticSignup.hooks.php';
5964 $wgAutoloadClasses['SemanticSignup'] = dirname( __FILE__ ) . '/includes/SES_Special.php';
6065 $wgAutoloadClasses['SES_UserAccountDataChecker'] = dirname( __FILE__ ) . '/includes/SES_Special.php';
@@ -63,7 +68,13 @@
6469
6570 $wgSpecialPages['SemanticSignup'] = 'SemanticSignup';
6671
67 -$wgHooks['UserCreateForm'][] = 'SemanticSignupHooks::onUserCreateForm';
68 -$wgHooks['ParserFirstCallInit'][] = 'SemanticSignupHooks::onParserFirstCallInit';
 72+$egSemanticSignupSettings = array();
6973
70 -require_once 'SemanticSignup.settings.php';
 74+$wgExtensionFunctions[] = 'efSemanticSignupSetup';
 75+
 76+function efSemanticSignupSetup() {
 77+ if ( !is_null( Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM ) ) ) {
 78+ $wgHooks['UserCreateForm'][] = 'SemanticSignupHooks::onUserCreateForm';
 79+ $wgHooks['ParserFirstCallInit'][] = 'SemanticSignupHooks::onParserFirstCallInit';
 80+ }
 81+}
Index: trunk/extensions/SemanticSignup/INSTALL
@@ -10,6 +10,7 @@
1111
1212 * MediaWiki 1.16 or above
1313 * Semantic MediaWiki 1.6 or above
 14+* Semantic Forms 2.0 or above
1415 * PHP 5.2 or above
1516
1617 == Download ==
Index: trunk/extensions/SemanticSignup/includes/SES_Special.php
@@ -194,8 +194,7 @@
195195 $user->setOption( 'language', $language );
196196
197197 global $wgEmailAuthentication;
198 - if( $wgEmailAuthentication && User::isValidEmailAddr($user->getEmail()) )
199 - {
 198+ if( $wgEmailAuthentication && User::isValidEmailAddr( $user->getEmail() ) ){
200199 $err = $user->sendConfirmationMail();
201200 if (WikiError::isError($err))
202201 throw new Exception(wfMsg('emailfailed'));
@@ -205,11 +204,8 @@
206205 wfRunHooks('AddNewAccount', array($user));
207206 }
208207
209 - private function createUserPage()
210 - {
211 - global $sesSignupFormName;
212 -
213 - $form_title = Title::newFromText($sesSignupFormName, SF_NS_FORM);
 208+ private function createUserPage() {
 209+ $form_title = Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM );
214210 $form = new Article($form_title);
215211 $form_definition = $form->getContent();
216212
@@ -224,12 +220,10 @@
225221
226222 global $wgUser;
227223 $wgUser = $this->mUserDataChecker->mUser;
228 - $user_page->doEdit($data_text, '', EDIT_FORCE_BOT);
 224+ $user_page->doEdit( $data_text, '', EDIT_FORCE_BOT );
229225 }
230226
231 - private function printForm()
232 - {
233 - global $sesSignupFormName;
 227+ private function printForm() {
234228 global $sesSignupBotName;
235229 global $wgUser;
236230
@@ -245,7 +239,7 @@
246240 $wgUser = User::newFromName($sesSignupBotName);
247241 }
248242
249 - $form_title = Title::newFromText($sesSignupFormName, SF_NS_FORM);
 243+ $form_title = Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM );
250244 $form = new Article($form_title);
251245 $form_definition = $form->getContent();
252246
Index: trunk/extensions/SemanticSignup/release-notes
@@ -1,6 +1,21 @@
2 -SemanticSignup
 2+These are the release notes for the SemanticSignup extension.
 3+
 4+Extension page on mediawiki.org: http://www.mediawiki.org/wiki/Extension:SemanticSignup
 5+Latest version of the release notes: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SemanticSignup/RELEASE-NOTES?view=co
36
4 -Version 0.2.0:
57
6 -- a new configuration setting $sesSignupBotName added;
7 -- README sections 3 and 4 updated.
 8+=== Version 0.3 ===
 9+2011-0x-xx
 10+
 11+* Added compatibility with MediaWiki 1.16 and above, removed compatibility with MediaWiki below 1.16.
 12+* Added compatibility with Semantic MediaWiki 1.6 and above.
 13+* Added INSTALL file.
 14+* Rewrote setting handling.
 15+* Moved entry point to SemanticSignup.php.
 16+* Moved code to standard i18n, hooks and settings files.
 17+* Stylized code.
 18+
 19+=== Version 0.2 ===
 20+
 21+* a new configuration setting $sesSignupBotName added;
 22+* README sections 3 and 4 updated.
Index: trunk/extensions/SemanticSignup/SemanticSignup.i18n.aliases.php
@@ -7,5 +7,5 @@
88 $aliases = array();
99
1010 $aliases['en'] = array(
11 - 'Semantic Signup' => array('Semantic Signup')
 11+ 'SemanticSignup' => array( 'SemanticSignup', 'Semantic Signup' )
1212 );
Index: trunk/extensions/SemanticSignup/SemanticSignup.i18n.php
@@ -18,4 +18,4 @@
1919 'createforbidden' => 'Current user is not allowed to create accounts',
2020 'throttlehit' => 'New user accounts number maximum per day has been exceeded for this IP',
2121 'ses_userexists' => 'User already exists'
22 -);
\ No newline at end of file
 22+);
Index: trunk/extensions/SemanticSignup/SemanticSignup.settings.php
@@ -12,18 +12,35 @@
1313 * @ingroup SemanticSignup
1414 *
1515 * @licence GNU GPL v3+
16 - * @author Serg Kutny
1716 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1817 */
1918
20 -if ( !defined( 'MEDIAWIKI' ) ) {
21 - die( 'Not an entry point.' );
 19+class SemanticSignupSettings {
 20+
 21+ protected static function getDefaultSettings() {
 22+ return array(
 23+ 'requireName' => false,
 24+ 'formName' => '',
 25+ 'botName' => '',
 26+ );
 27+ }
 28+
 29+ public static function getSettings() {
 30+ static $settings = false;
 31+
 32+ if ( $settings === false ) {
 33+ $settings = array_merge(
 34+ self::getDefaultSettings(),
 35+ $GLOBALS['egSemanticSignupSettings']
 36+ );
 37+ }
 38+
 39+ return $settings;
 40+ }
 41+
 42+ public static function get( $settingName ) {
 43+ $settings = self::getSettings();
 44+ return array_key_exists( $settingName, $settings ) ? $settings[$settingName] : null;
 45+ }
 46+
2247 }
23 -
24 -/*
25 - * I need real name to be required on user signup for my purposes
26 - * so I make this feature configurable
27 - */
28 -$sesRealNameRequired = false;
29 -$sesSignupFormName = '';
30 -$sesSignupBotName = '';
\ No newline at end of file