Пример #1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return SKADATE_BOL_Service
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Пример #2
0
 public function getList($params)
 {
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'), 'base.search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
     $this->assign('auth', $auth);
     if ($auth["base.search_users"]["status"] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         $this->assign("list", array());
         $this->assign("total", 0);
         return;
     }
     $_criteriaList = array_filter($params["criteriaList"]);
     $userId = OW::getUser()->getId();
     $userInfo = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("sex"));
     $_criteriaList["sex"] = !empty($userInfo[$userId]["sex"]) ? $userInfo[$userId]["sex"] : null;
     $questionList = BOL_QuestionService::getInstance()->findQuestionByNameList(array_keys($_criteriaList));
     $criteriaList = array();
     foreach ($_criteriaList as $questionName => $questionValue) {
         if (empty($questionList[$questionName])) {
             continue;
         }
         $criteriaList[$questionName] = $this->convertQuestionValue($questionList[$questionName]->presentation, $questionValue);
     }
     $idList = OW::getEventManager()->call("usearch.get_user_id_list", array("criterias" => $criteriaList, "limit" => array($params["first"], $params["count"])));
     $idList = empty($idList) ? array() : $idList;
     //$idList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $params["first"], $params["count"]);
     $total = BOL_UserService::getInstance()->countUsersByQuestionValues($params["criteriaList"]);
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatarList = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         foreach ($photos as $photo) {
             $photoList[$userId][] = array("src" => $photo["url"]["main"]);
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "photos" => empty($photoList[$userId]) ? array() : $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $this->assign("total", $total);
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
     BOL_AuthorizationService::getInstance()->trackAction("base", "search_users");
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
Пример #3
0
 public function getList($params)
 {
     $sort = empty($params["sort"]) ? "newest" : $params["sort"];
     $matchList = OW::getEventManager()->call("matchmaking.get_list", array("userId" => OW::getUser()->getId(), "sort" => $sort, "first" => empty($params["first"]) ? 0 : $params["first"], "count" => empty($params["count"]) ? 0 : $params["count"]));
     $idList = array();
     $compatibilityList = array();
     foreach ($matchList as $item) {
         $idList[] = $item["id"];
         $compatibilityList[$item["id"]] = $item["compatibility"];
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatarList = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         $photoList[$userId] = array();
         foreach ($photos as $photo) {
             $photoList[$userId][] = array("src" => $photo["url"]["main"]);
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "photos" => $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "compatibility" => $compatibilityList[$userId], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $total = OW::getEventManager()->call("matchmaking.get_list_count", array("userId" => OW::getUser()->getId()));
     $this->assign("total", $total);
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
Пример #4
0
 public function getList($params)
 {
     $idList = OW::getEventManager()->call('hotlist.get_id_list');
     $avatarList = $list = array();
     $skadateService = SKADATE_BOL_Service::getInstance();
     $avatarService = BOL_AvatarService::getInstance();
     $defaultAvatar = $avatarService->getDefaultAvatarUrl(2);
     foreach ($skadateService->findAvatarListByUserIdList($idList) as $avatar) {
         $avatarList[$avatar->userId] = $skadateService->getAvatarUrl($avatar->userId, $avatar->hash);
     }
     foreach (array_diff($idList, array_keys($avatarList)) as $_userId) {
         $avatarList[$_userId] = $avatarService->getAvatarUrl($_userId, 2);
     }
     foreach ($idList as $userId) {
         $list[] = array('userId' => $userId, 'avatar' => isset($avatarList[$userId]) ? $avatarList[$userId] : $defaultAvatar);
     }
     $this->assign('list', $list);
     $this->commonHandler($params);
 }
Пример #5
0
 public function suggestSpeedmatchUsers(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = $params["userId"];
     $first = (int) $params["first"];
     $count = (int) $params["count"];
     $service = SKADATE_BOL_Service::getInstance();
     $list = $service->findSpeedmatchOpponents($userId, $first, $count, $params['criteria']);
     $event->setData($list);
     return $list;
 }
Пример #6
0
 public function skipUser($params)
 {
     $userId = OW::getUser()->getId();
     if (!$userId) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['userId'])) {
         throw new ApiResponseErrorException();
     }
     $oppUserId = (int) $params['userId'];
     $result = SKADATE_BOL_Service::getInstance()->addSpeedmatchRelation($userId, $oppUserId, 0);
     $this->assign('result', $result);
 }
Пример #7
0
 public function __construct()
 {
     parent::__construct();
     $this->service = SKADATE_BOL_Service::getInstance();
 }
Пример #8
0
 public function getList($params)
 {
     $service = SKANDROID_ABOL_Service::getInstance();
     $auth = array('photo_view' => $service->getAuthorizationActionStatus('photo', 'view'), 'base_search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
     $this->assign('auth', $auth);
     if ($auth["base_search_users"]["status"] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         $this->assign("list", array());
         $this->assign("total", 0);
         return;
     }
     $_criteriaList = array_filter(json_decode($params["criteriaList"], true));
     $userId = OW::getUser()->getId();
     $userInfo = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("sex", 'match_sex'));
     $_criteriaList["sex"] = !empty($userInfo[$userId]["sex"]) ? $userInfo[$userId]["sex"] : null;
     if (OW::getPluginManager()->isPluginActive('googlelocation')) {
         $location = null;
         $json = null;
         if (!empty($_criteriaList["current_location"]) && $_criteriaList["current_location"] != "false" && !empty($_criteriaList["current_location_address"])) {
             $location = !empty($_criteriaList["current_location_address"]) ? json_decode($_criteriaList["current_location_address"], true) : null;
             $json = $_criteriaList["current_location_address"];
         } else {
             if (!empty($_criteriaList["custom_location"])) {
                 $location = !empty($_criteriaList["custom_location"]) ? json_decode($_criteriaList["custom_location"], true) : null;
                 $json = $_criteriaList["custom_location"];
             }
         }
         if (!empty($location)) {
             $value = array('distance' => !empty($_criteriaList['distance']) ? $_criteriaList['distance'] : 0, 'address' => $location['address'], 'latitude' => $location['latitude'], 'longitude' => $location['longitude'], 'northEastLat' => $location['northEastLat'], 'northEastLng' => $location['northEastLng'], 'southWestLat' => $location['southWestLat'], 'southWestLng' => $location['southWestLng'], 'json' => $json);
             $_criteriaList['googlemap_location'] = $value;
         }
     }
     unset($_criteriaList["current_location"]);
     unset($_criteriaList["current_location_address"]);
     unset($_criteriaList["custom_location"]);
     $questionList = BOL_QuestionService::getInstance()->findQuestionByNameList(array_keys($_criteriaList));
     $criteriaList = array();
     foreach ($_criteriaList as $questionName => $questionValue) {
         if (empty($questionList[$questionName])) {
             continue;
         }
         $criteriaList[$questionName] = $this->convertQuestionValue($questionList[$questionName]->presentation, $questionValue);
     }
     if (empty($criteriaList['match_sex']) && !empty($userInfo[$userId]["match_sex"])) {
         $criteriaList['match_sex'] = $userInfo[$userId]["match_sex"];
     }
     $idList = OW::getEventManager()->call("usearch.get_user_id_list_for_android", array("criterias" => $criteriaList, "limit" => array($params["first"], $params["count"])));
     $idList = empty($idList) ? array() : $idList;
     //$idList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $params["first"], $params["count"]);
     $total = BOL_UserService::getInstance()->countUsersByQuestionValues($criteriaList);
     //$idList = empty($idList) ? array() : $idList;
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($idList);
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatars = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         if ($bigAvatar) {
             $avatars[$userId] = SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash);
         } else {
             $avatars[$userId] = BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
             if ($avatars[$userId] == BOL_AvatarService::getInstance()->getDefaultAvatarUrl(2)) {
                 unset($avatars[$userId]);
             }
         }
         foreach ($photos as $photo) {
             if ($photo['status'] == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
                 $photoList[$userId][] = array("src" => $photo["url"]["main"]);
             }
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "avatar" => !empty($avatars[$userId]) ? $avatars[$userId] : "", "photos" => empty($photoList[$userId]) ? array() : $photoList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "displayName" => !empty($displayNames[$userId]) ? $displayNames[$userId] : "", "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $this->assign("total", $total);
     BOL_AuthorizationService::getInstance()->trackAction("base", "search_users");
 }
Пример #9
0
 public function getList($params)
 {
     $userId = !empty($params['userId']) ? $params['userId'] : OW::getUser()->getId();
     $page = !empty($params['page']) ? abs((int) $params['page']) : 1;
     $limit = !empty($params['limit']) ? abs((int) $params['limit']) : self::COUNT;
     $first = ($page - 1) * $limit;
     $countMatches = $this->getUserCountMatches($userId);
     if (empty($countMatches)) {
         $this->assign('list', array());
         return;
     }
     $sort = !empty($params['sort']) && $this->isAvailableSort($params['sort']) ? $params['sort'] : $this->getDefaultSort();
     $matchList = $this->getUserMatches($userId, $sort, $first, $limit);
     if (empty($matchList)) {
         $this->assign('list', array());
         return;
     }
     $userIdList = array();
     $compatibilityList = array();
     foreach ($matchList as $item) {
         $userIdList[] = $item['id'];
         $compatibilityList[$item['id']] = $item['compatibility'];
     }
     //        $userRoleList = array();
     //
     //        foreach ( BOL_AuthorizationService::getInstance()->getRoleListOfUsers($userIdList) as $role )
     //        {
     //            $userRoleList[$role['userId']] = array('label' => $role['label'], 'custom' => $role['custom']);
     //        }
     $userData = array();
     $displayNameList = BOL_UserService::getInstance()->getDisplayNamesForList($userIdList);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($userIdList, array('googlemap_location', 'birthdate'));
     foreach ($questionsData as $_userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$_userId]['ages'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$_userId]['displayName'] = $displayNameList[$_userId];
         $userData[$_userId]['location'] = empty($data['googlemap_location']['address']) ? '' : $data['googlemap_location']['address'];
     }
     $avatarList = array();
     $skadateService = SKADATE_BOL_Service::getInstance();
     foreach ($skadateService->findAvatarListByUserIdList($userIdList) as $avatar) {
         $avatarList[$avatar->userId] = $skadateService->getAvatarUrl($avatar->userId, $avatar->hash);
     }
     foreach (array_diff($userIdList, array_keys($avatarList)) as $_userId) {
         $avatarList[$_userId] = BOL_AvatarService::getInstance()->getAvatarUrl($_userId, 2);
     }
     $list = array();
     $authorizeMsg = '';
     $bookmarksList = $this->getUserBookmarkList($userId, $userIdList);
     $isAuthorized = $isSubscribe = OW::getUser()->isAuthorized('photo', 'view');
     if (!$isAuthorized) {
         $status = SKANDROID_ABOL_Service::getInstance()->getAuthorizationActionStatus('photo', 'view');
         $isSubscribe = $status['status'] == BOL_AuthorizationService::STATUS_PROMOTED;
         $authorizeMsg = $status['msg'];
     }
     foreach ($userIdList as $userId) {
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $userPhotos = array();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         foreach ($photos as $photo) {
             if ($photo['status'] == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
                 $userPhotos[] = $photo['url']['main'];
             }
         }
         $list[] = array('userId' => $userId, 'isAuthorized' => $isAuthorized, 'isSubscribe' => $isSubscribe, 'displayName' => $userData[$userId]['displayName'], 'compatibility' => $compatibilityList[$userId], 'location' => $userData[$userId]['location'], 'ages' => $userData[$userId]['ages'], 'bookmarked' => !empty($bookmarksList[$userId]), 'avatar' => !empty($avatarList[$userId]) ? $avatarList[$userId] : null, 'photos' => $userPhotos, 'authorizeMsg' => $authorizeMsg);
     }
     $this->assign('list', $list);
 }
Пример #10
0
 private static function dataForUserAvatar($userId)
 {
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId), true, false);
     $result = $avatar[$userId];
     if (!empty($result['labelColor'])) {
         $color = explode(', ', trim($result['labelColor'], 'rgba()'));
         $result['labelColor'] = array('r' => $color[0], 'g' => $color[1], 'b' => $color[2]);
     } else {
         $result['labelColor'] = array('r' => '100', 'g' => '100', 'b' => '100');
     }
     $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
     $result["bigAvatarUrl"] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2, null, true, false);
     if (($avatar = BOL_AvatarService::getInstance()->findByUserId($userId)) !== null) {
         $result["approved"] = $avatar->getStatus() == BOL_ContentService::STATUS_ACTIVE;
     }
     return $result;
 }