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.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 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
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • 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
  • write_css_cache
  1: <?php
  2: /* SVN FILE: $Id$ */
  3: /**
  4:  * ACL behavior class.
  5:  *
  6:  * Enables objects to easily tie into an ACL system
  7:  *
  8:  * PHP versions 4 and 5
  9:  *
 10:  * CakePHP :  Rapid Development Framework (http://cakephp.org)
 11:  * Copyright 2005-2012, Cake Software Foundation, Inc.
 12:  *
 13:  * Licensed under The MIT License
 14:  * Redistributions of files must retain the above copyright notice.
 15:  *
 16:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc.
 17:  * @link          http://cakefoundation.org/projects/info/cakephp CakePHP Project
 18:  * @package       cake
 19:  * @subpackage    cake.cake.libs.model.behaviors
 20:  * @since         CakePHP v 1.2.0.4487
 21:  * @version       $Revision$
 22:  * @modifiedby    $LastChangedBy$
 23:  * @lastmodified  $Date$
 24:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 25:  */
 26: /**
 27:  * Short description for file
 28:  *
 29:  * Long description for file
 30:  *
 31:  * @package       cake
 32:  * @subpackage    cake.cake.libs.model.behaviors
 33:  */
 34: class AclBehavior extends ModelBehavior {
 35: /**
 36:  * Maps ACL type options to ACL models
 37:  *
 38:  * @var array
 39:  * @access protected
 40:  */
 41:     var $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco');
 42: /**
 43:  * Sets up the configuation for the model, and loads ACL models if they haven't been already
 44:  *
 45:  * @param mixed $config
 46:  * @return void
 47:  * @access public
 48:  */
 49:     function setup(&$model, $config = array()) {
 50:         if (is_string($config)) {
 51:             $config = array('type' => $config);
 52:         }
 53:         $this->settings[$model->name] = array_merge(array('type' => 'requester'), (array)$config);
 54: 
 55:         $type = $this->__typeMaps[$this->settings[$model->name]['type']];
 56:         if (!class_exists('AclNode')) {
 57:             uses('model' . DS . 'db_acl');
 58:         }
 59:         $model->{$type} =& ClassRegistry::init($type);
 60:         if (!method_exists($model, 'parentNode')) {
 61:             trigger_error("Callback parentNode() not defined in {$model->alias}", E_USER_WARNING);
 62:         }
 63:     }
 64: /**
 65:  * Retrieves the Aro/Aco node for this model
 66:  *
 67:  * @param mixed $ref
 68:  * @return array
 69:  * @access public
 70:  */
 71:     function node(&$model, $ref = null) {
 72:         $type = $this->__typeMaps[strtolower($this->settings[$model->name]['type'])];
 73:         if (empty($ref)) {
 74:             $ref = array('model' => $model->name, 'foreign_key' => $model->id);
 75:         }
 76:         return $model->{$type}->node($ref);
 77:     }
 78: /**
 79:  * Creates a new ARO/ACO node bound to this record
 80:  *
 81:  * @param boolean $created True if this is a new record
 82:  * @return void
 83:  * @access public
 84:  */
 85:     function afterSave(&$model, $created) {
 86:         if ($created) {
 87:             $type = $this->__typeMaps[strtolower($this->settings[$model->name]['type'])];
 88:             $parent = $model->parentNode();
 89:             if (!empty($parent)) {
 90:                 $parent = $this->node($model, $parent);
 91:             } else {
 92:                 $parent = null;
 93:             }
 94: 
 95:             $model->{$type}->create();
 96:             $model->{$type}->save(array(
 97:                 'parent_id'     => Set::extract($parent, "0.{$type}.id"),
 98:                 'model'         => $model->name,
 99:                 'foreign_key'   => $model->id
100:             ));
101:         }
102:     }
103: /**
104:  * Destroys the ARO/ACO node bound to the deleted record
105:  *
106:  * @return void
107:  * @access public
108:  */
109:     function afterDelete(&$model) {
110:         $type = $this->__typeMaps[strtolower($this->settings[$model->name]['type'])];
111:         $node = Set::extract($this->node($model), "0.{$type}.id");
112:         if (!empty($node)) {
113:             $model->{$type}->delete($node);
114:         }
115:     }
116: }
117: 
118: ?>
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