示例#1
0
 /**
  * Returns class instance
  *
  * @return USEARCH_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
 public function __construct()
 {
     parent::__construct();
     $form = OW::getClassInstance('FEMALEREGONLYMEN_CLASS_QuickSearchForm', $this);
     $this->addForm($form);
     $this->assign('form', $form);
     $this->assign('advancedUrl', OW::getRouter()->urlForRoute('users-search'));
     $this->assign('questions', USEARCH_BOL_Service::getInstance()->getQuickSerchQuestionNames());
 }
示例#3
0
 public function __construct()
 {
     parent::__construct();
     $form = OW::getClassInstance('SELECTGENDER_CLASS_QuickSearchForm', $this);
     $this->addForm($form);
     $config = OW::getConfig();
     $opositeMatchSexSearch = $config->getValue('selectgender', 'opositeMatchSexSearch');
     $sameMatchSexSearch = $config->getValue('selectgender', 'sameMatchSexSearch');
     $isUserRegister = OW::getUser()->isAuthenticated();
     if (OW::getUser()->isAuthenticated()) {
         $userId = OW::getUser()->getId();
         $userSex = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array('sex'));
         $jsParams = array('isUserRegister' => $isUserRegister, 'opositeMatchSexSearch' => $opositeMatchSexSearch, 'sameMatchSexSearch' => $sameMatchSexSearch, 'userSex' => $userSex[$userId]['sex']);
         $script = ' var quickSearch = new SELECTGENDER_QuickSearch(); quickSearch.init(' . json_encode($jsParams) . '); ';
         OW::getDocument()->addOnloadScript($script);
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('selectgender')->getStaticJsUrl() . 'quickSearch.js');
     }
     $this->assign('form', $form);
     $this->assign('advancedUrl', OW::getRouter()->urlForRoute('users-search'));
     $this->assign('questions', USEARCH_BOL_Service::getInstance()->getQuickSerchQuestionNames());
     if (OW::getUser()->isAuthenticated()) {
         $this->assign('userId', OW::getUser()->getId());
     }
 }
 public function __construct($controller)
 {
     parent::__construct('QuickSearchForm');
     $this->questionService = BOL_QuestionService::getInstance();
     $this->searchService = USEARCH_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlForRoute('usearch.quick_search_action'));
     $this->setAjaxResetOnSuccess(false);
     $questionNameList = $this->searchService->getQuickSerchQuestionNames();
     $questionValueList = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $sessionData = OW::getSession()->get(self::FORM_SESSEION_VAR);
     if ($sessionData === null) {
         $sessionData = array();
         if (OW::getUser()->isAuthenticated()) {
             $data = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('sex', 'match_sex'));
             if (!empty($data[OW::getUser()->getId()]['sex'])) {
                 $sessionData['sex'] = $data[OW::getUser()->getId()]['sex'];
             }
             if (!empty($data[OW::getUser()->getId()]['match_sex'])) {
                 for ($i = 0; $i < 31; $i++) {
                     if (pow(2, $i) & $data[OW::getUser()->getId()]['match_sex']) {
                         $sessionData['match_sex'] = pow(2, $i);
                         break;
                     }
                 }
             }
             $sessionData['googlemap_location']['distance'] = 50;
             OW::getSession()->set(self::FORM_SESSEION_VAR, $sessionData);
         }
     }
     if (!empty($sessionData['match_sex'])) {
         if (is_array($sessionData['match_sex'])) {
             $sessionData['match_sex'] = array_shift($sessionData['match_sex']);
         } else {
             for ($i = 0; $i < 31; $i++) {
                 if (pow(2, $i) & $sessionData['match_sex']) {
                     $sessionData['match_sex'] = pow(2, $i);
                     break;
                 }
             }
         }
     }
     /* ------------------------- */
     $questionDtoList = BOL_QuestionService::getInstance()->findQuestionByNameList($questionNameList);
     $questions = array();
     $questionList = array();
     $orderedQuestionList = array();
     /* @var $question BOL_Question */
     foreach ($questionDtoList as $key => $question) {
         $dataList = (array) $question;
         $questions[$question->name] = $dataList;
         $isRequired = in_array($question->name, array('googlemap_location', 'match_sex')) ? 1 : 0;
         $questions[$question->name]['required'] = $isRequired;
         if ($question->name == 'sex' || $question->name == 'match_sex') {
             unset($questions[$question->name]);
         } else {
             $questionList[$question->name] = $dataList;
         }
     }
     foreach ($questionNameList as $questionName) {
         if (!empty($questionDtoList[$questionName])) {
             $orderedQuestionList[] = $questionDtoList[$questionName];
         }
     }
     $controller->assign('displayGender', false);
     $accounts = $this->getAccountTypes();
     $this->addQuestions($questions, $questionValueList, array());
     $locationField = $this->getElement('googlemap_location');
     if ($locationField) {
         $value = $locationField->getValue();
         if (empty($value['distance'])) {
             $locationField->setDistance(50);
         }
     }
     if (count($accounts) > 1) {
         $this->displayAccountType = true;
         $controller->assign('displayGender', true);
         $sex = new Selectbox('sex');
         $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
         $sex->setHasInvitation(false);
         $sex->setRequired();
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
         if (!empty($sessionData['sex'])) {
             $sex->setValue($sessionData['sex']);
         }
         $this->addElement($sex);
         $matchSex = new Selectbox('match_sex');
         $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
         $matchSex->setRequired();
         $matchSex->setHasInvitation(false);
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['sex']);
         if (!empty($sessionData['match_sex']) && !is_array($sessionData['match_sex'])) {
             $matchSex->setValue($sessionData['match_sex']);
         }
         $this->addElement($matchSex);
     }
     $controller->assign('questionList', $orderedQuestionList);
     $controller->assign('displayAccountType', $this->displayAccountType);
     // 'online' field
     $onlineField = new CheckboxField('online');
     if (is_array($sessionData) && array_key_exists('online', $sessionData)) {
         $onlineField->setValue((int) $sessionData['online']);
     }
     $onlineField->setLabel($lang->text('usearch', 'online_only'));
     $this->addElement($onlineField);
     //        if ( OW::getPluginManager()->isPluginActive('photo') )
     //        {
     // with photo
     $withPhoto = new CheckboxField('with_photo');
     if (is_array($sessionData) && array_key_exists('with_photo', $sessionData)) {
         $withPhoto->setValue((int) $sessionData['with_photo']);
     }
     $withPhoto->setLabel($lang->text('usearch', 'with_photo'));
     $this->addElement($withPhoto);
     //        }
     // submit
     $submit = new Submit('search');
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( data.result ) {\n                document.location.href = data.url;\n            }\n            else {\n                OW.warning(data.error);\n            }\n        }");
 }
