예제 #1
0
function advance_search()
{
    global $USEARCH_BOL_Service;
    global $Userservice;
    global $BOL_SearchService;
    global $BOL_UserOnlineDao;
    global $ow;
    global $PARAM_OPTION_DEFAULT_VALUE;
    global $BOL_AuthorizationService;
    global $SEARCH_RESULT_ID_VARIABLE;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $user_id = $app->request()->params('user_id');
    $location = $app->request()->params('location');
    $match_sex = $app->request()->params('match_sex');
    $sex = $app->request()->params('sex');
    $distance = $app->request()->params('miles_from');
    $online = $app->request()->params('online');
    $age_min = $app->request()->params('age_min');
    $age_max = $app->request()->params('age_max');
    $with_photo = $app->request()->params('with_photo');
    $realname = $app->request()->params('realname');
    $available = $app->request()->params('available');
    $services = $app->request()->params(HAMMU_DB_SERVICES_KEY);
    $serach_services = explode(",", $services);
    $urlencode_address = urlencode($location);
    $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false');
    $output = json_decode($geocode);
    if (!empty($output->results[0]->geometry->location->lng)) {
        $data_location['address'] = $output->results[0]->formatted_address;
        $data_location['latitude'] = $output->results[0]->geometry->location->lat;
        $data_location['longitude'] = $output->results[0]->geometry->location->lng;
        $data_location['northEastLat'] = $output->results[0]->geometry->viewport->northeast->lat;
        $data_location['northEastLng'] = $output->results[0]->geometry->viewport->northeast->lng;
        $data_location['southWestLat'] = $output->results[0]->geometry->viewport->southwest->lat;
        $data_location['southWestLng'] = $output->results[0]->geometry->viewport->southwest->lng;
        $data_location['json'] = json_encode($output->results[0]);
        $data_location['distance'] = $distance;
        $data_arr = array("form_name" => "MainSearchForm", "sex" => $sex, "match_sex" => $match_sex, "realname" => $realname, "with_photo" => $with_photo, "online" => $online, "googlemap_location" => $data_location, "birthdate" => array("from" => $age_min, "to" => $age_max), "realname" => $realname, HAMMU_DB_SERVICES_KEY => $serach_services, HAMMU_DB_IM_USING_HAMMU_AS_KEY => "2", "available" => $available, "MainSearchFormSubmit" => "Search");
        $clean_array = cleanArray($data_arr);
        $data = $USEARCH_BOL_Service->updateSearchData($clean_array);
        $addParams = array('join' => '', 'where' => '');
        if (!empty($data['online'])) {
            $addParams['join'] .= " INNER JOIN `" . $BOL_UserOnlineDao->getTableName() . "` `online` ON (`online`.`userId` = `user`.`id`) ";
        }
        if (!empty($data['with_photo'])) {
            $addParams['join'] .= " INNER JOIN `" . OW_DB_PREFIX . "base_avatar` avatar ON (`avatar`.`userId` = `user`.`id`) ";
        }
        if (!empty($data['available'])) {
            $addParams['join'] .= " LEFT JOIN `" . OW_DB_PREFIX . "skapi` ON (`ow_skapi`.`userId` = `user`.`id`)";
            $addParams['where'] .= " AND `" . OW_DB_PREFIX . "skapi`.`available` = 'online'";
        }
        // echo "call";
        //        print_r($addParams);
        //        die;
        $userIdList = $Userservice->findUserIdListByQuestionValues($data, 0, 500, false, $addParams);
        //print_r($userIdList);
        $listId = 0;
        if (count($userIdList) > 0) {
            //$listId = $BOL_SearchService->saveSearchResult($userIdList);
            $listId = $BOL_SearchService->saveSearchResult($userIdList);
            OW::getSession()->set($SEARCH_RESULT_ID_VARIABLE, $listId);
            OW::getSession()->set('usearch_search_data', $data);
            $BOL_AuthorizationService->trackAction('base', 'search_users');
            $serach_result = searchResult(array('orderType' => array($PARAM_OPTION_DEFAULT_VALUE => 'latest_activity')), $listId);
            foreach ($serach_result as $key => $result) {
                //$searchArr[] = $result['user_id'];
                $searchArr = checkFavorite($result['user_id']);
                if (count($searchArr)) {
                    $serach_result[$key]["is_favorite"] = 1;
                } else {
                    $serach_result[$key]["is_favorite"] = 0;
                }
            }
            $messages = "Searching Successfully";
            $return_data = array("response_status" => '1', "response_message" => $messages, "data" => $serach_result);
            return $app->response->setBody(json_encode($return_data));
        } else {
            $messages = "Sorry!!! No people found.Please try a different search for more results..";
            $return_data = array("response_status" => '0', "response_message" => $messages);
            return $app->response->setBody(json_encode($return_data));
        }
    }
}
예제 #2
0
function client_notification_list()
{
    global $HAMMU_BOL_Service;
    global $language;
    global $Userservice;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //Lang Call Start
    $hammu_lang_id = $app->request()->params("lang_id");
    if (!empty($hammu_lang_id)) {
        getCurrentLanguages($hammu_lang_id);
    }
    //Lang Call end
    $inviterId = $app->request()->params("inviterId");
    $rarray = $HAMMU_BOL_Service->findClientListByIds($inviterId);
    $datas = json_decode(json_encode($rarray, true), true);
    $data_content = "";
    $meet_location = "";
    $longitude = "";
    $latitude = "";
    $instruction = "";
    $final_date = "";
    if (!empty($datas)) {
        $return_array = array();
        $inviteeId_loop = null;
        $data_content = "";
        //        print_r($datas);
        //        exit;
        foreach ($datas as $key => $data) {
            $searchArr = checkFavorite($data['inviterId'], $data['inviteeId']);
            if (count($searchArr)) {
                $is_favorite = "1";
            } else {
                $is_favorite = "0";
            }
            $inviteeUsername = $Userservice->getUserName($data["inviteeId"]);
            $date = date("Y/m/d H:i", $data["timestamp"]);
            $time = date("H:i", $data["timestamp"]);
            $data_timestamp = $data["data"];
            $json_string = isJSON($data_timestamp);
            if (!empty($json_string)) {
                $meet_location_result = json_decode($data_timestamp);
                $meeting_data_arr = (array) $meet_location_result;
                if (in_array($meeting_data_arr['meet_location'], $meeting_data_arr)) {
                    $meet_location = $meeting_data_arr['meet_location'];
                }
                if (in_array($meeting_data_arr['latitude'], $meeting_data_arr)) {
                    $latitude = $meeting_data_arr['latitude'];
                }
                if (in_array($meeting_data_arr['longitude'], $meeting_data_arr)) {
                    $longitude = $meeting_data_arr['longitude'];
                }
                if (in_array($meeting_data_arr['instruction'], $meeting_data_arr)) {
                    $instruction = $meeting_data_arr['instruction'];
                }
                if (in_array($meeting_data_arr['date'], $meeting_data_arr)) {
                    $data_content = $final_date = date("Y-m-d H:i", $meeting_data_arr['date']);
                }
            } else {
                if ($data_timestamp) {
                    // $data_content = date("Y-m-d H:i", $data_timestamp);
                    $data_content = "";
                }
            }
            $message = $language->text('hammu', $data["action"] . "_noti", array('user' => $inviteeUsername, "date" => $date, "time" => $time, "data" => $data_content));
            $flag = "none";
            if ($data["action"] == "invitation_accept") {
                $flag = "agree";
            } else {
                if ($data["action"] == "buy_rose") {
                    $flag = "location";
                } else {
                    if ($data["action"] == "propose_date_accept" || $data["action"] == "client_re_arrange") {
                        $flag = "confirm";
                    } else {
                        if ($data["action"] == "meet_location") {
                            $flag = "meetting";
                        } else {
                            if ($data["action"] == "buy_rose_client") {
                                $flag = "location";
                            }
                        }
                    }
                }
            }
            //echo $data["inviteeId"];
            if ($inviteeId_loop != $data["inviteeId"]) {
                $inviteeId_loop = $data["inviteeId"];
                $user_infos = getUserInfo($inviteeId_loop);
            }
            $user_infos["meet_location"] = $meet_location;
            $user_infos["latitude"] = $latitude;
            $user_infos["longitude"] = $longitude;
            $user_infos["instruction"] = $instruction;
            $user_infos["propose_date"] = $final_date;
            $return_array[] = array("message" => $message, "id" => $data["id"], "data" => $data["data"], "flag" => $flag, "action" => $data["action"], "seen_unseen" => $data["flag"], "inviteeId" => $data["inviteeId"], "user_info" => $user_infos, "date" => date("Y/m/d H:i", $data["timestamp"]), "is_favorite" => $is_favorite);
        }
        // exit;
        $return_data = array("response_status" => "1", "data" => $return_array);
        $app->response->setBody(json_encode($return_data));
    } else {
        $message = $language->text("hammu", "client_notification_list_fail");
        //"You have No Notification"
        $return_data = array("response_status" => "0", "response_message" => $message);
        $app->response->setBody(json_encode($return_data));
    }
}
예제 #3
0
function advance_search()
{
    global $USEARCH_BOL_Service;
    global $Userservice;
    global $BOL_SearchService;
    global $BOL_UserOnlineDao;
    global $ow;
    global $PARAM_OPTION_DEFAULT_VALUE;
    global $BOL_AuthorizationService;
    global $SEARCH_RESULT_ID_VARIABLE;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $user_id = $app->request()->params('user_id');
    $location = $app->request()->params('location');
    $match_sex = $app->request()->params('match_sex');
    $sex = $app->request()->params('sex');
    $distance = $app->request()->params('miles_from');
    $online = $app->request()->params('online');
    $age_min = $app->request()->params('age_min');
    $age_max = $app->request()->params('age_max');
    $with_photo = $app->request()->params('with_photo');
    $realname = $app->request()->params('realname');
    $available = $app->request()->params('available');
    $lang_id = (int) $app->request()->params("lang_id");
    $currentLanguageId = getCurrentLanguages($lang_id);
    $services = $app->request()->params(HAMMU_DB_SERVICES_KEY);
    $serach_services = explode(",", $services);
    $urlencode_address = urlencode($location);
    $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false');
    $output = json_decode($geocode);
    if (!empty($output->results[0]->geometry->location->lng)) {
        $data_location['address'] = $output->results[0]->formatted_address;
        $data_location['latitude'] = $output->results[0]->geometry->location->lat;
        $data_location['longitude'] = $output->results[0]->geometry->location->lng;
        $data_location['northEastLat'] = $output->results[0]->geometry->viewport->northeast->lat;
        $data_location['northEastLng'] = $output->results[0]->geometry->viewport->northeast->lng;
        $data_location['southWestLat'] = $output->results[0]->geometry->viewport->southwest->lat;
        $data_location['southWestLng'] = $output->results[0]->geometry->viewport->southwest->lng;
        $data_location['json'] = json_encode($output->results[0]);
        $data_location['distance'] = $distance;
        $data_arr = array("form_name" => "MainSearchForm", "sex" => $sex, "match_sex" => $match_sex, "realname" => $realname, "with_photo" => $with_photo, "online" => $online, "googlemap_location" => $data_location, "birthdate" => array("from" => $age_min, "to" => $age_max), "realname" => $realname, HAMMU_DB_SERVICES_KEY => $serach_services, HAMMU_DB_IM_USING_HAMMU_AS_KEY => "2", "available" => $available, "MainSearchFormSubmit" => "Search");
        $clean_array = cleanArray($data_arr);
        $data = $USEARCH_BOL_Service->updateSearchData($clean_array);
        $addParams = array('join' => '', 'where' => '');
        if (!empty($data['online'])) {
            $addParams['join'] .= " INNER JOIN `" . $BOL_UserOnlineDao->getTableName() . "` `online` ON (`online`.`userId` = `user`.`id`) ";
        }
        if (!empty($data['with_photo'])) {
            $addParams['join'] .= " INNER JOIN `" . OW_DB_PREFIX . "base_avatar` avatar ON (`avatar`.`userId` = `user`.`id`) ";
        }
        if (!empty($data['available'])) {
            $addParams['join'] .= " LEFT JOIN `" . OW_DB_PREFIX . "skapi` ON (`ow_skapi`.`userId` = `user`.`id`)";
            $addParams['where'] .= " AND `" . OW_DB_PREFIX . "skapi`.`available` = 'online'";
        }
        $userIdList = $Userservice->findUserIdListByQuestionValues($data, 0, 500, false, $addParams);
        $listId = 0;
        if (count($userIdList) > 0) {
            $listId = $BOL_SearchService->saveSearchResult($userIdList);
            OW::getSession()->set($SEARCH_RESULT_ID_VARIABLE, $listId);
            OW::getSession()->set('usearch_search_data', $data);
            $BOL_AuthorizationService->trackAction('base', 'search_users');
            $serach_result = searchResult(array('orderType' => array($PARAM_OPTION_DEFAULT_VALUE => 'latest_activity')), $listId);
            foreach ($serach_result as $key => $result) {
                $searchArr = checkFavorite($user_id, $result['user_id']);
                if (count($searchArr)) {
                    $serach_result[$key]["is_favorite"] = "1";
                } else {
                    $serach_result[$key]["is_favorite"] = "0";
                }
            }
            if ($currentLanguageId == '32') {
                $messages = "Erfolgreiche Suche";
            } else {
                if ($currentLanguageId == '33') {
                    $messages = "Búsqueda completada con éxito";
                } else {
                    $messages = "Search successful";
                }
            }
            $search_location_lat_long = array('latitude' => $output->results[0]->geometry->location->lat, 'longitude' => $output->results[0]->geometry->location->lng);
            $return_data = array("response_status" => '1', "response_message" => $messages, "data" => $serach_result, "location" => $search_location_lat_long);
            return $app->response->setBody(json_encode($return_data));
        } else {
            if ($currentLanguageId == '32') {
                $messages = "Sorry, kein passendes Profile gefunden. Bitte versuchen Sie es nochmals mit anderen Kriterien";
            } else {
                if ($currentLanguageId == '33') {
                    $messages = "Disculpe. No se ha encontrado a nadie disponible. Cambie sus preferencias e inténtelo de nuevo.";
                } else {
                    $messages = "Sorry, no match found. Please try a different search for better results";
                }
            }
            $return_data = array("response_status" => '0', "response_message" => $messages);
            return $app->response->setBody(json_encode($return_data));
        }
    }
}