http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99329

Revision: 99329
Author:   aaron
Date:     2011-10-08 23:43:24 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
* Split config settings off into .config file
* Added ConfirmAccountSetup class to handle resources and special pages

Modified Paths:
--------------
    trunk/extensions/ConfirmAccount/ConfirmAccount.php
    trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php

Added Paths:
-----------
    trunk/extensions/ConfirmAccount/ConfirmAccount.config.php
    trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php

Copied: trunk/extensions/ConfirmAccount/ConfirmAccount.config.php (from rev 
99325, trunk/extensions/ConfirmAccount/ConfirmAccount.php)
===================================================================
--- trunk/extensions/ConfirmAccount/ConfirmAccount.config.php                   
        (rev 0)
+++ trunk/extensions/ConfirmAccount/ConfirmAccount.config.php   2011-10-08 
23:43:24 UTC (rev 99329)
@@ -0,0 +1,106 @@
+<?php
+
+# ######## Configuration variables ########
+# IMPORTANT: DO NOT EDIT THIS FILE
+# When configuring globals, set them at LocalSettings.php instead
+
+# Set the person's bio as their userpage?
+$wgMakeUserPageFromBio = true;
+# Text to add to bio pages if the above option is on
+$wgAutoUserBioText = '';
+
+$wgAutoWelcomeNewUsers = true;
+# Make the username of the real name?
+$wgUseRealNamesOnly = true;
+
+# How long to store rejected requests
+$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week
+# How long after accounts have been requested/held before they count as 
'rejected'
+$wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month
+
+# How many requests can an IP make at once?
+$wgAccountRequestThrottle = 1;
+# Can blocked users request accounts?
+$wgAccountRequestWhileBlocked = false;
+
+# Minimum biography specs
+$wgAccountRequestMinWords = 50;
+
+# Show ToS checkbox
+$wgAccountRequestToS = true;
+# Show confirmation info fields (notes,url,files if enabled)
+$wgAccountRequestExtraInfo = true;
+# If $wgAccountRequestExtraInfo, also enables file attachments
+$wgAllowAccountRequestFiles = true;
+# If files can be attached, what types can be used? (MIME data is checked)
+$wgAccountRequestExts = array( 'txt', 'pdf', 'doc', 'latex', 'rtf', 'text', 
'wp', 'wpd', 'sxw' );
+
+# Prospective account access levels.
+# An associative array of integer => (special page param,user group,autotext) 
pairs.
+# The account queues are at Special:ConfirmAccount/param. The integer keys 
enumerate the type.
+# When a request of a certain type (param) is approved, the new user:
+# (a) is placed in the <user group> group (if not User or *)
+# (b) If $wgMakeUserPageFromBio, <autotext> is appended his/her user page
+$wgAccountRequestTypes = array(
+       0 => array( 'authors', 'user', null )
+);
+
+# If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories.
+# The sortkey will be made be replacing the first element of this array
+# (regexp) with the second. Set this variable to false to avoid sortkey use.
+$wgConfirmAccountSortkey = false;
+// For example, the below will do {{DEFAULTSORT:firstname, lastname}}
+# $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' );
+
+# IMPORTANT: do we store the user's notes and credentials
+# for sucessful account request? This will be stored indefinetely
+# and will be accessible to users with crediential lookup permissions
+$wgConfirmAccountSaveInfo = true;
+
+# Send an email to this address when account requestors confirm their email.
+# Set to false to skip this
+$wgConfirmAccountContact = false;
+
+# If ConfirmEdit is installed and set to trigger for createaccount,
+# inject catpchas for requests too?
+$wgConfirmAccountCaptchas = true;
+
+# Storage repos. Has B/C for when this used FileStore.
+$wgConfirmAccountFSRepos = array(
+       'accountreqs' => array( # Location of attached files for pending 
requests
+               'name'       => 'accountreqs',
+               'directory'  => isset($wgFileStore['accountreqs']) ?
+                       $wgFileStore['accountreqs']['directory'] : 
"{$IP}/images/accountreqs",
+               'url'        => isset($wgFileStore['accountreqs']) ?
+                       $wgFileStore['accountreqs']['url'] : null,
+               'hashLevels' => isset($wgFileStore['accountreqs']) ?
+                       $wgFileStore['accountreqs']['hash'] : 3
+       ),
+       'accountcreds' => array( # Location of credential files
+               'name'       => 'accountcreds',
+               'directory'  => isset($wgFileStore['accountcreds']) ?
+                       $wgFileStore['accountcreds']['directory'] : 
"{$IP}/images/accountcreds",
+               'url'        => isset($wgFileStore['accountcreds']) ?
+                       $wgFileStore['accountcreds']['url'] : null,
+               'hashLevels' => isset($wgFileStore['accountcreds']) ?
+                       $wgFileStore['accountcreds']['hash'] : 3
+       )
+);
+
+# Restrict account creation
+$wgGroupPermissions['*']['createaccount'] = false;
+$wgGroupPermissions['user']['createaccount'] = false;
+# Grant account queue rights
+$wgGroupPermissions['bureaucrat']['confirmaccount'] = true;
+# This right has the request IP show when confirming accounts
+$wgGroupPermissions['bureaucrat']['requestips'] = true;
+
+# If credentials are stored, this right lets users look them up
+$wgGroupPermissions['bureaucrat']['lookupcredentials'] = true;
+
+# Show notice for open requests to admins?
+# This is cached, but still can be expensive on sites with thousands of 
requests.
+$wgConfirmAccountNotice = true;
+
+# End of configuration variables.
+# ########

