Пример #1
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;
 }
 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');
         }
     }
 }
Пример #3
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;
 }
Пример #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;
 }
Пример #5
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);
         }
     }
 }
Пример #6
0
 public function init()
 {
     parent::init();
     $this->addElement("hidden", "user_id", array('required' => false, 'decorators' => array()));
     $this->removeElement("aircraft");
     $this->removeElement("password");
     $this->removeElement("username");
     $this->removeElement("role_id");
 }
 public function indexAction()
 {
     $this->view->headTitle('Open Analytics Project | Login');
     $userform = new Form_User();
     $this->view->userform = $userform->replaceSubmitLabel('Login');
     $siteform = new Form_Site();
     $this->view->siteform = $siteform->replaceSubmitLabel('Step 2 >');
     if ($this->_request->isPost() && !is_null($this->_request->getParam('sitesubmit'))) {
         if (!$siteform->isValid($this->_request->getPost())) {
             $this->view->errors = $siteform->getErrors();
         } else {
             $namespace = new Zend_Session_Namespace('signup');
             $namespace->sitename = $siteform->getValue('sitename');
             $namespace->siteurl = $siteform->getValue('siteurl');
             $this->_redirect("/registration/step2");
         }
     }
     $this->view->headScript()->appendFile($this->view->public . '/js/auth.js');
 }
Пример #8
0
 public function init()
 {
     parent::init();
     $this->removeElement("username");
     // password element to a hidden one
     $this->removeElement("password");
     /*$this->addElement("hidden", "password", array(
           'required'   => false,
           'decorators' => array()
       ));*/
     $this->aircraft->setLabel("Aircraft assigned");
     $this->addElement("select", "aircraft_available", array('required' => false, 'label' => "Aircraft Available", 'multiple' => 'multiple', 'decorators' => array("ViewHelper", "Errors")));
     $this->aircraft_available->setRegisterInArrayValidator(false);
     // reposition
     $language = $this->language;
     $this->removeElement("language");
     $this->addElement($language);
     $this->addElement("hidden", "user_id", array('required' => false, 'decorators' => array()));
 }
 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');
     }
 }
Пример #10
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;
 }
Пример #11
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;
 }
Пример #12
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;
 }
Пример #13
0
 /**
  * 添加用户
  */
 function actionUserEdit()
 {
     $this->_pathway->addStep('编辑用户');
     $id = $this->_context->id;
     $user = Users::find()->getById($id);
     $form = new Form_User(url('admin::aclmanager/userEdit'));
     $form->element('username')->set('readonly', 'true');
     $form->element('password')->set('_tips', '密码长度只能在3-32位之间,如果不更改密码此处请留空');
     $form->element('group_id')->items = Groups::find('enabled=1')->order('weight desc')->getAll()->toHashMap('id', 'name');
     $form->element('level_id')->items = Levels::find('enabled=1')->order('weight desc')->getAll()->toHashMap('weight', 'name');
     $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $id));
     if ($this->_context->isPOST()) {
         if ($_POST['password'] == '') {
             $form->remove('password');
         }
         if ($form->validate($_POST)) {
             try {
                 $user->changePropForce('group_id', $form->element('group_id')->value());
                 $user->changePropForce('level_id', $form->element('level_id')->value());
                 $user->changeProps($form->values());
                 $user->save();
                 return "{id:{$id},msg:'编辑成功'}";
             } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
                 $form->invalidate($ex);
             }
         } else {
             $form->import($user);
         }
     } else {
         $form->import($user);
     }
     $form->element('password')->set('value', '');
     $form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true'));
     $this->_view['form'] = $form;
 }
Пример #14
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;
 }
Пример #15
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;
 }
Пример #16
0
 /**
  * 修改个人信息
  */
 function actionChangeInfo()
 {
     $this->_pathway->addStep('个人信息');
     $currentUser = $this->_app->currentUser();
     $user = Users::find()->getById($currentUser['id']);
     $form = new Form_User(url('admin::usercenter/changeInfo'));
     $form->element('username')->set('readonly', 'true');
     $form->remove('password');
     $form->element('group_id')->items = Groups::find('id=?', $user->group_id)->order('weight desc')->getAll()->toHashMap('id', 'name');
     $form->element('level_id')->items = Levels::find('weight=?', $user->level_id)->order('weight desc')->getAll()->toHashMap('weight', 'name');
     $form->remove('enabled');
     $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $currentUser['id']));
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             $user->changeProps($form->values());
             $user->save();
             return "{msg:'编辑成功'}";
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     } else {
         $form->import($user);
     }
     $form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true'));
     $this->_view['form'] = $form;
 }