Index: trunk/extensions/ConfirmAccount/frontend/specialpages/actions/UserCredentials_body.php |
— | — | @@ -2,19 +2,24 @@ |
3 | 3 | |
4 | 4 | class UserCredentialsPage extends SpecialPage { |
5 | 5 | |
6 | | - protected $target, $skin, $file; |
| 6 | + protected $target, $file; |
| 7 | + |
7 | 8 | function __construct() { |
8 | 9 | parent::__construct( 'UserCredentials', 'lookupcredentials' ); |
9 | 10 | } |
10 | 11 | |
| 12 | + public function userCanExecute( User $user ) { |
| 13 | + global $wgConfirmAccountSaveInfo; |
| 14 | + return $wgConfirmAccountSaveInfo && parent::userCanExecute( $user ); |
| 15 | + } |
| 16 | + |
11 | 17 | function execute( $par ) { |
12 | 18 | $out = $this->getOutput(); |
13 | 19 | $request = $this->getRequest(); |
14 | 20 | $reqUser = $this->getUser(); |
15 | 21 | |
16 | | - if ( !$reqUser->isAllowed( 'lookupcredentials' ) ) { |
17 | | - $out->permissionRequired( 'lookupcredentials' ); |
18 | | - return; |
| 22 | + if ( !$this->userCanExecute( $this->getUser() ) ) { |
| 23 | + throw new PermissionsError( 'lookupcredentials' ); |
19 | 24 | } |
20 | 25 | |
21 | 26 | $this->setHeaders(); |
— | — | @@ -24,8 +29,6 @@ |
25 | 30 | # Attachments |
26 | 31 | $this->file = $request->getVal( 'file' ); |
27 | 32 | |
28 | | - $this->skin = $reqUser->getSkin(); |
29 | | - |
30 | 33 | if ( $this->file ) { |
31 | 34 | $this->showFile( $this->file ); |
32 | 35 | } elseif ( $this->target ) { |
— | — | @@ -84,7 +87,7 @@ |
85 | 88 | $form .= '<legend>' . wfMsgHtml( 'usercredentials-leg-user' ) . '</legend>'; |
86 | 89 | $form .= '<table cellpadding=\'4\'>'; |
87 | 90 | $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"; |
89 | 92 | |
90 | 93 | $econf = $row->acd_email_authenticated ? ' <strong>' . wfMsgHtml( 'confirmaccount-econf' ) . '</strong>' : ''; |
91 | 94 | $form .= "<tr><td>" . wfMsgHtml( 'usercredentials-email' ) . "</td>"; |
— | — | @@ -147,7 +150,7 @@ |
148 | 151 | if( $wgAccountRequestExtraInfo ) { |
149 | 152 | $form .= '<p>' . wfMsgHtml( 'usercredentials-attach' ) . ' '; |
150 | 153 | if ( $row->acd_filename ) { |
151 | | - $form .= $this->skin->makeKnownLinkObj( $titleObj, htmlspecialchars( $row->acd_filename ), |
| 154 | + $form .= Linker::makeKnownLinkObj( $titleObj, htmlspecialchars( $row->acd_filename ), |
152 | 155 | 'file=' . $row->acd_storage_key ); |
153 | 156 | } else { |
154 | 157 | $form .= wfMsgHtml( 'confirmaccount-none-p' ); |
— | — | @@ -204,6 +207,7 @@ |
205 | 208 | $repo = new FSRepo( $wgConfirmAccountFSRepos['accountcreds'] ); |
206 | 209 | $path = $repo->getZonePath( 'public' ) . '/' . |
207 | 210 | UserAccountRequest::relPathFromKey( $key ); |
| 211 | + |
208 | 212 | StreamFile::stream( $path ); |
209 | 213 | } |
210 | 214 | |
Index: trunk/extensions/ConfirmAccount/frontend/ConfirmAccountUI.setup.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * @param $hooks Array $wgHooks (assoc array of hooks and handlers) |
10 | 10 | * @return void |
11 | 11 | */ |
12 | | - public static function defineHookHandlers( &$hooks ) { |
| 12 | + public static function defineHookHandlers( array &$hooks ) { |
13 | 13 | # Make sure "login / create account" notice still as "create account" |
14 | 14 | $hooks['PersonalUrls'][] = 'ConfirmAccountUIHooks::setRequestLoginLinks'; |
15 | 15 | # Add notice of where to request an account at UserLogin |
— | — | @@ -24,29 +24,25 @@ |
25 | 25 | * Register ConfirmAccount special pages as needed. |
26 | 26 | * @param $pages Array $wgSpecialPages (list of special pages) |
27 | 27 | * @param $groups Array $wgSpecialPageGroups (assoc array of special page groups) |
| 28 | + * @return void |
28 | 29 | */ |
29 | 30 | public static function defineSpecialPages( array &$pages, array &$groups ) { |
30 | | - global $wgConfirmAccountSaveInfo; |
31 | | - |
32 | 31 | $pages['RequestAccount'] = 'RequestAccountPage'; |
33 | 32 | $groups['RequestAccount'] = 'login'; |
34 | 33 | |
35 | 34 | $pages['ConfirmAccounts'] = 'ConfirmAccountsPage'; |
36 | 35 | $groups['ConfirmAccounts'] = 'users'; |
37 | 36 | |
38 | | - if ( $wgConfirmAccountSaveInfo ) { |
39 | | - $pages['UserCredentials'] = 'UserCredentialsPage'; |
40 | | - $groups['UserCredentials'] = 'users'; |
41 | | - } |
42 | | - |
43 | | - return true; |
| 37 | + $pages['UserCredentials'] = 'UserCredentialsPage'; |
| 38 | + $groups['UserCredentials'] = 'users'; |
44 | 39 | } |
45 | 40 | |
46 | 41 | /** |
47 | 42 | * Append ConfirmAccount resource module definitions |
48 | 43 | * @param $modules Array $wgResourceModules |
| 44 | + * @return void |
49 | 45 | */ |
50 | | - public static function defineResourceModules( &$modules ) { |
| 46 | + public static function defineResourceModules( array &$modules ) { |
51 | 47 | $modules['ext.confirmAccount'] = array( |
52 | 48 | 'styles' => 'confirmaccount.css', |
53 | 49 | 'localBasePath' => dirname( __FILE__ ) . '/modules', |
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | # Load default config variables |
36 | 36 | require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' ); |
37 | 37 | |
38 | | -# Define were classes and i18n files are located |
| 38 | +# Define were PHP files and i18n files are located |
39 | 39 | require( dirname( __FILE__ ) . '/ConfirmAccount.setup.php' ); |
40 | 40 | ConfirmAccountSetup::defineSourcePaths( |
41 | 41 | $wgAutoloadClasses, |
— | — | @@ -42,6 +42,9 @@ |
43 | 43 | $wgExtensionAliasesFiles |
44 | 44 | ); |
45 | 45 | |
| 46 | +# Define JS/CSS modules and file locations |
| 47 | +ConfirmAccountUISetup::defineResourceModules( $wgResourceModules ); |
| 48 | + |
46 | 49 | # Let some users confirm account requests and view credentials for created accounts |
47 | 50 | $wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests |
48 | 51 | $wgAvailableRights[] = 'requestips'; // user can see IPs in request queue |
— | — | @@ -50,9 +53,6 @@ |
51 | 54 | # Actually register special pages |
52 | 55 | ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups ); |
53 | 56 | |
54 | | -# JS/CSS modules and message bundles used by JS scripts |
55 | | -ConfirmAccountUISetup::defineResourceModules( $wgResourceModules ); |
56 | | - |
57 | 57 | # ####### HOOK CALLBACK FUNCTIONS ######### |
58 | 58 | |
59 | 59 | # UI-related hook handlers |