getUser(); if($context == null) { $context = ''; } $configurations = $this->orderConfigurations(AgaviConfigCache::parseConfig($config, true, $this->getValidationFile())->configurations, AgaviConfig::get('core.environment'), $context); $data = array(); foreach($configurations as $cfg) { if(isset($cfg->roles) ) { $this->parseHierarchy($user, $cfg->roles); } } $code = '$this->importHierarchy(' . var_export($user->exportHierarchy(), true) . ');'; // compile data $retval = ""; $retval = sprintf($retval, gmdate('m/d/Y H:i:s'), $code); return $retval; } protected function parseHierarchy($user, $roles, $parent = null) { foreach($roles as $role) { $name = $role->getAttribute('name'); $opts = array(); if($role->hasAttribute('description') ) $opts['description'] = $role->getAttribute('description'); if($role->hasAttribute('global_access') ) $opts['global_access'] = $this->literalize($role->getAttribute('global_access') ); $permissions = array(); if($role->hasChildren('permissions') ) { foreach($role->permissions as $permission) { $permissions[$permission->getAttribute('name')] = true; } } $user->addHierarchy($name, $permissions, $opts, $parent); if($role->hasChildren('roles') ) { $this->parseHierarchy($user, $role->roles, $name); } } } } ?>