当前位置: 首页>>代码示例>>PHP>>正文


PHP Country::update方法代码示例

本文整理汇总了PHP中Country::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::update方法的具体用法?PHP Country::update怎么用?PHP Country::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Country的用法示例。


在下文中一共展示了Country::update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->tagRepository->findById($id);
     $val = $this->tagRepository->getEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->tagRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->tagRepository->errors())->withInput();
     }
     return Redirect::action('AdminTagsController@index')->with('success', 'Tag Updated');
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:18,代码来源:AdminTagsController.php

示例2: _installStates

 /**
  * @param SimpleXMLElement $xml
  * @return bool
  * @throws PrestaShopException
  */
 protected function _installStates($xml)
 {
     if (isset($xml->states->state)) {
         foreach ($xml->states->state as $data) {
             /** @var SimpleXMLElement $data */
             $attributes = $data->attributes();
             $id_country = $attributes['country'] ? (int) Country::getByIso(strval($attributes['country'])) : false;
             $id_state = $id_country ? State::getIdByIso($attributes['iso_code'], $id_country) : State::getIdByName($attributes['name']);
             if (!$id_state) {
                 $state = new State();
                 $state->name = strval($attributes['name']);
                 $state->iso_code = strval($attributes['iso_code']);
                 $state->id_country = $id_country;
                 $id_zone = (int) Zone::getIdByName(strval($attributes['zone']));
                 if (!$id_zone) {
                     $zone = new Zone();
                     $zone->name = (string) $attributes['zone'];
                     $zone->active = true;
                     if (!$zone->add()) {
                         $this->_errors[] = Tools::displayError('Invalid Zone name.');
                         return false;
                     }
                     $id_zone = $zone->id;
                 }
                 $state->id_zone = $id_zone;
                 if (!$state->validateFields()) {
                     $this->_errors[] = Tools::displayError('Invalid state properties.');
                     return false;
                 }
                 $country = new Country($state->id_country);
                 if (!$country->contains_states) {
                     $country->contains_states = 1;
                     if (!$country->update()) {
                         $this->_errors[] = Tools::displayError('Cannot update the associated country: ') . $country->name;
                     }
                 }
                 if (!$state->add()) {
                     $this->_errors[] = Tools::displayError('An error occurred while adding the state.');
                     return false;
                 }
             } else {
                 $state = new State($id_state);
                 if (!Validate::isLoadedObject($state)) {
                     $this->_errors[] = Tools::displayError('An error occurred while fetching the state.');
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:56,代码来源:LocalizationPack.php

示例3: _installStates

 protected function _installStates($xml)
 {
     if (isset($xml->states->state)) {
         foreach ($xml->states->state as $data) {
             $attributes = $data->attributes();
             if (!($id_state = State::getIdByName($attributes['name']))) {
                 $state = new State();
                 $state->name = strval($attributes['name']);
                 $state->iso_code = strval($attributes['iso_code']);
                 $state->id_country = Country::getByIso(strval($attributes['country']));
                 $state->id_zone = (int) Zone::getIdByName(strval($attributes['zone']));
                 if (!$state->validateFields()) {
                     $this->_errors[] = Tools::displayError('Invalid state properties.');
                     return false;
                 }
                 $country = new Country($state->id_country);
                 if (!$country->contains_states) {
                     $country->contains_states = 1;
                     if (!$country->update()) {
                         $this->_errors[] = Tools::displayError('Cannot update the associated country: ') . $country->name;
                     }
                 }
                 if (!$state->add()) {
                     $this->_errors[] = Tools::displayError('An error occurred while adding the state.');
                     return false;
                 }
             } else {
                 $state = new State($id_state);
                 if (!Validate::isLoadedObject($state)) {
                     $this->_errors[] = Tools::displayError('An error occurred while fetching the state.');
                     return false;
                 }
             }
             // Add counties
             foreach ($data->county as $xml_county) {
                 $county_attributes = $xml_county->attributes();
                 if (!($id_county = County::getIdCountyByNameAndIdState($county_attributes['name'], $state->id))) {
                     $county = new County();
                     $county->name = $county_attributes['name'];
                     $county->id_state = (int) $state->id;
                     $county->active = 1;
                     if (!$county->validateFields()) {
                         $this->_errors[] = Tools::displayError('Invalid County properties');
                         return false;
                     }
                     if (!$county->save()) {
                         $this->_errors[] = Tools::displayError('An error has occurred while adding the county');
                         return false;
                     }
                 } else {
                     $county = new County((int) $id_county);
                     if (!Validate::isLoadedObject($county)) {
                         $this->_errors[] = Tools::displayError('An error occurred while fetching the county.');
                         return false;
                     }
                 }
                 // add zip codes
                 foreach ($xml_county->zipcode as $xml_zipcode) {
                     $zipcode_attributes = $xml_zipcode->attributes();
                     $zipcodes = $zipcode_attributes['from'];
                     if (isset($zipcode_attributes['to'])) {
                         $zipcodes .= '-' . $zipcode_attributes['to'];
                     }
                     if ($county->isZipCodeRangePresent($zipcodes)) {
                         continue;
                     }
                     if (!$county->addZipCodes($zipcodes)) {
                         $this->_errors[] = Tools::displayError('An error has occurred while adding zipcodes');
                         return false;
                     }
                 }
             }
         }
     }
     return true;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:76,代码来源:LocalizationPack.php

示例4: doModel

    function doModel()
    {
        switch ($this->action) {
            case 'comments':
                //calling the comments settings view
                $this->doView('settings/comments.php');
                break;
            case 'comments_post':
                // updating comment
                $iUpdated = 0;
                $enabledComments = Params::getParam('enabled_comments');
                $enabledComments = $enabledComments != '' ? true : false;
                $moderateComments = Params::getParam('moderate_comments');
                $moderateComments = $moderateComments != '' ? true : false;
                $numModerateComments = Params::getParam('num_moderate_comments');
                $commentsPerPage = Params::getParam('comments_per_page');
                $notifyNewComment = Params::getParam('notify_new_comment');
                $notifyNewComment = $notifyNewComment != '' ? true : false;
                $notifyNewCommentUser = Params::getParam('notify_new_comment_user');
                $notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
                $regUserPostComments = Params::getParam('reg_user_post_comments');
                $regUserPostComments = $regUserPostComments != '' ? true : false;
                $msg = '';
                if (!osc_validate_int(Params::getParam("num_moderate_comments"))) {
                    $msg .= _m("Number of moderate comments must only contain numeric characters") . "<br/>";
                }
                if (!osc_validate_int(Params::getParam("comments_per_page"))) {
                    $msg .= _m("Comments per page must only contain numeric characters") . "<br/>";
                }
                if ($msg != '') {
                    osc_add_flash_error_message($msg, 'admin');
                    $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
                if ($moderateComments) {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
                } else {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewCommentUser), array('s_name' => 'notify_new_comment_user'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
                if ($iUpdated > 0) {
                    osc_add_flash_ok_message(_m("Comment settings have been updated"), 'admin');
                }
                $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                break;
            case 'locations':
                // calling the locations settings view
                $location_action = Params::getParam('type');
                $mCountries = new Country();
                switch ($location_action) {
                    case 'add_country':
                        // add country
                        $countryCode = strtoupper(Params::getParam('c_country'));
                        $countryName = Params::getParam('country');
                        $exists = $mCountries->findByCode($countryCode);
                        if (isset($exists['s_name'])) {
                            osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                        } else {
                            $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
                            $countries = json_decode($countries_json);
                            $mCountries->insert(array('pk_c_code' => $countryCode, 's_name' => $countryName));
                            CountryStats::newInstance()->setNumItems($countryCode, 0);
                            if (isset($countries->error)) {
                                // Country is not in our GEO database
                                // We have no region for user-typed countries
                            } else {
                                // Country is in our GEO database, add regions and cities
                                $manager_region = new Region();
                                $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
                                $regions = json_decode($regions_json);
                                if (!isset($regions->error)) {
                                    if (count($regions) > 0) {
                                        foreach ($regions as $r) {
                                            $manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                                            $id = $manager_region->dao->insertedId();
                                            RegionStats::newInstance()->setNumItems($id, 0);
                                        }
                                    }
                                    unset($regions);
                                    unset($regions_json);
                                    $manager_city = new City();
                                    if (count($countries) > 0) {
                                        foreach ($countries as $c) {
                                            $regions = $manager_region->findByCountry($c->id);
                                            if (!isset($regions->error)) {
                                                if (count($regions) > 0) {
                                                    foreach ($regions as $region) {
                                                        $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&region=' . urlencode($region['s_name']) . '&term=all');
                                                        $cities = json_decode($cities_json);
                                                        if (!isset($cities->error)) {
                                                            if (count($cities) > 0) {
                                                                foreach ($cities as $ci) {
                                                                    $manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
                                                                    $id = $manager_city->dao->insertedId();
                                                                    CityStats::newInstance()->setNumItems($id, 0);
                                                                }
                                                            }
//.........这里部分代码省略.........
开发者ID:semul,项目名称:Osclass,代码行数:101,代码来源:settings.php

示例5: array

$GeneralObj->getRequestVars();
$CountryObj->setAllVar();
$iCountryId = $_POST["iCountryId"];
$redirect_file = "index.php?file=t-country_masteradd&mode={$mode}&iCountryId={$iCountryId}";
/*
 $ext='';
if($_REQUEST['keyword'] !='')
{
$ext .="&keyword=".$_REQUEST['keyword'];
}
if($_REQUEST['option'] !='')
{
$ext .="&option=".$_REQUEST['option'];
}  */
$GeneralObj->checkDuplicate('iCountryId', 'country_master', array('vCountry'), $redirect_file, MSG_ALLREADY_EXIST, $iCountryId);
$msg = MSG_ALLREADY_EXIST;
if ($mode == "Add") {
    //$CountryObj->setvCountry($_POST["vCountry"]);
    $lastcountryid = $CountryObj->insert();
    $msg = MSG_ADD;
    header("Location:index.php?file=Country&AX=Yes&var_msg={$msg}" . $ExtraVal);
    //exit;
} else {
    if ($mode == "Update") {
        //	$CountryObj->setvCountry($_POST["vCountry"]);
        $CountryObj->update($iCountryId);
        $msg = MSG_UPDATE;
        header("Location:index.php?file=Country&AX=Yes&var_msg={$msg}" . $ExtraVal);
        exit;
    }
}
开发者ID:redeyes1024,项目名称:medlii_mlm_backend,代码行数:31,代码来源:country_masteradd_a.php

示例6: install

 public function install()
 {
     include dirname(__FILE__) . '/sql-install.php';
     foreach ($sql as $s) {
         if (!Db::getInstance()->Execute($s)) {
             return false;
         }
     }
     if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('adminOrder') || !$this->registerHook('paymentReturn') || !$this->registerHook('orderConfirmation')) {
         return false;
     }
     $this->registerHook('displayPayment');
     $this->registerHook('rightColumn');
     $this->registerHook('extraRight');
     $this->registerHook('header');
     if (!Configuration::get('KLARNA_PAYMENT_ACCEPTED')) {
         Configuration::updateValue('KLARNA_PAYMENT_ACCEPTED', $this->addState('Klarna: Payment accepted', '#DDEEFF'));
     }
     if (!Configuration::get('KLARNA_PAYMENT_PENDING')) {
         Configuration::updateValue('KLARNA_PAYMENT_PENDING', $this->addState('Klarna : payment in pending verification', '#DDEEFF'));
     }
     /*auto install currencies*/
     $currencies = array('Euro' => array('iso_code' => 'EUR', 'iso_code_num' => 978, 'symbole' => '€', 'format' => 2), 'Danish Krone' => array('iso_code' => 'DKK', 'iso_code_num' => 208, 'symbole' => 'DAN kr.', 'format' => 2), 'krone' => array('iso_code' => 'NOK', 'iso_code_num' => 578, 'symbole' => 'NOK kr', 'format' => 2), 'Krona' => array('iso_code' => 'SEK', 'iso_code_num' => 752, 'symbole' => 'SEK kr', 'format' => 2));
     $languages = array('Swedish' => array('iso_code' => 'se', 'language_code' => 'sv', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'sweden.png'), 'Deutsch' => array('iso_code' => 'de', 'language_code' => 'de', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'germany.png'), 'Dutch' => array('iso_code' => 'nl', 'language_code' => 'nl', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'netherlands.png'), 'Finnish' => array('iso_code' => 'fi', 'language_code' => 'fi', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'finland.jpg'), 'Norwegian' => array('iso_code' => 'no', 'language_code' => 'no', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'norway.png'), 'Danish' => array('iso_code' => 'da', 'language_code' => 'da', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'denmark.png'));
     foreach ($currencies as $key => $val) {
         if (_PS_VERSION_ >= 1.5) {
             $exists = Currency::exists($val['iso_code_num'], $val['iso_code_num']);
         } else {
             $exists = Currency::exists($val['iso_code_num']);
         }
         if (!$exists) {
             $currency = new Currency();
             $currency->name = $key;
             $currency->iso_code = $val['iso_code'];
             $currency->iso_code_num = $val['iso_code_num'];
             $currency->sign = $val['symbole'];
             $currency->conversion_rate = 1;
             $currency->format = $val['format'];
             $currency->decimals = 1;
             $currency->active = true;
             $currency->add();
         }
     }
     Currency::refreshCurrencies();
     $version = str_replace('.', '', _PS_VERSION_);
     $version = substr($version, 0, 2);
     foreach ($languages as $key => $val) {
         $pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . $val['language_code'] . '.xml');
         if ($pack || ($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . $val['language_code'] . '.xml'))) {
             $localizationPack = new LocalizationPack();
             $localizationPack->loadLocalisationPack($pack, array('taxes', 'languages'));
         }
         if (!Language::getIdByIso($val['language_code'])) {
             if (_PS_VERSION_ >= 1.5) {
                 Language::checkAndAddLanguage($val['language_code']);
             } else {
                 $lang = new Language();
                 $lang->name = $key;
                 $lang->iso_code = $val['iso_code'];
                 $lang->language_code = $val['language_code'];
                 $lang->date_format_lite = $val['date_format_lite'];
                 $lang->date_format_full = $val['date_format_full'];
                 $lang->add();
                 $insert_id = (int) $lang->id;
                 $pack = Tools::file_get_contents('http://www.prestashop.com/download/localization/' . $val['iso_code'] . '.xml');
                 $lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $val['iso_code']));
                 if ($lang_pack) {
                     $flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/' . $val['iso_code'] . '.jpg');
                     if ($flag != null && !preg_match('/<body>/', $flag)) {
                         $file = fopen(dirname(__FILE__) . '/../../img/l/' . $insert_id . '.jpg', 'w');
                         if ($file) {
                             fwrite($file, $flag);
                             fclose($file);
                         }
                     }
                 }
             }
         }
     }
     foreach ($this->countries as $key => $val) {
         $country = new Country(Country::getByIso($key));
         $country->active = true;
         $country->update();
     }
     return true;
 }
开发者ID:juniorhq88,项目名称:PrestaShop-modules,代码行数:86,代码来源:klarnaprestashop.php

示例7: doModel

        function doModel()
        {
            // calling the locations settings view
            $location_action = Params::getParam('type');
            $mCountries = new Country();

            switch ($location_action) {
                case('add_country'):    // add country
                                        if( defined('DEMO') ) {
                                            osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
                                            $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
                                        }
                                        osc_csrf_check();
                                        $countryCode = strtoupper(Params::getParam('c_country'));
                                        $countryName = Params::getParam('country');
                                        $exists = $mCountries->findByCode($countryCode);
                                        if(isset($exists['s_name'])) {
                                            osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                                        } else {
                                            if(Params::getParam('c_manual')==1) {
                                                $mCountries->insert(array('pk_c_code' => $countryCode,
                                                                        's_name' => $countryName));
                                                osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
                                            } else {
                                                if(!osc_validate_min($countryCode, 1) || !osc_validate_min($countryName, 1)) {
                                                    osc_add_flash_error_message(_m('Country code and name should have at least two characters'), 'admin');
                                                } else {
                                                    $data_sql = osc_file_get_contents('http://geo.osclass.org/newgeo.download.php?action=country&term=' . urlencode($countryCode) );

                                                    if($data_sql!='') {
                                                        $conn = DBConnectionClass::newInstance();
                                                        $c_db = $conn->getOsclassDb();
                                                        $comm = new DBCommandClass($c_db);
                                                        $comm->query("SET FOREIGN_KEY_CHECKS = 0");
                                                        $comm->importSQL($data_sql);
                                                        $comm->query("SET FOREIGN_KEY_CHECKS = 1");
                                                    } else {
                                                        $mCountries->insert(array('pk_c_code' => $countryCode,
                                                                                's_name' => $countryName));
                                                    }
                                                    osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
                                                }
                                            }
                                        }
                                        osc_calculate_location_slug(osc_subdomain_type());
                                        $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
                break;
                case('edit_country'):   // edit country
                                        if( defined('DEMO') ) {
                                            osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
                                            $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
                                        }
                                        osc_csrf_check();
                                        if(!osc_validate_min(Params::getParam('e_country'), 1)) {
                                            osc_add_flash_error_message(_m('Country name cannot be blank'), 'admin');
                                        } else {
                                            $name = Params::getParam('e_country');
                                            $slug = Params::getParam('e_country_slug');
                                            if($slug=='') {
                                                $slug_tmp = $slug = osc_sanitizeString($name);
                                            } else {
                                                $exists = $mCountries->findBySlug($slug);
                                                if(isset($exists['s_slug']) && $exists['pk_c_code']!=Params::getParam('country_code')) {
                                                    $slug_tmp = $slug = osc_sanitizeString($name);
                                                } else {
                                                    $slug_tmp = $slug = osc_sanitizeString($slug);
                                                }
                                            }
                                            $slug_unique = 1;
                                            while(true) {
                                                $location_slug = $mCountries->findBySlug($slug);
                                                if(isset($location_slug['s_slug']) && $location_slug['pk_c_code']!=Params::getParam('country_code')) {
                                                    $slug = $slug_tmp . '-' . $slug_unique;
                                                    $slug_unique++;
                                                } else {
                                                    break;
                                                }
                                            }

                                            $ok = $mCountries->update(array('s_name'=> $name, 's_slug' => $slug), array('pk_c_code' => Params::getParam('country_code')));

                                            if( $ok ) {
                                                osc_add_flash_ok_message(_m('Country has been edited'), 'admin');
                                            } else {
                                                osc_add_flash_error_message(_m('There were some problems editing the country'), 'admin');
                                            }
                                        }
                                        $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
                break;
                case('delete_country'): // delete country
                                        if( defined('DEMO') ) {
                                            osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
                                            $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
                                        }
                                        osc_csrf_check();
                                        $countryIds = Params::getParam('id');

                                        if(is_array($countryIds)) {
                                            $locations = 0;
                                            $del_locations = 0;
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:locations.php

示例8: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'items':
             // calling the items settings view
             $this->doView('settings/items.php');
             break;
         case 'items_post':
             // update item settings
             $iUpdated = 0;
             $enabledRecaptchaItems = Params::getParam('enabled_recaptcha_items');
             $enabledRecaptchaItems = $enabledRecaptchaItems != '' ? true : false;
             $enabledItemValidation = Params::getParam('enabled_item_validation');
             $enabledItemValidation = $enabledItemValidation != '' ? true : false;
             $loggedUserItemValidation = Params::getParam('logged_user_item_validation');
             $loggedUserItemValidation = $loggedUserItemValidation != '' ? true : false;
             $regUserPost = Params::getParam('reg_user_post');
             $regUserPost = $regUserPost != '' ? true : false;
             $notifyNewItem = Params::getParam('notify_new_item');
             $notifyNewItem = $notifyNewItem != '' ? true : false;
             $notifyContactItem = Params::getParam('notify_contact_item');
             $notifyContactItem = $notifyContactItem != '' ? true : false;
             $notifyContactFriends = Params::getParam('notify_contact_friends');
             $notifyContactFriends = $notifyContactFriends != '' ? true : false;
             $enabledFieldPriceItems = Params::getParam('enableField#f_price@items');
             $enabledFieldPriceItems = $enabledFieldPriceItems != '' ? true : false;
             $enabledFieldImagesItems = Params::getParam('enableField#images@items');
             $enabledFieldImagesItems = $enabledFieldImagesItems != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledRecaptchaItems), array('s_name' => 'enabled_recaptcha_items'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledItemValidation), array('s_name' => 'enabled_item_validation'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $loggedUserItemValidation), array('s_name' => 'logged_user_item_validation'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPost), array('s_name' => 'reg_user_post'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewItem), array('s_name' => 'notify_new_item'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyContactItem), array('s_name' => 'notify_contact_item'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyContactFriends), array('s_name' => 'notify_contact_friends'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledFieldPriceItems), array('s_name' => 'enableField#f_price@items'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledFieldImagesItems), array('s_name' => 'enableField#images@items'));
             if ($iUpdated > 0) {
                 osc_add_flash_message(_m('Items\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=items');
             break;
         case 'comments':
             //calling the comments settings view
             $this->doView('settings/comments.php');
             break;
         case 'comments_post':
             // updating comment
             $iUpdated = 0;
             $enabledComments = Params::getParam('enabled_comments');
             $enabledComments = $enabledComments != '' ? true : false;
             $moderateComments = Params::getParam('moderate_comments');
             $moderateComments = $moderateComments != '' ? true : false;
             $numModerateComments = Params::getParam('num_moderate_comments');
             $notifyNewComment = Params::getParam('notify_new_comment');
             $notifyNewComment = $notifyNewComment != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
             if ($moderateComments) {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
             } else {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
             }
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
             if ($iUpdated > 0) {
                 osc_add_flash_message(_m('Comments\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
             break;
         case 'users':
             // calling the users settings view
             $this->doView('settings/users.php');
             break;
         case 'users_post':
             // updating users
             $iUpdated = 0;
             $enabledUserValidation = Params::getParam('enabled_user_validation');
             $enabledUserValidation = $enabledUserValidation != '' ? true : false;
             $enabledUserRegistration = Params::getParam('enabled_user_registration');
             $enabledUserRegistration = $enabledUserRegistration != '' ? true : false;
             $enabledUsers = Params::getParam('enabled_users');
             $enabledUsers = $enabledUsers != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserValidation), array('s_name' => 'enabled_user_validation'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserRegistration), array('s_name' => 'enabled_user_registration'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUsers), array('s_name' => 'enabled_users'));
             if ($iUpdated > 0) {
                 osc_add_flash_message(_m('Users\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=users');
             break;
         case 'locations':
             // calling the locations settings view
             $location_action = Params::getParam('type');
             $mCountries = new Country();
             switch ($location_action) {
                 case 'add_country':
                     // add country
                     if (!Params::getParam('c_manual')) {
                         $this->install_location_by_country();
                     } else {
                         $countryCode = Params::getParam('c_country');
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:settings.php

示例9: PostVar

$iCountryId = PostVar("iCountryId");
$actionfile = GetVar("file");
/** This is for Check Duplicate Record-------------------------------------------*/
$generalobj->getRequestVars();
$redirect_file = "index.php?file={$file}&view={$view}&iCountryId={$iCountryId}";
$generalobj->checkDuplicate('iCountryId', PRJ_DB_PREFIX . "_country_master", array('vCountry' => $Data['vCountry']), $redirect_file, COUNTRY_ALREADY_EXISTS, $iCountryId);
if ($view == "add") {
    //prints($Data);exit;
    $countryObj->setAllVar($Data);
    $id = $countryObj->insert();
    if ($id) {
        $var_msg = "Record Added Successfully.";
    } else {
        $var_msg = "Eror-in Add.";
    }
} else {
    if ($view == "edit") {
        $arr = $countryObj->select($iCountryId);
        $countryObj->setAllVar($arr);
        $countryObj->setAllVar($Data);
        $where = " iCountryId = '" . $iCountryId . "'";
        $id = $countryObj->update($where);
        if ($id) {
            $var_msg = "Record Updated Successfully.";
        } else {
            $var_msg = "Eror-in Update.";
        }
    }
}
header("Location:index.php?file=" . $actionfile . "&view=index&AX=Yes&var_msg={$var_msg}");
exit;
开发者ID:nstungxd,项目名称:F2CA5,代码行数:31,代码来源:addcountry_a.php


注:本文中的Country::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。