r99329 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99328‎ | r99329 | r99330 >
Date:23:43, 8 October 2011
Author:aaron
Status:deferred
Tags:
Comment:
* Split config settings off into .config file
* Added ConfirmAccountSetup class to handle resources and special pages
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.config.php (added) (history)
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php (added) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php
@@ -24,11 +24,11 @@
2525 }
2626
2727 $wgExtensionCredits['specialpage'][] = array(
28 - 'path' => __FILE__,
29 - 'name' => 'Confirm User Accounts',
 28+ 'path' => __FILE__,
 29+ 'name' => 'Confirm User Accounts',
3030 'descriptionmsg' => 'confirmedit-desc',
31 - 'author' => 'Aaron Schulz',
32 - 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount',
 31+ 'author' => 'Aaron Schulz',
 32+ 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount',
3333 );
3434
3535 # This extension needs email enabled!
@@ -38,123 +38,20 @@
3939 exit( 1 ) ;
4040 }
4141
42 -# Configuration
 42+# Load default config variables
 43+require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' );
4344
44 -# Set the person's bio as their userpage?
45 -$wgMakeUserPageFromBio = true;
46 -# Text to add to bio pages if the above option is on
47 -$wgAutoUserBioText = '';
48 -
49 -$wgAutoWelcomeNewUsers = true;
50 -# Make the username of the real name?
51 -$wgUseRealNamesOnly = true;
52 -
53 -# How long to store rejected requests
54 -$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week
55 -# How long after accounts have been requested/held before they count as 'rejected'
56 -$wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month
57 -
58 -# How many requests can an IP make at once?
59 -$wgAccountRequestThrottle = 1;
60 -# Can blocked users request accounts?
61 -$wgAccountRequestWhileBlocked = false;
62 -
63 -# Minimum biography specs
64 -$wgAccountRequestMinWords = 50;
65 -
66 -# Show ToS checkbox
67 -$wgAccountRequestToS = true;
68 -# Show confirmation info fields (notes,url,files if enabled)
69 -$wgAccountRequestExtraInfo = true;
70 -# If $wgAccountRequestExtraInfo, also enables file attachments
71 -$wgAllowAccountRequestFiles = true;
72 -# If files can be attached, what types can be used? (MIME data is checked)
73 -$wgAccountRequestExts = array( 'txt', 'pdf', 'doc', 'latex', 'rtf', 'text', 'wp', 'wpd', 'sxw' );
74 -
75 -# Prospective account access levels.
76 -# An associative array of integer => (special page param,user group,autotext) pairs.
77 -# The account queues are at Special:ConfirmAccount/param. The integer keys enumerate the type.
78 -# When a request of a certain type (param) is approved, the new user:
79 -# (a) is placed in the <user group> group (if not User or *)
80 -# (b) If $wgMakeUserPageFromBio, <autotext> is appended his/her user page
81 -$wgAccountRequestTypes = array(
82 - 0 => array( 'authors', 'user', null )
83 -);
84 -
85 -# If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories.
86 -# The sortkey will be made be replacing the first element of this array
87 -# (regexp) with the second. Set this variable to false to avoid sortkey use.
88 -$wgConfirmAccountSortkey = false;
89 -// For example, the below will do {{DEFAULTSORT:firstname, lastname}}
90 -# $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' );
91 -
92 -# IMPORTANT: do we store the user's notes and credentials
93 -# for sucessful account request? This will be stored indefinetely
94 -# and will be accessible to users with crediential lookup permissions
95 -$wgConfirmAccountSaveInfo = true;
96 -
97 -# Send an email to this address when account requestors confirm their email.
98 -# Set to false to skip this
99 -$wgConfirmAccountContact = false;
100 -
101 -# If ConfirmEdit is installed and set to trigger for createaccount,
102 -# inject catpchas for requests too?
103 -$wgConfirmAccountCaptchas = true;
104 -
105 -# Storage repos. Has B/C for when this used FileStore.
106 -$wgConfirmAccountFSRepos = array(
107 - 'accountreqs' => array( # Location of attached files for pending requests
108 - 'name' => 'accountreqs',
109 - 'directory' => isset($wgFileStore['accountreqs']) ?
110 - $wgFileStore['accountreqs']['directory'] : "{$IP}/images/accountreqs",
111 - 'url' => isset($wgFileStore['accountreqs']) ?
112 - $wgFileStore['accountreqs']['url'] : null,
113 - 'hashLevels' => isset($wgFileStore['accountreqs']) ?
114 - $wgFileStore['accountreqs']['hash'] : 3
115 - ),
116 - 'accountcreds' => array( # Location of credential files
117 - 'name' => 'accountcreds',
118 - 'directory' => isset($wgFileStore['accountcreds']) ?
119 - $wgFileStore['accountcreds']['directory'] : "{$IP}/images/accountcreds",
120 - 'url' => isset($wgFileStore['accountcreds']) ?
121 - $wgFileStore['accountcreds']['url'] : null,
122 - 'hashLevels' => isset($wgFileStore['accountcreds']) ?
123 - $wgFileStore['accountcreds']['hash'] : 3
124 - )
125 -);
126 -
127 -# Restrict account creation
128 -$wgGroupPermissions['*']['createaccount'] = false;
129 -$wgGroupPermissions['user']['createaccount'] = false;
130 -# Grant account queue rights
131 -$wgGroupPermissions['bureaucrat']['confirmaccount'] = true;
132 -# This right has the request IP show when confirming accounts
133 -$wgGroupPermissions['bureaucrat']['requestips'] = true;
134 -
135 -# If credentials are stored, this right lets users look them up
136 -$wgGroupPermissions['bureaucrat']['lookupcredentials'] = true;
137 -
 45+# Let some users confirm account requests and view credentials for created accounts
