Пример #1
0
    protected function setUp() {
        global $CFG, $PAGE, $SITE;
        parent::setUp();

        $PAGE->set_url('/');
        $PAGE->set_course($SITE);

        $this->activeurl = $PAGE->url;
        navigation_node::override_active_url($this->activeurl);

        $this->inactiveurl = new moodle_url('http://www.moodle.com/');
        $this->fakeproperties['action'] = $this->inactiveurl;

        $this->node = new navigation_node('Test Node');
        $this->node->type = navigation_node::TYPE_SYSTEM;
        $demo1 = $this->node->add('demo1', $this->inactiveurl, navigation_node::TYPE_COURSE, null, 'demo1', new pix_icon('i/course', ''));
        $demo2 = $this->node->add('demo2', $this->inactiveurl, navigation_node::TYPE_COURSE, null, 'demo2', new pix_icon('i/course', ''));
        $demo3 = $this->node->add('demo3', $this->inactiveurl, navigation_node::TYPE_CATEGORY, null, 'demo3',new pix_icon('i/course', ''));
        $demo4 = $demo3->add('demo4', $this->inactiveurl,navigation_node::TYPE_COURSE,  null, 'demo4', new pix_icon('i/course', ''));
        $demo5 = $demo3->add('demo5', $this->activeurl, navigation_node::TYPE_COURSE, null, 'demo5',new pix_icon('i/course', ''));
        $demo5->add('activity1', null, navigation_node::TYPE_ACTIVITY, null, 'activity1')->make_active();
        $hiddendemo1 = $this->node->add('hiddendemo1', $this->inactiveurl, navigation_node::TYPE_CATEGORY, null, 'hiddendemo1', new pix_icon('i/course', ''));
        $hiddendemo1->hidden = true;
        $hiddendemo1->add('hiddendemo2', $this->inactiveurl, navigation_node::TYPE_COURSE, null, 'hiddendemo2', new pix_icon('i/course', ''))->helpbutton = 'Here is a help button';;
        $hiddendemo1->add('hiddendemo3', $this->inactiveurl, navigation_node::TYPE_COURSE,null, 'hiddendemo3', new pix_icon('i/course', ''))->display = false;
    }
Пример #2
0
 protected function setup_node()
 {
     global $PAGE, $SITE;
     $PAGE->set_url('/');
     $PAGE->set_course($SITE);
     $activeurl = $PAGE->url;
     $inactiveurl = new moodle_url('http://www.moodle.com/');
     navigation_node::override_active_url($PAGE->url);
     $this->node = new navigation_node('Test Node');
     $this->node->type = navigation_node::TYPE_SYSTEM;
     // We add the first child without key. This way we make sure all keys search by comparison is performed using ===.
     $this->node->add('first child without key', null, navigation_node::TYPE_CUSTOM);
     $demo1 = $this->node->add('demo1', $inactiveurl, navigation_node::TYPE_COURSE, null, 'demo1', new pix_icon('i/course', ''));
     $demo2 = $this->node->add('demo2', $inactiveurl, navigation_node::TYPE_COURSE, null, 'demo2', new pix_icon('i/course', ''));
     $demo3 = $this->node->add('demo3', $inactiveurl, navigation_node::TYPE_CATEGORY, null, 'demo3', new pix_icon('i/course', ''));
     $demo4 = $demo3->add('demo4', $inactiveurl, navigation_node::TYPE_COURSE, null, 'demo4', new pix_icon('i/course', ''));
     $demo5 = $demo3->add('demo5', $activeurl, navigation_node::TYPE_COURSE, null, 'demo5', new pix_icon('i/course', ''));
     $demo5->add('activity1', null, navigation_node::TYPE_ACTIVITY, null, 'activity1')->make_active();
     $hiddendemo1 = $this->node->add('hiddendemo1', $inactiveurl, navigation_node::TYPE_CATEGORY, null, 'hiddendemo1', new pix_icon('i/course', ''));
     $hiddendemo1->hidden = true;
     $hiddendemo1->add('hiddendemo2', $inactiveurl, navigation_node::TYPE_COURSE, null, 'hiddendemo2', new pix_icon('i/course', ''))->helpbutton = 'Here is a help button';
     $hiddendemo1->add('hiddendemo3', $inactiveurl, navigation_node::TYPE_COURSE, null, 'hiddendemo3', new pix_icon('i/course', ''))->display = false;
 }
    redirect(new moodle_url('/'));
}
require_login($course);
require_capability("enrol/globalclassroom:unenrol", get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST));
$manager = new course_enrolment_manager($PAGE, $course, $filter);
$table = new course_enrolment_users_table($manager, $PAGE);
// The URL of the enrolled users page for the course.
$usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
// The URl to return the user too after this screen.
$returnurl = new moodle_url($usersurl, $manager->get_url_params() + $table->get_url_params());
// The URL of this page
$url = new moodle_url('/enrol/globalclassroom/unenroluser.php', $returnurl->params());
$url->param('ue', $ueid);
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url($usersurl);
list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
if (!$plugin->allow_unenrol($instance) || $instance->enrol != 'globalclassroom' || !$plugin instanceof enrol_globalclassroom_plugin) {
    print_error('erroreditenrolment', 'enrol');
}
// If the unenrolment has been confirmed and the sesskey is valid unenrol the user.
if ($confirm && confirm_sesskey() && $manager->unenrol_user($ue)) {
    redirect($returnurl);
}
$yesurl = new moodle_url($PAGE->url, array('confirm' => 1, 'sesskey' => sesskey()));
$message = get_string('unenroluser', 'enrol_globalclassroom', array('user' => fullname($user, true), 'course' => format_string($course->fullname)));
$fullname = fullname($user);
$title = get_string('unenrol', 'enrol_globalclassroom');
$PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->navbar->add($title);
Пример #4
0
}
if ($manager->get_context()->contextlevel < CONTEXT_COURSE) {
    throw new coding_exception('Unsupported gradable area context level');
}
// get the currently active method
$method = $manager->get_active_method();
list($context, $course, $cm) = get_context_info_array($manager->get_context()->id);
require_login($course, true, $cm);
require_capability('moodle/grade:managegradingforms', $context);
if (!empty($returnurl)) {
    $returnurl = new moodle_url($returnurl);
} else {
    $returnurl = null;
}
$PAGE->set_url($manager->get_management_url($returnurl));
navigation_node::override_active_url($manager->get_management_url());
$PAGE->set_title(get_string('gradingmanagement', 'core_grading'));
$PAGE->set_heading(get_string('gradingmanagement', 'core_grading'));
$output = $PAGE->get_renderer('core_grading');
// process the eventual change of the active grading method
if (!empty($setmethod)) {
    require_sesskey();
    if ($setmethod == 'none') {
        // here we expect that noone would actually want to call their plugin as 'none'
        $setmethod = null;
    }
    $manager->set_active_method($setmethod);
    redirect($PAGE->url);
}
// publish the form as a template
if (!empty($shareform)) {
Пример #5
0
 * @copyright  2013 Petr Skoda {@link http://skodak.org}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require __DIR__ . '../../config.php';
require_once "{$CFG->libdir}/adminlib.php";
$enrol = optional_param('enrol', '', PARAM_RAW);
if (!core_component::is_valid_plugin_name('enrol', $enrol)) {
    $enrol = '';
} else {
    if (!file_exists("{$CFG->dirroot}/enrol/{$enrol}/lib.php")) {
        $enrol = '';
    }
}
require_login();
require_capability('moodle/site:config', context_system::instance());
navigation_node::override_active_url(new moodle_url('/admin/settings.php', array('section' => 'manageenrols')));
admin_externalpage_setup('enroltestsettings');
$returnurl = new moodle_url('/admin/settings.php', array('section' => 'manageenrols'));
echo $OUTPUT->header();
if (!$enrol) {
    $options = array();
    $plugins = core_component::get_plugin_list('enrol');
    foreach ($plugins as $name => $fulldir) {
        $plugin = enrol_get_plugin($name);
        if (!$plugin or !method_exists($plugin, 'test_settings')) {
            continue;
        }
        $options[$name] = get_string('pluginname', 'enrol_' . $name);
    }
    if (!$options) {
        redirect($returnurl);
Пример #6
0
$hdr = get_string('managebadges', 'badges');
$returnurl = new moodle_url('/badges/index.php', $urlparams);
$PAGE->set_url($returnurl);
if ($type == BADGE_TYPE_SITE) {
    $title = get_string('sitebadges', 'badges');
    $PAGE->set_context(context_system::instance());
    $PAGE->set_pagelayout('admin');
    $PAGE->set_heading($title . ': ' . $hdr);
    navigation_node::override_active_url(new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)));
} else {
    require_login($course);
    $title = get_string('coursebadges', 'badges');
    $PAGE->set_context(context_course::instance($course->id));
    $PAGE->set_pagelayout('course');
    $PAGE->set_heading($course->fullname . ': ' . $hdr);
    navigation_node::override_active_url(new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_COURSE, 'id' => $course->id)));
}
if (!has_any_capability(array('moodle/badges:viewawarded', 'moodle/badges:createbadge', 'moodle/badges:awardbadge', 'moodle/badges:configuremessages', 'moodle/badges:configuredetails', 'moodle/badges:deletebadge'), $PAGE->context)) {
    redirect($CFG->wwwroot);
}
$PAGE->set_title($hdr);
$PAGE->requires->js('/badges/backpack.js');
$PAGE->requires->js_init_call('check_site_access', null, false);
$output = $PAGE->get_renderer('core', 'badges');
if ($delete && has_capability('moodle/badges:deletebadge', $PAGE->context)) {
    $badge = new badge($delete);
    if (!$confirm) {
        echo $output->header();
        echo $output->confirm(get_string('delconfirm', 'badges', $badge->name), new moodle_url($PAGE->url, array('delete' => $badge->id, 'confirm' => 1)), $returnurl);
        echo $output->footer();
        die;
Пример #7
0
$attemptobj->load_questions($questionids);
$attemptobj->load_question_states($questionids);
/// Save the flag states, if they are being changed.
if ($options->flags == QUESTION_FLAGSEDITABLE && optional_param('savingflags', false, PARAM_BOOL)) {
    require_sesskey();
    $formdata = data_submitted();
    question_save_flags($formdata, $attemptid, $questionids);
    redirect($attemptobj->review_url(0, $page, $showall));
}
/// Log this review.
add_to_log($attemptobj->get_courseid(), 'quiz', 'review', 'review.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Work out appropriate title and whether blocks should be shown
if ($attemptobj->is_preview_user() && $attemptobj->is_own_attempt()) {
    // Normal blocks
    $strreviewtitle = get_string('reviewofpreview', 'quiz');
    navigation_node::override_active_url($attemptobj->start_attempt_url());
} else {
    $strreviewtitle = get_string('reviewofattempt', 'quiz', $attemptobj->get_attempt_number());
    if (empty($attemptobj->get_quiz()->showblocks) && !$attemptobj->is_preview_user()) {
        // Only show pretend blocks
        $PAGE->blocks->show_only_fake_blocks();
    }
}
// Initialise the JavaScript.
$headtags = $attemptobj->get_html_head_contributions($page);
// Arrange for the navigation to be displayed.
$navbc = $attemptobj->get_navigation_panel('quiz_review_nav_panel', $page, $showall);
$firstregion = reset($PAGE->blocks->get_regions());
$PAGE->blocks->add_fake_block($navbc, $firstregion);
/// Print the page header
$headtags = $attemptobj->get_html_head_contributions($page);
Пример #8
0
$id = required_param('id', PARAM_INT);
// Course ID.
$delete = optional_param('delete', '', PARAM_ALPHANUM);
// Confirmation hash.
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$coursecontext = context_course::instance($course->id);
require_login();
if ($SITE->id == $course->id || !can_delete_course($id)) {
    // Can not delete frontpage or don't have permission to delete the course.
    print_error('cannotdeletecourse');
}
$categorycontext = context_coursecat::instance($course->category);
$PAGE->set_url('/course/delete.php', array('id' => $id));
$PAGE->set_context($categorycontext);
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url(new moodle_url('/course/management.php', array('categoryid' => $course->category)));
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
$coursefullname = format_string($course->fullname, true, array('context' => $coursecontext));
$categoryurl = new moodle_url('/course/management.php', array('categoryid' => $course->category));
// Check if we've got confirmation.
if ($delete === md5($course->timemodified)) {
    // We do - time to delete the course.
    require_sesskey();
    $strdeletingcourse = get_string("deletingcourse", "", $courseshortname);
    $PAGE->navbar->add($strdeletingcourse);
    $PAGE->set_title("{$SITE->shortname}: {$strdeletingcourse}");
    $PAGE->set_heading($SITE->fullname);
    echo $OUTPUT->header();
    echo $OUTPUT->heading($strdeletingcourse);
    // We do this here because it spits out feedback as it goes.
    delete_course($course);
Пример #9
0
    $urlparams['page'] = $page;
}
if ($perpage) {
    $urlparams['perpage'] = $perpage;
}
$urlparams += $searchcriteria;

$PAGE->set_pagelayout('coursecategory');
$courserenderer = $PAGE->get_renderer('core', 'course');

if (can_edit_in_category()) {
    // Integrate into the admin tree only if the user can edit categories at the top level,
    // otherwise the admin block does not appear to this user, and you get an error.
    require_once($CFG->libdir . '/adminlib.php');
    if ($id) {
        navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $id)));
    }
    admin_externalpage_setup('coursemgmt', '', $urlparams, $CFG->wwwroot . '/course/manage.php');
    $settingsnode = $PAGE->settingsnav->find_active_node();
    if ($id && $settingsnode) {
        $settingsnode->make_inactive();
        $settingsnode->force_open();
        $PAGE->navbar->add($settingsnode->text, $settingsnode->action);
    }
} else {
    $site = get_site();
    $PAGE->set_title("$site->shortname: $coursecat->name");
    $PAGE->set_heading($site->fullname);
    $PAGE->set_button($courserenderer->course_search_form('', 'navbar'));
}
Пример #10
0
// Process template deletion.
if ($deletetempl) {
    require_sesskey();
    $template = $DB->get_record('feedback_template', array('id' => $deletetempl), '*', MUST_EXIST);
    if ($template->ispublic) {
        require_capability('mod/feedback:createpublictemplate', $systemcontext);
        require_capability('mod/feedback:deletetemplate', $systemcontext);
    }
    feedback_delete_template($template);
    redirect($baseurl, get_string('template_deleted', 'feedback'));
}
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
$strdeletefeedback = get_string('delete_template', 'feedback');
navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php', array('id' => $id, 'do_show' => 'templates')));
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/// print the tabs
require 'tabs.php';
// Print the main part of the page.
echo $OUTPUT->heading($strdeletefeedback, 3);
// First we get the course templates.
$templates = feedback_get_template_list($course, 'own');
echo $OUTPUT->box_start('coursetemplates');
echo $OUTPUT->heading(get_string('course'), 4);
$tablecourse = new mod_feedback_templates_table('feedback_template_course_table', $baseurl);
$tablecourse->display($templates);
echo $OUTPUT->box_end();
Пример #11
0
}
require_capability('moodle/cohort:manage', $context);
$returnurl = new moodle_url('/cohort/index.php', array('contextid' => $context->id));
if (!empty($cohort->component)) {
    // we can not manually edit cohorts that were created by external systems, sorry
    redirect($returnurl);
}
$PAGE->set_context($context);
$PAGE->set_url('/cohort/edit.php', array('contextid' => $context->id, 'id' => $cohort->id));
$PAGE->set_context($context);
if ($context->contextlevel == CONTEXT_COURSECAT) {
    $category = $DB->get_record('course_categories', array('id' => $context->instanceid), '*', MUST_EXIST);
    navigation_node::override_active_url(new moodle_url('/cohort/index.php', array('contextid' => $cohort->contextid)));
    $PAGE->set_pagelayout('report');
} else {
    navigation_node::override_active_url(new moodle_url('/cohort/index.php', array()));
    $PAGE->set_pagelayout('admin');
}
if ($delete and $cohort->id) {
    $PAGE->url->param('delete', 1);
    if ($confirm and confirm_sesskey()) {
        cohort_delete_cohort($cohort);
        redirect($returnurl);
    }
    $strheading = get_string('delcohort', 'cohort');
    $PAGE->navbar->add($strheading);
    $PAGE->set_title($strheading);
    $PAGE->set_heading($COURSE->fullname);
    echo $OUTPUT->header();
    echo $OUTPUT->heading($strheading);
    $yesurl = new moodle_url('/cohort/edit.php', array('id' => $cohort->id, 'delete' => 1, 'confirm' => 1, 'sesskey' => sesskey()));
Пример #12
0
    $fullmodulename = get_string('modulename', $module->name);
    if ($data->section && $course->format != 'site') {
        $heading = new stdClass();
        $heading->what = $fullmodulename;
        $heading->to = $sectionname;
        $pageheading = get_string('addinganewto', 'moodle', $heading);
    } else {
        $pageheading = get_string('addinganew', 'moodle', $fullmodulename);
    }
    $navbaraddition = $pageheading;
} else {
    if (!empty($update)) {
        $url->param('update', $update);
        $PAGE->set_url($url);
        // Select the "Edit settings" from navigation.
        navigation_node::override_active_url(new moodle_url('/course/modedit.php', array('update' => $update, 'return' => 1)));
        // Check the course module exists.
        $cm = get_coursemodule_from_id('', $update, 0, false, MUST_EXIST);
        // Check the course exists.
        $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
        // require_login
        require_login($course, false, $cm);
        // needed to setup proper $COURSE
        list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
        $data->coursemodule = $cm->id;
        $data->section = $cw->section;
        // The section number itself - relative!!! (section column in course_sections)
        $data->visible = $cm->visible;
        //??  $cw->visible ? $cm->visible : 0; // section hiding overrides
        $data->cmidnumber = $cm->idnumber;
        // The cm IDnumber
Пример #13
0
         // Code.
         $attributes = array('wrap' => 'virtual', 'rows' => 5, 'style' => 'width:95%');
         $mform->addElement('textarea', 'css', get_string('csscode', 'dataform'), $attributes);
         // Uploads.
         $options = array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'maxfiles' => 10, 'accepted_types' => array('*.css'));
         $mform->addElement('filemanager', 'cssupload', get_string('cssupload', 'dataform'), null, $options);
         // Buttons.
         $this->add_action_buttons(true);
     }
 }
 // Set a dataform object.
 $df = mod_dataform_dataform::instance($urlparams->d, $urlparams->id);
 $df->require_manage_permission('css');
 $df->set_page('css', array('urlparams' => $urlparams));
 // Activate navigation node.
 navigation_node::override_active_url(new moodle_url('/mod/dataform/css.php', array('id' => $df->cm->id, 'cssedit' => 1)));
 $mform = new mod_dataform_css_form(new moodle_url('/mod/dataform/css.php', array('d' => $df->id, 'cssedit' => 1)));
 if ($data = $mform->get_data()) {
     // Update the dataform.
     $rec = new stdClass();
     $rec->css = $data->css;
     $rec->cssincludes = $data->cssincludes;
     $df->update($rec, get_string('csssaved', 'dataform'));
     // Add uploaded files.
     $options = array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'maxfiles' => 10, 'accepted_types' => array('*.css'));
     file_save_draft_area_files($data->cssupload, $df->context->id, 'mod_dataform', 'css', 0, $options);
 }
 $output = $df->get_renderer();
 echo $output->header(array('tab' => 'css', 'heading' => $df->name, 'urlparams' => $urlparams));
 $options = array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'maxfiles' => 10);
 $draftitemid = file_get_submitted_draft_itemid('cssupload');