示例#5
0
$BOL_UserDao = BOL_UserDao::getInstance();
$ow_user = OW::getUser();
$OW_Auth_inst = OW_Auth::getInstance();
$Userservice = BOL_UserService::getInstance();
$EmailVerifyService = BOL_EmailVerifyService::getInstance();
$BOL_AvatarService_inst = BOL_AvatarService::getInstance();
$SKAPI_BOL_Service_inst = SKAPI_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService_inst = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$PHOTO_BOL_PhotoTemporaryService = PHOTO_BOL_PhotoTemporaryService::getInstance();
$UserResetPassword = BOL_UserResetPasswordDao::getInstance();
$QuestionService = BOL_QuestionService::getInstance();
$AccountTypeToGenderService = SKADATE_BOL_AccountTypeToGenderService::getInstance();
$BOL_AuthorizationService = BOL_AuthorizationService::getInstance();
$BOL_UserOnlineDao = BOL_UserOnlineDao::getInstance();
$USEARCH_BOL_Service = USEARCH_BOL_Service::getInstance();
$BOL_SearchService = BOL_SearchService::getInstance();
$getPluginManager = OW::getPluginManager();
$CONTACTUS_BOL_Service = CONTACTUS_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumCoverDao = PHOTO_BOL_PhotoAlbumCoverDao::getInstance();
$PHOTO_BOL_PhotoDao = PHOTO_BOL_PhotoDao::getInstance();
$getRouter = OW::getRouter();
$language = OW::getLanguage();
$getMailer = OW::getMailer();
$getConfig = OW::getConfig();
$getFeedback = OW::getFeedback();
$getEventManager = OW::getEventManager();
$getMailer = OW::getMailer();
$ow = OW_DB_PREFIX;
$LanguageService = BOL_LanguageService::getInstance();
 public function isValid($data)
 {
     $valid = true;
     if (!is_array($data)) {
         throw new InvalidArgumentException('Array should be provided for validation!');
     }
     $matchSex = !empty($data['match_sex']) ? $data['match_sex'] : null;
     if ($matchSex) {
         $accounType = USEARCH_BOL_Service::getInstance()->getAccounTypeByGender($matchSex);
         $visibilityList = $this->getVisibilityList($accounType, $this->mainSearchQuestionList);
     }
     /* @var $element FormElement */
     foreach ($this->elements as $element) {
         $element->setValue(isset($data[$element->getName()]) ? $data[$element->getName()] : null);
         if (!empty($visibilityList['questions']) && isset($visibilityList['questions'][$element->getName()]) && $visibilityList['questions'][$element->getName()] == false) {
             continue;
         }
         if (!$element->isValid()) {
             $valid = false;
         }
     }
     return $valid;
 }
