/find_training_partner.php
PHP | 290 lines | 232 code | 43 blank | 15 comment | 41 complexity | 6f60e3ec50a534a3d54670aa126fc8a8 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
- <?php
- session_start();
- unset($_SESSION['sql']);
- unset($_SESSION['sort']);
- unset($_SESSION['sqlOrder']);
- unset($_SESSION['sqlPart']);
-
- $page_name=basename($_SERVER['SCRIPT_FILENAME']);
- $IsPreserved = 'Y';
- $IsProcess = $_REQUEST['IsProcess'];
- $action = $_REQUEST['action'];
- $action_arr = array("getSrchResult");
-
- //############## Added By Chandan
- if(isset($_REQUEST['game_id'])){
- $_SESSION['game_id'] = $_REQUEST['game_id'];
- $game_id = $_SESSION['game_id'];
- }else{
- $game_id = $_SESSION['game_id'];
- }
-
-
- if(is_array($game_id)){
- $game_id = $game_id[0];
- $_SESSION['game_id'] = $game_id;
- }
-
- //############# Added By Chandan
-
- if(in_array($action,$action_arr))
- {
- $IsProcess = 'Y';
- }
- include("general_include.php");
- $username = $_REQUEST['unm'];
- $sort_by = $_REQUEST['sorting_by'];
- $list_for = $_REQUEST['list_for'];
- //$availability_country = $_REQUEST['availability_country'];
- $availability_city = $_REQUEST['availability_city'];
-
- $language_id = $_REQUEST['language_id'];
-
-
- if($language_id == '')
- $language_id = array();
-
- //if($price == '')
- // $price = '0;100';
- //$prop_id = $_REQUEST['prop_id'];
- if(isset($_REQUEST['prop_id'])){
- $prop_id = $_REQUEST['prop_id'];
- $_SESSION['prop_id'] = $prop_id;
- }else{
- $prop_id = $_SESSION['prop_id'];
- }
-
- if($prop_id == '')
- $prop_id = array();
-
- if(count($prop_id)>0&& is_array($prop_id)&& !empty($prop_id)){
- $prop_ids = implode(',',$prop_id);
- $smarty->assign('prop_ids',$prop_ids);
- $sqlPart .= " AND u.user_id IN (SELECT user_id FROM nk_user_game_property WHERE ";// 1=1 property_id IN ($prop_ids))";
- $aux = "";
-
- $numProps = count($prop_id);
- for ($i = 0; $i <= $numProps; $i++) {
- $id = $prop_id[$i];
- $aux .= $aux.$i==0?"":" AND "." property_id = ".$id;
- }
- $sqlPart .= $aux;
-
- logToFile($sqlPart);
- }
-
- if(count($language_id)>0&& is_array($language_id)&& !empty($language_id))
- {
- $language_ids = implode(',',$language_id);
- $smarty->assign('languages',$language_ids);
- foreach($language_id as $val)
- $sqlPart .= " AND FIND_IN_SET($val,u.language_ids)";
- }
- if(count($availability)>0&& is_array($availability)&& !empty($availability))
- {
- $availabilitys = implode(',',$availability);
- $smarty->assign('availabilitys',$availabilitys);
- foreach($availability as $val)
- $sqlPart .= " AND FIND_IN_SET('$val',u.availability_type)";
- }
- /*if(!empty($availability_country))
- {
- $sqlPart .= " AND u.availability_country ='$availability_country'";
- }*/
- if(!empty($availability_city))
- {
- $sqlPart .= " AND u.availability_city ='$availability_city'";
- }
- if(!empty($username))
- {
- $sqlPart .= " AND u.name like '$username%'";
- }
- if($IsProcess <> 'Y')
- {
- include "top.php";
- }
-
- if($game_id==''|| empty($game_id)){
- $Sql = "SELECT * FROM ".TABLEPREFIX."_game WHERE is_default=1";
- $idRow = $UserManagerObjAjax->GetRecords("Row",$Sql);
- $game_id = $idRow['game_id'];
- }
-
- $GameSql = "SELECT * FROM ".TABLEPREFIX."_game WHERE game_id='$game_id'";
- $gamerow = $UserManagerObjAjax->GetRecords("Row",$GameSql);
- $game_id = $gamerow['game_id'];
- $game_name = $gamerow['game_name'];
-
- function findlanguage($language_id){
- if($language_id=='')
- return false;
-
- $SelectTypeSql = "SELECT language_name FROM ".TABLEPREFIX."_language WHERE language_id=$language_id";
- $SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
- return $SelectType[0];
- }
-
- function findvalue($table,$fld_name,$fld_value,$find_value){
- if($fld_value=='')
- return false;
- $SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
- $SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
- return $SelectType[0];
- }
-
- $record_per_page = !empty($record_per_page)?$record_per_page:15;
- $paginationObj = new PaginationClassFrontAjax($record_per_page,3,1,'Next','Previous');
-
- if($list_for == 'sorting')
- {
- $sortBy = explode('-',$sort_by);
- if($sortBy[0] == 'rating')
- {
- if($sortBy[1]=="DESC")
- $sqlPart.=" ORDER BY ur.overall_rating DESC,u.name ASC";
- else
- $sqlPart.=" ORDER BY ur.overall_rating ASC,u.name ASC";
- }
-
- }
- else
- $sqlPart.=" ORDER BY u.date_registered DESC";
-
- $SelectcoachSQL="SELECT DISTINCT u.*,ur.*,ug.* FROM ".TABLEPREFIX."_user u ,".TABLEPREFIX."_user_type_user_relation ur ,
- ".TABLEPREFIX."_user_game ug WHERE ur.user_type_id=3 and ur.user_id=u.user_id and u.is_active='Y' and ug.user_id=u.user_id
- and ug.game_id=$game_id and ug.is_active='Y' and ug.user_type_id=3".$sqlPart;
-
- $pagination_arr = $paginationObj->PaginationFrontAjaxALL('PaginationSearch',$SelectcoachSQL,$page_name.'?'.$catLink);
- $CoachArr=$UserManagerObjAjax->GetRecords("All",$pagination_arr[0]);
- //echo $pagination_arr[0];
- $friendsSql = "SELECT * FROM ".TABLEPREFIX."_user_friends_list WHERE friend_status = 2 AND (nk_user_id_owner='".$_SESSION['user_id']."' or nk_user_id_friend='".$_SESSION['user_id']."')";
- $friendsArr = $UserManagerObjAjax->GetRecords("All",$friendsSql);
-
- $NumCoach=count($CoachArr);
-
- $gameCategoriesSql = "SELECT * FROM ".TABLEPREFIX."_game_categories WHERE game_id=".$game_id;
- $gameCategoriesArr = $UserManagerObjAjax->GetRecords("All",$gameCategoriesSql);
- $NumGameCategories=count($gameCategoriesArr);
-
- for($i=0;$i<$NumCoach;$i++){
- $coach_id = $CoachArr[$i]['user_id'];
- $CoachArr[$i]['isfriend'] = "n";//count($friendsArr)." | ".$coach_id." || ";
- for($t=0;$t<count($friendsArr);$t++){
- if($friendsArr[$t]['nk_user_id_friend'] == $coach_id || $friendsArr[$t]['nk_user_id_owner'] == $coach_id){
- $CoachArr[$i]['isfriend'] = "y";
- break;
- }
- }
- $CoachArr[$i]['status'] = getUserStatus($CoachArr[$i]);
-
- $CoachArr[$i]['name']=show_to_control($CoachArr[$i]['name']);
- // $CoachArr[$i]['about']=show_to_control($CoachArr[$i]['user_about']);
- $Clanguage = explode(",",$CoachArr[$i]['language_ids']);
- $language='';
- for($l=0;$l<count($Clanguage);$l++)
- {
- if($Clanguage[$l]<>'')
- $language .=findlanguage($Clanguage[$l]).' , ';
- }
- $CoachArr[$i]['language']=substr($language,0,-2);
-
- $CoachArr[$i]['rating']=substr($rating,0,-2);
-
- $CoachArr[$i]['overall_rating']=number_format($CoachArr[$i]['overall_rating'], 1, '.', '');
-
- for($x=0; $x<$NumGameCategories; $x++){
- $userCategoriesPropSql = "SELECT * FROM ".TABLEPREFIX."_user_game_property p, nk_game_categories_properties c WHERE p.user_type_id = 3 AND p.user_id='".$coach_id."' AND p.user_type_id = 3
- AND p.category_id = ".$gameCategoriesArr[$x]['category_id']." AND c.property_id = p.property_id";
- $userCategoriesPropArr = $UserManagerObjAjax->GetRecords("All",$userCategoriesPropSql);
- $NumuserCategoriesProp=count($userCategoriesPropArr);
- $prop ='';
- for($y=0; $y<$NumuserCategoriesProp; $y++){
- $prop .= (($y > 0)?', ':'').$userCategoriesPropArr[$y]['property_name'];
- }
- $gameCategoriesArr[$x]['properties'] = $prop;
- }
- $CoachArr[$i]['categoriesArr'] = $gameCategoriesArr;
-
-
- $avail_type = explode(',',$CoachArr[$i]['availability_type']);
- if($avail_type[1]=='')
- {
- if($avail_type[0]=='O')
- $CoachArr[$i]['availability_type'] = 'Online';
- if($avail_type[0]=='L')
- {
- $CoachArr[$i]['availability_type'] = 'Local meet-up';
- $CoachArr[$i]['avail_local'] = 'Y';
- }
- }
- else
- {
- $CoachArr[$i]['availability_type'] = 'Online , Local meet-up';
- $CoachArr[$i]['avail_local'] = 'Y';
- }
-
- $CoachArr[$i]['availability_country'] = findvalue(TABLEPREFIX."_country","country_id",$CoachArr[$i]['availability_country'],"country_name");
- $CoachArr[$i]['availability_city'] = findvalue(TABLEPREFIX."_cities","city_id",$CoachArr[$i]['availability_city'],"city_key");
-
- $Sql_overall_tooptip="select rating_overall_tooltip from ".TABLEPREFIX."_default_comision";
- $overall_tooptip=$UserManagerObjAjax->GetRecords("Row",$Sql_overall_tooptip);
- $CoachArr[$i]['rating_overall_tooltip']=html_entity_decode($overall_tooptip['rating_overall_tooltip']);
-
- $totalReviewSql = "SELECT count(*) FROM ".TABLEPREFIX."_user_review WHERE user_id=".$CoachArr[$i]['user_id']." AND user_type_id=3";
- $totalR = $UserManagerObjAjax->GetRecords("Row",$totalReviewSql);
- $CoachArr[$i]['totalReview'] = $totalR[0];
-
- $Sql_Individual="select avg(rat.rating) as tot,rat.rcat_id,cat.rating_category,cat.rating_category_tooltip from ".TABLEPREFIX."_user_rating as rat,".TABLEPREFIX."_user_review as rev,".TABLEPREFIX."_rating_category as cat where rat.rcat_id=cat.rcat_id and rat.user_review_id=rev.user_review_id and rev.user_id=".$CoachArr[$i]['user_id']." and rev.user_type_id=3 group by rat.rcat_id";
- $Individual=$UserManagerObjAjax->GetRecords("All",$Sql_Individual);
-
- for($j=0;$j<count($Individual);$j++){
-
- $CatIndividualRec[$i][$j]['rating']=number_format($Individual[$j]['tot'], 1, '.', '');
- $CatIndividualRec[$i][$j]['rcat_id']=$Individual[$j]['rcat_id'];
- $CatIndividualRec[$i][$j]['rating_category']=$Individual[$j]['rating_category'];
- $CatIndividualRec[$i][$j]['rating_category_tooltip']=html_entity_decode($Individual[$j]['rating_category_tooltip']);
- }
-
- /*echo '<pre>';
- print_r($CatIndividualRec);*/
- }
- $city = findvalue(TABLEPREFIX."_cities","city_id",$availability_city,"city_key");
-
- $gameSql = "SELECT game_id,game_name FROM ".TABLEPREFIX."_game where status=1 ORDER BY game_name";
- $GameArr = $UserManagerObjAjax->HtmlOptionArrayCreate($gameSql);
- //print_r($ladder_id);
- $smarty->assign('prop_id',$prop_id);
- $smarty->assign('username',$username);
-
- $smarty->assign('rating_id',$rating_id);
- $smarty->assign('language_id',$language_id);
- $smarty->assign('availability',$availability);
- $smarty->assign("SearchTxt",$SearchTxt);
- $smarty->assign("GameArr",$GameArr);
- $smarty->assign('page_name',$page_name);
- $smarty->assign('sort_by',$sort_by);
- $smarty->assign('game_id',$game_id);
- $smarty->assign('game_name',$game_name);
- $smarty->assign('Numladder',$Numladder);
- $smarty->assign('LadderArr',$LadderArr);
- $smarty->assign('Numrace',$Numrace);
- $smarty->assign('RaceArr',$RaceArr);
- $smarty->assign('city',$city);
- $smarty->assign('cityid',$availability_city);
- $smarty->assign('availability_country',$availability_country);
- $smarty->assign('availability_city',$availability_city);
- $smarty->assign('Numserver',$Numserver);
- $smarty->assign('ServerArr',$ServerArr);
- $smarty->assign('Numlanguage',$Numlanguage);
- $smarty->assign('LangArr',$LangArr);
- $smarty->assign('StarArr',$StarArr);
- $smarty->assign("CoachArr",$CoachArr);
- $smarty->assign('pagination_arr',$pagination_arr);
- $smarty->assign("NumCoach",$NumCoach);
- $smarty->assign("CatIndividualRec",$CatIndividualRec);
- if($IsProcess <> 'Y')
- include "training_partner_leftpanel.php";
- $smarty->display('find_training_partner.tpl');
- if($IsProcess <> 'Y')
- include "footer.php";
- ?>