/application/modules/default/controllers/IndexController.php

https://bitbucket.org/darang/utm5cabinet_009 · PHP · 74 lines · 52 code · 14 blank · 8 comment · 8 complexity · d6e2a8cddbf7fd09cddd1f4c770031e5 MD5 · raw file

  1. <?php
  2. /**
  3. * @author Siomkin Alexandr <mail@mg7.by>
  4. * @link http://www.jext.biz/
  5. * @copyright Copyright &copy; 2011-2012
  6. * @license GNU General Public License, version 2:
  7. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  8. */
  9. class Default_IndexController extends Zend_Controller_Action
  10. {
  11. public function init()
  12. {
  13. $this->config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/billing.ini', 'app');
  14. }
  15. public function indexAction()
  16. {
  17. $this->view->title = "";
  18. $this->view->headTitle($this->view->title, 'PREPEND');
  19. $uri = $this->_getParam('return_uri','/user/');
  20. if ($this->view->identity != FALSE) {
  21. $this->redirect('/user/');
  22. }
  23. $form = new Default_Form_Login();
  24. if ($this->getRequest()->isPost()) {
  25. if ($form->isValid($this->getRequest()->getPost())) {
  26. $auth = Zend_Auth::getInstance();
  27. $authAdapter = new Urfa_Auth_Adapter($form->getValue('username'), $form->getValue('password'));
  28. $result = $auth->authenticate($authAdapter);
  29. if ($result->isValid()) {
  30. // Yay! User is authenticated and stored in the session (via the storage class)
  31. $this->redirect($uri);
  32. } else {
  33. $this->_helper->flashMessenger->addMessage(
  34. array('error' => '?????? ???????????. ?? ?????? ???? ?????-??????')
  35. );
  36. $this->redirect('/');
  37. }
  38. }
  39. }
  40. $this->view->form = $form;
  41. if(!empty($this->config->notice)){
  42. $this->view->notice = $this->config->notice;
  43. }
  44. }
  45. public function logoutAction()
  46. {
  47. if (!$this->view->identity) {
  48. $this->_helper->flashMessenger->addMessage(
  49. array('error' => '??? ?????????? ??????????????')
  50. );
  51. $this->redirect('/');
  52. }
  53. $_auth = Zend_Auth::getInstance();
  54. $_auth->clearIdentity();
  55. $this->_helper->flashMessenger->addMessage(
  56. array('success' => '?? ????????')
  57. );
  58. $this->redirect('/');
  59. }
  60. }