messages[$msg] = $this->msg( $msg )->escaped(); } $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() { list( $index, $userCond ) = $this->getUserCond(); $conds = array_merge( $userCond, $this->getNamespaceCond() ); $user = $this->getUser(); // Paranoia: avoid brute force searches (bug 17792) if( !$user->isAllowed( 'deletedhistory' ) ) { $conds[] = $this->mDb->bitAnd( 'ar_deleted', Revision::DELETED_USER ) . ' = 0'; } elseif( !$user->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'; if( !$this->msg( $message )->isDisabled() ) { $out->wrapWikiMsg( " ", array( $message, $target ) ); } } } /** * Generates the subheading with links * @param $userObj User object 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( $userObj ) { if ( $userObj->isAnon() ) { $user = htmlspecialchars( $userObj->getName() ); } else { $user = Linker::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) ); } $links = ''; $nt = $userObj->getUserPage(); $id = $userObj->getID(); $talk = $nt->getTalkPage(); if( $talk ) { # Talk page link $tools[] = Linker::link( $talk, $this->msg( 'sp-contributions-talk' )->escaped() ); if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { if( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links if ( $userObj->isBlocked() ) { $tools[] = Linker::linkKnown( # Change block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), $this->msg( 'change-blocklink' )->escaped() ); $tools[] = Linker::linkKnown( # Unblock link SpecialPage::getTitleFor( 'BlockList' ), $this->msg( 'unblocklink' )->escaped(), array(), array( 'action' => 'unblock', 'ip' => $nt->getDBkey() ) ); } else { # User is not blocked $tools[] = Linker::linkKnown( # Block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), $this->msg( 'blocklink' )->escaped() ); } } # Block log link $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'sp-contributions-blocklog' )->escaped(), array(), array( 'type' => 'block', 'page' => $nt->getPrefixedText() ) ); } # Uploads $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Listfiles', $userObj->getName() ), $this->msg( 'sp-contributions-uploads' )->escaped() ); # Other logs link $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'sp-contributions-logs' )->escaped(), array(), array( 'user' => $nt->getText() ) ); # Link to contributions $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ), $this->msg( 'sp-deletedcontributions-contribs' )->escaped() ); # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext( $this->getContext() ); if( $userrightsPage->userCanChangeRights( $userObj ) ) { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), $this->msg( 'sp-contributions-userrights' )->escaped() ); } wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); $links = $this->getLanguage()->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. if ( $userObj->isBlocked() ) { $out = $this->getOutput(); // LogEventsList::showLogExtract() wants the first parameter by ref LogEventsList::showLogExtract( $out, 'block', $nt, '', array( 'lim' => 1, 'showIfEmpty' => false, 'msgKey' => array( 'sp-contributions-blocked-notice', $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice' ), 'offset' => '' # don't use $this->getRequest() 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'. $oldMsg = $this->msg( 'contribsub' ); if ( $oldMsg->exists() ) { return $oldMsg->rawParams( "$user ($links)" ); } else { return $this->msg( 'contribsub2' )->rawParams( $user, $links ); } } /** * Generates the namespace selector form with hidden attributes. * @param $options Array: the options to be included. * @return string */ function getForm( $options ) { global $wgScript; $options['title'] = $this->getTitle()->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(), $this->msg( 'sp-contributions-search' )->text() ) . Xml::tags( 'label', array( 'for' => 'target' ), $this->msg( 'sp-contributions-username' )->parse() ) . ' ' . Html::input( 'target', $options['target'], 'text', array( 'size' => '20', 'required' => '' ) + ( $options['target'] ? array() : array( 'autofocus' ) ) ) . ' '. Html::namespaceSelector( array( 'selected' => $options['namespace'], 'all' => '', 'label' => $this->msg( 'namespace' )->text() ), array( 'name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector', ) ) . ' ' . Xml::submitButton( $this->msg( 'sp-contributions-submit' )->text() ) . Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ); return $f; } }