13846 $wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests
13947 $wgAvailableRights[] = 'requestips'; // user can see IPs in request queue
14048 $wgAvailableRights[] = 'lookupcredentials'; // user can lookup info on confirmed users
14149
142 -# Show notice for open requests to admins?
143 -# This is cached, but still can be expensive on sites with thousands of requests.
144 -$wgConfirmAccountNotice = true;
145 -
146 -# End Configuration
147 -
148 -$wgResourceModules['ext.confirmAccount'] = array(
149 - 'styles' => 'confirmaccount.css',
150 - 'localBasePath' => dirname( __FILE__ ) . '/presentation/modules',
151 - 'remoteExtPath' => 'ConfirmAccount/presentation/modules',
152 -);
153 -
15450 $dir = dirname( __FILE__ ) . '/presentation';
 51+$wgAutoloadClasses['ConfirmAccountUISetup'] = "$dir/ConfirmAccountUI.setup.php";
15552 # Internationalization files
15653 $wgExtensionMessagesFiles['ConfirmAccount'] = "$dir/ConfirmAccount.i18n.php";
15754 $wgExtensionAliasesFiles['ConfirmAccount'] = "$dir/ConfirmAccount.alias.php";
158 -# UI event handlers
 55+# UI event handler classes
15956 $wgAutoloadClasses['ConfirmAccountUIHooks'] = "$dir/ConfirmAccountUI.hooks.php";
16057
16158 $dir = dirname( __FILE__ ) . '/presentation/specialpages';
@@ -179,6 +76,14 @@
18077 # Schema changes
18178 $wgAutoloadClasses['ConfirmAccountUpdaterHooks'] = "$dir/ConfirmAccountUpdater.hooks.php";
18279
 80+# Actually register special pages
 81+ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
 82+
 83+# JS/CSS modules and message bundles used by JS scripts
 84+ConfirmAccountUISetup::defineResourceModules( $wgResourceModules );
 85+
 86+# ####### EVENT-HANDLER FUNCTIONS #########
 87+
