/** * Immediate version of notifyOnRespond(). * * Send emails corresponding to the user $editor editing the page $title. * Also updates wl_notificationtimestamp. * * @param $editor User object * @param $title Title object * @param $timestamp string Edit timestamp * @param $response string response text * @param $feedabck integer feedback id * @param $type string moodbar type * @param $responseId int response id */ public function actuallyNotifyOnRespond($editor, $title, $timestamp, $feedback, $response, $type, $responseId) { global $wgEnotifUserTalk; wfProfileIn(__METHOD__); if ($title->getNamespace() != NS_USER_TALK) { return; } $this->title = $title; $this->timestamp = $timestamp; $this->editor = $editor; $this->composed_common = false; $this->response = $response; $this->feedback = $feedback; $this->type = $type; if ($wgEnotifUserTalk && $this->canSendUserTalkEmail($editor, $title)) { $this->compose($this->targetUser); //update to mark the email as 'sent' MBFeedbackResponseItem::update($responseId, array('mbfr_enotif_sent' => 1)); } wfProfileOut(__METHOD__); }
public function execute() { global $wgRequest, $wgUser; if ($wgUser->isAnon()) { $this->dieUsage("You don't have permission to do that", 'permission-denied'); } if ($wgUser->isBlocked(false)) { $this->dieUsageMsg(array('blockedtext')); } $params = $this->extractRequestParams(); //Response Object $item = MBFeedbackResponseItem::create(array()); $setParams = array(); foreach ($params as $key => $value) { if ($item->isValidKey($key)) { $setParams[$key] = $value; } } $item->setProperties($setParams); $item->save(); $commenter = $item->getProperty('feedbackitem')->getProperty('user'); if ($commenter !== null && $commenter->isAnon() == false) { $talkPage = $commenter->getTalkPage(); $response = Parser::cleanSigInSig($params['response']); $feedback_link = wfMessage('moodbar-feedback-response-title')->inContentLanguage()->params(SpecialPage::getTitleFor('FeedbackDashboard', $item->getProperty('feedback'))->getPrefixedText())->escaped(); $summary = wfMessage('moodbar-feedback-edit-summary')->inContentLanguage()->rawParams($item->getProperty('feedback'), $response)->escaped(); $this->disableUserTalkEmailNotification(); $id = intval($item->getProperty('id')); $api = new ApiMain(new FauxRequest(array('action' => 'edit', 'title' => $talkPage->getFullText(), 'appendtext' => ($talkPage->exists() ? "\n\n" : '') . $feedback_link . "\n" . '<span id="feedback-dashboard-response-' . $id . '"></span>' . "\n\n" . $response . "\n\n~~~~\n\n" . '<span class="markashelpful-mbresponse-' . $id . '"> </span>', 'token' => $params['token'], 'summary' => $summary, 'notminor' => true), true, array('wsEditToken' => $wgRequest->getSessionData('wsEditToken'))), true); $api->execute(); $this->restoreUserTalkEmailNotification(); global $wgLang; $EMailNotif = new MoodBarHTMLEmailNotification(); $EMailNotif->notifyOnRespond($wgUser, $talkPage, wfTimestampNow(), $item->getProperty('feedback'), $wgLang->truncate($response, 250), $item->getProperty('feedbackitem')->getProperty('type'), $id); } $result = array('result' => 'success'); $this->getResult()->addValue(null, $this->getModuleName(), $result); }