Modified: trunk/extensions/ConfirmAccount/ConfirmAccount.php
===================================================================
--- trunk/extensions/ConfirmAccount/ConfirmAccount.php  2011-10-08 23:41:28 UTC 
(rev 99328)
+++ trunk/extensions/ConfirmAccount/ConfirmAccount.php  2011-10-08 23:43:24 UTC 
(rev 99329)
@@ -24,11 +24,11 @@
 }
 
 $wgExtensionCredits['specialpage'][] = array(
-       'path' => __FILE__,
-       'name' => 'Confirm User Accounts',
+       'path'           => __FILE__,
+       'name'           => 'Confirm User Accounts',
        'descriptionmsg' => 'confirmedit-desc',
-       'author' => 'Aaron Schulz',
-       'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount',
+       'author'         => 'Aaron Schulz',
+       'url'            => 
'http://www.mediawiki.org/wiki/Extension:ConfirmAccount',
 );
 
 # This extension needs email enabled!
@@ -38,123 +38,20 @@
        exit( 1 ) ;
 }
 
-# Configuration
+# Load default config variables
+require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' );
 
-# Set the person's bio as their userpage?
-$wgMakeUserPageFromBio = true;
-# Text to add to bio pages if the above option is on
-$wgAutoUserBioText = '';
-
-$wgAutoWelcomeNewUsers = true;
-# Make the username of the real name?
-$wgUseRealNamesOnly = true;
-
-# How long to store rejected requests
-$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week
-# How long after accounts have been requested/held before they count as 
'rejected'
-$wgConfirmAccountRejectAge = 30 * 24 * 3600; // 1 month
-
-# How many requests can an IP make at once?
-$wgAccountRequestThrottle = 1;
-# Can blocked users request accounts?
-$wgAccountRequestWhileBlocked = false;
-
-# Minimum biography specs
-$wgAccountRequestMinWords = 50;
-
-# Show ToS checkbox
-$wgAccountRequestToS = true;
-# Show confirmation info fields (notes,url,files if enabled)
-$wgAccountRequestExtraInfo = true;
-# If $wgAccountRequestExtraInfo, also enables file attachments
-$wgAllowAccountRequestFiles = true;
-# If files can be attached, what types can be used? (MIME data is checked)
-$wgAccountRequestExts = array( 'txt', 'pdf', 'doc', 'latex', 'rtf', 'text', 
'wp', 'wpd', 'sxw' );
-
-# Prospective account access levels.
-# An associative array of integer => (special page param,user group,autotext) 
pairs.
-# The account queues are at Special:ConfirmAccount/param. The integer keys 
enumerate the type.
-# When a request of a certain type (param) is approved, the new user:
-# (a) is placed in the <user group> group (if not User or *)
-# (b) If $wgMakeUserPageFromBio, <autotext> is appended his/her user page
-$wgAccountRequestTypes = array(
-       0 => array( 'authors', 'user', null )
-);
-
-# If set, will add {{DEFAULTSORT:sortkey}} to userpages for auto-categories.
-# The sortkey will be made be replacing the first element of this array
-# (regexp) with the second. Set this variable to false to avoid sortkey use.
-$wgConfirmAccountSortkey = false;
-// For example, the below will do {{DEFAULTSORT:firstname, lastname}}
-# $wgConfirmAccountSortkey = array( '/^(.+) ([^ ]+)$/', '$2, $1' );
-
-# IMPORTANT: do we store the user's notes and credentials
-# for sucessful account request? This will be stored indefinetely
-# and will be accessible to users with crediential lookup permissions
-$wgConfirmAccountSaveInfo = true;
-
-# Send an email to this address when account requestors confirm their email.
-# Set to false to skip this
-$wgConfirmAccountContact = false;
-
-# If ConfirmEdit is installed and set to trigger for createaccount,
-# inject catpchas for requests too?
-$wgConfirmAccountCaptchas = true;
-
-# Storage repos. Has B/C for when this used FileStore.
-$wgConfirmAccountFSRepos = array(
-       'accountreqs' => array( # Location of attached files for pending 
requests
-               'name'       => 'accountreqs',
-               'directory'  => isset($wgFileStore['accountreqs']) ?
-                       $wgFileStore['accountreqs']['directory'] : 
"{$IP}/images/accountreqs",
-               'url'        => isset($wgFileStore['accountreqs']) ?
-                       $wgFileStore['accountreqs']['url'] : null,
-               'hashLevels' => isset($wgFileStore['accountreqs']) ?
-                       $wgFileStore['accountreqs']['hash'] : 3
-       ),
-       'accountcreds' => array( # Location of credential files
-               'name'       => 'accountcreds',
-               'directory'  => isset($wgFileStore['accountcreds']) ?
-                       $wgFileStore['accountcreds']['directory'] : 
"{$IP}/images/accountcreds",
-               'url'        => isset($wgFileStore['accountcreds']) ?
-                       $wgFileStore['accountcreds']['url'] : null,
-               'hashLevels' => isset($wgFileStore['accountcreds']) ?
-                       $wgFileStore['accountcreds']['hash'] : 3
-       )
-);
-
-# Restrict account creation
-$wgGroupPermissions['*']['createaccount'] = false;
-$wgGroupPermissions['user']['createaccount'] = false;
-# Grant account queue rights
-$wgGroupPermissions['bureaucrat']['confirmaccount'] = true;
-# This right has the request IP show when confirming accounts
-$wgGroupPermissions['bureaucrat']['requestips'] = true;
-
-# If credentials are stored, this right lets users look them up
-$wgGroupPermissions['bureaucrat']['lookupcredentials'] = true;
-
+# Let some users confirm account requests and view credentials for created 
accounts
 $wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests
 $wgAvailableRights[] = 'requestips'; // user can see IPs in request queue
 $wgAvailableRights[] = 'lookupcredentials'; // user can lookup info on 
