Beispiel #1
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);
 }
Beispiel #2
0
 public function customPage(array $params)
 {
     if (empty($params['key'])) {
         $this->assign('content', '');
         return;
     }
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $this->assign('content', $service->getCustomPage($params['key']));
 }
Beispiel #3
0
 public function getMenu($userId, $type = 'main')
 {
     $items = array();
     $pm = OW::getPluginManager();
     switch ($type) {
         case 'main':
             if ($pm->isPluginActive("usearch")) {
                 $items[] = array('key' => 'Search', 'label' => 'Search', 'counter' => 0);
             }
             if ($pm->isPluginActive('mailbox')) {
                 $activeModes = MAILBOX_BOL_ConversationService::getInstance()->getActiveModeList();
                 $messageList = MAILBOX_BOL_MessageDao::getInstance()->findUnreadMessages($userId, array(), time(), $activeModes);
                 $count = count($messageList);
                 // Hot fix. TODO refactor
                 //$count = MAILBOX_BOL_ConversationService::getInstance()->getUnreadMessageCount($userId);
                 $items[] = array('key' => 'Mailbox', 'label' => 'Messages', 'counter' => $count);
             }
             if ($pm->isPluginActive('matchmaking')) {
                 $items[] = array('key' => 'Matches', 'label' => 'My Matches', 'counter' => 0);
                 if ($pm->isPluginActive("googlelocation")) {
                     $items[] = array('key' => 'SpeedMatch', 'label' => 'SpeedMatch', 'counter' => 0);
                 }
             }
             if ($pm->isPluginActive('ocsguests')) {
                 $count = OW::getEventManager()->call('guests.get_new_guests_count', array('userId' => $userId));
                 $items[] = array('key' => 'Guests', 'label' => 'Guests', 'counter' => $count);
             }
             if ($pm->isPluginActive('bookmarks')) {
                 $items[] = array('key' => 'Bookmarks', 'label' => 'Bookmarks', 'counter' => 0);
             }
             if (SKADATEIOS_ABOL_Service::getInstance()->isBillingEnabled()) {
                 $label = 'Membership & Credits';
                 if (!$pm->isPluginActive("usercredits")) {
                     $label = "membership";
                 }
                 if (!$pm->isPluginActive("membership")) {
                     $label = "credits";
                 }
                 $items[] = array('key' => 'Billing', 'label' => $label, 'counter' => 0);
             } else {
                 $items[] = array('key' => 'About', 'label' => 'About', 'counter' => 0);
             }
             break;
         case 'bottom':
             //$items[] = array('key' => 'Desktop', 'label' => 'Desktop Version', 'url' => OW_URL_HOME . 'desktop-version');
             $items[] = array('key' => 'Terms', 'label' => 'Terms & Policies', 'custom' => true);
             break;
     }
     return $items;
 }
Beispiel #4
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);
 }
Beispiel #5
0
 public function onPingNotifications(OW_Event $event)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return null;
     }
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $menu = $service->getMenu(OW::getUser()->getId());
     $counter = $service->getNewItemsCount($menu);
     $data = array('menu' => $menu, 'counter' => $counter);
     $eventData = $event->getData();
     if (empty($eventData)) {
         $data = array('menu' => $menu, 'counter' => $counter);
     } else {
         if (is_array($eventData)) {
             $data = array_merge($eventData, $data);
         }
     }
     $event->setData($data);
     return $data;
 }
Beispiel #6
0
 public function getMessages($params)
 {
     if (!OW::getUser()->isAuthenticated()) {
         $this->assign("result", array('list' => array()));
         return;
     }
     $userId = OW::getUser()->getId();
     $opponentId = empty($params["userId"]) ? null : $params["userId"];
     $conversationId = empty($params['conversationId']) ? null : $params['conversationId'];
     $result = OW::getEventManager()->call('mailbox.get_messages', array('userId' => $userId, 'conversationId' => $conversationId, "opponentId" => $opponentId));
     foreach ($result['list'] as &$message) {
         if (!empty($message["text"]) && is_string($message["text"])) {
             $message["text"] = strip_tags($message["text"]);
         }
     }
     $this->assign('list', $result['list']);
     $this->assign('length', $result['length']);
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('mailbox.read_chat_message' => $service->getAuthorizationActionStatus('mailbox', 'read_chat_message'), 'mailbox.send_chat_message' => $service->getAuthorizationActionStatus('mailbox', 'send_chat_message'), 'mailbox.reply_to_chat_message' => $service->getAuthorizationActionStatus('mailbox', 'reply_to_chat_message'), 'mailbox.read_message' => $service->getAuthorizationActionStatus('mailbox', 'read_message'), 'mailbox.send_message' => $service->getAuthorizationActionStatus('mailbox', 'send_message'), 'mailbox.reply_to_message' => $service->getAuthorizationActionStatus('mailbox', 'reply_to_message'));
     $this->assign('auth', $auth);
 }
