Index: trunk/extensions/ConfirmAccount/dataclasses/ConfirmAccount.class.php |
— | — | @@ -52,6 +52,7 @@ |
53 | 53 | */ |
54 | 54 | public static function confirmEmail( $name ) { |
55 | 55 | global $wgMemc; |
| 56 | + |
56 | 57 | $dbw = wfGetDB( DB_MASTER ); |
57 | 58 | $dbw->update( 'account_requests', |
58 | 59 | array( 'acr_email_authenticated' => $dbw->timestamp() ), |
— | — | @@ -85,6 +86,7 @@ |
86 | 87 | */ |
87 | 88 | public static function getConfirmationToken( $user, &$expiration ) { |
88 | 89 | global $wgConfirmAccountRejectAge; |
| 90 | + |
89 | 91 | $expires = time() + $wgConfirmAccountRejectAge; |
90 | 92 | $expiration = wfTimestamp( TS_MW, $expires ); |
91 | 93 | $token = $user->generateToken( $user->getName() . $user->getEmail() . $expires ); |
— | — | @@ -103,6 +105,7 @@ |
104 | 106 | */ |
105 | 107 | public static function sendConfirmationMail( User $user, $ip, $token, $expiration ) { |
106 | 108 | global $wgContLang; |
| 109 | + |
107 | 110 | $url = self::confirmationTokenUrl( $token ); |
108 | 111 | $lang = $user->getOption( 'language' ); |
109 | 112 | return $user->sendMail( |
— | — | @@ -125,8 +128,7 @@ |
126 | 129 | * @return string|false |
127 | 130 | */ |
128 | 131 | public function requestNameFromEmailToken( $code ) { |
129 | | - $dbr = wfGetDB( DB_SLAVE ); |
130 | | - return $dbr->selectField( 'account_requests', |
| 132 | + return wfGetDB( DB_SLAVE )->selectField( 'account_requests', |
131 | 133 | 'acr_name', |
132 | 134 | array( |
133 | 135 | 'acr_email_token' => md5( $code ), |
— | — | @@ -136,6 +138,28 @@ |
137 | 139 | } |
138 | 140 | |
139 | 141 | /** |
| 142 | + * Get the number of account requests for a request type |
| 143 | + * @param $type int |
| 144 | + * @return Array Assosiative array with 'open', 'held', 'type' keys mapping to integers |
| 145 | + */ |
| 146 | + public static function getOpenRequestCount( $type ) { |
| 147 | + $dbr = wfGetDB( DB_SLAVE ); |
| 148 | + $open = (int)$dbr->selectField( 'account_requests', 'COUNT(*)', |
| 149 | + array( 'acr_type' => $type, 'acr_deleted' => 0, 'acr_held IS NOT NULL' ), |
| 150 | + __METHOD__ |
| 151 | + ); |
| 152 | + $held = (int)$dbr->selectField( 'account_requests', 'COUNT(*)', |
| 153 | + array( 'acr_type' => $type, 'acr_deleted' => 0, 'acr_held IS NOT NULL' ), |
| 154 | + __METHOD__ |
| 155 | + ); |
| 156 | + $rej = (int)$dbr->selectField( 'account_requests', 'COUNT(*)', |
| 157 | + array( 'acr_type' => $type, 'acr_deleted' => 1, 'acr_user != 0' ), |
| 158 | + __METHOD__ |
| 159 | + ); |
| 160 | + return array( 'open' => $open, 'held' => $held, 'rejected' => $rej ); |
| 161 | + } |
| 162 | + |
| 163 | + /** |
140 | 164 | * Verifies that it's ok to include the uploaded file |
141 | 165 | * |
142 | 166 | * @param string $tmpfile the full path of the temporary file to verify |
Index: trunk/extensions/ConfirmAccount/presentation/specialpages/actions/ConfirmAccount_body.php |
— | — | @@ -1,26 +1,37 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ConfirmAccountsPage extends SpecialPage { |
| 5 | + protected $queueType = -1; |
| 6 | + protected $acrID = 0; |
| 7 | + protected $file = ''; |
5 | 8 | |
| 9 | + protected $showHeld = false; |
| 10 | + protected $showRejects = false; |
| 11 | + protected $showStale = false; |
| 12 | + |
| 13 | + protected $reqUsername; |
| 14 | + protected $reqType; |
| 15 | + protected $reqBio; |
| 16 | + protected $submitType; |
| 17 | + protected $reqAreas; |
| 18 | + protected $reqAreaset; |
| 19 | + protected $reason; |
| 20 | + |
6 | 21 | function __construct() { |
7 | | - parent::__construct('ConfirmAccounts','confirmaccount'); |
| 22 | + parent::__construct( 'ConfirmAccounts', 'confirmaccount' ); |
8 | 23 | } |
9 | 24 | |
10 | | - // @TODO: split out listlink mess |
11 | 25 | function execute( $par ) { |
12 | | - global $wgAccountRequestTypes, $wgLang; |
| 26 | + global $wgAccountRequestTypes; |
13 | 27 | |
14 | 28 | $reqUser = $this->getUser(); |
15 | 29 | $request = $this->getRequest(); |
16 | | - $out = $this->getOutput(); |
17 | | - if( !$reqUser->isAllowed( 'confirmaccount' ) ) { |
18 | | - $out->permissionRequired( 'confirmaccount' ); |
19 | | - return; |
| 30 | + |
| 31 | + if ( !$reqUser->isAllowed( 'confirmaccount' ) ) { |
| 32 | + throw new PermissionsError( 'confirmaccount' ); |
| 33 | + } elseif ( !$reqUser->getID() ) { |
| 34 | + throw new PermissionsError( 'user' ); |
20 | 35 | } |
21 | | - if( !$reqUser->getID() ) { |
22 | | - $out->permissionRequired( 'user' ); |
23 | | - return; |
24 | | - } |
25 | 36 | |
26 | 37 | $this->setHeaders(); |
27 | 38 | |
— | — | @@ -28,170 +39,190 @@ |
29 | 40 | # Use the special page param to act as a super type. |
30 | 41 | # Convert this to its integer form. |
31 | 42 | $this->queueType = -1; |
32 | | - foreach( $wgAccountRequestTypes as $i => $params ) { |
33 | | - if( $params[0] == $par ) { |
| 43 | + foreach ( $wgAccountRequestTypes as $i => $params ) { |
| 44 | + if ( $params[0] === $par ) { |
34 | 45 | $this->queueType = $i; |
35 | 46 | break; |
36 | 47 | } |
37 | 48 | } |
38 | | - |
39 | | - # A target user |
| 49 | + # User account request ID |
40 | 50 | $this->acrID = $request->getIntOrNull( 'acrid' ); |
41 | | - # Attachments |
| 51 | + # Attachment file name to view |
42 | 52 | $this->file = $request->getVal( 'file' ); |
43 | | - # For renaming to alot for collisions with other local requests |
44 | | - # that were added to some global $wgAuth system first. |
45 | | - $this->mUsername = trim( $request->getText( 'wpNewName' ) ); |
46 | | - # Position sought |
47 | | - $this->mType = $request->getIntOrNull( 'wpType' ); |
48 | | - $this->mType = ( !is_null($this->mType) && isset($wgAccountRequestTypes[$this->mType]) ) ? |
49 | | - $this->mType : null; |
50 | | - # For removing private info or such from bios |
51 | | - $this->mBio = $request->getText( 'wpNewBio' ); |
52 | | - # Held requests hidden by default |
53 | | - $this->showHeld = $request->getBool( 'wpShowHeld' ); |
54 | | - # Show stale requests |
55 | | - $this->showStale = $request->getBool( 'wpShowStale' ); |
56 | | - # For viewing rejected requests (stale requests count as rejected) |
57 | | - $this->showRejects = $request->getBool( 'wpShowRejects' ); |
58 | 53 | |
59 | | - $this->submitType = $request->getVal( 'wpSubmitType' ); |
60 | | - $this->reason = $request->getText( 'wpReason' ); |
61 | | - |
62 | 54 | # Load areas user plans to be active in... |
63 | | - $this->mAreas = $this->mAreaSet = array(); |
64 | | - if( wfMsg( 'requestaccount-areas' ) ) { |
| 55 | + # @FIXME: move this down and refactor |
| 56 | + $this->reqAreas = $this->reqAreaSet = array(); |
| 57 | + if ( wfMsgForContent( 'requestaccount-areas' ) ) { |
65 | 58 | $areas = explode("\n*","\n".wfMsg('requestaccount-areas')); |
66 | 59 | foreach( $areas as $area ) { |
67 | 60 | $set = explode("|",$area,2); |
68 | | - if( $set[0] && isset($set[1]) ) { |
| 61 | + if ( $set[0] && isset($set[1]) ) { |
69 | 62 | $formName = "wpArea-" . htmlspecialchars(str_replace(' ','_',$set[0])); |
70 | | - $this->mAreas[$formName] = $request->getInt( $formName, -1 ); |
| 63 | + $this->reqAreas[$formName] = $request->getInt( $formName, -1 ); |
71 | 64 | # Make a simple list of interests |
72 | | - if( $this->mAreas[$formName] > 0 ) |
73 | | - $this->mAreaSet[] = str_replace( '_', ' ', $set[0] ); |
| 65 | + if ( $this->reqAreas[$formName] > 0 ) { |
| 66 | + $this->reqAreaSet[] = str_replace( '_', ' ', $set[0] ); |
| 67 | + } |
74 | 68 | } |
75 | 69 | } |
76 | 70 | } |
77 | 71 | |
78 | | - $this->skin = $reqUser->getSkin(); |
| 72 | + // Showing a file |
| 73 | + if ( $this->file ) { |
| 74 | + $this->showFile( $this->file ); |
| 75 | + return; // nothing else to do |
| 76 | + // Showing or confirming an account request |
| 77 | + } elseif ( $this->acrID ) { |
| 78 | + if ( $request->wasPosted() ) { |
| 79 | + # For renaming to alot for collisions with other local requests |
| 80 | + # that were added to some global $wgAuth system first. |
| 81 | + $this->reqUsername = trim( $request->getText( 'wpNewName' ) ); |
| 82 | + # Position sought |
| 83 | + $this->reqType = $request->getIntOrNull( 'wpType' ); |
| 84 | + if ( !isset( $wgAccountRequestTypes[$this->reqType] ) ) { |
| 85 | + $this->reqType = null; |
| 86 | + } |
| 87 | + # For removing private info or such from bios |
| 88 | + $this->reqBio = $request->getText( 'wpNewBio' ); |
| 89 | + # Action the admin is taking and why |
| 90 | + $this->submitType = $request->getVal( 'wpSubmitType' ); |
| 91 | + $this->reason = $request->getText( 'wpReason' ); |
| 92 | + # Check if this is a valid submission... |
| 93 | + $token = $request->getVal( 'wpEditToken' ); |
| 94 | + if ( $reqUser->matchEditToken( $token, $this->acrID ) ) { |
| 95 | + $this->doAccountConfirmSubmit(); |
| 96 | + } else { |
| 97 | + $this->showAccountConfirmForm( wfMsgHtml( 'sessionfailure' ) ); |
| 98 | + } |
| 99 | + } else { |
| 100 | + $this->showAccountConfirmForm(); |
| 101 | + } |
| 102 | + // Showing all account requests in a queue |
| 103 | + } elseif ( $this->queueType != -1 ) { |
| 104 | + # Held requests hidden by default |
| 105 | + $this->showHeld = $request->getBool( 'wpShowHeld' ); |
| 106 | + # Show stale requests |
| 107 | + $this->showStale = $request->getBool( 'wpShowStale' ); |
| 108 | + # For viewing rejected requests (stale requests count as rejected) |
| 109 | + $this->showRejects = $request->getBool( 'wpShowRejects' ); |
79 | 110 | |
| 111 | + $this->showList(); |
| 112 | + // Showing all account request queues |
| 113 | + } else { |
| 114 | + $this->showQueues(); |
| 115 | + } |
| 116 | + |
| 117 | + // Show what queue we are in and links to others |
| 118 | + $this->addQueueSubtitleLinks(); |
| 119 | + |
| 120 | + $this->getOutput()->addModules( 'ext.confirmAccount' ); // CSS |
| 121 | + } |
| 122 | + |
| 123 | + protected function addQueueSubtitleLinks() { |
80 | 124 | $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $this->specialPageParameter ); |
81 | 125 | |
82 | 126 | # Show other sub-queue links. Grey out the current one. |
83 | 127 | # When viewing a request, show them all. |
84 | | - if( $this->acrID || $this->showStale || $this->showRejects || $this->showHeld ) { |
85 | | - $listLink = Linker::link( $titleObj, wfMsgHtml( 'confirmaccount-showopen' ), array(), array(), "known" ); |
| 128 | + if ( $this->acrID || $this->showStale || $this->showRejects || $this->showHeld ) { |
| 129 | + $listLink = Linker::link( $titleObj, |
| 130 | + wfMsgHtml( 'confirmaccount-showopen' ), array(), array(), "known" ); |
86 | 131 | } else { |
87 | 132 | $listLink = wfMsgHtml( 'confirmaccount-showopen' ); |
88 | 133 | } |
89 | | - if( $this->acrID || !$this->showHeld ) { |
90 | | - $listLink = $wgLang->pipeList( array( |
| 134 | + if ( $this->acrID || !$this->showHeld ) { |
| 135 | + $listLink = $this->getLang()->pipeList( array( |
91 | 136 | $listLink, |
92 | | - $this->skin->makeKnownLinkObj( $titleObj, |
93 | | - wfMsgHtml( 'confirmaccount-showheld' ), wfArrayToCGI( array( 'wpShowHeld' => 1 ) ) ) |
| 137 | + Linker::makeKnownLinkObj( $titleObj, |
| 138 | + wfMsgHtml( 'confirmaccount-showheld' ), |
| 139 | + wfArrayToCGI( array( 'wpShowHeld' => 1 ) ) ) |
94 | 140 | ) ); |
95 | 141 | } else { |
96 | | - $listLink = $wgLang->pipeList( array( |
| 142 | + $listLink = $this->getLang()->pipeList( array( |
97 | 143 | $listLink, |
98 | 144 | wfMsgHtml( 'confirmaccount-showheld' ) |
99 | 145 | ) ); |
100 | 146 | } |
101 | | - if( $this->acrID || !$this->showRejects ) { |
102 | | - $listLink = $wgLang->pipeList( array( |
| 147 | + if ( $this->acrID || !$this->showRejects ) { |
| 148 | + $listLink = $this->getLang()->pipeList( array( |
103 | 149 | $listLink, |
104 | | - $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-showrej' ), |
| 150 | + Linker::makeKnownLinkObj( $titleObj, |
| 151 | + wfMsgHtml( 'confirmaccount-showrej' ), |
105 | 152 | wfArrayToCGI( array( 'wpShowRejects' => 1 ) ) ) |
106 | 153 | ) ); |
107 | 154 | } else { |
108 | | - $listLink = $wgLang->pipeList( array( |
| 155 | + $listLink = $this->getLang()->pipeList( array( |
109 | 156 | $listLink, |
110 | 157 | wfMsgHtml( 'confirmaccount-showrej' ) |
111 | 158 | ) ); |
112 | 159 | } |
113 | | - if( $this->acrID || !$this->showStale ) { |
114 | | - $listLink = $wgLang->pipeList( array( |
| 160 | + if ( $this->acrID || !$this->showStale ) { |
| 161 | + $listLink = $this->getLang()->pipeList( array( |
115 | 162 | $listLink, |
116 | | - $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-showexp' ), |
| 163 | + Linker::makeKnownLinkObj( $titleObj, |
| 164 | + wfMsgHtml( 'confirmaccount-showexp' ), |
117 | 165 | wfArrayToCGI( array( 'wpShowStale' => 1 ) ) ) |
118 | 166 | ) ); |
119 | 167 | } else { |
120 | | - $listLink = $wgLang->pipeList( array( |
| 168 | + $listLink = $this->getLang()->pipeList( array( |
121 | 169 | $listLink, |
122 | 170 | wfMsgHtml( 'confirmaccount-showexp' ) |
123 | 171 | ) ); |
124 | 172 | } |
125 | 173 | |
126 | 174 | # Say what queue we are in... |
127 | | - if( $this->queueType != -1 ) { |
128 | | - $titleObj = $this->getTitle(); |
129 | | - $viewall = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-all') ); |
| 175 | + if ( $this->queueType != -1 ) { |
| 176 | + $viewall = Linker::makeKnownLinkObj( |
| 177 | + $this->getTitle(), wfMsgHtml('confirmaccount-all') ); |
130 | 178 | |
131 | | - $out->setSubtitle( "<strong>" . wfMsgHtml('confirmaccount-type') . " <i>" . |
| 179 | + $this->getOutput()->setSubtitle( |
| 180 | + "<strong>" . wfMsgHtml('confirmaccount-type') . " <i>" . |
132 | 181 | wfMsgHtml("confirmaccount-type-{$this->queueType}") . |
133 | 182 | "</i></strong> [{$listLink}] <strong>{$viewall}</strong>" ); |
134 | 183 | } |
135 | | - |
136 | | - if( $request->wasPosted() && $reqUser->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { |
137 | | - $this->doSubmit(); |
138 | | - } elseif( $this->file ) { |
139 | | - $this->showFile( $this->file ); |
140 | | - } elseif( $this->acrID ) { |
141 | | - $this->showForm(); |
142 | | - } elseif( $this->queueType != -1 ) { |
143 | | - $this->showList(); |
144 | | - } else { |
145 | | - $this->showQueues(); |
146 | | - } |
147 | | - $out->addModules( 'ext.confirmAccount' ); // CSS |
148 | 184 | } |
149 | 185 | |
150 | 186 | protected function showQueues() { |
151 | | - global $wgAccountRequestTypes, $wgLang; |
| 187 | + global $wgAccountRequestTypes; |
| 188 | + |
152 | 189 | $out = $this->getOutput(); |
153 | 190 | |
154 | 191 | $out->addWikiMsg( 'confirmaccount-maintext' ); |
| 192 | + $out->addHTML( '<p><strong>' . wfMsgHtml('confirmaccount-types') . '</strong></p>' ); |
155 | 193 | |
156 | | - $out->addHTML( '<p><strong>' . wfMsgHtml('confirmaccount-types') . '</strong></p>' ); |
| 194 | + # List each queue and some information about it... |
157 | 195 | $out->addHTML( '<ul>' ); |
158 | | - |
159 | | - $dbr = wfGetDB( DB_SLAVE ); |
160 | | - # List each queue |
161 | | - foreach( $wgAccountRequestTypes as $i => $params ) { |
| 196 | + foreach ( $wgAccountRequestTypes as $i => $params ) { |
162 | 197 | $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $params[0] ); |
| 198 | + $counts = ConfirmAccount::getOpenRequestCount( $i ); |
163 | 199 | |
164 | | - $open = '<b>'.$this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-open' ), |
165 | | - wfArrayToCGI( array('wpShowHeld' => 0) ) ).'</b>'; |
166 | | - $held = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-held' ), |
167 | | - wfArrayToCGI( array('wpShowHeld' => 1) ) ); |
168 | | - $rejects = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-rej' ), |
169 | | - wfArrayToCGI( array('wpShowRejects' => 1) ) ); |
170 | | - $stale = '<i>'.$this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-stale' ), |
171 | | - wfArrayToCGI( array('wpShowStale' => 1) ) ).'</i>';; |
| 200 | + $open = '<b>' . Linker::makeKnownLinkObj( $titleObj, |
| 201 | + wfMsgHtml( 'confirmaccount-q-open' ), |
| 202 | + wfArrayToCGI( array( 'wpShowHeld' => 0 ) ) ) . '</b>'; |
| 203 | + $open .= ' [' . $counts['open'] . ']'; |
172 | 204 | |
173 | | - $count = $dbr->selectField( 'account_requests', 'COUNT(*)', |
174 | | - array( 'acr_type' => $i, 'acr_deleted' => 0, 'acr_held IS NULL' ), |
175 | | - __METHOD__ ); |
176 | | - $open .= " [$count]"; |
| 205 | + $held = Linker::makeKnownLinkObj( $titleObj, |
| 206 | + wfMsgHtml( 'confirmaccount-q-held' ), |
| 207 | + wfArrayToCGI( array( 'wpShowHeld' => 1 ) ) ); |
| 208 | + $held .= ' [' . $counts['held'] . ']'; |
177 | 209 | |
178 | | - $count = $dbr->selectField( 'account_requests', 'COUNT(*)', |
179 | | - array( 'acr_type' => $i, 'acr_deleted' => 0, 'acr_held IS NOT NULL' ), |
180 | | - __METHOD__ ); |
181 | | - $held .= " [$count]"; |
| 210 | + $rejects = Linker::makeKnownLinkObj( $titleObj, |
| 211 | + wfMsgHtml( 'confirmaccount-q-rej' ), |
| 212 | + wfArrayToCGI( array( 'wpShowRejects' => 1 ) ) ); |
| 213 | + $rejects .= ' [' . $counts['rejected'] . ']'; |
182 | 214 | |
183 | | - $count = $dbr->selectField( 'account_requests', 'COUNT(*)', |
184 | | - array( 'acr_type' => $i, 'acr_deleted' => 1, 'acr_user != 0' ), |
185 | | - __METHOD__ ); |
186 | | - $rejects .= " [$count]"; |
| 215 | + $stale = '<i>'.Linker::makeKnownLinkObj( $titleObj, |
| 216 | + wfMsgHtml( 'confirmaccount-q-stale' ), |
| 217 | + wfArrayToCGI( array( 'wpShowStale' => 1 ) ) ).'</i>'; |
187 | 218 | |
188 | 219 | $out->addHTML( "<li><i>".wfMsgHtml("confirmaccount-type-$i")."</i> (" . |
189 | | - $wgLang->pipeList( array( $open, $held, $rejects, $stale ) ) . ")</li>" ); |
| 220 | + $this->getLang()->pipeList( array( $open, $held, $rejects, $stale ) ) . ")</li>" ); |
190 | 221 | } |
191 | 222 | $out->addHTML( '</ul>' ); |
192 | 223 | } |
193 | 224 | |
194 | | - protected function showForm( $msg='' ) { |
195 | | - global $wgLang, $wgAccountRequestTypes; |
| 225 | + protected function showAccountConfirmForm( $msg='' ) { |
| 226 | + global $wgAccountRequestTypes; |
196 | 227 | $reqUser = $this->getUser(); |
197 | 228 | $out = $this->getOutput(); |
198 | 229 | |
— | — | @@ -212,9 +243,9 @@ |
213 | 244 | $out->addWikiMsg( 'confirmaccount-text' ); |
214 | 245 | |
215 | 246 | if( $row->acr_rejected ) { |
216 | | - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
217 | | - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
218 | | - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
| 247 | + $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
| 248 | + $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
| 249 | + $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
219 | 250 | $reason = $row->acr_comment ? |
220 | 251 | htmlspecialchars($row->acr_comment) : wfMsgHtml('confirmaccount-noreason'); |
221 | 252 | # Auto-rejected requests have a user ID of zero |
— | — | @@ -227,9 +258,9 @@ |
228 | 259 | $out->addHTML( "<p><i> $reason </i></p>" ); |
229 | 260 | } |
230 | 261 | } elseif( $row->acr_held ) { |
231 | | - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true ); |
232 | | - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_held), true ); |
233 | | - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_held), true ); |
| 262 | + $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true ); |
| 263 | + $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_held), true ); |
| 264 | + $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_held), true ); |
234 | 265 | $reason = $row->acr_comment ? $row->acr_comment : wfMsgHtml('confirmaccount-noreason'); |
235 | 266 | |
236 | 267 | $out->addHTML('<p><b>'.wfMsgExt( 'confirmaccount-held', array('parseinline'), |
— | — | @@ -244,7 +275,7 @@ |
245 | 276 | $form .= '<legend>' . wfMsgHtml('confirmaccount-leg-user') . '</legend>'; |
246 | 277 | $form .= '<table cellpadding=\'4\'>'; |
247 | 278 | $form .= "<tr><td>".Xml::label( wfMsgHtml('username'), 'wpNewName' )."</td>"; |
248 | | - $form .= "<td>".Xml::input( 'wpNewName', 30, $this->mUsername, array('id' => 'wpNewName') )."</td></tr>\n"; |
| 279 | + $form .= "<td>".Xml::input( 'wpNewName', 30, $this->reqUsername, array('id' => 'wpNewName') )."</td></tr>\n"; |
249 | 280 | |
250 | 281 | $econf = $row->acr_email_authenticated ? ' <strong>'.wfMsgHtml('confirmaccount-econf').'</strong>' : ''; |
251 | 282 | $form .= "<tr><td>".wfMsgHtml('confirmaccount-email')."</td>"; |
— | — | @@ -253,7 +284,7 @@ |
254 | 285 | $options = array(); |
255 | 286 | $form .= "<tr><td><strong>".wfMsgHtml('confirmaccount-reqtype')."</strong></td><td>"; |
256 | 287 | foreach( $wgAccountRequestTypes as $i => $params ) { |
257 | | - $options[] = Xml::option( wfMsg( "confirmaccount-pos-$i" ), $i, ($i == $this->mType) ); |
| 288 | + $options[] = Xml::option( wfMsg( "confirmaccount-pos-$i" ), $i, ($i == $this->reqType) ); |
258 | 289 | } |
259 | 290 | $form .= Xml::openElement( 'select', array( 'name' => "wpType" ) ); |
260 | 291 | $form .= implode( "\n", $options ); |
— | — | @@ -263,7 +294,7 @@ |
264 | 295 | |
265 | 296 | $form .= '</table></fieldset>'; |
266 | 297 | |
267 | | - if( wfMsg( 'requestaccount-areas' ) ) { |
| 298 | + if( wfMsgForContent( 'requestaccount-areas' ) ) { |
268 | 299 | $form .= '<fieldset>'; |
269 | 300 | $form .= '<legend>' . wfMsgHtml('confirmaccount-leg-areas') . '</legend>'; |
270 | 301 | |
— | — | @@ -286,7 +317,7 @@ |
287 | 318 | $pg = ''; |
288 | 319 | } |
289 | 320 | |
290 | | - $form .= "<td>".Xml::checkLabel( $set[0], $formName, $formName, $this->mAreas[$formName] > 0 )." {$pg}</td>\n"; |
| 321 | + $form .= "<td>".Xml::checkLabel( $set[0], $formName, $formName, $this->reqAreas[$formName] > 0 )." {$pg}</td>\n"; |
291 | 322 | } |
292 | 323 | } |
293 | 324 | $form .= "</tr></table></div>"; |
— | — | @@ -304,7 +335,7 @@ |
305 | 336 | } |
306 | 337 | $form .= "<p>".wfMsgHtml('confirmaccount-bio')."\n"; |
307 | 338 | $form .= "<textarea tabindex='1' name='wpNewBio' id='wpNewBio' rows='12' cols='80' style='width:100%; background-color:#f9f9f9;'>" . |
308 | | - htmlspecialchars($this->mBio) . |
| 339 | + htmlspecialchars($this->reqBio) . |
309 | 340 | "</textarea></p>\n"; |
310 | 341 | $form .= '</fieldset>'; |
311 | 342 | global $wgAccountRequestExtraInfo; |
— | — | @@ -314,7 +345,7 @@ |
315 | 346 | if( $wgAccountRequestExtraInfo ) { |
316 | 347 | $form .= '<p>'.wfMsgHtml('confirmaccount-attach') . ' '; |
317 | 348 | if( $row->acr_filename ) { |
318 | | - $form .= $this->skin->makeKnownLinkObj( $titleObj, htmlspecialchars($row->acr_filename), |
| 349 | + $form .= Linker::makeKnownLinkObj( $titleObj, htmlspecialchars($row->acr_filename), |
319 | 350 | 'file=' . $row->acr_storage_key ); |
320 | 351 | } else { |
321 | 352 | $form .= wfMsgHtml('confirmaccount-none-p'); |
— | — | @@ -329,7 +360,7 @@ |
330 | 361 | if( $reqUser->isAllowed( 'requestips' ) ) { |
331 | 362 | $blokip = SpecialPage::getTitleFor( 'Block' ); |
332 | 363 | $form .= "<p>".wfMsgHtml('confirmaccount-ip')." ".htmlspecialchars($row->acr_ip). |
333 | | - " (" . $this->skin->makeKnownLinkObj( $blokip, wfMsgHtml('blockip'), |
| 364 | + " (" . Linker::makeKnownLinkObj( $blokip, wfMsgHtml('blockip'), |
334 | 365 | 'ip=' . $row->acr_ip . '&wpCreateAccount=1' ).")</p>\n"; |
335 | 366 | } |
336 | 367 | $form .= '</fieldset>'; |
— | — | @@ -364,7 +395,7 @@ |
365 | 396 | $form .= Html::Hidden( 'action', 'reject' ); |
366 | 397 | $form .= Html::Hidden( 'acrid', $row->acr_id ); |
367 | 398 | $form .= Html::Hidden( 'wpShowRejects', $this->showRejects ); |
368 | | - $form .= Html::Hidden( 'wpEditToken', $reqUser->editToken() )."\n"; |
| 399 | + $form .= Html::Hidden( 'wpEditToken', $reqUser->editToken( $row->acr_id ) )."\n"; |
369 | 400 | $form .= Xml::closeElement( 'form' ); |
370 | 401 | |
371 | 402 | $out->addHTML( $form ); |
— | — | @@ -402,7 +433,7 @@ |
403 | 434 | StreamFile::stream( $path ); |
404 | 435 | } |
405 | 436 | |
406 | | - protected function doSubmit() { |
| 437 | + protected function doAccountConfirmSubmit() { |
407 | 438 | $reqUser = $this->getUser(); |
408 | 439 | $out = $this->getOutput(); |
409 | 440 | |
— | — | @@ -449,7 +480,7 @@ |
450 | 481 | |
451 | 482 | if( !$result->isOk() ) { |
452 | 483 | $error = wfMsg( 'mailerror', $out->parse( $result->getWikiText() ) ); |
453 | | - $this->showForm( $error ); |
| 484 | + $this->showAccountConfirmForm( $error ); |
454 | 485 | return false; |
455 | 486 | } |
456 | 487 | } |
— | — | @@ -466,9 +497,9 @@ |
467 | 498 | global $wgAuth, $wgConfirmAccountSaveInfo, $wgAllowAccountRequestFiles; |
468 | 499 | |
469 | 500 | # Now create user and check if the name is valid |
470 | | - $user = User::newFromName( $this->mUsername, 'creatable' ); |
| 501 | + $user = User::newFromName( $this->reqUsername, 'creatable' ); |
471 | 502 | if( is_null($user) ) { |
472 | | - $this->showForm( wfMsgHtml('noname') ); |
| 503 | + $this->showAccountConfirmForm( wfMsgHtml('noname') ); |
473 | 504 | return; |
474 | 505 | } |
475 | 506 | |
— | — | @@ -477,7 +508,7 @@ |
478 | 509 | |
479 | 510 | # Check if already in use |
480 | 511 | if( 0 != $user->idForName() || $wgAuth->userExists( $user->getName() ) ) { |
481 | | - $this->showForm( wfMsgHtml('userexists') ); |
| 512 | + $this->showAccountConfirmForm( wfMsgHtml('userexists') ); |
482 | 513 | return; |
483 | 514 | } |
484 | 515 | # Add user to DB |
— | — | @@ -547,15 +578,15 @@ |
548 | 579 | if( !$wgAuth->addUser( $user, $p, $row->acr_email, $row->acr_real_name ) ) { |
549 | 580 | $dbw->delete( 'user', array( 'user_id' => $user->getID() ) ); |
550 | 581 | $dbw->rollback(); |
551 | | - $this->showForm( wfMsgHtml( 'externaldberror' ) ); |
| 582 | + $this->showAccountConfirmForm( wfMsgHtml( 'externaldberror' ) ); |
552 | 583 | return false; |
553 | 584 | } |
554 | 585 | |
555 | 586 | # Grant any necessary rights |
556 | 587 | $grouptext = $group = ''; |
557 | 588 | global $wgAccountRequestTypes; |
558 | | - if( array_key_exists($this->mType,$wgAccountRequestTypes) ) { |
559 | | - $params = $wgAccountRequestTypes[$this->mType]; |
| 589 | + if( array_key_exists($this->reqType,$wgAccountRequestTypes) ) { |
| 590 | + $params = $wgAccountRequestTypes[$this->reqType]; |
560 | 591 | $group = isset($params[1]) ? $params[1] : false; |
561 | 592 | $grouptext = isset($params[2]) ? $params[2] : ''; |
562 | 593 | // Do not add blank or dummy groups |
— | — | @@ -574,7 +605,7 @@ |
575 | 606 | |
576 | 607 | # Send out password |
577 | 608 | if( $this->reason ) { |
578 | | - $msg = "confirmaccount-email-body2-pos{$this->mType}"; |
| 609 | + $msg = "confirmaccount-email-body2-pos{$this->reqType}"; |
579 | 610 | # If the user is in a group and there is a welcome for that group, use it |
580 | 611 | if( $group && !wfEmptyMsg( $msg, wfMsg($msg) ) ) { |
581 | 612 | $ebody = wfMsgExt( $msg, array('parsemag','content'), |
— | — | @@ -585,7 +616,7 @@ |
586 | 617 | array('parsemag','content'), $user->getName(), $p, $this->reason ); |
587 | 618 | } |
588 | 619 | } else { |
589 | | - $msg = "confirmaccount-email-body-pos{$this->mType}"; |
| 620 | + $msg = "confirmaccount-email-body-pos{$this->reqType}"; |
590 | 621 | # If the user is in a group and there is a welcome for that group, use it |
591 | 622 | if( $group && !wfEmptyMsg( $msg, wfMsg($msg) ) ) { |
592 | 623 | $ebody = wfMsgExt($msg, array('parsemag','content'), |
— | — | @@ -627,30 +658,30 @@ |
628 | 659 | |
629 | 660 | # Start up the user's (presumedly brand new) userpages |
630 | 661 | # Will not append, so previous content will be blanked |
631 | | - global $wgMakeUserPageFromBio, $wgAutoUserBioText; |
632 | | - if( $wgMakeUserPageFromBio ) { |
| 662 | + global $wgMakeUserPageFroreqBio, $wgAutoUserBioText; |
| 663 | + if( $wgMakeUserPageFroreqBio ) { |
633 | 664 | $usertitle = $user->getUserPage(); |
634 | 665 | $userpage = new Article( $usertitle ); |
635 | 666 | |
636 | 667 | $autotext = strval($wgAutoUserBioText); |
637 | | - $body = $autotext ? "{$this->mBio}\n\n{$autotext}" : $this->mBio; |
| 668 | + $body = $autotext ? "{$this->reqBio}\n\n{$autotext}" : $this->reqBio; |
638 | 669 | $body = $grouptext ? "{$body}\n\n{$grouptext}" : $body; |
639 | 670 | |
640 | 671 | # Add any interest categories |
641 | | - if( wfMsg( 'requestaccount-areas' ) ) { |
| 672 | + if( wfMsgForContent( 'requestaccount-areas' ) ) { |
642 | 673 | $areas = explode("\n*","\n".wfMsg('requestaccount-areas')); |
643 | 674 | foreach( $areas as $n => $line ) { |
644 | 675 | $set = explode("|",$line); |
645 | 676 | //$name = str_replace("_"," ",$set[0]); |
646 | | - if( in_array($set[0],$this->mAreaSet) ) { |
| 677 | + if( in_array($set[0],$this->reqAreaSet) ) { |
647 | 678 | # General userpage text for anyone with this interest |
648 | 679 | if( isset($set[2]) ) { |
649 | 680 | $body .= $set[2]; |
650 | 681 | } |
651 | 682 | # Message for users with this interested with the given account type |
652 | 683 | # MW: message of format <name>|<wiki page>|<anyone>|<group0>|<group1>... |
653 | | - if( isset($set[3+$this->mType]) && $set[3+$this->mType] ) { |
654 | | - $body .= $set[3+$this->mType]; |
| 684 | + if( isset($set[3+$this->reqType]) && $set[3+$this->reqType] ) { |
| 685 | + $body .= $set[3+$this->reqType]; |
655 | 686 | } |
656 | 687 | } |
657 | 688 | } |
— | — | @@ -680,7 +711,7 @@ |
681 | 712 | global $wgAutoWelcomeNewUsers; |
682 | 713 | if( $wgAutoWelcomeNewUsers ) { |
683 | 714 | $utalk = new Article( $user->getTalkPage() ); |
684 | | - $msg = "confirmaccount-welc-pos{$this->mType}"; |
| 715 | + $msg = "confirmaccount-welc-pos{$this->reqType}"; |
685 | 716 | # Is there a custom message? |
686 | 717 | $welcome = wfEmptyMsg( $msg, wfMsg($msg) ) ? |
687 | 718 | wfMsg('confirmaccount-welc') : wfMsg($msg); |
— | — | @@ -699,11 +730,11 @@ |
700 | 731 | # Pointless without a summary... |
701 | 732 | if( $row->acr_held || ($row->acr_deleted && $row->acr_deleted !='f') ) { |
702 | 733 | $error = wfMsg( 'confirmaccount-canthold' ); |
703 | | - $this->showForm( $error ); |
| 734 | + $this->showAccountConfirmForm( $error ); |
704 | 735 | return false; |
705 | 736 | } elseif( !$this->reason ) { |
706 | 737 | $error = wfMsg( 'confirmaccount-needreason' ); |
707 | | - $this->showForm( $error ); |
| 738 | + $this->showAccountConfirmForm( $error ); |
708 | 739 | return false; |
709 | 740 | } |
710 | 741 | |
— | — | @@ -728,7 +759,7 @@ |
729 | 760 | if( !$result->isOK() ) { |
730 | 761 | $dbw->rollback(); |
731 | 762 | $error = wfMsg( 'mailerror', $out->parse( $result->getWikiText() ) ); |
732 | | - $this->showForm( $error ); |
| 763 | + $this->showAccountConfirmForm( $error ); |
733 | 764 | return false; |
734 | 765 | } |
735 | 766 | } |
— | — | @@ -741,7 +772,7 @@ |
742 | 773 | |
743 | 774 | $this->showSuccess( $this->submitType ); |
744 | 775 | } else { |
745 | | - $this->showForm(); |
| 776 | + $this->showAccountConfirmForm(); |
746 | 777 | } |
747 | 778 | } |
748 | 779 | |
— | — | @@ -758,18 +789,18 @@ |
759 | 790 | ); |
760 | 791 | # Check if parameters are to be overridden |
761 | 792 | if( $row ) { |
762 | | - $this->mUsername = $this->mUsername ? $this->mUsername : $row->acr_name; |
763 | | - $this->mBio = $this->mBio ? $this->mBio : $row->acr_bio; |
764 | | - $this->mType = !is_null($this->mType) ? $this->mType : $row->acr_type; |
| 793 | + $this->reqUsername = $this->reqUsername ? $this->reqUsername : $row->acr_name; |
| 794 | + $this->reqBio = $this->reqBio ? $this->reqBio : $row->acr_bio; |
| 795 | + $this->reqType = !is_null($this->reqType) ? $this->reqType : $row->acr_type; |
765 | 796 | $rowareas = UserAccountRequest::expandAreas( $row->acr_areas ); |
766 | 797 | |
767 | | - foreach( $this->mAreas as $area => $within ) { |
| 798 | + foreach( $this->reqAreas as $area => $within ) { |
768 | 799 | # If admin didn't set any of these checks, go back to how the user set them |
769 | 800 | if( $within == -1 ) { |
770 | 801 | if( in_array($area,$rowareas) ) |
771 | | - $this->mAreas[$area] = 1; |
| 802 | + $this->reqAreas[$area] = 1; |
772 | 803 | else |
773 | | - $this->mAreas[$area] = 0; |
| 804 | + $this->reqAreas[$area] = 0; |
774 | 805 | } |
775 | 806 | } |
776 | 807 | } |
— | — | @@ -870,35 +901,34 @@ |
871 | 902 | } |
872 | 903 | |
873 | 904 | public function formatRow( $row ) { |
874 | | - global $wgLang, $wgUseRealNamesOnly, $wgAllowRealName; |
| 905 | + global $wgUseRealNamesOnly, $wgAllowRealName, $wgMemc; |
875 | 906 | |
876 | 907 | $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $this->specialPageParameter ); |
877 | 908 | if( $this->showRejects || $this->showStale ) { |
878 | | - $link = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'), |
| 909 | + $link = Linker::makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'), |
879 | 910 | 'acrid='.$row->acr_id.'&wpShowRejects=1' ); |
880 | 911 | } else { |
881 | | - $link = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'), |
| 912 | + $link = Linker::makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'), |
882 | 913 | 'acrid='.$row->acr_id ); |
883 | 914 | } |
884 | | - $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_registration), true ); |
| 915 | + $time = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_registration), true ); |
885 | 916 | |
886 | 917 | $r = "<li class='mw-confirmaccount-time-{$this->queueType}'>"; |
887 | 918 | |
888 | 919 | $r .= $time." (<strong>{$link}</strong>)"; |
889 | 920 | # Auto-rejected accounts have a user ID of zero |
890 | 921 | if( $row->acr_rejected && $row->acr_user ) { |
891 | | - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
892 | | - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
893 | | - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
| 922 | + $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
| 923 | + $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
| 924 | + $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_rejected), true ); |
894 | 925 | $r .= ' <b>'.wfMsgExt( 'confirmaccount-reject', array('parseinline'), $row->user_name, $datim, $date, $time ).'</b>'; |
895 | 926 | } elseif( $row->acr_held && !$row->acr_rejected ) { |
896 | | - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true ); |
897 | | - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_held), true ); |
898 | | - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_held), true ); |
| 927 | + $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true ); |
| 928 | + $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_held), true ); |
| 929 | + $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_held), true ); |
899 | 930 | $r .= ' <b>'.wfMsgExt( 'confirmaccount-held', array('parseinline'), User::whoIs($row->acr_user), $datim, $date, $time ).'</b>'; |
900 | 931 | } |
901 | 932 | # Check if someone is viewing this request |
902 | | - global $wgMemc; |
903 | 933 | $key = wfMemcKey( 'acctrequest', 'view', $row->acr_id ); |
904 | 934 | $value = $wgMemc->get( $key ); |
905 | 935 | if( $value ) { |
— | — | @@ -919,7 +949,7 @@ |
920 | 950 | htmlspecialchars($row->acr_email) . $econf.'</td></tr>'; |
921 | 951 | # Truncate this, blah blah... |
922 | 952 | $bio = htmlspecialchars($row->acr_bio); |
923 | | - $preview = $wgLang->truncate( $bio, 400, '' ); |
| 953 | + $preview = $this->getLang()->truncate( $bio, 400, '' ); |
924 | 954 | if( strlen($preview) < strlen($bio) ) { |
925 | 955 | $preview = substr( $preview, 0, strrpos($preview,' ') ); |
926 | 956 | $preview .= " . . ."; |
— | — | @@ -954,10 +984,11 @@ |
955 | 985 | $this->mConds['acr_deleted'] = 1; |
956 | 986 | } else { |
957 | 987 | $this->mConds['acr_deleted'] = 0; |
958 | | - if( $showHeld ) |
| 988 | + if( $showHeld ) { |
959 | 989 | $this->mConds[] = 'acr_held IS NOT NULL'; |
960 | | - else |
| 990 | + } else { |
961 | 991 | $this->mConds[] = 'acr_held IS NULL'; |
| 992 | + } |
962 | 993 | |
963 | 994 | } |
964 | 995 | parent::__construct(); |