getOutput(); $request = $this->getRequest(); AbuseFilter::addNavigationLinks( $this->getContext(), 'log' ); $this->setHeaders(); $this->outputHeader( 'abusefilter-log-summary' ); $this->loadParameters(); $out->setPageTitle( $this->msg( 'abusefilter-log' ) ); $out->setRobotPolicy( "noindex,nofollow" ); $out->setArticleRelated( false ); $out->enableClientCache( false ); $out->addModuleStyles( 'ext.abuseFilter' ); // Are we allowed? $errors = $this->getTitle()->getUserPermissionsErrors( 'abusefilter-log', $this->getUser(), true, array( 'ns-specialprotected' ) ); if ( count( $errors ) ) { // Go away. $out->showPermissionsErrorPage( $errors, 'abusefilter-log' ); return; } $detailsid = $request->getIntOrNull( 'details' ); $hideid = $request->getIntOrNull( 'hide' ); if ( $parameter ) { $detailsid = $parameter; } if ( $detailsid ) { $this->showDetails( $detailsid ); } elseif ( $hideid ) { $this->showHideForm( $hideid ); } else { // Show the search form. $this->searchForm(); // Show the log itself. $this->showList(); } } function loadParameters() { $request = $this->getRequest(); $this->mSearchUser = $request->getText( 'wpSearchUser' ); $t = Title::newFromText( trim( $this->mSearchUser ) ); if ( $t ) { $this->mSearchUser = $t->getText(); // Username normalisation } else { $this->mSearchUser = null; } $this->mSearchTitle = $request->getText( 'wpSearchTitle' ); $this->mSearchFilter = null; if ( self::canSeeDetails() ) { $this->mSearchFilter = $request->getIntOrNull( 'wpSearchFilter' ); } } function searchForm() { $output = Xml::element( 'legend', null, wfMsg( 'abusefilter-log-search' ) ); $fields = array(); // Search conditions $fields['abusefilter-log-search-user'] = Xml::input( 'wpSearchUser', 45, $this->mSearchUser ); if ( self::canSeeDetails() ) { $fields['abusefilter-log-search-filter'] = Xml::input( 'wpSearchFilter', 45, $this->mSearchFilter ); } $fields['abusefilter-log-search-title'] = Xml::input( 'wpSearchTitle', 45, $this->mSearchTitle ); $form = Html::hidden( 'title', $this->getTitle()->getPrefixedText() ); $form .= Xml::buildForm( $fields, 'abusefilter-log-search-submit' ); $output .= Xml::tags( 'form', array( 'method' => 'get', 'action' => $this->getTitle()->getLocalURL() ), $form ); $output = Xml::tags( 'fieldset', null, $output ); $this->getOutput()->addHTML( $output ); } /** * @param $id * @return mixed */ function showHideForm( $id ) { if ( !$this->getUser()->isAllowed( 'abusefilter-hide-log' ) ) { $this->getOutput()->addWikiMsg( 'abusefilter-log-hide-forbidden' ); return; } $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( array( 'abuse_filter_log', 'abuse_filter' ), '*', array( 'afl_id' => $id ), __METHOD__, array(), array( 'abuse_filter' => array( 'LEFT JOIN', 'af_id=afl_filter' ) ) ); if ( !$row ) { return; } $formInfo = array( 'logid' => array( 'type' => 'info', 'default' => $id, 'label-message' => 'abusefilter-log-hide-id', ), 'reason' => array( 'type' => 'text', 'label-message' => 'abusefilter-log-hide-reason', ), 'hidden' => array( 'type' => 'toggle', 'default' => $row->afl_deleted, 'label-message' => 'abusefilter-log-hide-hidden', ), ); $form = new HTMLForm( $formInfo, $this->getContext() ); $form->setTitle( $this->getTitle() ); $form->setWrapperLegend( wfMsgExt( 'abusefilter-log-hide-legend', 'parsemag' ) ); $form->addHiddenField( 'hide', $id ); $form->setSubmitCallback( array( $this, 'saveHideForm' ) ); $form->show(); } /** * @param $fields * @return bool */ function saveHideForm( $fields ) { $logid = $this->getRequest()->getVal( 'hide' ); $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'abuse_filter_log', array( 'afl_deleted' => $fields['hidden'] ), array( 'afl_id' => $logid ), __METHOD__ ); $logPage = new LogPage( 'suppress' ); $action = $fields['hidden'] ? 'hide-afl' : 'unhide-afl'; $logPage->addEntry( $action, $this->getTitle( $logid ), $fields['reason'] ); $this->getOutput()->redirect( SpecialPage::getTitleFor( 'AbuseLog' )->getFullURL() ); return true; } function showList() { $out = $this->getOutput(); // Generate conditions list. $conds = array(); if ( $this->mSearchUser ) { $user = User::newFromName( $this->mSearchUser ); if ( !$user ) { $conds[] = 'afl_ip=afl_user_text'; $conds['afl_user'] = 0; $conds['afl_user_text'] = $this->mSearchUser; } else { $conds['afl_user'] = $user->getId(); $conds['afl_user_text'] = $user->getName(); } } if ( $this->mSearchFilter ) { // if the filter is hidden, users who can't view private filters should not be able to find log entries generated by it if ( !AbuseFilter::filterHidden( $this->mSearchFilter ) || AbuseFilterView::canViewPrivate() || $this->getUser()->isAllowed( 'abusefilter-log-private' ) ) { $conds['afl_filter'] = $this->mSearchFilter; } } $searchTitle = Title::newFromText( $this->mSearchTitle ); if ( $this->mSearchTitle && $searchTitle ) { $conds['afl_namespace'] = $searchTitle->getNamespace(); $conds['afl_title'] = $searchTitle->getDBkey(); } $pager = new AbuseLogPager( $this, $conds ); $pager->doQuery(); $result = $pager->getResult(); if( $result && $result->numRows() !== 0 ) { $out->addHTML( $pager->getNavigationBar() . Xml::tags( 'ul', null, $pager->getBody() ) . $pager->getNavigationBar() ); } else { $out->addWikiMsg( 'abusefilter-log-noresults' ); } } /** * @param $id * @return mixed */ function showDetails( $id ) { $out = $this->getOutput(); $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( array( 'abuse_filter_log', 'abuse_filter' ), '*', array( 'afl_id' => $id ), __METHOD__, array(), array( 'abuse_filter' => array( 'LEFT JOIN', 'af_id=afl_filter' ) ) ); if ( !$row ) { return; } if ( AbuseFilter::decodeGlobalName( $row->afl_filter ) ) { $filter_hidden = null; } else { $filter_hidden = $row->af_hidden; } if ( !self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) { $out->addWikiMsg( 'abusefilter-log-cannot-see-details' ); return; } if ( $row->afl_deleted && !self::canSeeHidden() ) { $out->addWikiMsg( 'abusefilter-log-details-hidden' ); return; } $output = ''; $output .= Xml::element( 'legend', null, wfMsg( 'abusefilter-log-details-legend', $id ) ); $output .= Xml::tags( 'p', null, $this->formatRow( $row, false ) ); // Load data $vars = AbuseFilter::loadVarDump( $row->afl_var_dump ); // Diff, if available if ( $vars->getVar( 'action' )->toString() == 'edit' ) { $old_wikitext = $vars->getVar( 'old_wikitext' )->toString(); $new_wikitext = $vars->getVar( 'new_wikitext' )->toString(); $diffEngine = new DifferenceEngine; $diffEngine->showDiffStyle(); $formattedDiff = $diffEngine->generateDiffBody( $old_wikitext, $new_wikitext ); static $colDescriptions = "