Example #1
0
 public function index($params)
 {
     if (!OW::getPluginManager()->isPluginActive('event')) {
         throw new Redirect404Exception();
     }
     $lat = null;
     $lon = null;
     $hash = null;
     if (!empty($params['lat'])) {
         $lat = (double) $params['lat'];
     }
     if (!empty($params['lat'])) {
         $lat = (double) $params['lat'];
     }
     if (!empty($params['lng'])) {
         $lon = (double) $params['lng'];
     }
     if (!empty($params['hash'])) {
         $hash = $params['hash'];
     }
     $entityIdList = GOOGLELOCATION_BOL_LocationService::getInstance()->getEntityListFromSession($hash);
     $bridge = new GOOGLELOCATION_CLASS_EventBridge();
     $listCmp = $bridge->getEventListCmp($entityIdList);
     $this->addComponent('cmp', $listCmp);
     $locationName = GOOGLELOCATION_BOL_LocationService::getInstance()->getLocationName($lat, $lon);
     $this->assign('locationName', $locationName);
     $language = OW::getLanguage();
     $this->setPageHeading(OW::getLanguage()->text('googlelocation', 'browse_page_heading'));
     $this->setPageTitle(OW::getLanguage()->text('googlelocation', 'events_browse_page_title'));
     $this->setPageHeadingIconClass('ow_ic_bookmark');
     $this->assign('backUrl', empty($_GET['backUri']) ? null : OW_URL_HOME . $_GET['backUri']);
     $this->setTemplate(OW::getPluginManager()->getPlugin('googlelocation')->getCtrlViewDir() . 'entity_list_index.html');
 }