confirmed users
 
-# Show notice for open requests to admins?
-# This is cached, but still can be expensive on sites with thousands of 
requests.
-$wgConfirmAccountNotice = true;
-
-# End Configuration
-
-$wgResourceModules['ext.confirmAccount'] = array(
-       'styles'                => 'confirmaccount.css',
-       'localBasePath' => dirname( __FILE__ ) . '/presentation/modules',
-       'remoteExtPath' => 'ConfirmAccount/presentation/modules',
-);
-
 $dir = dirname( __FILE__ ) . '/presentation';
+$wgAutoloadClasses['ConfirmAccountUISetup'] = 
"$dir/ConfirmAccountUI.setup.php";
 # Internationalization files
 $wgExtensionMessagesFiles['ConfirmAccount'] = "$dir/ConfirmAccount.i18n.php";
 $wgExtensionAliasesFiles['ConfirmAccount'] = "$dir/ConfirmAccount.alias.php";
-# UI event handlers
+# UI event handler classes
 $wgAutoloadClasses['ConfirmAccountUIHooks'] = 
"$dir/ConfirmAccountUI.hooks.php";
 
 $dir = dirname( __FILE__ ) . '/presentation/specialpages';
@@ -179,6 +76,14 @@
 # Schema changes
 $wgAutoloadClasses['ConfirmAccountUpdaterHooks'] = 
"$dir/ConfirmAccountUpdater.hooks.php";
 
