Exemplo n.º 1
0
 public function signupAction()
 {
     $form = new AccountForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $user->exchangeArray($form->getData());
             $username = $this->getUserTable()->getUserByName($user->username);
             if (!empty($username)) {
                 $this->redirect()->toRoute('user', array('action' => 'signup'));
                 echo '<div class="alert alert-error">
                             <button type="button" class="close" data-dismiss="alert">&times;</button>
                             <h4>Warning!</h4>
                             User already exist!.
                         </div>';
             } else {
                 $this->getUserTable()->createAccount($user);
                 $this->redirect()->toRoute('user');
             }
         }
     }
     return array('form' => $form);
 }
Exemplo n.º 2
0
 public function detailAction()
 {
     $id = $this->params()->fromQuery('id');
     $user = new User();
     $user->setId($id);
     /** @var \User\Model\UserMapper $userMapper */
     $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
     if (!$user->getId() || !$userMapper->get($user->getId())) {
         return $this->page404();
     }
     if (!$this->params()->fromQuery('created') || !DateBase::validateDate($this->params()->fromQuery('created'), DateBase::DISPLAY_DATE_FORMAT)) {
         return $this->page404();
     }
     $user = $userMapper->get($id);
     /** @var \Admin\Model\MessagesMG $mess */
     $mess = new MessagesMG();
     $mess->setSender($user->getUsername());
     $mess->setCreated($this->params()->fromQuery('created'));
     /** @var \Admin\Model\ReportMapper $reportMapper */
     $reportMapper = $this->getServiceLocator()->get('Admin\\Model\\ReportMapper');
     $data = $reportMapper->reportdetail($mess);
     $this->getViewModel()->setVariable('data', $data);
     $this->getViewModel()->setVariable('user', $user);
     return $this->getViewModel();
 }
 public function updateAction()
 {
     $request = $this->getRequest();
     $data = $request->getPost();
     $db = $this->getTable('category');
     if ($data['actiontype'] == 'delete') {
         $db->delete(array('id' => $data['id']));
     } elseif ($data['actiontype'] == 'update') {
         $postdata = array();
         foreach ($data as $key => $value) {
             if ($key == 'actiontype') {
                 continue;
             }
             $postdata[$key] = $value;
         }
         $db->update($postdata, array('id' => $data['id']));
     } elseif ($data['actiontype'] == 'addsub') {
         $user = new User($this->getServiceLocator());
         $adminloginuser = new Container('adminloginuser');
         $menus = $user->getUserMenu($adminloginuser->userid);
         $view = new ViewModel(array('userdetail' => $adminloginuser->userdetail, 'menus' => $menus, 'controller' => 'Category', 'categorytree' => $this->getAllCategory(), 'parentcategoryid' => $data['id'], 'parentcategoryname' => $data['name']));
         return $view->setTemplate('/category/category/index.phtml');
     }
     return $this->redirect()->toRoute('category/default', array('controller' => 'category', 'action' => 'index'));
 }
Exemplo n.º 4
0
 public function isValid()
 {
     $isValid = parent::isValid();
     if ($isValid) {
         /** @var \User\Service\User $userService */
         $userService = $this->getServiceLocator()->get('User\\Service\\User');
         $data = parent::getData();
         $user = new User();
         $user->setEmail($data['email']);
         /** @var \User\Model\UserMapper $userMapper */
         $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
         if ($userMapper->isActive($user) && !$data['password']) {
             $this->get('email')->setMessages(['Bạn đã đăng ký, vui lòng chọn đăng nhập để tiếp tục']);
             return false;
         }
         if (!$userService->isAvailableEmail($data['email'])) {
             return true;
         }
         if ($data['password'] != '' && !$userService->authenticate($data['email'], $data['password'])) {
             $this->get('email')->setMessages([\User\Form\Signin::ERROR_INVALID]);
             return false;
         }
     }
     return $isValid;
 }
Exemplo n.º 5
0
 public function testInputFiltersAreSetCorrectly()
 {
     $user = new User();
     $inputFilter = $user->getInputFilter();
     $this->assertSame(8, $inputFilter->count());
     $this->assertTrue($inputFilter->has('userId'));
     $this->assertTrue($inputFilter->has('firstName'));
     $this->assertTrue($inputFilter->has('lastName'));
 }
 private function getUser($id)
 {
     $userData = $this->userMapper->getUserById($id);
     if (!$userData) {
         return null;
     }
     $user = new User();
     $user->exchangeArray($userData);
     return $user;
 }
