r102925 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102924‎ | r102925 | r102926 >
Date:23:53, 13 November 2011
Author:aaron
Status:deferred
Tags:
Comment:
* Fixed LocalSettings $wgConfirmAccountSaveInfo define order dependency for UserCredentialsPage
* Added some type hinting and made some doc tweaks
* Moved defineResourceModules() call near defineSourcePaths()
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/frontend/ConfirmAccountUI.setup.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/frontend/specialpages/actions/UserCredentials_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/frontend/specialpages/actions/UserCredentials_body.php
@@ -2,19 +2,24 @@
33
44 class UserCredentialsPage extends SpecialPage {
55
6 - protected $target, $skin, $file;
 6+ protected $target, $file;
 7+
78 function __construct() {
89 parent::__construct( 'UserCredentials', 'lookupcredentials' );
910 }
1011
 12+ public function userCanExecute( User $user ) {
 13+ global $wgConfirmAccountSaveInfo;
 14+ return $wgConfirmAccountSaveInfo && parent::userCanExecute( $user );
 15+ }
 16+
1117 function execute( $par ) {
1218 $out = $this->getOutput();
1319 $request = $this->getRequest();
1420 $reqUser = $this->getUser();
1521
16 - if ( !$reqUser->isAllowed( 'lookupcredentials' ) ) {
17 - $out->permissionRequired( 'lookupcredentials' );
18 - return;
 22+ if ( !$this->userCanExecute( $this->getUser() ) ) {
 23+ throw new PermissionsError( 'lookupcredentials' );
1924 }
2025
2126 $this->setHeaders();
@@ -24,8 +29,6 @@
2530 # Attachments
2631 $this->file = $request->getVal( 'file' );
2732
28 - $this->skin = $reqUser->getSkin();
29 -
3033 if ( $this->file ) {
3134 $this->showFile( $this->file );
3235 } elseif ( $this->target ) {
@@ -84,7 +87,7 @@
8588 $form .= '<legend>' . wfMsgHtml( 'usercredentials-leg-user' ) . '</legend>';
8689 $form .= '<table cellpadding=\'4\'>';
8790 $form .= "<tr><td>" . wfMsgHtml( 'username' ) . "</td>";
88 - $form .= "<td>" . $this->skin->makeLinkObj( $user->getUserPage(), htmlspecialchars( $user->getUserPage()->getText() ) ) . "</td></tr>\n";
 91+ $form .= "<td>" . Linker::makeLinkObj( $user->getUserPage(), htmlspecialchars( $user->getUserPage()->getText() ) ) . "</td></tr>\n";
8992
9093 $econf = $row->acd_email_authenticated ? ' <strong>' . wfMsgHtml( 'confirmaccount-econf' ) . '</strong>' : '';
9194 $form .= "<tr><td>" . wfMsgHtml( 'usercredentials-email' ) . "</td>";
@@ -147,7 +150,7 @@
148151 if( $wgAccountRequestExtraInfo ) {
149152 $form .= '<p>' . wfMsgHtml( 'usercredentials-attach' ) . ' ';
150153 if ( $row->acd_filename ) {
151 - $form .= $this->skin->makeKnownLinkObj( $titleObj, htmlspecialchars( $row->acd_filename ),
 154+ $form .= Linker::makeKnownLinkObj( $titleObj, htmlspecialchars( $row->acd_filename ),
152155 'file=' . $row->acd_storage_key );
153156 } else {
154157 $form .= wfMsgHtml( 'confirmaccount-none-p' );
@@ -204,6 +207,7 @@
205208 $repo = new FSRepo( $wgConfirmAccountFSRepos['accountcreds'] );
206209 $path = $repo->getZonePath( 'public' ) . '/' .
207210 UserAccountRequest::relPathFromKey( $key );
 211+
208212 StreamFile::stream( $path );
209213 }
210214
Index: trunk/extensions/ConfirmAccount/frontend/ConfirmAccountUI.setup.php
@@ -8,7 +8,7 @@
99 * @param $hooks Array $wgHooks (assoc array of hooks and handlers)
1010 * @return void
1111 */
12 - public static function defineHookHandlers( &$hooks ) {
 12+ public static function defineHookHandlers( array &$hooks ) {
1313 # Make sure "login / create account" notice still as "create account"
1414 $hooks['PersonalUrls'][] = 'ConfirmAccountUIHooks::setRequestLoginLinks';
1515 # Add notice of where to request an account at UserLogin
@@ -24,29 +24,25 @@
2525 * Register ConfirmAccount special pages as needed.
2626 * @param $pages Array $wgSpecialPages (list of special pages)
2727 * @param $groups Array $wgSpecialPageGroups (assoc array of special page groups)
 28+ * @return void
2829 */
2930 public static function defineSpecialPages( array &$pages, array &$groups ) {
30 - global $wgConfirmAccountSaveInfo;
31 -
3231 $pages['RequestAccount'] = 'RequestAccountPage';
3332 $groups['RequestAccount'] = 'login';
3433
3534 $pages['ConfirmAccounts'] = 'ConfirmAccountsPage';
3635 $groups['ConfirmAccounts'] = 'users';
3736
38 - if ( $wgConfirmAccountSaveInfo ) {
39 - $pages['UserCredentials'] = 'UserCredentialsPage';
40 - $groups['UserCredentials'] = 'users';
41 - }
42 -
43 - return true;
 37+ $pages['UserCredentials'] = 'UserCredentialsPage';
 38+ $groups['UserCredentials'] = 'users';
4439 }
4540
4641 /**
4742 * Append ConfirmAccount resource module definitions
4843 * @param $modules Array $wgResourceModules
 44+ * @return void
4945 */
50 - public static function defineResourceModules( &$modules ) {
 46+ public static function defineResourceModules( array &$modules ) {
5147 $modules['ext.confirmAccount'] = array(
5248 'styles' => 'confirmaccount.css',
5349 'localBasePath' => dirname( __FILE__ ) . '/modules',
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php
@@ -34,7 +34,7 @@
3535 # Load default config variables
3636 require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' );
3737
38 -# Define were classes and i18n files are located
 38+# Define were PHP files and i18n files are located
3939 require( dirname( __FILE__ ) . '/ConfirmAccount.setup.php' );
4040 ConfirmAccountSetup::defineSourcePaths(
4141 $wgAutoloadClasses,
@@ -42,6 +42,9 @@
4343 $wgExtensionAliasesFiles
4444 );
4545
 46+# Define JS/CSS modules and file locations
 47+ConfirmAccountUISetup::defineResourceModules( $wgResourceModules );
 48+
4649 # Let some users confirm account requests and view credentials for created accounts
4750 $wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests
4851 $wgAvailableRights[] = 'requestips'; // user can see IPs in request queue
@@ -50,9 +53,6 @@
5154 # Actually register special pages
5255 ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
5356
54 -# JS/CSS modules and message bundles used by JS scripts
55 -ConfirmAccountUISetup::defineResourceModules( $wgResourceModules );
56 -
5757 # ####### HOOK CALLBACK FUNCTIONS #########
5858
5959 # UI-related hook handlers

Status & tagging log