MediaWiki
REL1_20
|
00001 <?php 00029 class RevisionDeleter { 00041 protected static function checkItem( $desc, $field, $diff, $new, &$arr ) { 00042 if( $diff & $field ) { 00043 $arr[ ( $new & $field ) ? 0 : 1 ][] = $desc; 00044 } 00045 } 00046 00065 public static function getChanges( $n, $o ) { 00066 $diff = $n ^ $o; 00067 $ret = array( 0 => array(), 1 => array(), 2 => array() ); 00068 // Build bitfield changes in language 00069 self::checkItem( 'revdelete-content', 00070 Revision::DELETED_TEXT, $diff, $n, $ret ); 00071 self::checkItem( 'revdelete-summary', 00072 Revision::DELETED_COMMENT, $diff, $n, $ret ); 00073 self::checkItem( 'revdelete-uname', 00074 Revision::DELETED_USER, $diff, $n, $ret ); 00075 // Restriction application to sysops 00076 if( $diff & Revision::DELETED_RESTRICTED ) { 00077 if( $n & Revision::DELETED_RESTRICTED ) 00078 $ret[2][] = 'revdelete-restricted'; 00079 else 00080 $ret[2][] = 'revdelete-unrestricted'; 00081 } 00082 return $ret; 00083 } 00084 00090 public static function getRelationType( $typeName ) { 00091 if ( isset( SpecialRevisionDelete::$deprecatedTypeMap[$typeName] ) ) { 00092 $typeName = SpecialRevisionDelete::$deprecatedTypeMap[$typeName]; 00093 } 00094 if ( isset( SpecialRevisionDelete::$allowedTypes[$typeName] ) ) { 00095 $class = SpecialRevisionDelete::$allowedTypes[$typeName]['list-class']; 00096 return call_user_func( array( $class, 'getRelationType' ) ); 00097 } else { 00098 return null; 00099 } 00100 } 00101 00111 public static function checkRevisionExistence( $title, $revid ) { 00112 $dbr = wfGetDB( DB_SLAVE ); 00113 $exists = $dbr->selectField( 'revision', '1', 00114 array( 'rev_id' => $revid ), __METHOD__ ); 00115 00116 if ( $exists ) { 00117 return true; 00118 } 00119 00120 $timestamp = $dbr->selectField( 'archive', 'ar_timestamp', 00121 array( 'ar_namespace' => $title->getNamespace(), 00122 'ar_title' => $title->getDBkey(), 00123 'ar_rev_id' => $revid ), __METHOD__ ); 00124 00125 return $timestamp; 00126 } 00127 }