Example #2
0
 /**
  * Returns class instance
  *
  * @return GOOGLELOCATION_BOL_LocationService
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #3
0
 private function getEventMapCmp($backUri = null)
 {
     if (!OW::getPluginManager()->isPluginActive('event')) {
         throw new Redirect404Exception();
     }
     $map = new GOOGLELOCATION_CMP_Map();
     $map->setHeight('600px');
     $map->setZoom(2);
     $map->setCenter(30, 10);
     $map->setMapOption('scrollwheel', 'false');
     $locationList = GOOGLELOCATION_BOL_LocationService::getInstance()->getAllLocationsForEntityType('event');
     $entityIdList = array();
     $entityLocationList = array();
     foreach ($locationList as $location) {
         $entityIdList[$location['entityId']] = $location['entityId'];
         $entityLocationList[$location['entityId']] = $location;
     }
     $locationList = $entityLocationList;
     $eventsList = EVENT_BOL_EventService::getInstance()->findPublicEvents(null, 1000);
     $publicEventsId = array();
     $tmpEventList = array();
     foreach ($eventsList as $event) {
         $publicEventsId[$event->id] = $event->id;
         $tmpEventList[$event->id] = $event;
     }
     $eventsList = $tmpEventList;
     $entityIdList = array_intersect($entityIdList, $publicEventsId);
     $publicLocationList = array();
     $publicEventList = array();
     foreach ($entityIdList as $entityId) {
         $publicLocationList[$entityId] = $locationList[$entityId];
         $publicEventList[$entityId] = $eventsList[$entityId];
     }
     $events = EVENT_BOL_EventService::getInstance()->getListingDataWithToolbar($publicEventList);
     $pointList = GOOGLELOCATION_BOL_LocationService::getInstance()->getPointList($publicLocationList);
     foreach ($pointList as $point) {
         if (!empty($point['entityIdList'])) {
             $content = "";
             if ($point['count'] > 1) {
                 $listCmp = new GOOGLELOCATION_CMP_MapEventList($point['entityIdList'], $point['location']['lat'], $point['location']['lng'], $backUri);
                 $content .= $listCmp->render();
                 unset($listCmp);
             } else {
                 $eventId = current($point['entityIdList']);
                 if (!empty($events[$eventId])) {
                     $cmp = new GOOGLELOCATION_CMP_MapItem();
                     $cmp->setAvatar(array('src' => $events[$eventId]['imageSrc']));
                     $content = "<a href='{$events[$eventId]['eventUrl']}'>" . $events[$eventId]['title'] . "</a>\n                            <div>{$events[$eventId]['content']}</div>\n                            <div>{$publicLocationList[$eventId]['address']}</div> ";
                     $cmp->setContent($content);
                     $content = $cmp->render();
                 }
             }
             if (!empty($content)) {
                 $map->addPoint($point['location'], '', $content);
             }
         }
     }
     return $map;
 }
Example #4
0
 /**
  * Constructor.
  *
  * @param string $name
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->region = GOOGLELOCATION_BOL_LocationService::getInstance()->getLanguageCode();
     $this->addAttribute('type', 'text');
     $this->addAttribute('id', 'google_location_' . uniqid(rand(0, 999999)));
     $this->setHasInvitation(false);
     $this->addAttribute('class', '');
     OW::getEventManager()->trigger(new OW_Event('googlelocation.add_js_lib'));
 }
Example #5
0
 public function __construct($IdList, $lat, $lng, $backUri = null)
 {
     parent::__construct($IdList, $lat, $lng, $backUri);
     if (count($IdList) > self::DISPLAY_COUNT) {
         $hash = GOOGLELOCATION_BOL_LocationService::getInstance()->saveEntityListToSession($IdList);
         $this->display = true;
         $this->url = ow::getRouter()->urlForRoute('googlelocation_user_list', array('lat' => $this->lat, 'lng' => $this->lng, 'hash' => $hash));
         $this->label = OW::getLanguage()->text('googlelocation', 'map_user_list_view_all_button_label', array('count' => count($IdList)));
     }
 }
Example #6
0
 public function map()
 {
     $menu = BASE_MCTRL_UserList::getMenu('map');
     $this->addComponent('menu', $menu);
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('googlelocation', 'map_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_bookmark');
     $map = GOOGLELOCATION_BOL_LocationService::getInstance()->getMobileUserListMapCmp('all', OW::getRouter()->getUri());
     $this->addComponent("map", $map);
 }
Example #7
0
 /**
  * Updates forum plugin configuration
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $apiKey = empty($values['api_key']) ? '' : $values['api_key'];
     $distanseUnits = empty($values['distanse_units']) ? '' : $values['distanse_units'];
     $autoFillOnSearch = empty($values['auto_fill_location_on_search']) ? false : $values['auto_fill_location_on_search'];
     $config = OW::getConfig();
     $config->saveConfig('googlelocation', 'api_key', $apiKey);
     $config->saveConfig('googlelocation', 'auto_fill_location_on_search', $autoFillOnSearch);
     GOOGLELOCATION_BOL_LocationService::getInstance()->setDistanseUnits($distanseUnits);
     return array('result' => true);
 }
Example #8
0
 public function __construct($IdList, $lat, $lng, $backUri = null)
 {
     $this->IdList = $IdList;
     $this->lat = (double) $lat;
     $this->lng = (double) $lng;
     $this->count = count($IdList);
     $this->setBackUri($backUri);
     if (count($IdList) > self::DISPLAY_COUNT) {
         $hash = GOOGLELOCATION_BOL_LocationService::getInstance()->saveEntityListToSession($IdList);
         $this->display = true;
         $this->label = OW::getLanguage()->text('googlelocation', 'map_user_list_view_all_button_label', array('count' => count($IdList)));
         $this->url = ow::getRouter()->urlForRoute('googlelocation_user_list', array('lat' => $this->lat, 'lng' => $this->lng, 'hash' => $hash));
     }
     parent::__construct();
     $this->template = OW::getPluginManager()->getPlugin('googlelocation')->getCmpViewDir() . 'map_entity_list.html';
 }
Example #9
0
 public function index($params)
 {
     $menu = BASE_MCTRL_UserList::getMenu('');
     $this->addComponent('menu', $menu);
     $lat = null;
     $lon = null;
     $hash = null;
     if (!empty($params['lat'])) {
         $lat = (double) $params['lat'];
     }
     if (!empty($params['lat'])) {
         $lat = (double) $params['lat'];
     }
     if (!empty($params['lng'])) {
         $lon = (double) $params['lng'];
     }
     if (!empty($params['hash'])) {
         $hash = $params['hash'];
     }
     $usersPerPage = 500;
     //(int)OW::getConfig()->getValue('base', 'users_count_on_page');
     $userIdList = GOOGLELOCATION_BOL_LocationService::getInstance()->getEntityListFromSession($hash);
     $userList = GOOGLELOCATION_BOL_LocationService::getInstance()->findUserListByCoordinates($lat, $lon, 0, $usersPerPage, $userIdList);
     $usersCount = GOOGLELOCATION_BOL_LocationService::getInstance()->findUserCountByCoordinates($lat, $lon, $userIdList);
     $idList = array();
     foreach ($userList as $dto) {
         $idList[$dto->id] = $dto->id;
     }
     $language = OW::getLanguage();
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'mobile_user_list.js', "text/javascript", GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY + 1);
     $cmp = new BASE_MCMP_BaseUserList('google_map_mobile_userlist', $idList, true);
     $this->addComponent('list', $cmp);
     //$this->assign('listType', 'google_map_mobile_userlist');
     /* OW::getDocument()->addOnloadScript("
            window.mobileUserList = new OW_UserList(".  json_encode(array(
                    'component' => 'BASE_MCMP_BaseUserList',
                    'listType' => 'google_map_mobile_userlist',
                    'excludeList' => $idList,
                    'node' => '.owm_user_list',
                    'showOnline' => true,
                    'count' => $usersPerPage,
                    'responderUrl' => OW::getRouter()->urlForRoute('base_user_lists_responder')
                )).");
        ", 50); */
     //$locationName = GOOGLELOCATION_BOL_LocationService::getInstance()->getLocationName($lat, $lon);
     //$this->assign('locationName', $locationName);
 }