Exemplo n.º 7
0
 protected function createUser(array $data)
 {
     $user = new User();
     $user->exchangeArray($data);
     $user->setPassword($data['password']);
     $user->setRegisterDate();
     $userTable = $this->getServiceLocator()->get('UserTable');
     $userTable->saveUser($user);
     return true;
 }
 public function addAction()
 {
     $container = new Container('adminloginuser');
     if ($container->userid == '') {
         // this section is not working. Need some more work here
         return $this->redirect()->toRoute('admin/default', array('controller' => 'index', 'action' => 'login'));
     }
     $user = new User($this->getServiceLocator());
     //        $adminloginuser = new Container('adminloginuser');
     $menus = $user->getUserMenu($container->userid);
     return new ViewModel(array('userdetail' => $container->userdetail, 'islink' => true, 'menus' => $menus, 'controller' => 'Customer'));
 }
Exemplo n.º 9
0
 public function testUserInitialState()
 {
     $user = new User();
     $this->assertNull($user->getLidnr());
     $this->assertNull($user->getEmail());
     $this->assertNull($user->getPassword());
     $this->assertNull($user->getMember());
     $this->assertEmpty($user->getRoleNames());
     $this->assertEquals('user_', $user->getRoleId());
     $this->assertEquals('user', $user->getResourceId());
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $user->getRoles());
     $this->assertEquals(0, count($user->getRoles()));
 }
Exemplo n.º 10
0
 public function findmentorAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->page404();
     }
     $data = $this->getRequest()->getPost();
     $form = new SearchDetail($this->getServiceLocator());
     $form->setData($data);
     if ($form->isValid()) {
         $user = new User();
         $user->setEmail($data['email']);
         $activeKey = md5($user->getEmail() . DateBase::getCurrentDateTime());
         $user->setActiveKey($activeKey);
         $user->setRole(User::ROLE_MEMBER);
         $user->setCreatedDateTime(DateBase::getCurrentDateTime());
         $user->setCreatedDate(DateBase::getCurrentDate());
         /** @var \User\Model\UserMapper $userMapper */
         $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
         if (!$userMapper->isExistedEmail($user)) {
             $userMapper->save($user);
             Uri::autoLink('/user/user/sendemail', ['email' => $data['email'], 'activeKey' => $user->getActiveKey()]);
             $this->getJsonModel()->setVariables(['code' => 2, 'data' => 'Email kích hoạt tài khoản đã được gửi đến địa chỉ email của bạn. Kiểm tra hòm thư và làm theo hướng dẫn đễ kích hoạt tài khoản.']);
             return $this->getJsonModel();
         }
         return $this->getViewModel();
     } else {
         $this->getJsonModel()->setVariables(['code' => 1, 'data' => $form->getErrorMessagesList()]);
     }
     return $this->getJsonModel();
 }
Exemplo n.º 11
0
 public function testSaveUserWillUpdateExistingUsersIfTheyAlreadyHaveAnId()
 {
     $userData = array('userId' => 125, 'firstName' => 'Ho', 'lastName' => 'Kiet', 'email' => '*****@*****.**', 'password' => '123', 'role' => 'Operator', 'activated' => 1);
     $user = new User();
     $user->exchangeArray($userData);
     $resultSet = new ResultSet();
     $resultSet->setArrayObjectPrototype(new User());
     $resultSet->initialize(array($user));
     $mockTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select', 'update'), array(), '', false);
     $mockTableGateway->expects($this->once())->method('select')->with(array('userId' => 125))->will($this->returnValue($resultSet));
     $mockTableGateway->expects($this->once())->method('update')->with(array('userId' => 125, 'firstName' => 'Ho', 'lastName' => 'Kiet', 'email' => '*****@*****.**', 'password' => '123', 'role' => 'Operator', 'activated' => 1));
     $userTable = new UserTable($mockTableGateway);
     $userTable->saveUser($user);
 }
 /**
  * Register new user
  *
  * @param array $values
  * @return User
  * @throws Exception
  */
 public function registerUser(array $values = [])
 {
     $user = new User();
     $user->dateCreated = new RawValue('NOW()');
     $user->dateModified = new RawValue('NOW()');
     $user->publish = true;
     $user->deleted = false;
     $user->group_id = 1;
     $result = $user->save($values);
     if ($result === false) {
         throw new Exception(implode(', ', $user->getMessages()));
     }
     return $user;
 }
