Example #1
0
 public static function getInstance()
 {
     if (!isset(self::$classInstance)) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 public function acceptWink($params)
 {
     $partnerId = OW::getUser()->getId();
     if (!$partnerId) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['userId'])) {
         throw new ApiResponseErrorException();
     }
     $service = WINKS_BOL_Service::getInstance();
     $userId = $params['userId'];
     /**
      * @var WINKS_BOL_Winks $wink
      */
     $wink = $service->findWinkByUserIdAndPartnerId($userId, $partnerId);
     if (empty($wink)) {
         throw new ApiResponseErrorException();
     }
     $wink->setStatus(WINKS_BOL_WinksDao::STATUS_ACCEPT);
     WINKS_BOL_WinksDao::getInstance()->save($wink);
     if (($_wink = $service->findWinkByUserIdAndPartnerId($partnerId, $userId)) !== NULL) {
         $_wink->setStatus(WINKS_BOL_WinksDao::STATUS_IGNORE);
         WINKS_BOL_WinksDao::getInstance()->save($_wink);
     }
     $params = array('userId' => $userId, 'partnerId' => $partnerId, 'content' => array('entityType' => 'wink', 'eventName' => 'renderWink', 'params' => array('winkId' => $wink->id, 'winkBackEnabled' => 1)));
     $event = new OW_Event('winks.onAcceptWink', $params);
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (!empty($data['conversationId'])) {
         $wink->setConversationId($data['conversationId']);
         WINKS_BOL_WinksDao::getInstance()->save($wink);
     }
     $this->assign('result', true);
 }
 /**
  * Application event methods
  */
 public function getUnreadMessageCount($userId, $ignoreList = array(), $time = null, $activeModes = array())
 {
     $ignoreList = empty($ignoreList) ? array() : (array) $ignoreList;
     $time = $time == null ? time() : (int) $time;
     $activeModes = empty($activeModes) ? $this->getActiveModeList() : $activeModes;
     $messageList = $this->messageDao->findUnreadMessages($userId, $ignoreList, $time, $activeModes);
     $winkList = array();
     if (OW::getPluginManager()->isPluginActive('winks')) {
         $winks = WINKS_BOL_Service::getInstance()->findWinkList($userId, 0, 9999);
         foreach ($winks as $wink) {
             if ($wink->userId == $userId) {
                 continue;
             }
             if ($wink->status == 'wait') {
                 $winkList[] = $wink->userId;
             }
         }
     }
     return count($messageList) + count($winkList);
 }
Example #4
0
 public function __construct()
 {
     parent::__construct();
     $this->service = WINKS_BOL_Service::getInstance();
 }
 private function __construct()
 {
     $this->service = WINKS_BOL_Service::getInstance();
 }
