public function addAction() { $logic = new Logic_Ws_Cert(); $form = new Logic_Ws_Service_Form_Cert_Generic(); if ($this->getRequest()->isPost()) { if ($form->isCancelled($this->getRequest()->getPost())) { $this->_helper->messenger('error', 'Anulowano proces.'); return $this->_helper->redirector('index', null, null); } elseif ($form->isValid($this->getRequest()->getPost())) { try { $values = $form->getValues(); $logic->saveCertificateFiles($values['ws_service_id'], $form->getReceivedFiles()); } catch (Exception $e) { $this->_helper->messenger->error($e->getMessage()); } return $this->_helper->redirector('index', null, null); } } $this->view->form = $form; }
/** * @return void */ public function editAction() { $request = $this->getRequest(); $id = $this->_helper->IdConvert->hexToStr($request->getParam('id')); $form = new $this->_addForm(null, 0, array(), true); $logic = new Logic_Ws_Service(new $this->_model()); $appEnvs = Logic_Ws_Service::getServiceAppEnvs(); if ($request->isPost()) { if ($form->isCancelled($this->getRequest()->getPost())) { return $this->_helper->redirector('index', null, null); } if ($form->isValid($request->getPost())) { try { $value = $form->getValues(); $logic->createOrUpdateService($value, $id); $logic->addLimits(array('min' => $value['min'], 'max' => $value['max']), $id); $files = $form->getReceivedFiles(); if (false === empty($files)) { $certLogic = new Logic_Ws_Cert(); $certLogic->saveCertificateFiles($id, $files); } $this->_helper->messenger->success(); return $this->_helper->redirector('index'); } catch (Logic_Ws_Exception $e) { $this->_helper->messenger->error(); } } } try { $serviceRow = $logic->getService($id); } catch (Zend_Db_Exception $e) { $this->_helper->messenger->error($e->getMessage()); return $this->_helper->redirector('index'); } $defaults = $serviceRow->toArray(); $getLimits = $logic->getLimitsForService($id, array()); if ($getLimits->count() > 0) { $getLimits = Zend_Json_Decoder::decode($getLimits->getRow(0)->validator_params); foreach ($getLimits as $key => $getLimit) { $defaults[$key] = $getLimit; } } $defaults['mask'] = $serviceRow->getMasks(); $form->setDefaults($defaults); $this->view->form = $form; }