Beispiel #1
0
 /**
  * Set page title and show header for this log type
  * @param $type String
  */
 public function showHeader($type)
 {
     if (LogPage::isLogType($type)) {
         $this->out->setPageTitle(LogPage::logName($type));
         $this->out->addHTML(LogPage::logHeader($type));
     }
 }
Beispiel #2
0
 public function execute($par)
 {
     global $wgLogRestrictions;
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('type', '');
     $opts->add('user', '');
     $opts->add('page', '');
     $opts->add('pattern', false);
     //		$opts->add( 'year', null, FormOptions::INTNULL ); don't default to zero
     $opts->add('year', '');
     $opts->add('month', null, FormOptions::INTNULL);
     $opts->add('tagfilter', '');
     $opts->add('offset', '');
     $opts->add('dir', '');
     $opts->add('offender', '');
     // Set values
     $opts->fetchValuesFromRequest($this->getRequest());
     if ($par !== null) {
         $this->parseParams($opts, (string) $par);
     }
     # Don't let the user get stuck with a certain date
     if ($opts->getValue('offset') || $opts->getValue('dir') == 'prev') {
         $opts->setValue('year', '');
         $opts->setValue('month', '');
     }
     // If the user doesn't have the right permission to view the specific
     // log type, throw a PermissionsError
     // If the log type is invalid, just show all public logs
     $type = $opts->getValue('type');
     if (!LogPage::isLogType($type)) {
         $opts->setValue('type', '');
     } elseif (isset($wgLogRestrictions[$type]) && !$this->getUser()->isAllowed($wgLogRestrictions[$type])) {
         throw new PermissionsError($wgLogRestrictions[$type]);
     }
     # Handle type-specific inputs
     $qc = array();
     if ($opts->getValue('type') == 'suppress') {
         $offender = User::newFromName($opts->getValue('offender'), false);
         if ($offender && $offender->getId() > 0) {
             $qc = array('ls_field' => 'target_author_id', 'ls_value' => $offender->getId());
         } elseif ($offender && IP::isIPAddress($offender->getName())) {
             $qc = array('ls_field' => 'target_author_ip', 'ls_value' => $offender->getName());
         }
     }
     # Some log types are only for a 'User:'******'User:username'. This part try
     # to lookup for a user by that name and eventually fix user input. See bug 1697.
     wfRunHooks('GetLogTypesOnUser', array(&$this->typeOnUser));
     if (in_array($opts->getValue('type'), $this->typeOnUser)) {
         # ok we have a type of log which expect a user title.
         $target = Title::newFromText($opts->getValue('page'));
         if ($target && $target->getNamespace() === NS_MAIN) {
             # User forgot to add 'User:'******'page', Title::makeTitleSafe(NS_USER, $opts->getValue('page')));
         }
     }
     $this->show($opts, $qc);
 }
Beispiel #3
0
 /**
  * Set page title and show header for this log type
  * @param $type Array
  */
 public function showHeader($type)
 {
     // If only one log type is used, then show a special message...
     $headerType = count($type) == 1 ? $type[0] : '';
     if (LogPage::isLogType($headerType)) {
         $this->out->setPageTitle(LogPage::logName($headerType));
         $this->out->addHTML(LogPage::logHeader($headerType));
     } else {
         $this->out->addHTML(wfMsgExt('alllogstext', array('parseinline')));
     }
 }
Beispiel #4
0
	/**
	 * Set page title and show header for this log type
	 * @param $type Array
	 * @deprecated in 1.19
	 */
	public function showHeader( $type ) {
		wfDeprecated( __METHOD__, '1.19' );
		// If only one log type is used, then show a special message...
		$headerType = count( $type ) == 1 ? $type[0] : '';
		$out = $this->getOutput();
		if ( LogPage::isLogType( $headerType ) ) {
			$page = new LogPage( $headerType );
			$out->setPageTitle( $page->getName()->text() );
			$out->addHTML( $page->getDescription()->parseAsBlock() );
		} else {
			$out->addHTML( $this->msg( 'alllogstext' )->parse() );
		}
	}
 /**
  * @param OutputPage &$out where to send output
  * @private
  */
 function showHeader(&$out)
 {
     $type = $this->reader->queryType();
     if (LogPage::isLogType($type)) {
         $out->setPageTitle(LogPage::logName($type));
         $out->addWikiText(LogPage::logHeader($type));
     }
 }
 /**
  * @todo Move this to AbstractBlock and use for summary/header/etc.
  * @param AbstractRevision $revision
  * @return Message
  */
 protected function getDisallowedErrorMessage(AbstractRevision $revision)
 {
     if (in_array($this->action, array('moderate-topic', 'moderate-post'))) {
         /*
          * When failing to moderate an already moderated action (like
          * undo), show the more general "you have insufficient
          * permissions for this action" message, rather than the
          * specialized "this topic is <hidden|deleted|suppressed>" msg.
          */
         return $this->context->msg('flow-error-not-allowed');
     }
     $state = $revision->getModerationState();
     // display simple message
     // i18n messages:
     //  flow-error-not-allowed-hide,
     //  flow-error-not-allowed-reply-to-hide-topic
     //  flow-error-not-allowed-delete
     //  flow-error-not-allowed-reply-to-delete-topic
     //  flow-error-not-allowed-suppress
     //  flow-error-not-allowed-reply-to-suppress-topic
     if ($revision instanceof PostRevision) {
         $type = $revision->isTopicTitle() ? 'topic' : 'post';
     } else {
         $type = $revision->getRevisionType();
     }
     // Show a snippet of the relevant log entry if available.
     if (\LogPage::isLogType($state)) {
         // check if user has sufficient permissions to see log
         $logPage = new \LogPage($state);
         if ($this->context->getUser()->isAllowed($logPage->getRestriction())) {
             // LogEventsList::showLogExtract will write to OutputPage, but we
             // actually just want that text, to write it ourselves wherever we want,
             // so let's create an OutputPage object to then get the content from.
             $rc = new \RequestContext();
             $output = $rc->getOutput();
             // get log extract
             $entries = \LogEventsList::showLogExtract($output, array($state), $this->workflow->getArticleTitle()->getPrefixedText(), '', array('lim' => 10, 'showIfEmpty' => false, 'msgKey' => array(array("flow-error-not-allowed-{$this->action}-to-{$state}-{$type}", "flow-error-not-allowed-{$state}-extract"))));
             // check if there were any log extracts
             if ($entries) {
                 $message = new \RawMessage('$1');
                 return $message->rawParams($output->getHTML());
             }
         }
     }
     return $this->context->msg(array("flow-error-not-allowed-{$this->action}-to-{$state}-{$type}", "flow-error-not-allowed-{$state}", "flow-error-not-allowed"));
 }