MediaWiki
REL1_19
|
00001 <?php 00028 class RollbackAction extends FormlessAction { 00029 00030 public function getName() { 00031 return 'rollback'; 00032 } 00033 00034 public function getRestriction() { 00035 return 'rollback'; 00036 } 00037 00038 public function onView() { 00039 $details = null; 00040 00041 $request = $this->getRequest(); 00042 00043 $result = $this->page->doRollback( 00044 $request->getVal( 'from' ), 00045 $request->getText( 'summary' ), 00046 $request->getVal( 'token' ), 00047 $request->getBool( 'bot' ), 00048 $details, 00049 $this->getUser() 00050 ); 00051 00052 if ( in_array( array( 'actionthrottledtext' ), $result ) ) { 00053 throw new ThrottledError; 00054 } 00055 00056 if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { 00057 $this->getOutput()->setPageTitle( $this->msg( 'rollbackfailed' ) ); 00058 $errArray = $result[0]; 00059 $errMsg = array_shift( $errArray ); 00060 $this->getOutput()->addWikiMsgArray( $errMsg, $errArray ); 00061 00062 if ( isset( $details['current'] ) ) { 00063 $current = $details['current']; 00064 00065 if ( $current->getComment() != '' ) { 00066 $this->getOutput()->addHTML( wfMessage( 'editcomment' )->rawParams( 00067 Linker::formatComment( $current->getComment() ) )->parse() ); 00068 } 00069 } 00070 00071 return; 00072 } 00073 00074 # Display permissions errors before read-only message -- there's no 00075 # point in misleading the user into thinking the inability to rollback 00076 # is only temporary. 00077 if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) { 00078 # array_diff is completely broken for arrays of arrays, sigh. 00079 # Remove any 'readonlytext' error manually. 00080 $out = array(); 00081 foreach ( $result as $error ) { 00082 if ( $error != array( 'readonlytext' ) ) { 00083 $out [] = $error; 00084 } 00085 } 00086 throw new PermissionsError( 'rollback', $out ); 00087 } 00088 00089 if ( $result == array( array( 'readonlytext' ) ) ) { 00090 throw new ReadOnlyError; 00091 } 00092 00093 $current = $details['current']; 00094 $target = $details['target']; 00095 $newId = $details['newid']; 00096 $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) ); 00097 $this->getOutput()->setRobotPolicy( 'noindex,nofollow' ); 00098 00099 if ( $current->getUserText() === '' ) { 00100 $old = wfMsg( 'rev-deleted-user' ); 00101 } else { 00102 $old = Linker::userLink( $current->getUser(), $current->getUserText() ) 00103 . Linker::userToolLinks( $current->getUser(), $current->getUserText() ); 00104 } 00105 00106 $new = Linker::userLink( $target->getUser(), $target->getUserText() ) 00107 . Linker::userToolLinks( $target->getUser(), $target->getUserText() ); 00108 $this->getOutput()->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); 00109 $this->getOutput()->returnToMain( false, $this->getTitle() ); 00110 00111 if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) { 00112 $de = new DifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true ); 00113 $de->showDiff( '', '' ); 00114 } 00115 } 00116 00117 protected function getDescription() { 00118 return ''; 00119 } 00120 }