示例#1
0
 public function onBeforeAsk(OW_Event $event)
 {
     $params = $event->getParams();
     $question = EQUESTIONS_BOL_Service::getInstance()->findQuestion($params['questionId']);
     $data = array('question' => $question->text);
     $notification = new EQUESTIONS_BOL_Notification();
     $notification->userId = (int) $params['recipientId'];
     $notification->special = empty($params['special']) ? 0 : 1;
     $notification->senderId = (int) $params['userId'];
     $notification->type = EQUESTIONS_BOL_FeedService::ACTIVITY_ASK;
     $notification->questionId = (int) $params['questionId'];
     $notification->setData($data);
     $notification->timeStamp = time();
     $notification->viewed = false;
     $this->service->saveNotification($notification);
     $params = array('userId' => $notification->senderId, 'questionId' => $notification->questionId, 'recipientId' => $notification->userId, 'special' => $notification->special, 'id' => $notification->id);
     $event = new OW_Event(EQUESTIONS_BOL_Service::EVENT_QUESTION_ASKED, $params, $data);
     OW::getEventManager()->trigger($event);
 }