+# Actually register special pages
+ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, 
$wgSpecialPageGroups );
+
+# JS/CSS modules and message bundles used by JS scripts
+ConfirmAccountUISetup::defineResourceModules( $wgResourceModules );
+
+# ####### EVENT-HANDLER FUNCTIONS  #########
+
 # Make sure "login / create account" notice still as "create account"
 $wgHooks['PersonalUrls'][] = 'ConfirmAccountUIHooks::setRequestLoginLinks';
 # Add notice of where to request an account at UserLogin
@@ -192,7 +97,6 @@
 # Register admin pages for AdminLinks extension.
 $wgHooks['AdminLinks'][] = 'ConfirmAccountUIHooks::confirmAccountAdminLinks';
 
-# Actually register some special pages
-$wgHooks['SpecialPage_initList'][] = 
'ConfirmAccountUIHooks::defineSpecialPages';
-
 $wgHooks['LoadExtensionSchemaUpdates'][] = 
'ConfirmAccountUpdaterHooks::addSchemaUpdates';
+
+# ####### END HOOK TRIGGERED FUNCTIONS  #########

Modified: 
trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php
===================================================================
--- trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php     
2011-10-08 23:41:28 UTC (rev 99328)
+++ trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php     
2011-10-08 23:43:24 UTC (rev 99329)
@@ -4,31 +4,6 @@
  */
 class ConfirmAccountUIHooks {
        /**
-        * Register ConfirmAccount special pages as needed.
-        * Also sets $wgSpecialPages just to be consistent.
-        *
-        * @param $list array
-        *
-        * @return true
-        */
-       public static function defineSpecialPages( array &$list ) {
-               global $wgSpecialPages, $wgSpecialPageGroups, 
$wgConfirmAccountSaveInfo;
-
-               $list['RequestAccount'] = $wgSpecialPages['RequestAccount'] = 
'RequestAccountPage';
-               $wgSpecialPageGroups['RequestAccount'] = 'login';
-
-               $list['ConfirmAccounts'] = $wgSpecialPages['ConfirmAccounts'] = 
'ConfirmAccountsPage';
-               $wgSpecialPageGroups['ConfirmAccounts'] = 'users';
-
-               if ( $wgConfirmAccountSaveInfo ) {
-                       $list['UserCredentials'] = 
$wgSpecialPages['UserCredentials'] = 'UserCredentialsPage';
-                       $wgSpecialPageGroups['UserCredentials'] = 'users';
-               }
-
-               return true;
-       }
-
-       /**
         * @param $template
         * @return bool
         */

Copied: trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php 
(from rev 99325, 
trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.hooks.php)
===================================================================
--- trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php     
                        (rev 0)
+++ trunk/extensions/ConfirmAccount/presentation/ConfirmAccountUI.setup.php     
2011-10-08 23:43:24 UTC (rev 99329)
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Class containing hooked functions for a ConfirmAccount environment
+ */
+class ConfirmAccountUISetup {
+       /**
+        * Register ConfirmAccount special pages as needed.
+        * @param $pages Array $wgSpecialPages (list of special pages)
+        * @param $groups Array $wgSpecialPageGroups (assoc array of special 
page groups)
+        */
+       public static function defineSpecialPages( array &$pages, array 
&$groups ) {
+               global $wgSpecialPages, $wgSpecialPageGroups, 
$wgConfirmAccountSaveInfo;
+
+               $pages['RequestAccount'] = 'RequestAccountPage';
+               $groups['RequestAccount'] = 'login';
+
+               $pages['ConfirmAccounts'] = 'ConfirmAccountsPage';
+               $groups['ConfirmAccounts'] = 'users';
+
+               if ( $wgConfirmAccountSaveInfo ) {
+                       $pages['UserCredentials'] = 'UserCredentialsPage';
+                       $groups['UserCredentials'] = 'users';
+               }
+
+               return true;
+       }
+
+       /**
+        * Append ConfirmAccount resource module definitions
+        * @param $modules Array $wgResourceModules
+        */
+       public static function defineResourceModules( &$modules ) {
+               $modules['ext.confirmAccount'] = array(
+                       'styles'        => 'confirmaccount.css',
+                       'localBasePath' => dirname( __FILE__ ) . 
'/presentation/modules',
+                       'remoteExtPath' => 
'ConfirmAccount/presentation/modules',
+               );
+       }
+}


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to