Exemplo n.º 13
0
 public function indexAction()
 {
     $checklogin = new IndexController();
     return $checklogin->checkLogin('Products', $this->getServiceLocator());
     $checklogin = new IndexController();
     $obj = $checklogin->checkLogin($this->getServiceLocator());
     if (is_object($obj)) {
         return $obj;
     } else {
         $user = new User($this->getServiceLocator());
         $adminloginuser = new Container('adminloginuser');
         $menus = $user->getUserMenu($adminloginuser->userid);
         return new ViewModel(array('userdetail' => $adminloginuser->userdetail, 'menus' => $menus, 'controller' => 'User'));
     }
 }
Exemplo n.º 14
0
 public function indexAction()
 {
     $form = new \Admin\Form\Subject\CategoryFilter($this->getServiceLocator());
     $form->setData($this->params()->fromQuery());
     $this->getViewModel()->setVariable('form', $form);
     if ($form->isValid()) {
         $user = new User();
         $user->exchangeArray($form->getData());
         $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
         /** @var $userMapper \User\Model\UserMapper */
         $paginator = $userMapper->search($user);
         $this->getViewModel()->setVariable('paginator', $paginator);
     }
     return $this->getViewModel();
 }
Exemplo n.º 15
0
 /**
  * Activate a user.
  *
  * @param array $data Activation data.
  * @param NewUserModel $newUser The user to create
  *
  * @return boolean
  */
 public function activate($data, NewUserModel $newUser)
 {
     $form = $this->getActivateForm();
     $form->setData($data);
     if (!$form->isValid()) {
         return false;
     }
     $data = $form->getData();
     $bcrypt = $this->sm->get('user_bcrypt');
     // create a new user from this data, and insert it into the database
     $user = new UserModel($newUser);
     $user->setPassword($bcrypt->create($data['password']));
     $this->getUserMapper()->createUser($user, $newUser);
     return true;
 }
 /**
  * Login action
  */
 public function loginAction()
 {
     $this->view->setLayout('empty-layout');
     $form = new Login();
     if ($this->request->isPost()) {
         try {
             if ($form->isValid($this->request->getPost())) {
                 $user = User::findFirst(1);
                 /**
                  * @var $authService \App\Service\Auth
                  */
                 $authService = $this->di->get('auth');
                 /**
                  * @todo Rewrite for AuthService with check
                  */
                 $authService->authByUser($user);
                 $this->response->redirect(array('for' => 'admin'));
             } else {
                 //@todo Implement it
             }
         } catch (\Exception $e) {
             $this->flash->error($e->getMessage());
         }
     }
     $this->view->form = $form;
 }
Exemplo n.º 17
0
 /**
  * Init some subsystems after engine initialization.
  */
 public function afterEngine()
 {
     $di = $this->getDI();
     $config = $this->getConfig();
     $this->_initI18n($di, $config);
     if (!$config->installed) {
         return;
     }
     // Remove profiler for non-user.
     if (!User::getViewer()->id) {
         $di->remove('profiler');
     }
     // Init widgets system.
     $this->_initWidgets($di);
     /**
      * Listening to events in the dispatcher using the Acl.
      */
     if ($config->installed) {
         $this->getEventsManager()->attach('dispatch', $di->get('core')->acl());
     }
     // Install assets if required.
     if ($config->application->debug) {
         $di->get('assets')->installAssets(PUBLIC_PATH . '/themes/' . Settings::getSetting('system_theme'));
     }
 }
