Exemple #1
0
 /**
  *
  * @param $userId
  * @param $question
  * @param $settings
  * @return EQUESTIONS_BOL_Question
  */
 public function addQuestion($userId, $text, $attachment = array(), $settings = array(), $privacy = EQUESTIONS_BOL_FeedService::PRIVACY_EVERYBODY)
 {
     $event = new OW_Event(self::EVENT_BEFORE_QUESTION_ADDED, array('text' => $text, 'userId' => $userId, 'settings' => $settings, 'attachment' => $attachment), array('text' => $text, 'settings' => $settings, 'privacy' => $privacy, 'attachment' => $attachment));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     $text = $data['text'];
     $settings = $data['settings'];
     $privacy = $data['privacy'];
     $attachment = $data['attachment'];
     $question = new EQUESTIONS_BOL_Question();
     $question->setSettings($settings);
     if (!empty($attachment)) {
         $question->setAttachment($attachment);
     }
     $question->text = $text;
     $question->userId = (int) $userId;
     $question->timeStamp = time();
     $this->questionDao->save($question);
     $this->followDao->addFollow($userId, $question->id);
     OW::getEventManager()->trigger(new OW_Event(self::EVENT_QUESTION_ADDED, array('text' => $text, 'userId' => $userId, 'settings' => $settings, 'id' => $question->id, 'privacy' => $privacy)));
     return $question;
 }