<commit_before><?php

class Project_groups extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('client_model');
        $this->load->model('project_group_model');
        $this->load->model('project_model');
        $this->load->model('layer_model');
        $this->load->model('user_model');
        $this->load->helper(array('eqwc_parse','path'));
    }

    public function index()
    {
        $task = 'project_groups_table_view';

        if (!$this->ion_auth->can_execute_task($task)){
            $this->session->set_flashdata('message', '<div class="alert alert-danger text-center">No permission!</div>');
            redirect('/auth/login');
        }

        //filter for client administrator
        $user_role = $this->ion_auth->admin_scope();
        $filter = $user_role->filter;

        $data['title'] = $this->lang->line('gp_groups_title');
        $data['lang'] = $this->session->userdata('lang') == null ? get_code($this->config->item('language')) : $this->session->userdata('lang');
        $data['groups'] = $this->project_group_model->get_project_groups($filter);
        $data['logged_in'] = true;
        $data['is_admin'] = $user_role->admin;
        $data['role'] = $user_role->role_name;

        $this->load->view('templates/header', $data);
        $this->load->view('project_groups_admin', $data);
        $this->load->view('templates/footer', $data);
    }

    /*
     * Portal view
     */
    public function view($client_id = false, $parent_id = null)
    {
        if ($client_id === FALSE) {
            redirect("/");
        }

        if (!$this->ion_auth->logged_in()) {
            redirect('/auth/login?ru=/' . uri_string());
        }

        $client = $this->client_model->get_client($client_id);
        $user_role = $this->ion_auth->admin_scope();

        $data['title'] = $this->lang->line('gp_groups_title');
        $data['lang'] = $this->session->userdata('lang') == null ? get_code($this->config->item('language')) : $this->session->userdata('lang');
        $data['logged_in'] = true;
        $data['is_admin'] = $user_role->admin;
        $data['role'] = $user_role->role_name;

		//rss
		if(!empty($this->config->item('rss_feed_url'))) {
			$rss_config['url'] = $this->config->item('rss_feed_url');
			$rss_config['limit'] = empty($this->config->item('rss_feed_limit')) ? 10 : $this->config->item('rss_feed_limit');
			$this->load->library('rss_parser', $rss_config);
			$rss['rss'] = $this->rss_parser->parse();
			$rss['rss']['last_login'] = $this->session->userdata('old_last_login');
		}

        try {
            $data['items'] = $this->get_user_groups($client_id,$parent_id,$data['is_admin']);

            //if there is only one group, open it
            if(count($data['items']) == 1) {
                redirect('projects/view_group/' . $client_id . '/' . $data['items'][0]['id']);
            }

            $data['navigation'] = $this->build_user_navigation($client,$parent_id);
        } catch (Exception $e) {
            $this->session->set_flashdata('alert', '<div class="alert alert-danger text-center">' . $e->getMessage() . '</div>');
            redirect("/");
        }

        $data['client_id'] = $client_id;

        $this->load->view('templates/header', $data);
        $this->load->view('project_groups', $data);
		if(!empty($rss)) {
			$this->load->view('rss_short', $rss);
		}
        $this->load->view('templates/footer', $data);

    }<commit_msg>Fix wrong redirection, closing #50<commit_after><?php

class Project_groups extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('client_model');
        $this->load->model('project_group_model');
        $this->load->model('project_model');
        $this->load->model('layer_model');
        $this->load->model('user_model');
        $this->load->helper(array('eqwc_parse','path'));
    }

    public function index()
    {
        $task = 'project_groups_table_view';

        if (!$this->ion_auth->can_execute_task($task)){
            $this->session->set_flashdata('message', '<div class="alert alert-danger text-center">No permission!</div>');
            redirect('/auth/login');
        }

        //filter for client administrator
        $user_role = $this->ion_auth->admin_scope();
        $filter = $user_role->filter;

        $data['title'] = $this->lang->line('gp_groups_title');
        $data['lang'] = $this->session->userdata('lang') == null ? get_code($this->config->item('language')) : $this->session->userdata('lang');
        $data['groups'] = $this->project_group_model->get_project_groups($filter);
        $data['logged_in'] = true;
        $data['is_admin'] = $user_role->admin;
        $data['role'] = $user_role->role_name;

        $this->load->view('templates/header', $data);
        $this->load->view('project_groups_admin', $data);
        $this->load->view('templates/footer', $data);
    }

    /*
     * Portal view
     */
    public function view($client_id = false, $parent_id = null)
    {
        if ($client_id === FALSE) {
            redirect("/");
        }

        if (!$this->ion_auth->logged_in()) {
            redirect('/auth/login?ru=/' . uri_string());
        }

        $client = $this->client_model->get_client($client_id);
        $user_role = $this->ion_auth->admin_scope();

        $data['title'] = $this->lang->line('gp_groups_title');
        $data['lang'] = $this->session->userdata('lang') == null ? get_code($this->config->item('language')) : $this->session->userdata('lang');
        $data['logged_in'] = true;
        $data['is_admin'] = $user_role->admin;
        $data['role'] = $user_role->role_name;

		//rss
		if(!empty($this->config->item('rss_feed_url'))) {
			$rss_config['url'] = $this->config->item('rss_feed_url');
			$rss_config['limit'] = empty($this->config->item('rss_feed_limit')) ? 10 : $this->config->item('rss_feed_limit');
			$this->load->library('rss_parser', $rss_config);
			$rss['rss'] = $this->rss_parser->parse();
			$rss['rss']['last_login'] = $this->session->userdata('old_last_login');
		}

        try {
            $data['items'] = $this->get_user_groups($client_id,$parent_id,$data['is_admin']);

            //if there is only one group, open it
            if(count($data['items']) == 1) {
				if ($data['items'][0]['type'] === SUB_GROUP) {
					redirect('project_groups/view/' . $client_id . '/' . $data['items'][0]['id']);
				} else {
					redirect('projects/view_group/' . $client_id . '/' . $data['items'][0]['id']);
				}
            }

            $data['navigation'] = $this->build_user_navigation($client,$parent_id);
        } catch (Exception $e) {
            $this->session->set_flashdata('alert', '<div class="alert alert-danger text-center">' . $e->getMessage() . '</div>');
            redirect("/");
        }

        $data['client_id'] = $client_id;

        $this->load->view('templates/header', $data);
        $this->load->view('project_groups', $data);
		if(!empty($rss)) {
			$this->load->view('rss_short', $rss);
		}
        $this->load->view('templates/footer', $data);

    }
{'fraction_non_alphanumeric': 0.213428252372976, 'fraction_numerical': 0.0016750418760469012, 'mean_word_length': 2.96513558384062, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 171, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '965227', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2252, 'n_words': 299}