http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70690

Revision: 70690
Author:   demon
Date:     2010-08-08 13:04:56 +0000 (Sun, 08 Aug 2010)

Log Message:
-----------
Remove per-user restriction special pages. Never enabled and removed in 1.16 as 
well

Removed Paths:
-------------
    branches/REL1_15/phase3/includes/specials/SpecialListUserRestrictions.php
    branches/REL1_15/phase3/includes/specials/SpecialRemoveRestrictions.php
    branches/REL1_15/phase3/includes/specials/SpecialRestrictUser.php

Deleted: 
branches/REL1_15/phase3/includes/specials/SpecialListUserRestrictions.php
===================================================================
--- branches/REL1_15/phase3/includes/specials/SpecialListUserRestrictions.php   
2010-08-08 13:03:43 UTC (rev 70689)
+++ branches/REL1_15/phase3/includes/specials/SpecialListUserRestrictions.php   
2010-08-08 13:04:56 UTC (rev 70690)
@@ -1,162 +0,0 @@
-<?php
-
-function wfSpecialListUserRestrictions() {
-       global $wgOut, $wgRequest;
-       
-       $wgOut->addWikiMsg( 'listuserrestrictions-intro' );
-       $f = new SpecialListUserRestrictionsForm();
-       $wgOut->addHTML( $f->getHTML() );
-
-       if( !mt_rand( 0, 10 ) )
-               UserRestriction::purgeExpired();
-       $pager = new UserRestrictionsPager( $f->getConds() );
-       if( $pager->getNumRows() ) 
-               $wgOut->addHTML( $pager->getNavigationBar() .
-                       Xml::tags( 'ul', null, $pager->getBody() ) .
-                       $pager->getNavigationBar()
-               );
-       elseif( $f->getConds() )
-               $wgOut->addWikiMsg( 'listuserrestrictions-notfound' );
-       else 
-               $wgOut->addWikiMsg( 'listuserrestrictions-empty' );
-}
-
-class SpecialListUserRestrictionsForm {
-       public function getHTML() {
-               global $wgRequest, $wgScript, $wgTitle;
-               $action = htmlspecialchars( $wgScript );
-               $s = '';
-               $s .= Xml::fieldset( wfMsg( 'listuserrestrictions-legend' ) );
-               $s .= "<form action=\"{$action}\">";
-               $s .= Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() );
-               $s .= Xml::label( wfMsgHtml( 'listuserrestrictions-type' ), 
'type' ) . '&nbsp;' .
-                       self::typeSelector( 'type', $wgRequest->getVal( 'type' 
), 'type' );
-               $s .= '&nbsp;';
-               $s .= Xml::inputLabel( wfMsgHtml( 'listuserrestrictions-user' 
), 'user', 'user',
-                       false, $wgRequest->getVal( 'user' ) );
-               $s .= '<p>';
-               $s .= Xml::label( wfMsgHtml( 'listuserrestrictions-namespace' 
), 'namespace' ) . '&nbsp;' .
-                       Xml::namespaceSelector( $wgRequest->getVal( 'namespace' 
), '', 'namespace' );
-               $s .= '&nbsp;';
-               $s .= Xml::inputLabel( wfMsgHtml( 'listuserrestrictions-page' 
), 'page', 'page',
-                       false, $wgRequest->getVal( 'page' ) );
-               $s .= Xml::submitButton( wfMsg( 'listuserrestrictions-submit' ) 
);
-               $s .= "</p></form></fieldset>";
-               return $s;
-       }
-
-       public static function typeSelector( $name = 'type', $value = '', $id = 
false ) {
-               $s = new XmlSelect( $name, $id, $value );
-               $s->addOption( wfMsg( 'userrestrictiontype-none' ), '' );
-               $s->addOption( wfMsg( 'userrestrictiontype-page' ), 
UserRestriction::PAGE );
-               $s->addOption( wfMsg( 'userrestrictiontype-namespace' ), 
UserRestriction::NAMESPACE );
-               return $s->getHTML();
-       }
-
-       public function getConds() {
-               global $wgRequest;
-               $conds = array();
-
-               $type = $wgRequest->getVal( 'type' );
-               if( in_array( $type, array( UserRestriction::PAGE, 
UserRestriction::NAMESPACE ) ) )
-                       $conds['ur_type'] = $type;
-
-               $user = $wgRequest->getVal( 'user' );
-               if( $user )
-                       $conds['ur_user_text'] = $user;
-
-               $namespace = $wgRequest->getVal( 'namespace' );
-               if( $namespace || $namespace === '0' )
-                       $conds['ur_namespace'] = $namespace;
-
-               $page = $wgRequest->getVal( 'page' );
-               $title = Title::newFromText( $page );
-               if( $title ) {
-                       $conds['ur_page_namespace'] = $title->getNamespace();
-                       $conds['ur_page_title'] = $title->getDBKey();
-               }
-
-               return $conds;
-       }
-}
-
-class UserRestrictionsPager extends ReverseChronologicalPager {
-       public $mConds;
-
-       public function __construct( $conds = array() ) {
-               $this->mConds = $conds;
-               parent::__construct();
-       }
-
-       public function getStartBody() {
-               # Copied from Special:Ipblocklist
-               wfProfileIn( __METHOD__ );
-               # Do a link batch query
-               $this->mResult->seek( 0 );
-               $lb = new LinkBatch;
-
-               # Faster way
-               # Usernames and titles are in fact related by a simple 
substitution of space -> underscore
-               # The last few lines of Title::secureAndSplit() tell the story.
-               foreach( $this->mResult as $row ) {
-                       $name = str_replace( ' ', '_', $row->ur_by_text );
-                       $lb->add( NS_USER, $name );
-                       $lb->add( NS_USER_TALK, $name );
-                       $name = str_replace( ' ', '_', $row->ur_user_text );
-                       $lb->add( NS_USER, $name );
-                       $lb->add( NS_USER_TALK, $name );
-                       if( $row->ur_type == UserRestriction::PAGE )
-                               $lb->add( $row->ur_page_namespace, 
$row->ur_page_title );
-               }
-               $lb->execute();
-               wfProfileOut( __METHOD__ );
-               return '';
-       }
-
-       public function getQueryInfo() {
-               return array(
-                       'tables' => 'user_restrictions',
-                       'fields' => '*',
-                       'conds' => $this->mConds,
-               );
-       }
-
-       public function formatRow( $row ) {
-               return self::formatRestriction( UserRestriction::newFromRow( 
$row )  );
-       }
-
-       // Split off for use on Special:RestrictUser
-       public static function formatRestriction( $r ) {
-               global $wgUser, $wgLang;
-               $sk = $wgUser->getSkin();
-               $timestamp = $wgLang->timeanddate( $r->getTimestamp(), true );
-               $blockerlink = $sk->userLink( $r->getBlockerId(), 
$r->getBlockerText() ) .
-                       $sk->userToolLinks( $r->getBlockerId(), 
$r->getBlockerText() );
-               $subjlink = $sk->userLink( $r->getSubjectId(), 
$r->getSubjectText() ) .
-                       $sk->userToolLinks( $r->getSubjectId(), 
$r->getSubjectText() );
-               $expiry = is_numeric( $r->getExpiry() ) ?
-                       wfMsg( 'listuserrestrictions-row-expiry', 
$wgLang->timeanddate( $r->getExpiry() ) ) :
-                       wfMsg( 'ipbinfinite' );
-               $msg = '';
-               if( $r->isNamespace() ) {
-                       $msg = wfMsgHtml( 'listuserrestrictions-row-ns', 
$subjlink,
-                               $wgLang->getDisplayNsText( $r->getNamespace() 
), $expiry );
-               }
-               if( $r->isPage() ) {
-                       $pagelink = $sk->link( $r->getPage() );
-                       $msg = wfMsgHtml( 'listuserrestrictions-row-page', 
$subjlink,
-                               $pagelink, $expiry );
-               }
-               $reason = $sk->commentBlock( $r->getReason() );
-               $removelink = '';
-               if( $wgUser->isAllowed( 'restrict' ) ) {
-                       $removelink = '(' . $sk->link( 
SpecialPage::getTitleFor( 'RemoveRestrictions' ),
-                               wfMsgHtml( 'listuserrestrictions-remove' ), 
array(), array( 'id' => $r->getId() ) ) . ')';
-               }
-               return "<li>{$timestamp}, {$blockerlink} {$msg} {$reason} 
{$removelink}</li>\n";
-       }
-
-       public function getIndexField() {
-               return 'ur_timestamp';
-       }
-}