Beispiel #7
0
 public function getUser($params)
 {
     $viewerId = OW::getUser()->getId();
     $users = OW::getEventManager()->call("speedmatch.suggest_users", array("userId" => $viewerId, "criteria" => !empty($params["criteria"]) ? $params["criteria"] : null, "first" => empty($params["first"]) ? 0 : $params["first"], "count" => empty($params["count"]) ? 1 : $params["count"], "exclude" => array()));
     if (empty($users[0])) {
         $this->assign('userId', null);
         return;
     }
     $userId = $users[0];
     $questionService = BOL_QuestionService::getInstance();
     $accountType = BOL_UserService::getInstance()->findUserById($userId)->accountType;
     $viewQuestionList = $questionService->findViewQuestionsForAccountType($accountType);
     $mainNames = array();
     $extraNames = array();
     foreach ($viewQuestionList as $viewQuestion) {
         $name = $viewQuestion['name'];
         if (in_array($name, self::$basicNames)) {
             continue;
         }
         if (in_array($name, self::$priorityNames)) {
             $mainNames[] = $name;
         } else {
             $extraNames[] = $name;
         }
     }
     $viewNames = count($extraNames) ? array_merge($mainNames, $extraNames) : $mainNames;
     if (count($viewNames) > self::QUESTIONS_DISPLAY_LIMIT) {
         $viewNames = array_slice($viewNames, 0, self::QUESTIONS_DISPLAY_LIMIT);
     }
     $viewQuestionList = BOL_UserService::getInstance()->getUserViewQuestions($userId, false, $viewNames);
     $questions = array();
     foreach ($viewQuestionList['questions'] as $section) {
         foreach ($section as $question) {
             $questions[$question['name']] = $question;
         }
     }
     $viewQuestions = array();
     $data = isset($viewQuestionList['data'][$userId]) ? $viewQuestionList['data'][$userId] : array();
     foreach ($viewNames as $name) {
         if (!isset($data[$name])) {
             continue;
         }
         if (is_array($data[$name])) {
             $values = array();
             foreach ($data[$name] as $val) {
                 $values[] = strip_tags($val);
             }
         } else {
             $values = strip_tags($data[$name]);
         }
         if (empty($questions[$name])) {
             continue;
         }
         $question = $questions[$name];
         $viewQuestions[] = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'section' => $question['sectionName'], 'custom' => json_decode($question['custom'], true), 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation']);
     }
     $this->assign('questions', $viewQuestions);
     $basicQuestionList = BOL_UserService::getInstance()->getUserViewQuestions($userId, false, self::$basicNames);
     $viewBasic = $basicQuestionList['data'][$userId];
     if (isset($viewBasic['realname'])) {
         $viewBasic['username'] = $viewBasic['realname'];
     }
     if (isset($viewBasic['birthdate'])) {
         $viewBasic['birthdate'] = (int) $viewBasic['birthdate'];
     }
     if (isset($viewBasic['sex'])) {
         $viewBasic['sex'] = reset($viewBasic['sex']);
     }
     $viewBasic['online'] = (bool) BOL_UserService::getInstance()->findOnlineUserById($userId);
     // compatibility
     if ($userId != $viewerId) {
         $viewBasic['compatibility'] = OW::getEventManager()->call("matchmaking.get_compatibility", array("firstUserId" => $viewerId, "secondUserId" => $userId));
     } else {
         $viewBasic['compatibility'] = null;
     }
     $this->assign('basic', $viewBasic);
     $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
     OW::getEventManager()->trigger($event);
     $album = $event->getData();
     $list = !empty($album['photoList']) ? $album['photoList'] : array();
     $photos = array();
     $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
     $avatarMainUrl = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
     if ($avatarMainUrl) {
         $photo0 = SKADATEIOS_ACTRL_Photo::preparePhotoData(0, null);
         $photo0['mainUrl'] = $avatarMainUrl;
         $photo0['thumbUrl'] = $bigAvatar ? $avatarMainUrl : BOL_AvatarService::getInstance()->getAvatarUrl($userId);
         $photos[] = $photo0;
     }
     if ($list) {
         foreach ($list as $photo) {
             $photos[] = SKADATEIOS_ACTRL_Photo::preparePhotoData($photo['id'], $photo['hash'], $photo['dimension']);
         }
     }
     $this->assign('photos', $photos);
     $this->assign('hasAvatar', !empty($avatarMainUrl));
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('base.view_profile' => $service->getAuthorizationActionStatus('base', 'view_profile'), 'photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     $this->assign('userId', $userId);
 }
Beispiel #8
0
 public function setLocation($params)
 {
     $userId = OW::getUser()->getId();
     if (!$userId) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['lat']) || empty($params['lon'])) {
         throw new ApiResponseErrorException();
     }
     $set = SKADATEIOS_ABOL_Service::getInstance()->setUserCurrentLocation($userId, $params['lat'], $params['lon']);
     $this->assign('status', $set);
 }