18388 # Make sure "login / create account" notice still as "create account"
18489 $wgHooks['PersonalUrls'][] = 'ConfirmAccountUIHooks::setRequestLoginLinks';
18590 # Add notice of where to request an account at UserLogin
@@ -192,7 +97,6 @@
19398 # Register admin pages for AdminLinks extension.
19499 $wgHooks['AdminLinks'][] = 'ConfirmAccountUIHooks::confirmAccountAdminLinks';
195100
196 -# Actually register some special pages
197 -$wgHooks['SpecialPage_initList'][] = 'ConfirmAccountUIHooks::defineSpecialPages';
198 -
199101 $wgHooks['LoadExtensionSchemaUpdates'][] = 'ConfirmAccountUpdaterHooks::addSchemaUpdates';
 102+
 103+# ####### END HOOK TRIGGERED FUNCTIONS #########
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.config.php
@@ -0,0 +1,106 @@
 2+<?php
 3+
 4+# ######## Configuration variables ########
 5+# IMPORTANT: DO NOT EDIT THIS FILE
 6+# When configuring globals, set them at LocalSettings.php instead
 7+
 8+# Set the person's bio as their userpage?
 9+$wgMakeUserPageFromBio = true;
 10+# Text to add to bio pages if the above option is on
 11+$wgAutoUserBioText = '';
 12+
 13+$wgAutoWelcomeNewUsers = true;
 14+# Make the username of the real name?
 15+$wgUseRealNamesOnly = true;
 16+
 17+# How long to store rejected requests
 18+$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week
 19+# How long after accounts have been requested/held before they count as 'rejected'
 20+$wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month
 21+
 22+# How many requests can an IP make at once?
 23+$wgAccountRequestThrottle = 1;
 24+# Can blocked users request accounts?
 25+$wgAccountRequestWhileBlocked = false;
 26+
 27+# Minimum biography specs
 28+$wgAccountRequestMinWords = 50;
 29+
 30+# Show ToS checkbox
 31+$wgAccountRequestToS = true;
 32+# Show confirmation info fields (notes,url,files if enabled)
 33+$wgAccountRequestExtraInfo = true;
 34+# If $wgAccountRequestExtraInfo, also enables file attachments
 35+$wgAllowAccountRequestFiles = true;
 36+# If files can be attached, what types can be used? (MIME data is checked)
 37+$wgAccountRequestExts = array( 'txt', 'pdf', 'doc', 'latex', 'rtf', 'text', 'wp', 'wpd', 'sxw' );
 38+
 39+# Prospective account access levels.
 40+# An associative array of integer => (special page param,user group,autotext) pairs.
 41+# The account queues are at Special:ConfirmAccount/param. The integer keys enumerate the type.
 42+# When a request of a certain type (param) is approved, the new user:
 43+# (a) is placed in the <user group> group (if not User or *)
 44+# (b) If $wgMakeUserPageFromBio, <autotext> is appended his/her user page
 45+$wgAccountRequestTypes = array(
 46+ 0 => array( 'authors', 'user', null )
 47+);
 48+
 49+# If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories.
 50+# The sortkey will be made be replacing the first element of this array
 51+# (regexp) with the second. Set this variable to false to avoid sortkey use.
 52+$wgConfirmAccountSortkey = false;
 53+// For example, the below will do {{DEFAULTSORT:firstname, lastname}}
 54+# $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' );
 55+
 56+# IMPORTANT: do we store the user's notes and credentials
 57+# for sucessful account request? This will be stored indefinetely
 58+# and will be accessible to users with crediential lookup permissions
 59+$wgConfirmAccountSaveInfo = true;
 60+
 61+# Send an email to this address when account requestors confirm their email.
 62+# Set to false to skip this
 63+$wgConfirmAccountContact = false;
 64+
 65+# If ConfirmEdit is installed and set to trigger for createaccount,
 66+# inject catpchas for requests too?
 67+$wgConfirmAccountCaptchas = true;
 68+
 69+# Storage repos. Has B/C for when this used FileStore.
 70+$wgConfirmAccountFSRepos = array(
 71+ 'accountreqs' => array( # Location of attached files for pending requests
 72+ 'name' => 'accountreqs',
 73+ 'directory' => isset($wgFileStore['accountreqs']) ?
 74+ $wgFileStore['accountreqs']['directory'] : "{$IP}/images/accountreqs",
 75+ 'url' => isset($wgFileStore['accountreqs']) ?
 76+ $wgFileStore['accountreqs']['url'] : null,
 77+ 'hashLevels' => isset($wgFileStore['accountreqs']) ?
 78+ $wgFileStore['accountreqs']['hash'] : 3
 79+ ),
 80+ 'accountcreds' => array( # Location of credential files
 81+ 'name' => 'accountcreds',
 82+ 'directory' => isset($wgFileStore['accountcreds']) ?
 83+ $wgFileStore['accountcreds']['directory'] : "{$IP}/images/accountcreds",
 84+ 'url' => isset($wgFileStore['accountcreds']) ?
 85+ $wgFileStore['accountcreds']['url'] : null,
 86+ 'hashLevels' => isset($wgFileStore['accountcreds']) ?
 87+ $wgFileStore['accountcreds']['hash'] : 3
 88+ )
 89+);
 90+
 91+# Restrict account creation
 92+$wgGroupPermissions['*']['createaccount'] = false;
 93+$wgGroupPermissions['user']['createaccount'] = false;
 94+# Grant account queue rights
 95+$wgGroupPermissions['bureaucrat']['confirmaccount'] = true;
 96+# This right has the request IP show when confirming accounts
 97+$wgGroupPermissions['bureaucrat']['requestips'] = true;
 98+
 99+# If credentials are stored, this right lets users look them up
 100+$wgGroupPermissions['bureaucrat']['lookupcredentials'] = true;
 101+
 102+# Show notice for open requests to admins?
 103+# This is cached, but still can be expensive on sites with thousands of requests.
 104+$wgConfirmAccountNotice = true;
 105+
 106+# End of configuration variables.
 107+# ########