Deleted: branches/REL1_15/phase3/includes/specials/SpecialRemoveRestrictions.php
===================================================================
--- branches/REL1_15/phase3/includes/specials/SpecialRemoveRestrictions.php     
2010-08-08 13:03:43 UTC (rev 70689)
+++ branches/REL1_15/phase3/includes/specials/SpecialRemoveRestrictions.php     
2010-08-08 13:04:56 UTC (rev 70690)
@@ -1,60 +0,0 @@
-<?php
-
-function wfSpecialRemoveRestrictions() {
-       global $wgOut, $wgRequest, $wgUser, $wgLang, $wgTitle;
-       $sk = $wgUser->getSkin();
-
-       $id = $wgRequest->getVal( 'id' );
-       if( !is_numeric( $id ) ) {
-               $wgOut->addWikiMsg( 'removerestrictions-noid' );
-               return;
-       }
-
-       UserRestriction::purgeExpired();
-       $r = UserRestriction::newFromId( $id, true );
-       if( !$r ) {
-               $wgOut->addWikiMsg( 'removerestrictions-wrongid' );
-               return;
-       }
-
-       $form = array();
-       $form['removerestrictions-user'] = $sk->userLink( $r->getSubjectId(), 
$r->getSubjectText() ) .
-               $sk->userToolLinks( $r->getSubjectId(), $r->getSubjectText() );
-       $form['removerestrictions-type'] = UserRestriction::formatType( 
$r->getType() );
-       if( $r->isPage() )
-               $form['removerestrictions-page'] = $sk->link( $r->getPage() );
-       if( $r->isNamespace() )
-               $form['removerestrictions-namespace'] = 
$wgLang->getDisplayNsText( $r->getNamespace() );
-       $form['removerestrictions-reason'] = Xml::input( 'reason' );
-
-       $result = null;
-       if( $wgRequest->wasPosted() && $wgUser->matchEditToken( 
$wgRequest->getVal( 'edittoken' ) ) )
-               $result = wfSpecialRemoveRestrictionsProcess( $r );
-
-       $wgOut->addWikiMsg( 'removerestrictions-intro' );
-       $wgOut->addHTML( Xml::fieldset( wfMsgHtml( 'removerestrictions-legend' 
) ) );
-       if( $result )
-               $wgOut->addHTML( '<strong class="success">' . wfMsgExt( 
'removerestrictions-success',
-                       'parseinline', $r->getSubjectText() ) . '</strong>' );
-       $wgOut->addHTML( Xml::openElement( 'form', array( 'action' => 
$wgTitle->getLocalUrl( array( 'id' => $id ) ),
-               'method' => 'post' ) ) );
-       $wgOut->addHTML( Xml::buildForm( $form, 'removerestrictions-submit' ) );
-       $wgOut->addHTML( Xml::hidden( 'id', $r->getId() ) );
-       $wgOut->addHTML( Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() ) );
-       $wgOut->addHTML( Xml::hidden( 'edittoken', $wgUser->editToken() ) );
-       $wgOut->addHTML( "</form></fieldset>" );
-}
-
-function wfSpecialRemoveRestrictionsProcess( $r ) {
-       global $wgUser, $wgRequest;
-       $reason = $wgRequest->getVal( 'reason' );
-       $result = $r->delete();
-       $log = new LogPage( 'restrict' );
-       $params = array( $r->getType() );
-       if( $r->isPage() )
-               $params[] = $r->getPage()->getPrefixedDbKey();
-       if( $r->isNamespace() )
-               $params[] = $r->getNamespace();
-       $log->addEntry( 'remove', Title::makeTitle( NS_USER, 
$r->getSubjectText() ), $reason, $params );
-       return $result;
-}

