本文整理汇总了PHP中Users::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getMessages方法的具体用法?PHP Users::getMessages怎么用?PHP Users::getMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::getMessages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginFbAction
public function loginFbAction()
{
$response = new ApiResponse();
if ($this->request->isPost()) {
$fbId = $this->request->getPost('fbId');
$username = $this->request->getPost('username');
$email = $this->request->getPost('email');
$avatar = $this->request->getPost('avatar');
$user = Users::findFirstByFbId($fbId);
if ($user == true) {
$response->setResponseMessage('Login successfully!');
return $response;
} else {
$user = new Users();
$user->id = uniqid();
$user->fbId = $fbId;
$user->avatar = $avatar;
$user->username = $username;
$user->email = $email;
try {
if ($user->save() == false) {
$response->setResponseError(implode(', ', $user->getMessages()));
} else {
$response->setResponseMessage('Register successfully!');
}
} catch (PDOException $e) {
$response->setResponseError($e->getMessage());
}
}
} else {
$response->setResponseError('Wrong HTTP Method');
}
return $response;
}
示例2: indexAction
/**
* Action to register a new user
*/
public function indexAction()
{
$form = new RegisterForm();
if ($this->request->isPost()) {
$name = $this->request->getPost('name', array('string', 'striptags'));
$username = $this->request->getPost('username', 'alphanum');
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');
if ($password != $repeatPassword) {
$this->flash->error('Passwords are diferent');
return false;
}
$user = new Users();
$user->username = $username;
$user->password = sha1($password);
$user->name = $name;
$user->email = $email;
$user->created_at = new Phalcon\Db\RawValue('now()');
$user->active = 'Y';
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->tag->setDefault('email', '');
$this->tag->setDefault('password', '');
$this->flash->success('Thanks for sign-up, please log-in to start generating invoices');
return $this->forward('session/index');
}
}
$this->view->form = $form;
}
示例3: registerAction
public function registerAction()
{
if ($this->request->isPost()) {
$name = $this->request->getPost('name', 'string');
$username = $this->request->getPost('username', 'string');
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');
if ($password != $repeatPassword) {
Flash::error((string) $message, 'alert alert-error');
return false;
}
$name = strip_tags($name);
$username = strip_tags($username);
$user = new Users();
$user->username = $username;
$user->password = sha1($password);
$user->name = $name;
$user->email = $email;
$user->created_at = new Phalcon_Db_RawValue('now()');
$user->active = 'Y';
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
Flash::error((string) $message, 'alert alert-error');
}
} else {
Tag::setDefault('email', '');
Tag::setDefault('password', '');
Flash::success('Thanks for sign-up, please log-in to start generating invoices', 'alert alert-success');
return $this->_forward('session/index');
}
}
}
示例4: indexAction
public function indexAction()
{
if ($this->request->isPost()) {
$username = $this->request->getPost('username', 'alphanum');
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$name = $this->request->getPost('name');
$phone = $this->request->getPost('phone');
$user = new Users();
$user->username = $username;
$user->email = $email;
$user->password = sha1($password);
$user->name = $name;
$user->created_at = new Phalcon\Db\RawValue('now()');
$user->active = 'Y';
$user->class = '1';
$user->phone = $phone;
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->tag->setDefault('email', '');
$this->tag->setDefault('password', '');
$this->flash->success('Спасибо за регистрацию, пожалуйста войдите в вашу учетную запись');
return $this->view->pick("login/index");
}
}
}
示例5: indexAction
/**
* Action to register a new user
*/
public function indexAction()
{
$form = new RegisterForm();
if ($this->request->isPost()) {
$name = $this->request->getPost('name', array('string', 'striptags'));
$username = $this->request->getPost('username', 'alphanum');
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');
if ($password != $repeatPassword) {
$this->flash->error('Passwords are different');
return false;
}
$user = new Users();
$user->username = $username;
$user->password = sha1($password);
$user->name = $name;
$user->email = $email;
$user->created_at = new Phalcon\Db\RawValue('now()');
$user->active = 'Y';
$user->key = md5($email);
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->tag->setDefault('email', '');
$this->tag->setDefault('password', '');
$this->flash->success('Спасибо за регисрация. Пожалуйста залогинтесь для использования API');
return $this->forward('session/index');
}
}
$this->view->form = $form;
}
示例6: addAction
/**
* Create new user
*/
public function addAction()
{
// check API authentication
if (!$this->authenticateRequest()) {
return $this->processResponse(array('status' => 401, 'payload' => array('status' => 'failure', 'data' => null, 'error' => array('code' => 401, 'message' => 'API authentication failed'))));
}
// verify token
if (!$this->verifyCsrfToken()) {
return $this->processResponse(array('status' => 401, 'payload' => array('status' => 'failure', 'data' => null, 'error' => array('code' => 401, 'message' => 'Token validation failed'))));
}
// get HTTP entity body
$httpContent = file_get_contents('php://input');
if (empty($httpContent)) {
return $this->processResponse(array('status' => 404, 'payload' => array('status' => 'failure', 'data' => null, 'error' => array('code' => 404, 'message' => 'User information not provided'))));
}
$data = json_decode($httpContent);
// create user
$user = new Users();
$user->name = htmlentities($data->name);
$user->createdDate = new MongoDate();
$user->modifiedDate = new MongoDate();
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->logger->log(sprintf('NAMESPACE=user MESSAGE=%s', $message), \Phalcon\Logger::ERROR);
}
return $this->processResponse(array('status' => 404, 'payload' => array('status' => 'failure', 'data' => null, 'error' => array('code' => 404, 'message' => 'Failed to create user'))));
} else {
return $this->processResponse(array('status' => 201, 'payload' => array('status' => 'success', 'data' => json_encode($user), 'error' => null)));
}
}
示例7: upAction
/**
* Registration
*/
public function upAction()
{
if ($this->request->isPost()) {
$user = new Users();
$user->login = $this->request->getPost('login', 'string');
$user->password = $this->request->getPost('password', 'string');
$passwordVerify = $this->request->getPost('password-verify', 'string');
if (md5($user->password) !== md5($passwordVerify)) {
$this->flashSession->error('Пароли не совпадают');
return;
}
if (!$user->create()) {
$this->flashSession->error(implode("<br/>", $user->getMessages()));
return;
}
$auth = new Auth();
$authSucceed = $auth->authorize($user);
if ($authSucceed) {
$this->response->redirect();
return;
}
$this->dispatcher->forward(['controller' => 'sign', 'action' => 'in']);
return;
}
}
示例8: signupAction
public function signupAction()
{
if ($this->request->isPost()) {
if ($this->request->getPost()) {
$user = new Users();
$user->assign(array('username' => $this->request->getPost('username', 'striptags'), 'email' => $this->request->getPost('email'), 'password' => $this->security->hash($this->request->getPost('password')), 'fullName' => $this->request->getPost('fullName')));
if ($user->save()) {
return $this->dispatcher->forward(array('controller' => 'session', 'action' => 'index'));
}
$this->flash->error($user->getMessages());
}
}
}
示例9: registerAction
public function registerAction()
{
$user = new Users();
//Store and check for errors
if ($user->save($_POST, array('name', 'email')) == true) {
echo "Thanks for register!";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
}
示例10: registerAction
public function registerAction()
{
$user = new Users();
//Store and check for errors
$success = $user->save($this->request->getPost(), array('name', 'email'));
if ($success) {
echo "Thanks for register!";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
}
示例11: registerAction
public function registerAction()
{
$user = new Users();
$success = $user->save($this->request->getPost(), array('email', 'password', 'ime', 'prezime', 'datum_rodenja'));
if ($success) {
echo "Thanks for registering!";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
$this->view->disable();
}
示例12: enregistrementAction
public function enregistrementAction()
{
$user = new Users();
//Enregistrement et vérification des erreurs
$success = $user->save($this->request->getPost(), array('nom', 'email'));
if ($success) {
echo "Merci de votre enregistrement !";
} else {
echo "Erreurs lors de l'enregistrement : ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
$this->view->disable();
}
示例13: indexAction
public function indexAction()
{
$form = new RegisterForm();
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'), 'number' => $this->request->getPost('number'), 'password' => $this->security->hash($this->request->getPost('password')), 'telephone' => $this->request->getPost('telephone')));
if ($user->save()) {
return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
}
$this->flash->error($user->getMessages());
}
}
$this->view->form = $form;
}
示例14: registerAction
public function registerAction()
{
$user = new Users();
// Сохраняем и проверяем на наличие ошибок
$success = $user->save($this->request->getPost(), array('name', 'email'));
if ($success) {
echo "Спасибо за регистрацию!";
} else {
echo "К сожалению, возникли следующие проблемы: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
$this->view->disable();
}
示例15: indexAction
public function indexAction()
{
$user = new Users();
$post = $this->request->getPost();
foreach ($post as $key => $p_val) {
if ($key == 'password') {
$pw = md5($p_val);
$user->password = $pw;
continue;
}
$user->{$key} = $post[$key];
}
if (!$user->save()) {
var_dump($user->getMessages());
}
}