public function setCountriesFromOldConfigFile() {
     $countriesConfigFile = new CountriesConfigFile();
     try {
         $countries = $countriesConfigFile->read();	
     } catch (Gpf_Exception $e) {
     	Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED);
         return;
     }
     
     if ($countries == '') {
     	Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED);
     	return;
     }
     Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_DISABLED);
     $countriesCodesArray = preg_split('/,/', $countries);
     
     foreach ($countriesCodesArray as $countryCode) {
         $country = new Gpf_Db_Country();
         $country->setCountryCode($countryCode);
         $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId());
         try {
             $country->loadFromData(array(Gpf_Db_Table_Countries::COUNTRY_CODE, Gpf_Db_Table_Countries::ACCOUNTID));
             $country->setStatus(Gpf_Db_Country::STATUS_ENABLED);
             $country->save();
         } catch (Gpf_Exception $e) {
         }
         
     }
 }
 /**
  * @service country write
  *
  * @param $id
  * @return Gpf_Rpc_Action
  */
 public function setDefaultCountry(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_("Error changing default country"));
     $action->setInfoMessage($this->_("Default country changed"));
     try {
         $countryCode = $action->getParam('id');
         Gpf_Settings::set(Gpf_Settings_Gpf::DEFAULT_COUNTRY, $countryCode);
         $country = new Gpf_Db_Country();
         $country->setCountryCode($countryCode);
         $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId());
         $country->loadFromData(array(Gpf_Db_Table_Countries::COUNTRY_CODE, Gpf_Db_Table_Countries::ACCOUNTID));
         if ($country->getStatus() != Gpf_Db_Country::STATUS_ENABLED) {
             $country->setStatus(Gpf_Db_Country::STATUS_ENABLED);
             $country->save();
         }
         $action->addOk();
     } catch (Exception $e) {
         $action->addError();
     }
     return $action;
 }
 protected function getCountryName($country_code){
     if($country_code == null) {
         return '';
     }
     $country = new Gpf_Db_Country();
     $country->setCountryCode($country_code);
     try {
         $country->loadFromData();
         return Gpf_Lang::_localizeRuntime($country->getCountry());
     } catch (Gpf_Exception $e) {
         return '';
     }
 }
 /**
  * @param $countryStatus (E - Enabled, D - Disabled, defined in Gpf_Db_Country)
  */
 public static function insertCountriesToDB($countryStatus)
 {
     if (self::$countries == null) {
         self::$countries = self::createCountries();
     }
     foreach (self::$countries as $code => $name) {
         $country = new Gpf_Db_Country();
         $country->setCountryCode($code);
         $country->setCountry($name);
         $country->setStatus($countryStatus);
         $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId());
         try {
             $country->save();
         } catch (Gpf_DbEngine_Row_ConstraintException $e) {
         }
     }
 }