public function execute( $par ) { global $wgRequest, $wgUser, $wgOut; $this->setHeaders(); if( $wgUser->isAllowed( 'feedback' ) ) { if( $wgUser->isBlocked() ) { $wgOut->blockedPage(); return; } } else { $wgOut->permissionRequired( 'feedback' ); return; } if( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } $this->skin = $wgUser->getSkin(); $this->doPurge = ('purge' === $wgRequest->getVal( 'action' ) && $wgUser->isAllowed('purge')); # Our target page $this->target = $wgRequest->getText( 'target' ); $this->page = Title::newFromURL( $this->target ); # We need a page... if( is_null($this->page) ) { $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); return; } elseif( !ReaderFeedback::isPageRateable( $this->page ) ) { $wgOut->addHTML( wfMsgExt('readerfeedback-main',array('parse')) ); return; } # Thank people who voted... if( ReaderFeedbackPage::userAlreadyVoted( $this->page ) ) { $wgOut->setSubtitle( wfMsgExt('ratinghistory-thanks','parseinline') ); } $period = $wgRequest->getInt( 'period' ); $validPeriods = array(31,93,365,1095); if( !in_array($period,$validPeriods) ) { $period = 31; // default } $this->period = $period; $this->dScale = 20; $this->now = time(); // one time for whole request $this->showForm(); $this->showTable(); /* * Allow client caching. */ if( !$this->doPurge && $wgOut->checkLastModified( self::getTouched($this->page) ) ) { return; // Client cache fresh and headers sent, nothing more to do } else { $wgOut->enableClientCache( false ); // don't show stale graphs if( $this->doPurge ) $this->purgePage(); } $this->showGraphs(); }
public static function addFeedbackForm( &$data, $skin ) { global $wgOut; $title = $skin->getTitle(); if( $wgOut->isArticleRelated() ) { global $wgRequest, $wgUser; if( !$title->exists() || !ReaderFeedback::isPageRateable($title) || !$wgOut->getRevisionId() ) { return true; } # Check action and if page is protected $action = $wgRequest->getVal( 'action', 'view' ); if( !self::isViewAction($action) ) { return true; } if( $wgUser->isAllowed( 'feedback' ) ) { # Only allow votes on the latest revision! $id = $wgOut->getRevisionId(); if( $id != $title->getLatestRevID() ) { return true; } # If the user already voted, then don't show the form. # Always show for IPs however, due to squid caching... if( !$wgUser->getId() || !ReaderFeedbackPage::userAlreadyVoted( $title, $id ) ) { self::addQuickFeedback( $data, false, $title ); } } return true; } return true; }