Exemplo n.º 18
0
 /**
  * Checking user existing in system
  *
  * @param  string  $email
  * @param  string  $password
  * @param  boolean $cookie
  * @param  boolean $log
  * @return boolean
  */
 public function check($name, $password, $cookie = false, $log = false)
 {
     $me = new \stdClass();
     $myUser = UserModel::findFirst(['name = :fname: AND status = :status:', 'bind' => ['fname' => $name, 'status' => UserModel::STATUS_ENABLE]]);
     if ($myUser) {
         if ($this->security->checkHash($password, $myUser->password)) {
             $me->id = $myUser->id;
             $me->email = $myUser->email;
             $me->name = $myUser->name;
             $me->role = $myUser->role;
             $me->roleName = $myUser->getRoleName();
             $me->avatar = $myUser->avatar;
             // create session for user
             $this->session->set('me', $me);
             // store cookie if chosen
             if ($cookie == true) {
                 $this->cookie->set('remember-me', $me->id, time() + 15 * 86400);
             }
             return true;
         } else {
             $this->flash->error('Wrong password!');
         }
     } else {
         $this->flash->error('Wrong user information!');
     }
 }
Exemplo n.º 19
0
 public function insert(UserModel $user)
 {
     $data = array('user_id' => $user->getUserId(), 'email' => $user->getEmail(), 'display_name' => $user->getDisplayName(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'register_time' => new Expr('NOW()'), 'register_ip' => new Expr("INET_ATON('{$_SERVER['REMOTE_ADDR']}')"));
     $db = $this->getWriteAdapter();
     $db->insert($this->getTableName(), $data);
     $userId = $db->lastInsertId();
     $user->setUserId($userId);
     return $user;
 }
Exemplo n.º 20
0
 public function addAction()
 {
     $form = new UserForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $user->exchangeArray($form->getData());
             $this->getUserTable()->saveUser($user);
             return $this->redirect()->toRoute('user');
         }
     }
     return array('form' => $form);
 }
Exemplo n.º 21
0
 /**
  * Render profiler.
  *
  * @return string
  */
 public function render()
 {
     $di = $this->getDI();
     $this->_config = $di->get('config');
     $this->_view = $di->get('view');
     if (!$di->has('profiler')) {
         return '';
     }
     // check admin area
     if (substr($di->get('dispatcher')->getControllerName(), 0, 5) == 'Admin') {
         return '';
     }
     $viewer = User::getViewer();
     if (!$viewer->id || !$viewer->isAdmin()) {
         return '';
     }
     $profiler = $di->get('profiler');
     $router = $di->get('router');
     $dbProfiler = $profiler->getDbProfiler();
     $handlerValues = [];
     //////////////////////////////////////
     /// Router.
     //////////////////////////////////////
     $handlerValues['router'] = ucfirst($router->getControllerName()) . 'Controller::' . ucfirst($router->getActionName()) . 'Action';
     //////////////////////////////////////
     /// Memory.
     //////////////////////////////////////
     $memoryData = memory_get_usage();
     $memoryLimit = (int) ini_get('memory_limit') * 1024 * 1024;
     $currentMemoryPercent = round($memoryData / ($memoryLimit / 100));
     $colorClass = $currentMemoryPercent > 30 ? $currentMemoryPercent < 75 ? 'item-normal' : 'item-bad' : 'item-good';
     $handlerValues['memory'] = ['class' => $colorClass, 'value' => round($memoryData / 1024, 2)];
     //////////////////////////////////////
     /// Time.
     //////////////////////////////////////
     $timeData = round((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) * 1000, 2);
     $colorClass = $timeData > 200 ? $timeData < 500 ? 'item-normal' : 'item-bad' : 'item-good';
     $handlerValues['time'] = ['class' => $colorClass, 'value' => $timeData];
     //////////////////////////////////////
     /// Files.
     //////////////////////////////////////
     $filesData = get_included_files();
     $handlerValues['files'] = count($filesData);
     //////////////////////////////////////
     /// SQL.
     //////////////////////////////////////
     $handlerValues['sql'] = $totalSqlStatements = $dbProfiler->getNumberTotalStatements();
     //////////////////////////////////////
     /// Errors.
     //////////////////////////////////////
     $errorsData = $profiler->getData('error');
     $errorsCount = count($errorsData);
     $colorClass = $errorsCount == 0 ? 'item-good' : 'item-bad';
     $handlerValues['errors'] = ['class' => $colorClass, 'value' => $errorsCount];
     $output = $this->_viewRender('main', ['handlerValues' => $handlerValues, 'htmlConfig' => $this->_getHtmlConfig(), 'htmlRouter' => $this->_getHtmlRouter(), 'htmlMemory' => $this->_getHtmlMemory(), 'htmlTime' => $this->_getHtmlTime($timeData), 'htmlFiles' => $this->_getHtmlFiles($filesData), 'htmlSql' => $this->_getHtmlSql($dbProfiler, $totalSqlStatements), 'htmlErrors' => $this->_getHtmlErrors($errorsData, $errorsCount)]);
     return trim(preg_replace('/\\s\\s+/', ' ', $output));
 }
