Exemplo n.º 1
0
 protected function saveContent()
 {
     global $wgLogRestrictions;
     $dbw = wfGetDB(DB_MASTER);
     $log_id = $dbw->nextSequenceValue('logging_log_id_seq');
     $this->timestamp = $now = wfTimestampNow();
     $data = array('log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $this->doer->getId(), 'log_user_text' => $this->doer->getName(), 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_page' => $this->target->getArticleId(), 'log_comment' => $this->comment, 'log_params' => $this->params);
     $dbw->insert('logging', $data, __METHOD__);
     $newId = !is_null($log_id) ? $log_id : $dbw->insertId();
     # And update recentchanges
     if ($this->updateRecentChanges) {
         $titleObj = SpecialPage::getTitleFor('Log', $this->type);
         RecentChange::notifyLog($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
     } else {
         if ($this->sendToUDP) {
             # Don't send private logs to UDP
             if (isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] != '*') {
                 return true;
             }
             # Notify external application via UDP.
             # We send this to IRC but do not want to add it the RC table.
             $titleObj = SpecialPage::getTitleFor('Log', $this->type);
             $rc = RecentChange::newLogEntry($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
             $rc->notifyRC2UDP();
         }
     }
     return $newId;
 }
Exemplo n.º 2
0
 /**
  * Get a RecentChanges object for the log entry
  * @param int $newId
  * @return RecentChange
  * @since 1.23
  */
 public function getRecentChange($newId = 0)
 {
     $formatter = LogFormatter::newFromEntry($this);
     $context = RequestContext::newExtraneousContext($this->getTarget());
     $formatter->setContext($context);
     $logpage = SpecialPage::getTitleFor('Log', $this->getType());
     $user = $this->getPerformer();
     $ip = "";
     if ($user->isAnon()) {
         /*
          * "MediaWiki default" and friends may have
          * no IP address in their name
          */
         if (IP::isIPAddress($user->getName())) {
             $ip = $user->getName();
         }
     }
     return RecentChange::newLogEntry($this->getTimestamp(), $logpage, $user, $formatter->getPlainActionText(), $ip, $this->getType(), $this->getSubtype(), $this->getTarget(), $this->getComment(), LogEntryBase::makeParamBlob($this->getParameters()), $newId, $formatter->getIRCActionComment());
 }
Exemplo n.º 3
0
 /**
  * Publishes the log entry.
  * @param int $newId id of the log entry.
  * @param string $to rcandudp (default), rc, udp
  */
 public function publish($newId, $to = 'rcandudp')
 {
     $log = new LogPage($this->getType());
     if ($log->isRestricted()) {
         return;
     }
     $formatter = LogFormatter::newFromEntry($this);
     $context = RequestContext::newExtraneousContext($this->getTarget());
     $formatter->setContext($context);
     $logpage = SpecialPage::getTitleFor('Log', $this->getType());
     $user = $this->getPerformer();
     $ip = "";
     if ($user->isAnon()) {
         /*
          * "MediaWiki default" and friends may have
          * no IP address in their name
          */
         if (IP::isIPAddress($user->getName())) {
             $ip = $user->getName();
         }
     }
     $rc = RecentChange::newLogEntry($this->getTimestamp(), $logpage, $user, $formatter->getPlainActionText(), $ip, $this->getType(), $this->getSubtype(), $this->getTarget(), $this->getComment(), serialize((array) $this->getParameters()), $newId, $formatter->getIRCActionComment());
     if ($to === 'rc' || $to === 'rcandudp') {
         $rc->save('pleasedontudp');
     }
     if ($to === 'udp' || $to === 'rcandudp') {
         $rc->notifyRC2UDP();
     }
 }
Exemplo n.º 4
0
 /**
  * Publishes the log entry.
  * @param $newId int id of the log entry.
  * @param $to string: rcandudp (default), rc, udp
  */
 public function publish($newId, $to = 'rcandudp')
 {
     $log = new LogPage($this->getType());
     if ($log->isRestricted()) {
         return;
     }
     $formatter = LogFormatter::newFromEntry($this);
     $context = RequestContext::newExtraneousContext($this->getTarget());
     $formatter->setContext($context);
     $logpage = SpecialPage::getTitleFor('Log', $this->getType());
     $user = $this->getPerformer();
     $rc = RecentChange::newLogEntry($this->getTimestamp(), $logpage, $user, $formatter->getPlainActionText(), $user->isAnon() ? $user->getName() : '', $this->getType(), $this->getSubtype(), $this->getTarget(), $this->getComment(), serialize((array) $this->getParameters()), $newId, $formatter->getIRCActionComment());
     if ($to === 'rc' || $to === 'rcandudp') {
         $rc->save('pleasedontudp');
     }
     if ($to === 'udp' || $to === 'rcandudp') {
         $rc->notifyRC2UDP();
     }
 }