Exemple #1
0
 public function __construct($startStamp, $userId, $count)
 {
     parent::__construct();
     $this->userId = $userId;
     $this->uniqId = uniqid('questionList');
     $this->startStamp = (int) $startStamp;
     $this->count = $count;
     $this->service = EQUESTIONS_BOL_FeedService::getInstance();
     $template = OW::getPluginManager()->getPlugin('equestions')->getCmpViewDir() . 'feed.html';
     $this->setTemplate($template);
     $this->order = $this->service->getDefaultOrder();
     $this->feedType = self::FEED_ALL;
     EQUESTIONS_Plugin::getInstance()->addStatic();
 }
Exemple #2
0
 /**
  * Returns class instance
  *
  * @return EQUESTIONS_BOL_FeedService
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #3
0
 public function onAsk(OW_Event $e)
 {
     $params = $e->getParams();
     $activity = new EQUESTIONS_BOL_Activity();
     $activity->questionId = (int) $params['questionId'];
     $activity->activityType = EQUESTIONS_BOL_FeedService::ACTIVITY_ASK;
     $activity->activityId = (int) $params['recipientId'];
     $activity->userId = (int) $params['userId'];
     $activity->privacy = EQUESTIONS_BOL_FeedService::PRIVACY_NOBODY;
     $activity->timeStamp = time();
     $this->service->saveActivity($activity);
 }
Exemple #4
0
 public function __construct()
 {
     parent::__construct();
     $this->addComponent('menu', $this->getMenu());
     $this->order = EQUESTIONS_BOL_FeedService::getInstance()->getDefaultOrder();
 }
Exemple #5
0
 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;
     }
     EQUESTIONS_BOL_FeedService::getInstance()->setPrivacy($userId, $actionList[self::PRIVACY_ACTION_VIEW_MY_QUESTIONS]);
 }
Exemple #6
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;
 }