Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/moodle/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	files/externallib.php
  • Loading branch information
pcharsle committed Sep 3, 2012
2 parents 4873a89 + 569f1ad commit 5e21657
Show file tree
Hide file tree
Showing 221 changed files with 7,509 additions and 2,420 deletions.
51 changes: 44 additions & 7 deletions admin/enrol.php
Expand Up @@ -23,12 +23,15 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('NO_OUTPUT_BUFFERING', true);

require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');

$action = required_param('action', PARAM_ALPHANUMEXT);
$enrol = required_param('enrol', PARAM_PLUGIN);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$migrate = optional_param('migrate', 0, PARAM_BOOL);

$PAGE->set_url('/admin/enrol.php');
$PAGE->set_context(context_system::instance());
Expand Down Expand Up @@ -94,24 +97,58 @@
break;

case 'uninstall':
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));

if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
$strplugin = get_string('pluginname', 'enrol_'.$enrol);
} else {
$strplugin = $enrol;
}

echo $PAGE->set_title($strplugin);
echo $OUTPUT->header();

if (!$confirm) {
$uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1));
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return);
echo $OUTPUT->heading(get_string('enrolments', 'enrol'));

$deleteurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>0));
$migrateurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>1));

$migrate = new single_button($migrateurl, get_string('uninstallmigrate', 'enrol'));
$delete = new single_button($deleteurl, get_string('uninstalldelete', 'enrol'));
$cancel = new single_button($return, get_string('cancel'), 'get');

$buttons = $OUTPUT->render($delete) . $OUTPUT->render($cancel);
if ($enrol !== 'manual') {
$buttons = $OUTPUT->render($migrate) . $buttons;
}

echo $OUTPUT->box_start('generalbox', 'notice');
echo html_writer::tag('p', markdown_to_html(get_string('uninstallconfirm', 'enrol', $strplugin)));
echo html_writer::tag('div', $buttons, array('class' => 'buttons'));
echo $OUTPUT->box_end();

echo $OUTPUT->footer();
exit;

} else { // Delete everything!!
} else {
// This may take a long time.
set_time_limit(0);

// Disable plugin to prevent concurrent cron execution.
unset($enabled[$enrol]);
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));

if ($migrate) {
echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol));

require_once("$CFG->dirroot/enrol/manual/locallib.php");
enrol_manual_migrate_plugin_enrolments($enrol);

echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
}

// Delete everything!!
uninstall_plugin('enrol', $enrol);
$syscontext->mark_dirty(); // resets all enrol caches
$syscontext->mark_dirty(); // Resets all enrol caches.

$a = new stdClass();
$a->plugin = $strplugin;
Expand Down
8 changes: 4 additions & 4 deletions admin/roles/lib.php
Expand Up @@ -933,7 +933,7 @@ protected function load_parent_permissions() {
global $DB;

/// Get the capabilities from the parent context, so that can be shown in the interface.
$parentcontext = get_context_instance_by_id(get_parent_contextid($this->context));
$parentcontext = context::instance_by_id(get_parent_contextid($this->context));
$this->parentpermissions = role_context_capabilities($this->roleid, $parentcontext);
}

