<commit_before><?php

defined('BASEPATH') OR exit('No direct script access allowed');
$path_projects = 'application/apps/projects/views/project/';
$path_modules = 'application/apps/projects/modules/';
$CI = &get_instance();
$CI->load->model('../apps/projects/models/projects_model', null, false, true);
$CI->load->model('../apps/projects/models/pages_model', null, false, true);
$CI->load->model('../apps/projects/models/sections_model', null, false, true);
$CI->load->library('../apps/projects/libraries/config_page');
$projects = $CI->projects_model->list_projects_permissions();
if ($projects) {
    foreach ($projects as $project) {
        $id_project = $project['id'];
        $name_project = $project['name'];
        $slug_project = $project['slug'];
        $dir_project = $project['directory'];
        $pages = $CI->pages_model->list_pages_permissions($id_project);
        if ($pages) {
            foreach ($pages as $page) {
                $id_page = $page['id'];
                $name_page = $page['name'];
                $slug_page = $page['slug'];
                $dir_page = $page['directory'];
                $sections = $CI->sections_model->list_sections_permissions($id_page);
                if ($sections) {
                    foreach ($sections as $section) {
                        $name_section = $section['name'];
                        $slug_section = $section['slug'];
                        $dir_section = $section['directory'];
                        $config = $path_projects . $dir_project . '/' . $dir_page . '/' . $dir_section . '/config.xml';
                        $module = $path_modules . $dir_project . '/' . $dir_page . '/' . $dir_section . '/controllers/' . ucfirst($dir_section) . '.php';
                        $method = $slug_project . '-' . $slug_page . '-' . $slug_section;
                        $page = 'project/'.$slug_project . '/' . $slug_page . '/' . $slug_section;
                        if (!is_file($module)) {
                            // Verifica se possui listagem de registros na seção, se existir insere mais duas permissões
                            if (is_file($config)) {
                                $config = $CI->config_page->load_config($dir_project, $dir_page, $dir_section);
                                if (isset($config['list']) && count($config['list']) > 0) {
                                    $permission[$page][$method] = '<strong>' . $name_project . ' - ' . $name_page . ' - ' . $name_section . '</strong>';
                                    $permission[$page][$page . '/' . 'create'][$method . '-create'] = 'Criar';
                                    $permission[$page][$page . '/' . 'edit/.*'][$method . '-edit'] = 'Editar';
                                    $permission[$page][$page . '/' . $slug_section . '/' . 'remove/.*'][$method . '-remove'] = 'Remover';
                                }else{
                                    $permission[$page][$method] = '<strong>' . $name_project . ' - ' . $name_page . ' - ' . $name_section . '</strong> - Editar';
                                }
                            }<commit_msg>Correção de carregamento do xml<commit_after><?php

defined('BASEPATH') OR exit('No direct script access allowed');
$path_projects = 'application/apps/projects/views/project/';
$path_modules = 'application/apps/projects/modules/';
$CI = &get_instance();
$CI->load->model('../apps/projects/models/projects_model', null, false, true);
$CI->load->model('../apps/projects/models/pages_model', null, false, true);
$CI->load->model('../apps/projects/models/sections_model', null, false, true);
$CI->load->library('../apps/projects/libraries/config_xml');
$projects = $CI->projects_model->list_projects_permissions();
if ($projects) {
    foreach ($projects as $project) {
        $id_project = $project['id'];
        $name_project = $project['name'];
        $slug_project = $project['slug'];
        $dir_project = $project['directory'];
        $pages = $CI->pages_model->list_pages_permissions($id_project);
        if ($pages) {
            foreach ($pages as $page) {
                $id_page = $page['id'];
                $name_page = $page['name'];
                $slug_page = $page['slug'];
                $dir_page = $page['directory'];
                $sections = $CI->sections_model->list_sections_permissions($id_page);
                if ($sections) {
                    foreach ($sections as $section) {
                        $name_section = $section['name'];
                        $slug_section = $section['slug'];
                        $dir_section = $section['directory'];
                        $config = $path_projects . $dir_project . '/' . $dir_page . '/' . $dir_section . '/config.xml';
                        $module = $path_modules . $dir_project . '/' . $dir_page . '/' . $dir_section . '/controllers/' . ucfirst($dir_section) . '.php';
                        $method = $slug_project . '-' . $slug_page . '-' . $slug_section;
                        $page = 'project/' . $slug_project . '/' . $slug_page . '/' . $slug_section;
                        if (!is_file($module)) {
                            // Verifica se possui listagem de registros na seção, se existir insere mais duas permissões
                            if (is_file($config)) {
                                $config = $CI->config_xml->load_config($dir_project, $dir_page, $dir_section);
                                if (isset($config['list']) && count($config['list']) > 0) {
                                    $permission[$page][$method] = '<strong>' . $name_project . ' - ' . $name_page . ' - ' . $name_section . '</strong>';
                                    $permission[$page][$page . '/' . 'create'][$method . '-create'] = 'Criar';
                                    $permission[$page][$page . '/' . 'edit/.*'][$method . '-edit'] = 'Editar';
                                    $permission[$page][$page . '/' . $slug_section . '/' . 'remove/.*'][$method . '-remove'] = 'Remover';
                                } else {
                                    $permission[$page][$method] = '<strong>' . $name_project . ' - ' . $name_page . ' - ' . $name_section . '</strong> - Editar';
                                }
                            }
{'fraction_non_alphanumeric': 0.17691819911223844, 'fraction_numerical': 0.0003170577045022194, 'mean_word_length': 1.727626459143969, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4937203', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1743, 'n_words': 301}