示例#7
0
 public function process($data)
 {
     if (OW::getRequest()->isPost() && !$this->isAjax() && isset($data['form_name']) && $data['form_name'] === $this->getName()) {
         OW::getSession()->set(self::FORM_SESSEION_VAR, $data);
         OW::getSession()->set('usearch_search_data', $data);
         if (isset($data[self::SUBMIT_NAME]) && $this->isValid($data) && !$this->isAjax()) {
             if (!OW::getUser()->isAuthorized('base', 'search_users')) {
                 $status = BOL_AuthorizationService::getInstance()->getActionStatus('base', 'search_users');
                 OW::getFeedback()->warning($status['msg']);
                 $this->controller->redirect();
             }
             //                echo "<pre>";
             //                print_r($data);
             //                exit;
             $data = USEARCH_BOL_Service::getInstance()->updateSearchData($data);
             $addParams = array('join' => '', 'where' => '');
             if ($data['online']) {
                 $addParams['join'] .= " INNER JOIN `" . BOL_UserOnlineDao::getInstance()->getTableName() . "` `online` ON (`online`.`userId` = `user`.`id`) ";
             }
             if ($data['with_photo']) {
                 $addParams['join'] .= " INNER JOIN `" . OW_DB_PREFIX . "base_avatar` avatar ON (`avatar`.`userId` = `user`.`id`) ";
                 //                    $addParams['join'] .= " INNER JOIN `".OW_DB_PREFIX . "photo_album` album ON (`album`.`userId` = `user`.`id`)
                 //                            INNER JOIN `". OW_DB_PREFIX . "photo` `photo` ON (`album`.`id` = `photo`.`albumId`) ";
             }
             $userIdList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($data, 0, BOL_SearchService::USER_LIST_SIZE, false, $addParams);
             $listId = 0;
             if (OW::getUser()->isAuthenticated()) {
                 foreach ($userIdList as $key => $id) {
                     if (OW::getUser()->getId() == $id) {
                         unset($userIdList[$key]);
                     }
                 }
             }
             if (count($userIdList) > 0) {
                 $listId = BOL_SearchService::getInstance()->saveSearchResult($userIdList);
             }
             OW::getSession()->set(BOL_SearchService::SEARCH_RESULT_ID_VARIABLE, $listId);
             BOL_AuthorizationService::getInstance()->trackAction('base', 'search_users');
             $this->controller->redirect(OW::getRouter()->urlForRoute("users-search-result", array()));
         }
         $this->controller->redirect(OW::getRouter()->urlForRoute("users-search"));
     }
 }