Example #10
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $IdList = $this->assignList($params);
     if (empty($IdList) && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $this->locationList = GOOGLELOCATION_BOL_LocationService::getInstance()->findByUserIdList($IdList);
     if (empty($this->locationList) && !$params->customizeMode) {
         $this->setVisible(false);
         return;
     }
     $this->map = $this->getMap($params);
     $this->renderMap();
     $this->setTemplate(OW::getPluginManager()->getPlugin('googlelocation')->getCmpViewDir() . 'map_widget.html');
 }
Example #11
0
 public function renderInput($params = null)
 {
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'location_search.js', "text/javascript", GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY + 1);
     OW::getDocument()->addOnloadScript(' $( document ).ready( function(){ window.googlemap_location_search = new OW_GoogleMapLocationSearch( ' . json_encode($this->getName()) . ',' . ' ' . json_encode($this->getId()) . ', ' . json_encode(GOOGLELOCATION_BOL_LocationService::getInstance()->getCountryRestriction()) . ' );
                                          window.googlemap_location_search.initialize(); }); ');
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[address]', 'value' => !empty($this->value['address']) ? $this->escapeValue($this->value['address']) : '');
     $html = UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[latitude]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['latitude']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[longitude]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['longitude']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[northEastLat]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['northEastLat']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[northEastLng]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['northEastLng']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[southWestLat]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['southWestLat']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[southWestLng]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['southWestLng']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[json]', 'value' => !empty($this->value['json']) ? $this->escapeValue($this->value['json']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'text', 'name' => $this->getName() . '[distance]', 'class' => 'ow_googlelocation_search_distance', 'value' => !empty($this->value['distance']) ? $this->escapeValue($this->value['distance']) : '');
     $html .= '<span>' . UTIL_HtmlTag::generateTag('input', $attribute) . '</span>';
     if (OW::getConfig()->getValue('googlelocation', 'distance_units') == GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_MILES) {
         $html .= '<span class="ow_googlelocation_search_miles_from" >' . OW::getLanguage()->text('googlelocation', 'miles_from') . '</span>';
     } else {
         $html .= '<span class="ow_googlelocation_search_miles_from" >' . OW::getLanguage()->text('googlelocation', 'kms_from') . '</span>';
     }
     $attribute = $this->attributes;
     unset($attribute['name']);
     $attribute['value'] = !empty($this->value['address']) ? $this->value['address'] : '';
     $attribute['class'] .= ' ow_left ow_googlelocation_location_search_input';
     if (empty($attribute['value']) && $this->hasInvitation) {
         $attribute['value'] = $this->invitation;
         $attribute['class'] .= ' invitation';
     }
     $html .= '<div class="googlelocation_address_div">' . UTIL_HtmlTag::generateTag('input', $attribute) . '<div class="googlelocation_address_icon_div">
                     <span id=' . json_encode($this->getId() . '_icon') . ' style="' . (!empty($this->value['json']) ? 'display:none' : 'display:inline') . '" class="ic_googlemap_pin googlelocation_address_icon"></span>
                     <div id=' . json_encode($this->getId() . '_delete_icon') . '  style="' . (empty($this->value['json']) ? 'display:none' : 'display:inline') . '" class="ow_miniic_delete googlelocation_delete_icon"></div>
                 </div>
              </div>';
     //$html .= '<div id="' . $this->getName() . '_map" style="margin-top:10px;width:90%;height:200px;display:none;"></div>';
     return $html;
 }
