Index: trunk/phase3/includes/specials/SpecialRemoveRestrictions.php |
— | — | @@ -1,60 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -function wfSpecialRemoveRestrictions() { |
5 | | - global $wgOut, $wgRequest, $wgUser, $wgLang; |
6 | | - $sk = $wgUser->getSkin(); |
7 | | - $title = SpecialPage::getTitleFor( 'RemoveRestrictions' ); |
8 | | - $id = $wgRequest->getVal( 'id' ); |
9 | | - if( !is_numeric( $id ) ) { |
10 | | - $wgOut->addWikiMsg( 'removerestrictions-noid' ); |
11 | | - return; |
12 | | - } |
13 | | - |
14 | | - UserRestriction::purgeExpired(); |
15 | | - $r = UserRestriction::newFromId( $id, true ); |
16 | | - if( !$r ) { |
17 | | - $wgOut->addWikiMsg( 'removerestrictions-wrongid' ); |
18 | | - return; |
19 | | - } |
20 | | - |
21 | | - $form = array(); |
22 | | - $form['removerestrictions-user'] = $sk->userLink( $r->getSubjectId(), $r->getSubjectText() ) . |
23 | | - $sk->userToolLinks( $r->getSubjectId(), $r->getSubjectText() ); |
24 | | - $form['removerestrictions-type'] = UserRestriction::formatType( $r->getType() ); |
25 | | - if( $r->isPage() ) |
26 | | - $form['removerestrictions-page'] = $sk->link( $r->getPage() ); |
27 | | - if( $r->isNamespace() ) |
28 | | - $form['removerestrictions-namespace'] = $wgLang->getDisplayNsText( $r->getNamespace() ); |
29 | | - $form['removerestrictions-reason'] = Xml::input( 'reason' ); |
30 | | - |
31 | | - $result = null; |
32 | | - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'edittoken' ) ) ) |
33 | | - $result = wfSpecialRemoveRestrictionsProcess( $r ); |
34 | | - |
35 | | - $wgOut->addWikiMsg( 'removerestrictions-intro' ); |
36 | | - $wgOut->addHTML( Xml::fieldset( wfMsgHtml( 'removerestrictions-legend' ) ) ); |
37 | | - if( $result ) |
38 | | - $wgOut->addHTML( '<strong class="success">' . wfMsgExt( 'removerestrictions-success', |
39 | | - 'parseinline', $r->getSubjectText() ) . '</strong>' ); |
40 | | - $wgOut->addHTML( Xml::openElement( 'form', array( 'action' => $title->getLocalUrl( array( 'id' => $id ) ), |
41 | | - 'method' => 'post' ) ) ); |
42 | | - $wgOut->addHTML( Xml::buildForm( $form, 'removerestrictions-submit' ) ); |
43 | | - $wgOut->addHTML( Xml::hidden( 'id', $r->getId() ) ); |
44 | | - $wgOut->addHTML( Xml::hidden( 'title', $title->getPrefixedDbKey() ) ); |
45 | | - $wgOut->addHTML( Xml::hidden( 'edittoken', $wgUser->editToken() ) ); |
46 | | - $wgOut->addHTML( "</form></fieldset>" ); |
47 | | -} |
48 | | - |
49 | | -function wfSpecialRemoveRestrictionsProcess( $r ) { |
50 | | - global $wgRequest; |
51 | | - $reason = $wgRequest->getVal( 'reason' ); |
52 | | - $result = $r->delete(); |
53 | | - $log = new LogPage( 'restrict' ); |
54 | | - $params = array( $r->getType() ); |
55 | | - if( $r->isPage() ) |
56 | | - $params[] = $r->getPage()->getPrefixedDbKey(); |
57 | | - if( $r->isNamespace() ) |
58 | | - $params[] = $r->getNamespace(); |
59 | | - $log->addEntry( 'remove', Title::makeTitle( NS_USER, $r->getSubjectText() ), $reason, $params ); |
60 | | - return $result; |
61 | | -} |