<?php if (!defined('VB_ENTRY')) die('Access denied.'); class vB_Notification_Moderator_SpamPost extends vB_Notification_Moderator { const TYPENAME = 'SpamPost'; protected static $triggers = [ 'node-spam-post' => 20, ]; protected $notifyBitfieldName = 'spampost'; protected $emailBitfieldName = 'spampost'; protected function overwriteRule() { return 'always'; } final protected static function defineUnique($notificationData, $skipValidation) { $items = []; $items['senderid'] = (int) $notificationData['sender']; $items['sentbynodeid'] = (int) $notificationData['sentbynodeid']; return $items; } public static function fetchPhraseArray($notificationData) { $senderUrl = ''; try { $senderUrl = vB5_Route::buildUrl('profile|fullurl', [ 'userid' => $notificationData['senderid'], 'username' => $notificationData['sender_username'], ]); } catch (Throwable $e){} $nodeUrl = ''; try { $nodeUrl = vB5_Route::buildUrl('node|fullurl', [ 'nodeid' => $notificationData['sentbynodeid'] ]); } catch (Throwable $e){} $userid = $notificationData['sender']; $phraseVarName = 'a_post_by_ab_in_cd_has_been_identified_as_spam'; $phraseData = [ $senderUrl, $notificationData['sender_musername'], $nodeUrl, $notificationData['aboutstartertitle'], $userid, ]; return [ $phraseVarName, $phraseData, ]; } public static function renderEmailPhrases($data) { $assertor = vB::getDbAssertor(); $nodeUrl = ''; try { $nodeUrl = vB5_Route::buildUrl('node|fullurl', [ 'nodeid' => $data['sentbynodeid'] ]); } catch (Throwable $e){} $title = ''; if (!empty($data['aboutstartertitle'])) { $title = $data['aboutstartertitle']; } else if (!empty($data['sentbynodeid'])) { $node = $assertor->getRow('vBForum:node', ['nodeid' => $data['sentbynodeid']]); if (!empty($node['title'])) { $title = $node['title']; } else { $node = $assertor->getRow('vBForum:node', ['nodeid' => $node['starter']]); if (!empty($node['title'])) { $title = $node['title']; } } } $string = vB::getString(); $node = vB_Library::instance('node')->getNodeFullContent($data['sentbynodeid']); $node = $node[$data['sentbynodeid']]; $preview = vB_Mail::getPreviewTextForEmail($node['rawtext'], $node['htmlstate'] ?? 'off', $string); $preview = vB_Mail::wrapPreviewTextForEmail($preview, $data['languageid']); $vboptions = vB::getDatastore()->getValue('options'); $bbtitle_escaped = $string->htmlspecialchars($vboptions['bbtitle']); $maildata = vB_Api::instanceInternal('phrase')->fetchEmailPhrases( 'notification_spampost', [ $string->htmlspecialchars($data['recipient_displayname']), $nodeUrl, $preview, $bbtitle_escaped, ], [vB_String::unHtmlSpecialChars($title)], $data['languageid'] ); return $maildata; } } 