Example #1
0
 public function put($d = array())
 {
     $res = new responseBup();
     $id = $this->_getIDFromReq($d);
     $d = prepareParamsBup($d);
     if (is_numeric($id) && $id) {
         if (isset($d['active'])) {
             $d['active'] = is_string($d['active']) && $d['active'] == 'true' || $d['active'] == 1 ? 1 : 0;
         }
         //mmm.... govnokod?....)))
         /* else
            $d['active'] = 0;*/
         if (frameBup::_()->getTable('modules')->update($d, array('id' => $id))) {
             $res->messages[] = langBup::_('Module Updated');
             $mod = frameBup::_()->getTable('modules')->getById($id);
             $newType = frameBup::_()->getTable('modules_type')->getById($mod['type_id'], 'label');
             $newType = $newType['label'];
             $res->data = array('id' => $id, 'label' => $mod['label'], 'code' => $mod['code'], 'type' => $newType, 'params' => utilsBup::jsonEncode($mod['params']), 'description' => $mod['description'], 'active' => $mod['active']);
         } else {
             if ($tableErrors = frameBup::_()->getTable('modules')->getErrors()) {
                 $res->errors = array_merge($res->errors, $tableErrors);
             } else {
                 $res->errors[] = langBup::_('Module Update Failed');
             }
         }
     } else {
         $res->errors[] = langBup::_('Error module ID');
     }
     parent::put($d);
     return $res;
 }