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($startStamp, $userId, $count) { parent::__construct(); $this->userId = $userId; $this->uniqId = uniqid('questionList'); $this->startStamp = (int) $startStamp; $this->count = $count; $this->service = QUESTIONS_BOL_FeedService::getInstance(); $template = OW::getPluginManager()->getPlugin('questions')->getCmpViewDir() . 'feed.html'; $this->setTemplate($template); $this->order = $this->service->getDefaultOrder(); $this->feedType = self::FEED_ALL; QUESTIONS_Plugin::getInstance()->addStatic(); }
public function __construct() { parent::__construct(); $this->addComponent('menu', $this->getMenu()); $this->order = QUESTIONS_BOL_FeedService::getInstance()->getDefaultOrder(); }
private function __construct() { $this->service = QUESTIONS_BOL_FeedService::getInstance(); }
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; } $question = empty($_POST['question']) ? '' : strip_tags($_POST['question']); $question = UTIL_HtmlTag::autoLink($question); $answers = empty($_POST['answers']) ? array() : array_filter($_POST['answers'], 'trim'); $allowAddOprions = !empty($_POST['allowAddOprions']); $userId = OW::getUser()->getId(); $questionDto = $this->service->addQuestion($userId, $question, array('allowAddOprions' => $allowAddOprions)); foreach ($answers as $ans) { $this->service->addOption($questionDto->id, $userId, $ans); } $event = new OW_Event('feed.action', array('entityType' => QUESTIONS_BOL_Service::ENTITY_TYPE, 'entityId' => $questionDto->id, 'pluginKey' => 'questions', 'userId' => $userId, 'visibility' => 15)); OW::getEventManager()->trigger($event); $activityList = QUESTIONS_BOL_FeedService::getInstance()->findMainActivity(time(), array($questionDto->id), array(0, 6)); $cmp = new QUESTIONS_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'))); exit; }
public function onPrivacyChange(OW_Event $e) { $params = $e->getParams(); $userId = (int) $params['userId']; $actionList = $params['actionList']; $actionList = is_array($actionList) ? $actionList : array(); if (empty($actionList[self::PRIVACY_ACTION_VIEW_MY_QUESTIONS])) { return; } QUESTIONS_BOL_FeedService::getInstance()->setPrivacy($userId, $actionList[self::PRIVACY_ACTION_VIEW_MY_QUESTIONS]); }