Exemplo n.º 1
0
 public function manage_update()
 {
     global $db;
     //eDebug($this->params,true);
     //countries
     $db->columnUpdate('geo_country', 'active', 0, 'active=1');
     foreach ($this->params['country'] as $country_id => $is_active) {
         $gc = new geoCountry($country_id);
         $gc->active = true;
         $gc->save();
     }
     //country default
     $db->columnUpdate('geo_country', 'is_default', 0, 'is_default=1');
     if (isset($this->params['country_default'])) {
         $gc = new geoCountry($this->params['country_default']);
         $db->setUniqueFlag($gc, 'geo_country', 'is_default', 'id=' . $gc->id);
         $gc->refresh();
     }
     //regions
     $db->columnUpdate('geo_region', 'active', 0, 'active=1');
     foreach ($this->params['region'] as $region_id => $is_active) {
         $gr = new geoRegion($region_id);
         $gr->active = true;
         if (isset($this->params['region_rank'][$region_id])) {
             $gr->rank = $this->params['region_rank'][$region_id];
         }
         $gr->save();
     }
     flash('message', gt('Address configurations successfully updated.'));
     redirect_to(array('controller' => 'address', 'action' => 'manage'));
 }