messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities') ); } $this->target = $target; $this->namespace = $namespace; $this->mDb = wfGetDB( DB_SLAVE, 'contributions' ); } function getDefaultQuery() { $query = parent::getDefaultQuery(); $query['target'] = $this->target; return $query; } function getQueryInfo() { global $wgUser; list( $index, $userCond ) = $this->getUserCond(); $conds = array_merge( $userCond, $this->getNamespaceCond() ); // Paranoia: avoid brute force searches (bug 17792) if( !$wgUser->isAllowed( 'deletedhistory' ) ) { $conds[] = $this->mDb->bitAnd('ar_deleted',Revision::DELETED_USER) . ' = 0'; } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) { $conds[] = $this->mDb->bitAnd('ar_deleted',Revision::SUPPRESSED_USER) . ' != ' . Revision::SUPPRESSED_USER; } return array( 'tables' => array( 'archive' ), 'fields' => array( 'ar_rev_id', 'ar_namespace', 'ar_title', 'ar_timestamp', 'ar_comment', 'ar_minor_edit', 'ar_user', 'ar_user_text', 'ar_deleted' ), 'conds' => $conds, 'options' => array( 'USE INDEX' => $index ) ); } function getUserCond() { $condition = array(); $condition['ar_user_text'] = $this->target; $index = 'usertext_timestamp'; return array( $index, $condition ); } function getIndexField() { return 'ar_timestamp'; } function getStartBody() { return "
' . $pager->getNavigationBar() . '
' . $pager->getBody() . '' . $pager->getNavigationBar() . '
' ); # If there were contributions, and it was a valid user or IP, show # the appropriate "footer" message - WHOIS tools, etc. if( $target != 'newbies' ) { $message = IP::isIPAddress( $target ) ? 'sp-contributions-footer-anon' : 'sp-contributions-footer'; $text = wfMsgNoTrans( $message, $target ); if( !wfEmptyMsg( $message, $text ) && $text != '-' ) { $wgOut->wrapWikiMsg( " ", array( $message, $target ) ); } } } /** * Generates the subheading with links * @param $nt Title object for the target * @param $id Integer: User ID for the target * @return String: appropriately-escaped HTML to be output literally * @todo Fixme: almost the same as contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle( $nt, $id ) { global $wgSysopUserBans, $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); if ( $id === null ) { $user = htmlspecialchars( $nt->getText() ); } else { $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); } $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false ); $talk = $nt->getTalkPage(); if( $talk ) { # Talk page link $tools[] = $sk->link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); if( ( $id !== null && $wgSysopUserBans ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { if( $wgUser->isAllowed( 'block' ) ) { # Block / Change block / Unblock links if ( $userObj->isBlocked() ) { $tools[] = $sk->linkKnown( # Change block link SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'change-blocklink' ) ); $tools[] = $sk->linkKnown( # Unblock link SpecialPage::getTitleFor( 'BlockList' ), wfMsgHtml( 'unblocklink' ), array(), array( 'action' => 'unblock', 'ip' => $nt->getDBkey() ) ); } else { # User is not blocked $tools[] = $sk->linkKnown( # Block link SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); } } # Block log link $tools[] = $sk->linkKnown( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'sp-contributions-blocklog' ), array(), array( 'type' => 'block', 'page' => $nt->getPrefixedText() ) ); } # Other logs link $tools[] = $sk->linkKnown( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'sp-contributions-logs' ), array(), array( 'user' => $nt->getText() ) ); # Link to contributions $tools[] = $sk->linkKnown( SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ), wfMsgHtml( 'sp-deletedcontributions-contribs' ) ); # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); if( $id !== null && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) { $tools[] = $sk->linkKnown( SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), wfMsgHtml( 'sp-contributions-userrights' ) ); } wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); $links = $wgLang->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. if ( $userObj->isBlocked() ) { LogEventsList::showLogExtract( $wgOut, 'block', $nt->getPrefixedText(), '', array( 'lim' => 1, 'showIfEmpty' => false, 'msgKey' => array( 'sp-contributions-blocked-notice', $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice' ), 'offset' => '' # don't use $wgRequest parameter offset ) ); } } // Old message 'contribsub' had one parameter, but that doesn't work for // languages that want to put the "for" bit right after $user but before // $links. If 'contribsub' is around, use it for reverse compatibility, // otherwise use 'contribsub2'. if( wfEmptyMsg( 'contribsub', wfMsg( 'contribsub' ) ) ) { return wfMsgHtml( 'contribsub2', $user, $links ); } else { return wfMsgHtml( 'contribsub', "$user ($links)" ); } } /** * Generates the namespace selector form with hidden attributes. * @param $options Array: the options to be included. */ function getForm( $options ) { global $wgScript; $options['title'] = SpecialPage::getTitleFor( 'DeletedContributions' )->getPrefixedText(); if ( !isset( $options['target'] ) ) { $options['target'] = ''; } else { $options['target'] = str_replace( '_' , ' ' , $options['target'] ); } if ( !isset( $options['namespace'] ) ) { $options['namespace'] = ''; } if ( !isset( $options['contribs'] ) ) { $options['contribs'] = 'user'; } if ( $options['contribs'] == 'newbie' ) { $options['target'] = ''; } $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); foreach ( $options as $name => $value ) { if ( in_array( $name, array( 'namespace', 'target', 'contribs' ) ) ) { continue; } $f .= "\t" . Html::hidden( $name, $value ) . "\n"; } $f .= Xml::openElement( 'fieldset' ) . Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) . Xml::tags( 'label', array( 'for' => 'target' ), wfMsgExt( 'sp-contributions-username', 'parseinline' ) ) . ' ' . Html::input( 'target', $options['target'], 'text', array( 'size' => '20', 'required' => '' ) + ( $options['target'] ? array() : array( 'autofocus' ) ) ) . ' '. Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' . Xml::namespaceSelector( $options['namespace'], '' ) . ' ' . Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) . Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ); return $f; } }