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