예제 #1
0
	 /**
	*adduserAction
          *
          * @return void
          */
     public function adduserAction()
	 {
	 	$userService = new User_Service_User();
		$form = new User_Form_Adduser();
		
		if( $this->getRequest()->isPost() ){
			if( $form->isValid( $this->getRequest()->getPost() ) ){
				$result = $userService->create( $form->getValues() );
				switch( $result ){
					case User_Service_User::USER_DATA_INVALID:
						$this->addSystemError('Données invalides');
						break;
					case User_Service_User::USER_NOT_SAVED:
						$this->addSystemError('Echec de la création');
						break;
					default:
						$this->addSystemSuccess('Utilisateur créé');
						$form->reset();
						$this->_redirect( $this->_helper->url->url( array('id' => $result), 'userById' ));
						break;
				}
			} else {
				$this->addSystemError('Le formulaire contient des erreurs');
			}
		}
		$this->view->form = $form;
	 }
예제 #2
0
	 /**
	*adduserAction
          *
          * @return void
          */
     public function adduserAction()
	 {
		$form = new User_Form_Adduser();
		if( $this->getRequest()->isPost() ){
			if( $form->isValid( $this->getRequest()->getPost() ) ){
				$user = new User_Model_User();
				$user->populate( $form->getValues() );
				$userMapper = new User_Model_Mapper_User();
				if( $id = $userMapper->save( $user ) ){
					$this->addSystemSuccess('Utilisateur créé');
					//$form->reset();
					$this->_redirect( $this->_helper->url->url( array('id' => $id), 'userById' ));
				} else {
					$this->addSystemError('Echec de la création');
				}
			} else {
				$this->addSystemError('Le formulaire contient 
				des erreurs');
			}
		}
		$this->view->form = $form;
	 }