Index: trunk/extensions/SemanticSignup/SemanticSignup.php |
— | — | @@ -25,18 +25,22 @@ |
26 | 26 | } |
27 | 27 | |
28 | 28 | 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.' ); |
30 | 30 | } |
31 | 31 | |
32 | 32 | // 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.' ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | if ( version_compare( SMW_VERSION, '1.6 alpha', '<' ) ) { |
38 | 38 | die( '<b>Error:</b> Semantic Signup requires Semantic MediaWiki 1.6 or above.' ); |
39 | 39 | } |
40 | 40 | |
| 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 | + |
41 | 45 | define( 'SemanticSignup_VERSION', '0.3 alpha' ); |
42 | 46 | |
43 | 47 | $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array( |
— | — | @@ -54,6 +58,7 @@ |
55 | 59 | $wgExtensionMessagesFiles['SemanticSignup'] = dirname( __FILE__ ) . '/SemanticSignup.i18n.php'; |
56 | 60 | $wgExtensionAliasesFiles['SemanticSignup'] = dirname( __FILE__ ) . '/SemanticSignup.i18n.aliases.php'; |
57 | 61 | |
| 62 | +$wgAutoloadClasses['SemanticSignupSettings'] = dirname( __FILE__ ) . '/SemanticSignup.settings.php'; |
58 | 63 | $wgAutoloadClasses['SemanticSignupHooks'] = dirname( __FILE__ ) . '/SemanticSignup.hooks.php'; |
59 | 64 | $wgAutoloadClasses['SemanticSignup'] = dirname( __FILE__ ) . '/includes/SES_Special.php'; |
60 | 65 | $wgAutoloadClasses['SES_UserAccountDataChecker'] = dirname( __FILE__ ) . '/includes/SES_Special.php'; |
— | — | @@ -63,7 +68,13 @@ |
64 | 69 | |
65 | 70 | $wgSpecialPages['SemanticSignup'] = 'SemanticSignup'; |
66 | 71 | |
67 | | -$wgHooks['UserCreateForm'][] = 'SemanticSignupHooks::onUserCreateForm'; |
68 | | -$wgHooks['ParserFirstCallInit'][] = 'SemanticSignupHooks::onParserFirstCallInit'; |
| 72 | +$egSemanticSignupSettings = array(); |
69 | 73 | |
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 @@ |
11 | 11 | |
12 | 12 | * MediaWiki 1.16 or above |
13 | 13 | * Semantic MediaWiki 1.6 or above |
| 14 | +* Semantic Forms 2.0 or above |
14 | 15 | * PHP 5.2 or above |
15 | 16 | |
16 | 17 | == Download == |
Index: trunk/extensions/SemanticSignup/includes/SES_Special.php |
— | — | @@ -194,8 +194,7 @@ |
195 | 195 | $user->setOption( 'language', $language ); |
196 | 196 | |
197 | 197 | global $wgEmailAuthentication; |
198 | | - if( $wgEmailAuthentication && User::isValidEmailAddr($user->getEmail()) ) |
199 | | - { |
| 198 | + if( $wgEmailAuthentication && User::isValidEmailAddr( $user->getEmail() ) ){ |
200 | 199 | $err = $user->sendConfirmationMail(); |
201 | 200 | if (WikiError::isError($err)) |
202 | 201 | throw new Exception(wfMsg('emailfailed')); |
— | — | @@ -205,11 +204,8 @@ |
206 | 205 | wfRunHooks('AddNewAccount', array($user)); |
207 | 206 | } |
208 | 207 | |
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 ); |
214 | 210 | $form = new Article($form_title); |
215 | 211 | $form_definition = $form->getContent(); |
216 | 212 | |
— | — | @@ -224,12 +220,10 @@ |
225 | 221 | |
226 | 222 | global $wgUser; |
227 | 223 | $wgUser = $this->mUserDataChecker->mUser; |
228 | | - $user_page->doEdit($data_text, '', EDIT_FORCE_BOT); |
| 224 | + $user_page->doEdit( $data_text, '', EDIT_FORCE_BOT ); |
229 | 225 | } |
230 | 226 | |
231 | | - private function printForm() |
232 | | - { |
233 | | - global $sesSignupFormName; |
| 227 | + private function printForm() { |
234 | 228 | global $sesSignupBotName; |
235 | 229 | global $wgUser; |
236 | 230 | |
— | — | @@ -245,7 +239,7 @@ |
246 | 240 | $wgUser = User::newFromName($sesSignupBotName); |
247 | 241 | } |
248 | 242 | |
249 | | - $form_title = Title::newFromText($sesSignupFormName, SF_NS_FORM); |
| 243 | + $form_title = Title::newFromText( SemanticSignupSettings::get( 'formName' ), SF_NS_FORM ); |
250 | 244 | $form = new Article($form_title); |
251 | 245 | $form_definition = $form->getContent(); |
252 | 246 | |
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 |
3 | 6 | |
4 | | -Version 0.2.0: |
5 | 7 | |
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 @@ |
8 | 8 | $aliases = array(); |
9 | 9 | |
10 | 10 | $aliases['en'] = array( |
11 | | - 'Semantic Signup' => array('Semantic Signup') |
| 11 | + 'SemanticSignup' => array( 'SemanticSignup', 'Semantic Signup' ) |
12 | 12 | ); |
Index: trunk/extensions/SemanticSignup/SemanticSignup.i18n.php |
— | — | @@ -18,4 +18,4 @@ |
19 | 19 | 'createforbidden' => 'Current user is not allowed to create accounts', |
20 | 20 | 'throttlehit' => 'New user accounts number maximum per day has been exceeded for this IP', |
21 | 21 | 'ses_userexists' => 'User already exists' |
22 | | -); |
\ No newline at end of file |
| 22 | +); |
Index: trunk/extensions/SemanticSignup/SemanticSignup.settings.php |
— | — | @@ -12,18 +12,35 @@ |
13 | 13 | * @ingroup SemanticSignup |
14 | 14 | * |
15 | 15 | * @licence GNU GPL v3+ |
16 | | - * @author Serg Kutny |
17 | 16 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
18 | 17 | */ |
19 | 18 | |
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 | + |
22 | 47 | } |
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 |