Example #1
0
 /**
  * Return the country name (e.g. "Canada") given the country code (e.g. "CA").
  * @param string $strCode The country code.
  * @return The country name.
  */
 public static function CountryByCode($strCode)
 {
     $objCountry = Country::LoadByCode($strCode);
     if ($objCountry instanceof Country) {
         return $objCountry->country;
     } else {
         return '';
     }
 }
Example #2
0
 public static function LoadByCountry($strCountry, $blnRestrict = false)
 {
     $objCountry = Country::LoadByCode($strCountry);
     if ($blnRestrict) {
         if (count(Destination::model()->countByAttributes(array('country' => $objCountry->id, 'state' => null)))) {
             $arrStates = State::model()->findAllByAttributes(array('country_id' => $objCountry->id, 'active' => 1), State::GetDefaultOrdering());
             return Destination::ConvertStatesToDestinations($objCountry->id, $arrStates);
         }
     }
     return Destination::model()->findAll('country IS NULL OR country=:t1 ' . Destination::GetDefaultOrdering(true), array(':t1' => $objCountry->id));
 }
Example #3
0
    $objPerson->SetPassword($objRow['password']);
    $objPerson->FirstName = $objRow['first_name'];
    $objPerson->LastName = $objRow['last_name'];
    $objPerson->Email = $objRow['email'];
    $objPerson->PasswordResetFlag = false;
    $objPerson->DisplayRealNameFlag = $objRow['display_real_name_flag'];
    $objPerson->DisplayEmailFlag = $objRow['display_email_flag'];
    $objPerson->OptInFlag = $objRow['opt_in_flag'];
    $objPerson->DonatedFlag = $objRow['donated_flag'];
    $objPerson->Location = $objRow['location'];
    $objPerson->Url = $objRow['url'];
    $objPerson->RegistrationDate = new QDateTime($objRow['registration_date']);
    if ($objRow['country_id']) {
        $objCountryResult = $objDb->query('SELECT * FROM country WHERE id=' . $objRow['country_id']);
        $objCountryRow = $objCountryResult->fetch_array();
        $objPerson->Country = Country::LoadByCode($objCountryRow['code']);
    }
    $objPerson->RefreshDisplayName();
    $objPerson->Save();
    if ($objPerson->Id != $objRow['id']) {
        Person::GetDatabase()->NonQuery('UPDATE person SET id=' . $objRow['id'] . ' WHERE id=' . $objPerson->Id);
    }
}
$intNewTopicLinkIdArray[3591] = 7;
$intNewTopicLinkIdArray[3578] = 7;
$intNewTopicLinkIdArray[3547] = 7;
$intNewTopicLinkIdArray[3455] = 7;
$intNewTopicLinkIdArray[3242] = 7;
$intNewTopicLinkIdArray[3244] = 7;
$objResult = $objDb->query('SELECT * FROM topic ORDER BY id');
while (QDataGen::DisplayWhileTask('Migrating Topics', $objResult->num_rows)) {
 /**
  * 18 Change destination tables and map to country/state ids
  */
 protected function actionConvertDestinationTables()
 {
     //Convert Wish List items to new formats
     //Ship to me
     //Ship to buyer
     //Keep in store
     //find and remove any destinations with an erroneous taxcode
     $sql = 'SELECT `id` FROM `xlsws_destination` WHERE `taxcode` NOT IN (SELECT xlsws_tax_code.lsid FROM xlsws_tax_code);';
     $array = Yii::app()->db->createCommand($sql)->queryAll();
     foreach ($array as $a) {
         Yii::log('Destination id ' . $a['id'] . 'deleted due to erroneous tax code', 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         _dbx('DELETE FROM `xlsws_destination` WHERE `id`=' . $a['id'] . ';');
     }
     $objDestinations = Destination::model()->findAll();
     foreach ($objDestinations as $objDestination) {
         if ($objDestination->country == "*") {
             $objDestination->country = null;
         } else {
             if (!is_numeric($objDestination->country)) {
                 $objC = Country::LoadByCode($objDestination->country);
                 $objDestination->country = $objC->id;
             }
         }
         if ($objDestination->state == "*" || $objDestination->state == null) {
             $objDestination->state = null;
         } else {
             if (!is_numeric($objDestination->state)) {
                 $objS = State::LoadByCode($objDestination->state, $objDestination->country);
                 $objDestination->state = $objS->id;
             }
         }
         if (!$objDestination->save()) {
             return print_r($objDestination->getErrors());
         }
     }
     //Need to map destinations to IDs before doing this
     _dbx("update `xlsws_destination` set country=null where country=0;");
     _dbx("update `xlsws_destination` set state=null where state=0;");
     _dbx("ALTER TABLE `xlsws_destination` CHANGE `country` `country` INT(11)  UNSIGNED  NULL  DEFAULT NULL;");
     _dbx("ALTER TABLE `xlsws_destination` CHANGE `state` `state` INT(11)  UNSIGNED  NULL  DEFAULT NULL;");
     _dbx("ALTER TABLE `xlsws_destination` CHANGE `taxcode` `taxcode` INT(11)  UNSIGNED  NULL  DEFAULT NULL;");
     _dbx("ALTER TABLE `xlsws_destination` ADD FOREIGN KEY (`state`) REFERENCES `xlsws_state` (`id`);");
     _dbx("ALTER TABLE `xlsws_destination` ADD FOREIGN KEY (`country`) REFERENCES `xlsws_country` (`id`);");
     _dbx("ALTER TABLE `xlsws_destination` ADD FOREIGN KEY (`taxcode`) REFERENCES `xlsws_tax_code` (`lsid`);");
     _dbx("ALTER TABLE `xlsws_category` CHANGE `custom_page` `custom_page` INT(11)  UNSIGNED  NULL  DEFAULT NULL;");
     _dbx("UPDATE `xlsws_category` set `custom_page`=null where `custom_page`=0;");
     _dbx("ALTER TABLE `xlsws_category` ADD FOREIGN KEY (`custom_page`) REFERENCES `xlsws_custom_page` (`id`);");
     _dbx("ALTER TABLE `xlsws_country` DROP `code_a3`;");
     _dbx("update `xlsws_shipping_tiers` set `class_name`='tieredshipping';");
     return array('result' => "success", 'makeline' => 19, 'tag' => 'Applying database schema changes', 'total' => 50);
 }
 public function setBillingCountryCode($strCountryCode)
 {
     $objBillingCountry = Country::LoadByCode($strCountryCode);
     if ($objBillingCountry === null) {
         $this->billingCountry = null;
     } else {
         $this->billingCountry = $objBillingCountry->id;
     }
 }