Property changes on: trunk/extensions/ConfirmAccount/ConfirmAccount.config.php
___________________________________________________________________
Added: svn:eol-style
1108 + native
Index: trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php
@@ -4,31 +4,6 @@
55 */
66 class ConfirmAccountUIHooks {
77 /**
8 - * Register ConfirmAccount special pages as needed.
9 - * Also sets $wgSpecialPages just to be consistent.
10 - *
11 - * @param $list array
12 - *
13 - * @return true
14 - */
15 - public static function defineSpecialPages( array &$list ) {
16 - global $wgSpecialPages, $wgSpecialPageGroups, $wgConfirmAccountSaveInfo;
17 -
18 - $list['RequestAccount'] = $wgSpecialPages['RequestAccount'] = 'RequestAccountPage';
19 - $wgSpecialPageGroups['RequestAccount'] = 'login';
20 -
21 - $list['ConfirmAccounts'] = $wgSpecialPages['ConfirmAccounts'] = 'ConfirmAccountsPage';
22 - $wgSpecialPageGroups['ConfirmAccounts'] = 'users';
23 -
24 - if ( $wgConfirmAccountSaveInfo ) {
25 - $list['UserCredentials'] = $wgSpecialPages['UserCredentials'] = 'UserCredentialsPage';
26 - $wgSpecialPageGroups['UserCredentials'] = 'users';
27 - }
28 -
29 - return true;
30 - }
31 -
32 - /**
338 * @param $template
349 * @return bool
3510 */
Index: trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php
@@ -0,0 +1,39 @@
 2+<?php
 3+/**
 4+ * Class containing hooked functions for a ConfirmAccount environment
 5+ */
 6+class ConfirmAccountUISetup {
 7+ /**
 8+ * Register ConfirmAccount special pages as needed.
 9+ * @param $pages Array $wgSpecialPages (list of special pages)
 10+ * @param $groups Array $wgSpecialPageGroups (assoc array of special page groups)
 11+ */
 12+ public static function defineSpecialPages( array &$pages, array &$groups ) {
 13+ global $wgSpecialPages, $wgSpecialPageGroups, $wgConfirmAccountSaveInfo;
 14+
 15+ $pages['RequestAccount'] = 'RequestAccountPage';
 16+ $groups['RequestAccount'] = 'login';
 17+
 18+ $pages['ConfirmAccounts'] = 'ConfirmAccountsPage';
 19+ $groups['ConfirmAccounts'] = 'users';
 20+
 21+ if ( $wgConfirmAccountSaveInfo ) {
 22+ $pages['UserCredentials'] = 'UserCredentialsPage';
 23+ $groups['UserCredentials'] = 'users';
 24+ }
 25+
 26+ return true;
 27+ }
 28+
 29+ /**
 30+ * Append ConfirmAccount resource module definitions
 31+ * @param $modules Array $wgResourceModules
 32+ */
 33+ public static function defineResourceModules( &$modules ) {
 34+ $modules['ext.confirmAccount'] = array(
 35+ 'styles' => 'confirmaccount.css',
 36+ 'localBasePath' => dirname( __FILE__ ) . '/presentation/modules',
 37+ 'remoteExtPath' => 'ConfirmAccount/presentation/modules',
 38+ );
 39+ }
 40+}
Property changes on: trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php
___________________________________________________________________
Added: svn:eol-style
141 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r99333* Split out ConfirmAccount::getOpenEmailConfirmedCount() and ConfirmAccount::...aaron05:11, 9 October 2011

Status & tagging log