Пример #14
0
/**
 * Common setup for all pages for editing questions.
 * @param string $baseurl the name of the script calling this funciton. For examle 'qusetion/edit.php'.
 * @param string $edittab code for this edit tab
 * @param bool $requirecmid require cmid? default false
 * @param bool $requirecourseid require courseid, if cmid is not given? default true
 * @return array $thispageurl, $contexts, $cmid, $cm, $module, $pagevars
 */
function question_edit_setup($edittab, $baseurl, $requirecmid = false, $requirecourseid = true)
{
    global $DB, $PAGE;
    $thispageurl = new moodle_url($baseurl);
    $thispageurl->remove_all_params();
    // We are going to explicity add back everything important - this avoids unwanted params from being retained.
    if ($requirecmid) {
        $cmid = required_param('cmid', PARAM_INT);
    } else {
        $cmid = optional_param('cmid', 0, PARAM_INT);
    }
    if ($cmid) {
        list($module, $cm) = get_module_from_cmid($cmid);
        $courseid = $cm->course;
        $thispageurl->params(compact('cmid'));
        require_login($courseid, false, $cm);
        $thiscontext = context_module::instance($cmid);
    } else {
        $module = null;
        $cm = null;
        if ($requirecourseid) {
            $courseid = required_param('courseid', PARAM_INT);
        } else {
            $courseid = optional_param('courseid', 0, PARAM_INT);
        }
        if ($courseid) {
            $thispageurl->params(compact('courseid'));
            require_login($courseid, false);
            $thiscontext = context_course::instance($courseid);
        } else {
            $thiscontext = null;
        }
    }
    if ($thiscontext) {
        $contexts = new question_edit_contexts($thiscontext);
        $contexts->require_one_edit_tab_cap($edittab);
    } else {
        $contexts = null;
    }
    $PAGE->set_pagelayout('admin');
    $pagevars['qpage'] = optional_param('qpage', -1, PARAM_INT);
    //pass 'cat' from page to page and when 'category' comes from a drop down menu
    //then we also reset the qpage so we go to page 1 of
    //a new cat.
    $pagevars['cat'] = optional_param('cat', 0, PARAM_SEQUENCE);
    // if empty will be set up later
    if ($category = optional_param('category', 0, PARAM_SEQUENCE)) {
        if ($pagevars['cat'] != $category) {
            // is this a move to a new category?
            $pagevars['cat'] = $category;
            $pagevars['qpage'] = 0;
        }
    }
    if ($pagevars['cat']) {
        $thispageurl->param('cat', $pagevars['cat']);
    }
    if (strpos($baseurl, '/question/') === 0) {
        navigation_node::override_active_url($thispageurl);
    }
    if ($pagevars['qpage'] > -1) {
        $thispageurl->param('qpage', $pagevars['qpage']);
    } else {
        $pagevars['qpage'] = 0;
    }
    $pagevars['qperpage'] = question_get_display_preference('qperpage', DEFAULT_QUESTIONS_PER_PAGE, PARAM_INT, $thispageurl);
    for ($i = 1; $i <= question_bank_view::MAX_SORTS; $i++) {
        $param = 'qbs' . $i;
        if (!($sort = optional_param($param, '', PARAM_TEXT))) {
            break;
        }
        $thispageurl->param($param, $sort);
    }
    $defaultcategory = question_make_default_categories($contexts->all());
    $contextlistarr = array();
    foreach ($contexts->having_one_edit_tab_cap($edittab) as $context) {
        $contextlistarr[] = "'{$context->id}'";
    }
    $contextlist = join($contextlistarr, ' ,');
    if (!empty($pagevars['cat'])) {
        $catparts = explode(',', $pagevars['cat']);
        if (!$catparts[0] || false !== array_search($catparts[1], $contextlistarr) || !$DB->count_records_select("question_categories", "id = ? AND contextid = ?", array($catparts[0], $catparts[1]))) {
            print_error('invalidcategory', 'question');
        }
    } else {
        $category = $defaultcategory;
        $pagevars['cat'] = "{$category->id},{$category->contextid}";
    }
    // Display options.
    $pagevars['recurse'] = question_get_display_preference('recurse', 1, PARAM_BOOL, $thispageurl);
    $pagevars['showhidden'] = question_get_display_preference('showhidden', 0, PARAM_BOOL, $thispageurl);
    $pagevars['qbshowtext'] = question_get_display_preference('qbshowtext', 0, PARAM_BOOL, $thispageurl);
    // Category list page.
    $pagevars['cpage'] = optional_param('cpage', 1, PARAM_INT);
    if ($pagevars['cpage'] != 1) {
        $thispageurl->param('cpage', $pagevars['cpage']);
    }
    return array($thispageurl, $contexts, $cmid, $cm, $module, $pagevars);
}
Пример #15
0
$configstr = get_string('manageyourportfolios', 'portfolio');
$namestr = get_string('name');
$pluginstr = get_string('plugin', 'portfolio');
$baseurl = $CFG->wwwroot . '/user/portfolio.php';
$display = true;
// Set this to false in the conditions to stop processing.
require_login($course, false);
$PAGE->set_url($url);
$PAGE->set_context(context_user::instance($user->id));
$PAGE->set_title("{$course->fullname}: {$fullname}: {$strportfolios}");
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('admin');
echo $OUTPUT->header();
$showroles = 1;
if (!empty($config)) {
    navigation_node::override_active_url(new moodle_url('/user/portfolio.php', array('courseid' => $courseid)));
    $instance = portfolio_instance($config);
    $mform = new portfolio_user_form('', array('instance' => $instance, 'userid' => $user->id));
    if ($mform->is_cancelled()) {
        redirect($baseurl);
        exit;
    } else {
        if ($fromform = $mform->get_data()) {
            if (!confirm_sesskey()) {
                print_error('confirmsesskeybad', '', $baseurl);
            }
            // This branch is where you process validated data.
            $instance->set_user_config($fromform, $USER->id);
            core_plugin_manager::reset_caches();
            redirect($baseurl, get_string('instancesaved', 'portfolio'), 3);
            exit;
Пример #16
0
// preferences.php - user prefs for calendar
require_once '../config.php';
require_once $CFG->dirroot . '/calendar/lib.php';
require_once $CFG->dirroot . '/calendar/preferences_form.php';
$courseid = required_param('course', PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$PAGE->set_url(new moodle_url('/calendar/preferences.php', array('course' => $courseid)));
$PAGE->set_pagelayout('standard');
require_login($course);
if ($courseid == SITEID) {
    $viewurl = new moodle_url('/calendar/view.php', array('view' => 'month'));
} else {
    $viewurl = new moodle_url('/calendar/view.php', array('view' => 'month', 'course' => $courseid));
}
navigation_node::override_active_url($viewurl);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
    $defaultlookahead = intval($CFG->calendar_lookahead);
}
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
    $defaultmaxevents = intval($CFG->calendar_maxevents);
}
$prefs = new stdClass();
$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
$prefs->startwday = calendar_get_starting_weekday();
$prefs->maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$prefs->lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
$form = new calendar_preferences_form($PAGE->url);
Пример #17
0
/**
 * This function checks that the current user is logged in and has the
 * required privileges
 *
 * This function checks that the current user is logged in, and optionally
 * whether they are allowed to be in a particular course and view a particular
 * course module.
 * If they are not logged in, then it redirects them to the site login unless
 * $autologinguest is set and {@link $CFG}->autologinguests is set to 1 in which
 * case they are automatically logged in as guests.
 * If $courseid is given and the user is not enrolled in that course then the
 * user is redirected to the course enrolment page.
 * If $cm is given and the course module is hidden and the user is not a teacher
 * in the course then the user is redirected to the course home page.
 *
 * When $cm parameter specified, this function sets page layout to 'module'.
 * You need to change it manually later if some other layout needed.
 *
 * @package    core_access
 * @category   access
 *
 * @param mixed $courseorid id of the course or course object
 * @param bool $autologinguest default true
 * @param object $cm course module object
 * @param bool $setwantsurltome Define if we want to set $SESSION->wantsurl, defaults to
 *             true. Used to avoid (=false) some scripts (file.php...) to set that variable,
 *             in order to keep redirects working properly. MDL-14495
 * @param bool $preventredirect set to true in scripts that can not redirect (CLI, rss feeds, etc.), throws exceptions
 * @return mixed Void, exit, and die depending on path
 * @throws coding_exception
 * @throws require_login_exception
 */
function require_login($courseorid = null, $autologinguest = true, $cm = null, $setwantsurltome = true, $preventredirect = false)
{
    global $CFG, $SESSION, $USER, $PAGE, $SITE, $DB, $OUTPUT;
    // Must not redirect when byteserving already started.
    if (!empty($_SERVER['HTTP_RANGE'])) {
        $preventredirect = true;
    }
    if (AJAX_SCRIPT) {
        // We cannot redirect for AJAX scripts either.
        $preventredirect = true;
    }
    // Setup global $COURSE, themes, language and locale.
    if (!empty($courseorid)) {
        if (is_object($courseorid)) {
            $course = $courseorid;
        } else {
            if ($courseorid == SITEID) {
                $course = clone $SITE;
            } else {
                $course = $DB->get_record('course', array('id' => $courseorid), '*', MUST_EXIST);
            }
        }
        if ($cm) {
            if ($cm->course != $course->id) {
                throw new coding_exception('course and cm parameters in require_login() call do not match!!');
            }
            // Make sure we have a $cm from get_fast_modinfo as this contains activity access details.
            if (!$cm instanceof cm_info) {
                // Note: nearly all pages call get_fast_modinfo anyway and it does not make any
                // db queries so this is not really a performance concern, however it is obviously
                // better if you use get_fast_modinfo to get the cm before calling this.
                $modinfo = get_fast_modinfo($course);
                $cm = $modinfo->get_cm($cm->id);
            }
        }
    } else {
        // Do not touch global $COURSE via $PAGE->set_course(),
        // the reasons is we need to be able to call require_login() at any time!!
        $course = $SITE;
        if ($cm) {
            throw new coding_exception('cm parameter in require_login() requires valid course parameter!');
        }
    }
    // If this is an AJAX request and $setwantsurltome is true then we need to override it and set it to false.
    // Otherwise the AJAX request URL will be set to $SESSION->wantsurl and events such as self enrolment in the future
    // risk leading the user back to the AJAX request URL.
    if ($setwantsurltome && defined('AJAX_SCRIPT') && AJAX_SCRIPT) {
        $setwantsurltome = false;
    }
    // Redirect to the login page if session has expired, only with dbsessions enabled (MDL-35029) to maintain current behaviour.
    if ((!isloggedin() or isguestuser()) && !empty($SESSION->has_timed_out) && !empty($CFG->dbsessions)) {
        if ($preventredirect) {
            throw new require_login_session_timeout_exception();
        } else {
            if ($setwantsurltome) {
                $SESSION->wantsurl = qualified_me();
            }
            redirect(get_login_url());
        }
    }
    // If the user is not even logged in yet then make sure they are.
    if (!isloggedin()) {
        if ($autologinguest and !empty($CFG->guestloginbutton) and !empty($CFG->autologinguests)) {
            if (!($guest = get_complete_user_data('id', $CFG->siteguest))) {
                // Misconfigured site guest, just redirect to login page.
                redirect(get_login_url());
                exit;
                // Never reached.
            }
            $lang = isset($SESSION->lang) ? $SESSION->lang : $CFG->lang;
            complete_user_login($guest);
            $USER->autologinguest = true;
            $SESSION->lang = $lang;
        } else {
            // NOTE: $USER->site check was obsoleted by session test cookie, $USER->confirmed test is in login/index.php.
            if ($preventredirect) {
                throw new require_login_exception('You are not logged in');
            }
            if ($setwantsurltome) {
                $SESSION->wantsurl = qualified_me();
            }
            $referer = get_local_referer(false);
            if (!empty($referer)) {
                $SESSION->fromurl = $referer;
            }
            // Give auth plugins an opportunity to authenticate or redirect to an external login page
            $authsequence = get_enabled_auth_plugins(true);
            // auths, in sequence
            foreach ($authsequence as $authname) {
                $authplugin = get_auth_plugin($authname);
                $authplugin->pre_loginpage_hook();
                if (isloggedin()) {
                    break;
                }
            }
            // If we're still not logged in then go to the login page
            if (!isloggedin()) {
                redirect(get_login_url());
                exit;
                // Never reached.
            }
        }
    }
    // Loginas as redirection if needed.
    if ($course->id != SITEID and \core\session\manager::is_loggedinas()) {
        if ($USER->loginascontext->contextlevel == CONTEXT_COURSE) {
            if ($USER->loginascontext->instanceid != $course->id) {
                print_error('loginasonecourse', '', $CFG->wwwroot . '/course/view.php?id=' . $USER->loginascontext->instanceid);
            }
        }
    }
    // Check whether the user should be changing password (but only if it is REALLY them).
    if (get_user_preferences('auth_forcepasswordchange') && !\core\session\manager::is_loggedinas()) {
        $userauth = get_auth_plugin($USER->auth);
        if ($userauth->can_change_password() and !$preventredirect) {
            if ($setwantsurltome) {
                $SESSION->wantsurl = qualified_me();
            }
            if ($changeurl = $userauth->change_password_url()) {
                // Use plugin custom url.
                redirect($changeurl);
            } else {
                // Use moodle internal method.
                if (empty($CFG->loginhttps)) {
                    redirect($CFG->wwwroot . '/login/change_password.php');
                } else {
                    $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
                    redirect($wwwroot . '/login/change_password.php');
                }
            }
        } else {
            if ($userauth->can_change_password()) {
                throw new moodle_exception('forcepasswordchangenotice');
            } else {
                throw new moodle_exception('nopasswordchangeforced', 'auth');
            }
        }
    }
    // Check that the user account is properly set up. If we can't redirect to
    // edit their profile, perform just the lax check. It will allow them to
    // use filepicker on the profile edit page.
    if ($preventredirect) {
        $usernotfullysetup = user_not_fully_set_up($USER, false);
    } else {
        $usernotfullysetup = user_not_fully_set_up($USER, true);
    }
    if ($usernotfullysetup) {
        if ($preventredirect) {
            throw new moodle_exception('usernotfullysetup');
        }
        if ($setwantsurltome) {
            $SESSION->wantsurl = qualified_me();
        }
        redirect($CFG->wwwroot . '/user/edit.php?id=' . $USER->id . '&amp;course=' . SITEID);
    }
    // Make sure the USER has a sesskey set up. Used for CSRF protection.
    sesskey();
    // Do not bother admins with any formalities.
    if (is_siteadmin()) {
        // Set the global $COURSE.
        if ($cm) {
            $PAGE->set_cm($cm, $course);
            $PAGE->set_pagelayout('incourse');
        } else {
            if (!empty($courseorid)) {
                $PAGE->set_course($course);
            }
        }
        // Set accesstime or the user will appear offline which messes up messaging.
        user_accesstime_log($course->id);
        return;
    }
    // Check that the user has agreed to a site policy if there is one - do not test in case of admins.
    if (!$USER->policyagreed and !is_siteadmin()) {
        if (!empty($CFG->sitepolicy) and !isguestuser()) {
            if ($preventredirect) {
                throw new moodle_exception('sitepolicynotagreed', 'error', '', $CFG->sitepolicy);
            }
            if ($setwantsurltome) {
                $SESSION->wantsurl = qualified_me();
            }
            redirect($CFG->wwwroot . '/user/policy.php');
        } else {
            if (!empty($CFG->sitepolicyguest) and isguestuser()) {
                if ($preventredirect) {
                    throw new moodle_exception('sitepolicynotagreed', 'error', '', $CFG->sitepolicyguest);
                }
                if ($setwantsurltome) {
                    $SESSION->wantsurl = qualified_me();
                }
                redirect($CFG->wwwroot . '/user/policy.php');
            }
        }
    }
    // Fetch the system context, the course context, and prefetch its child contexts.
    $sysctx = context_system::instance();
    $coursecontext = context_course::instance($course->id, MUST_EXIST);
    if ($cm) {
        $cmcontext = context_module::instance($cm->id, MUST_EXIST);
    } else {
        $cmcontext = null;
    }
    // If the site is currently under maintenance, then print a message.
    if (!empty($CFG->maintenance_enabled) and !has_capability('moodle/site:maintenanceaccess', $sysctx)) {
        if ($preventredirect) {
            throw new require_login_exception('Maintenance in progress');
        }
        $PAGE->set_context(null);
        print_maintenance_message();
    }
    // Make sure the course itself is not hidden.
    if ($course->id == SITEID) {
        // Frontpage can not be hidden.
    } else {
        if (is_role_switched($course->id)) {
            // When switching roles ignore the hidden flag - user had to be in course to do the switch.
        } else {
            if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
                // Originally there was also test of parent category visibility, BUT is was very slow in complex queries
                // involving "my courses" now it is also possible to simply hide all courses user is not enrolled in :-).
                if ($preventredirect) {
                    throw new require_login_exception('Course is hidden');
                }
                $PAGE->set_context(null);
                // We need to override the navigation URL as the course won't have been added to the navigation and thus
                // the navigation will mess up when trying to find it.
                navigation_node::override_active_url(new moodle_url('/'));
                notice(get_string('coursehidden'), $CFG->wwwroot . '/');
            }
        }
    }
    // Is the user enrolled?
    if ($course->id == SITEID) {
        // Everybody is enrolled on the frontpage.
    } else {
        if (\core\session\manager::is_loggedinas()) {
            // Make sure the REAL person can access this course first.
            $realuser = \core\session\manager::get_realuser();
            if (!is_enrolled($coursecontext, $realuser->id, '', true) and !is_viewing($coursecontext, $realuser->id) and !is_siteadmin($realuser->id)) {
                if ($preventredirect) {
                    throw new require_login_exception('Invalid course login-as access');
                }
                $PAGE->set_context(null);
                echo $OUTPUT->header();
                notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot . '/');
            }
        }
        $access = false;
        if (is_role_switched($course->id)) {
            // Ok, user had to be inside this course before the switch.
            $access = true;
        } else {
            if (is_viewing($coursecontext, $USER)) {
                // Ok, no need to mess with enrol.
                $access = true;
            } else {
                if (isset($USER->enrol['enrolled'][$course->id])) {
                    if ($USER->enrol['enrolled'][$course->id] > time()) {
                        $access = true;
                        if (isset($USER->enrol['tempguest'][$course->id])) {
                            unset($USER->enrol['tempguest'][$course->id]);
                            remove_temp_course_roles($coursecontext);
                        }
                    } else {
                        // Expired.
                        unset($USER->enrol['enrolled'][$course->id]);
                    }
                }
                if (isset($USER->enrol['tempguest'][$course->id])) {
                    if ($USER->enrol['tempguest'][$course->id] == 0) {
                        $access = true;
                    } else {
                        if ($USER->enrol['tempguest'][$course->id] > time()) {
                            $access = true;
                        } else {
                            // Expired.
                            unset($USER->enrol['tempguest'][$course->id]);
                            remove_temp_course_roles($coursecontext);
                        }
                    }
                }
                if (!$access) {
                    // Cache not ok.
                    $until = enrol_get_enrolment_end($coursecontext->instanceid, $USER->id);
                    if ($until !== false) {
                        // Active participants may always access, a timestamp in the future, 0 (always) or false.
                        if ($until == 0) {
                            $until = ENROL_MAX_TIMESTAMP;
                        }
                        $USER->enrol['enrolled'][$course->id] = $until;
                        $access = true;
                    } else {
                        $params = array('courseid' => $course->id, 'status' => ENROL_INSTANCE_ENABLED);
                        $instances = $DB->get_records('enrol', $params, 'sortorder, id ASC');
                        $enrols = enrol_get_plugins(true);
                        // First ask all enabled enrol instances in course if they want to auto enrol user.
                        foreach ($instances as $instance) {
                            if (!isset($enrols[$instance->enrol])) {
                                continue;
                            }
                            // Get a duration for the enrolment, a timestamp in the future, 0 (always) or false.
                            $until = $enrols[$instance->enrol]->try_autoenrol($instance);
                            if ($until !== false) {
                                if ($until == 0) {
                                    $until = ENROL_MAX_TIMESTAMP;
                                }
                                $USER->enrol['enrolled'][$course->id] = $until;
                                $access = true;
                                break;
                            }
                        }
                        // If not enrolled yet try to gain temporary guest access.
                        if (!$access) {
                            foreach ($instances as $instance) {
                                if (!isset($enrols[$instance->enrol])) {
                                    continue;
                                }
                                // Get a duration for the guest access, a timestamp in the future or false.
                                $until = $enrols[$instance->enrol]->try_guestaccess($instance);
                                if ($until !== false and $until > time()) {
                                    $USER->enrol['tempguest'][$course->id] = $until;
                                    $access = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!$access) {
            if ($preventredirect) {
                throw new require_login_exception('Not enrolled');
            }
            if ($setwantsurltome) {
                $SESSION->wantsurl = qualified_me();
            }
            redirect($CFG->wwwroot . '/enrol/index.php?id=' . $course->id);
        }
    }
    // Check visibility of activity to current user; includes visible flag, conditional availability, etc.
    if ($cm && !$cm->uservisible) {
        if ($preventredirect) {
            throw new require_login_exception('Activity is hidden');
        }
        if ($course->id != SITEID) {
            $url = new moodle_url('/course/view.php', array('id' => $course->id));
        } else {
            $url = new moodle_url('/');
        }
        redirect($url, get_string('activityiscurrentlyhidden'));
    }
    // Set the global $COURSE.
    if ($cm) {
        $PAGE->set_cm($cm, $course);
        $PAGE->set_pagelayout('incourse');
    } else {
        if (!empty($courseorid)) {
            $PAGE->set_course($course);
        }
    }
    // Finally access granted, update lastaccess times.
    user_accesstime_log($course->id);
}
Пример #18
0
// Filters list actions.
$urlparams->default = optional_param('default', 0, PARAM_INT);
// id of filter to default
$urlparams->showhide = optional_param('showhide', 0, PARAM_SEQUENCE);
// filter ids (comma delimited) to hide/show
$urlparams->delete = optional_param('delete', 0, PARAM_SEQUENCE);
// filter ids (comma delim) to delete
$urlparams->duplicate = optional_param('duplicate', 0, PARAM_SEQUENCE);
// filter ids (comma delim) to duplicate
$urlparams->confirmed = optional_param('confirmed', 0, PARAM_INT);
// Set a dataform object.
$df = mod_dataform_dataform::instance($urlparams->d, $urlparams->id);
$df->require_manage_permission('filters');
$df->set_page('filter/index', array('urlparams' => $urlparams));
// Activate navigation node.
navigation_node::override_active_url(new moodle_url('/mod/dataform/filter/index.php', array('id' => $df->cm->id)));
$fm = mod_dataform_filter_manager::instance($df->id);
// DATA PROCESSING.
if ($urlparams->duplicate and confirm_sesskey()) {
    // Duplicate any requested filters.
    $fm->process_filters('duplicate', $urlparams->duplicate, $urlparams->confirmed);
} else {
    if ($urlparams->delete and confirm_sesskey()) {
        // Delete any requested filters.
        $fm->process_filters('delete', $urlparams->delete, $urlparams->confirmed);
    } else {
        if ($urlparams->showhide and confirm_sesskey()) {
            // Set filter's visibility (confirmed by default).
            $fm->process_filters('visible', $urlparams->showhide, true);
        } else {
            if ($urlparams->default and confirm_sesskey()) {
Пример #19
0
}
if ($day !== 0) {
    $url->param('cal_d', $day);
}
if ($mon !== 0) {
    $url->param('cal_m', $mon);
}
if ($yr !== 0) {
    $url->param('cal_y', $yr);
}
$PAGE->set_url($url);
if ($courseid != SITEID && !empty($courseid)) {
    $course = $DB->get_record('course', array('id' => $courseid));
    $courses = array($course->id => $course);
    $issite = false;
    navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
} else {
    $course = get_site();
    $courses = calendar_get_default_courses();
    $issite = true;
}
require_course_login($course);
$calendar = new calendar_information($day, $mon, $yr);
$calendar->prepare_for_view($course, $courses);
$now = usergetdate(time());
$pagetitle = '';
$strcalendar = get_string('calendar', 'calendar');
if (!checkdate($mon, $day, $yr)) {
    $day = intval($now['mday']);
    $mon = intval($now['mon']);
    $yr = intval($now['year']);
Пример #20
0
$action = optional_param('action', '', PARAM_ACTION);
$filter = optional_param('ifilter', 0, PARAM_INT);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
if ($course->id == SITEID) {
    redirect(new moodle_url('/'));
}
require_login($course);
require_capability('moodle/course:enrolreview', $context);
$PAGE->set_pagelayout('admin');
$manager = new course_enrolment_manager($PAGE, $course, $filter);
$table = new course_enrolment_users_table($manager, $PAGE);
$returnurl = new moodle_url('/enrol/users.php', $table->get_combined_url_params());
$actionurl = new moodle_url('/enrol/bulkchange.php', $table->get_combined_url_params() + array('bulkuserop' => $bulkuserop));
$PAGE->set_url($actionurl);
navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('id' => $id)));
$ops = $table->get_bulk_user_enrolment_operations();
if (!array_key_exists($bulkuserop, $ops)) {
    throw new moodle_exception('invalidbulkenrolop');
}
$operation = $ops[$bulkuserop];
// Prepare the properties of the form
$users = $manager->get_users_enrolments($userids);
// Get the form for the bulk operation
$mform = $operation->get_form($actionurl, array('users' => $users));
// If the mform is false then attempt an immediate process. This may be an immediate action that
// doesn't require user input OR confirmation.... who know what but maybe one day
if ($mform === false) {
    if ($operation->process($manager, $users, new stdClass())) {
        redirect($returnurl);
    } else {
Пример #21
0
if ($appendqnumstring !== '') {
    $url->param('appendqnumstring', $appendqnumstring);
}
if ($inpopup !== 0) {
    $url->param('inpopup', $inpopup);
}
if ($scrollpos) {
    $url->param('scrollpos', $scrollpos);
}
$PAGE->set_url($url);
if ($cmid) {
    $questionbankurl = new moodle_url('/question/edit.php', array('cmid' => $cmid));
} else {
    $questionbankurl = new moodle_url('/question/edit.php', array('courseid' => $courseid));
}
navigation_node::override_active_url($questionbankurl);
if ($originalreturnurl) {
    if (strpos($originalreturnurl, '/') !== 0) {
        throw new coding_exception("returnurl must be a local URL starting with '/'. {$originalreturnurl} was given.");
    }
    $returnurl = new moodle_url($originalreturnurl);
} else {
    $returnurl = $questionbankurl;
}
if ($scrollpos) {
    $returnurl->param('scrollpos', $scrollpos);
}
if ($movecontext && !$id) {
    print_error('questiondoesnotexist', 'question', $returnurl);
}
if ($cmid) {
 * @package    report
 * @subpackage customlang
 * @copyright  2010 David Mudrak <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/report/customlang/locallib.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/report/customlang/filter_form.php';
require_login(SITEID, false);
require_capability('report/customlang:edit', get_system_context());
$lng = required_param('lng', PARAM_LANG);
$currentpage = optional_param('p', 0, PARAM_INT);
$translatorsubmitted = optional_param('translatorsubmitted', 0, PARAM_BOOL);
$PAGE->set_pagelayout('standard');
$PAGE->set_url('/admin/report/customlang/edit.php', array('lng' => $lng));
navigation_node::override_active_url(new moodle_url('/admin/report/customlang/index.php'));
$PAGE->set_title(get_string('pluginname', 'report_customlang'));
$PAGE->set_heading(get_string('pluginname', 'report_customlang'));
$PAGE->requires->js_init_call('M.report_customlang.init_editor', array(), true);
if (empty($lng)) {
    // PARAM_LANG validation failed
    print_error('missingparameter');
}
// pre-output processing
$filter = new report_customlang_filter_form($PAGE->url, null, 'post', '', array('class' => 'filterform'));
$filterdata = report_customlang_utils::load_filter($USER);
$filter->set_data($filterdata);
if ($filter->is_cancelled()) {
    redirect($PAGE->url);
} elseif ($submitted = $filter->get_data()) {
    report_customlang_utils::save_filter($submitted, $USER);
Пример #23
0
 * @package core_group
 */
require_once '../config.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/group/lib.php';
include_once 'import_form.php';
$id = required_param('id', PARAM_INT);
// Course id
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$PAGE->set_url('/group/import.php', array('id' => $id));
require_login($course);
$context = context_course::instance($id);
require_capability('moodle/course:managegroups', $context);
$strimportgroups = get_string('importgroups', 'core_group');
$PAGE->navbar->add($strimportgroups);
navigation_node::override_active_url(new moodle_url('/group/index.php', array('id' => $course->id)));
$PAGE->set_title("{$course->shortname}: {$strimportgroups}");
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('admin');
$returnurl = new moodle_url('/group/index.php', array('id' => $id));
$mform_post = new groups_import_form(null, array('id' => $id));
// If a file has been uploaded, then process it
if ($mform_post->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($mform_post->get_data()) {
        echo $OUTPUT->header();
        $csv_encode = '/\\&\\#44/';
        if (isset($CFG->CSV_DELIMITER)) {
            $csv_delimiter = $CFG->CSV_DELIMITER;
            if (isset($CFG->CSV_ENCODE)) {
$context = $badge->get_context();
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
// Make sure that no actions available for locked or active badges.
if ($badge->is_active() || $badge->is_locked()) {
    redirect($return);
}
if ($badge->type == BADGE_TYPE_COURSE) {
    require_login($badge->courseid);
    $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
}
$PAGE->set_context($context);
$PAGE->set_url('/badges/criteria_action.php');
$PAGE->set_pagelayout('standard');
$PAGE->set_heading($badge->name);
$PAGE->set_title($badge->name);
navigation_node::override_active_url($navurl);
if ($delete && has_capability('moodle/badges:configurecriteria', $context)) {
    if (!$confirm) {
        $optionsyes = array('confirm' => 1, 'sesskey' => sesskey(), 'badgeid' => $badgeid, 'delete' => true, 'type' => $type);
        $strdeletecheckfull = get_string('delcritconfirm', 'badges');
        echo $OUTPUT->header();
        $formcontinue = new single_button(new moodle_url('/badges/criteria_action.php', $optionsyes), get_string('yes'));
        $formcancel = new single_button($return, get_string('no'), 'get');
        echo $OUTPUT->confirm($strdeletecheckfull, $formcontinue, $formcancel);
        echo $OUTPUT->footer();
        die;
    }
    require_sesskey();
    if (count($badge->criteria) == 2) {
        // Remove overall criterion as well.
        $badge->criteria[$type]->delete();
Пример #25
0
$moveto = optional_param('moveto', 0, PARAM_INT);
$resort = optional_param('resort', 0, PARAM_BOOL);
$site = get_site();
if (empty($id)) {
    print_error("unknowcategory");
}
$PAGE->set_category_by_id($id);
$urlparams = array('id' => $id);
if ($page) {
    $urlparams['page'] = $page;
}
if ($perpage) {
    $urlparams['perpage'] = $perpage;
}
$PAGE->set_url(new moodle_url('/course/category.php', array('id' => $id)));
navigation_node::override_active_url($PAGE->url);
$context = $PAGE->context;
$category = $PAGE->category;
$canedit = can_edit_in_category($category->id);
if ($canedit) {
    if ($categoryedit !== -1) {
        $USER->editing = $categoryedit;
    }
    require_login();
    $editingon = $PAGE->user_is_editing();
} else {
    if ($CFG->forcelogin) {
        require_login();
    }
    $editingon = false;
}
Пример #26
0
<?php

//This script is used to configure and execute the restore proccess.
require_once '../config.php';
require_once $CFG->dirroot . '/backup/util/includes/restore_includes.php';
$contextid = required_param('contextid', PARAM_INT);
$stage = optional_param('stage', restore_ui::STAGE_CONFIRM, PARAM_INT);
list($context, $course, $cm) = get_context_info_array($contextid);
navigation_node::override_active_url(new moodle_url('/backup/restorefile.php', array('contextid' => $contextid)));
$PAGE->set_url(new moodle_url('/backup/restore.php', array('contextid' => $contextid)));
$PAGE->set_context($context);
$PAGE->set_pagelayout('standard');
require_login($course, null, $cm);
require_capability('moodle/restore:restorecourse', $context);
if ($stage & restore_ui::STAGE_CONFIRM + restore_ui::STAGE_DESTINATION) {
    $restore = restore_ui::engage_independent_stage($stage, $contextid);
} else {
    $restoreid = optional_param('restore', false, PARAM_ALPHANUM);
    $rc = restore_ui::load_controller($restoreid);
    if (!$rc) {
        $restore = restore_ui::engage_independent_stage($stage / 2, $contextid);
        if ($restore->process()) {
            $rc = new restore_controller($restore->get_filepath(), $restore->get_course_id(), backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id, $restore->get_target());
        }
    }
    if ($rc) {
        // check if the format conversion must happen first
        if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
            $rc->convert();
        }
        $restore = new restore_ui($rc, array('contextid' => $context->id));
Пример #27
0
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../../config.php';
require_once $CFG->dirroot . '/grade/lib.php';
require_once $CFG->dirroot . '/grade/report/lib.php';
require_once 'category_form.php';
$courseid = required_param('courseid', PARAM_INT);
$id = optional_param('id', 0, PARAM_INT);
// grade_category->id
$url = new moodle_url('/grade/edit/tree/category.php', array('courseid' => $courseid));
if ($id !== 0) {
    $url->param('id', $id);
}
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url(new moodle_url('/grade/edit/tree/index.php', array('id' => $courseid)));
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
    print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($course->id);
require_capability('moodle/grade:manage', $context);
// default return url
$gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url('index.php?id=' . $course->id);
$heading = get_string('categoryedit', 'grades');
if ($id) {
    if (!($grade_category = grade_category::fetch(array('id' => $id, 'courseid' => $course->id)))) {
        print_error('invalidcategory');
    }
    $grade_category->apply_forced_settings();
Пример #28
0
    throw new moodle_exception('invaliddata', 'error');
}
require_login($course);
require_capability('enrol/' . $type . ':config', $context);
$PAGE->set_url('/enrol/editinstance.php', array('courseid' => $course->id, 'id' => $instanceid, 'type' => $type));
$PAGE->set_pagelayout('admin');
$return = new moodle_url('/enrol/instances.php', array('id' => $course->id));
if (!enrol_is_enabled($type)) {
    redirect($return);
}
if ($instanceid) {
    $instance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => $type, 'id' => $instanceid), '*', MUST_EXIST);
} else {
    require_capability('moodle/course:enrolconfig', $context);
    // No instance yet, we have to add new instance.
    navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id' => $course->id)));
    $instance = (object) $plugin->get_instance_defaults();
    $instance->id = null;
    $instance->courseid = $course->id;
    $instance->status = ENROL_INSTANCE_ENABLED;
    // Do not use default for automatically created instances here.
}
$mform = new enrol_instance_edit_form(null, array($instance, $plugin, $context, $type));
if ($mform->is_cancelled()) {
    redirect($return);
} else {
    if ($data = $mform->get_data()) {
        if ($instance->id) {
            $reset = false;
            if (isset($data->status)) {
                $reset = $instance->status != $data->status;
Пример #29
0
require_once '../config.php';
require_once $CFG->libdir . '/bennu/bennu.inc.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/calendar/lib.php';
require_once $CFG->dirroot . '/calendar/managesubscriptions_form.php';
// Required use.
$courseid = optional_param('course', SITEID, PARAM_INT);
// Used for processing subscription actions.
$subscriptionid = optional_param('id', 0, PARAM_INT);
$pollinterval = optional_param('pollinterval', 0, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
$url = new moodle_url('/calendar/managesubscriptions.php');
if ($courseid != SITEID) {
    $url->param('course', $courseid);
}
navigation_node::override_active_url(new moodle_url('/calendar/view.php', array('view' => 'month')));
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'));
if ($courseid != SITEID && !empty($courseid)) {
    $course = $DB->get_record('course', array('id' => $courseid));
    $courses = array($course->id => $course);
} else {
    $course = get_site();
    $courses = calendar_get_default_courses();
}
require_course_login($course);
if (!calendar_user_can_add_event($course)) {
    print_error('errorcannotimport', 'calendar');
}
$form = new calendar_addsubscription_form(null);
Пример #30
0
require_once dirname(__FILE__) . '/locallib.php';
require_once dirname(__FILE__) . '/mlanglib.php';
require_once dirname(__FILE__) . '/stash_form.php';
$name = optional_param('name', null, PARAM_RAW);
// stash name
$new = optional_param('new', null, PARAM_BOOL);
// new stash requested
$apply = optional_param('apply', null, PARAM_INT);
$pop = optional_param('pop', null, PARAM_INT);
$drop = optional_param('drop', null, PARAM_INT);
$submit = optional_param('submit', null, PARAM_INT);
require_login(SITEID, false);
require_capability('local/amos:stash', get_system_context());
$PAGE->set_pagelayout('standard');
$PAGE->set_url('/local/amos/stash.php');
navigation_node::override_active_url(new moodle_url('/local/amos/stash.php'));
$PAGE->set_title('AMOS ' . get_string('stashes', 'local_amos'));
$PAGE->set_heading('AMOS ' . get_string('stashes', 'local_amos'));
$PAGE->requires->yui_module('moodle-local_amos-stash', 'M.local_amos.init_stash');
$PAGE->requires->strings_for_js(array('confirmaction'), 'local_amos');
if ($new) {
    // pushing the current stage into a new stash
    require_sesskey();
    $stage = mlang_persistent_stage::instance_for_user($USER->id, sesskey());
    $stash = mlang_stash::instance_from_stage($stage, $stage->userid, $name);
    $stash->push();
    redirect($PAGE->url);
}
if ($apply) {
    require_sesskey();
    require_capability('local/amos:stage', get_system_context());