Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -184,7 +184,7 @@ |
185 | 185 | * @todo Fixme: almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined. |
186 | 186 | */ |
187 | 187 | protected function contributionsSub( $nt, $id ) { |
188 | | - global $wgSysopUserBans, $wgLang, $wgUser, $wgOut; |
| 188 | + global $wgLang, $wgUser, $wgOut; |
189 | 189 | |
190 | 190 | $sk = $wgUser->getSkin(); |
191 | 191 | |
— | — | @@ -196,78 +196,7 @@ |
197 | 197 | $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false ); |
198 | 198 | $talk = $nt->getTalkPage(); |
199 | 199 | if( $talk ) { |
200 | | - # Talk page link |
201 | | - $tools[] = $sk->link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); |
202 | | - if( ( $id !== null && $wgSysopUserBans ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { |
203 | | - if( $wgUser->isAllowed( 'block' ) ) { # Block / Change block / Unblock links |
204 | | - if ( $userObj->isBlocked() ) { |
205 | | - $tools[] = $sk->linkKnown( # Change block link |
206 | | - SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), |
207 | | - wfMsgHtml( 'change-blocklink' ) |
208 | | - ); |
209 | | - $tools[] = $sk->linkKnown( # Unblock link |
210 | | - SpecialPage::getTitleFor( 'Ipblocklist' ), |
211 | | - wfMsgHtml( 'unblocklink' ), |
212 | | - array(), |
213 | | - array( |
214 | | - 'action' => 'unblock', |
215 | | - 'ip' => $nt->getDBkey() |
216 | | - ) |
217 | | - ); |
218 | | - } |
219 | | - else { # User is not blocked |
220 | | - $tools[] = $sk->linkKnown( # Block link |
221 | | - SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), |
222 | | - wfMsgHtml( 'blocklink' ) |
223 | | - ); |
224 | | - } |
225 | | - } |
226 | | - # Block log link |
227 | | - $tools[] = $sk->linkKnown( |
228 | | - SpecialPage::getTitleFor( 'Log' ), |
229 | | - wfMsgHtml( 'sp-contributions-blocklog' ), |
230 | | - array(), |
231 | | - array( |
232 | | - 'type' => 'block', |
233 | | - 'page' => $nt->getPrefixedText() |
234 | | - ) |
235 | | - ); |
236 | | - } |
237 | | - # Uploads |
238 | | - $tools[] = $sk->linkKnown( |
239 | | - SpecialPage::getTitleFor( 'Listfiles' ), |
240 | | - wfMsgHtml( 'sp-contributions-uploads' ), |
241 | | - array(), |
242 | | - array( 'user' => $nt->getText() ) |
243 | | - ); |
244 | | - |
245 | | - # Other logs link |
246 | | - $tools[] = $sk->linkKnown( |
247 | | - SpecialPage::getTitleFor( 'Log' ), |
248 | | - wfMsgHtml( 'sp-contributions-logs' ), |
249 | | - array(), |
250 | | - array( 'user' => $nt->getText() ) |
251 | | - ); |
252 | | - |
253 | | - # Add link to deleted user contributions for priviledged users |
254 | | - if( $wgUser->isAllowed( 'deletedhistory' ) ) { |
255 | | - $tools[] = $sk->linkKnown( |
256 | | - SpecialPage::getTitleFor( 'DeletedContributions', $nt->getDBkey() ), |
257 | | - wfMsgHtml( 'sp-contributions-deleted' ) |
258 | | - ); |
259 | | - } |
260 | | - |
261 | | - # Add a link to change user rights for privileged users |
262 | | - $userrightsPage = new UserrightsPage(); |
263 | | - if( $id !== null && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) { |
264 | | - $tools[] = $sk->linkKnown( |
265 | | - SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), |
266 | | - wfMsgHtml( 'sp-contributions-userrights' ) |
267 | | - ); |
268 | | - } |
269 | | - |
270 | | - wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); |
271 | | - |
| 200 | + $tools = self::getUserLinks( $nt, $talk, $userObj, $wgUser ); |
272 | 201 | $links = $wgLang->pipeList( $tools ); |
273 | 202 | |
274 | 203 | // Show a note if the user is blocked and display the last block log entry. |
— | — | @@ -304,6 +233,93 @@ |
305 | 234 | } |
306 | 235 | |
307 | 236 | /** |
| 237 | + * Links to different places. |
| 238 | + * @param $userpage Title: Target user page |
| 239 | + * @param $talkpage Title: Talk page |
| 240 | + * @param $target User: Target user object |
| 241 | + * @param $subject User: The viewing user ($wgUser is still checked in some cases, like userrights page!!) |
| 242 | + */ |
| 243 | + public static function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) { |
| 244 | + global $wgSysopUserBans; |
| 245 | + |
| 246 | + $sk = $subject->getSkin(); |
| 247 | + $id = $target->getId(); |
| 248 | + $username = $target->getName(); |
| 249 | + |
| 250 | + $tools[] = $sk->link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) ); |
| 251 | + |
| 252 | + if( ( $id !== null && $wgSysopUserBans ) || ( $id === null && IP::isIPAddress( $username ) ) ) { |
| 253 | + if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links |
| 254 | + if ( $target->isBlocked() ) { |
| 255 | + $tools[] = $sk->linkKnown( # Change block link |
| 256 | + SpecialPage::getTitleFor( 'Blockip', $username ), |
| 257 | + wfMsgHtml( 'change-blocklink' ) |
| 258 | + ); |
| 259 | + $tools[] = $sk->linkKnown( # Unblock link |
| 260 | + SpecialPage::getTitleFor( 'Ipblocklist' ), |
| 261 | + wfMsgHtml( 'unblocklink' ), |
| 262 | + array(), |
| 263 | + array( |
| 264 | + 'action' => 'unblock', |
| 265 | + 'ip' => $username |
| 266 | + ) |
| 267 | + ); |
| 268 | + } else { # User is not blocked |
| 269 | + $tools[] = $sk->linkKnown( # Block link |
| 270 | + SpecialPage::getTitleFor( 'Blockip', $username ), |
| 271 | + wfMsgHtml( 'blocklink' ) |
| 272 | + ); |
| 273 | + } |
| 274 | + } |
| 275 | + # Block log link |
| 276 | + $tools[] = $sk->linkKnown( |
| 277 | + SpecialPage::getTitleFor( 'Log' ), |
| 278 | + wfMsgHtml( 'sp-contributions-blocklog' ), |
| 279 | + array(), |
| 280 | + array( |
| 281 | + 'type' => 'block', |
| 282 | + 'page' => $userpage->getPrefixedText() |
| 283 | + ) |
| 284 | + ); |
| 285 | + } |
| 286 | + # Uploads |
| 287 | + $tools[] = $sk->linkKnown( |
| 288 | + SpecialPage::getTitleFor( 'Listfiles' ), |
| 289 | + wfMsgHtml( 'sp-contributions-uploads' ), |
| 290 | + array(), |
| 291 | + array( 'user' => $username ) |
| 292 | + ); |
| 293 | + |
| 294 | + # Other logs link |
| 295 | + $tools[] = $sk->linkKnown( |
| 296 | + SpecialPage::getTitleFor( 'Log' ), |
| 297 | + wfMsgHtml( 'sp-contributions-logs' ), |
| 298 | + array(), |
| 299 | + array( 'user' => $username ) |
| 300 | + ); |
| 301 | + |
| 302 | + # Add link to deleted user contributions for priviledged users |
| 303 | + if( $subject->isAllowed( 'deletedhistory' ) ) { |
| 304 | + $tools[] = $sk->linkKnown( |
| 305 | + SpecialPage::getTitleFor( 'DeletedContributions', $username ), |
| 306 | + wfMsgHtml( 'sp-contributions-deleted' ) |
| 307 | + ); |
| 308 | + } |
| 309 | + |
| 310 | + # Add a link to change user rights for privileged users |
| 311 | + $userrightsPage = new UserrightsPage(); |
| 312 | + if( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) { |
| 313 | + $tools[] = $sk->linkKnown( |
| 314 | + SpecialPage::getTitleFor( 'Userrights', $username ), |
| 315 | + wfMsgHtml( 'sp-contributions-userrights' ) |
| 316 | + ); |
| 317 | + } |
| 318 | + |
| 319 | + wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) ); |
| 320 | + return $tools; |
| 321 | + } |
| 322 | + |
| 323 | + /** |
308 | 324 | * Generates the namespace selector form with hidden attributes. |
309 | 325 | * @return String: HTML fragment |
310 | 326 | */ |