public function editAction()
 {
     $id = $this->getParam(self::PARAM_GET_ID);
     $form = new Form_User();
     $userModel = $this->em->getRepository('Federico\\Entity\\User')->getUser($id);
     $languages = $userModel->getLanguages()->toArray();
     $selectedLanguages = array();
     //needed countries to populate form
     foreach ($languages as $language) {
         $selectedLanguages[] = $language->getLanguageName();
     }
     $form->getElement('id')->setValue($userModel->getId());
     $form->getElement('role')->setValue($userModel->getRole());
     $form->getElement('name')->setValue($userModel->getName());
     $form->getElement('email')->setValue($userModel->getEmail());
     $form->getElement('password')->setValue($userModel->getPassword());
     $form->getElement('url')->setValue($userModel->getUrl());
     $form->getElement('languages')->setValue($selectedLanguages);
     echo $form;
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $instance = new \Federico\Entity\UserService($this->em);
             $entity = $instance->makeUser($data);
             $user = $instance->updateUser($entity);
             $this->_redirect('federico/index');
         }
     }
 }
Esempio n. 2
0
 public function addAction()
 {
     $this->view->title = "New User";
     $this->view->headTitle($this->view->title, 'PREPEND');
     $form = new Form_User();
     $form->submit->setLabel('Sign Up');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $first = $form->getValue('first');
             $last = $form->getValue('last');
             $email = $form->getValue('email');
             $password = $form->getValue('password1');
             $users = new Model_DbTable_Users();
             $users->addUser($first, $last, $email, $password);
             //auto log-in user and redirect to home page
             // Setup DbTable adapter
             $dbAdapter = Zend_Db_Table::getDefaultAdapter();
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
             $authAdapter->setTableName('users')->setIdentityColumn('email')->setCredentialColumn('password');
             $authAdapter->setIdentity($email)->setCredential(hash('SHA256', $password));
             // authentication attempt
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             $userInfo = $authAdapter->getResultRowObject(null, 'password');
             // the default storage is a session with namespace Zend_Auth
             $authStorage = $auth->getStorage();
             $authStorage->write($userInfo);
             $this->_redirect('/index');
         } else {
             $form->populate($formData);
         }
     }
 }
Esempio n. 3
0
 public function edituserAction()
 {
     global $mySession;
     $userId = $this->getRequest()->getParam('userId');
     $uType = $this->getRequest()->getParam('uType');
     $this->view->uType = $uType;
     $this->view->userId = $userId;
     $myform = new Form_User($userId);
     $this->view->pageHeading = "Edit User";
     $db = new Db();
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $myObj = new Users();
             $Result = $myObj->UpdateUser($dataForm, $userId);
             if ($Result == 1) {
                 $mySession->sucessMsg = "User details updated successfully.";
                 $this->_redirect('users/index/uType/' . $uType);
             } else {
                 $mySession->errorMsg = "Username you entered is already exists.";
             }
         }
     }
     $this->view->myform = $myform;
 }
Esempio n. 4
0
 /**
  * Signup
  */
 public function signupAction()
 {
     $form = new Form_User();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $userData = $form->getValues();
         $userData['id'] = User::fetchNextId();
         // save user
         $user = new User($userData['id']);
         $user->setValue($userData);
         $users = new Users();
         $users->add($userData['id']);
         // save login to id link
         User::setLoginToIdLink($userData['login'], $userData['id']);
         $this->_redirect('/user/login');
     }
     $this->view->form = $form;
 }
 public function step2Action()
 {
     $namespace = new Zend_Session_Namespace('signup');
     if (!is_null($namespace->sitename) && !is_null($namespace->siteurl)) {
         $userform = new Form_User();
         $userform->addRepeatPassword();
         $userform->setAction('/registration/step2');
         $userform->addDBNoRecordExistsValidator();
         if ($this->_request->isPost()) {
             if ($userform->isValid($this->_request->getPost())) {
                 $namespace->email = $userform->getValue('email');
                 $namespace->password = $userform->getValue('password');
                 $this->_redirect('/registration/step3');
             }
         }
         $this->view->userform = $userform->replaceSubmitLabel("Step 3 >");
         $this->view->sitename = $namespace->sitename;
         $this->view->siteurl = $namespace->siteurl;
     } else {
         $this->_redirect('/auth');
     }
 }
Esempio n. 6
0
 public function ownerregistrationAction()
 {
     global $mySession;
     $db = new Db();
     $this->view->pageTitle = "Property Owner Registration";
     $this->view->headMeta("Deal A Trip Customers and Property Owner Login and Registration", 'description');
     $myform = new Form_User();
     $varsuccess = 0;
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             //prd($dataForm);
             $sql = "select * from " . USERS . " where email_address = '" . trim($dataForm['email_address']) . "'";
             $chkArr = $db->runQuery($sql);
             if (count($chkArr) == 0) {
                 $myObj = new Users();
                 $Result = $myObj->SaveUser($dataForm, 2);
                 $mySession->sucessMsg = "Successfully registered";
                 $varsuccess = 1;
             } else {
                 $mySession->errorMsg = "This username or email address already exist";
             }
         } else {
             $mySession->errorMsg = "Image not proper";
         }
     }
     $this->view->varsuccess = $varsuccess;
     $this->view->myform = $myform;
     $this->view->myform = $myform;
 }