Exemplo n.º 22
0
 public function loginAction()
 {
     $authStorage = new AuthenticationStorage(self::NAMESPACE_ZENDSTORE_FRONT);
     $authService = new AuthenticationService($authStorage);
     if ($authService->hasIdentity()) {
         echo 'You have logined';
         exit;
     }
     $form = new UserForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->post());
         if ($form->isValid()) {
             $data = $form->getData();
             // Authentication
             $sm = $this->getServiceLocator();
             $db = $sm->get('db-adapter');
             //$authAdapter = new AuthenticationAdapter($db, 'user', 'email', 'password', 'MD5(?)');
             $authAdapter = new AuthenticationAdapter($db, 'user', 'email', 'password', 'MD5(CONCAT(?, password_salt))');
             $authAdapter->setIdentity($data['email']);
             $authAdapter->setCredential($data['password']);
             $result = $authService->authenticate($authAdapter);
             if ($result->isValid()) {
                 return $this->redirect()->toRoute('user-front-user');
             } else {
                 var_dump($result->getMessages());
                 exit;
             }
         } else {
             echo '<h1>ERROR: Form data is invalid.</h1>';
             echo '<pre>';
             print_r($form->getMessages());
             exit;
         }
     }
     $viewVars = array('form' => $form);
     $viewModel = $this->getViewModel();
     $viewModel->setVariables($viewVars);
     return $viewModel;
 }
 public function addAction()
 {
     $form = new UserForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $User = new User();
         $form->setInputFilter($User->getInputFilter());
         $form->setData($request->getPost());
         $User->user_nom = $request->getPost('User_nom');
         $User->user_prenom = $request->getPost('User_prenom');
         $User->user_password = $request->getPost('Passwd');
         $bcrypt = new Bcrypt();
         $securePass = $bcrypt->create($User->user_password);
         $User->user_password = $securePass;
         // Sauvegarde
         $user_id = $this->getUserTable()->saveUser($User);
         return $this->redirect()->toRoute('User', array('user_id' => $user_id, 'action' => 'index'));
     }
     return array('form' => $form, 'erreur' => @$erreur);
 }
Exemplo n.º 24
0
 /**
  * Activate a user.
  *
  * @param array $data Activation data.
  * @param NewUserModel $newUser The user to create
  *
  * @return boolean
  */
 public function activate($data, NewUserModel $newUser)
 {
     $form = $this->getActivateForm();
     $form->setData($data);
     if (!$form->isValid()) {
         return false;
     }
     $data = $form->getData();
     $bcrypt = $this->sm->get('user_bcrypt');
     // first try to obtain the user
     $user = $this->getUserMapper()->findByLidnr($newUser->getLidnr());
     if (null === $user) {
         // create a new user from this data, and insert it into the database
         $user = new UserModel($newUser);
     }
     $user->setPassword($bcrypt->create($data['password']));
     // this will also save a user with a lost password
     $this->getUserMapper()->createUser($user, $newUser);
     return true;
 }
Exemplo n.º 25
0
 public function editAction()
 {
     $id = $this->params()->fromQuery('id');
     $user = new User();
     $user->setId($id);
     $user->setRole(User::ROLE_MENTOR);
     /** @var \User\Model\UserMapper $userMapper */
     $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
     if (!$user->getId() || !$userMapper->getUser($user)) {
         return $this->page404();
     }
     $form = new \Admin\Form\Expert\Expert($this->getServiceLocator());
     $form->remove('afterSubmit');
     $form->getInputFilter()->remove('userName');
     $form->remove('userName');
     $form->remove('userId');
     $form->setData($user->toFormValues());
     $this->getViewModel()->setVariables(['form' => $form]);
     return $this->getViewModel();
 }
