Example #1
0
 /**
  * Send emails corresponding to the user $editor editing the page $title.
  * Also updates wl_notificationtimestamp.
  *
  * May be deferred via the job queue.
  *
  * @param $editor User object
  * @param $title Title object
  * @param $timestamp
  * @param $summary
  * @param $minorEdit
  * @param $oldid (default: false)
  */
 public function notifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid = false)
 {
     global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker;
     if ($title->getNamespace() < 0) {
         return;
     }
     // Build a list of users to notfiy
     $watchers = array();
     if ($wgEnotifWatchlist || $wgShowUpdatedMarker) {
         $dbw = wfGetDB(DB_MASTER);
         $res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user != ' . intval($editor->getID()), 'wl_notificationtimestamp IS NULL'), __METHOD__);
         foreach ($res as $row) {
             $watchers[] = intval($row->wl_user);
         }
         if ($watchers) {
             // Update wl_notificationtimestamp for all watching users except
             // the editor
             $dbw->begin();
             $dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp($timestamp)), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user' => $watchers), __METHOD__);
             $dbw->commit();
         }
     }
     if ($wgEnotifUseJobQ) {
         $params = array("editor" => $editor->getName(), "editorID" => $editor->getID(), "timestamp" => $timestamp, "summary" => $summary, "minorEdit" => $minorEdit, "oldid" => $oldid, "watchers" => $watchers);
         $job = new EnotifNotifyJob($title, $params);
         $job->insert();
     } else {
         $this->actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers);
     }
 }
Example #2
0
 /**
  * Send emails corresponding to the user $editor editing the page $title.
  * Also updates wl_notificationtimestamp.
  *
  * May be deferred via the job queue.
  *
  * @param $editor User object
  * @param $title Title object
  * @param $timestamp
  * @param $summary
  * @param $minorEdit
  * @param $oldid (default: false)
  */
 public function notifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid = false)
 {
     global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifMinorEdits, $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk;
     if ($title->getNamespace() < 0) {
         return;
     }
     // Build a list of users to notfiy
     $watchers = array();
     if ($wgEnotifWatchlist || $wgShowUpdatedMarker) {
         $dbw = wfGetDB(DB_MASTER);
         $res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_user != ' . intval($editor->getID()), 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey(), 'wl_notificationtimestamp IS NULL'), __METHOD__);
         foreach ($res as $row) {
             $watchers[] = intval($row->wl_user);
         }
         if ($watchers) {
             // Update wl_notificationtimestamp for all watching users except the editor
             $fname = __METHOD__;
             $dbw->onTransactionIdle(function () use($dbw, $timestamp, $watchers, $title, $fname) {
                 $dbw->begin($fname);
                 $dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp($timestamp)), array('wl_user' => $watchers, 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey()), $fname);
                 $dbw->commit($fname);
             });
         }
     }
     $sendEmail = true;
     // If nobody is watching the page, and there are no users notified on all changes
     // don't bother creating a job/trying to send emails
     // $watchers deals with $wgEnotifWatchlist
     if (!count($watchers) && !count($wgUsersNotifiedOnAllChanges)) {
         $sendEmail = false;
         // Only send notification for non minor edits, unless $wgEnotifMinorEdits
         if (!$minorEdit || $wgEnotifMinorEdits && !$editor->isAllowed('nominornewtalk')) {
             $isUserTalkPage = $title->getNamespace() == NS_USER_TALK;
             if ($wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail($editor, $title, $minorEdit)) {
                 $sendEmail = true;
             }
         }
     }
     if (!$sendEmail) {
         return;
     }
     if ($wgEnotifUseJobQ) {
         $params = array('editor' => $editor->getName(), 'editorID' => $editor->getID(), 'timestamp' => $timestamp, 'summary' => $summary, 'minorEdit' => $minorEdit, 'oldid' => $oldid, 'watchers' => $watchers);
         $job = new EnotifNotifyJob($title, $params);
         $job->insert();
     } else {
         $this->actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers);
     }
 }