Expand Down Expand Up @@ -996,7 +996,7 @@ public function __construct($name, $options) {
if (isset($options['context'])) {
$this->context = $options['context'];
} else {
$this->context = get_context_instance_by_id($options['contextid']);
$this->context = context::instance_by_id($options['contextid']);
}
$options['accesscontext'] = $this->context;
parent::__construct($name, $options);
Expand Down Expand Up @@ -1230,7 +1230,7 @@ protected function this_con_group_name($search, $numusers) {
}

protected function parent_con_group_name($search, $contextid) {
$context = get_context_instance_by_id($contextid);
$context = context::instance_by_id($contextid);
$contextname = print_context_name($context, true, true);
if ($search) {
$a = new stdClass;
Expand Down Expand Up @@ -1477,7 +1477,7 @@ public function get_intro_text() {
function roles_get_potential_user_selector($context, $name, $options) {
$blockinsidecourse = false;
if ($context->contextlevel == CONTEXT_BLOCK) {
$parentcontext = get_context_instance_by_id(get_parent_contextid($context));
$parentcontext = context::instance_by_id(get_parent_contextid($context));
$blockinsidecourse = in_array($parentcontext->contextlevel, array(CONTEXT_MODULE, CONTEXT_COURSE));
}

Expand Down
Expand Up @@ -36,6 +36,7 @@
$string['conversionfailed'] = 'The assignment conversion was not successful. The log from the upgrade was: <br />{$a}';
$string['listnotupgraded'] = 'List assignments that have not been upgraded';
$string['listnotupgraded_desc'] = 'You can upgrade individual assignments from here';
$string['noassignmentsselected'] = 'No assignments selected';
$string['noassignmentstoupgrade'] = 'There are no assignments that require upgrading';
$string['notsupported'] = '';
$string['notupgradedintro'] = 'This page lists the assignments created with an older version of Moodle that have not been upgraded to the new assignment module in Moodle 2.3. Not all assignments can be upgraded - if they were created with a custom assignment subtype, then that subtype will need to be upgraded to the new assignment plugin format in order to complete the upgrade.';
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/assignmentupgrade/module.js
Expand Up @@ -42,8 +42,8 @@ M.tool_assignmentupgrade = {
}
});

var batchform = Y.one('.tool_assignmentupgrade_batchform form');
batchform.on('submit', function(e) {
var upgradeselectedbutton = Y.one('#id_upgradeselected');
upgradeselectedbutton.on('click', function(e) {
checkboxes = Y.all('td.c0 input');
var selectedassignments = [];
checkboxes.each(function(node) {
Expand All @@ -56,7 +56,7 @@ M.tool_assignmentupgrade = {
assignmentsinput = Y.one('input.selectedassignments');
assignmentsinput.set('value', selectedassignments.join(','));
if (selectedassignments.length == 0) {
alert(M.str.assign.noassignmentsselected);
alert(M.str.tool_assignmentupgrade.noassignmentsselected);
e.preventDefault();
}
});
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/assignmentupgrade/renderer.php
Expand Up @@ -119,7 +119,7 @@ public function assignment_list_page(tool_assignmentupgrade_assignments_table $a
$output = '';
$output .= $this->header();
$this->page->requires->js_init_call('M.tool_assignmentupgrade.init_upgrade_table', array());

$this->page->requires->string_for_js('noassignmentsselected', 'tool_assignmentupgrade');

$output .= $this->heading(get_string('notupgradedtitle', 'tool_assignmentupgrade'));
$output .= $this->box(get_string('notupgradedintro', 'tool_assignmentupgrade'));
Expand Down
2 changes: 1 addition & 1 deletion admin/user/user_bulk_cohortadd.php
Expand Up @@ -45,7 +45,7 @@
// external cohorts can not be modified
continue;
}
$context = get_context_instance_by_id($c->contextid);
$context = context::instance_by_id($c->contextid);
if (!has_capability('moodle/cohort:assign', $context)) {
continue;
}
Expand Down
11 changes: 7 additions & 4 deletions backup/moodle2/backup_stepslib.php
Expand Up @@ -522,9 +522,12 @@ protected function define_structure() {
$enrol = new backup_nested_element('enrol', array('id'), array(
'enrol', 'status', 'sortorder', 'name', 'enrolperiod', 'enrolstartdate',
'enrolenddate', 'expirynotify', 'expirytreshold', 'notifyall',
'password', 'cost', 'currency', 'roleid', 'customint1', 'customint2', 'customint3',
'customint4', 'customchar1', 'customchar2', 'customdec1', 'customdec2',
'customtext1', 'customtext2', 'timecreated', 'timemodified'));
'password', 'cost', 'currency', 'roleid',
'customint1', 'customint2', 'customint3', 'customint4', 'customint5', 'customint6', 'customint7', 'customint8',
'customchar1', 'customchar2', 'customchar3',
'customdec1', 'customdec2',
'customtext1', 'customtext2', 'customtext3', 'customtext4',
'timecreated', 'timemodified'));

$userenrolments = new backup_nested_element('user_enrolments');

Expand Down Expand Up @@ -1002,7 +1005,7 @@ protected function define_structure() {
$members = new backup_nested_element('group_members');

$member = new backup_nested_element('group_member', array('id'), array(
'userid', 'timeadded'));
'userid', 'timeadded', 'component', 'itemid'));

$groupings = new backup_nested_element('groupings');

Expand Down
32 changes: 27 additions & 5 deletions backup/moodle2/restore_stepslib.php
Expand Up @@ -270,7 +270,14 @@ protected function process_grade_letter($data) {

$data->contextid = context_course::instance($this->get_courseid())->id;

$newitemid = $DB->insert_record('grade_letters', $data);
$gradeletter = (array)$data;
unset($gradeletter['id']);
if (!$DB->record_exists('grade_letters', $gradeletter)) {
$newitemid = $DB->insert_record('grade_letters', $data);
} else {
$newitemid = $data->id;
}

$this->set_mapping('grade_letter', $oldid, $newitemid);
}
protected function process_grade_setting($data) {
Expand Down Expand Up @@ -773,6 +780,17 @@ public function process_member($data) {
// map user newitemid and insert if not member already
if ($data->userid = $this->get_mappingid('user', $data->userid)) {
if (!$DB->record_exists('groups_members', array('groupid' => $data->groupid, 'userid' => $data->userid))) {
// Check the componment, if any, exists
if (!empty($data->component)) {
$dir = get_component_directory($data->component);
if (!$dir || !is_dir($dir)) {
// Component does not exist on restored system; clear
// component and itemid
unset($data->component);
unset($data->itemid);
}
}

$DB->insert_record('groups_members', $data);
}
}
Expand Down Expand Up @@ -2399,17 +2417,21 @@ protected function process_grade_grade($data) {

/**
* process activity grade_letters. Note that, while these are possible,
* because grade_letters are contextid based, in proctice, only course
* because grade_letters are contextid based, in practice, only course
* context letters can be defined. So we keep here this method knowing
* it won't be executed ever. gradebook restore will restore course letters.
*/
protected function process_grade_letter($data) {
global $DB;

$data = (object)$data;
$data['contextid'] = $this->task->get_contextid();
$gradeletter = (object)$data;

$data->contextid = $this->task->get_contextid();
$newitemid = $DB->insert_record('grade_letters', $data);
// Check if it exists before adding it
unset($data['id']);
if (!$DB->record_exists('grade_letters', $data)) {
$newitemid = $DB->insert_record('grade_letters', $gradeletter);
}
// no need to save any grade_letter mapping
}
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/community/block_community.php
Expand Up @@ -43,7 +43,7 @@ function user_can_addto($page) {
function user_can_edit() {
// Don't allow people to edit the block if they can't even use it
if (!has_capability('moodle/community:add',
get_context_instance_by_id($this->instance->parentcontextid))) {
context::instance_by_id($this->instance->parentcontextid))) {
return false;
}
return parent::user_can_edit();
Expand All @@ -52,7 +52,7 @@ function user_can_edit() {
function get_content() {
global $CFG, $OUTPUT, $USER;

$coursecontext = get_context_instance_by_id($this->instance->parentcontextid);
$coursecontext = context::instance_by_id($this->instance->parentcontextid);

if (!has_capability('moodle/community:add', $coursecontext)
or $this->content !== NULL) {
Expand Down
2 changes: 1 addition & 1 deletion blocks/edit_form.php
Expand Up @@ -87,7 +87,7 @@ function definition() {

$regionoptions = $this->page->theme->get_all_block_regions();

$parentcontext = get_context_instance_by_id($this->block->instance->parentcontextid);
$parentcontext = context::instance_by_id($this->block->instance->parentcontextid);
$mform->addElement('hidden', 'bui_parentcontextid', $parentcontext->id);

$mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), print_context_name($parentcontext));
Expand Down
14 changes: 11 additions & 3 deletions blocks/html/block_html.php
Expand Up @@ -29,6 +29,10 @@ function init() {
$this->title = get_string('pluginname', 'block_html');
}

function has_config() {
return true;
}

function applicable_formats() {
return array('all' => true);
}
Expand Down Expand Up @@ -104,7 +108,7 @@ function instance_delete() {
function content_is_trusted() {
global $SCRIPT;

if (!$context = get_context_instance_by_id($this->instance->parentcontextid)) {
if (!$context = context::instance_by_id($this->instance->parentcontextid, IGNORE_MISSING)) {
return false;
}
//find out if this block is on the profile page
Expand Down Expand Up @@ -138,10 +142,14 @@ public function instance_can_be_docked() {
* @return array
*/
function html_attributes() {
global $CFG;

$attributes = parent::html_attributes();

if (!empty($this->config->classes)) {
$attributes['class'] .= ' '.$this->config->classes;
if (!empty($CFG->block_html_allowcssclasses)) {
if (!empty($this->config->classes)) {
$attributes['class'] .= ' '.$this->config->classes;
}
}

return $attributes;
Expand Down
10 changes: 7 additions & 3 deletions blocks/html/edit_form.php
Expand Up @@ -31,6 +31,8 @@
*/
class block_html_edit_form extends block_edit_form {
protected function specific_definition($mform) {
global $CFG;

// Fields for editing HTML block title and contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));

Expand All @@ -42,9 +44,11 @@ protected function specific_definition($mform) {
$mform->addRule('config_text', null, 'required', null, 'client');
$mform->setType('config_text', PARAM_RAW); // XSS is prevented when printing the block contents and serving files

$mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html'));
$mform->setType('config_classes', PARAM_TEXT);
$mform->addHelpButton('config_classes', 'configclasses', 'block_html');
if (!empty($CFG->block_html_allowcssclasses)) {
$mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html'));
$mform->setType('config_classes', PARAM_TEXT);
$mform->addHelpButton('config_classes', 'configclasses', 'block_html');
}
}

function set_data($defaults) {
Expand Down
4 changes: 3 additions & 1 deletion blocks/html/lang/en/block_html.php
Expand Up @@ -23,7 +23,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['configclasses'] = 'Additional HTML classes';
$string['allowadditionalcssclasses'] = 'Allow additional CSS classes';
$string['configallowadditionalcssclasses'] = 'Adds a configuration option to HTML block instances allowing additional CSS classes to be set.';
$string['configclasses'] = 'Additional CSS classes';
$string['configclasses_help'] = 'The purpose of this configuration is to aid with theming by helping distinguish HTML blocks from each other. Any CSS classes entered here (space delimited) will be appended to the block\'s default classes.';
$string['configcontent'] = 'Content';
$string['configtitle'] = 'Block title';
Expand Down
2 changes: 1 addition & 1 deletion blocks/html/lib.php
Expand Up @@ -53,7 +53,7 @@ function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $a
send_file_not_found();
}

if ($parentcontext = get_context_instance_by_id($birecord_or_cm->parentcontextid)) {
if ($parentcontext = context::instance_by_id($birecord_or_cm->parentcontextid, IGNORE_MISSING)) {
if ($parentcontext->contextlevel == CONTEXT_USER) {
// force download on all personal pages including /my/
//because we do not have reliable way to find out from where this is used
Expand Down
10 changes: 10 additions & 0 deletions blocks/html/settings.php
@@ -0,0 +1,10 @@
<?php

defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('block_html_allowcssclasses', get_string('allowadditionalcssclasses', 'block_html'),
get_string('configallowadditionalcssclasses', 'block_html'), 0));
}


2 changes: 1 addition & 1 deletion blocks/quiz_results/block_quiz_results.php
Expand Up @@ -65,7 +65,7 @@ public function get_owning_quiz() {
if (empty($this->instance->parentcontextid)) {
return 0;
}
$parentcontext = get_context_instance_by_id($this->instance->parentcontextid);
$parentcontext = context::instance_by_id($this->instance->parentcontextid);
if ($parentcontext->contextlevel != CONTEXT_MODULE) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion cohort/assign.php
Expand Up @@ -32,7 +32,7 @@
require_login();

$cohort = $DB->get_record('cohort', array('id'=>$id), '*', MUST_EXIST);
$context = get_context_instance_by_id($cohort->contextid, MUST_EXIST);
$context = context::instance_by_id($cohort->contextid, MUST_EXIST);

require_capability('moodle/cohort:assign', $context);

Expand Down
4 changes: 2 additions & 2 deletions cohort/edit.php
Expand Up @@ -40,9 +40,9 @@
$category = null;
if ($id) {
$cohort = $DB->get_record('cohort', array('id'=>$id), '*', MUST_EXIST);
$context = get_context_instance_by_id($cohort->contextid, MUST_EXIST);
$context = context::instance_by_id($cohort->contextid, MUST_EXIST);
} else {
$context = get_context_instance_by_id($contextid, MUST_EXIST);
$context = context::instance_by_id($contextid, MUST_EXIST);
if ($context->contextlevel != CONTEXT_COURSECAT and $context->contextlevel != CONTEXT_SYSTEM) {
print_error('invalidcontext');
}
Expand Down

0 comments on commit 5e21657

Please sign in to comment.