Esempio n. 1
0
 private function answer($query, $data, $relation)
 {
     $userId = OW::getUser()->getId();
     $unvote = false;
     foreach ($query['answers']['yes'] as $optionId) {
         $this->service->addAnswer($userId, $optionId);
         $unvote = $data['poll'];
     }
     if (!empty($query['answers']['no'])) {
         $this->service->removeAnswerList($userId, $query['answers']['no']);
     }
     $answerCount = EQUESTIONS_BOL_Service::getInstance()->findTotalAnswersCount($data['questionId']);
     if (!empty($relation)) {
         $relation = $this->reload(array('answerCount' => $answerCount), $relation['data']);
     }
     $permissions = EQUESTIONS_CLASS_CreditsBridge::getInstance()->getAllPermissions(EQUESTIONS_CLASS_Credits::ACTION_ANSWER);
     return array('forceNotifications' => true, 'relation' => $relation, 'status' => array('posts' => false, 'votes' => $answerCount, 'follows' => false), 'unvote' => $unvote, 'permissions' => $permissions);
 }