Example #1
0
 private function __construct()
 {
     $this->questionMatchDao = MATCHMAKING_BOL_QuestionMatchDao::getInstance();
 }
 public function getFields($userIdList)
 {
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $qLocation = BOL_QuestionService::getInstance()->findQuestionByName('googlemap_location');
     if ($qLocation && $qLocation->onView) {
         $qs[] = 'googlemap_location';
     }
     //        if ( $this->listType == 'details' )
     //        {
     //            $qs[] = 'aboutme';
     //        }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     $matchCompatibility = array();
     if ($this->orderType == USEARCH_BOL_Service::LIST_ORDER_MATCH_COMPATIBILITY) {
         if (OW::getPluginManager()->isPluginActive('matchmaking') && OW::getUser()->isAuthenticated()) {
             $maxCompatibility = MATCHMAKING_BOL_QuestionMatchDao::getInstance()->getMaxPercentValue();
             $matchCompatibilityList = MATCHMAKING_BOL_Service::getInstance()->findCompatibilityByUserIdList(OW::getUser()->getId(), $userIdList, 0, 1000);
             foreach ($matchCompatibilityList as $compatibility) {
                 $matchCompatibility[$compatibility['userId']] = (int) ($compatibility['compatibility'] / $maxCompatibility * 100);
             }
         }
     }
     foreach ($questionList as $uid => $q) {
         $fields[$uid] = array();
         $age = '';
         if (!empty($q['birthdate'])) {
             $date = UTIL_DateTime::parseDate($q['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         if (!empty($q['sex'])) {
             $sex = $q['sex'];
             $sexValue = '';
             for ($i = 0; $i < 31; $i++) {
                 $val = pow(2, $i);
                 if ((int) $sex & $val) {
                     $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
                 }
             }
             if (!empty($sexValue)) {
                 $sexValue = substr($sexValue, 0, -2);
             }
         }
         if (!empty($sexValue) && !empty($age)) {
             $fields[$uid]['base'][] = array('label' => '', 'value' => $sexValue . ' ' . $age);
         }
         if (!empty($q['aboutme'])) {
             $fields[$uid]['aboutme'] = array('label' => '', 'value' => $q['aboutme']);
         }
         if (!empty($q['googlemap_location']['address'])) {
             $fields[$uid]['location'] = array('label' => '', 'value' => $q['googlemap_location']['address']);
         }
         if (isset($matchCompatibility[$uid])) {
             $fields[$uid]['match_compatibility'] = array('label' => '', 'value' => $matchCompatibility[$uid] . '%');
         }
         if ($this->orderType == USEARCH_BOL_Service::LIST_ORDER_DISTANCE) {
             if (OW::getPluginManager()->isPluginActive('googlelocation') && !empty($q['googlemap_location']) && !empty($this->location)) {
                 $event = new OW_Event('googlelocation.calc_distance', array('lat' => $this->location['latitude'], 'lon' => $this->location['longitude'], 'lat1' => $q['googlemap_location']['latitude'], 'lon1' => $q['googlemap_location']['longitude']));
                 OW::getEventManager()->trigger($event);
                 $data = $event->getData();
                 if ($data['units'] == 'miles') {
                     $html = '&nbsp;<span>' . OW::getLanguage()->text('usearch', 'miles') . '</span>';
                 } else {
                     $html = '&nbsp;<span>' . OW::getLanguage()->text('usearch', 'kms') . '</span>';
                 }
                 $fields[$uid]['distance'] = array('label' => '', 'value' => $data['distance'] . $html);
             }
         }
     }
     return $fields;
 }