Esempio n. 1
0
 protected function getForm()
 {
     $form = new UserForm();
     $user = new User();
     $form->bind($user);
     return $form;
 }
Esempio n. 2
0
 public function testAction()
 {
     //##-> ACCESS
     $form = new UserForm();
     $form->setConfig($this->getExternalService('user', 'user')->getFormConfig('user-edit'));
     return $this->view()->setTemplate('application/index/test')->setVars(array('form' => $form->getForm()))->getView();
 }
Esempio n. 3
0
 public function loginAction()
 {
     $form = new UserForm();
     $form->get('submit')->setValue('Login');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $sm = $this->getServiceLocator();
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $data = $request->getPost();
         $this->userService->login($data, $dbAdapter);
     }
     return array('form' => $form);
 }
Esempio n. 4
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /**
      * @var \Doctrine\ORM\EntityManager $entityManager
      */
     $entityManager = $serviceLocator->get('Doctrine\\ORM\\EntityManager');
     $formManager = $serviceLocator->get('FormElementManager');
     /**
      * @var UserFieldset $fieldset
      */
     $fieldset = $formManager->get('User\\Form\\UserFieldset');
     $form = new UserForm();
     $hydrator = new DoctrineHydrator($entityManager, '\\User\\Entity\\User');
     $fieldset->setUseAsBaseFieldset(true)->setHydrator($hydrator)->setObject(new User());
     $form->add($fieldset)->setInputFilter(new InputFilter())->setHydrator($hydrator);
     return $form;
 }
Esempio n. 5
0
 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $inputFilterManager = $serviceLocator->get('InputFilterManager');
     $form = new UserForm('delete');
     $form->addIdElement();
     $form->addCsrfElement();
     $form->addSubmitElement('delete', 'Löschen');
     $form->addSubmitElement('cancel', 'Abbrechen');
     $form->setInputFilter($inputFilterManager->get('User\\Filter\\User'));
     $form->setValidationGroup(array('id', 'delete', 'cancel'));
     return $form;
 }
 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $inputFilterManager = $serviceLocator->get('InputFilterManager');
     $form = new UserForm('register');
     $form->addCsrfElement();
     $form->addEmailElement();
     $form->addSubmitElement('save', 'Neues Passwort anfordern');
     $form->addSubmitElement('cancel', 'Abbrechen');
     $form->setInputFilter($inputFilterManager->get('User\\Filter\\User'));
     $form->setValidationGroup(array('email', 'save', 'cancel'));
     return $form;
 }