Esempio n. 7
0
 public function editAction()
 {
     $this->view->title = "Редагувати дані користувача";
     $this->view->headTitle($this->view->title, 'PREPEND');
     // $id=$this->getRequest->getParam('id');
     $id = $this->getParam('id');
     $user = new Model_User($id);
     //форма для edit
     $form = new Form_User();
     //зберігаємо редаговані дані
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             //дані з форми
             $user->fill($form->getValues());
             //оскільки ми модифікуємо,то
             $user->modefied = date('Y-m-d, H:i:s');
             $user->save();
             $this->_helper->redirector('index');
         }
     } else {
         //заповнити форму даними цього юзера
         //populate() приймає асоціативний масив
         $form->populate($user->populateform());
     }
     $this->view->form = $form;
 }
Esempio n. 8
0
 public function editAction()
 {
     $this->view->title = "Редактировать данные пользователя.";
     $this->view->headTitle($this->view->title, 'PREPEND');
     //$id = $this->getRequest()->getParam('id');
     $id = $this->_getParam('id');
     $user = new Model_User($id);
     $form = new Form_User();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $user->fill($form->getValues());
             $user->modified = date('Y-m-d H:i:s');
             $user->save();
             $this->_helper->redirector('index');
         }
     } else {
         $form->populate($user->populateForm());
     }
     $this->view->form = $form;
 }
Esempio n. 9
0
 public function loginAction()
 {
     $userForm = new Form_User();
     $userForm->setAction('/user/login');
     $userForm->removeElement('first_name');
     $userForm->removeElement('last_name');
     $userForm->removeElement('role');
     if ($this->_request->isPost() && $userForm->isValid($_POST)) {
         $data = $userForm->getValues();
         //set up the auth adapter
         // get the default db adapter
         $db = Zend_Db_Table::getDefaultAdapter();
         //create the auth adapter
         $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password');
         //set the username and password
         $authAdapter->setIdentity($data['username']);
         $authAdapter->setCredential(md5($data['password']));
         //authenticate
         $result = $authAdapter->authenticate();
         if ($result->isValid()) {
             // store the username, first and last names of the user
             $auth = Zend_Auth::getInstance();
             $storage = $auth->getStorage();
             $storage->write($authAdapter->getResultRowObject(array('username', 'first_name', 'last_name', 'role')));
             return $this->_forward('index');
         } else {
             $this->view->loginMessage = "Sorry, your username or\n                password was incorrect";
         }
     }
     $this->view->form = $userForm;
 }
Esempio n. 10
0
 public function processAction()
 {
     global $mySession;
     $db = new Db();
     $step = $this->getRequest()->getParam("step");
     $this->core();
     $myform = new Form_User();
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             //prd($dataForm);
             $sql = "select * from " . USERS . " where email_address = '" . trim($dataForm['email_address']) . "'";
             $chkArr = $db->runQuery($sql);
             if (count($chkArr) == 0) {
                 $myObj = new Users();
                 $Result = $myObj->SaveUser($dataForm, 1);
                 $mySession->steps = '3';
                 $mySession->sucessMsg = "Successfully registered";
                 /*					$mySession->LoggedUser = $dataForm*/
                 $userArr = $db->runQuery("select * from " . USERS . " where user_id = '" . $Result . "' ");
                 $mySession->bookingUser = $userArr[0];
                 $this->_redirect("booking/index/ppty/" . $this->ppty . "/step/3");
             } else {
                 $mySession->errorMsg = "This username or email address already exist";
                 $this->render("index");
             }
         } else {
             $mySession->errorMsg = "Oops! Some error occurred while registering your account";
             $this->_redirect("booking/index/ppty/" . $this->ppty . "/step/1");
         }
     }
     $this->view->myform = $myform;
 }
Esempio n. 11
0
 /**
  * 更改密码
  *
  */
 public function changePasswordAction()
 {
     $id = $this->_request->getParam('id');
     $formUser = new Form_User();
     $formUser->removeElement('username');
     $formUser->removeElement('sex');
     $formUser->removeElement('email');
     $formUser->removeElement('avatar');
     $formUser->removeElement('profile');
     $formUser->removeElement('role');
     $formUser->removeElement('star');
     $formUser->removeElement('status');
     if ($this->getRequest()->isPost()) {
         if ($formUser->isValid($_POST)) {
             $modelUser = new User();
             $newpsw = $modelUser->changPassword($id, $formUser->getValue('password'));
             return $this->_forward('account');
         }
     }
     $this->view->formUser = $formUser;
 }