static function notifyUsersByMail($t, $watching_users, $timestamp, $type) { $messages = array(Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-newthread'); $subjects = array(Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread'); if (!isset($messages[$type]) || !isset($subjects[$type])) { wfDebugLog('LiquidThreads', "Email notification failed: type {$type} unrecognised"); return; } else { $msgName = $messages[$type]; $subjectMsg = $subjects[$type]; } // Send email notification, fetching all the data in one go $dbr = wfGetDB(DB_SLAVE); $tables = array('user', 'tc_prop' => 'user_properties', 'l_prop' => 'user_properties'); $fields = array($dbr->tableName('user') . '.*', 'tc_prop.up_value AS timecorrection', 'l_prop.up_value as language'); $join_conds = array('tc_prop' => array('LEFT JOIN', array('tc_prop.up_user=user_id', 'tc_prop.up_property' => 'timecorrection')), 'l_prop' => array('LEFT JOIN', array('l_prop.up_user=user_id', 'l_prop.up_property' => 'language'))); $res = $dbr->select($tables, $fields, array('user_id' => $watching_users), __METHOD__, array(), $join_conds); // Set up one-time data. global $wgPasswordSender; $link_title = clone $t->getTitle(); $link_title->setFragment('#' . $t->getAnchorName()); $permalink = LqtView::linkInContextCanonicalURL($t); $talkPage = $t->getTitle()->getPrefixedText(); $from = new MailAddress($wgPasswordSender, 'WikiAdmin'); $threadSubject = $t->subject(); // Parse content and strip HTML of post content foreach ($res as $row) { $u = User::newFromRow($row); if ($row->language) { $langCode = $row->language; } else { global $wgLanguageCode; $langCode = $wgLanguageCode; } $lang = Language::factory($langCode); // Adjust with time correction $timeCorrection = $row->timecorrection; $adjustedTimestamp = $lang->userAdjust($timestamp, $timeCorrection); $date = $lang->date($adjustedTimestamp); $time = $lang->time($adjustedTimestamp); $params = array($u->getName(), $t->subjectWithoutIncrement(), $date, $time, $talkPage, $permalink, $t->root()->getContent(), $t->author()->getName()); // Get message in user's own language, bug 20645 $msg = wfMsgReal($msgName, $params, true, $langCode, true); $to = new MailAddress($u); $subject = wfMsgReal($subjectMsg, array($threadSubject), true, $langCode, true); UserMailer::send($to, $from, $subject, $msg); } }