示例#8
0
 public function searchResult($params)
 {
     //OW::getSession()->set(BOL_SearchService::SEARCH_RESULT_ID_VARIABLE,999);
     $listId = OW::getSession()->get(BOL_SearchService::SEARCH_RESULT_ID_VARIABLE);
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $orderType = $this->getOrderType($params);
     if (!OW::getUser()->isAuthenticated()) {
         if (in_array($orderType, array(USEARCH_BOL_Service::LIST_ORDER_MATCH_COMPATIBILITY, USEARCH_BOL_Service::LIST_ORDER_DISTANCE))) {
             throw new Redirect404Exception();
         }
     }
     $limit = 16;
     $itemCount = BOL_SearchService::getInstance()->countSearchResultItem($listId);
     $list = USEARCH_BOL_Service::getInstance()->getSearchResultList($listId, $orderType, ($page - 1) * $limit, $limit);
     $idList = array();
     foreach ($list as $dto) {
         $idList[] = $dto->id;
     }
     $searchResultMenu = $this->searchResultMenu($orderType);
     if (!empty($searchResultMenu)) {
         $this->addComponent('searchResultMenu', $searchResultMenu);
     }
     $cmp = OW::getClassInstance('USEARCH_CMP_SearchResultList', $list, $page, $orderType);
     $this->addComponent('cmp', $cmp);
     $script = '$(".back_to_search_button").click(function(){
         window.location = ' . json_encode(OW::getRouter()->urlForRoute('users-search')) . ';
     });  ';
     OW::getDocument()->addOnloadScript($script);
     $jsParams = array('excludeList' => $idList, 'respunderUrl' => OW::getRouter()->urlForRoute('usearch.load_list_action'), 'orderType' => $orderType, 'page' => $page, 'listId' => $listId, 'count' => $limit);
     $script = ' USEARCH_ResultList.init(' . json_encode($jsParams) . ', $(".ow_search_results_photo_gallery_container")); ';
     OW::getDocument()->addOnloadScript($script);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('usearch')->getStaticJsUrl() . 'result_list.js');
     $this->addComponent('menu', $this->getMenu());
     $this->assign('itemCount', $itemCount);
     $this->assign('page', $page);
     $this->assign('searchUrl', OW::getRouter()->urlForRoute('users-search'));
     OW::getDocument()->setHeading(OW::getLanguage()->text('usearch', 'search_result'));
     OW::getDocument()->setDescription(OW::getLanguage()->text('base', 'users_list_user_search_meta_description'));
 }
示例#9
0
 public function getForAndroidSearchResult(OW_Event $e)
 {
     $params = $e->getParams();
     $criteriaList = $params['criterias'];
     $limit = empty($params['limit']) ? array(0, BOL_SearchService::USER_LIST_SIZE) : $params['limit'];
     $sex = !empty($criteriaList['sex']) ? $criteriaList['sex'] : null;
     $match_sex = !empty($criteriaList['match_sex']) ? $criteriaList['match_sex'] : null;
     unset($criteriaList['sex']);
     unset($criteriaList['match_sex']);
     if (!empty($sex)) {
         $criteriaList['match_sex'] = $sex;
     }
     if (!empty($match_sex)) {
         $criteriaList['sex'] = $match_sex;
     }
     $criteriaList = USEARCH_BOL_Service::getInstance()->updateQuickSearchData($criteriaList);
     $criteriaList = USEARCH_BOL_Service::getInstance()->updateSearchData($criteriaList);
     $extra = OW::getUser()->isAuthenticated() ? array("where" => "AND `user`.`id` !=" . OW::getUser()->getId() . " ") : array();
     $userIdList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $limit[0], $limit[1], false, $extra);
     $e->setData($userIdList);
     return $userIdList;
 }
示例#10
0
 public function responder()
 {
     if (!OW::getRequest()->isAjax()) {
         exit(json_encode(array('result' => false)));
     }
     $lang = OW::getLanguage();
     if (!OW::getUser()->isAdmin()) {
         exit(json_encode(array('result' => false)));
     }
     if (isset($_POST['positions']) && is_array($_POST['positions'])) {
         $positions = $_POST['positions'];
         $allowedQuestionNameList = USEARCH_BOL_Service::getInstance()->getAllowedQuickSerchQuestionNames();
         $allowedQuestionNameList['sex'] = 'sex';
         $allowedQuestionNameList['match_sex'] = 'match_sex';
         $positionList = USEARCH_BOL_Service::getInstance()->getPositionList();
         $result = array();
         foreach ($positionList as $position) {
             $result[$position] = null;
             if (!empty($positions[$position]) && in_array($positions[$position], $allowedQuestionNameList)) {
                 $result[$position] = $positions[$position];
                 unset($allowedQuestionNameList[$positions[$position]]);
             }
         }
         USEARCH_BOL_Service::getInstance()->saveQuickSerchQuestionPosition($result);
         exit(json_encode(array('result' => true)));
     } else {
         exit(json_encode(array('result' => false)));
     }
 }
