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); }
/** * @param $signature string * @param $alldata array * @param $form HTMLForm * @return string */ static function cleanSignature( $signature, $alldata, $form ) { if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) { global $wgParser; $signature = $wgParser->cleanSig( $signature ); } else { // When no fancy sig used, make sure ~{3,5} get removed. $signature = Parser::cleanSigInSig( $signature ); } return $signature; }
/** * cleanSigInSig() just removes tildes * @dataProvider provideStringsForCleanSigInSig */ function testCleanSigInSig($in, $out) { $this->assertEquals(Parser::cleanSigInSig($in), $out); }
/** * Determines the contents of the welcome message. * * @since MediaWiki 1.19.4 * @internal */ public function setMessage() { $welcomeMessageKey = 'welcome-message-'; // Determine the proper key // // Is Message Wall enabled? $welcomeMessageKey .= $this->getMessageWallExtensionEnabled() ? 'wall-' : ''; // Is recipient a registered user? $welcomeMessageKey .= $this->recipientId ? 'user' : 'anon'; // Is sender a staff member and not a local admin? $senderGroups = $this->senderObject->getEffectiveGroups(); if ((in_array('staff', $senderGroups) || in_array('helper', $senderGroups)) && !in_array('sysop', $senderGroups)) { $welcomeMessageKey .= '-staff'; } $sPrefixedText = $this->title->getPrefixedText(); // Article Comments and Message Wall hook up to this event. wfRunHooks('HAWelcomeGetPrefixText', array(&$sPrefixedText, $this->title)); // Determine the key for the signature. $sSignatureKey = in_array('staff', $senderGroups) && !in_array('sysop', $senderGroups) ? 'staffsig-text' : 'signature'; // Determine the full signature. $sFullSignature = $this->getTextVersionOfMessage($sSignatureKey, [$this->senderObject->getName(), Parser::cleanSigInSig($this->senderObject->getName())]); // Append the timestamp to the signature. $sFullSignature .= ' ~~~~~'; // Put the contents of the welcome message together. // Messages that can be used here: // * welcome-message-user // * welcome-message-user-staff // * welcome-message-anon // * welcome-message-anon-staff // * welcome-message-wall-user // * welcome-message-wall-user-staff // * welcome-message-wall-anon // * welcome-message-wall-anon-staff $this->welcomeMessage = $this->getPlainVersionOfMessage($welcomeMessageKey, [$sPrefixedText, $this->senderObject->getUserPage()->getTalkPage()->getPrefixedText(), $sFullSignature, wfEscapeWikiText($this->recipientName)]); }