public function onUserUnregister(OW_Event $event) { $params = $event->getParams(); $userId = $params["userId"]; // Delete Questions $questions = QUESTIONS_BOL_Service::getInstance()->findQuestionsByUserId($userId); foreach ($questions as $question) { QUESTIONS_BOL_Service::getInstance()->deleteQuestion($question->id); } // Delete Answers $answers = QUESTIONS_BOL_Service::getInstance()->findAnswersByUserId($userId); foreach ($answers as $answer) { QUESTIONS_BOL_Service::getInstance()->removeAnswerById($answer->id); } // Delete Follows $follows = QUESTIONS_BOL_Service::getInstance()->findFollowsByUserId($userId); foreach ($follows as $follow) { QUESTIONS_BOL_Service::getInstance()->removeFollow($follow->userId, $follow->questionId); } // Delete Activity $activityList = QUESTIONS_BOL_FeedService::getInstance()->findActivityByUserId($userId); foreach ($activityList as $activity) { /* @var $activity QUESTIONS_BOL_Activity */ QUESTIONS_BOL_FeedService::getInstance()->deleteActivity($activity->questionId, $activity->activityType, $activity->activityId); } }
public function __construct($optionId, $hiddenUsers) { $service = QUESTIONS_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'); }
public function __construct(array $optionList, $uniqId, $userId) { parent::__construct(); $this->optionDtoList = $optionList; $this->service = QUESTIONS_BOL_Service::getInstance(); $this->userId = $userId; $this->uniqId = $uniqId; }
public function __construct() { parent::__construct(); if (!QUESTIONS_BOL_Service::getInstance()->isCurrentUserCanAsk()) { $this->setVisible(false); return; } $template = OW::getPluginManager()->getPlugin('questions')->getCmpViewDir() . 'question_add.html'; $this->setTemplate($template); }
public function __construct($questionId, $context, $hidden) { $service = QUESTIONS_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'); }
public function __construct(QUESTIONS_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 = QUESTIONS_BOL_Service::getInstance(); $this->userId = OW::getUser()->getId(); $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('questions-question', array('qid' => $this->question->id)); }
public function all() { $language = OW::getLanguage(); OW::getDocument()->setTitle($language->text('questions', 'list_all_page_title')); OW::getDocument()->setDescription($language->text('questions', 'list_all_page_description')); OW::getDocument()->setHeading($language->text('questions', 'list_heading')); OW::getDocument()->setHeadingIconClass('ow_ic_lens'); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'questions', 'main_menu_list'); $userId = OW::getUser()->getId(); $cmp = new QUESTIONS_CMP_MainFeed(time(), $userId, self::ITEMS_COUNT); $cmp->setFeedType(QUESTIONS_CMP_Feed::FEED_ALL); $order = QUESTIONS_BOL_FeedService::getInstance()->getOrder(QUESTIONS_CMP_Feed::FEED_ALL, OW::getUser()->getId()); $cmp->setOrder($order); $menu = $this->getMenu(); $menu->setOrder($order); $this->addComponent('list', $cmp); $this->addComponent('menu', $menu); if (QUESTIONS_BOL_Service::getInstance()->isCurrentUserCanAsk()) { $add = new QUESTIONS_CMP_QuestionAdd(); $this->addComponent('add', $add); } }
public function __construct($questionId, $userContext = null, $count = null, $options = null) { parent::__construct(); $language = OW::getLanguage(); $configs = OW::getConfig()->getValues('questions'); $count = empty($count) ? QUESTIONS_BOL_Service::MORE_DISPLAY_COUNT : $count; $uniqId = uniqid('question_'); $this->assign('uniqId', $uniqId); $service = QUESTIONS_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 QUESTIONS_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 QUESTIONS_CMP_QuestionStatus($answers->getUniqId(), $postCount, $answerCount, $followsCount); $plugin = OW::getPluginManager()->getPlugin('questions'); $statusCmp->setTemplate($plugin->getCmpViewDir() . 'question_static_status.html'); $this->addComponent('questionStatus', $statusCmp); $tplQuestion = array('text' => nl2br($question->text)); $event = new OW_Event(QUESTIONS_BOL_Service::EVENT_ON_QUESTION_RENDER, array("questionId" => $question->id, "questionDto" => $question, "text" => $question->text, "settings" => $settings, "uniqId" => $uniqId), $tplQuestion); OW::getEventManager()->trigger($event); $this->assign('question', $event->getData()); $js = UTIL_JsGenerator::newInstance()->newObject('question', 'QUESTIONS_Question', array($uniqId, $question->id)); if ($configs['allow_comments']) { $commentsParams = new BASE_CommentsParams('questions', QUESTIONS_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('questions')->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()')); /*$followLabel = $language->text('questions', 'toolbar_follow_btn'); $unfollowLabel = $language->text('questions', 'toolbar_unfollow_btn'); if ( $service->isFollow($userId, $question->id) ) { $toolbar[] = array( 'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a> <a id="' . $answers->getUniqId() . '-follow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>' ); } else { $toolbar[] = array( 'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a> <a id="' . $answers->getUniqId() . '-follow" href="javascript://" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>' ); }*/ } } 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('questions', 'toolbar_unvote_btn') . '</a>'); } } if ($service->isCurrentUserCanEdit($question)) { $condEmbed = "confirm('" . $language->text('questions', 'delete_question_confirm') . "')"; $toolbar[] = array('label' => '<a href="javascript://" onclick="if(' . $condEmbed . ') ' . $jsSelector . '.deleteQuestion();">' . $language->text('questions', '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); }
private function reload($query, $data) { $question = QUESTIONS_BOL_Service::getInstance()->findQuestion($data['questionId']); $optionTotal = QUESTIONS_BOL_Service::getInstance()->findOptionCount($data['questionId']); $answerCount = !empty($query['answerCount']) ? $query['answerCount'] : QUESTIONS_BOL_Service::getInstance()->findTotalAnswersCount($data['questionId']); $count = QUESTIONS_BOL_Service::DISPLAY_COUNT; if ($optionTotal - $count < 2) { $count = $optionTotal; } $cmp = new QUESTIONS_CMP_Answers($question, $optionTotal, array(0, $count), $data['uniqId']); $cmp->setUsersContext($data['userContext']); $cmp->setTotalAnswerCount($answerCount); $markup = $cmp->render(); $js = OW::getDocument()->getOnloadScript(); return array('reload' => array('markup' => $markup, 'script' => $js), 'status' => array('posts' => false, 'votes' => $answerCount, 'follows' => false)); }
public function onAnswerRemove(OW_Event $event) { $params = $event->getParams(); $optionId = (int) $params['optionId']; $optionDto = QUESTIONS_BOL_Service::getInstance()->findOption($optionId); $activityParams = array('entityType' => QUESTIONS_BOL_Service::ENTITY_TYPE, 'entityId' => $optionDto->questionId, 'activityType' => QUESTIONS_BOL_FeedService::ACTIVITY_ANSWER, 'activityId' => $params['id']); $event = new OW_Event('feed.delete_activity', $activityParams); OW::getEventManager()->trigger($event); }
public function onAnswerRemove(OW_Event $e) { $params = $e->getParams(); $option = QUESTIONS_BOL_Service::getInstance()->findOption($params['optionId']); if ($option === null) { return; } $this->service->deleteActivity($option->questionId, QUESTIONS_BOL_FeedService::ACTIVITY_ANSWER, $params['id']); }
private function __construct() { $this->service = QUESTIONS_BOL_Service::getInstance(); }
public function onBeforeRender() { parent::onBeforeRender(); $language = OW::getLanguage(); $configs = OW::getConfig()->getValues('questions'); $optionTotal = QUESTIONS_BOL_Service::getInstance()->findOptionCount($this->question->id); $answerCount = QUESTIONS_BOL_Service::getInstance()->findTotalAnswersCount($this->question->id); $postCount = BOL_CommentService::getInstance()->findCommentCount(QUESTIONS_BOL_Service::ENTITY_TYPE, $this->question->id); $questionUrl = OW::getRouter()->urlForRoute('questions-question', array('qid' => $this->question->id)); $count = QUESTIONS_BOL_Service::DISPLAY_COUNT; if ($optionTotal - $count < 2) { $count = $optionTotal; } $answers = new QUESTIONS_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('questions', 'follow_not_allowed') . "')"; $isFollowing = false; if (QUESTIONS_BOL_Service::getInstance()->isCurrentUserCanInteract($this->question)) { $userId = OW::getUser()->getId(); $isFollowing = QUESTIONS_BOL_Service::getInstance()->isFollow($userId, $this->question->id); $onClickStr = $isFollowing ? $jsSelector . '.unfollowQuestion();' : $jsSelector . '.followQuestion();'; } else { if (OW::getUser()->isAuthenticated()) { $isFollowing = QUESTIONS_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' => QUESTIONS_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); $event = new OW_Event(QUESTIONS_BOL_Service::EVENT_ON_LIST_ITEM_RENDER, array("questionId" => $this->question->id, "questionDto" => $this->question, "text" => $text, "settings" => $settings, "uniqId" => $this->getUniqId()), $tplQuestion); OW::getEventManager()->trigger($event); $this->assign('item', $event->getData()); }