'~^[a-z,\-_]+$~i', ); function getPrimaryKey() { return 'role_id'; } function getTable() { return 'k4_roles'; } } class RolesRecord extends FARecord { //------------------------------------------------- // Deal with caching. //------------------------------------------------- var $_channel_perms; var $_channel_objects; var $_cache = array( 'channel' => FALSE, 'channel_objects' => FALSE, ); //------------------------------------------------- // Get permissions for a specific channel. //------------------------------------------------- /* function &getChannelPerms() { if(!$this->_cache['channel']) { $this->_channel_perms = &new ChannelPermissionsIterator('view'); $this->_cache['channel'] = TRUE; } return $this->_channel_perms; } function &getChannelObjects() { if(!$this->_cache['channel_objects']) { //------------------------------------------------- // Get the objects. //------------------------------------------------- $finder = &$this->getFinder('objects'); $objects = &$finder->findAllWhere("object_name LIKE 'channel_%'", array()); //------------------------------------------------- // Get the channels. //------------------------------------------------- $finder = &$this->getFinder('channels'); $channels = &$finder->findAll('order_key ASC', ''); //------------------------------------------------- // So, we've got some channels, let's loop them and // their objects and build a nice array :D //------------------------------------------------- $data = array(); $channel_objects = array(); //------------------------------------------------- // Hazaa, we've got the channels. //------------------------------------------------- if($channels !== NULL && $objects !== NULL) { //------------------------------------------------- // Loop through the objects to make the first set of info. //------------------------------------------------- while($objects->next()) { $object = &$objects->current(); //------------------------------------------------- // Derive the channel id from the object name. //------------------------------------------------- preg_match("~[0-9]+$~", $object->get('object_name'), $matches); $channel_id = intval($matches[0]); $channel_objects[$channel_id]['object_id'] = $object->getId(); $channel_objects[$channel_id]['id'] = $object->getId(); $channel_objects[$channel_id]['object_perms'] = $object->get('object_perms'); } //------------------------------------------------- // Loop through the channels and create the final array // of data. //------------------------------------------------- $i = 0; while($channels->next()) { $channel = &$channels->current(); //------------------------------------------------- // Set some nice channel information. //------------------------------------------------- $data[$i]['object_name'] = $channel->get('name'); $data[$i]['channel_id'] = $channel->getId(); $data[$i]['indent_space'] = $channel->get('indent_space'); $data[$i] = array_merge($data[$i], $channel_objects[$channel->getId()]); $i++; } } //------------------------------------------------- // Cache the results. //------------------------------------------------- $this->_channel_objects = &new FAArrayIterator($data); $this->_cache['channel_objects'] = TRUE; } return $this->_channel_objects; }*/ } ?>