Example #3
0
 /**
  * Send emails corresponding to the user $editor editing the page $title.
  * Also updates wl_notificationtimestamp.
  *
  * May be deferred via the job queue.
  *
  * @param $editor User object
  * @param $title Title object
  * @param $timestamp
  * @param $summary
  * @param $minorEdit
  * @param $oldid (default: false)
  */
 function notifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid = false)
 {
     global $wgEnotifUseJobQ;
     if ($title->getNamespace() < 0) {
         return;
     }
     if ($wgEnotifUseJobQ) {
         $params = array("editor" => $editor->getName(), "editorID" => $editor->getID(), "timestamp" => $timestamp, "summary" => $summary, "minorEdit" => $minorEdit, "oldid" => $oldid);
         $job = new EnotifNotifyJob($title, $params);
         $job->insert();
     } else {
         $this->actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid);
     }
 }
Example #4
0
 /**
  * Send emails corresponding to the user $editor editing the page $title.
  * Also updates wl_notificationtimestamp.
  *
  * May be deferred via the job queue.
  *
  * @param $editor User object
  * @param $title Title object
  * @param $timestamp
  * @param $summary
  * @param $minorEdit
  * @param $oldid (default: false)
  * @param $action(Wikia)
  * @param $otherParam(Wikia)
  */
 public function notifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid = false, $action = '', $otherParam = array())
 {
     global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifMinorEdits, $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk;
     if ($title->getNamespace() < 0) {
         return;
     }
     # <Wikia>
     if (!wfRunHooks('AllowNotifyOnPageChange', array($editor, $title))) {
         return false;
     }
     if (!empty($otherParam['watchers'])) {
         $watchers = $otherParam['watchers'];
     }
     # </Wikia>
     // Build a list of users to notfiy
     $watchers = array();
     if ($wgEnotifWatchlist || $wgShowUpdatedMarker) {
         /* Wikia change begin - @author: wladek & tomek */
         /* RT#55604: Add a timeout to the watchlist email block */
         global $wgEnableWatchlistNotificationTimeout, $wgWatchlistNotificationTimeout;
         if (!empty($otherParam['notisnull'])) {
             $notificationTimeoutSql = "1";
         } elseif (!empty($wgEnableWatchlistNotificationTimeout) && isset($wgWatchlistNotificationTimeout)) {
             $blockTimeout = wfTimestamp(TS_MW, wfTimestamp(TS_UNIX, $timestamp) - intval($wgWatchlistNotificationTimeout));
             $notificationTimeoutSql = "wl_notificationtimestamp IS NULL OR wl_notificationtimestamp < '{$blockTimeout}'";
         } else {
             $notificationTimeoutSql = 'wl_notificationtimestamp IS NULL';
         }
         /* Wikia change end */
         $dbw = wfGetDB(DB_MASTER);
         $res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user != ' . intval($editor->getID()), $notificationTimeoutSql), __METHOD__);
         foreach ($res as $row) {
             $watchers[] = intval($row->wl_user);
         }
         if ($watchers) {
             // Update wl_notificationtimestamp for all watching users except
             // the editor
             $wl = WatchedItem::fromUserTitle($editor, $title);
             $wl->updateWatch($watchers, $timestamp);
         }
         /* Wikia change begin - @author: Jakub Kurcek */
         wfRunHooks('NotifyOnSubPageChange', array($watchers, $title, $editor, $notificationTimeoutSql));
         /* Wikia change end */
     }
     $sendEmail = true;
     // If nobody is watching the page, and there are no users notified on all changes
     // don't bother creating a job/trying to send emails
     // $watchers deals with $wgEnotifWatchlist
     if (!count($watchers) && !count($wgUsersNotifiedOnAllChanges)) {
         $sendEmail = false;
         // Only send notification for non minor edits, unless $wgEnotifMinorEdits
         if (!$minorEdit || $wgEnotifMinorEdits && !$editor->isAllowed('nominornewtalk')) {
             $isUserTalkPage = $title->getNamespace() == NS_USER_TALK;
             if ($wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail($editor, $title, $minorEdit)) {
                 $sendEmail = true;
             }
         }
     }
     if (!$sendEmail) {
         return;
     }
     if ($wgEnotifUseJobQ) {
         $params = array('editor' => $editor->getName(), 'editorID' => $editor->getID(), 'timestamp' => $timestamp, 'summary' => $summary, 'minorEdit' => $minorEdit, 'oldid' => $oldid, 'watchers' => $watchers, 'action' => $action, 'otherParam' => $othersParam);
         $job = new EnotifNotifyJob($title, $params);
         $job->insert();
     } else {
         $this->actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $action, $otherParam);
     }
 }