CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BakeTask
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeRoute
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbConfigTask
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • FileLog
  • FixtureTask
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JqueryEngineHelper
  • JsBaseEngineHelper
  • JsHelper
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • MootoolsEngineHelper
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginShortRoute
  • PluginTask
  • ProjectTask
  • PrototypeEngineHelper
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • Set
  • Shell
  • String
  • TemplateTask
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  1: <?php
  2: /**
  3:  * ACL behavior class.
  4:  *
  5:  * Enables objects to easily tie into an ACL system
  6:  *
  7:  * PHP versions 4 and 5
  8:  *
  9:  * CakePHP :  Rapid Development Framework (http://cakephp.org)
 10:  * Copyright 2005-2012, Cake Software Foundation, Inc.
 11:  *
 12:  * Licensed under The MIT License
 13:  * Redistributions of files must retain the above copyright notice.
 14:  *
 15:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc.
 16:  * @link          http://cakephp.org CakePHP Project
 17:  * @package       cake
 18:  * @subpackage    cake.cake.libs.model.behaviors
 19:  * @since         CakePHP v 1.2.0.4487
 20:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 21:  */
 22: 
 23: /**
 24:  * ACL behavior
 25:  *
 26:  * @package       cake
 27:  * @subpackage    cake.cake.libs.model.behaviors
 28:  * @link http://book.cakephp.org/1.3/en/The-Manual/Core-Behaviors/ACL.html#ACL
 29:  */
 30: class AclBehavior extends ModelBehavior {
 31: 
 32: /**
 33:  * Maps ACL type options to ACL models
 34:  *
 35:  * @var array
 36:  * @access protected
 37:  */
 38:     var $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco');
 39: 
 40: /**
 41:  * Sets up the configuation for the model, and loads ACL models if they haven't been already
 42:  *
 43:  * @param mixed $config
 44:  * @return void
 45:  * @access public
 46:  */
 47:     function setup(&$model, $config = array()) {
 48:         if (is_string($config)) {
 49:             $config = array('type' => $config);
 50:         }
 51:         $this->settings[$model->name] = array_merge(array('type' => 'requester'), (array)$config);
 52:         $this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']);
 53: 
 54:         $type = $this->__typeMaps[$this->settings[$model->name]['type']];
 55:         if (!class_exists('AclNode')) {
 56:             require LIBS . 'model' . DS . 'db_acl.php';
 57:         }
 58:         if (PHP5) {
 59:             $model->{$type} = ClassRegistry::init($type);
 60:         } else {
 61:             $model->{$type} =& ClassRegistry::init($type);
 62:         }
 63:         if (!method_exists($model, 'parentNode')) {
 64:             trigger_error(sprintf(__('Callback parentNode() not defined in %s', true), $model->alias), E_USER_WARNING);
 65:         }
 66:     }
 67: 
 68: /**
 69:  * Retrieves the Aro/Aco node for this model
 70:  *
 71:  * @param mixed $ref
 72:  * @return array
 73:  * @access public
 74:  * @link http://book.cakephp.org/1.3/en/The-Manual/Core-Behaviors/ACL.html#node
 75:  */
 76:     function node(&$model, $ref = null) {
 77:         $type = $this->__typeMaps[$this->settings[$model->name]['type']];
 78:         if (empty($ref)) {
 79:             $ref = array('model' => $model->name, 'foreign_key' => $model->id);
 80:         }
 81:         return $model->{$type}->node($ref);
 82:     }
 83: 
 84: /**
 85:  * Creates a new ARO/ACO node bound to this record
 86:  *
 87:  * @param boolean $created True if this is a new record
 88:  * @return void
 89:  * @access public
 90:  */
 91:     function afterSave(&$model, $created) {
 92:         $type = $this->__typeMaps[$this->settings[$model->name]['type']];
 93:         $parent = $model->parentNode();
 94:         if (!empty($parent)) {
 95:             $parent = $this->node($model, $parent);
 96:         }
 97:         $data = array(
 98:             'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null,
 99:             'model' => $model->name,
100:             'foreign_key' => $model->id
101:         );
102:         if (!$created) {
103:             $node = $this->node($model);
104:             $data['id'] = isset($node[0][$type]['id']) ? $node[0][$type]['id'] : null;
105:         }
106:         $model->{$type}->create();
107:         $model->{$type}->save($data);
108:     }
109: 
110: /**
111:  * Destroys the ARO/ACO node bound to the deleted record
112:  *
113:  * @return void
114:  * @access public
115:  */
116:     function afterDelete(&$model) {
117:         $type = $this->__typeMaps[$this->settings[$model->name]['type']];
118:         $node = Set::extract($this->node($model), "0.{$type}.id");
119:         if (!empty($node)) {
120:             $model->{$type}->delete($node);
121:         }
122:     }
123: }
124: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs