<commit_before><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once 'ilios_web_controller.php';

/**
 * @package Ilios
 *
 * Controller for Ilios' user management module.
 */
class Management_Console extends Ilios_Web_Controller
{
    /**
     * Constructor.
     */
    public function __construct ()
    {
        parent::__construct();

        $this->load->model('Authentication', 'authentication', true);
        $this->load->model('Cohort', 'cohort', true);
        $this->load->model('Permission', 'permission', true);
        $this->load->model('Program', 'program', true);
        $this->load->model('School', 'school', true);
        $this->load->model('User', 'user', true);
    }

    /**
     * Default controller action.
     * Prints the user management console view.
     */
    public function index ()
    {
        $lang = $this->getLangToUse();

        $data = array();
        $data['lang'] = $lang;
        $data['institution_name'] = $this->config->item('ilios_institution_name');
        $data['user_id'] = $this->session->userdata('uid');

        // authorization check
        if (! $this->session->userdata('has_admin_access')) {
            $this->_viewAccessForbiddenPage($lang, $data);
            return;
        }

        // switch schools if instructed
        $change_school = $this->input->get_post('schoolselect');
        if ($change_school) {
            $this->_setActiveSchool($change_school);
        }

        // get the current school id
        $schoolId = $this->session->userdata('school_id');
        $schoolTitle = null;

        if (! in_array($schoolId, $this->_getAvailableSchools())) {
            // Reset to primary school
            $this->_setActiveSchool($this->session->userdata('primary_school_id'));
            $schoolId = $this->session->userdata('school_id');
        }

        //get the  title of the currently selected school
        $schoolRow = $this->school->getRowForPrimaryKeyId($schoolId);
        if ($schoolRow) {
            $schoolTitle = $schoolRow->title;
        }

        $institution = $this->config->item('ilios_institution_name');
        $data['viewbar_title'] = $data['institution_name'];

        // add school title (and school switcher if applicable) to viewbar
        if ($schoolTitle != null) {
            $key = 'general.phrases.school_of';
            $schoolOfStr = $this->languagemap->getI18NString($key, $lang);
            $data['viewbar_title'] .= ' ' . $schoolOfStr . ' ' . $schoolTitle;

            $availSchools = $this->_getAvailableSchools();

            if (count($availSchools) > 1) {
                $school_ids = $availSchools;
                $schools = array();
                foreach ($school_ids as $sid) {
                    $row = $this->school->getRowForPrimaryKeyId($sid);
                    $schools[$sid] = $row->title;
                }
                $data['available_schools'] = $schools;
                $data['selected_school_id'] = $schoolId;

                $key = 'general.phrases.select_school';
                $data['select_school_string'] = $this->languagemap->getI18NString($key, $lang);
            }
        }

        $data['manage_login_credentials'] = true; // flag used enable login credentials mngmt. in the UI
        $authnMethod = $this->config->item('ilios_authentication');

        switch ($authnMethod) {
            case 'shibboleth' :
                $data['manage_login_credentials'] = false;
                break;
            case 'default' :
            default :<commit_msg>pushing flag to the view indicating whether user passwords need to be captured in account management screens. refs #3615<commit_after><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once 'ilios_web_controller.php';

/**
 * @package Ilios
 *
 * Controller for Ilios' user management module.
 */
class Management_Console extends Ilios_Web_Controller
{
    /**
     * Constructor.
     */
    public function __construct ()
    {
        parent::__construct();

        $this->load->model('Authentication', 'authentication', true);
        $this->load->model('Cohort', 'cohort', true);
        $this->load->model('Permission', 'permission', true);
        $this->load->model('Program', 'program', true);
        $this->load->model('School', 'school', true);
        $this->load->model('User', 'user', true);
    }

    /**
     * Default controller action.
     * Prints the user management console view.
     */
    public function index ()
    {
        $lang = $this->getLangToUse();

        $data = array();
        $data['lang'] = $lang;
        $data['institution_name'] = $this->config->item('ilios_institution_name');
        $data['user_id'] = $this->session->userdata('uid');

        // authorization check
        if (! $this->session->userdata('has_admin_access')) {
            $this->_viewAccessForbiddenPage($lang, $data);
            return;
        }

        // switch schools if instructed
        $change_school = $this->input->get_post('schoolselect');
        if ($change_school) {
            $this->_setActiveSchool($change_school);
        }

        // get the current school id
        $schoolId = $this->session->userdata('school_id');
        $schoolTitle = null;

        if (! in_array($schoolId, $this->_getAvailableSchools())) {
            // Reset to primary school
            $this->_setActiveSchool($this->session->userdata('primary_school_id'));
            $schoolId = $this->session->userdata('school_id');
        }

        //get the  title of the currently selected school
        $schoolRow = $this->school->getRowForPrimaryKeyId($schoolId);
        if ($schoolRow) {
            $schoolTitle = $schoolRow->title;
        }

        $institution = $this->config->item('ilios_institution_name');
        $data['viewbar_title'] = $data['institution_name'];

        // add school title (and school switcher if applicable) to viewbar
        if ($schoolTitle != null) {
            $key = 'general.phrases.school_of';
            $schoolOfStr = $this->languagemap->getI18NString($key, $lang);
            $data['viewbar_title'] .= ' ' . $schoolOfStr . ' ' . $schoolTitle;

            $availSchools = $this->_getAvailableSchools();

            if (count($availSchools) > 1) {
                $school_ids = $availSchools;
                $schools = array();
                foreach ($school_ids as $sid) {
                    $row = $this->school->getRowForPrimaryKeyId($sid);
                    $schools[$sid] = $row->title;
                }
                $data['available_schools'] = $schools;
                $data['selected_school_id'] = $schoolId;

                $key = 'general.phrases.select_school';
                $data['select_school_string'] = $this->languagemap->getI18NString($key, $lang);
            }
        }

        $data['manage_login_credentials'] = true; // flag used enable login credentials mngmt. in the UI
        $data['password_required'] = true;
        $authnMethod = $this->config->item('ilios_authentication');

        switch ($authnMethod) {
            case 'shibboleth' :
                $data['manage_login_credentials'] = false;
                $data['password_required'] = <PASSWORD>;
                break;
            case 'ldap' :
                $data['password_required'] = false;
                break;
            case 'default' :
            default :
{'fraction_non_alphanumeric': 0.14812332439678283, 'fraction_numerical': 0.0018766756032171583, 'mean_word_length': 2.220112214069918, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 98, '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': '6882964', 'n_tokens_mistral': 2154, 'n_tokens_neox': 2075, 'n_words': 407}