Exemplo n.º 26
0
 public function addAction()
 {
     //        $user_session = new \Zend\Session\Container('user');
     //        if ($user_session->email == null) {
     //            return $this->redirect()->toRoute('signin', array(
     //                        'action' => 'signin'
     //            ));
     //        }
     //        if ($user_session->role == 'Operator') {
     //            return array('error' => 'You don\'t have permission to do this action');
     //        }
     $auth = new \Zend\Authentication\AuthenticationService();
     if ($auth->hasIdentity()) {
         $user = $auth->getIdentity();
     } else {
         return $this->redirect()->toRoute('signin', array('action' => 'index'));
     }
     if ($user->role == 'Operator') {
         //$this->flashMessenger()->addMessage('You don\'t have permission to do this action');
         //$this->redirect()->toRoute('add');
         return array('error' => 'You don\'t have permission to do this action');
     }
     $form = new UserForm(null, $user->role);
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $user->exchangeArray($form->getData());
             $this->getUserTable()->saveUser($user);
             return $this->redirect()->toRoute('user');
         } else {
             echo "Fail to add new user";
         }
     }
     return array('form' => $form, 'flashMessages' => $this->flashMessenger()->getMessages());
 }
 public function getAction($id)
 {
     if ($id <= 0) {
         throw new Exception('Wrong id passed', 500);
     }
     /**
      * @var $user User|boolean
      */
     $user = User::findFirst($id);
     if (!$user) {
         throw new Exception('User not found', 404);
     }
     return array('success' => true, 'result' => array('id' => $user->id, 'nick' => $user->nick, 'firstname' => $user->firstname, 'lastname' => $user->lastname));
 }
Exemplo n.º 28
0
 public function signinAction()
 {
     $form = new LoginForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $post = $request->getPost();
             $sm = $this->getServiceLocator();
             $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
             $authAdapter = new AuthAdapter($dbAdapter);
             $authAdapter->setTableName('user')->setIdentityColumn('username')->setCredentialColumn('password');
             $authAdapter->setIdentity($post->get('username'))->setCredential(sha1($post->get('password')));
             $authService = new AuthenticationService();
             $authService->setAdapter($authAdapter);
             $result = $authService->authenticate();
             if ($result->isValid()) {
                 $user = $this->getUserTable()->getUserByName($post->get('username'));
                 $session = new Container('user');
                 $session->offsetUnset('username');
                 $session->offsetSet('username', $user->username);
                 $session->offsetUnset('id');
                 $session->offsetSet('id', $user->id);
                 return $this->redirect()->toRoute('image');
             } else {
                 echo '<div class="alert alert-error">
                         <button type="button" class="close" data-dismiss="alert">&times;</button>
                         <h4>Warning!</h4>
                         Log in failed!.
                       </div>';
             }
         }
     }
     return array('form' => $form);
 }
Exemplo n.º 29
0
 public function loginAction()
 {
     //        $user = $this->identity();
     $user = new User($this->getServiceLocator());
     $form = new AdminForm();
     $form->get('submit')->setValue('Login');
     $messages = null;
     $request = $this->getRequest();
     if ($request->isPost()) {
         $userdetail = $user->getUserId($request);
         if ($userdetail) {
             $messages = "Successful login";
             $container = new Container('adminloginuser');
             $container->userdetail = $userdetail;
             $container->userid = $userdetail['id'];
             return $this->redirect()->toRoute('admin/default', array('controller' => 'index', 'action' => 'index'));
         } else {
             $messages = "Error login";
             return new ViewModel(array('form' => $form, 'messages' => $messages));
         }
     } else {
         return new ViewModel(array('form' => $form));
     }
 }
Exemplo n.º 30
0
 public function changeroleAction()
 {
     $id = $this->params()->fromPost('id', null);
     $role = $this->params()->fromPost('role', null);
     $facebook = $this->params()->fromPost('facebook', null);
     //  var_dump($facebook);die;
     if ($id && ($role == 5 || $role == 200)) {
         $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper');
         $user = new User();
         $user->setId($id);
         $user = $userMapper->get($user->getId());
         if ($user->getEmail()) {
             $user->setRole($role);
             $user->setFacebook($facebook);
             $userMapper->save($user);
             $this->flashMessenger()->addMessage('Cập nhật thành công!');
             $this->redirect()->toUrl("/admin/user");
         }
         $this->flashMessenger()->addMessage('User không tồn tại!');
         $this->redirect()->toUrl("/admin/user");
     }
     $this->flashMessenger()->addMessage('Dữ liệu truyền vào không đúng!');
     $this->redirect()->toUrl("/admin/user");
 }