Example #1
0
 /**
  * execute the signup ation, face to an existent user.
  */
 public function signupAction()
 {
     $form = new SignUpForm();
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) != false) {
             $user = new User();
             $user->assign(array('username' => $this->request->getPost('name', 'striptags'), 'password' => $this->security->hash($this->request->getPost('password')), 'email' => $this->request->getPost('email'), 'active' => 0, 'token' => "false"));
             if ($user->save()) {
                 return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             } else {
                 echo "<h5>Upps! Data couldn't be saved :(... Try again...</h5>";
             }
             $this->flash->error($user->getMessages());
         }
     }
     $this->view->form = $form;
 }
 /**
  * Allow a user to signup to the system
  */
 public function signupAction()
 {
     $this->view->setTemplateBefore('public');
     if ($this->request->isPost()) {
         $user = new User();
         $pass = $this->request->getPost('password');
         $repeatPassword = $this->request->getPost('repeatPassword');
         if ($pass != $repeatPassword) {
             $this->flash->error('Passwords are diferent');
             return $this->response->redirect("index");
         }
         $enctrypted = sha1($pass);
         $user->assign(array('username' => $this->request->getPost('username'), 'password' => $enctrypted, 'email' => $this->request->getPost('email'), 'access_group_id' => 1));
         $success = $user->save();
         if ($success) {
             $this->_registerSession($user);
             $this->flash->success('Thanks for registering!' . $user->username);
             return $this->response->redirect('user/index');
         } else {
             $this->flash->error('You Cant ');
             return $this->response->redirect('session/signup');
         }
     }
 }
Example #3
0
 /**
  * 新增用户,客户端提供用户数据;不验证直接insert,返回user_id
  */
 public function addUserAction($key)
 {
     $param = $this->__getParam($key);
     $new_user = $param['user'];
     $user = new User();
     $user->assign($new_user);
     if ($user->save()) {
         $ret = array("result" => "SUCCESS", "user_id" => $user->user_id);
     } else {
         $ret = array("result" => "FAIL", "msg" => $user->getMessages());
     }
     unset($user);
     $this->table->del($key);
     return $ret;
 }
Example #4
0
 public static function find($column = '*', $value = NULL, array $options = array())
 {
     $query = 'SELECT * FROM users';
     $params = array();
     if ($column != '*' && strlen($column) > 0 && $value != NULL) {
         $query .= ' WHERE ' . Database::makeTableOrColumnName($column) . ' = :value';
         $params[':value'] = $value;
     }
     if (isset($options['orderby']) && isset($options['sort'])) {
         $query .= ' ORDER BY ' . Database::makeTableOrColumnName($options['orderby']) . ' ' . strtoupper($options['sort']);
     }
     if (isset($options['limit'])) {
         $query .= ' LIMIT ' . $options['limit'];
     }
     $sql = System::getDatabase()->prepare($query);
     $sql->execute($params);
     if ($sql->rowCount() == 0) {
         return NULL;
     } else {
         if ($sql->rowCount() == 1) {
             $user = new User();
             $user->assign($sql->fetch());
             return $user;
         } else {
             $list = array();
             while ($row = $sql->fetch()) {
                 $user = new User();
                 $user->assign($row);
                 $list[] = $user;
             }
             return $list;
         }
     }
 }