<commit_before><?php  // $Id$

    require_once(dirname(dirname(__FILE__)) . '/config.php');
    require_once($CFG->dirroot . '/repository/lib.php');
    //require_once($CFG->libdir . '/adminlib.php');

    $edit    = optional_param('edit', 0, PARAM_INT);        // Repository ID
    $new     = optional_param('new', '', PARAM_FORMAT);
    $delete  = optional_param('delete', 0, PARAM_INT);
    $sure    = optional_param('sure', '', PARAM_ALPHA);
    $contextid = optional_param('contextid', 0, PARAM_INT);
    $usercourseid = optional_param('usercourseid', SITEID, PARAM_INT);  // Extra: used for user context only

    if ($edit){
        $pagename = 'repositoryinstanceedit';
    } else if ($delete) {
        $pagename = 'repositorydelete';
    } else if ($new) {
        $pagename = 'repositoryinstancenew';
    } else {
        $pagename = 'repositorylist';
    }

    require_login(SITEID, false);

    $context = get_context_instance_by_id($contextid);

/// Security: make sure we're allowed to do this operation
    if ($context->contextlevel == CONTEXT_COURSE) {
        $pagename = get_string("repositorycourse",'repository');

        // If the user is allowed to edit this course, he's allowed to edit list of repository instances
        require_capability('moodle/course:update',  $context);

        if ( !$course = $DB->get_record('course', array('id'=>$context->instanceid))) {<commit_msg>repository MDL-19821 Added set_url call<commit_after><?php  // $Id$

    require_once(dirname(dirname(__FILE__)) . '/config.php');
    require_once($CFG->dirroot . '/repository/lib.php');
    //require_once($CFG->libdir . '/adminlib.php');

    $edit    = optional_param('edit', 0, PARAM_INT);        // Repository ID
    $new     = optional_param('new', '', PARAM_FORMAT);
    $delete  = optional_param('delete', 0, PARAM_INT);
    $sure    = optional_param('sure', '', PARAM_ALPHA);
    $contextid = optional_param('contextid', 0, PARAM_INT);
    $usercourseid = optional_param('usercourseid', SITEID, PARAM_INT);  // Extra: used for user context only

    $url = new moodle_url($CFG->wwwroot.'/repository/manage_instances.php');

    if ($edit){
        $url->param('edit', $edit);
        $pagename = 'repositoryinstanceedit';
    } else if ($delete) {
        $url->param('delete', $delete);
        $pagename = 'repositorydelete';
    } else if ($new) {
        $url->param('new', $new);
        $pagename = 'repositoryinstancenew';
    } else {
        $pagename = 'repositorylist';
    }

    if ($sure !== '') {
        $url->param('sure', $sure);
    }
    if ($contextid !== 0) {
        $url->param('contextid', $contextid);
    }
    if ($usercourseid !== SITEID) {
        $url->param('usercourseid', $usercourseid);
    }

    $PAGE->set_url($url);

    require_login(SITEID, false);

    $context = get_context_instance_by_id($contextid);

/// Security: make sure we're allowed to do this operation
    if ($context->contextlevel == CONTEXT_COURSE) {
        $pagename = get_string("repositorycourse",'repository');

        // If the user is allowed to edit this course, he's allowed to edit list of repository instances
        require_capability('moodle/course:update',  $context);

        if ( !$course = $DB->get_record('course', array('id'=>$context->instanceid))) {
{'fraction_non_alphanumeric': 0.16322815533980584, 'fraction_numerical': 0.0036407766990291263, 'mean_word_length': 3.25968992248062, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '3928594', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1022, 'n_words': 220}