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:  * This is core configuration file.
  5:  *
  6:  * Use it to configure core behaviour ofCake.
  7:  *
  8:  * PHP versions 4 and 5
  9:  *
 10:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 11:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 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. (http://cakefoundation.org)
 17:  * @link          http://cakephp.org CakePHP(tm) Project
 18:  * @package       cake
 19:  * @subpackage    cake.cake.libs.model
 20:  * @since         CakePHP(tm) v 0.2.9
 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:  * Load Model and AppModel
 28:  */
 29: App::import('Model', 'App');
 30: /**
 31:  * Short description for file.
 32:  *
 33:  * Long description for file
 34:  *
 35:  *
 36:  * @package       cake
 37:  * @subpackage    cake.cake.libs.model
 38:  */
 39: class AclNode extends AppModel {
 40: /**
 41:  * Explicitly disable in-memory query caching for ACL models
 42:  *
 43:  * @var boolean
 44:  * @access public
 45:  */
 46:     var $cacheQueries = false;
 47: /**
 48:  * ACL models use the Tree behavior
 49:  *
 50:  * @var array
 51:  * @access public
 52:  */
 53:     var $actsAs = array('Tree' => 'nested');
 54: /**
 55:  * Constructor
 56:  *
 57:  */
 58:     function __construct() {
 59:         $config = Configure::read('Acl.database');
 60:         if (isset($config)) {
 61:             $this->useDbConfig = $config;
 62:         }
 63:         parent::__construct();
 64:     }
 65: /**
 66:  * Retrieves the Aro/Aco node for this model
 67:  *
 68:  * @param mixed $ref Array with 'model' and 'foreign_key', model object, or string value
 69:  * @return array Node found in database
 70:  * @access public
 71:  */
 72:     function node($ref = null) {
 73:         $db =& ConnectionManager::getDataSource($this->useDbConfig);
 74:         $type = $this->alias;
 75:         $result = null;
 76: 
 77:         if (!empty($this->useTable)) {
 78:             $table = $this->useTable;
 79:         } else {
 80:             $table = Inflector::pluralize(Inflector::underscore($type));
 81:         }
 82: 
 83:         if (empty($ref)) {
 84:             return null;
 85:         } elseif (is_string($ref)) {
 86:             $path = explode('/', $ref);
 87:             $start = $path[0];
 88:             unset($path[0]);
 89: 
 90:             $queryData = array(
 91:                 'conditions' => array(
 92:                     $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft"),
 93:                     $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")),
 94:                 'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'),
 95:                 'joins' => array(array(
 96:                     'table' => $db->fullTableName($this),
 97:                     'alias' => "{$type}0",
 98:                     'type' => 'LEFT',
 99:                     'conditions' => array("{$type}0.alias" => $start)
100:                 )),
101:                 'order' => $db->name("{$type}.lft") . ' DESC'
102:             );
103: 
104:             foreach ($path as $i => $alias) {
105:                 $j = $i - 1;
106: 
107:                 $queryData['joins'][] = array(
108:                     'table' => $db->fullTableName($this),
109:                     'alias' => "{$type}{$i}",
110:                     'type'  => 'LEFT',
111:                     'conditions' => array(
112:                         $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"),
113:                         $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"),
114:                         $db->name("{$type}{$i}.alias") . ' = ' . $db->value($alias, 'string'),
115:                         $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id")
116:                     )
117:                 );
118: 
119:                 $queryData['conditions'] = array('or' => array(
120:                     $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght"),
121:                     $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}{$i}.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}{$i}.rght"))
122:                 );
123:             }
124:             $result = $db->read($this, $queryData, -1);
125:             $path = array_values($path);
126: 
127:             if (
128:                 !isset($result[0][$type]) ||
129:                 (!empty($path) && $result[0][$type]['alias'] != $path[count($path) - 1]) ||
130:                 (empty($path) && $result[0][$type]['alias'] != $start)
131:             ) {
132:                 return false;
133:             }
134:         } elseif (is_object($ref) && is_a($ref, 'Model')) {
135:             $ref = array('model' => $ref->alias, 'foreign_key' => $ref->id);
136:         } elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
137:             $name = key($ref);
138: 
139:             if (PHP5) {
140:                 $model = ClassRegistry::init(array('class' => $name, 'alias' => $name));
141:             } else {
142:                 $model =& ClassRegistry::init(array('class' => $name, 'alias' => $name));
143:             }
144: 
145:             if (empty($model)) {
146:                 trigger_error("Model class '$name' not found in AclNode::node() when trying to bind {$this->alias} object", E_USER_WARNING);
147:                 return null;
148:             }
149: 
150:             $tmpRef = null;
151:             if (method_exists($model, 'bindNode')) {
152:                 $tmpRef = $model->bindNode($ref);
153:             }
154:             if (empty($tmpRef)) {
155:                 $ref = array('model' => $name, 'foreign_key' => $ref[$name][$model->primaryKey]);
156:             } else {
157:                 if (is_string($tmpRef)) {
158:                     return $this->node($tmpRef);
159:                 }
160:                 $ref = $tmpRef;
161:             }
162:         }
163:         if (is_array($ref)) {
164:             if (is_array(current($ref)) && is_string(key($ref))) {
165:                 $name = key($ref);
166:                 $ref = current($ref);
167:             }
168:             foreach ($ref as $key => $val) {
169:                 if (strpos($key, $type) !== 0 && strpos($key, '.') === false) {
170:                     unset($ref[$key]);
171:                     $ref["{$type}0.{$key}"] = $val;
172:                 }
173:             }
174:             $queryData = array(
175:                 'conditions' => $ref,
176:                 'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'),
177:                 'joins' => array(array(
178:                     'table' => $db->fullTableName($this),
179:                     'alias' => "{$type}0",
180:                     'type' => 'LEFT',
181:                     'conditions' => array(
182:                         $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft"),
183:                         $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")
184:                     )
185:                 )),
186:                 'order' => $db->name("{$type}.lft") . ' DESC'
187:             );
188:             $result = $db->read($this, $queryData, -1);
189: 
190:             if (!$result) {
191:                 trigger_error("AclNode::node() - Couldn't find {$type} node identified by \"" . print_r($ref, true) . "\"", E_USER_WARNING);
192:             }
193:         }
194:         return $result;
195:     }
196: }
197: /**
198:  * Access Control Object
199:  *
200:  * @package       cake
201:  * @subpackage    cake.cake.libs.model
202:  */
203: class Aco extends AclNode {
204: /**
205:  * Model name
206:  *
207:  * @var string
208:  * @access public
209:  */
210:     var $name = 'Aco';
211: /**
212:  * Binds to ARO nodes through permissions settings
213:  *
214:  * @var array
215:  * @access public
216:  */
217:     var $hasAndBelongsToMany = array('Aro' => array('with' => 'Permission'));
218: }
219: /**
220:  * Action for Access Control Object
221:  *
222:  * @package       cake
223:  * @subpackage    cake.cake.libs.model
224:  */
225: class AcoAction extends AppModel {
226: /**
227:  * Model name
228:  *
229:  * @var string
230:  * @access public
231:  */
232:     var $name = 'AcoAction';
233: /**
234:  * ACO Actions belong to ACOs
235:  *
236:  * @var array
237:  * @access public
238:  */
239:     var $belongsTo = array('Aco');
240: }
241: /**
242:  * Access Request Object
243:  *
244:  * @package       cake
245:  * @subpackage    cake.cake.libs.model
246:  */
247: class Aro extends AclNode {
248: /**
249:  * Model name
250:  *
251:  * @var string
252:  * @access public
253:  */
254:     var $name = 'Aro';
255: /**
256:  * AROs are linked to ACOs by means of Permission
257:  *
258:  * @var array
259:  * @access public
260:  */
261:     var $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission'));
262: }
263: /**
264:  * Permissions linking AROs with ACOs
265:  *
266:  * @package       cake
267:  * @subpackage    cake.cake.libs.model
268:  */
269: class Permission extends AppModel {
270: /**
271:  * Model name
272:  *
273:  * @var string
274:  * @access public
275:  */
276:     var $name = 'Permission';
277: /**
278:  * Explicitly disable in-memory query caching
279:  *
280:  * @var boolean
281:  * @access public
282:  */
283:     var $cacheQueries = false;
284: /**
285:  * Override default table name
286:  *
287:  * @var string
288:  * @access public
289:  */
290:     var $useTable = 'aros_acos';
291: /**
292:  * Permissions link AROs with ACOs
293:  *
294:  * @var array
295:  * @access public
296:  */
297:     var $belongsTo = array('Aro', 'Aco');
298: /**
299:  * No behaviors for this model
300:  *
301:  * @var array
302:  * @access public
303:  */
304:     var $actsAs = null;
305: /**
306:  * Constructor, used to tell this model to use the
307:  * database configured for ACL
308:  */
309:     function __construct() {
310:         $config = Configure::read('Acl.database');
311:         if (!empty($config)) {
312:             $this->useDbConfig = $config;
313:         }
314:         parent::__construct();
315:     }
316: }
317: ?>
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