예제 #1
0
 public function save($d = array())
 {
     $id = 0;
     if (isset($d['opt_values']) && is_array($d['opt_values']) && !empty($d['opt_values'])) {
         if (isset($d['code']) && !empty($d['code'])) {
             $d['what'] = 'id';
             $id = $this->get($d);
             $id = intval($id);
             //echo $id.'|';
         }
         if ($id) {
             $updateData = array('value' => $d['opt_values'][$d['code']]);
             $checkArr = $this->get(array('code' => $d['code'], 'what' => 'value_type'));
             if ($checkArr == 'array' && !empty($checkArr)) {
                 $updateData['value'] = utilsBup::serialize($updateData['value']);
             }
             if (frameBup::_()->getTable('options')->update($updateData, array('id' => $id))) {
                 // Let's update data in current options params to avoid reload it from database
                 if (isset($d['code'])) {
                     $this->_setByCode($d['code'], $d['opt_values'][$d['code']]);
                 }
                 return true;
             } else {
                 $this->pushError(__('Option ' . $d['code'] . ' update Failed', BUP_LANG_CODE));
             }
         } else {
             $this->pushError(__('Invalid option ID or Code', BUP_LANG_CODE));
         }
     } else {
         $this->pushError(__('Empty data to save option', BUP_LANG_CODE));
     }
     return false;
 }