AjaxAuthController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * AjaxAuthController
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @since 3.0.0
  16. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  17. */
  18. namespace TestApp\Controller;
  19. use Cake\Controller\Controller;
  20. use Cake\Event\Event;
  21. /**
  22. * AjaxAuthController class
  23. *
  24. */
  25. class AjaxAuthController extends Controller {
  26. /**
  27. * components property
  28. *
  29. * @var array
  30. */
  31. public $components = array('Session', 'TestAuth');
  32. /**
  33. * uses property
  34. *
  35. * @var array
  36. */
  37. public $uses = array();
  38. /**
  39. * testUrl property
  40. *
  41. * @var mixed null
  42. */
  43. public $testUrl = null;
  44. /**
  45. * beforeFilter method
  46. *
  47. * @param Event $event
  48. * @return void
  49. */
  50. public function beforeFilter(Event $event) {
  51. $this->TestAuth->config('ajaxLogin', 'test_element');
  52. $this->TestAuth->config('userModel', 'AuthUser');
  53. $this->TestAuth->RequestHandler->ajaxLayout = 'ajax2';
  54. }
  55. /**
  56. * add method
  57. *
  58. * @return void
  59. */
  60. public function add() {
  61. if ($this->TestAuth->testStop !== true) {
  62. echo 'Added Record';
  63. }
  64. }
  65. /**
  66. * redirect method
  67. *
  68. * @param mixed $url
  69. * @param mixed $status
  70. * @param mixed $exit
  71. * @return void
  72. */
  73. public function redirect($url, $status = null, $exit = true) {
  74. $this->testUrl = Router::url($url);
  75. return false;
  76. }
  77. }