Example #12
0
 public function index($params)
 {
     if (!OW::getPluginManager()->isPluginActive("skadate")) {
         $menu = BASE_CTRL_UserList::getMenu('map');
         $this->addComponent('menu', $menu);
     }
     $lat = null;
     $lon = null;
     $hash = null;
     if (!empty($params['lat'])) {
         $lat = (double) $params['lat'];
     }
     if (!empty($params['lat'])) {
         $lat = (double) $params['lat'];
     }
     if (!empty($params['lng'])) {
         $lon = (double) $params['lng'];
     }
     if (!empty($params['hash'])) {
         $hash = $params['hash'];
     }
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $first = $page - 1;
     $usersPerPage = (int) OW::getConfig()->getValue('base', 'users_count_on_page');
     $userIdList = GOOGLELOCATION_BOL_LocationService::getInstance()->getEntityListFromSession($hash);
     //BOL_UserService::getInstance()->findUserListByIdList($userIdList);
     $userList = GOOGLELOCATION_BOL_LocationService::getInstance()->findUserListByCoordinates($lat, $lon, $first, $usersPerPage, $userIdList);
     $usersCount = GOOGLELOCATION_BOL_LocationService::getInstance()->findUserCountByCoordinates($lat, $lon, $userIdList);
     $listCmp = new GOOGLELOCATION_CMP_UserList($userList, $usersCount, $usersPerPage);
     $this->addComponent('cmp', $listCmp);
     $locationName = GOOGLELOCATION_BOL_LocationService::getInstance()->getLocationName($lat, $lon);
     $this->assign('locationName', $locationName);
     $language = OW::getLanguage();
     $this->setPageHeading(OW::getLanguage()->text('base', 'browse_users_page_heading'));
     $this->setPageTitle(OW::getLanguage()->text('base', 'browse_users_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_bookmark');
     $this->assign('backUrl', empty($_GET['backUri']) ? null : OW_URL_HOME . $_GET['backUri']);
     $this->setTemplate(OW::getPluginManager()->getPlugin('googlelocation')->getCtrlViewDir() . 'entity_list_index.html');
 }
Example #13
0
 public function addPoint($location, $title = '', $windowContent = '', $isOpen = false)
 {
     if (!empty($location)) {
         $this->points[] = array('location' => $location, 'title' => UTIL_HtmlTag::stripJs($title), 'content' => UTIL_HtmlTag::stripJs($windowContent), 'isOpen' => (bool) $isOpen, 'icon' => GOOGLELOCATION_BOL_LocationService::getInstance()->getDefaultMarkerIcon());
     }
 }
Example #14
0
 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     parent::renderInput($params);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('googlelocation')->getStaticJsUrl() . 'location.js', "text/javascript", GOOGLELOCATION_BOL_LocationService::JQUERY_LOAD_PRIORITY + 1);
     $name = json_encode($this->getName());
     $id = json_encode($this->getId());
     $lat = !empty($this->value['latitude']) ? (double) $this->value['latitude'] : 0;
     $lon = !empty($this->value['longitude']) ? (double) $this->value['longitude'] : 0;
     $northEastLat = !empty($this->value['northEastLat']) ? (double) $this->value['northEastLat'] : 0;
     $northEastLng = !empty($this->value['northEastLng']) ? (double) $this->value['northEastLng'] : 0;
     $southWestLat = !empty($this->value['southWestLat']) ? (double) $this->value['southWestLat'] : 0;
     $southWestLng = !empty($this->value['southWestLng']) ? (double) $this->value['southWestLng'] : 0;
     $params = array('lat' => $lat, 'lng' => $lon, 'northEastLat' => $northEastLat, 'northEastLng' => $northEastLng, 'southWestLat' => $southWestLat, 'southWestLng' => $southWestLng, 'region' => $this->region, 'countryRestriction' => GOOGLELOCATION_BOL_LocationService::getInstance()->getCountryRestriction(), 'customMarkerIcon' => GOOGLELOCATION_BOL_LocationService::getInstance()->getDefaultMarkerIcon());
     OW::getDocument()->addOnloadScript(' $( document ).ready( function(){ window.googlemap_location = new OW_GoogleMapLocation( ' . json_encode($this->getName()) . ', ' . json_encode($this->getId()) . ', ' . json_encode($this->getName() . '_map') . ' );
                                          window.googlemap_location.initialize(' . json_encode($params) . '); }); ');
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[address]', 'value' => !empty($this->value['address']) ? $this->escapeValue($this->value['address']) : '');
     $html = UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[latitude]', 'value' => !empty($this->value['latitude']) ? $this->escapeValue($this->value['latitude']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[longitude]', 'value' => !empty($this->value['longitude']) ? $this->escapeValue($this->value['longitude']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[northEastLat]', 'value' => !empty($this->value['northEastLat']) ? $this->escapeValue($this->value['northEastLat']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[northEastLng]', 'value' => !empty($this->value['northEastLng']) ? $this->escapeValue($this->value['northEastLng']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[southWestLat]', 'value' => !empty($this->value['southWestLat']) ? $this->escapeValue($this->value['southWestLat']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[southWestLng]', 'value' => !empty($this->value['southWestLng']) ? $this->escapeValue($this->value['southWestLng']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[json]', 'value' => !empty($this->value['json']) ? $this->escapeValue($this->value['json']) : '');
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = array('type' => 'hidden', 'name' => $this->getName() . '[remove]', 'value' => !empty($this->value['remove']) ? $this->escapeValue($this->value['remove']) : false);
     $html .= UTIL_HtmlTag::generateTag('input', $attribute);
     $attribute = $this->attributes;
     unset($attribute['name']);
     $attribute['value'] = !empty($this->value['address']) ? $this->value['address'] : '';
     $attribute['class'] .= ' ow_left ow_googlelocation_location_input';
     if (empty($attribute['value']) && $this->hasInvitation) {
         $attribute['value'] = $this->invitation;
         $attribute['class'] .= ' invitation';
     }
     $html .= '<div class="googlelocation_form_element_div clearfix">' . UTIL_HtmlTag::generateTag('input', $attribute) . '<div class="googlelocation_address_icon_div">
                     <span id=' . json_encode($this->getId() . '_icon') . ' style="' . (!empty($this->value['json']) ? 'display:none' : 'display:inline') . '" class="ic_googlemap_pin googlelocation_address_icon"></span>
                     <div id=' . json_encode($this->getId() . '_delete_icon') . '  style="' . (empty($this->value['json']) ? 'display:none' : 'display:inline') . '" class="ow_miniic_delete googlelocation_delete_icon"></div>
                 </div>
              </div>';
     $html .= '<div id="' . $this->getName() . '_map" style="margin-top:10px;width:90%;height:200px;display:none;"></div>';
     return $html;
 }
Example #15
0
 public function calcDistance(OW_Event $e)
 {
     $params = $e->getParams();
     $lat = !empty($params['lat']) ? (double) $params['lat'] : 0;
     $lon = !empty($params['lon']) ? (double) $params['lon'] : 0;
     $lat1 = !empty($params['lat1']) ? (double) $params['lat1'] : 0;
     $lon1 = !empty($params['lon1']) ? (double) $params['lon1'] : 0;
     $distance = GOOGLELOCATION_BOL_LocationService::getInstance()->distance($lat, $lon, $lat1, $lon1);
     $units = GOOGLELOCATION_BOL_LocationService::getInstance()->getDistanseUnits();
     $data = array('distance' => $distance, 'units' => $units);
     $e->setData($data);
 }
Example #16
0
 public function findSpeedmatchOpponents($userId, $first, $count, $criteria, $exclude = array())
 {
     if (!$userId) {
         return null;
     }
     if (isset($criteria['birthdate'])) {
         $range = explode('-', $criteria['birthdate']);
         if (!empty($range[0]) && !empty($range[1])) {
             $criteria['birthdate'] = array('from' => $range[0], 'to' => $range[1]);
         } else {
             unset($criteria['birthdate']);
         }
     }
     $addQuery['join'] = ' LEFT JOIN `' . $this->relationDao->getTableName() . '` AS `relation`
         ON (`user`.`id` = `relation`.`oppUserId` AND `relation`.`userId` = ' . OW::getDbo()->escapeString($userId) . ') ';
     $addQuery['where'] = ' AND `relation`.`id` IS NULL AND `user`.`id` != ' . OW::getDbo()->escapeString($userId);
     if (!empty($criteria['googlemap_location']['latitude']) && !empty($criteria['googlemap_location']['longitude'])) {
         $location = $criteria['googlemap_location'];
         unset($criteria['googlemap_location']);
         $coord = GOOGLELOCATION_BOL_LocationService::getInstance()->getNewCoordinates($location['latitude'], $location['longitude'], 225, (double) $location['distance']);
         $location['southWestLat'] = $coord['lat'];
         $location['southWestLng'] = $coord['lng'];
         $coord = GOOGLELOCATION_BOL_LocationService::getInstance()->getNewCoordinates($location['latitude'], $location['longitude'], 45, (double) $location['distance']);
         $location['northEastLat'] = $coord['lat'];
         $location['northEastLng'] = $coord['lng'];
         $sql = GOOGLELOCATION_BOL_LocationService::getInstance()->getSearchInnerJoinSql('user', $location['southWestLat'], $location['southWestLng'], $location['northEastLat'], $location['northEastLng'], null, 'LEFT');
         $locationDao = SKADATE_BOL_CurrentLocationDao::getInstance();
         $sql .= ' LEFT JOIN `' . $locationDao->getTableName() . '` current_location ON (user.id = current_location.userId
             AND (
                 current_location.latitude >= ' . $location['southWestLat'] . '
                 AND current_location.latitude <= ' . $location['northEastLat'] . '
             )
             AND (
                 current_location.longitude >= ' . $location['southWestLng'] . '
                 AND current_location.longitude <= ' . $location['northEastLng'] . '
             )) ';
         $addQuery['join'] .= $sql;
         $addQuery['where'] .= ' AND (current_location.id IS NOT NULL OR location.id IS NOT NULL) ';
         $addQuery['order'] = ' current_location.id IS NOT NULL DESC, `user`.`activityStamp` DESC ';
     }
     if (!empty($exclude)) {
         $addQuery['where'] .= ' AND `user`.`id` NOT IN (' . implode(',', array_map('intval', array_filter($exclude))) . ') ';
     }
     $idList = BOL_UserDao::getInstance()->findUserIdListByQuestionValues($criteria, $first, $count, false, $addQuery);
     return $idList;
 }
Example #17
0
 public function getSearchResultList($listId, $listType, $from, $count, $excludeList = array())
 {
     if (empty($excludeList)) {
         $excludeList = array();
     }
     if (OW::getUser()->isAuthenticated()) {
         $excludeList[] = OW::getUser()->getId();
     }
     $userIdList = $this->getUserIdList($listId, 0, BOL_SearchService::USER_LIST_SIZE, $excludeList);
     //$userIdList = BOL_SearchService::getInstance()->getUserIdList($listId, 0, BOL_SearchService::USER_LIST_SIZE, $excludeList);
     if (empty($userIdList)) {
         return array();
     }
     switch ($listType) {
         case USEARCH_BOL_Service::LIST_ORDER_NEW:
             return $this->searchDao->findSearchResultListOrderedByRecentlyJoined($userIdList, $from, $count);
             break;
         case USEARCH_BOL_Service::LIST_ORDER_MATCH_COMPATIBILITY:
             if (OW::getPluginManager()->isPluginActive('matchmaking') && OW::getUser()->isAuthenticated()) {
                 $result = MATCHMAKING_BOL_Service::getInstance()->findCompatibilityByUserIdList(OW::getUser()->getId(), $userIdList, $from, $count);
                 $idList = array();
                 foreach ($result as $item) {
                     $idList[$item['userId']] = $item['userId'];
                 }
                 $users = BOL_UserService::getInstance()->findUserListByIdList($idList);
                 $list = array();
                 foreach ($users as $user) {
                     $list[] = $user;
                 }
                 return $list;
             }
             break;
         case USEARCH_BOL_Service::LIST_ORDER_DISTANCE:
             if (OW::getPluginManager()->isPluginActive('googlelocation') && OW::getUser()->isAuthenticated()) {
                 $result = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('googlemap_location'));
                 if (!empty($result[OW::getUser()->getId()]['googlemap_location']['json'])) {
                     $location = $result[OW::getUser()->getId()]['googlemap_location'];
                     return GOOGLELOCATION_BOL_LocationService::getInstance()->getListOrderedByDistance($userIdList, $from, $count, $location['latitude'], $location['longitude']);
                 }
             }
             break;
         default:
             $params = array('idList' => $userIdList, 'orderType' => $listType, 'from' => $from, 'count' => $count, 'userId' => OW::getUser()->isAuthenticated() ? OW::getUser()->getId() : 0);
             $event = new OW_Event('usearch.get_ordered_list', $params, array());
             OW::getEventManager()->trigger($event);
             $data = $event->getData();
             if (!empty($data) && is_array($data)) {
                 return $data;
             }
     }
     return $this->searchDao->findSearchResultListByLatestActivity($userIdList, $from, $count);
 }
Example #18
0
 public function onBeforePluginUninstall(OW_Event $e)
 {
     $params = $e->getParams();
     if (!empty($params['pluginKey']) && $params['pluginKey'] == 'event') {
         GOOGLELOCATION_BOL_LocationService::getInstance()->deleteByEntityType(GOOGLELOCATION_BOL_LocationDao::ENTITY_TYPE_EVENT);
     }
 }