Beispiel #9
0
 public function albumPhotoList($post, $params)
 {
     $auth = array('photo_view' => SKADATEIOS_ABOL_Service::getInstance()->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     if (empty($params['albumId'])) {
         $this->assign('list', array());
         return;
     }
     $albumId = (int) $params['albumId'];
     $service = PHOTO_BOL_PhotoService::getInstance();
     $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId);
     $selfMode = $album->userId == OW::getUser()->getId();
     $status = $selfMode ? null : PHOTO_BOL_PhotoDao::STATUS_APPROVED;
     $list = $service->getAlbumPhotos($albumId, 1, 500, null, $status);
     if ($list) {
         $result = array();
         foreach ($list as $photo) {
             $result[] = self::preparePhotoData($photo['dto']->id, $photo['dto']->hash, $photo['dto']->dimension, $photo['dto']->status);
         }
         $list = $result;
     }
     $this->assign('list', $list);
 }
Beispiel #10
0
 private function getBenefits()
 {
     $authService = BOL_AuthorizationService::getInstance();
     $permissionList = $authService->getPermissionList();
     foreach ($permissionList as $permission) {
         /* @var $permission BOL_AuthorizationPermission */
         $permissions[$permission->roleId][$permission->actionId] = true;
     }
     $roleList = $authService->getRoleList();
     $groupList = SKADATEIOS_ABOL_Service::getInstance()->getAuthorizationActions();
     $result = array();
     foreach ($roleList as $role) {
         foreach ($groupList as &$group) {
             foreach ($group['actions'] as &$action) {
                 $action['allowed'] = isset($permissions[$role->id][$action['id']]);
             }
         }
         $result[$role->id] = $groupList;
     }
     return $result;
 }
Beispiel #11
0
 private function respondUserData($userId)
 {
     $avatarService = BOL_AvatarService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->assign("userId", $userId);
     $this->assign("displayName", $userService->getDisplayName($userId));
     $this->assign("avatar", array("url" => $avatarService->getAvatarUrl($userId)));
     $this->assign("suspended", BOL_UserService::getInstance()->isSuspended($userId));
     $this->assign("approved", BOL_UserService::getInstance()->isApproved($userId));
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $mainMenu = $service->getMenu($userId, 'main');
     $this->assign("mainMenu", $mainMenu);
     $bottomMenu = $service->getMenu($userId, 'bottom');
     $this->assign("bottomMenu", $bottomMenu);
     $this->assign('newCounter', $service->getNewItemsCount($mainMenu));
     $token = OW_Auth::getInstance()->getAuthenticator()->getId();
     $this->assign("token", $token);
 }