AAAAhome/academiac/www/administrator/components/com_virtuemart/models/state.php000060400000007763151372163450023450 0ustar00setMainTable('states'); $this->_selectedOrderingDir = 'ASC'; } /** * Retrieve the detail record for the current $id if the data has not already been loaded. * * Renamed to getSingleState to avoid overwriting by jseros * * @author Max Milbers */ function getSingleState(){ if (empty($this->_data)) { $this->_data = $this->getTable('states'); $this->_data->load((int)$this->_id); } return $this->_data; } /** * Retireve a list of countries from the database. * * @author RickG, Max Milbers * @return object List of state objects */ public function getStates($countryId, $noLimit=false, $published = false) { $quer= 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.(int)$countryId.'" '; if($published){ $quer .= 'AND `published`="1" '; } $quer .= 'ORDER BY `#__virtuemart_states`.`state_name`'; if ($noLimit) { $this->_data = $this->_getList($quer); } else { $this->_data = $this->_getList($quer, $this->getState('limitstart'), $this->getState('limit')); } if(count($this->_data) >0){ $this->_total = $this->_getListCount($quer); } return $this->_data; } /** * Tests if a state and country fits together and if they are published * * @author Max Milbers * @return String Attention, this function gives a 0=false back in case of success */ public static function testStateCountry($countryId,$stateId) { $countryId = (int)$countryId; $stateId = (int)$stateId; vmdebug('testStateCountry country '.$countryId.' $stateId '.$stateId); $db = JFactory::getDBO(); $q = 'SELECT * FROM `#__virtuemart_countries` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `published`="1" '; $db->setQuery($q); if($db->loadResult()){ //Test if country has states $q = 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `published`="1" '; $db->setQuery($q); if($res = $db->loadResult()){ vmdebug('testStateCountry country has states ',$res); //Test if virtuemart_state_id fits to virtuemart_country_id $q = 'SELECT * FROM `#__virtuemart_states` WHERE `virtuemart_country_id`= "'.$countryId.'" AND `virtuemart_state_id`="'.$stateId.'" and `published`="1"'; $db->setQuery($q); if($db->loadResult()){ return true; } else { //There is a country, but the state does not exist or is unlisted return false; } } else { vmdebug('testStateCountry country has no states listed'); //This country has no states listed return true; } } else { //The given country does not exist, this can happen, when no country was chosen, which maybe valid. return true; } } } // pure php no closing taghome/academiac/www/administrator/components/com_virtuemart/controllers/state.php000060400000003164151372432640024522 0ustar00redirectPath .= ($country > 0) ? '&virtuemart_country_id=' . $country : ''; } /** * Retrieve full statelist */ function getList() { /* Create the view object. */ $view = $this->getView('state', 'json'); /* Now display the view. */ $view->display(null); } } home/academiac/www/components/com_virtuemart/controllers/state.php000060400000003035151374535310021637 0ustar00getStates( JFilterInput::clean($country, 'INTEGER'),true,true ); } echo json_encode($states); jExit(); } }