示例#11
0
 public function loadList()
 {
     if (!OW::getRequest()->isAjax() || empty($_POST['command'])) {
         exit(json_encode(array('result' => false)));
     }
     $command = !empty($_POST['command']) ? $_POST['command'] : null;
     $listId = !empty($_POST['listId']) ? (int) $_POST['listId'] : null;
     $orderType = !empty($_POST['orderType']) ? $_POST['orderType'] : null;
     $excludeList = !empty($_POST['excludeList']) ? $_POST['excludeList'] : null;
     $count = !empty($_POST['count']) ? (int) $_POST['count'] : 0;
     $startFrom = !empty($_POST['startFrom']) ? (int) $_POST['startFrom'] : 1;
     $page = !empty($_POST['page']) ? (int) $_POST['page'] : 1;
     $lang = OW::getLanguage();
     //        if ( !OW::getUser()->isAuthorized() )
     //        {
     //            exit(json_encode(array('result' => false, 'error' => $lang->text('usearch', 'action_removefriend_signin_required'))));
     //        }
     if (empty($listId)) {
         exit(json_encode(array('result' => false)));
     }
     switch ($command) {
         case 'getNext':
             $from = ($startFrom - 1) * $count;
             $list = USEARCH_BOL_Service::getInstance()->getSearchResultList($listId, $orderType, $from, $count, $excludeList);
             break;
         case 'getPrev':
             if ($startFrom == 0) {
                 exit(json_encode(array('result' => true, 'items' => array(), 'content' => '')));
             }
             $from = ($startFrom - 1) * $count;
             $list = USEARCH_BOL_Service::getInstance()->getSearchResultList($listId, $orderType, $from, $count, $excludeList);
             break;
     }
     if (empty($list)) {
         exit(json_encode(array('result' => true, 'items' => array(), 'content' => '')));
     }
     $idList = array();
     foreach ($list as $dto) {
         $idList[] = $dto->id;
     }
     $cmp = OW::getClassInstance('USEARCH_CMP_SearchResultList', $list, $page, $orderType);
     exit(json_encode(array('result' => true, 'items' => $idList, 'content' => $cmp->render())));
 }
示例#12
0
 protected function searchResult($params, $listId)
 {
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $orderType = $this->getOrderType($params);
     //bhushan changes
     if (!OW::getUser()->isAuthenticated()) {
         if (in_array($orderType, array(USEARCH_BOL_Service::LIST_ORDER_MATCH_COMPATIBILITY, USEARCH_BOL_Service::LIST_ORDER_DISTANCE))) {
             throw new Redirect404Exception();
         }
         //    }
         //end bhushan changes
         $limit = 16;
         $itemCount = BOL_SearchService::getInstance()->countSearchResultItem($listId);
         $list = USEARCH_BOL_Service::getInstance()->getSearchResultList($listId, $orderType, ($page - 1) * $limit, $limit);
         foreach ($list as $key => $list_id) {
             $ids[] = $list_id->id;
         }
         $user_ids = array();
         $user_data = array();
         if (!empty($ids)) {
             $user_ids = array_values($ids);
             $single_id = $user_ids[0];
         }
         $userinfoData = array();
         $userinfoData = BOL_QuestionService::getInstance()->getQuestionData($user_ids, array('id', 'username', 'realname', 'birthdate', 'googlemap_location'));
         $flag = "1";
         $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars($user_ids, true, true, true, true, $flag);
         //$onlineStatus = $Userservice->findOnlineStatusForUserList($user_ids);
         foreach ($userinfoData as $key => $user) {
             $user_data[] = array("user_id" => $key, "user_name" => $user["username"], "realname" => $user["realname"], "profile_picture" => $avatar[$key]["src"]);
         }
         return $user_data;
     }
 }