ActionsAuthorize.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * PHP 5
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  6. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * Redistributions of files must retain the above copyright notice.
  10. *
  11. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  12. * @link http://cakephp.org CakePHP(tm) Project
  13. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  14. */
  15. App::uses('BaseAuthorize', 'Controller/Component/Auth');
  16. /**
  17. * An authorization adapter for AuthComponent. Provides the ability to authorize using the AclComponent,
  18. * If AclComponent is not already loaded it will be loaded using the Controller's ComponentCollection.
  19. *
  20. * @package Cake.Controller.Component.Auth
  21. * @since 2.0
  22. * @see AuthComponent::$authenticate
  23. * @see AclComponent::check()
  24. */
  25. class ActionsAuthorize extends BaseAuthorize {
  26. /**
  27. * Authorize a user using the AclComponent.
  28. *
  29. * @param array $user The user to authorize
  30. * @param CakeRequest $request The request needing authorization.
  31. * @return boolean
  32. */
  33. public function authorize($user, CakeRequest $request) {
  34. $Acl = $this->_Collection->load('Acl');
  35. $user = array($this->settings['userModel'] => $user);
  36. return $Acl->check($user, $this->action($request));
  37. }
  38. }