assign('loggedon','Yes'); } $smarty->assign('group_search_form','groupsearchinfo'); $right_advertising=array('banner_tower120x480'); $smarty->assign('right_advertising',$right_advertising); $smarty->assign($_SESSION); $smarty->assign('page','group_search'); $smarty->debugging=DEBUGGING; include("group_form_options.inc"); include_once("group_profile_options.inc"); // $searches = $_SESSION['cs']['member']->fetchGroupSearches(); // $saved_searches = count($searches); // $smarty->assign('saved_searches', $saved_searches); // $saved_array = array(); // for($i=0; $i < $saved_searches ; $i++){ // $saved_array[$i] = $searches[$i]->getSearchName(); // $_SESSION['cs']['groupsavedlist'][$i] = $searches[$i]->getID(); // } // // $smarty->assign('saved_array', $saved_array); //print_r($_POST); //print_r($_SESSION['cs']['group_saved_searches']); if($_POST['delete'] == "1"){ $_SESSION['cs']['group_search']->setDeleted(true); $_SESSION['cs']['group_search']->setActive(false); $_SESSION['cs']['group_search']->save(); unset($_SESSION['cs']['group_search']); //UPDATE SAVED GROUP SEARCHES IN THE SESSION unset($_SESSION['cs']['group_saved_searches']); unset($_SESSION['cs']['group_saved_searchnames']); if($_SESSION['cs']['member'] instanceof Member){ $_SESSION['cs']['group_saved_searches'] = $_SESSION['cs']['member']->fetchGroupSearches(); } $group_saved_searches = count($_SESSION['cs']['group_saved_searches']); for($i=0; $i < $group_saved_searches ; $i++){ $_SESSION['cs']['group_saved_searchnames'][$i] = $_SESSION['cs']['group_saved_searches'][$i]->getSearchName(); } header("Location:group_search.html"); }elseif(empty($_POST) OR $_POST['Group_Saved'] == "2" OR $_POST['Group_Saved_Choice'] == "New") { //MAKE SURE THE RIGHT SAVED SEARCH IS IN THE SESSION, SET THE VALIDATORS, AND DISPLAY THE EDIT FORM if($_POST['Group_Saved_Choice'] >= "0"){ $sel = $_POST['Group_Saved_Choice']; $_SESSION['cs']['group_search'] = $_SESSION['cs']['group_saved_searches'][$sel]; //print_r($_SESSION['cs']['group_search']); } if((!$_POST['Group_Saved'] AND !$_GET['nf']) or !$_SESSION['cs']['group_search'] instanceof Group_Search){ $_SESSION['cs']['group_search'] = new Group_Search; } if($_GET['nf']){ $smarty->assign('notfound',TRUE); } // Reset the form to make sure there is no old session data in there SmartyValidate::connect($smarty, true); //SmartyValidate::register_validator('minstartmake','minstart','dummyValid',false,false,'makeDate'); //SmartyValidate::register_validator('maxstartmake','maxstart','dummyValid',false,false,'makeDate'); //SmartyValidate::register_validator('minendmake','minend','dummyValid',false,false,'makeDate'); //SmartyValidate::register_validator('maxendmake','maxend','dummyValid',false,false,'makeDate'); SmartyValidate::register_form('groupsearchinfo', $reset = true); SmartyValidate::register_validator('searchname','searchname:!^w+|[0-9]+|[A-Z]+|[a-z]+|[punct]+$!','isRegExp',true,false,'','groupsearchinfo'); SmartyValidate::register_validator('zip','zip:!^w+|[0-9]+|[A-Z]+|[a-z]+|[punct]+$!','isRegExp',true,false,'','groupsearchinfo'); //SmartyValidate::register_validator('searchname','searchname:!^w+|[0-9]+|[A-Z]+|[a-z]+|[punct]+$!','isRegExp',true,false); //SmartyValidate::register_validator('zip','zip:!^w+|[0-9]+|[A-Z]+|[a-z]+|[punct]+$!','isRegExp',true,false); $smarty->assign($_SESSION); $smarty->display('CS_wrapper1.tpl'); }elseif($_POST['group_name'] or $_POST['index_search']){ $_SESSION['cs']['group_name_search'] = $_POST['group_name']; $groupname = addslashes($_POST['group_name']); $sql = "SELECT tbGroup.id FROM tbGroup, tbGroupProfile WHERE tbGroup.name = \"$groupname\" AND tbGroupProfile.public = \"1\" AND tbGroup.active = true AND tbGroup.deleted != true AND tbGroupProfile.active = true AND tbGroupProfile.deleted != true AND tbGroup.ProfileID = tbGroupProfile.id LIMIT 0, 800 "; //echo $sql; $f = new Finder(); $result = $f->execSQL($sql); if(mysql_num_rows($result)) { for($matchcount=0; $matchcount < mysql_num_rows($result); $matchcount++){ $resultarray = mysql_fetch_array($result , MYSQL_NUM); $matches[$matchcount] = $resultarray[0]; } } $_SESSION['cs']['group_search_results'] = $matches; if(is_array($_SESSION['cs']['group_search_results'])){ header("Location:group_search_results.html?p=1"); }else{ $_SESSION['cs']['group_name_search_nf'] = true; header("Location:my_ubashare.html"); } }else{ $run_search = true; //SAVE THE SEARCH, UPDATE THE SEARCH LIST IN THE SESSION, THEN RUN THE SEARCH if($_POST['Group_Saved'] == "1"){ if($_POST['Group_Saved_Choice'] >= "0"){ $_SESSION['cs']['group_search'] = $_SESSION['cs']['group_saved_searches'][$_POST['Group_Saved_Choice']]; }else{ $_SESSION['cs']['group_search'] = new Group_Search; } }else{ SmartyValidate::connect($smarty); //if(SmartyValidate::is_valid($_POST)) { if(SmartyValidate::is_valid($_POST, $form='groupsearchinfo')) { // Close SmartyValidate SmartyValidate::disconnect(); //SAVE THE SEARCH REQUEST if(!$_SESSION['cs']['group_search'] instanceof Group_Search){ $_SESSION['cs']['group_search'] = new Group_Search; } $_SESSION['cs']['group_search'] = saveSearch($_POST , $_SESSION); //UPDATE SAVED GROUP SEARCHES IN THE SESSION unset($_SESSION['cs']['group_saved_searches']); unset($_SESSION['cs']['group_saved_searchnames']); if($_SESSION['cs']['member'] instanceof Member){ $_SESSION['cs']['group_saved_searches'] = $_SESSION['cs']['member']->fetchGroupSearches(); } $group_saved_searches = count($_SESSION['cs']['group_saved_searches']); for($i=0; $i < $group_saved_searches ; $i++){ $_SESSION['cs']['group_saved_searchnames'][$i] = $_SESSION['cs']['group_saved_searches'][$i]->getSearchName(); } }else{ unset($run_search); $smarty->assign($_POST); $smarty->assign($_SESSION); $smarty->display('CS_wrapper1.tpl'); } } if($run_search){ //RUN THE SEARCH IN THE SESSION $smarty->assign('notfound',false); if($_SESSION['cs']['group_search'] instanceof Group_Search){ $_SESSION['cs']['group_search_results'] = $_SESSION['cs']['group_search']->getMatches(); } if(!is_array($_SESSION['cs']['group_search_results'])){ $_SESSION['cs']['sql'] = $_SESSION['cs']['group_search_results']; header("Location:group_search.html?nf=1"); }else{ header("Location:group_search_results.html?p=1"); } } } /* ========================================================================= */ function saveSearch($params,$session){ $setsearch = $session['cs']['group_search']; if($session['cs']['member'] instanceof Member){ $setsearch->setMemberID($session['cs']['member']->getID()); } $setsearch->setMemberCost($params['membercost']); $setsearch->setMemberCostPeriod($params['membercostperiod']); $setsearch->setGuests($params['guests']); $setsearch->setMinStart($params['minstart']); $setsearch->setMaxStart($params['maxstart']); $setsearch->setMinEnd($params['minend']); $setsearch->setMaxEnd($params['maxend']); $setsearch->setAgeRanges($params['ageranges']); $setsearch->setGenderType($params['gendertype']); $setsearch->setOrientation($params['orientation']); $setsearch->set420Type($params['four_twenty']); $setsearch->setSmoking($params['smoking']); $setsearch->setDrinking($params['drinking']); $setsearch->setCleanliness($params['cleanliness']); $setsearch->setPets($params['pets']); $setsearch->setSpotsAvailable($params['spotsavailable']); $setsearch->setGroupSize($params['groupsize']); $setsearch->setState($params['state']); $setsearch->setRegion($params['region']); $setsearch->setArea($params['area']); $setsearch->setLocation($params['location']); $setsearch->setDistance($params['distance']); $setsearch->setZip($params['zip']); $setsearch->setSearchName($params['searchname']); if($params['searchname'] OR $setsearch->getID() > "0"){ if($params['delete'] == '1'){ $setsearch->setActive(false); $setsearch->setDeleted(true); } $setsearch->save(); } return $setsearch; } ?>