Index: trunk/extensions/Configure/settings/Settings-ext.txt |
— | — | @@ -311,7 +311,6 @@ |
312 | 312 | url = http://www.mediawiki.org/wiki/Extension:CommunityVoice |
313 | 313 | |
314 | 314 | ConfirmAccount |
315 | | -file = SpecialConfirmAccount.php |
316 | 315 | settings[] = wgMakeUserPageFromBio: bool, wgAutoUserBioText: text |
317 | 316 | settings[] = wgAutoWelcomeNewUsers: bool, wgUseRealNamesOnly: bool |
318 | 317 | settings[] = wgRejectedAccountMaxAge: int, wgConfirmAccountRejectAge: int |
Index: trunk/extensions/ConfirmAccount/SpecialConfirmAccount.php |
— | — | @@ -1,258 +0,0 @@ |
2 | | -<?php |
3 | | -# (c) Aaron Schulz 2007, GPL |
4 | | - |
5 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
6 | | - echo "ConfirmAccount extension\n"; |
7 | | - exit( 1 ) ; |
8 | | -} |
9 | | - |
10 | | -$wgExtensionCredits['specialpage'][] = array( |
11 | | - 'path' => __FILE__, |
12 | | - 'name' => 'Confirm user accounts', |
13 | | - 'descriptionmsg' => 'confirmedit-desc', |
14 | | - 'author' => 'Aaron Schulz', |
15 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount', |
16 | | -); |
17 | | - |
18 | | -# This extension needs email enabled! |
19 | | -# Otherwise users can't get their passwords... |
20 | | -if ( !$wgEnableEmail ) { |
21 | | - echo "ConfirmAccount extension requires \$wgEnableEmail set to true \n"; |
22 | | - exit( 1 ) ; |
23 | | -} |
24 | | - |
25 | | -# Set the person's bio as their userpage? |
26 | | -$wgMakeUserPageFromBio = true; |
27 | | -# Text to add to bio pages if the above option is on |
28 | | -$wgAutoUserBioText = ''; |
29 | | - |
30 | | -$wgAutoWelcomeNewUsers = true; |
31 | | -# Make the username of the real name? |
32 | | -$wgUseRealNamesOnly = true; |
33 | | - |
34 | | -# How long to store rejected requests |
35 | | -$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week |
36 | | -# How long after accounts have been requested/held before they count as 'rejected' |
37 | | -$wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month |
38 | | - |
39 | | -# How many requests can an IP make at once? |
40 | | -$wgAccountRequestThrottle = 1; |
41 | | -# Can blocked users request accounts? |
42 | | -$wgAccountRequestWhileBlocked = false; |
43 | | - |
44 | | -# Minimum biography specs |
45 | | -$wgAccountRequestMinWords = 50; |
46 | | - |
47 | | -# Show ToS checkbox |
48 | | -$wgAccountRequestToS = true; |
49 | | -# Show confirmation info fields |
50 | | -$wgAccountRequestExtraInfo = true; |
51 | | - |
52 | | -# Prospective account access levels. |
53 | | -# An associative array of integer => (special page param,user group,autotext) pairs. |
54 | | -# The account queues are at Special:ConfirmAccount/param. |
55 | | -# The integer keys are used to enumerate the type. |
56 | | -$wgAccountRequestTypes = array( |
57 | | - 0 => array( 'authors', 'user' ) |
58 | | -); |
59 | | - |
60 | | -# If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories. |
61 | | -# The sortkey will be made be replacing the first element of this array |
62 | | -# (regexp) with the second. Set this variable to false to avoid sortkey use. |
63 | | -$wgConfirmAccountSortkey = false; |
64 | | -// For example, the below will do {{DEFAULTSORT:firstname, lastname}} |
65 | | -# $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' ); |
66 | | - |
67 | | -# IMPORTANT: do we store the user's notes and credentials |
68 | | -# for sucessful account request? This will be stored indefinetely |
69 | | -# and will be accessible to users with crediential lookup permissions |
70 | | -$wgConfirmAccountSaveInfo = true; |
71 | | - |
72 | | -# Send an email to address when account requests confirm their email. |
73 | | -# Set to false to skip this. |
74 | | -$wgConfirmAccountContact = false; |
75 | | - |
76 | | -# If ConfirmEdit is installed and set to trigger for createaccount, |
77 | | -# inject catpchas for requests too? |
78 | | -$wgConfirmAccountCaptchas = true; |
79 | | - |
80 | | -$wgAllowAccountRequestFiles = true; |
81 | | -$wgAccountRequestExts = array( 'txt', 'pdf', 'doc', 'latex', 'rtf', 'text', 'wp', 'wpd', 'sxw' ); |
82 | | - |
83 | | -# Storage repos. Has B/C for when this used FileStore. |
84 | | -$wgConfirmAccountFSRepos = array( |
85 | | - 'accountreqs' => array( # Location of attached files for pending requests |
86 | | - 'name' => 'accountreqs', |
87 | | - 'directory' => isset($wgFileStore['accountreqs']) ? |
88 | | - $wgFileStore['accountreqs']['directory'] : "{$IP}/images/accountreqs", |
89 | | - 'url' => isset($wgFileStore['accountreqs']) ? |
90 | | - $wgFileStore['accountreqs']['url'] : null, |
91 | | - 'hashLevels' => isset($wgFileStore['accountreqs']) ? |
92 | | - $wgFileStore['accountreqs']['hash'] : 3 |
93 | | - ), |
94 | | - 'accountcreds' => array( # Location of credential files |
95 | | - 'name' => 'accountcreds', |
96 | | - 'directory' => isset($wgFileStore['accountcreds']) ? |
97 | | - $wgFileStore['accountcreds']['directory'] : "{$IP}/images/accountcreds", |
98 | | - 'url' => isset($wgFileStore['accountcreds']) ? |
99 | | - $wgFileStore['accountcreds']['url'] : null, |
100 | | - 'hashLevels' => isset($wgFileStore['accountcreds']) ? |
101 | | - $wgFileStore['accountcreds']['hash'] : 3 |
102 | | - ) |
103 | | -); |
104 | | - |
105 | | -# Restrict account creation |
106 | | -$wgGroupPermissions['*']['createaccount'] = false; |
107 | | -$wgGroupPermissions['user']['createaccount'] = false; |
108 | | -# Grant account queue rights |
109 | | -$wgGroupPermissions['bureaucrat']['confirmaccount'] = true; |
110 | | -# This right has the request IP show when confirming accounts |
111 | | -$wgGroupPermissions['bureaucrat']['requestips'] = true; |
112 | | - |
113 | | -# If credentials are stored, this right lets users look them up |
114 | | -$wgGroupPermissions['bureaucrat']['lookupcredentials'] = true; |
115 | | - |
116 | | -$wgAvailableRights[] = 'confirmaccount'; |
117 | | -$wgAvailableRights[] = 'requestips'; |
118 | | -$wgAvailableRights[] = 'lookupcredentials'; |
119 | | - |
120 | | -# Show notice for open requests to admins? |
121 | | -# This is cached, but still can be expensive on sites with thousands of requests. |
122 | | -$wgConfirmAccountNotice = true; |
123 | | - |
124 | | -$dir = dirname( __FILE__ ) . '/'; |
125 | | -$wgExtensionMessagesFiles['ConfirmAccount'] = $dir . 'ConfirmAccount.i18n.php'; |
126 | | -$wgExtensionAliasesFiles['ConfirmAccount'] = $dir . 'ConfirmAccount.alias.php'; |
127 | | - |
128 | | -function efLoadConfirmAccount() { |
129 | | - global $wgUser; |
130 | | - # Don't load unless needed |
131 | | - if ( $wgUser->getId() && $wgUser->isAllowed( 'confirmaccount' ) ) { |
132 | | - efConfirmAccountInjectStyle(); |
133 | | - } |
134 | | -} |
135 | | - |
136 | | -function efAddRequestLoginText( &$template ) { |
137 | | - global $wgUser; |
138 | | - wfLoadExtensionMessages( 'ConfirmAccount' ); |
139 | | - # Add a link to RequestAccount from UserLogin |
140 | | - if ( !$wgUser->isAllowed( 'createaccount' ) ) { |
141 | | - $template->set( 'header', wfMsgExt( 'requestaccount-loginnotice', array( 'parse' ) ) ); |
142 | | - } |
143 | | - return true; |
144 | | -} |
145 | | - |
146 | | -function efCheckIfAccountNameIsPending( $user, &$abortError ) { |
147 | | - # If an account is made with name X, and one is pending with name X |
148 | | - # we will have problems if the pending one is later confirmed |
149 | | - $dbw = wfGetDB( DB_MASTER ); |
150 | | - $dup = $dbw->selectField( 'account_requests', '1', |
151 | | - array( 'acr_name' => $user->getName() ), |
152 | | - __METHOD__ ); |
153 | | - if ( $dup ) { |
154 | | - wfLoadExtensionMessages( 'ConfirmAccount' ); |
155 | | - $abortError = wfMsgHtml( 'requestaccount-inuse' ); |
156 | | - return false; |
157 | | - } |
158 | | - return true; |
159 | | -} |
160 | | - |
161 | | -function efConfirmAccountInjectStyle() { |
162 | | - global $wgOut, $wgUser, $wgScriptPath; |
163 | | - # FIXME: find better load place |
164 | | - # UI CSS |
165 | | - $wgOut->addLink( array( |
166 | | - 'rel' => 'stylesheet', |
167 | | - 'type' => 'text/css', |
168 | | - 'media' => 'screen', |
169 | | - 'href' => $wgScriptPath . '/extensions/ConfirmAccount/confirmaccount.css', |
170 | | - ) ); |
171 | | - return true; |
172 | | -} |
173 | | - |
174 | | -function efConfirmAccountsNotice( $notice ) { |
175 | | - global $wgConfirmAccountNotice, $wgUser; |
176 | | - if ( !$wgConfirmAccountNotice || !$wgUser->isAllowed( 'confirmaccount' ) ) { |
177 | | - return true; |
178 | | - } |
179 | | - global $wgMemc, $wgOut; |
180 | | - # Check cached results |
181 | | - $key = wfMemcKey( 'confirmaccount', 'noticecount' ); |
182 | | - $count = $wgMemc->get( $key ); |
183 | | - # Only show message if there are any such requests |
184 | | - if ( !$count ) { |
185 | | - $dbw = wfGetDB( DB_MASTER ); |
186 | | - $count = $dbw->selectField( 'account_requests', 'COUNT(*)', |
187 | | - array( 'acr_deleted' => 0, 'acr_held IS NULL', 'acr_email_authenticated IS NOT NULL' ), |
188 | | - __METHOD__ ); |
189 | | - # Use '-' for zero, to avoid any confusion over key existence |
190 | | - if ( !$count ) { |
191 | | - $count = '-'; |
192 | | - } |
193 | | - # Cache results |
194 | | - $wgMemc->set( $key, $count, 3600 * 24 * 7 ); |
195 | | - } |
196 | | - if ( $count !== '-' ) { |
197 | | - wfLoadExtensionMessages( 'ConfirmAccount' ); |
198 | | - $message = wfMsgExt( 'confirmaccount-newrequests', array( 'parsemag' ), $count ); |
199 | | - |
200 | | - $notice .= '<div id="mw-confirmaccount-msg" class="mw-confirmaccount-bar">' . $wgOut->parse( $message ) . '</div>'; |
201 | | - } |
202 | | - return true; |
203 | | -} |
204 | | - |
205 | | -$dir = dirname( __FILE__ ) . '/'; |
206 | | -# Request an account |
207 | | -$wgSpecialPages['RequestAccount'] = 'RequestAccountPage'; |
208 | | -$wgAutoloadClasses['RequestAccountPage'] = $dir . 'RequestAccount_body.php'; |
209 | | -$wgSpecialPageGroups['RequestAccount'] = 'login'; |
210 | | -# Confirm accounts |
211 | | -$wgSpecialPages['ConfirmAccounts'] = 'ConfirmAccountsPage'; |
212 | | -$wgAutoloadClasses['ConfirmAccountsPage'] = $dir . 'ConfirmAccount_body.php'; |
213 | | -$wgSpecialPageGroups['ConfirmAccounts'] = 'users'; |
214 | | -# Account credentials |
215 | | -$wgSpecialPages['UserCredentials'] = 'UserCredentialsPage'; |
216 | | -$wgAutoloadClasses['UserCredentialsPage'] = $dir . 'UserCredentials_body.php'; |
217 | | -$wgSpecialPageGroups['UserCredentials'] = 'users'; |
218 | | - |
219 | | -$wgExtensionFunctions[] = 'efLoadConfirmAccount'; |
220 | | -# Add notice of where to request an account |
221 | | -$wgHooks['UserCreateForm'][] = 'efAddRequestLoginText'; |
222 | | -$wgHooks['UserLoginForm'][] = 'efAddRequestLoginText'; |
223 | | -# Check for collisions |
224 | | -$wgHooks['AbortNewAccount'][] = 'efCheckIfAccountNameIsPending'; |
225 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'efConfirmAccountSchemaUpdates'; |
226 | | -# Status header like "new messages" bar |
227 | | -$wgHooks['SiteNoticeAfter'][] = 'efConfirmAccountsNotice'; |
228 | | - |
229 | | -function efConfirmAccountSchemaUpdates() { |
230 | | - global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewTables, $wgExtNewIndexes; |
231 | | - $base = dirname( __FILE__ ); |
232 | | - if ( $wgDBtype == 'mysql' ) { |
233 | | - $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.sql" ); |
234 | | - |
235 | | - $wgExtNewFields[] = array( 'account_requests', 'acr_filename', |
236 | | - "$base/archives/patch-acr_filename.sql" ); |
237 | | - |
238 | | - $wgExtNewTables[] = array( 'account_credentials', "$base/archives/patch-account_credentials.sql" ); |
239 | | - |
240 | | - $wgExtNewFields[] = array( 'account_requests', 'acr_areas', "$base/archives/patch-acr_areas.sql" ); |
241 | | - |
242 | | - $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/archives/patch-email-index.sql" ); |
243 | | - } else if ( $wgDBtype == 'postgres' ) { |
244 | | - $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.pg.sql" ); |
245 | | - |
246 | | - $wgExtPGNewFields[] = array( 'account_requests', 'acr_held', "TIMESTAMPTZ" ); |
247 | | - $wgExtPGNewFields[] = array( 'account_requests', 'acr_filename', "TEXT" ); |
248 | | - $wgExtPGNewFields[] = array( 'account_requests', 'acr_storage_key', "TEXT" ); |
249 | | - $wgExtPGNewFields[] = array( 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''" ); |
250 | | - |
251 | | - $wgExtPGNewFields[] = array( 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0" ); |
252 | | - $wgExtNewTables[] = array( 'account_credentials', "$base/postgres/patch-account_credentials.sql" ); |
253 | | - $wgExtPGNewFields[] = array( 'account_requests', 'acr_areas', "TEXT" ); |
254 | | - $wgExtPGNewFields[] = array( 'account_credentials', 'acd_areas', "TEXT" ); |
255 | | - |
256 | | - $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/postgres/patch-email-index.sql" ); |
257 | | - } |
258 | | - return true; |
259 | | -} |
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php |
— | — | @@ -0,0 +1,258 @@ |
| 2 | +<?php |
| 3 | +# (c) Aaron Schulz 2007, GPL |
| 4 | + |
| 5 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 6 | + echo "ConfirmAccount extension\n"; |
| 7 | + exit( 1 ) ; |
| 8 | +} |
| 9 | + |
| 10 | +$wgExtensionCredits['specialpage'][] = array( |
| 11 | + 'path' => __FILE__, |
| 12 | + 'name' => 'Confirm user accounts', |
| 13 | + 'descriptionmsg' => 'confirmedit-desc', |
| 14 | + 'author' => 'Aaron Schulz', |
| 15 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount', |
| 16 | +); |
| 17 | + |
| 18 | +# This extension needs email enabled! |
| 19 | +# Otherwise users can't get their passwords... |
| 20 | +if ( !$wgEnableEmail ) { |
| 21 | + echo "ConfirmAccount extension requires \$wgEnableEmail set to true \n"; |
| 22 | + exit( 1 ) ; |
| 23 | +} |
| 24 | + |
| 25 | +# Set the person's bio as their userpage? |
| 26 | +$wgMakeUserPageFromBio = true; |
| 27 | +# Text to add to bio pages if the above option is on |
| 28 | +$wgAutoUserBioText = ''; |
| 29 | + |
| 30 | +$wgAutoWelcomeNewUsers = true; |
| 31 | +# Make the username of the real name? |
| 32 | +$wgUseRealNamesOnly = true; |
| 33 | + |
| 34 | +# How long to store rejected requests |
| 35 | +$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week |
| 36 | +# How long after accounts have been requested/held before they count as 'rejected' |
| 37 | +$wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month |
| 38 | + |
| 39 | +# How many requests can an IP make at once? |
| 40 | +$wgAccountRequestThrottle = 1; |
| 41 | +# Can blocked users request accounts? |
| 42 | +$wgAccountRequestWhileBlocked = false; |
| 43 | + |
| 44 | +# Minimum biography specs |
| 45 | +$wgAccountRequestMinWords = 50; |
| 46 | + |
| 47 | +# Show ToS checkbox |
| 48 | +$wgAccountRequestToS = true; |
| 49 | +# Show confirmation info fields |
| 50 | +$wgAccountRequestExtraInfo = true; |
| 51 | + |
| 52 | +# Prospective account access levels. |
| 53 | +# An associative array of integer => (special page param,user group,autotext) pairs. |
| 54 | +# The account queues are at Special:ConfirmAccount/param. |
| 55 | +# The integer keys are used to enumerate the type. |
| 56 | +$wgAccountRequestTypes = array( |
| 57 | + 0 => array( 'authors', 'user' ) |
| 58 | +); |
| 59 | + |
| 60 | +# If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories. |
| 61 | +# The sortkey will be made be replacing the first element of this array |
| 62 | +# (regexp) with the second. Set this variable to false to avoid sortkey use. |
| 63 | +$wgConfirmAccountSortkey = false; |
| 64 | +// For example, the below will do {{DEFAULTSORT:firstname, lastname}} |
| 65 | +# $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' ); |
| 66 | + |
| 67 | +# IMPORTANT: do we store the user's notes and credentials |
| 68 | +# for sucessful account request? This will be stored indefinetely |
| 69 | +# and will be accessible to users with crediential lookup permissions |
| 70 | +$wgConfirmAccountSaveInfo = true; |
| 71 | + |
| 72 | +# Send an email to address when account requests confirm their email. |
| 73 | +# Set to false to skip this. |
| 74 | +$wgConfirmAccountContact = false; |
| 75 | + |
| 76 | +# If ConfirmEdit is installed and set to trigger for createaccount, |
| 77 | +# inject catpchas for requests too? |
| 78 | +$wgConfirmAccountCaptchas = true; |
| 79 | + |
| 80 | +$wgAllowAccountRequestFiles = true; |
| 81 | +$wgAccountRequestExts = array( 'txt', 'pdf', 'doc', 'latex', 'rtf', 'text', 'wp', 'wpd', 'sxw' ); |
| 82 | + |
| 83 | +# Storage repos. Has B/C for when this used FileStore. |
| 84 | +$wgConfirmAccountFSRepos = array( |
| 85 | + 'accountreqs' => array( # Location of attached files for pending requests |
| 86 | + 'name' => 'accountreqs', |
| 87 | + 'directory' => isset($wgFileStore['accountreqs']) ? |
| 88 | + $wgFileStore['accountreqs']['directory'] : "{$IP}/images/accountreqs", |
| 89 | + 'url' => isset($wgFileStore['accountreqs']) ? |
| 90 | + $wgFileStore['accountreqs']['url'] : null, |
| 91 | + 'hashLevels' => isset($wgFileStore['accountreqs']) ? |
| 92 | + $wgFileStore['accountreqs']['hash'] : 3 |
| 93 | + ), |
| 94 | + 'accountcreds' => array( # Location of credential files |
| 95 | + 'name' => 'accountcreds', |
| 96 | + 'directory' => isset($wgFileStore['accountcreds']) ? |
| 97 | + $wgFileStore['accountcreds']['directory'] : "{$IP}/images/accountcreds", |
| 98 | + 'url' => isset($wgFileStore['accountcreds']) ? |
| 99 | + $wgFileStore['accountcreds']['url'] : null, |
| 100 | + 'hashLevels' => isset($wgFileStore['accountcreds']) ? |
| 101 | + $wgFileStore['accountcreds']['hash'] : 3 |
| 102 | + ) |
| 103 | +); |
| 104 | + |
| 105 | +# Restrict account creation |
| 106 | +$wgGroupPermissions['*']['createaccount'] = false; |
| 107 | +$wgGroupPermissions['user']['createaccount'] = false; |
| 108 | +# Grant account queue rights |
| 109 | +$wgGroupPermissions['bureaucrat']['confirmaccount'] = true; |
| 110 | +# This right has the request IP show when confirming accounts |
| 111 | +$wgGroupPermissions['bureaucrat']['requestips'] = true; |
| 112 | + |
| 113 | +# If credentials are stored, this right lets users look them up |
| 114 | +$wgGroupPermissions['bureaucrat']['lookupcredentials'] = true; |
| 115 | + |
| 116 | +$wgAvailableRights[] = 'confirmaccount'; |
| 117 | +$wgAvailableRights[] = 'requestips'; |
| 118 | +$wgAvailableRights[] = 'lookupcredentials'; |
| 119 | + |
| 120 | +# Show notice for open requests to admins? |
| 121 | +# This is cached, but still can be expensive on sites with thousands of requests. |
| 122 | +$wgConfirmAccountNotice = true; |
| 123 | + |
| 124 | +$dir = dirname( __FILE__ ) . '/'; |
| 125 | +$wgExtensionMessagesFiles['ConfirmAccount'] = $dir . 'ConfirmAccount.i18n.php'; |
| 126 | +$wgExtensionAliasesFiles['ConfirmAccount'] = $dir . 'ConfirmAccount.alias.php'; |
| 127 | + |
| 128 | +function efLoadConfirmAccount() { |
| 129 | + global $wgUser; |
| 130 | + # Don't load unless needed |
| 131 | + if ( $wgUser->getId() && $wgUser->isAllowed( 'confirmaccount' ) ) { |
| 132 | + efConfirmAccountInjectStyle(); |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +function efAddRequestLoginText( &$template ) { |
| 137 | + global $wgUser; |
| 138 | + wfLoadExtensionMessages( 'ConfirmAccount' ); |
| 139 | + # Add a link to RequestAccount from UserLogin |
| 140 | + if ( !$wgUser->isAllowed( 'createaccount' ) ) { |
| 141 | + $template->set( 'header', wfMsgExt( 'requestaccount-loginnotice', array( 'parse' ) ) ); |
| 142 | + } |
| 143 | + return true; |
| 144 | +} |
| 145 | + |
| 146 | +function efCheckIfAccountNameIsPending( $user, &$abortError ) { |
| 147 | + # If an account is made with name X, and one is pending with name X |
| 148 | + # we will have problems if the pending one is later confirmed |
| 149 | + $dbw = wfGetDB( DB_MASTER ); |
| 150 | + $dup = $dbw->selectField( 'account_requests', '1', |
| 151 | + array( 'acr_name' => $user->getName() ), |
| 152 | + __METHOD__ ); |
| 153 | + if ( $dup ) { |
| 154 | + wfLoadExtensionMessages( 'ConfirmAccount' ); |
| 155 | + $abortError = wfMsgHtml( 'requestaccount-inuse' ); |
| 156 | + return false; |
| 157 | + } |
| 158 | + return true; |
| 159 | +} |
| 160 | + |
| 161 | +function efConfirmAccountInjectStyle() { |
| 162 | + global $wgOut, $wgUser, $wgScriptPath; |
| 163 | + # FIXME: find better load place |
| 164 | + # UI CSS |
| 165 | + $wgOut->addLink( array( |
| 166 | + 'rel' => 'stylesheet', |
| 167 | + 'type' => 'text/css', |
| 168 | + 'media' => 'screen', |
| 169 | + 'href' => $wgScriptPath . '/extensions/ConfirmAccount/confirmaccount.css', |
| 170 | + ) ); |
| 171 | + return true; |
| 172 | +} |
| 173 | + |
| 174 | +function efConfirmAccountsNotice( $notice ) { |
| 175 | + global $wgConfirmAccountNotice, $wgUser; |
| 176 | + if ( !$wgConfirmAccountNotice || !$wgUser->isAllowed( 'confirmaccount' ) ) { |
| 177 | + return true; |
| 178 | + } |
| 179 | + global $wgMemc, $wgOut; |
| 180 | + # Check cached results |
| 181 | + $key = wfMemcKey( 'confirmaccount', 'noticecount' ); |
| 182 | + $count = $wgMemc->get( $key ); |
| 183 | + # Only show message if there are any such requests |
| 184 | + if ( !$count ) { |
| 185 | + $dbw = wfGetDB( DB_MASTER ); |
| 186 | + $count = $dbw->selectField( 'account_requests', 'COUNT(*)', |
| 187 | + array( 'acr_deleted' => 0, 'acr_held IS NULL', 'acr_email_authenticated IS NOT NULL' ), |
| 188 | + __METHOD__ ); |
| 189 | + # Use '-' for zero, to avoid any confusion over key existence |
| 190 | + if ( !$count ) { |
| 191 | + $count = '-'; |
| 192 | + } |
| 193 | + # Cache results |
| 194 | + $wgMemc->set( $key, $count, 3600 * 24 * 7 ); |
| 195 | + } |
| 196 | + if ( $count !== '-' ) { |
| 197 | + wfLoadExtensionMessages( 'ConfirmAccount' ); |
| 198 | + $message = wfMsgExt( 'confirmaccount-newrequests', array( 'parsemag' ), $count ); |
| 199 | + |
| 200 | + $notice .= '<div id="mw-confirmaccount-msg" class="mw-confirmaccount-bar">' . $wgOut->parse( $message ) . '</div>'; |
| 201 | + } |
| 202 | + return true; |
| 203 | +} |
| 204 | + |
| 205 | +$dir = dirname( __FILE__ ) . '/'; |
| 206 | +# Request an account |
| 207 | +$wgSpecialPages['RequestAccount'] = 'RequestAccountPage'; |
| 208 | +$wgAutoloadClasses['RequestAccountPage'] = $dir . 'RequestAccount_body.php'; |
| 209 | +$wgSpecialPageGroups['RequestAccount'] = 'login'; |
| 210 | +# Confirm accounts |
| 211 | +$wgSpecialPages['ConfirmAccounts'] = 'ConfirmAccountsPage'; |
| 212 | +$wgAutoloadClasses['ConfirmAccountsPage'] = $dir . 'ConfirmAccount_body.php'; |
| 213 | +$wgSpecialPageGroups['ConfirmAccounts'] = 'users'; |
| 214 | +# Account credentials |
| 215 | +$wgSpecialPages['UserCredentials'] = 'UserCredentialsPage'; |
| 216 | +$wgAutoloadClasses['UserCredentialsPage'] = $dir . 'UserCredentials_body.php'; |
| 217 | +$wgSpecialPageGroups['UserCredentials'] = 'users'; |
| 218 | + |
| 219 | +$wgExtensionFunctions[] = 'efLoadConfirmAccount'; |
| 220 | +# Add notice of where to request an account |
| 221 | +$wgHooks['UserCreateForm'][] = 'efAddRequestLoginText'; |
| 222 | +$wgHooks['UserLoginForm'][] = 'efAddRequestLoginText'; |
| 223 | +# Check for collisions |
| 224 | +$wgHooks['AbortNewAccount'][] = 'efCheckIfAccountNameIsPending'; |
| 225 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'efConfirmAccountSchemaUpdates'; |
| 226 | +# Status header like "new messages" bar |
| 227 | +$wgHooks['SiteNoticeAfter'][] = 'efConfirmAccountsNotice'; |
| 228 | + |
| 229 | +function efConfirmAccountSchemaUpdates() { |
| 230 | + global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewTables, $wgExtNewIndexes; |
| 231 | + $base = dirname( __FILE__ ); |
| 232 | + if ( $wgDBtype == 'mysql' ) { |
| 233 | + $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.sql" ); |
| 234 | + |
| 235 | + $wgExtNewFields[] = array( 'account_requests', 'acr_filename', |
| 236 | + "$base/archives/patch-acr_filename.sql" ); |
| 237 | + |
| 238 | + $wgExtNewTables[] = array( 'account_credentials', "$base/archives/patch-account_credentials.sql" ); |
| 239 | + |
| 240 | + $wgExtNewFields[] = array( 'account_requests', 'acr_areas', "$base/archives/patch-acr_areas.sql" ); |
| 241 | + |
| 242 | + $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/archives/patch-email-index.sql" ); |
| 243 | + } else if ( $wgDBtype == 'postgres' ) { |
| 244 | + $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.pg.sql" ); |
| 245 | + |
| 246 | + $wgExtPGNewFields[] = array( 'account_requests', 'acr_held', "TIMESTAMPTZ" ); |
| 247 | + $wgExtPGNewFields[] = array( 'account_requests', 'acr_filename', "TEXT" ); |
| 248 | + $wgExtPGNewFields[] = array( 'account_requests', 'acr_storage_key', "TEXT" ); |
| 249 | + $wgExtPGNewFields[] = array( 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''" ); |
| 250 | + |
| 251 | + $wgExtPGNewFields[] = array( 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0" ); |
| 252 | + $wgExtNewTables[] = array( 'account_credentials', "$base/postgres/patch-account_credentials.sql" ); |
| 253 | + $wgExtPGNewFields[] = array( 'account_requests', 'acr_areas', "TEXT" ); |
| 254 | + $wgExtPGNewFields[] = array( 'account_credentials', 'acd_areas', "TEXT" ); |
| 255 | + |
| 256 | + $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/postgres/patch-email-index.sql" ); |
| 257 | + } |
| 258 | + return true; |
| 259 | +} |
Property changes on: trunk/extensions/ConfirmAccount/ConfirmAccount.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 260 | + native |