예제 #1
0
 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) {
         }
         
     }
 }
예제 #2
0
 private function resolveCountryNames($countryArray) {
     $out = '';
     if (count($countryArray) == 0) {
         return $out;
     }
     foreach ($countryArray as $code) {
         $out .= $this->_localize(Gpf_Country_Countries::getCountryName($code)) . ', ';
     }
     return substr($out, 0, -2);
 }
 private function setupCountries() {
     Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED);
     Gpf_Settings::set(Gpf_Settings_Gpf::DEFAULT_COUNTRY, "US");
 }
예제 #4
0
 /**
  * @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) {
         }
     }
 }