<?php if (!defined('VB_ENTRY')) die('Access denied.'); class vB_Notification_Content_GroupByStarter_Reply extends vB_Notification_Content_GroupByStarter { protected static $triggers = array( 'new-content' => 5, ); const TYPENAME = 'Reply'; const FCM_SUPPORTED = true; protected function addAdditionalRecipients() { $nodeid = $this->notificationData['sentbynodeid']; $node = vB_Library::instance('node')->getNodeBare($nodeid); if ($node['parentid'] == $node['starter']) { $starter = vB_Library::instance('node')->getNodeBare($node['starter']); if (!empty($starter['userid']) AND $starter['userid'] != $this->notificationData['sender']) { return array($starter['userid']); } } return array(); } protected function typeEnabledForUser($user) { static $bf_masks; if (empty($bf_masks)) { $bf_masks = vB::getDatastore()->getValue('bf_misc_usernotificationoptions'); } return ((bool) ($user['notification_options'] & $bf_masks['discussions_on'])); } public static function fetchPhraseArray($notificationData) { $nodelink = vB5_Route::buildUrl('node|fullurl', array('nodeid' => $notificationData['sentbynodeid'])); $phraseTitle = "missing phrase for " . __CLASS__; $phraseData = array(); if (empty($notificationData['sender']) OR is_null($notificationData['sender_username'])) { switch ($notificationData['otherParticipantsCount']) { case 0: $phraseTitle = 'guest_replied_to_z'; $phraseData = array( $nodelink, $notificationData['aboutstartertitle'] ); break; case 1: $phraseTitle = 'guest_and_one_other_replied_to_z'; $phraseData = array( $notificationData['sentbynodeid'], $nodelink, $notificationData['aboutstartertitle'] ); break; default: $phraseTitle = 'guest_and_y_others_replied_to_z'; $phraseData = array( $notificationData['sentbynodeid'], $notificationData['otherParticipantsCount'], $nodelink, $notificationData['aboutstartertitle'] ); break; } } else { $userid = $notificationData['sender']; $username = $notificationData['sender_username']; $userInfo = array('userid' => $userid, 'username' => $username); try { $userProfileUrl = vB5_Route::buildUrl('profile|fullurl', $userInfo); } catch (Exception $e) { $userProfileUrl = "#"; } switch ($notificationData['otherParticipantsCount']) { case 0: $phraseTitle = 'x_replied_to_z'; $phraseData = array( $userProfileUrl, $userid, $notificationData['sender_musername'], $nodelink, $notificationData['aboutstartertitle'] ); break; case 1: $phraseTitle = 'x_and_one_other_replied_to_z'; $phraseData = array( $userProfileUrl, $userid, $notificationData['sender_musername'], $notificationData['sentbynodeid'], $nodelink, $notificationData['aboutstartertitle'] ); break; default: $phraseTitle = 'x_and_y_others_replied_to_z'; $phraseData = array( $userProfileUrl, $userid, $notificationData['sender_musername'], $notificationData['sentbynodeid'], $notificationData['otherParticipantsCount'], $nodelink, $notificationData['aboutstartertitle'] ); break; } } return array($phraseTitle, $phraseData); } public static function getFCMExtraData($data, $languageids) { if (empty($data['sentbynodeid'])) { return array(); } $nodeLib = vB_Library::instance('node'); $node = $nodeLib->getNode($data['sentbynodeid']); if (empty($node['starter'])) { return array(); } if ($node['starter'] == $node['nodeid']) { $starter = $node; } else { $starter = $nodeLib->getNode($node['starter']); } if (empty($starter['title'])) { return array(); } $phraseApi = vB_Api::instanceInternal('phrase'); $phraseid = 'fcm_replied_to_y'; $phraseArgs = array($starter['title']); $return = array(); $data = array( 'INTENT_EXTRA_THREAD_ID' => $node['starter'], 'INTENT_EXTRA_POST_ID' => $node['nodeid'], ); foreach ($languageids AS $__langid) { $__phrase = $phraseApi->fetch($phraseid, $__langid); $__phrase = $__phrase[$phraseid]; $__renderedPhrase = vsprintf($__phrase, $phraseArgs); $return[$__langid] = array( 'title' => $node['authorname'], 'body' => $__renderedPhrase, 'click_action' => vB_Library_FCMessaging::CLICK_ACTION_THREAD, 'data' => $data, ); } return $return; } } 