Beispiel #1
0
 public function userSearch($query)
 {
     $kw = $query['kw'];
     $data = $query['data'];
     $friendMode = $data['friendsMode'];
     $idList = array();
     $userIds = array();
     if ($friendMode) {
         if (OW::getUser()->isAuthenticated()) {
             $userId = OW::getUser()->getId();
             $userIds = EQUESTIONS_BOL_Service::getInstance()->findFriends($kw, $userId);
         }
     } else {
         $userIds = EQUESTIONS_BOL_Service::getInstance()->findUsers($kw);
     }
     foreach ($userIds as $u) {
         if ($u != OW::getUser()->getId()) {
             $idList[] = $u;
         }
     }
     $allList = empty($idList) ? array() : BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false, true, false);
     $cachelist = array();
     foreach ($allList as $uid => $info) {
         $info['userId'] = $uid;
         $info['kw'] = strtolower($info['title']);
         $cachelist[$uid] = $info;
     }
     return $cachelist;
 }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
 /**
  * Returns class instance
  *
  * @return EQUESTIONS_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #4
0
 private function askUsers($query, $data)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return array('warning' => OW::getLanguage()->text('equestions', 'not_authed_ask_warning'));
     }
     $userIds = $query['ids'];
     $questionId = $data['questionId'];
     $question = $this->service->findQuestion($questionId);
     $params = array('userId' => OW::getUser()->getId(), 'questionId' => $questionId);
     if ($query['all']) {
         $params['special'] = true;
         $users = BOL_UserDao::getInstance()->findAll();
         foreach ($users as $user) {
             if ($user->id != $params['userId']) {
                 $userIds[] = $user->id;
             }
         }
     }
     foreach ($userIds as $uid) {
         $params['recipientId'] = $uid;
         $event = new OW_Event(EQUESTIONS_BOL_Service::EVENT_QUESTION_BEFORE_ASK, $params, $data);
         OW::getEventManager()->trigger($event);
     }
     $permissions = EQUESTIONS_CLASS_CreditsBridge::getInstance()->getAllPermissions(EQUESTIONS_CLASS_Credits::ACTION_ASK);
     return array('message' => OW::getLanguage()->text('equestions', 'question_ask_complete_msg', array('count' => count($userIds))), 'permissions' => $permissions);
 }
Beispiel #5
0
 public function __construct($optionId, $hiddenUsers)
 {
     $service = EQUESTIONS_BOL_Service::getInstance();
     $userIds = $service->findAnsweredUserIdList($optionId);
     $userIds = array_diff($userIds, $hiddenUsers);
     parent::__construct($userIds);
     $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'floatbox_user_list.html');
 }
Beispiel #6
0
 public function onOptionAdd(OW_Event $e)
 {
     $params = $e->getParams();
     $question = EQUESTIONS_BOL_Service::getInstance()->findQuestion($params['questionId']);
     if ($question->userId != OW::getUser()->getId()) {
         $this->credits->trackUse(EQUESTIONS_CLASS_Credits::ACTION_ADD_ANSWER);
     }
 }
Beispiel #7
0
 public function onAnswerRemove(OW_Event $e)
 {
     $params = $e->getParams();
     $option = EQUESTIONS_BOL_Service::getInstance()->findOption($params['optionId']);
     if ($option === null) {
         return;
     }
     $this->service->deleteActivity($option->questionId, EQUESTIONS_BOL_FeedService::ACTIVITY_ANSWER, $params['id']);
 }
Beispiel #8
0
 public function __construct()
 {
     parent::__construct();
     if (!EQUESTIONS_BOL_Service::getInstance()->isCurrentUserCanAsk()) {
         $this->setVisible(false);
         return;
     }
     $template = OW::getPluginManager()->getPlugin('equestions')->getCmpViewDir() . 'question_add.html';
     $this->setTemplate($template);
 }
Beispiel #9
0
 public function __construct($questionId, $context, $hidden)
 {
     $service = EQUESTIONS_BOL_Service::getInstance();
     $context = empty($context) ? array() : $context;
     $follows = $service->findFollows($questionId, $context, $hidden);
     $userIds = array();
     foreach ($follows as $follow) {
         $userIds[] = (int) $follow->userId;
     }
     parent::__construct($userIds);
     $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'floatbox_user_list.html');
 }
Beispiel #10
0
 public function initOption($countList, $optionCount = null)
 {
     if (empty($this->optionDtoList)) {
         return array();
     }
     foreach ($this->optionDtoList as $opt) {
         $this->optionIdList[] = $opt->id;
         $cmp = new EQUESTIONS_CMP_Answer($opt, $this->uniqId);
         $this->optionList[$opt->id] = $cmp;
         $cmp->setDisbled(!$this->editable);
         $cmp->setIsMultiple(!$this->poll);
     }
     $checkedOptions = array();
     $optionsState = array();
     $totalAnswers = $this->answerCount;
     //$countList = $this->service->findAnswersCount($this->optionIdList);
     $answerDtoList = $this->service->findUserAnswerList($this->userId, $this->optionIdList);
     foreach ($answerDtoList as $item) {
         $checkedOptions[] = $item->optionId;
         $this->getOption($item->optionId)->setVoted();
     }
     $optionCount = empty($optionCount) ? count($this->optionDtoList) : $optionCount;
     foreach ($this->optionDtoList as $optionDto) {
         $optionId = $optionDto->id;
         $checked = in_array($optionId, $checkedOptions);
         $voteCount = $countList[$optionId];
         $users = $this->service->findAnsweredUserIdList($optionId, $this->usersContext, $checked ? 4 : 3);
         $optionsState[] = array('id' => $optionId, 'users' => $users, 'voteCount' => $voteCount, 'checked' => $checked);
         $this->getOption($optionId)->setVoteCount($voteCount);
         $this->getOption($optionId)->setUsers($users);
         $canEdit = $optionDto->userId == $this->userId && ($voteCount == 0 || $voteCount == 1 && $checked);
         $canEdit = $this->editMode || $canEdit;
         $canEdit = $this->poll ? $canEdit && $optionCount > 2 : $canEdit;
         $this->getOption($optionId)->setEditMode($canEdit);
         if ($totalAnswers) {
             $this->getOption($optionId)->setPercents($voteCount * 100 / $totalAnswers);
         }
     }
     return $optionsState;
 }
Beispiel #11
0
 public function onAnswerAdd(OW_Event $e)
 {
     $params = $e->getParams();
     $option = EQUESTIONS_BOL_Service::getInstance()->findOption($params['optionId']);
     if ($option === null) {
         return;
     }
     $notification = $this->service->findNotification($option->questionId, EQUESTIONS_BOL_FeedService::ACTIVITY_ASK, $params['userId']);
     if ($notification === null) {
         return;
     }
     $this->deleteInvitation($notification->id);
 }
Beispiel #12
0
 /**
  * @return Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $userId = OW::getUser()->getId();
     $cmp = new EQUESTIONS_CMP_MainFeed(time(), $userId, $paramObj->customParamList['count']);
     $cmp->setFeedType(EQUESTIONS_CMP_Feed::FEED_ALL);
     $cmp->setOrder($paramObj->customParamList['order']);
     $this->addComponent('feed', $cmp);
     if ($paramObj->customParamList['addNew'] && EQUESTIONS_BOL_Service::getInstance()->isCurrentUserCanAsk()) {
         $add = new EQUESTIONS_CMP_QuestionAdd();
         $this->addComponent('add', $add);
     }
 }
Beispiel #13
0
 public function addQuestion()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(false);
         exit;
     }
     if (empty($_POST['question'])) {
         echo json_encode(false);
         exit;
     }
     $permissions = EQUESTIONS_CLASS_CreditsBridge::getInstance()->getAllPermissions(EQUESTIONS_CLASS_Credits::ACTION_ASK);
     if (!$permissions[EQUESTIONS_CLASS_Credits::ACTION_ASK]) {
         echo json_encode(array('reset' => false, 'warning' => EQUESTIONS_CLASS_CreditsBridge::getInstance()->credits->getErrorMessage(EQUESTIONS_CLASS_Credits::ACTION_ASK)));
         exit;
     }
     $question = empty($_POST['question']) ? '' : htmlspecialchars($_POST['question']);
     $answers = empty($_POST['answers']) ? array() : array_filter($_POST['answers'], 'trim');
     $allowAddOprions = !empty($_POST['allowAddOprions']);
     $attachment = empty($_POST['attachment']) ? array() : json_decode($_POST['attachment'], true);
     if (!empty($attachment)) {
         if ($attachment['type'] == 'file') {
             $attachment['url'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $attachment['fileId']));
             $attachment['type'] = 'photo';
             $attachment['href'] = $attachment['url'];
         }
     }
     $userId = OW::getUser()->getId();
     $questionDto = $this->service->addQuestion($userId, $question, $attachment, array('allowAddOprions' => $allowAddOprions));
     foreach ($answers as $ans) {
         $this->service->addOption($questionDto->id, $userId, $ans);
     }
     $event = new OW_Event('feed.action', array('entityType' => EQUESTIONS_BOL_Service::ENTITY_TYPE, 'entityId' => $questionDto->id, 'pluginKey' => 'equestions', 'userId' => $userId, 'visibility' => 15));
     OW::getEventManager()->trigger($event);
     $activityList = EQUESTIONS_BOL_FeedService::getInstance()->findMainActivity(time(), array($questionDto->id), array(0, 6));
     $cmp = new EQUESTIONS_CMP_FeedItem($questionDto, reset($activityList[$questionDto->id]), $activityList[$questionDto->id]);
     $html = $cmp->render();
     $script = OW::getDocument()->getOnloadScript();
     echo json_encode(array('markup' => array('html' => $html, 'script' => $script, 'position' => 'prepend'), 'permissions' => $permissions));
     exit;
 }
Beispiel #14
0
 public function onBeforeRender()
 {
     if (!empty($this->attachment)) {
         if ($this->expandedView) {
             $this->attachment['onclick'] = null;
         } else {
             $this->attachment['onclick'] = 'QUESTIONS_AnswerListCollection.' . $this->uniqId . '.openQuestion(); return false;';
             if ($this->attachment['type'] != 'link') {
                 $this->attachment['href'] = $this->questionUrl;
             }
         }
         $attachCmp = new EQUESTIONS_CMP_Attachment($this->attachment, $this->expandedView);
         $this->addComponent('attachment', $attachCmp);
     }
     if (!$this->doNotLoadStatic) {
         EQUESTIONS_Plugin::getInstance()->addStatic();
     }
     if ($this->editable === null) {
         $this->editable = $this->service->isCurrentUserCanInteract($this->question) && $this->service->isCurrentUserCanAnswer($this->question);
     }
     $tmp = $this->service->findOptionListAndAnswerCountList($this->question->id, $this->startStamp, $this->userContext, $this->limit);
     $optionsDtoList = $tmp['optionList'];
     $countList = $tmp['countList'];
     $userContext = null;
     if (is_array($this->userContext)) {
         $userContext = $this->userContext;
         $userContext[] = $this->userId;
         $userContext = array_unique($userContext);
     }
     $totalAnswerCount = $this->totalAnswerCount == null ? $this->service->findTotalAnswersCount($this->question->id) : $this->totalAnswerCount;
     $answerCount = $this->poll ? $totalAnswerCount : $this->service->findMaxAnswersCount($this->question->id);
     $optionList = new EQUESTIONS_CMP_OptionList($optionsDtoList, $this->uniqId, $this->userId);
     $optionList->setAnswerCount($answerCount);
     $optionList->setEditable($this->editable);
     $optionList->setIsPoll($this->poll);
     $optionList->setUsersContext($userContext);
     $optionList->setEditMode($this->editMode);
     $options = $optionList->initOption($countList);
     $shareData = array('userId' => $this->userId, 'ownerId' => $this->question->userId, 'editable' => $this->editable, 'editMode' => $this->editMode, 'questionId' => $this->question->id, 'totalAnswers' => $answerCount, 'poll' => $this->poll, 'uniqId' => $this->uniqId, 'userContext' => $userContext, 'displayedCount' => count($options), 'optionTotal' => $this->optionTotal, 'startStamp' => $this->startStamp, 'ignoreOptions' => array(), 'expandedView' => $this->expandedView, 'inPopupMode' => $this->inPopupMode, 'ownerMode' => $this->userId == $this->question->userId);
     $shareData['offset'] = $shareData['displayedCount'];
     $shareData['st']['displayedCount'] = $shareData['displayedCount'];
     $shareData['st']['optionTotal'] = $shareData['optionTotal'];
     $jsAccessor = 'questionAnswers';
     $js = UTIL_JsGenerator::newInstance();
     $js->equateVarables($jsAccessor, array('QUESTIONS_AnswerListCollection', $this->uniqId));
     $js->callFunction(array($jsAccessor, 'init'), array($this->uniqId, $options, $shareData, !$this->editable));
     $js->callFunction(array($jsAccessor, 'setResponder'), array(OW::getRouter()->urlFor('EQUESTIONS_CTRL_Questions', 'rsp')));
     $this->assign('viewMore', $this->viewMore);
     $this->assign('editMode', $this->editMode);
     if ($this->viewMore) {
         $js->callFunction(array($jsAccessor, 'initViewMore'), array());
         $this->assign('viewMoreUrl', $this->questionUrl);
     }
     $addNewAvaliable = $this->editable && !$this->poll;
     $this->assign('addNew', $addNewAvaliable);
     $this->assign('hideAddNew', !$this->isAddNewAvaliable());
     if ($addNewAvaliable) {
         $js->callFunction(array($jsAccessor, 'initAddNew'), array());
     }
     OW::getDocument()->addOnloadScript($js);
     $this->assign('uniqId', $this->uniqId);
     $this->addComponent('list', $optionList);
     OW::getLanguage()->addKeyForJs('equestions', 'option_not_empty_delete_warning');
     OW::getLanguage()->addKeyForJs('equestions', 'question_fb_title');
     OW::getLanguage()->addKeyForJs('equestions', 'users_fb_title');
 }
Beispiel #15
0
 public function onAnswerRemove(OW_Event $event)
 {
     $params = $event->getParams();
     $optionId = (int) $params['optionId'];
     $optionDto = EQUESTIONS_BOL_Service::getInstance()->findOption($optionId);
     $activityParams = array('entityType' => EQUESTIONS_BOL_Service::ENTITY_TYPE, 'entityId' => $optionDto->questionId, 'activityType' => EQUESTIONS_BOL_FeedService::ACTIVITY_ANSWER, 'activityId' => $params['id']);
     $event = new OW_Event('feed.delete_activity', $activityParams);
     OW::getEventManager()->trigger($event);
 }
Beispiel #16
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('equestions');
     $optionTotal = EQUESTIONS_BOL_Service::getInstance()->findOptionCount($this->question->id);
     $answerCount = EQUESTIONS_BOL_Service::getInstance()->findTotalAnswersCount($this->question->id);
     $postCount = BOL_CommentService::getInstance()->findCommentCount(EQUESTIONS_BOL_Service::ENTITY_TYPE, $this->question->id);
     $questionUrl = OW::getRouter()->urlForRoute('equestions-question', array('qid' => $this->question->id));
     $count = EQUESTIONS_BOL_Service::DISPLAY_COUNT;
     if ($optionTotal - $count < 2) {
         $count = $optionTotal;
     }
     $answers = new EQUESTIONS_CMP_Answers($this->question, $optionTotal, array(0, $count));
     $answers->setTotalAnswerCount($answerCount);
     $answers->setUsersContext($this->getContextUserIds());
     $bubbleActivity = $this->getBubbleActivity();
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $answers->getUniqId();
     $text = $this->getItemString($bubbleActivity, $jsSelector, $questionUrl);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($bubbleActivity->userId));
     $allowPopups = !isset($configs['allow_popups']) || $configs['allow_popups'];
     $features = array();
     $onClickStr = "window.location.href='{$questionUrl}'";
     if ($configs['allow_comments']) {
         if ($allowPopups) {
             $onClickStr = "return {$jsSelector}.openQuestionDelegate(true);";
         }
         $features[] = array('class' => 'q-' . $answers->getUniqId() . '-status-comments', 'iconClass' => 'ow_miniic_comment', 'label' => $postCount, 'onclick' => $onClickStr, 'string' => null);
     }
     if ($allowPopups) {
         $onClickStr = "return {$jsSelector}.openQuestionDelegate();";
     }
     $features[] = array('class' => 'q-' . $answers->getUniqId() . '-status-votes', 'iconClass' => 'questions_miniicon_check', 'label' => $answerCount, 'onclick' => $onClickStr, 'string' => null);
     if ($configs['enable_follow']) {
         $onClickStr = "OW.error('" . $language->text('equestions', 'follow_not_allowed') . "')";
         $isFollowing = false;
         if (EQUESTIONS_BOL_Service::getInstance()->isCurrentUserCanInteract($this->question)) {
             $userId = OW::getUser()->getId();
             $isFollowing = EQUESTIONS_BOL_Service::getInstance()->isFollow($userId, $this->question->id);
             $onClickStr = $isFollowing ? $jsSelector . '.unfollowQuestion();' : $jsSelector . '.followQuestion();';
         } else {
             if (OW::getUser()->isAuthenticated()) {
                 $isFollowing = EQUESTIONS_BOL_Service::getInstance()->isFollow($userId, $this->question->id);
                 if ($isFollowing) {
                     $onClickStr = $jsSelector . '.unfollowQuestion();';
                 }
             }
         }
         $features[] = array('class' => 'q-' . $answers->getUniqId() . '-status-follows', 'iconClass' => 'questions_miniic_follow', 'label' => EQUESTIONS_BOL_Service::getInstance()->findFollowsCount($this->question->id), 'onclick' => $onClickStr, 'active' => $isFollowing);
     }
     $settings = $this->question->getSettings();
     $context = empty($settings['context']['url']) || empty($settings['context']['label']) ? null : array('url' => $settings['context']['url'], 'label' => $settings['context']['label']);
     $tplQuestion = array('questionId' => $this->question->id, 'uniqId' => $this->getUniqId(), 'text' => $text, 'timeStamp' => UTIL_DateTime::formatDate($bubbleActivity->timeStamp), 'lastItem' => $this->lastItem, 'answers' => $answers->render(), 'avatar' => $avatars[$bubbleActivity->userId], 'settings' => $settings, 'context' => $context, 'features' => $features, 'permalink' => $questionUrl);
     $this->assign('item', $tplQuestion);
 }
Beispiel #17
0
 public function __construct($questionId, $userContext = null, $count = null, $options = null)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('equestions');
     $count = empty($count) ? EQUESTIONS_BOL_Service::MORE_DISPLAY_COUNT : $count;
     $uniqId = uniqid('question_');
     $this->assign('uniqId', $uniqId);
     $service = EQUESTIONS_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $question = $service->findQuestion($questionId);
     if (empty($question)) {
         $this->assign('noQuestion', true);
         return;
     }
     $settings = $question->getSettings();
     $isPoll = !$settings['allowAddOprions'];
     $optionTotal = $service->findOptionCount($questionId);
     $answerCount = $service->findTotalAnswersCount($questionId);
     $postCount = BOL_CommentService::getInstance()->findCommentCount('question', $questionId);
     $isAutor = $question->userId == $userId;
     if ($optionTotal - $count < 10) {
         $count = $optionTotal;
     }
     $limit = $count ? array(0, $count) : null;
     $answers = new EQUESTIONS_CMP_Answers($question, $optionTotal, $limit);
     $answers->setExpandedView();
     $answers->setSettings($options);
     if (isset($options['inPopup']) && $options['inPopup'] === true) {
         $answers->setInPopupMode();
     }
     if (isset($options['loadStatic']) && $options['loadStatic'] === false) {
         $answers->setDoNotLoadStatic();
     }
     $editable = $service->isCurrentUserCanInteract($question);
     $answers->setEditable($editable && $service->isCurrentUserCanAnswer($question));
     if ($userContext !== null) {
         $answers->setUsersContext($userContext);
     }
     $answers->showAddNew();
     $this->addComponent('answers', $answers);
     $followsCount = $service->findFollowsCount($question->id, $userContext, array($question->userId));
     $statusCmp = new EQUESTIONS_CMP_QuestionStatus($answers->getUniqId(), $postCount, $answerCount, $followsCount);
     $plugin = OW::getPluginManager()->getPlugin('equestions');
     $statusCmp->setTemplate($plugin->getCmpViewDir() . 'question_static_status.html');
     $this->addComponent('questionStatus', $statusCmp);
     $tplQuestion = array('text' => nl2br($question->text));
     $this->assign('question', $tplQuestion);
     $js = UTIL_JsGenerator::newInstance()->newObject('question', 'QUESTIONS_Question', array($uniqId, $question->id));
     if ($configs['allow_comments']) {
         $commentsParams = new BASE_CommentsParams('equestions', EQUESTIONS_BOL_Service::ENTITY_TYPE);
         $commentsParams->setEntityId($question->id);
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
         $commentsParams->setCommentCountOnPage(5);
         $commentsParams->setOwnerId($question->userId);
         $commentsParams->setAddComment($editable);
         $commentCmp = new BASE_CMP_Comments($commentsParams);
         //$commentTemplate = OW::getPluginManager()->getPlugin('equestions')->getCmpViewDir() . 'comments.html';
         //$commentCmp->setTemplate($commentTemplate);
         $this->addComponent('comments', $commentCmp);
         if (!empty($options['focusToPost'])) {
             $js->addScript('question.focusOnPostInput()');
         }
     }
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $answers->getUniqId();
     $js->addScript('question.setAnswerList(' . $jsSelector . ');');
     if (!empty($options['relation'])) {
         $js->addScript($jsSelector . '.setRelation("' . $options['relation'] . '");');
     }
     $js->equateVarables(array('QUESTIONS_QuestionColletction', $uniqId), 'question');
     OW::getDocument()->addOnloadScript($js);
     $toolbar = array();
     if ($service->isCurrentUserCanInteract($question)) {
         if ($configs['enable_follow']) {
             $this->assign('follow', array('isFollow' => $service->isFollow($userId, $question->id), 'followId' => $answers->getUniqId() . '-follow', 'unfollowId' => $answers->getUniqId() . '-unfollow', 'followClick' => $jsSelector . '.followQuestion()', 'unfollowClick' => $jsSelector . '.unfollowQuestion()'));
         }
         if ($configs['ask_friends']) {
             $friendMode = (bool) OW::getEventManager()->call('plugin.friends');
             $askLabel = $friendMode ? $language->text('equestions', 'toolbar_ask_friends') : $language->text('equestions', 'toolbar_ask_users');
             $this->assign('ask', array('label' => $askLabel, 'onClick' => $jsSelector . '.showUserSelector()'));
         }
     }
     if ($isPoll) {
         $list = $service->findUserAnswerListByQuestionId($userId, $question->id);
         if (count($list)) {
             $toolbar[] = array('label' => '<a id="' . $answers->getUniqId() . '-unvote" href="javascript://" onclick="' . $jsSelector . '.unvote()">' . $language->text('equestions', 'toolbar_unvote_btn') . '</a>');
         }
     }
     if ($service->isCurrentUserCanEdit($question)) {
         $condEmbed = "confirm('" . $language->text('equestions', 'delete_question_confirm') . "')";
         $toolbar[] = array('label' => '<a href="javascript://" onclick="if(' . $condEmbed . ') ' . $jsSelector . '.deleteQuestion();">' . $language->text('equestions', 'toolbar_delete_btn') . '</a>');
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($question->userId));
     $questionInfo = array('avatar' => $userData[$question->userId], 'profileUrl' => $userData[$question->userId]['url'], 'displayName' => $userData[$question->userId]['title'], 'content' => '', 'toolbar' => $toolbar, 'date' => UTIL_DateTime::formatDate($question->timeStamp));
     $this->assign('questionInfo', $questionInfo);
 }