Esempio n. 1
0
 /**
  * @param EchoEvent $event
  * @param $param
  * @param Message $message
  * @param User $user
  */
 protected function processParam($event, $param, $message, $user)
 {
     if ($param === 'content-page') {
         if ($event->getTitle()) {
             $message->params($event->getTitle()->getSubjectPage()->getPrefixedText());
         } else {
             $message->params('');
         }
     } elseif ($param === 'subject-link') {
         $this->setTitleLink($event, $message);
         // The title text without namespace
     } elseif ($param === 'main-title-text') {
         if (!$event->getTitle()) {
             $message->params($this->getMessage('echo-no-title')->text());
         } else {
             $message->params($event->getTitle()->getText());
         }
     } else {
         parent::processParam($event, $param, $message, $user);
     }
 }
 /**
  * Get subscribers for the echo notifications
  * @param EchoEvent $event
  * @param type $users
  * @return boolean
  */
 public function onEchoGetDefaultNotifiedUsers($event, &$users)
 {
     $aTmpUsers = array_unique(array_merge(BsConfig::getUsersForVar($this->aEchoPrefix['web'] . $event->getType() . '-cat', '1', false, false), BsConfig::getUsersForVar($this->aEchoPrefix['email'] . $event->getType() . '-cat', '1', false, false)));
     foreach ($aTmpUsers as $index => $user) {
         if (!$user->getOption('MW::Notifications::Active', false)) {
             continue;
         }
         if ($event->getTitle() instanceof Title) {
             if (!$event->getTitle()->userCan('read', $user)) {
                 continue;
             }
             if (is_array($user->getOption('MW::Notifications::NotifyNS', array()))) {
                 if (!in_array($event->getTitle()->getNamespace(), $user->getOption('MW::Notifications::NotifyNS', array()))) {
                     continue;
                 }
             }
         }
         if ($event->getAgent() instanceof User) {
             if ($event->getAgent()->getRequest()->getVal('wpMinoredit', false) && $user->getOption('MW::Notifications::NotifyNoMinor', false)) {
                 continue;
             }
         }
         $users[] = $user;
     }
     return true;
 }
 /**
  * Helper function for getLink()
  *
  * @param EchoEvent $event
  * @param User $user The user receiving the notification
  * @param String $destination The destination type for the link
  * @return Array including target and query parameters
  */
 protected function getLinkParams($event, $user, $destination)
 {
     $target = null;
     $query = array();
     // Set up link parameters based on the destination (or pass to parent)
     switch ($destination) {
         case 'link-from-page':
             if ($this->bundleData['use-bundle']) {
                 if ($event->getTitle()) {
                     $target = SpecialPage::getTitleFor('WhatLinksHere', $event->getTitle()->getPrefixedText());
                 }
             } else {
                 $extra = self::extractExtra($event->getExtra());
                 if ($this->isTitleSet($extra)) {
                     $target = Title::newFromId($extra['link-from-page-id']);
                 }
             }
             break;
         default:
             return parent::getLinkParams($event, $user, $destination);
     }
     return array($target, $query);
 }
Esempio n. 4
0
 /**
  * Helper function for getLink()
  *
  * @param EchoEvent $event
  * @param User $user The user receiving the notification
  * @param String $destination The destination type for the link, e.g. 'agent'
  * @return Array including target and query parameters
  */
 protected function getLinkParams($event, $user, $destination)
 {
     $target = null;
     $query = array();
     // Set up link parameters based on the destination
     switch ($destination) {
         case 'agent':
             if ($event->getAgent()) {
                 $target = $event->getAgent()->getUserPage();
             }
             break;
         case 'title':
             $target = $event->getTitle();
             break;
         case 'section':
             $target = $event->getTitle();
             if ($target) {
                 $fragment = $this->formatSubjectAnchor($event);
                 if ($fragment) {
                     $target->setFragment("#{$fragment}");
                 }
             }
             break;
         case 'diff':
             $eventData = $event->getExtra();
             if (isset($eventData['revid']) && $event->getTitle()) {
                 $target = $event->getTitle();
                 // Explicitly set fragment to empty string for diff links, $title is
                 // passed around by reference, it may end up using fragment set from
                 // other parameters
                 $target->setFragment('#');
                 $query = array('oldid' => 'prev', 'diff' => $eventData['revid']);
                 if ($event->getBundleHash()) {
                     // First try cache data from preivous query
                     if (isset($this->bundleData['last-raw-data'])) {
                         $stat = $this->bundleData['last-raw-data'];
                         // Then try to query the storage
                     } else {
                         global $wgEchoBackend;
                         $stat = $wgEchoBackend->getRawBundleData($user, $event->getBundleHash(), $this->distributionType, 'ASC', 1);
                         if ($stat) {
                             $stat = $stat->current();
                         }
                     }
                     if ($stat) {
                         $extra = $stat->event_extra ? unserialize($stat->event_extra) : array();
                         if (isset($extra['revid'])) {
                             $oldId = $target->getPreviousRevisionID($extra['revid']);
                             // The diff engine doesn't provide a way to diff against a null revision.
                             // In this case, just fall back old id to the first revision
                             if (!$oldId) {
                                 $oldId = $extra['revid'];
                             }
                             if ($oldId < $eventData['revid']) {
                                 $query['oldid'] = $oldId;
                             }
                         }
                     }
                 }
             }
             break;
     }
     return array($target, $query);
 }