public function act_test() { include APPROOT . '3rd/phpgacl/gacl_api.class.php'; // $gacl_api = new gacl_api(array('db'=>$global['db'] , 'db_table_prefix'=>'gacl_')); $gacl_api = new gacl_api(); $gacl_api->clear_database(); // ARO // $root_aro = $gacl_api->add_group('root', 'OpenEvSysUser', 0, 'ARO'); $user_group = $gacl_api->add_group('users', 'Users', $root_aro, 'ARO'); $g_user_admin = $gacl_api->add_group('admin', 'Admin', $user_group, ' ARO'); $g_user_analyst = $gacl_api->add_group('analyst', 'Analyst', $user_group, ' ARO'); $g_user_data_entry = $gacl_api->add_group('data_entry', 'Data Entry', $user_group, ' ARO'); $ws_group = $gacl_api->add_group('ws', 'WS', $root_aro, 'ARO'); // ARO sections $gacl_api->add_object_section('Users', 'users', 1, 0, 'ARO'); //ARO values $gacl_api->add_object('users', 'Admin', 'admin', 1, 0, 'ARO'); $gacl_api->add_object('users', 'User1', 'user1', 2, 0, 'ARO'); $gacl_api->add_object('users', 'User2', 'user2', 3, 0, 'ARO'); $gacl_api->add_object('users', 'User3', 'user3', 4, 0, 'ARO'); //ACO // //ACO sections $gacl_api->add_object_section('CRUD', 'crud', 1, 0, 'ACO'); $gacl_api->add_object_section('Access', 'access', 1, 0, 'ACO'); //ACO values $gacl_api->add_object('access', 'Access', 'access', 1, 0, 'ACO'); $gacl_api->add_object('crud', 'Create', 'create', 1, 0, 'ACO'); $gacl_api->add_object('crud', 'Read', 'read', 2, 0, 'ACO'); $gacl_api->add_object('crud', 'Update', 'update', 3, 0, 'ACO'); $gacl_api->add_object('crud', 'Delete', 'delete', 4, 0, 'ACO'); // AXO // $root_axo = $gacl_api->add_group('root', 'root', 0, 'AXO'); $gacl_api->add_group('modules', 'Modules', $root_axo, 'AXO'); $entity_group = $gacl_api->add_group('entities', 'Entities', $root_axo, 'AXO'); $g_entities_primary = $gacl_api->add_group('primary', 'Primary', $entity_group, 'AXO'); $g_entities_linking = $gacl_api->add_group('linking', 'Linking', $entity_group, 'AXO'); $g_entities_additional = $gacl_api->add_group('additional', 'Additional Details', $entity_group, 'AXO'); $g_events = $gacl_api->add_group('events', 'Events', $root_axo, 'AXO'); // AXO sections // $gacl_api->add_object_section('Modules', 'modules', 1, 0, 'AXO'); $gacl_api->add_object_section('Entities', 'entities', 2, 0, 'AXO'); $gacl_api->add_object_section('Events', 'events', 3, 0, 'AXO'); // AXO values $gacl_api->add_object('modules', 'Event', 'events', 1, 0, 'AXO'); $gacl_api->add_object('modules', 'Person', 'person', 2, 0, 'AXO'); $gacl_api->add_object('modules', 'Documents', 'docu', 3, 0, 'AXO'); $gacl_api->add_object('modules', 'Home', 'home', 4, 0, 'AXO'); $gacl_api->add_object('modules', 'Help', 'help', 5, 0, 'AXO'); $gacl_api->add_object('modules', 'Admin', 'admin', 6, 0, 'AXO'); $gacl_api->add_object('modules', 'Analysis', 'analysis', 7, 0, 'AXO'); $gacl_api->add_object('entities', 'Event', 'event', 1, 0, 'AXO'); $gacl_api->add_object('entities', 'Person', 'person', 2, 0, 'AXO'); $gacl_api->add_object('entities', 'Document', 'document', 3, 0, 'AXO'); $gacl_api->add_object('entities', 'Information', 'information', 4, 0, 'AXO'); $gacl_api->add_object('entities', 'Involvement', 'involvement', 5, 0, 'AXO'); $gacl_api->add_object('entities', 'Intervention', 'intervention', 6, 0, 'AXO'); $gacl_api->add_object('entities', 'Act', 'act', 7, 0, 'AXO'); $gacl_api->add_object('entities', 'Chain Of Events', 'chain_of_events', 8, 0, 'AXO'); $gacl_api->add_object('entities', 'Biographic Details', 'biographic_details', 9, 0, 'AXO'); // Add Groups $gacl_api->add_group_object($g_entities_primary, 'entities', 'event', 'AXO'); $gacl_api->add_group_object($g_entities_primary, 'entities', 'person', 'AXO'); $gacl_api->add_group_object($g_entities_primary, 'entities', 'document', 'AXO'); $gacl_api->add_group_object($g_entities_linking, 'entities', 'act', 'AXO'); $gacl_api->add_group_object($g_entities_linking, 'entities', 'information', 'AXO'); $gacl_api->add_group_object($g_entities_linking, 'entities', 'intervention', 'AXO'); $gacl_api->add_group_object($g_entities_linking, 'entities', 'involvement', 'AXO'); $gacl_api->add_group_object($g_entities_linking, 'entities', 'chain_of_events', 'AXO'); $gacl_api->add_group_object($g_entities_additional, 'entities', 'biographic_details', 'AXO'); $gacl_api->add_group_object($g_user_admin, 'users', 'admin', 'ARO'); $gacl_api->add_group_object($g_user_data_entry, 'users', 'user1', 'ARO'); $gacl_api->add_group_object($g_user_analyst, 'users', 'user2', 'ARO'); $gacl_api->add_group_object($g_user_data_entry, 'users', 'user3', 'ARO'); // permissions $gacl_api->add_acl(array('access' => array('access')), null, array($root_aro), array('modules' => array('home', 'help'))); $gacl_api->add_acl(array('access' => array('access')), null, array($g_user_admin), array('modules' => array('events', 'person', 'docu', 'analysis', 'admin'))); $gacl_api->add_acl(array('access' => array('access')), null, array($g_user_analyst), array('modules' => array('analysis'))); $gacl_api->add_acl(array('access' => array('access')), null, array($g_user_data_entry), array('modules' => array('person', 'events', 'docu'))); $gacl_api->add_acl(array('crud' => array('create', 'read', 'update', 'delete')), null, array($root_aro), array('entities' => array('person', 'event', 'act', 'information', 'intervention', 'involvement', 'chain_of_events', 'biographic_details'))); $gacl_api->add_acl(array('crud' => array('create', 'read', 'update', 'delete')), null, array($root_aro), null, array($g_events)); }
<?php global $conf; global $global; define('APPROOT', realpath(dirname(__FILE__) . '/../') . '/'); require_once APPROOT . 'conf/sysconf.php'; include APPROOT . '3rd/phpgacl/gacl.class.php'; include APPROOT . '3rd/phpgacl/gacl_api.class.php'; include APPROOT . 'inc/handler_db.inc'; # $gacl= new gacl(array('db_host'=> $conf['db_host'] , 'db_name'=> $conf['db_name'] , 'db_user'=> $conf['db_user'], 'db_password'=> $conf['db_pass'] , 'db_table_prefix'=>'gacl_' , 'db_type'=> 'mysql' )); # $gacl_api = new gacl_api(array('db_host'=> $conf['db_host'] , 'db_name'=> $conf['db_name'] , 'db_user'=> $conf['db_user'], 'db_password'=> $conf['db_pass'] , 'db_table_prefix'=>'gacl_' , 'db_type'=> 'mysql' )); $gacl = new gacl(array('db' => $global['db'], 'db_table_prefix' => 'gacl_')); $gacl_api = new gacl_api(array('db' => $global['db'], 'db_table_prefix' => 'gacl_')); $gacl_api->clear_database(); // ARO // $root_aro = $gacl_api->add_group('root', 'OpenEvSysUser', 0, 'ARO'); $user_group = $gacl_api->add_group('users', 'Users', $root_aro, 'ARO'); $g_user_admin = $gacl_api->add_group('admin', 'Admin', $user_group, ' ARO'); $g_user_analyst = $gacl_api->add_group('analyst', 'Analyst', $user_group, ' ARO'); $g_user_data_entry = $gacl_api->add_group('data_entry', 'Data Entry', $user_group, ' ARO'); $ws_group = $gacl_api->add_group('ws', 'WS', $root_aro, 'ARO'); // ARO sections $gacl_api->add_object_section('Users', 'users', 1, 0, 'ARO'); //ARO values $gacl_api->add_object('users', 'Admin', 'admin', 1, 0, 'ARO'); //ACO // //ACO sections $gacl_api->add_object_section('CRUD', 'crud', 1, 0, 'ACO'); $gacl_api->add_object_section('Access', 'access', 1, 0, 'ACO'); //ACO values $gacl_api->add_object('access', 'Access', 'access', 1, 0, 'ACO');
function commit_update() { //set phpgacl options $gacl_options = array('smarty_dir' => 'phpgacl/admin/smarty/libs', 'smarty_template_dir' => 'phpgacl/admin/templates', 'smarty_compile_dir' => AMP_SYSTEM_CACHE_PATH, 'db_type' => AMP_DB_TYPE, 'db_host' => AMP_DB_HOST, 'db_user' => AMP_DB_USER, 'db_password' => AMP_DB_PASS, 'db_name' => AMP_DB_NAME, 'db_table_prefix' => 'acl_'); if (!defined('AMP_SYSTEM_PERMISSIONS_LOADING')) { define('AMP_SYSTEM_PERMISSIONS_LOADING', 1); } require_once 'phpgacl/gacl_api.class.php'; $gacl = new gacl_api($gacl_options); //$gacl = AMP_acl( true ); $this->_upgrade_database('acl_'); $gacl->clear_database(); //ACOs $aco_objects = array('view' => 'View', 'access' => 'Access', 'create' => 'Create', 'save' => 'Save', 'submit' => 'Submit', 'publish' => 'Publish', 'delete' => 'Delete'); $aco_sections = array('commands' => 'Commands'); $aco_complete_set = array('commands' => $aco_objects); foreach ($aco_sections as $value => $name) { $aco_section_id[$value] = $gacl->add_object_section($name, $value, 0, 0, 'ACO'); foreach ($aco_objects as $aco_value => $aco_name) { $aco_id[$aco_value] = $gacl->add_object($value, $aco_name, $aco_value, 0, 0, 'ACO'); } } // AROs $client_root_id = $gacl->add_group('clients', 'Clients', 0, 'ARO'); $admin_group = $gacl->add_group('admins', 'Admins', $client_root_id, 'ARO'); $users = AMP_lookup('admins'); $aro_sections = array('users' => 'Users'); foreach ($users as $id => $name) { $aro_objects['user_' . $id] = $name; } foreach ($aro_sections as $value => $name) { $gacl->add_object_section($name, $value, 0, 0, 'ARO'); } foreach ($aro_objects as $value => $name) { $aro_object_ids[$value] = $gacl->add_object('users', $name, $value, 0, 0, 'ARO'); $gacl->add_group_object($admin_group, 'users', $value, 'ARO'); } //AXOs $system_root = $gacl->add_group('system', 'AMP', 0, 'AXO'); $site_root = $gacl->add_group('site', AMP_SITE_NAME, $system_root, 'AXO'); $section_root = $gacl->add_object_section(AMP_SITE_NAME . ' Content', 'sections', 0, 0, 'AXO'); $section_order_ref = AMP_lookup('sectionMap'); require_once 'AMP/Content/Map/Complete.php'; $map = AMP_Content_Map_Complete::instance(); $map_result = $map->selectOptions(); $section_order_ref = $map_result; $section_names_source = new AMPContentLookup_Sections(); //AMP_lookup( 'sections' ); $section_parents_source = new AMPContentLookup_SectionParents(); AMP_lookup('sectionParents'); $section_names = $section_names_source->dataset; $section_parents = $section_parents_source->dataset; if ($section_order_ref && $section_names) { $sections = array_combine_key(array_keys($section_order_ref), $section_names); $sections = array(AMP_CONTENT_MAP_ROOT_SECTION => AMP_SITE_NAME) + $sections; } else { $sections = array(AMP_CONTENT_MAP_ROOT_SECTION => AMP_SITE_NAME); } $axo_group_ids = array(); foreach ($sections as $id => $name) { $parent_group_id = $site_root; $parent_id_content = isset($section_parents[$id]) ? $section_parents[$id] : AMP_CONTENT_MAP_ROOT_SECTION; if (isset($axo_group_ids[$parent_id_content])) { $parent_group_id = $axo_group_ids[$parent_id_content]; } $parent_group_id = $gacl->add_group('section_' . $id, $name, $parent_group_id, 'AXO'); $axo_group_ids['section'][$id] = $parent_group_id; $axo_object_ids[$id] = $gacl->add_object('sections', $name, 'section_' . $id, 0, 0, 'AXO'); $gacl->add_group_object($parent_group_id, 'sections', 'section_' . $id, 'AXO'); } //ACLs $group_ids = AMP_lookup('permissionGroups'); foreach ($group_ids as $group_id => $group_name) { $acl_group_id = $gacl->add_group('group_' . $group_id, $group_name, $admin_group, 'ARO'); $allowed_sections_lookup = new AMPSystemLookup_SectionsByGroup($group_id); //AMP_lookup( 'sectionsByGroup', $group_id ); $allowed_sections = $allowed_sections_lookup->dataset; $affected_users = AMP_lookup('usersByGroup', $group_id); if (!$affected_users) { continue; } foreach ($affected_users as $user_id => $user_name) { $gacl->add_group_object($acl_group_id, 'users', 'user_' . $user_id, 'ARO'); } if (!$allowed_sections) { $allow_group = array($site_root); } else { $allow_group = array_combine_key(array_keys($allowed_sections), $axo_group_ids['section']); } $acl_id = $gacl->add_acl($aco_complete_set, array(), array($acl_group_id), array(), $allow_group, true, true); } $reg =& AMP_Registry::instance(); $reg->setEntry(AMP_REGISTRY_PERMISSION_MANAGER, $gacl); $this->message('Permissions Update Successful'); AMP_cacheFlush(AMP_CACHE_TOKEN_LOOKUP); return true; }