Deleted: branches/REL1_15/phase3/includes/specials/SpecialRestrictUser.php
===================================================================
--- branches/REL1_15/phase3/includes/specials/SpecialRestrictUser.php   
2010-08-08 13:03:43 UTC (rev 70689)
+++ branches/REL1_15/phase3/includes/specials/SpecialRestrictUser.php   
2010-08-08 13:04:56 UTC (rev 70690)
@@ -1,190 +0,0 @@
-<?php
-
-function wfSpecialRestrictUser( $par = null ) {
-       global $wgOut, $wgRequest;
-       $user = $userOrig = null;
-       if( $par ) {
-               $userOrig = $par;
-       } elseif( $wgRequest->getVal( 'user' ) ) {
-               $userOrig = $wgRequest->getVal( 'user' );
-       } else {
-               $wgOut->addHTML( RestrictUserForm::selectUserForm() );
-               return;
-       }
-       $isIP = User::isIP( $userOrig );
-       $user = $isIP ? $userOrig : User::getCanonicalName( $userOrig );
-       $uid = User::idFromName( $user );
-       if( !$uid && !$isIP ) {
-               $err = '<strong class="error">' . wfMsgHtml( 
'restrictuser-notfound' ) . '</strong>';
-               $wgOut->addHTML( RestrictUserForm::selectUserForm( $userOrig, 
$err ) );
-               return;
-       }
-       $wgOut->addHTML( RestrictUserForm::selectUserForm( $user ) );
-
-       UserRestriction::purgeExpired();
-       $old = UserRestriction::fetchForUser( $user, true );
-
-       RestrictUserForm::pageRestrictionForm( $uid, $user, $old );
-       RestrictUserForm::namespaceRestrictionForm( $uid, $user, $old );
-
-       // Renew it after possible changes in previous two functions
-       $old = UserRestriction::fetchForUser( $user, true );
-       if( $old ) {
-               $wgOut->addHTML( RestrictUserForm::existingRestrictions( $old ) 
);
-       }
-}
-
-class RestrictUserForm {
-       public static function selectUserForm( $val = null, $error = null ) {
-               global $wgScript, $wgTitle;
-               $action = htmlspecialchars( $wgScript );
-               $s  = Xml::fieldset( wfMsg( 'restrictuser-userselect' ) ) . 
"<form action=\"{$action}\">";
-               if( $error )
-                       $s .= '<p>' . $error . '</p>';
-               $s .= Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() );
-               $form = array( 'restrictuser-user' => Xml::input( 'user', 
false, $val ) );
-               $s .= Xml::buildForm( $form, 'restrictuser-go' );
-               $s .= "</form></fieldset>";
-               return $s;
-       }
-
-       public static function existingRestrictions( $restrictions ) {
-               //TODO: autoload?
-               require_once( dirname( __FILE__ ) . 
'/SpecialListUserRestrictions.php' );
-               $s  = Xml::fieldset( wfMsg( 'restrictuser-existing' ) ) . 
'<ul>';
-               foreach( $restrictions as $r )
-                       $s .= UserRestrictionsPager::formatRestriction( $r );
-               $s .= "</ul></fieldset>";
-               return $s;
-       }
-
-       public static function pageRestrictionForm( $uid, $user, 
$oldRestrictions ) {
-               global $wgOut, $wgTitle, $wgRequest, $wgUser;
-               $error = '';
-               $success = false;
-               if( $wgRequest->wasPosted() && $wgRequest->getVal( 'type' ) == 
UserRestriction::PAGE &&
-                       $wgUser->matchEditToken( $wgRequest->getVal( 
'edittoken' ) ) ) {
-
-                       $title = Title::newFromText( $wgRequest->getVal( 'page' 
) );
-                       if( !$title ) {
-                               $error = array( 'restrictuser-badtitle', 
$wgRequest->getVal( 'page' ) );
-                       } elseif( UserRestriction::convertExpiry( 
$wgRequest->getVal( 'expiry' ) ) === false ) {
-                               $error = array( 'restrictuser-badexpiry', 
$wgRequest->getVal( 'expiry' ) );
-                       } else {
-                               foreach( $oldRestrictions as $r ) {
-                                       if( $r->isPage() && 
$r->getPage()->equals( $title ) )
-                                               $error = array( 
'restrictuser-duptitle' );
-                               }
-                       }
-                       if( !$error ) {
-                               self::doPageRestriction( $uid, $user );
-                               $success = array('restrictuser-success', $user);
-                       }
-               }
-               $useRequestValues = $wgRequest->getVal( 'type' ) == 
UserRestriction::PAGE;
-               $wgOut->addHTML( Xml::fieldset( wfMsg( 
'restrictuser-legend-page' ) ) );
-
-               self::printSuccessError( $success, $error );
-
-               $wgOut->addHTML( Xml::openElement( 'form', array( 'action' => 
$wgTitle->getLocalUrl(),
-                       'method' => 'post' ) ) );
-               $wgOut->addHTML( Xml::hidden( 'type', UserRestriction::PAGE ) );
-               $wgOut->addHTML( Xml::hidden( 'edittoken', $wgUser->editToken() 
) );
-               $wgOut->addHTML( Xml::hidden( 'user', $user ) );
-               $form = array();
-               $form['restrictuser-title'] = Xml::input( 'page', false,
-                       $useRequestValues ? $wgRequest->getVal( 'page' ) : 
false );
-               $form['restrictuser-expiry'] = Xml::input( 'expiry', false,
-                       $useRequestValues ? $wgRequest->getVal( 'expiry' ) : 
false );
-               $form['restrictuser-reason'] = Xml::input( 'reason', false,
-                       $useRequestValues ? $wgRequest->getVal( 'reason' ) : 
false );
-               $wgOut->addHTML( Xml::buildForm( $form, 'restrictuser-submit' ) 
);
-               $wgOut->addHTML( "</form></fieldset>" );
-       }
-
-       public static function printSuccessError( $success, $error ) {
-               global $wgOut;
-               if ( $error )
-                       $wgOut->wrapWikiMsg( '<strong 
class="error">$1</strong>', $error );
-               if ( $success )
-                       $wgOut->wrapWikiMsg( '<strong 
class="success">$1</strong>', $success );
-       }
-
-       public static function doPageRestriction( $uid, $user ) {
-               global $wgUser, $wgRequest;
-               $r = new UserRestriction();
-               $r->setType( UserRestriction::PAGE );
-               $r->setPage( Title::newFromText( $wgRequest->getVal( 'page' ) ) 
);
-               $r->setSubjectId( $uid );
-               $r->setSubjectText( $user );
-               $r->setBlockerId( $wgUser->getId() );
-               $r->setBlockerText( $wgUser->getName() );
-               $r->setReason( $wgRequest->getVal( 'reason' ) );
-               $r->setExpiry( UserRestriction::convertExpiry( 
$wgRequest->getVal( 'expiry' ) ) );
-               $r->setTimestamp( wfTimestampNow( TS_MW ) );
-               $r->commit();
-               $logExpiry = $wgRequest->getVal( 'expiry' ) ? 
$wgRequest->getVal( 'expiry' ) : Block::infinity();
-               $l = new LogPage( 'restrict' );
-               $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), 
$r->getReason(),
-                       array( $r->getType(), $r->getPage()->getFullText(), 
$logExpiry) );
-       }
-
-       public static function namespaceRestrictionForm( $uid, $user, 
$oldRestrictions ) {
-               global $wgOut, $wgTitle, $wgRequest, $wgUser, $wgContLang;
-               $error = '';
-               $success = false;
-               if( $wgRequest->wasPosted() && $wgRequest->getVal( 'type' ) == 
UserRestriction::NAMESPACE &&
-                       $wgUser->matchEditToken( $wgRequest->getVal( 
'edittoken' ) ) ) {
-                               $ns = $wgRequest->getVal( 'namespace' );
-                               if( $wgContLang->getNsText( $ns ) === false )
-                                       $error = wfMsgExt( 
'restrictuser-badnamespace', 'parseinline' );
-                               elseif( UserRestriction::convertExpiry( 
$wgRequest->getVal( 'expiry' ) ) === false )
-                                       $error = wfMsgExt( 
'restrictuser-badexpiry', 'parseinline', $wgRequest->getVal( 'expiry' ) );
-                               else 
-                                       foreach( $oldRestrictions as $r )
-                                               if( $r->isNamespace() && 
$r->getNamespace() == $ns )
-                                                       $error = wfMsgExt( 
'restrictuser-dupnamespace', 'parse' );
-                               if( !$error ) {
-                                       self::doNamespaceRestriction( $uid, 
$user );
-                                       $success = 
array('restrictuser-success', $user);
-                               }
-               }
-               $useRequestValues = $wgRequest->getVal( 'type' ) == 
UserRestriction::NAMESPACE;
-               $wgOut->addHTML( Xml::fieldset( wfMsg( 
'restrictuser-legend-namespace' ) ) );
-
-               self::printSuccessError( $success, $error );
-
-               $wgOut->addHTML( Xml::openElement( 'form', array( 'action' => 
$wgTitle->getLocalUrl(),
-                       'method' => 'post' ) ) );
-               $wgOut->addHTML( Xml::hidden( 'type', 
UserRestriction::NAMESPACE ) );
-               $wgOut->addHTML( Xml::hidden( 'edittoken', $wgUser->editToken() 
) );
-               $wgOut->addHTML( Xml::hidden( 'user', $user ) );
-               $form = array();
-               $form['restrictuser-namespace'] = Xml::namespaceSelector( 
$wgRequest->getVal( 'namespace' ) );
-               $form['restrictuser-expiry'] = Xml::input( 'expiry', false,
-                       $useRequestValues ? $wgRequest->getVal( 'expiry' ) : 
false );
-               $form['restrictuser-reason'] = Xml::input( 'reason', false,
-                       $useRequestValues ? $wgRequest->getVal( 'reason' ) : 
false );
-               $wgOut->addHTML( Xml::buildForm( $form, 'restrictuser-submit' ) 
);
-               $wgOut->addHTML( "</form></fieldset>" );
-       }
-
-       public static function doNamespaceRestriction( $uid, $user ) {
-               global $wgUser, $wgRequest;
-               $r = new UserRestriction();
-               $r->setType( UserRestriction::NAMESPACE );
-               $r->setNamespace( $wgRequest->getVal( 'namespace' ) );
-               $r->setSubjectId( $uid );
-               $r->setSubjectText( $user );
-               $r->setBlockerId( $wgUser->getId() );
-               $r->setBlockerText( $wgUser->getName() );
-               $r->setReason( $wgRequest->getVal( 'reason' ) );
-               $r->setExpiry( UserRestriction::convertExpiry( 
$wgRequest->getVal( 'expiry' ) ) );
-               $r->setTimestamp( wfTimestampNow( TS_MW ) );
-               $r->commit();
-               $logExpiry = $wgRequest->getVal( 'expiry' ) ? 
$wgRequest->getVal( 'expiry' ) : Block::infinity();
-               $l = new LogPage( 'restrict' );
-               $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), 
$r->getReason(),
-                       array( $r->getType(), $r->getNamespace(), $logExpiry ) 
);
-       }
-}



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to