Example #1
0
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $id = $this->_helper->IdConvert->hexToStr($id);
     $logic = new Logic_User();
     $form = new Logic_User_Form_Generic(true);
     if ($request->isPost()) {
         if ($form->isCancelled($this->getRequest()->getPost())) {
             $this->_helper->redirector('index', null, null);
             return;
         }
         $post = $request->getPost();
         if ($form->isValid($post)) {
             try {
                 $logic->updateUser($form, $id, isset($post['force']));
                 //                    $this->_helper->messenger->success('Zmiana danych konta użytkownika czeka na akceptację.');
                 $this->_helper->messenger->success('Zmieniono dane konta użytkownika');
                 $this->_helper->redirector('index');
                 return;
             } catch (Logic_User_RecklessChangeAttemptException $e) {
                 $ldapData = $e->expected;
                 $form->first_name->setValue($ldapData['first_name']);
                 $form->surname->setValue($ldapData['surname']);
                 $form->email->setValue($ldapData['email']);
                 $logic->updateUser($form, $id, isset($post['force']));
                 $this->_helper->messenger->success('Dane zostały zapisane zgodnie z danymi z domeny');
                 $this->_helper->redirector('index');
                 /*$form->clearErrorMessages();
                   $form->addElement('hidden', 'ldap_mismatch', array(
                       'value' => str_replace('"', '~', (string) $e),
                       'decorators' => array(
                           'ViewHelper',
                       )
                   ));*/
             } catch (Logic_Exception $e) {
                 $this->_helper->messenger->error($e->getMessage());
             }
         }
     } else {
         $data = array();
         try {
             $data = $logic->showUser($id);
         } catch (Logic_Branch_Exception $e) {
             $this->_helper->messenger->error();
             $this->_helper->redirector('index');
             return;
         }
         $form->setDefaults($data->toArray());
     }
     $this->view->form = $form;
 }