Esempio n. 7
0
 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $inputFilterManager = $serviceLocator->get('InputFilterManager');
     $form = new UserForm('login');
     $form->addCsrfElement();
     $form->addEmailElement();
     $form->addPassElement();
     $form->addSubmitElement('login', 'Einloggen');
     $form->setInputFilter($inputFilterManager->get('User\\Filter\\User'));
     $form->setValidationGroup(array('email', 'pass', 'login'));
     return $form;
 }
 public function loginAction()
 {
     $authStorage = new AuthenticationStorage(self::NAMESPACE_ZENDSTORE_FRONT);
     $authService = new AuthenticationService($authStorage);
     if ($authService->hasIdentity()) {
         echo 'You have logined';
         exit;
     }
     $form = new UserForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->post());
         if ($form->isValid()) {
             $data = $form->getData();
             // Authentication
             $sm = $this->getServiceLocator();
             $db = $sm->get('db-adapter');
             //$authAdapter = new AuthenticationAdapter($db, 'user', 'email', 'password', 'MD5(?)');
             $authAdapter = new AuthenticationAdapter($db, 'user', 'email', 'password', 'MD5(CONCAT(?, password_salt))');
             $authAdapter->setIdentity($data['email']);
             $authAdapter->setCredential($data['password']);
             $result = $authService->authenticate($authAdapter);
             if ($result->isValid()) {
                 return $this->redirect()->toRoute('user-front-user');
             } else {
                 var_dump($result->getMessages());
                 exit;
             }
         } else {
             echo '<h1>ERROR: Form data is invalid.</h1>';
             echo '<pre>';
             print_r($form->getMessages());
             exit;
         }
     }
     $viewVars = array('form' => $form);
     $viewModel = $this->getViewModel();
     $viewModel->setVariables($viewVars);
     return $viewModel;
 }
 public function addAction()
 {
     $form = new UserForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $User = new User();
         $form->setInputFilter($User->getInputFilter());
         $form->setData($request->getPost());
         $User->user_nom = $request->getPost('User_nom');
         $User->user_prenom = $request->getPost('User_prenom');
         $User->user_password = $request->getPost('Passwd');
         $bcrypt = new Bcrypt();
         $securePass = $bcrypt->create($User->user_password);
         $User->user_password = $securePass;
         // Sauvegarde
         $user_id = $this->getUserTable()->saveUser($User);
         return $this->redirect()->toRoute('User', array('user_id' => $user_id, 'action' => 'index'));
     }
     return array('form' => $form, 'erreur' => @$erreur);
 }
 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('user', array('action' => 'add'));
     }
     try {
         $user = $this->getUserTable()->getUser($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('user', array('action' => 'index'));
     }
     $form = new UserForm();
     $form->bind($user);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getUserTable()->saveUser($user);
             return $this->redirect()->toRoute('user');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
Esempio n. 11
0
 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $inputFilterManager = $serviceLocator->get('InputFilterManager');
     $form = new UserForm('logout');
     $form->addCsrfElement();
     $form->addSubmitElement('logout', 'Abmelden');
     $form->setInputFilter($inputFilterManager->get('User\\Filter\\User'));
     $form->setValidationGroup(array('logout'));
     return $form;
 }
Esempio n. 12
0
 public function addAction()
 {
     //        $user_session = new \Zend\Session\Container('user');
     //        if ($user_session->email == null) {
     //            return $this->redirect()->toRoute('signin', array(
     //                        'action' => 'signin'
     //            ));
     //        }
     //        if ($user_session->role == 'Operator') {
     //            return array('error' => 'You don\'t have permission to do this action');
     //        }
     $auth = new \Zend\Authentication\AuthenticationService();
     if ($auth->hasIdentity()) {
         $user = $auth->getIdentity();
     } else {
         return $this->redirect()->toRoute('signin', array('action' => 'index'));
     }
     if ($user->role == 'Operator') {
         //$this->flashMessenger()->addMessage('You don\'t have permission to do this action');
         //$this->redirect()->toRoute('add');
         return array('error' => 'You don\'t have permission to do this action');
     }
     $form = new UserForm(null, $user->role);
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $user->exchangeArray($form->getData());
             $this->getUserTable()->saveUser($user);
             return $this->redirect()->toRoute('user');
         } else {
             echo "Fail to add new user";
         }
     }
     return array('form' => $form, 'flashMessages' => $this->flashMessenger()->getMessages());
 }
Esempio n. 13
0
 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $inputFilterManager = $serviceLocator->get('InputFilterManager');
     $userEntity = $serviceLocator->get('User\\Entity\\User');
     $roleOptions = $userEntity->getRoleNames();
     $form = new UserForm('update');
     $form->addIdElement();
     $form->addCsrfElement();
     $form->addRoleElement($roleOptions);
     $form->addEmailElement();
     $form->addPassElement();
     $form->addFirstnameElement();
     $form->addLastnameElement();
     $form->addSubmitElement('save', 'Speichern');
     $form->addSubmitElement('cancel', 'Abbrechen');
     $form->setInputFilter($inputFilterManager->get('User\\Filter\\User'));
     $form->setValidationGroup(array('id', 'role', 'email', 'pass', 'firstname', 'lastname', 'save', 'cancel'));
     return $form;
 }