public function onPostAdd(OW_Event $event) { $params = $event->getParams(); $userService = BOL_UserService::getInstance(); $userId = $params['userId']; $question = $this->service->findQuestion($params['questionId']); $post = UTIL_String::truncate($params['text'], 100, '...'); $postId = $params['id']; $ownerId = $question->userId; $questionUrl = OW::getRouter()->urlForRoute('equestions-question', array('qid' => $question->id)); $questionText = UTIL_String::truncate($question->text, 100, '...'); $notificationParams = array('pluginKey' => EQUESTIONS_Plugin::PLUGIN_KEY, 'action' => self::ACTION_POST, 'entityType' => 'questions-post', 'entityId' => $postId, 'userId' => null, 'time' => time()); $uniqId = uniqid('question_post'); $userAvatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId)); $userAvatar = $userAvatars[$userId]; $string = array('key' => EQUESTIONS_Plugin::PLUGIN_KEY . '+notifications_post', 'vars' => array('question' => '<a class="' . $uniqId . '" href="' . $questionUrl . '" >' . $questionText . '</a>', 'user' => '<a href="' . $userAvatar['url'] . '">' . $userAvatar['title'] . '</a>', 'post' => '<a class="' . $uniqId . '" href="' . $questionUrl . '" >' . $post . '</a>')); $questionSettings = array('userContext' => array((int) $userId), 'questionId' => $question->id, 'relationId' => $question->id); $notificationData = array('string' => $string, 'avatar' => $userAvatar, 'questionSettings' => $questionSettings, 'uniqId' => $uniqId, 'url' => $questionUrl); $follows = $this->service->findFollows($question->id, null, array($userId)); foreach ($follows as $f) { $notificationParams['userId'] = $f->userId; $event = new OW_Event('notifications.add', $notificationParams, $notificationData); OW::getEventManager()->trigger($event); } }