示例#1
0
 /**
  * Creates a User
  */
 public function createAction()
 {
     if ($this->request->isPost()) {
         $user = new Users();
         $user->assign(array('name' => $this->request->getPost('name', 'striptags'), 'email' => $this->request->getPost('email', 'email')));
         if (!$user->save()) {
             $this->flash->error($user->getMessages());
         } else {
             $this->flash->success("User was created successfully");
             Tag::resetInput();
         }
     }
     $this->view->form = new UsersForm(null);
 }
 /**
  * Allow a user to signup to the system
  */
 public function signupAction()
 {
     $form = new SignUpForm();
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) != false) {
             $user = new Users();
             $user->assign(array('name' => $this->request->getPost('name', 'striptags'), 'email' => $this->request->getPost('email'), 'password' => $this->security->hash($this->request->getPost('password'))));
             if ($user->save()) {
                 return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             }
             $this->flash->error($user->getMessages());
         }
     }
     $this->view->form = $form;
 }