Example #1
0
function usearch_set_question_sql(BASE_CLASS_QueryBuilderEvent $event)
{
    $params = $event->getParams();
    if (empty($params['question']) || !$params['question'] instanceof BOL_Question || empty($params['value']) || !in_array($params['question']->name, array('sex', 'match_sex'))) {
        return;
    }
    $value = is_array($params['value']) ? array_sum($params['value']) : (int) $params['value'];
    $prefix = !empty($params['prefix']) ? $params['prefix'] : 'q' . rand(100, 10000);
    $questionName = $params['question']->name == 'sex' ? 'match_sex' : 'sex';
    $innerJoin = " INNER JOIN `" . BOL_QuestionDataDao::getInstance()->getTableName() . "` `" . $prefix . "`\n        ON ( `user`.`id` = `" . $prefix . "`.`userId` AND `" . $prefix . "`.`questionName` = '" . OW::getDbo()->escapeString($questionName) . "' AND `" . $prefix . "`.`intValue` & " . OW::getDbo()->escapeString($value) . " ) ";
    $event->addJoin($innerJoin);
}
Example #2
0
 public function photoGetPhotoList(BASE_CLASS_QueryBuilderEvent $event)
 {
     $params = $event->getParams();
     $aliases = $params['aliases'];
     if (empty($params['listType']) || !in_array($params['listType'], array('latest', 'featured', 'toprated', 'most_discussed', 'searchByDesc', 'searchByHashtag', 'searchByUsername'))) {
         return;
     }
     if (!OW::getUser()->isAuthenticated() || !(bool) OW::getConfig()->getValue('skadate', 'photo_filter_setting_matching') || OW::getUser()->isAuthorized('photo') || OW::getUser()->isAuthorized('base')) {
         return;
     }
     $userId = OW::getUser()->getId();
     $matchValue = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array('sex', 'match_sex'));
     if (empty($matchValue[$userId]['match_sex'])) {
         return;
     }
     $join = 'INNER JOIN `' . BOL_UserDao::getInstance()->getTableName() . '` AS `sk_u` ON(`' . $aliases['album'] . '`.`userId` = `sk_u`.`id`)
         INNER JOIN `' . BOL_QuestionDataDao::getInstance()->getTableName() . '` AS `sk_qd` ON (`sk_qd`.`userId` = `sk_u`.`id` AND `sk_qd`.`questionName` = :sk_sexQuestionName AND `sk_qd`.`intValue` & :sk_matchSexValue)
         INNER JOIN `' . BOL_QuestionDataDao::getInstance()->getTableName() . '` AS `sk_qd1` ON (`sk_qd1`.`userId` = `sk_u`.`id` AND `sk_qd1`.`questionName` = :sk_matchSexQuestionName AND `sk_qd1`.`intValue` & :sk_sexValue)';
     $params = array('sk_sexQuestionName' => 'sex', 'sk_matchSexQuestionName' => 'match_sex', 'sk_sexValue' => $matchValue[$userId]['sex'], 'sk_matchSexValue' => $matchValue[$userId]['match_sex']);
     $event->addJoin($join);
     $event->addBatchQueryParams($params);
 }
Example #3
0
 function questionSearchSql(BASE_CLASS_QueryBuilderEvent $e)
 {
     $params = $e->getParams();
     $question = !empty($params['question']) ? $params['question'] : null;
     $questionValue = !empty($params['value']) ? $params['value'] : null;
     if (!empty($question) && $question->name == 'googlemap_location') {
         if (empty($questionValue) || empty($questionValue['json'])) {
             $e->addWhere(" 1 ");
             return;
         }
         $element = new GOOGLELOCATION_CLASS_Location('location');
         $element->setValue($params['value']);
         $value = $element->getListValue();
         $json = !empty($value['json']) ? json_decode($value['json'], true) : array();
         $countryCode = "";
         if (!empty($json['address_components'])) {
             foreach ($json['address_components'] as $component) {
                 if (!empty($component['types']) && is_array($component['types']) && in_array('country', $component['types'])) {
                     $countryCode = !empty($component['short_name']) ? $component['short_name'] : "";
                 }
             }
         }
         if (!empty($value['distance']) && (double) $value['distance'] > 0) {
             $coord = GOOGLELOCATION_BOL_LocationService::getInstance()->getNewCoordinates($value['southWestLat'], $value['southWestLng'], 225, (double) $value['distance']);
             $value['southWestLat'] = $coord['lat'];
             $value['southWestLng'] = $coord['lng'];
             $coord = GOOGLELOCATION_BOL_LocationService::getInstance()->getNewCoordinates($value['northEastLat'], $value['northEastLng'], 45, (double) $value['distance']);
             $value['northEastLat'] = $coord['lat'];
             $value['northEastLng'] = $coord['lng'];
         }
         $sql = GOOGLELOCATION_BOL_LocationService::getInstance()->getSearchInnerJoinSql('user', $value['southWestLat'], $value['southWestLng'], $value['northEastLat'], $value['northEastLng'], $countryCode);
         $e->addJoin($sql);
     }
 }
 public function photoGetPhotoList(BASE_CLASS_QueryBuilderEvent $event)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $params = $event->getParams();
     $aliases = $params['tables'];
     $currentId = OW::getUser()->getId();
     $sex = BOL_QuestionService::getInstance()->getQuestionData(array($currentId), array('sex'));
     $join = ' INNER JOIN `' . BOL_QuestionDataDao::getInstance()->getTableName() . '` AS `bqdt` ON(`' . $aliases['content'] . '`.`userId` = `bqdt`.`userId`
         AND `bqdt`.`questionName` = \'sex\' 
         AND (`bqdt`.`intValue` != ' . $sex[$currentId]['sex'] . ' OR `' . $aliases['content'] . '`.`userId` = ' . $currentId . ' )) ';
     $params = array('sex' => $sex[$currentId]['sex'], 'currentId' => $currentId);
     $event->addJoin($join);
 }