Example #6
0
 public function getQuestions($params)
 {
     if (empty($params['userId'])) {
         throw new ApiResponseErrorException();
     }
     $userId = (int) $params['userId'];
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         throw new ApiResponseErrorException();
     }
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $questionService = BOL_QuestionService::getInstance();
     $accountType = OW::getUser()->getUserObject()->accountType;
     $viewQuestionList = $questionService->findViewQuestionsForAccountType($accountType);
     $viewNames = array();
     foreach ($viewQuestionList as $viewQuestion) {
         $viewNames[] = $viewQuestion['name'];
     }
     $viewQuestionList = BOL_UserService::getInstance()->getUserViewQuestions($userId, false, $viewNames);
     $viewSections = array();
     $sortedSections = $questionService->findSortedSectionList();
     foreach ($viewQuestionList['questions'] as $sectionName => $section) {
         if ($sectionName == 'location') {
             continue;
         }
         $order = 0;
         foreach ($sortedSections as $sorted) {
             if ($sorted->name == $sectionName) {
                 $order = $sorted->sortOrder;
             }
         }
         $viewSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
     }
     usort($viewSections, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
     $viewQuestions = array();
     $viewBasic = array();
     $data = $viewQuestionList['data'][$userId];
     foreach ($viewQuestionList['questions'] as $sectName => $section) {
         $sectionQuestions = array();
         foreach ($section as $question) {
             $name = $question['name'];
             if (is_array($data[$name])) {
                 $values = array();
                 foreach ($data[$name] as $val) {
                     $values[] = strip_tags($val);
                 }
             } else {
                 $values = strip_tags($data[$name]);
             }
             if (in_array($name, self::$basicNames)) {
                 if ($name == 'sex') {
                     $v = array_values($values);
                     $viewBasic[$name] = array_shift($v);
                 } else {
                     $viewBasic[$name] = $values;
                 }
             } else {
                 $sectionQuestions[] = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'section' => $sectName, 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation'], 'order' => $question["sortOrder"]);
             }
         }
         usort($sectionQuestions, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
         $viewQuestions[$sectName] = $sectionQuestions;
     }
     $viewBasic['online'] = (bool) BOL_UserService::getInstance()->findOnlineUserById($userId);
     $viewBasic['avatar'] = self::dataForUserAvatar($userId);
     $viewBasic["displayName"] = BOL_UserService::getInstance()->getDisplayName($userId);
     // compatibility
     if ($userId != OW::getUser()->getId()) {
         $viewBasic['compatibility'] = OW::getEventManager()->call("matchmaking.get_compatibility", array("firstUserId" => OW::getUser()->getId(), "secondUserId" => $userId));
     } else {
         $viewBasic['compatibility'] = null;
     }
     // edit questions
     $editQuestionList = $questionService->findEditQuestionsForAccountType($accountType);
     $editNames = array();
     foreach ($editQuestionList as $editQuestion) {
         $editNames[] = $editQuestion['name'];
     }
     $editQuestionList = $this->getUserEditQuestions($userId, $editNames);
     $editOptions = $questionService->findQuestionsValuesByQuestionNameList($editNames);
     $editData = $questionService->getQuestionData(array($userId), $editNames);
     $editData = !empty($editData[$userId]) ? $editData[$userId] : array();
     $editSections = array();
     foreach ($editQuestionList['questions'] as $sectionName => $section) {
         if ($sectionName == 'location') {
             continue;
         }
         $order = 0;
         foreach ($sortedSections as $sorted) {
             if ($sorted->name == $sectionName) {
                 $order = $sorted->sortOrder;
             }
         }
         $editSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
     }
     usort($editSections, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
     $editQuestions = array();
     $editBasic = array();
     foreach ($editQuestionList['questions'] as $sectName => $section) {
         $sectionQuestions = array();
         foreach ($section as $question) {
             $data = $editQuestionList['data'][$userId];
             $name = $question['name'];
             $values = "";
             if (!empty($data[$name])) {
                 if (is_array($data[$name])) {
                     $values = array();
                     foreach ($data[$name] as $val) {
                         $values[] = strip_tags($val);
                     }
                 } else {
                     $values = strip_tags($data[$name]);
                 }
             }
             $q = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'rawValue' => !empty($editData[$name]) ? $editData[$name] : null, 'section' => $sectName, 'custom' => json_decode($question['custom'], true), 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation'], 'options' => self::formatOptionsForQuestion($name, $editOptions), 'order' => $question['sortOrder']);
             if (in_array($name, self::$basicNames)) {
                 $editBasic[] = $q;
             } else {
                 $sectionQuestions[] = $q;
             }
         }
         usort($sectionQuestions, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
         $editQuestions[$sectName] = $sectionQuestions;
     }
     $viewQuestionList = array();
     $editQuestionList = array();
     $viewSectionList = array();
     $editSectionList = array();
     foreach ($viewSections as $section) {
         unset($section['index']);
         $viewSectionList[] = $section;
         $viewQuestionList[] = empty($viewQuestions[$section["name"]]) ? array() : $viewQuestions[$section["name"]];
     }
     foreach ($editSections as $section) {
         unset($section['index']);
         $editSectionList[] = $section;
         $editQuestionList[] = empty($editQuestions[$section["name"]]) ? array() : $editQuestions[$section["name"]];
     }
     $this->assign('viewQuestions', $viewQuestionList);
     $this->assign('editQuestions', $editQuestionList);
     $this->assign('viewSections', $viewSectionList);
     $this->assign('editSections', $editSectionList);
     $this->assign('viewBasic', $viewBasic);
     $this->assign('editBasic', $editBasic);
     $this->assign('isBlocked', BOL_UserService::getInstance()->isBlocked($userId, OW::getUser()->getId()));
     $pm = OW::getPluginManager();
     $isBookmarked = $pm->isPluginActive('bookmarks') && BOOKMARKS_BOL_Service::getInstance()->isMarked(OW::getUser()->getId(), $userId);
     $this->assign('isBookmarked', $isBookmarked);
     $isWinked = $pm->isPluginActive('winks') && WINKS_BOL_Service::getInstance()->isLimited(OW::getUser()->getId(), $userId);
     $this->assign('isWinked', $isWinked);
     $isAdmin = BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser($userId, BOL_AuthorizationService::ADMIN_GROUP_NAME);
     $this->assign('isAdmin', $isAdmin);
     $auth = array('base.view_profile' => $service->getAuthorizationActionStatus('base', 'view_profile'), 'photo.upload' => $service->getAuthorizationActionStatus('photo', 'upload'), 'photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     // track guests
     if ($userId != OW::getUser()->getId()) {
         $event = new OW_Event('guests.track_visit', array('userId' => $userId, 'guestId' => OW::getUser()->getId()));
         OW::getEventManager()->trigger($event);
     }
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks') && OW::getPluginManager()->isPluginActive('mailbox')));
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
Example #7
0
 public function baseUserSuspend(OW_Event $event)
 {
     $params = $event->getParams();
     WINKS_BOL_Service::getInstance()->setStatusByUserId($params['userId'], WINKS_BOL_WinksDao::STATUS_IGNORE);
 }
Example #8
0
 public function onRenderWinkBackInMailbox(OW_Event $event)
 {
     $params = $event->getParams();
     $data = array();
     $data['eventName'] = 'renderWinkBack';
     if (empty($params['winkId']) || ($wink = WINKS_BOL_Service::getInstance()->findWinkById($params['winkId'])) === NULL) {
         $data['text'] = '';
     } else {
         if ($wink->getUserId() == OW::getUser()->getId()) {
             $data['text'] = BOL_UserService::getInstance()->getDisplayName($wink->getPartnerId()) . ' ' . OW::getLanguage()->text('winks', 'wink_back_message_owner');
         } else {
             $data['text'] = OW::getLanguage()->text('winks', 'winked_back_msg');
         }
     }
     $data['winkBackEnabled'] = false;
     $event->setData($data);
 }
Example #9
0
 public function winkBack(OW_Event $event)
 {
     $params = $event->getParams();
     $service = WINKS_BOL_Service::getInstance();
     if (empty($params['userId']) || empty($params['partnerId']) || empty($params['messageId']) || ($wink = $service->findWinkByUserIdAndPartnerId($params['userId'], $params['partnerId'])) === NULL) {
         $event->setData(array('result' => FALSE, 'msg' => OW::getLanguage()->text('winks', 'wink_back_error')));
         return $event->getData();
     }
     if (!$service->isWinkBacked($wink->getId()) && $service->setWinkback($wink->getId(), TRUE)) {
         if (empty($params['sendNotification']) && OW::getPluginManager()->isPluginActive('notifications')) {
             $rule = NOTIFICATIONS_BOL_Service::getInstance()->findRuleList($wink->userId, array('wink_email_notification'));
             if (!isset($rule['wink_email_notification']) || (int) $rule['wink_email_notification']->checked) {
                 $service->sendWinkEmailNotification($wink->partnerId, $wink->userId, WINKS_BOL_Service::EMAIL_BACK);
             }
         }
         $winkBackEvent = new OW_Event('winks.onWinkBack', array('userId' => $wink->getUserId(), 'partnerId' => $wink->getPartnerId(), 'conversationId' => $wink->getConversationId(), 'content' => array('entityType' => 'wink', 'eventName' => 'renderWinkBack', 'params' => array('winkId' => $wink->id, 'messageId' => $params['messageId']))));
         OW::getEventManager()->trigger($winkBackEvent);
         $event->setData(array('result' => true, 'userId' => $wink->getUserId(), 'partnerId' => $wink->getPartnerId()));
     } else {
         $event->setData(array('result' => FALSE, 'msg' => OW::getLanguage()->text('winks', 'wink_back_error')));
     }
     return $event->getData();
 }
Example #10
0
 public function getQuestions($post, $params)
 {
     if (empty($params['id'])) {
         throw new ApiResponseErrorException();
     }
     $userId = (int) $params['id'];
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         throw new ApiResponseErrorException();
     }
     $service = SKANDROID_ABOL_Service::getInstance();
     $questionService = BOL_QuestionService::getInstance();
     $accountType = OW::getUser()->getUserObject()->accountType;
     $viewQuestionList = $questionService->findViewQuestionsForAccountType($accountType);
     /* $viewNames = array();
     
             foreach ( $viewQuestionList as $viewQuestion )
             {
                 $viewNames[] = $viewQuestion['name'];
             } */
     $viewQuestionList = BOL_UserService::getInstance()->getUserViewQuestions($userId, false);
     $viewSections = array();
     $sortedSections = $questionService->findSortedSectionList();
     foreach ($viewQuestionList['questions'] as $sectionName => $section) {
         if ($sectionName == 'location') {
             continue;
         }
         $order = 0;
         foreach ($sortedSections as $sorted) {
             if ($sorted->name == $sectionName) {
                 $order = $sorted->sortOrder;
             }
         }
         $viewSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
     }
     usort($viewSections, array('SKANDROID_ACTRL_User', 'sortSectionsAsc'));
     $viewQuestions = array();
     $viewBasic = array();
     $data = $viewQuestionList['data'][$userId];
     $sectionIndex = 0;
     foreach ($viewQuestionList['questions'] as $sectName => $section) {
         $sectionQstions = array();
         foreach ($section as $question) {
             $name = $question['name'];
             if (is_array($data[$name])) {
                 $values = array();
                 foreach ($data[$name] as $val) {
                     $values[] = strip_tags($val);
                 }
             } else {
                 $values = strip_tags($data[$name]);
             }
             if (in_array($name, self::$basicNames)) {
                 if ($name == 'sex') {
                     $v = array_values($values);
                     $viewBasic[$name] = array_shift($v);
                 } else {
                     $viewBasic[$name] = $values;
                 }
             } else {
                 $sectionQstions[] = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'section' => $sectName, 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation']);
             }
         }
         $viewQuestions[] = $sectionQstions;
     }
     $viewBasic['online'] = (bool) BOL_UserService::getInstance()->findOnlineUserById($userId);
     $viewBasic['avatar'] = self::dataForUserAvatar($userId);
     // compatibility
     if ($userId != OW::getUser()->getId()) {
         $viewBasic['compatibility'] = OW::getEventManager()->call("matchmaking.get_compatibility", array("firstUserId" => OW::getUser()->getId(), "secondUserId" => $userId));
     } else {
         $viewBasic['compatibility'] = null;
     }
     // edit questions
     $editQuestionList = $questionService->findEditQuestionsForAccountType($accountType);
     $editNames = array();
     foreach ($editQuestionList as $editQuestion) {
         $editNames[] = $editQuestion['name'];
     }
     //$editQuestionList = $this->getUserEditQuestions($userId, $editNames);
     $editOptions = $questionService->findQuestionsValuesByQuestionNameList($editNames);
     $editData = $questionService->getQuestionData(array($userId), $editNames);
     $editData = !empty($editData[$userId]) ? $editData[$userId] : array();
     $editSections = array();
     $editQuestions = array();
     $i = 0;
     $sectionName = null;
     foreach ($editQuestionList as $question) {
         if (in_array($question['name'], array('email'))) {
             continue;
         }
         if ($sectionName != $question['sectionName']) {
             if ($sectionName != null) {
                 $i++;
             }
             $sectionName = $question['sectionName'];
             $order = 0;
             foreach ($sortedSections as $sorted) {
                 if ($sorted->name == $sectionName) {
                     $order = $sorted->sortOrder;
                 }
             }
             $editSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
             $editQuestions[] = array();
         }
         $name = $question['name'];
         $custom = json_decode($question['custom'], true);
         $options = self::formatOptionsForQuestion($name, $editOptions);
         $value = !empty($editData[$name]) ? $editData[$name] : null;
         if ($name == 'googlemap_location' && !empty($value)) {
             $value = json_encode($value);
         } elseif ($name == 'match_age') {
             $birthday = $questionService->findQuestionByName('birthdate');
             if ($birthday !== null && mb_strlen(trim($birthday->custom)) > 0) {
                 $custom = json_decode($birthday->custom, true);
             }
         }
         $q = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $value, 'section' => $question['sectionName'], 'custom' => empty($custom) ? null : array_merge(array('custom' => 'custom'), $custom), 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation'], 'required' => $question['required'], 'options' => !empty($options['values']) ? $options['values'] : array());
         $editQuestions[$i][] = $q;
     }
     usort($editSections, array('SKANDROID_ACTRL_User', 'sortSectionsAsc'));
     $this->assign('viewQuestions', $viewQuestions);
     $this->assign('editQuestions', $editQuestions);
     $viewSectionList = array();
     $editSectionList = array();
     foreach ($viewSections as $section) {
         unset($section['index']);
         $viewSectionList[] = $section;
     }
     foreach ($editSections as $section) {
         unset($section['index']);
         $editSectionList[] = $section;
     }
     $adat = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("googlemap_location"));
     $viewBasic["location"] = empty($adat[$userId]["googlemap_location"]["json"]) ? null : $adat[$userId]["googlemap_location"]["address"];
     $this->assign('viewSections', $viewSectionList);
     $this->assign('editSections', $editSectionList);
     $this->assign('viewBasic', $viewBasic);
     $this->assign('isBlocked', BOL_UserService::getInstance()->isBlocked($userId, OW::getUser()->getId()));
     $pm = OW::getPluginManager();
     $isBookmarked = $pm->isPluginActive('bookmarks') && BOOKMARKS_BOL_Service::getInstance()->isMarked(OW::getUser()->getId(), $userId);
     $this->assign('isBookmarked', $isBookmarked);
     $isWinked = $pm->isPluginActive('winks') && WINKS_BOL_Service::getInstance()->isLimited(OW::getUser()->getId(), $userId);
     $this->assign('isWinked', $isWinked);
     $isAdmin = BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser($userId, BOL_AuthorizationService::ADMIN_GROUP_NAME);
     $this->assign('isAdmin', $isAdmin);
     $auth = array('base.view_profile' => $service->getAuthorizationActionStatus('base', 'view_profile'), 'photo.upload' => $service->getAuthorizationActionStatus('photo', 'upload'), 'photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     // track guests
     if ($userId != OW::getUser()->getId()) {
         $event = new OW_Event('guests.track_visit', array('userId' => $userId, 'guestId' => OW::getUser()->getId()));
         OW::getEventManager()->trigger($event);
     }
     //printVar($this->assignedVars); exit;
 }