public function __construct(EQUESTIONS_BOL_Question $question, $optionTotal, array $listLimit = null, $uniqId = null) { parent::__construct(); $this->uniqId = empty($uniqId) ? uniqid('questionsAnswers_') : $uniqId; $this->question = $question; $this->limit = $listLimit; $this->startStamp = time(); $this->service = EQUESTIONS_BOL_Service::getInstance(); $this->userId = OW::getUser()->getId(); $this->attachment = $this->question->getAttachment(); $this->editMode = $this->service->isCurrentUserCanEdit($question); $settings = json_decode($this->question->settings, true); $this->poll = !$settings['allowAddOprions']; $this->optionTotal = $optionTotal; $this->viewMore = $this->optionTotal - (empty($this->limit[1]) ? $this->optionTotal : $this->limit[1]); $this->viewMore = $this->viewMore > 0 ? $this->viewMore : 0; $jsConstructor = $this->poll ? 'QUESTIONS_PollAnswers' : 'QUESTIONS_QuestionAnswers'; $js = UTIL_JsGenerator::newInstance()->newObject(array('QUESTIONS_AnswerListCollection', $this->uniqId), $jsConstructor); OW::getDocument()->addOnloadScript($js); $this->questionUrl = OW::getRouter()->urlForRoute('equestions-question', array('qid' => $this->question->id)); }
private function deleteQuestion($query, $data) { if (!OW::getUser()->isAuthenticated()) { return array('warning' => OW::getLanguage()->text('equestions', 'not_authed_delete_warning')); } $questionId = $data['questionId']; $question = $this->service->findQuestion($questionId); if (!$this->service->isCurrentUserCanEdit($question)) { return array(); } $this->service->deleteQuestion($questionId); return array('message' => OW::getLanguage()->text('equestions', 'question_delete_complete_msg'), 'listing' => array('loadMore' => 1)); }