Permalink
Browse files

Merge branch 'master' of https://github.com/moodle/moodle

Conflicts:
	files/externallib.php
  • Loading branch information...
2 parents 4873a89 + 569f1ad commit 5e21657f87ec6cd6ca5281205bc3b776a2ec8e0d @pcharsle pcharsle committed Sep 3, 2012
Showing with 7,509 additions and 2,420 deletions.
  1. +44 −7 admin/enrol.php
  2. +4 −4 admin/roles/lib.php
  3. +1 −0 admin/tool/assignmentupgrade/lang/en/tool_assignmentupgrade.php
  4. +3 −3 admin/tool/assignmentupgrade/module.js
  5. +1 −1 admin/tool/assignmentupgrade/renderer.php
  6. +1 −1 admin/user/user_bulk_cohortadd.php
  7. +7 −4 backup/moodle2/backup_stepslib.php
  8. +27 −5 backup/moodle2/restore_stepslib.php
  9. +2 −2 blocks/community/block_community.php
  10. +1 −1 blocks/edit_form.php
  11. +11 −3 blocks/html/block_html.php
  12. +7 −3 blocks/html/edit_form.php
  13. +3 −1 blocks/html/lang/en/block_html.php
  14. +1 −1 blocks/html/lib.php
  15. +10 −0 blocks/html/settings.php
  16. +1 −1 blocks/quiz_results/block_quiz_results.php
  17. +1 −1 cohort/assign.php
  18. +2 −2 cohort/edit.php
  19. +1 −1 cohort/edit_form.php
  20. +1 −1 cohort/index.php
  21. +12 −0 cohort/lib.php
  22. +1 −1 comment/lib.php
  23. +1 −1 comment/locallib.php
  24. +1 −1 course/editsection_form.php
  25. +18 −15 course/lib.php
  26. +3 −3 course/reset_form.php
  27. +1 −1 draftfile.php
  28. +1 −1 enrol/ajax.php
  29. +4 −4 enrol/category/locallib.php
  30. +1 −1 enrol/cohort/addinstance_form.php
  31. +1 −1 enrol/cohort/lib.php
  32. +3 −3 enrol/cohort/locallib.php
  33. +2 −2 enrol/externallib.php
  34. +15 −1 enrol/imsenterprise/lib.php
  35. +42 −11 enrol/locallib.php
  36. +8 −7 enrol/manual/ajax.php
  37. +2 −4 enrol/manual/bulkchangeforms.php
  38. +5 −1 enrol/manual/db/access.php
  39. +1 −3 enrol/manual/db/install.php
  40. +3 −5 enrol/manual/edit.php
  41. +2 −4 enrol/manual/edit_form.php
  42. +17 −23 enrol/manual/editenrolment.php
  43. +2 −4 enrol/manual/editenrolment_form.php
  44. +16 −17 enrol/manual/externallib.php
  45. +11 −13 enrol/manual/lib.php
  46. +110 −14 enrol/manual/locallib.php
  47. +5 −6 enrol/manual/manage.php
  48. +1 −4 enrol/manual/settings.php
  49. +204 −0 enrol/manual/tests/lib_test.php
  50. +3 −5 enrol/manual/unenrolself.php
  51. +1 −2 enrol/manual/version.php
  52. +1 −1 enrol/renderer.php
  53. +4 −2 enrol/self/db/access.php
  54. +1 −3 enrol/self/db/install.php
  55. +8 −8 enrol/self/edit.php
  56. +36 −4 enrol/self/edit_form.php
  57. +32 −33 enrol/self/editenrolment.php
  58. +2 −4 enrol/self/editenrolment_form.php
  59. +5 −4 enrol/self/lang/en/enrol_self.php
  60. +46 −25 enrol/self/lib.php
  61. +6 −8 enrol/self/locallib.php
  62. +1 −3 enrol/self/settings.php
  63. +3 −5 enrol/self/unenrolself.php
  64. +3 −4 enrol/self/version.php
  65. +3 −0 enrol/upgrade.txt
  66. +312 −312 files/externallib.php
  67. +1 −1 files/renderer.php
  68. +14 −5 filter/algebra/filter.php
  69. +90 −0 filter/algebra/tests/filter_test.php
  70. +0 −1 grade/grading/form/guide/lang/en/gradingform_guide.php
  71. +3 −4 grade/grading/form/guide/lib.php
  72. +0 −3 grade/grading/form/guide/preview.php
  73. +8 −0 grade/grading/form/rubric/lib.php
  74. +0 −3 grade/grading/form/rubric/preview.php
  75. +1 −1 grade/grading/lib.php
  76. +1 −2 grade/grading/manage.php
  77. +8 −1 grade/lib.php
  78. +3 −0 group/externallib.php
  79. +73 −1 group/lib.php
  80. +4 −0 group/members.php
  81. +5 −3 install/lang/lt/admin.php
  82. +6 −1 lang/en/enrol.php
  83. +2 −0 lang/en/group.php
  84. +1 −0 lang/en/repository.php
  85. +1 −1 lib/blocklib.php
  86. +12 −10 lib/boxlib.php
  87. +5 −1 lib/completionlib.php
  88. +0 −4 lib/cronlib.php
  89. +44 −40 lib/csvlib.class.php
  90. +18 −9 lib/db/install.xml
  91. +64 −0 lib/db/upgrade.php
  92. +194 −1 lib/editor/tinymce/adminlib.php
  93. +78 −0 lib/editor/tinymce/classes/plugin.php
  94. +5 −0 lib/editor/tinymce/lang/en/editor_tinymce.php
  95. +43 −5 lib/editor/tinymce/lib.php
  96. +3 −0 lib/editor/tinymce/plugins/dragmath/lib.php
  97. +3 −0 lib/editor/tinymce/plugins/moodleemoticon/lib.php
  98. +10 −0 lib/editor/tinymce/plugins/moodleimage/lib.php
  99. +10 −0 lib/editor/tinymce/plugins/moodlemedia/lib.php
  100. +3 −0 lib/editor/tinymce/plugins/moodlenolink/lib.php
  101. +4 −0 lib/editor/tinymce/plugins/moodlenolink/tinymce/editor_plugin.js
  102. +5 −2 lib/editor/tinymce/plugins/spellchecker/config.php
  103. +32 −0 lib/editor/tinymce/plugins/spellchecker/db/install.php
  104. +40 −0 lib/editor/tinymce/plugins/spellchecker/db/upgrade.php
  105. +41 −0 lib/editor/tinymce/plugins/spellchecker/db/upgradelib.php
  106. +4 −2 lib/editor/tinymce/plugins/spellchecker/lib.php
  107. +38 −0 lib/editor/tinymce/plugins/spellchecker/settings.php
  108. +1 −1 lib/editor/tinymce/plugins/spellchecker/version.php
  109. +28 −10 lib/editor/tinymce/settings.php
  110. +23 −0 lib/editor/tinymce/subplugins.php
  111. +53 −0 lib/editor/tinymce/tests/editor_test.php
  112. +9 −0 lib/editor/tinymce/upgrade.txt
  113. +1 −1 lib/externallib.php
  114. +1 −1 lib/filebrowser/file_info_context_course.php
  115. +1 −1 lib/filebrowser/file_info_context_coursecat.php
  116. +1 −1 lib/filebrowser/file_info_context_module.php
  117. +84 −177 lib/filelib.php
  118. +110 −30 lib/filestorage/file_storage.php
  119. +52 −22 lib/filestorage/stored_file.php
  120. +13 −4 lib/googleapi.php
  121. +4 −0 lib/modinfolib.php
  122. +3 −3 lib/moodlelib.php
  123. +7 −1 lib/navigationlib.php
  124. +23 −4 lib/oauthlib.php
  125. +33 −20 lib/questionlib.php
  126. +0 −39 lib/session-test.php
  127. +1 −1 lib/setuplib.php
  128. +1 −1 lib/tests/accesslib_test.php
  129. +1 −1 lib/tests/completionlib_test.php
  130. +42 −0 lib/tests/csvclass_test.php
  131. +15 −0 lib/tests/questionlib_test.php
  132. +2 −2 lib/weblib.php
  133. +6 −6 login/index.php
  134. +0 −1 message/edit.php
  135. +1 −1 mod/assign/gradingtable.php
  136. +2 −2 mod/assign/locallib.php
  137. +12 −1 mod/assignment/type/upload/assignment.class.php
  138. +1 −2 mod/choice/backup/moodle2/restore_choice_stepslib.php
  139. +1 −1 mod/data/lib.php
  140. +1 −1 mod/feedback/item/multichoice/lib.php
  141. +1 −1 mod/feedback/item/multichoicerated/lib.php
  142. +13 −15 mod/feedback/lang/en/feedback.php
  143. +1 −1 mod/forum/lib.php
  144. +1 −1 mod/glossary/lib.php
  145. +96 −0 mod/lesson/format.php
  146. +4 −0 mod/page/lib.php
  147. +1 −1 mod/quiz/edit.php
  148. +1 −1 mod/quiz/editlib.php
  149. +29 −4 mod/quiz/report/upgrade.txt
  150. +1 −1 mod/wiki/edit_form.php
  151. +1 −1 question/addquestion.php
  152. +1 −1 question/category.php
  153. +4 −4 question/category_class.php
  154. +4 −4 question/editlib.php
  155. +1 −1 question/engine/questionusage.php
  156. +69 −5 question/format.php
  157. +0 −27 question/format/blackboard/format.php
  158. +131 −898 question/format/blackboard_six/format.php
  159. +163 −0 question/format/blackboard_six/formatbase.php
  160. +467 −0 question/format/blackboard_six/formatpool.php
  161. +894 −0 question/format/blackboard_six/formatqti.php
  162. +10 −3 question/format/blackboard_six/lang/en/qformat_blackboard_six.php
  163. +330 −0 question/format/blackboard_six/tests/blackboardformatpool_test.php
  164. +330 −0 question/format/blackboard_six/tests/blackboardsixformatqti_test.php
  165. +142 −0 question/format/blackboard_six/tests/fixtures/sample_blackboard_pool.dat
  166. +1,058 −0 question/format/blackboard_six/tests/fixtures/sample_blackboard_qti.dat
  167. +3 −4 question/format/blackboard_six/version.php
  168. +0 −35 question/format/examview/format.php
  169. +55 −26 question/format/gift/format.php
  170. +3 −2 question/format/gift/tests/fixtures/questions.gift.txt
  171. +117 −0 question/format/gift/tests/giftformat_test.php
  172. +17 −14 question/format/multianswer/format.php
  173. +8 −0 question/format/multianswer/tests/fixtures/questions.multianswer.txt
  174. +76 −0 question/format/multianswer/tests/multianswerformat_test.php
  175. +1 −1 question/import.php
  176. +1 −1 question/preview.php
  177. +3 −3 question/question.php
  178. +1 −1 question/type/calculated/datasetdefinitions_form.php
  179. +1 −1 question/type/calculated/datasetitems_form.php
  180. +8 −6 question/type/calculated/questiontype.php
  181. +3 −3 question/type/edit_question_form.php
  182. +39 −29 question/type/essay/db/upgrade.php
  183. +1 −1 question/type/match/lang/en/qtype_match.php
  184. +1 −1 question/type/multianswer/lang/en/qtype_multianswer.php
  185. +3 −3 question/type/multianswer/questiontype.php
  186. +1 −1 question/type/multichoice/lang/en/qtype_multichoice.php
  187. +5 −3 question/type/numerical/question.php
  188. +37 −5 question/type/numerical/tests/answer_test.php
  189. +1 −1 question/type/questiontypebase.php
  190. +1 −1 question/type/shortanswer/lang/en/qtype_shortanswer.php
  191. +2 −2 report/security/locallib.php
  192. +1 −6 repository/alfresco/lib.php
  193. +26 −13 repository/boxnet/lib.php
  194. +2 −2 repository/coursefiles/lib.php
  195. +1 −1 repository/draftfiles_ajax.php
  196. +39 −0 repository/dropbox/db/upgrade.php
  197. +2 −1 repository/dropbox/lang/en/repository_dropbox.php
  198. +290 −61 repository/dropbox/lib.php
  199. +98 −27 repository/dropbox/locallib.php
  200. +44 −0 repository/dropbox/thumbnail.php
  201. +2 −3 repository/dropbox/version.php
  202. +94 −28 repository/equella/lib.php
  203. +10 −7 repository/filepicker.php
  204. +39 −7 repository/filesystem/lib.php
  205. +1 −8 repository/flickr/lib.php
  206. +2 −6 repository/flickr_public/lib.php
  207. +1 −1 repository/googledocs/lib.php
  208. +163 −57 repository/lib.php
  209. +1 −1 repository/local/lib.php
  210. +2 −2 repository/manage_instances.php
  211. +1 −1 repository/recent/lib.php
  212. +21 −13 repository/repository_ajax.php
  213. +3 −0 theme/base/style/user.css
  214. +0 −2 theme/formal_white/style/formal_white.css
  215. +1 −1 user/index.php
  216. +2 −2 user/profile.php
  217. +12 −2 user/selector/lib.php
  218. +5 −0 user/selector/module.js
  219. +3 −0 user/selector/search.php
  220. +2 −2 version.php
  221. +1 −1 webservice/lib.php
View
@@ -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());
@@ -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;
View
@@ -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);
}
@@ -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);
@@ -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;
@@ -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));
}
@@ -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.';
@@ -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) {
@@ -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();
}
});
@@ -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'));
@@ -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;
}
@@ -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');
@@ -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');
@@ -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) {
@@ -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);
}
}
@@ -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
}
}
@@ -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();
@@ -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) {
View
@@ -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));
View
@@ -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);
}
@@ -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
@@ -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;
View
@@ -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'));
@@ -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) {
@@ -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';
View
@@ -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
View
@@ -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));
+}
+
+
@@ -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;
}
View
@@ -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);
View
@@ -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');
}
Oops, something went wrong.

0 comments on commit 5e21657

Please sign in to comment.