Skip to content
Browse files

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

  • Loading branch information...
2 parents 81a0be7 + 87e9331 commit 3a2b8bb09d6034db94060229898f895e970a1ad8 @pcharsle pcharsle committed Aug 14, 2012
Showing with 988 additions and 17,480 deletions.
  1. +114 −0 admin/plagiarism.php
  2. +3 −2 admin/roles/usersroles.php
  3. +1 −1 admin/settings/grades.php
  4. +3 −3 admin/settings/plugins.php
  5. +2 −0 admin/tool/uploaduser/index.php
  6. +16 −17 admin/user/user_bulk_download.php
  7. +41 −26 auth/db/auth.php
  8. +1 −1 auth/fc/auth.php
  9. +3 −3 auth/ldap/auth.php
  10. +1 −1 auth/ldap/ntlmsso_attempt.php
  11. +1 −1 auth/ldap/ntlmsso_finish.php
  12. +1 −1 auth/ldap/ntlmsso_magic.php
  13. +3 −3 auth/mnet/auth.php
  14. +1 −1 auth/shibboleth/index.php
  15. +2 −0 auth/upgrade.txt
  16. +2 −1 backup/converter/moodle1/lib.php
  17. +23 −7 backup/moodle2/restore_activity_task.class.php
  18. +22 −7 backup/moodle2/restore_section_task.class.php
  19. +12 −8 backup/util/ui/base_moodleform.class.php
  20. +2 −2 blocks/community/block_community.php
  21. +1 −1 blocks/news_items/block_news_items.php
  22. +1 −1 comment/index.php
  23. +13 −6 comment/lib.php
  24. +2 −2 completion/criteria/completion_criteria_course.php
  25. +18 −18 course/format/renderer.php
  26. +15 −15 course/format/topics/renderer.php
  27. +0 −16 course/lib.php
  28. +3 −2 course/rest.php
  29. +3 −1 course/view.php
  30. +3 −1 enrol/authorize/locallib.php
  31. +7 −1 enrol/imsenterprise/lib.php
  32. +2 −0 enrol/manual/lib.php
  33. +3 −3 enrol/manual/manage.php
  34. +1 −0 enrol/self/edit_form.php
  35. +6 −0 enrol/self/lang/en/enrol_self.php
  36. +15 −5 enrol/self/lib.php
  37. +1 −1 file.php
  38. +2 −1 filter/algebra/algebradebug.php
  39. +1 −0 filter/algebra/lang/en/filter_algebra.php
  40. +4 −1 filter/manage.php
  41. +1 −1 grade/edit/outcome/edit.php
  42. +1 −0 grade/edit/tree/calculation.php
  43. +1 −1 grade/edit/tree/index.php
  44. +2 −1 grade/edit/tree/lib.php
  45. +15 −37 grade/export/txt/grade_export_txt.php
  46. +3 −1 grade/grading/form/guide/lib.php
  47. +4 −3 grade/grading/form/rubric/renderer.php
  48. +1 −1 grade/lib.php
  49. +2 −1 grade/report/grader/lib.php
  50. +1 −1 group/assign.php
  51. +1 −2 group/autogroup.php
  52. +1 −1 group/autogroup_form.php
  53. +1 −1 group/delete.php
  54. +7 −7 group/externallib.php
  55. +1 −1 group/group.php
  56. +1 −1 group/grouping.php
  57. +1 −1 group/groupings.php
  58. +2 −2 group/import.php
  59. +1 −1 group/index.php
  60. +11 −11 group/lib.php
  61. +1 −1 group/members.php
  62. +1 −1 group/overview.php
  63. +1 −1 help.php
  64. +3 −3 index.php
  65. +3 −0 install/lang/cs/install.php
  66. +7 −0 install/lang/lt/admin.php
  67. +1 −0 install/lang/nl/langconfig.php
  68. +2 −2 iplookup/index.php
  69. +2 −2 lang/en/admin.php
  70. +1 −0 lang/en/message.php
  71. +1 −0 lang/en/moodle.php
  72. +1 −0 lang/en/notes.php
  73. +1 −1 lang/en/plagiarism.php
  74. +1 −1 lib/accesslib.php
  75. +0 −89 lib/adminlib.php
  76. +12 −0 lib/authlib.php
  77. +191 −0 lib/csvlib.class.php
  78. +13 −0 lib/db/upgrade.php
  79. +3 −3 lib/filelib.php
  80. +6 −1 lib/form/editor.php
  81. +19 −19 lib/formslib.php
  82. +31 −2 lib/javascript-static.js
  83. +10 −17 lib/medialib.php
  84. +19 −3 lib/moodlelib.php
  85. +2 −4 lib/outputrequirementslib.php
  86. +1 −1 lib/setup.php
  87. +15 −14 lib/tablelib.php
  88. +75 −0 lib/tests/csvclass_test.php
  89. +3 −3 lib/tests/medialib_test.php
  90. +1 −1 lib/thirdpartylibs.xml
  91. +148 −31 lib/webdavlib.php
  92. +0 −199 lib/yui/3.5.1/build/align-plugin/align-plugin-debug.js
  93. +0 −7 lib/yui/3.5.1/build/align-plugin/align-plugin-min.js
  94. +0 −199 lib/yui/3.5.1/build/align-plugin/align-plugin.js
  95. +0 −682 lib/yui/3.5.1/build/anim-base/anim-base-debug.js
  96. +0 −7 lib/yui/3.5.1/build/anim-base/anim-base-min.js
  97. +0 −681 lib/yui/3.5.1/build/anim-base/anim-base.js
  98. +0 −54 lib/yui/3.5.1/build/anim-color/anim-color-debug.js
  99. +0 −7 lib/yui/3.5.1/build/anim-color/anim-color-min.js
  100. +0 −54 lib/yui/3.5.1/build/anim-color/anim-color.js
  101. +0 −63 lib/yui/3.5.1/build/anim-curve/anim-curve-debug.js
  102. +0 −7 lib/yui/3.5.1/build/anim-curve/anim-curve-min.js
  103. +0 −63 lib/yui/3.5.1/build/anim-curve/anim-curve.js
  104. +0 −356 lib/yui/3.5.1/build/anim-easing/anim-easing-debug.js
  105. +0 −7 lib/yui/3.5.1/build/anim-easing/anim-easing-min.js
  106. +0 −356 lib/yui/3.5.1/build/anim-easing/anim-easing.js
  107. +0 −32 lib/yui/3.5.1/build/anim-node-plugin/anim-node-plugin-debug.js
  108. +0 −7 lib/yui/3.5.1/build/anim-node-plugin/anim-node-plugin-min.js
  109. +0 −32 lib/yui/3.5.1/build/anim-node-plugin/anim-node-plugin.js
  110. +0 −44 lib/yui/3.5.1/build/anim-scroll/anim-scroll-debug.js
  111. +0 −7 lib/yui/3.5.1/build/anim-scroll/anim-scroll-min.js
  112. +0 −44 lib/yui/3.5.1/build/anim-scroll/anim-scroll.js
  113. +0 −112 lib/yui/3.5.1/build/anim-shape-transform/anim-shape-transform-debug.js
  114. +0 −7 lib/yui/3.5.1/build/anim-shape-transform/anim-shape-transform-min.js
  115. +0 −112 lib/yui/3.5.1/build/anim-shape-transform/anim-shape-transform.js
  116. +0 −32 lib/yui/3.5.1/build/anim-xy/anim-xy-debug.js
  117. +0 −7 lib/yui/3.5.1/build/anim-xy/anim-xy-min.js
  118. +0 −32 lib/yui/3.5.1/build/anim-xy/anim-xy.js
  119. +0 −1,142 lib/yui/3.5.1/build/app-base/app-base-debug.js
  120. +0 −7 lib/yui/3.5.1/build/app-base/app-base-min.js
  121. +0 −1,142 lib/yui/3.5.1/build/app-base/app-base.js
  122. +0 −7 lib/yui/3.5.1/build/app-transitions-css/app-transitions-css-min.css
  123. +0 −24 lib/yui/3.5.1/build/app-transitions-css/app-transitions-css.css
  124. +0 −358 lib/yui/3.5.1/build/app-transitions-native/app-transitions-native-debug.js
  125. +0 −7 lib/yui/3.5.1/build/app-transitions-native/app-transitions-native-min.js
  126. +0 −358 lib/yui/3.5.1/build/app-transitions-native/app-transitions-native.js
  127. +0 −257 lib/yui/3.5.1/build/app-transitions/app-transitions-debug.js
  128. +0 −7 lib/yui/3.5.1/build/app-transitions/app-transitions-min.js
  129. +0 −257 lib/yui/3.5.1/build/app-transitions/app-transitions.js
  130. +0 −367 lib/yui/3.5.1/build/array-extras/array-extras-debug.js
  131. +0 −7 lib/yui/3.5.1/build/array-extras/array-extras-min.js
  132. +0 −366 lib/yui/3.5.1/build/array-extras/array-extras.js
  133. +0 −46 lib/yui/3.5.1/build/array-invoke/array-invoke-debug.js
  134. +0 −7 lib/yui/3.5.1/build/array-invoke/array-invoke-min.js
  135. +0 −46 lib/yui/3.5.1/build/array-invoke/array-invoke.js
  136. +0 −93 lib/yui/3.5.1/build/arraylist-add/arraylist-add-debug.js
  137. +0 −7 lib/yui/3.5.1/build/arraylist-add/arraylist-add-min.js
  138. +0 −93 lib/yui/3.5.1/build/arraylist-add/arraylist-add.js
  139. +0 −51 lib/yui/3.5.1/build/arraylist-filter/arraylist-filter-debug.js
  140. +0 −7 lib/yui/3.5.1/build/arraylist-filter/arraylist-filter-min.js
  141. +0 −51 lib/yui/3.5.1/build/arraylist-filter/arraylist-filter.js
  142. +0 −220 lib/yui/3.5.1/build/arraylist/arraylist-debug.js
  143. +0 −7 lib/yui/3.5.1/build/arraylist/arraylist-min.js
  144. +0 −220 lib/yui/3.5.1/build/arraylist/arraylist.js
  145. +0 −71 lib/yui/3.5.1/build/arraysort/arraysort-debug.js
  146. +0 −7 lib/yui/3.5.1/build/arraysort/arraysort-min.js
  147. +0 −71 lib/yui/3.5.1/build/arraysort/arraysort.js
  148. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/autocomplete-list.css
  149. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/calendar-base.css
  150. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/calendar.css
  151. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/calendarnavigator.css
  152. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/console-filters.css
  153. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/console.css
  154. +0 −8 lib/yui/3.5.1/build/assets/skins/sam/datatable-base-deprecated.css
  155. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/datatable-base.css
  156. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/datatable-message.css
  157. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/datatable-scroll.css
  158. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/datatable-sort.css
  159. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/dial.css
  160. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/node-flick.css
  161. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/node-menunav.css
  162. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/overlay.css
  163. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/panel.css
  164. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/resize-base.css
  165. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/scrollview-base.css
  166. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/scrollview-list.css
  167. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/scrollview-scrollbars.css
  168. +0 −35 lib/yui/3.5.1/build/assets/skins/sam/skin.css
  169. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/slider-base.css
  170. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/tabview.css
  171. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/test-console.css
  172. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/test.css
  173. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/widget-base.css
  174. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/widget-buttons.css
  175. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/widget-modality.css
  176. +0 −7 lib/yui/3.5.1/build/assets/skins/sam/widget-stack.css
  177. +0 −528 lib/yui/3.5.1/build/async-queue/async-queue-debug.js
  178. +0 −7 lib/yui/3.5.1/build/async-queue/async-queue-min.js
  179. +0 −528 lib/yui/3.5.1/build/async-queue/async-queue.js
  180. +0 −111 lib/yui/3.5.1/build/attribute-base/attribute-base-debug.js
  181. +0 −7 lib/yui/3.5.1/build/attribute-base/attribute-base-min.js
  182. +0 −111 lib/yui/3.5.1/build/attribute-base/attribute-base.js
  183. +0 −132 lib/yui/3.5.1/build/attribute-complex/attribute-complex-debug.js
  184. +0 −7 lib/yui/3.5.1/build/attribute-complex/attribute-complex-min.js
  185. +0 −132 lib/yui/3.5.1/build/attribute-complex/attribute-complex.js
  186. +0 −1,029 lib/yui/3.5.1/build/attribute-core/attribute-core-debug.js
  187. +0 −7 lib/yui/3.5.1/build/attribute-core/attribute-core-min.js
  188. +0 −1,017 lib/yui/3.5.1/build/attribute-core/attribute-core.js
  189. +0 −180 lib/yui/3.5.1/build/attribute-events/attribute-events-debug.js
  190. +0 −7 lib/yui/3.5.1/build/attribute-events/attribute-events-min.js
  191. +0 −179 lib/yui/3.5.1/build/attribute-events/attribute-events.js
  192. +0 −150 lib/yui/3.5.1/build/attribute-extras/attribute-extras-debug.js
  193. +0 −7 lib/yui/3.5.1/build/attribute-extras/attribute-extras-min.js
  194. +0 −149 lib/yui/3.5.1/build/attribute-extras/attribute-extras.js
  195. +0 −1,552 lib/yui/3.5.1/build/autocomplete-base/autocomplete-base-debug.js
  196. +0 −8 lib/yui/3.5.1/build/autocomplete-base/autocomplete-base-min.js
  197. +0 −1,544 lib/yui/3.5.1/build/autocomplete-base/autocomplete-base.js
  198. +0 −142 lib/yui/3.5.1/build/autocomplete-filters-accentfold/autocomplete-filters-accentfold-debug.js
  199. +0 −7 lib/yui/3.5.1/build/autocomplete-filters-accentfold/autocomplete-filters-accentfold-min.js
  200. +0 −142 lib/yui/3.5.1/build/autocomplete-filters-accentfold/autocomplete-filters-accentfold.js
  201. +0 −245 lib/yui/3.5.1/build/autocomplete-filters/autocomplete-filters-debug.js
  202. +0 −7 lib/yui/3.5.1/build/autocomplete-filters/autocomplete-filters-min.js
  203. +0 −245 lib/yui/3.5.1/build/autocomplete-filters/autocomplete-filters.js
  204. +0 −113 ...ui/3.5.1/build/autocomplete-highlighters-accentfold/autocomplete-highlighters-accentfold-debug.js
  205. +0 −7 lib/yui/3.5.1/build/autocomplete-highlighters-accentfold/autocomplete-highlighters-accentfold-min.js
Sorry, we could not display the entire diff because too many files (2,988) changed.
View
114 admin/plagiarism.php
@@ -0,0 +1,114 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Provides an overview of installed plagiarism plugins
+ *
+ * Displays the list of found plagiarism plugins, their version (if found) and
+ * a link to delete the plagiarism plugin.
+ *
+ * @see http://docs.moodle.org/dev/Plagiarism_API
+ * @package admin
+ * @copyright 2012 Dan Marsden <dan@danmarsden.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(dirname(dirname(__FILE__)) . '/config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/tablelib.php');
+
+admin_externalpage_setup('manageplagiarismplugins');
+
+$delete = optional_param('delete', '', PARAM_PLUGIN);
+$confirm = optional_param('confirm', false, PARAM_BOOL);
+
+if (!empty($delete) and confirm_sesskey()) { // If data submitted, then process and store.
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(get_string('manageplagiarism', 'plagiarism'));
+
+ if (!$confirm) {
+ if (get_string_manager()->string_exists('pluginname', 'plagiarism_' . $delete)) {
+ $strpluginname = get_string('pluginname', 'plagiarism_' . $delete);
+ } else {
+ $strpluginname = $delete;
+ }
+ echo $OUTPUT->confirm(get_string('plagiarismplugindeleteconfirm', 'plagiarism', $strpluginname),
+ new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
+ $PAGE->url);
+ echo $OUTPUT->footer();
+ die();
+
+ } else {
+ uninstall_plugin('plagiarism', $delete);
+ $a = new stdclass();
+ $a->name = $delete;
+ $pluginlocation = get_plugin_types();
+ $a->directory = $pluginlocation['plagiarism'] . '/' . $delete;
+ echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
+ echo $OUTPUT->continue_button($PAGE->url);
+ echo $OUTPUT->footer();
+ die();
+ }
+}
+
+echo $OUTPUT->header();
+
+// Print the table of all installed plagiarism plugins.
+
+$txt = get_strings(array('settings', 'name', 'version', 'delete'));
+
+$plagiarismplugins = get_plugin_list('plagiarism');
+if (empty($plagiarismplugins)) {
+ echo $OUTPUT->notification(get_string('nopluginsinstalled', 'plagiarism'));
+ echo $OUTPUT->footer();
+ exit;
+}
+
+echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main');
+echo $OUTPUT->box_start('generalbox authsui');
+
+$table = new html_table();
+$table->head = array($txt->name, $txt->version, $txt->delete, $txt->settings);
+$table->colclasses = array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align');
+$table->data = array();
+$table->attributes['class'] = 'manageplagiarismtable generaltable';
+
+// Iterate through auth plugins and add to the display table.
+$authcount = count($plagiarismplugins);
+foreach ($plagiarismplugins as $plugin => $dir) {
+ if (file_exists($dir.'/settings.php')) {
+ $displayname = "<span>".get_string($plugin, 'plagiarism_'.$plugin)."</span>";
+ // Settings link.
+ $url = new moodle_url("/plagiarism/$plugin/settings.php");
+ $settings = html_writer::link($url, $txt->settings);
+ // Get version.
+ $version = get_config('plagiarism_' . $plugin);
+ if (!empty($version->version)) {
+ $version = $version->version;
+ } else {
+ $version = '?';
+ }
+ // Delete link.
+ $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey()));
+ $delete = html_writer::link($delete, get_string('delete'));
+ $table->data[] = array($displayname, $version, $delete, $settings);
+ }
+}
+echo html_writer::table($table);
+echo get_string('configplagiarismplugins', 'plagiarism');
+echo $OUTPUT->box_end();
+
+echo $OUTPUT->footer();
View
5 admin/roles/usersroles.php
@@ -165,7 +165,8 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname, $al
$context = context::instance_by_id($contextid);
// Print the context name.
- echo $OUTPUT->heading($context->get_context_name(), 4, 'contextname');
+ echo $OUTPUT->heading(html_writer::link($context->get_url(), $context->get_context_name()),
+ 4, 'contextname');
// If there are any role assignments here, print them.
foreach ($contexts[$contextid]->roleassignments as $ra) {
@@ -186,7 +187,7 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname, $al
}
$a = new stdClass;
$a->fullname = $fullname;
- $a->contextlevel = get_contextlevel_name($context->contextlevel);
+ $a->contextlevel = $context->get_level_name();
if ($context->contextlevel == CONTEXT_SYSTEM) {
$strgoto = get_string('gotoassignsystemroles', 'role');
$strcheck = get_string('checksystempermissionsfor', 'role', $a);
View
2 admin/settings/grades.php
@@ -60,7 +60,7 @@
$temp->add(new admin_setting_configtext('grade_export_userprofilefields', new lang_string('gradeexportuserprofilefields', 'grades'), new lang_string('gradeexportuserprofilefields_desc', 'grades'), 'firstname,lastname,idnumber,institution,department,email', PARAM_TEXT));
- $temp->add(new admin_setting_configtext('grade_export_customprofilefields', new lang_string('gradeexportcustomprofilefields', 'grades'), new lang_string('gradeexportcustomprofilefields_desc', 'grades'), null, PARAM_TEXT));
+ $temp->add(new admin_setting_configtext('grade_export_customprofilefields', new lang_string('gradeexportcustomprofilefields', 'grades'), new lang_string('gradeexportcustomprofilefields_desc', 'grades'), '', PARAM_TEXT));
$temp->add(new admin_setting_configcheckbox('recovergradesdefault', new lang_string('recovergradesdefault', 'grades'), new lang_string('recovergradesdefault_help', 'grades'), 0));
View
6 admin/settings/plugins.php
@@ -422,9 +422,9 @@
// Plagiarism plugin settings
if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
$ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
- $temp = new admin_settingpage('plagiarismsettings', new lang_string('plagiarismsettings', 'plagiarism'));
- $temp->add(new admin_setting_manageplagiarism());
- $ADMIN->add('plagiarism', $temp);
+ $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
+ $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
+
foreach (get_plugin_list('plagiarism') as $plugin => $plugindir) {
if (file_exists($plugindir.'/settings.php')) {
$ADMIN->add('plagiarism', new admin_externalpage('plagiarism'.$plugin, new lang_string($plugin, 'plagiarism_'.$plugin), "$CFG->wwwroot/plagiarism/$plugin/settings.php", 'moodle/site:config'));
View
2 admin/tool/uploaduser/index.php
@@ -857,6 +857,8 @@
if ($duration > 0) { // sanity check
$timeend = $today + $duration;
}
+ } else if ($manualcache[$courseid]->enrolperiod > 0) {
+ $timeend = $today + $manualcache[$courseid]->enrolperiod;
}
$manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend);
View
33 admin/user/user_bulk_download.php
@@ -148,34 +148,33 @@ function user_download_csv($fields) {
global $CFG, $SESSION, $DB;
require_once($CFG->dirroot.'/user/profile/lib.php');
+ require_once($CFG->libdir . '/csvlib.class.php');
- $filename = clean_filename(get_string('users').'.csv');
+ $filename = clean_filename(get_string('users'));
- header("Content-Type: application/download\n");
- header("Content-Disposition: attachment; filename=\"$filename\"");
- header("Expires: 0");
- header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
- header("Pragma: public");
-
- $delimiter = get_string('listsep', 'langconfig');
- $encdelim = '&#'.ord($delimiter);
-
- $row = array();
- foreach ($fields as $fieldname) {
- $row[] = str_replace($delimiter, $encdelim, $fieldname);
- }
- echo implode($delimiter, $row)."\n";
+ $csvexport = new csv_export_writer();
+ $csvexport->set_filename($filename);
+ $csvexport->add_data($fields);
foreach ($SESSION->bulk_users as $userid) {
$row = array();
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
continue;
}
profile_load_data($user);
+ $userprofiledata = array();
foreach ($fields as $field=>$unused) {
- $row[] = str_replace($delimiter, $encdelim, $user->$field);
+ // Custom user profile textarea fields come in an array
+ // The first element is the text and the second is the format.
+ // We only take the text.
+ if (is_array($user->$field)) {
+ $userprofiledata[] = reset($user->$field);
+ } else {
+ $userprofiledata[] = $user->$field;
+ }
}
- echo implode($delimiter, $row)."\n";
+ $csvexport->add_data($userprofiledata);
}
+ $csvexport->download_file();
die;
}
View
67 auth/db/auth.php
@@ -224,25 +224,31 @@ function sync_users($do_updates=false, $verbose=false) {
// delete obsolete internal users
if (!empty($this->config->removeuser)) {
+ $suspendselect = "";
+ if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
+ $suspendselect = "AND u.suspended = 0";
+ }
+
// find obsolete users
if (count($userlist)) {
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', false);
$params['authtype'] = $this->authtype;
$sql = "SELECT u.*
FROM {user} u
- WHERE u.auth=:authtype AND u.deleted=0 AND u.username $notin_sql";
+ WHERE u.auth=:authtype AND u.deleted=0 AND u.mnethostid=:mnethostid $suspendselect AND u.username $notin_sql";
} else {
$sql = "SELECT u.*
FROM {user} u
- WHERE u.auth=:authtype AND u.deleted=0";
+ WHERE u.auth=:authtype AND u.deleted=0 AND u.mnethostid=:mnethostid $suspendselect";
$params = array();
$params['authtype'] = $this->authtype;
}
+ $params['mnethostid'] = $CFG->mnet_localhost_id;
$remove_users = $DB->get_records_sql($sql, $params);
if (!empty($remove_users)) {
if ($verbose) {
- mtrace(print_string('auth_dbuserstoremove','auth_db', count($remove_users)));
+ mtrace(get_string('auth_dbuserstoremove','auth_db', count($remove_users)));
}
foreach ($remove_users as $user) {
@@ -254,7 +260,7 @@ function sync_users($do_updates=false, $verbose=false) {
} else if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
$updateuser = new stdClass();
$updateuser->id = $user->id;
- $updateuser->auth = 'nologin';
+ $updateuser->suspended = 1;
$updateuser->timemodified = time();
$DB->update_record('user', $updateuser);
if ($verbose) {
@@ -324,11 +330,15 @@ function sync_users($do_updates=false, $verbose=false) {
///
// NOTE: this is very memory intensive
// and generally inefficient
- $sql = 'SELECT u.id, u.username
- FROM {user} u
- WHERE u.auth=\'' . $this->authtype . '\' AND u.deleted=\'0\'';
+ $suspendselect = "";
+ if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
+ $suspendselect = "AND u.suspended = 0";
+ }
+ $sql = "SELECT u.id, u.username
+ FROM {user} u
+ WHERE u.auth=:authtype AND u.deleted='0' AND mnethostid=:mnethostid $suspendselect";
- $users = $DB->get_records_sql($sql);
+ $users = $DB->get_records_sql($sql, array('authtype'=>$this->authtype, 'mnethostid'=>$CFG->mnet_localhost_id));
// simplify down to usernames
$usernames = array();
@@ -349,39 +359,44 @@ function sync_users($do_updates=false, $verbose=false) {
$transaction = $DB->start_delegated_transaction();
foreach($add_users as $user) {
$username = $user;
- $user = $this->get_userinfo_asobj($user);
+ if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) {
+ if ($old_user = $DB->get_record('user', array('username'=>$username, 'deleted'=>0, 'suspended'=>1, 'mnethostid'=>$CFG->mnet_localhost_id, 'auth'=>$this->authtype))) {
+ $DB->set_field('user', 'suspended', 0, array('id'=>$old_user->id));
+ if ($verbose) {
+ mtrace("\t".get_string('auth_dbreviveduser', 'auth_db', array('name'=>$username, 'id'=>$old_user->id)));
+ }
+ continue;
+ }
+ }
+
+ // Do not try to undelete users here, instead select suspending if you ever expect users will reappear.
// prep a few params
+ $user = $this->get_userinfo_asobj($user);
$user->username = $username;
$user->confirmed = 1;
$user->auth = $this->authtype;
$user->mnethostid = $CFG->mnet_localhost_id;
if (empty($user->lang)) {
$user->lang = $CFG->lang;
}
-
- // maybe the user has been deleted before
- if ($old_user = $DB->get_record('user', array('username'=>$user->username, 'deleted'=>1, 'mnethostid'=>$user->mnethostid, 'auth'=>$user->auth))) {
- // note: this undeleting is deprecated and will be eliminated soon
- $DB->set_field('user', 'deleted', 0, array('id'=>$old_user->id));
- $DB->set_field('user', 'timemodified', time(), array('id'=>$old_user->id));
- if ($verbose) {
- mtrace("\t".get_string('auth_dbreviveduser', 'auth_db', array('name'=>$old_user->username, 'id'=>$old_user->id)));
- }
-
- } else {
- $user->timecreated = time();
- $user->timemodified = $user->timecreated;
+ $user->timecreated = time();
+ $user->timemodified = $user->timecreated;
+ try {
$id = $DB->insert_record ('user', $user); // it is truly a new user
if ($verbose) {
mtrace("\t".get_string('auth_dbinsertuser', 'auth_db', array('name'=>$user->username, 'id'=>$id)));
}
- // if relevant, tag for password generation
- if ($this->is_internal()) {
- set_user_preference('auth_forcepasswordchange', 1, $id);
- set_user_preference('create_password', 1, $id);
+ } catch (moodle_exception $e) {
+ if ($verbose) {
+ mtrace("\t".get_string('auth_dbinsertusererror', 'auth_db', $user->username));
}
}
+ // if relevant, tag for password generation
+ if ($this->is_internal()) {
+ set_user_preference('auth_forcepasswordchange', 1, $id);
+ set_user_preference('create_password', 1, $id);
+ }
}
$transaction->allow_commit();
unset($add_users); // free mem
View
2 auth/fc/auth.php
@@ -180,7 +180,7 @@ function sync_roles($user) {
if ($roles = get_archetype_roles('coursecreator')) {
$creatorrole = array_shift($roles); // We can only use one, let's use the first one
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $systemcontext = context_system::instance();
if ($iscreator) { // Following calls will not create duplicates
role_assign($creatorrole->id, $user->id, $systemcontext->id, 'auth_fc');
View
6 auth/ldap/auth.php
@@ -771,7 +771,7 @@ function sync_users($do_updates=true) {
if (!empty($users)) {
print_string('userentriestoupdate', 'auth_ldap', count($users));
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+ $sitecontext = context_system::instance();
if (!empty($this->config->creators) and !empty($this->config->memberattribute)
and $roles = get_archetype_roles('coursecreator')) {
$creatorrole = array_shift($roles); // We can only use one, let's use the first one
@@ -820,7 +820,7 @@ function sync_users($do_updates=true) {
if (!empty($add_users)) {
print_string('userentriestoadd', 'auth_ldap', count($add_users));
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+ $sitecontext = context_system::instance();
if (!empty($this->config->creators) and !empty($this->config->memberattribute)
and $roles = get_archetype_roles('coursecreator')) {
$creatorrole = array_shift($roles); // We can only use one, let's use the first one
@@ -1649,7 +1649,7 @@ function sync_roles($user) {
if ($roles = get_archetype_roles('coursecreator')) {
$creatorrole = array_shift($roles); // We can only use one, let's use the first one
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $systemcontext = context_system::instance();
if ($iscreator) { // Following calls will not create duplicates
role_assign($creatorrole->id, $user->id, $systemcontext->id, $this->roleauth);
View
2 auth/ldap/ntlmsso_attempt.php
@@ -6,7 +6,7 @@
$PAGE->https_required();
$PAGE->set_url('/auth/ldap/ntlmsso_attempt.php');
-$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
+$PAGE->set_context(context_system::instance());
// Define variables used in page
$site = get_site();
View
2 auth/ldap/ntlmsso_finish.php
@@ -6,7 +6,7 @@
$PAGE->https_required();
$PAGE->set_url('/auth/ldap/ntlmsso_finish.php');
-$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
+$PAGE->set_context(context_system::instance());
// Define variables used in page
$site = get_site();
View
2 auth/ldap/ntlmsso_magic.php
@@ -11,7 +11,7 @@
//HTTPS is required in this page when $CFG->loginhttps enabled
$PAGE->https_required();
-$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
+$PAGE->set_context(context_system::instance());
$authsequence = get_enabled_auth_plugins(true); // auths, in sequence
if (!in_array('ldap', $authsequence, true)) {
View
6 auth/mnet/auth.php
@@ -81,7 +81,7 @@ function user_authorise($token, $useragent) {
if (array_key_exists('picture', $userdata) && !empty($user->picture)) {
$fs = get_file_storage();
- $usercontext = get_context_instance(CONTEXT_USER, $user->id, MUST_EXIST);
+ $usercontext = context_user::instance($user->id, MUST_EXIST);
if ($usericonfile = $fs->get_file($usercontext->id, 'user', 'icon', 0, '/', 'f1.png')) {
$userdata['_mnet_userpicture_timemodified'] = $usericonfile->get_timemodified();
$userdata['_mnet_userpicture_mimetype'] = $usericonfile->get_mimetype();
@@ -299,7 +299,7 @@ function confirm_mnet_session($token, $remotepeer) {
if ($key == '_mnet_userpicture_timemodified' and empty($CFG->disableuserimages) and isset($remoteuser->picture)) {
// update the user picture if there is a newer verion at the identity provider
- $usercontext = get_context_instance(CONTEXT_USER, $localuser->id, MUST_EXIST);
+ $usercontext = context_user::instance($localuser->id, MUST_EXIST);
if ($usericonfile = $fs->get_file($usercontext->id, 'user', 'icon', 0, '/', 'f1.png')) {
$localtimemodified = $usericonfile->get_timemodified();
} else if ($usericonfile = $fs->get_file($usercontext->id, 'user', 'icon', 0, '/', 'f1.jpg')) {
@@ -1136,7 +1136,7 @@ function fetch_user_image($username) {
if ($user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id))) {
$fs = get_file_storage();
- $usercontext = get_context_instance(CONTEXT_USER, $user->id, MUST_EXIST);
+ $usercontext = context_user::instance($user->id, MUST_EXIST);
$return = array();
if ($f1 = $fs->get_file($usercontext->id, 'user', 'icon', 0, '/', 'f1.png')) {
$return['f1'] = base64_encode($f1->get_content());
View
2 auth/shibboleth/index.php
@@ -72,7 +72,7 @@
}
/// Go to my-moodle page instead of homepage if defaulthomepage enabled
- if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) and !empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY and !isguestuser()) {
+ if (!has_capability('moodle/site:config',context_system::instance()) and !empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY and !isguestuser()) {
if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') {
$urltogo = $CFG->wwwroot.'/my/';
}
View
2 auth/upgrade.txt
@@ -8,6 +8,8 @@ required changes in code:
* use role_get_name() or role_fix_names() if you need any role names, using role.name
directly from database is not correct any more
+optional - no changes needed:
+* add support for custom user signup form - see auth_plugin_base::signup_form() function
=== 2.2 ===
View
3 backup/converter/moodle1/lib.php
@@ -528,7 +528,8 @@ public function get_stash_itemids($stashname) {
* CONTEXT_SYSTEM and CONTEXT_COURSE ignore the $instance as they represent a
* single system or the course being restored.
*
- * @see get_context_instance()
+ * @see context_system::instance()
+ * @see context_course::instance()
* @param int $level the context level, like CONTEXT_COURSE or CONTEXT_MODULE
* @param int $instance the instance id, for example $course->id for courses or $cm->id for activity modules
* @return int the context id
View
30 backup/moodle2/restore_activity_task.class.php
@@ -293,30 +293,46 @@ protected function define_settings() {
// Define activity_userinfo. Dependent of:
// - users root setting
// - section_userinfo setting (if exists)
- // - activity_included setting
+ // - activity_included setting.
$settingname = $settingprefix . 'userinfo';
- $selectvalues = array(0=>get_string('no')); // Safer options
- $defaultvalue = false; // Safer default
+ $defaultvalue = false;
if (isset($this->info->settings[$settingname]) && $this->info->settings[$settingname]) { // Only enabled when available
- $selectvalues = array(1=>get_string('yes'), 0=>get_string('no'));
$defaultvalue = true;
}
+
$activity_userinfo = new restore_activity_userinfo_setting($settingname, base_setting::IS_BOOLEAN, $defaultvalue);
- $activity_userinfo->set_ui(new backup_setting_ui_select($activity_userinfo, get_string('includeuserinfo','backup'), $selectvalues));
+ if (!$defaultvalue) {
+ // This is a bit hacky, but if there is no user data to restore, then
+ // we replace the standard check-box with a select menu with the
+ // single choice 'No', and the select menu is clever enough that if
+ // there is only one choice, it just displays a static string.
+ //
+ // It would probably be better design to have a special UI class
+ // setting_ui_checkbox_or_no, rather than this hack, but I am not
+ // going to do that today.
+ $activity_userinfo->set_ui(new backup_setting_ui_select($activity_userinfo, '-',
+ array(0 => get_string('no'))));
+ } else {
+ $activity_userinfo->get_ui()->set_label('-');
+ }
+
$this->add_setting($activity_userinfo);
+
// Look for "users" root setting
$users = $this->plan->get_setting('users');
$users->add_dependency($activity_userinfo);
+
// Look for "section_userinfo" section setting (if exists)
$settingname = 'section_' . $this->info->sectionid . '_userinfo';
if ($this->plan->setting_exists($settingname)) {
$section_userinfo = $this->plan->get_setting($settingname);
$section_userinfo->add_dependency($activity_userinfo);
}
- // Look for "activity_included" setting
+
+ // Look for "activity_included" setting.
$activity_included->add_dependency($activity_userinfo);
- // End of common activity settings, let's add the particular ones
+ // End of common activity settings, let's add the particular ones.
$this->define_my_settings();
}
View
29 backup/moodle2/restore_section_task.class.php
@@ -169,21 +169,36 @@ protected function define_settings() {
// Define section_userinfo. Dependent of:
// - users root setting
- // - section_included setting
+ // - section_included setting.
$settingname = $settingprefix . 'userinfo';
- $selectvalues = array(0=>get_string('no')); // Safer options
- $defaultvalue = false; // Safer default
+ $defaultvalue = false;
if (isset($this->info->settings[$settingname]) && $this->info->settings[$settingname]) { // Only enabled when available
- $selectvalues = array(1=>get_string('yes'), 0=>get_string('no'));
$defaultvalue = true;
}
+
$section_userinfo = new restore_section_userinfo_setting($settingname, base_setting::IS_BOOLEAN, $defaultvalue);
- $section_userinfo->set_ui(new backup_setting_ui_select($section_userinfo, get_string('includeuserinfo','backup'), $selectvalues));
+ if (!$defaultvalue) {
+ // This is a bit hacky, but if there is no user data to restore, then
+ // we replace the standard check-box with a select menu with the
+ // single choice 'No', and the select menu is clever enough that if
+ // there is only one choice, it just displays a static string.
+ //
+ // It would probably be better design to have a special UI class
+ // setting_ui_checkbox_or_no, rather than this hack, but I am not
+ // going to do that today.
+ $section_userinfo->set_ui(new backup_setting_ui_select($section_userinfo, get_string('includeuserinfo','backup'),
+ array(0 => get_string('no'))));
+ } else {
+ $section_userinfo->get_ui()->set_label(get_string('includeuserinfo','backup'));
+ }
+
$this->add_setting($section_userinfo);
- // Look for "users" root setting
+
+ // Look for "users" root setting.
$users = $this->plan->get_setting('users');
$users->add_dependency($section_userinfo);
- // Look for "section_included" section setting
+
+ // Look for "section_included" section setting.
$section_included->add_dependency($section_userinfo);
}
}
View
20 backup/util/ui/base_moodleform.class.php
@@ -96,7 +96,6 @@ function definition() {
* @global moodle_page $PAGE
*/
function definition_after_data() {
- global $PAGE;
$buttonarray=array();
$buttonarray[] = $this->_form->createElement('submit', 'submitbutton', get_string($this->uistage->get_ui()->get_name().'stage'.$this->uistage->get_stage().'action', 'backup'), array('class'=>'proceedbutton'));
if (!$this->uistage->is_first_stage()) {
@@ -106,13 +105,9 @@ function definition_after_data() {
$this->_form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$this->_form->closeHeaderBefore('buttonar');
- $config = new stdClass;
- $config->title = get_string('confirmcancel', 'backup');
- $config->question = get_string('confirmcancelquestion', 'backup');
- $config->yesLabel = get_string('confirmcancelyes', 'backup');
- $config->noLabel = get_string('confirmcancelno', 'backup');
- $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
+ $this->_definition_finalized = true;
}
+
/**
* Closes any open divs
*/
@@ -318,7 +313,17 @@ public function get_element($elementname) {
* Displays the form
*/
public function display() {
+ global $PAGE;
+
$this->require_definition_after_data();
+
+ $config = new stdClass;
+ $config->title = get_string('confirmcancel', 'backup');
+ $config->question = get_string('confirmcancelquestion', 'backup');
+ $config->yesLabel = get_string('confirmcancelyes', 'backup');
+ $config->noLabel = get_string('confirmcancelno', 'backup');
+ $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
+
parent::display();
}
@@ -327,7 +332,6 @@ public function display() {
*/
public function require_definition_after_data() {
if (!$this->_definition_finalized) {
- $this->_definition_finalized = true;
$this->definition_after_data();
}
}
View
4 blocks/community/block_community.php
@@ -71,7 +71,7 @@ function get_content() {
$icon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/group'),
'class' => 'icon', 'alt' => get_string('addcourse', 'block_community')));
$addcourseurl = new moodle_url('/blocks/community/communitycourse.php',
- array('add' => true, 'courseid' => $coursecontext->instanceid));
+ array('add' => true, 'courseid' => $this->page->course->id));
$searchlink = html_writer::tag('a', $icon . '&nbsp;' . get_string('addcourse', 'block_community'),
array('href' => $addcourseurl->out(false)));
$this->content->items[] = $searchlink;
@@ -91,7 +91,7 @@ function get_content() {
'alt' => get_string('removecommunitycourse', 'block_community')));
$deleteurl = new moodle_url('/blocks/community/communitycourse.php',
array('remove' => true,
- 'courseid' => $coursecontext->instanceid,
+ 'courseid' => $this->page->course->id,
'communityid' => $course->id, 'sesskey' => sesskey()));
$deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl));
View
2 blocks/news_items/block_news_items.php
@@ -104,7 +104,7 @@ function get_content() {
$tooltiptext = get_string('rsssubscriberssposts','forum');
}
if (!isloggedin()) {
- $userid = 0;
+ $userid = $CFG->siteguest;
} else {
$userid = $USER->id;
}
View
2 comment/index.php
@@ -29,7 +29,7 @@
require_login();
admin_externalpage_setup('comments', '', null, '', array('pagelayout'=>'report'));
-$context = get_context_instance(CONTEXT_SYSTEM);
+$context = context_system::instance();
require_capability('moodle/comment:delete', $context);
$PAGE->requires->js_init_call('M.core_comment.init_admin', null, true);
View
19 comment/lib.php
@@ -201,12 +201,19 @@ public function __construct(stdClass $options) {
$this->check_permissions();
// load template
- $this->template = html_writer::tag('div', '___picture___', array('class' => 'comment-userpicture'));
- $this->template .= html_writer::start_tag('div', array('class' => 'comment-content'));
- $this->template .= '___name___ - ';
- $this->template .= html_writer::tag('span', '___time___');
- $this->template .= html_writer::tag('div', '___content___');
- $this->template .= html_writer::end_tag('div'); // .comment-content
+ $this->template = html_writer::start_tag('div', array('class' => 'comment-message'));
+
+ $this->template .= html_writer::start_tag('div', array('class' => 'comment-message-meta'));
+
+ $this->template .= html_writer::tag('span', '___picture___', array('class' => 'picture'));
+ $this->template .= html_writer::tag('span', '___name___', array('class' => 'user')) . ' - ';
+ $this->template .= html_writer::tag('span', '___time___', array('class' => 'time'));
+
+ $this->template .= html_writer::end_tag('div'); // .comment-message-meta
+ $this->template .= html_writer::tag('div', '___content___', array('class' => 'text'));
+
+ $this->template .= html_writer::end_tag('div'); // .comment-message
+
if (!empty($this->plugintype)) {
$this->template = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'template', array($this->comment_param), $this->template);
}
View
4 completion/criteria/completion_criteria_course.php
@@ -135,7 +135,7 @@ public function get_title_detailed() {
global $DB;
$prereq = $DB->get_record('course', array('id' => $this->courseinstance));
- $coursecontext = get_context_instance(CONTEXT_COURSE, $prereq->id, MUST_EXIST);
+ $coursecontext = context_course::instance($prereq->id, MUST_EXIST);
$fullname = format_string($prereq->fullname, true, array('context' => $coursecontext));
return shorten_text(urldecode($fullname));
}
@@ -215,7 +215,7 @@ public function get_details($completion) {
$info = new completion_info($course);
$prereq = $DB->get_record('course', array('id' => $this->courseinstance));
- $coursecontext = get_context_instance(CONTEXT_COURSE, $prereq->id, MUST_EXIST);
+ $coursecontext = context_course::instance($prereq->id, MUST_EXIST);
$fullname = format_string($prereq->fullname, true, array('context' => $coursecontext));
$prereq_info = new completion_info($prereq);
View
36 course/format/renderer.php
@@ -205,9 +205,7 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
return array();
}
- if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
- return array();
- }
+ $coursecontext = context_course::instance($course->id);
if ($onsectionpage) {
$baseurl = course_get_url($course, $section->section);
@@ -219,23 +217,25 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
$controls = array();
$url = clone($baseurl);
- if ($section->visible) { // Show the hide/show eye.
- $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
- $url->param('hide', $section->section);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
- 'class' => 'icon hide', 'alt' => $strhidefromothers)),
- array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
- } else {
- $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
- $url->param('show', $section->section);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
- 'class' => 'icon hide', 'alt' => $strshowfromothers)),
- array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
+ if (has_capability('moodle/course:sectionvisibility', $coursecontext)) {
+ if ($section->visible) { // Show the hide/show eye.
+ $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
+ $url->param('hide', $section->section);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
+ 'class' => 'icon hide', 'alt' => $strhidefromothers)),
+ array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
+ } else {
+ $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
+ $url->param('show', $section->section);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
+ 'class' => 'icon hide', 'alt' => $strshowfromothers)),
+ array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
+ }
}
- if (!$onsectionpage) {
+ if (!$onsectionpage && has_capability('moodle/course:update', $coursecontext)) {
$url = clone($baseurl);
if ($section->section > 1) { // Add a arrow to move section up.
$url->param('section', $section->section);
View
30 course/format/topics/renderer.php
@@ -74,9 +74,7 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
return array();
}
- if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
- return array();
- }
+ $coursecontext = context_course::instance($course->id);
if ($onsectionpage) {
$url = course_get_url($course, $section->section);
@@ -86,18 +84,20 @@ protected function section_edit_controls($course, $section, $onsectionpage = fal
$url->param('sesskey', sesskey());
$controls = array();
- if ($course->marker == $section->section) { // Show the "light globe" on/off.
- $url->param('marker', 0);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'),
- 'class' => 'icon ', 'alt' => get_string('markedthistopic'))),
- array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight'));
- } else {
- $url->param('marker', $section->section);
- $controls[] = html_writer::link($url,
- html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'),
- 'class' => 'icon', 'alt' => get_string('markthistopic'))),
- array('title' => get_string('markthistopic'), 'class' => 'editing_highlight'));
+ if (has_capability('moodle/course:setcurrentsection', $coursecontext)) {
+ if ($course->marker == $section->section) { // Show the "light globe" on/off.
+ $url->param('marker', 0);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'),
+ 'class' => 'icon ', 'alt' => get_string('markedthistopic'))),
+ array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight'));
+ } else {
+ $url->param('marker', $section->section);
+ $controls[] = html_writer::link($url,
+ html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'),
+ 'class' => 'icon', 'alt' => get_string('markthistopic'))),
+ array('title' => get_string('markthistopic'), 'class' => 'editing_highlight'));
+ }
}
return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage));
View
16 course/lib.php
@@ -2257,22 +2257,6 @@ function make_categories_options() {
}
/**
- * Gets the name of a course to be displayed when showing a list of courses.
- * By default this is just $course->fullname but user can configure it. The
- * result of this function should be passed through print_string.
- * @param object $course Moodle course object
- * @return string Display name of course (either fullname or short + fullname)
- */
-function get_course_display_name_for_list($course) {
- global $CFG;
- if (!empty($CFG->courselistshortnames)) {
- return $course->shortname . ' ' .$course->fullname;
- } else {
- return $course->fullname;
- }
-}
-
-/**
* Prints the category info in indented fashion
* This function is only used by print_whole_category_list() above
*/
View
5 course/rest.php
@@ -75,19 +75,20 @@
switch ($class) {
case 'section':
- require_capability('moodle/course:update', $coursecontext);
if (!$DB->record_exists('course_sections', array('course'=>$course->id, 'section'=>$id))) {
throw new moodle_exception('AJAX commands.php: Bad Section ID '.$id);
}
switch ($field) {
case 'visible':
+ require_capability('moodle/course:sectionvisibility', $coursecontext);
$resourcestotoggle = set_section_visible($course->id, $id, $value);
echo json_encode(array('resourcestotoggle' => $resourcestotoggle));
break;
case 'move':
+ require_capability('moodle/course:update', $coursecontext);
move_section_to($course, $id, $value);
// See if format wants to do something about it
$libfile = $CFG->dirroot.'/course/format/'.$course->format.'/lib.php';
@@ -178,7 +179,7 @@
case 'course':
switch($field) {
case 'marker':
- require_capability('moodle/course:update', $coursecontext);
+ require_capability('moodle/course:setcurrentsection', $coursecontext);
course_set_marker($course->id, $value);
break;
}
View
4 course/view.php
@@ -162,7 +162,7 @@
set_user_preference('usemodchooser', $modchooser);
}
- if (has_capability('moodle/course:update', $context)) {
+ if (has_capability('moodle/course:sectionvisibility', $context)) {
if ($hide && confirm_sesskey()) {
set_section_visible($course->id, $hide, '0');
redirect($PAGE->url);
@@ -172,7 +172,9 @@
set_section_visible($course->id, $show, '1');
redirect($PAGE->url);
}
+ }
+ if (has_capability('moodle/course:update', $context)) {
if (!empty($section)) {
if (!empty($move) and confirm_sesskey()) {
$destsection = $section + $move;
View
4 enrol/authorize/locallib.php
@@ -58,8 +58,10 @@ function authorize_print_orders($courseid, $userid) {
$searchmenu = array('orderid' => $authstrs->orderid, 'transid' => $authstrs->transid, 'cclastfour' => $authstrs->cclastfour);
$buttons = "<form method='post' action='index.php' autocomplete='off'><div>";
+ $buttons .= html_writer::label(get_string('orderdetails', 'enrol_authorize'), 'menusearchtype', false, array('class' => 'accesshide'));
$buttons .= html_writer::select($searchmenu, 'searchtype', $searchtype, false);
- $buttons .= "<input type='text' size='16' name='searchquery' value='' />";
+ $buttons .= html_writer::label(get_string('search'), 'searchquery', false, array('class' => 'accesshide'));
+ $buttons .= "<input id='searchquery' type='text' size='16' name='searchquery' value='' />";
$buttons .= "<input type='submit' value='$strs->search' />";
$buttons .= "</div></form>";
View
8 enrol/imsenterprise/lib.php
@@ -321,6 +321,9 @@ function process_group_tag($tagcontents) {
if (preg_match('{<description>.*?<short>(.*?)</short>.*?</description>}is', $tagcontents, $matches)) {
$group->shortName = trim($matches[1]);
}
+ if (preg_match('{<description>.*?<full>(.*?)</full>.*?</description>}is', $tagcontents, $matches)) {
+ $group->fulldescription = trim($matches[1]);
+ }
if (preg_match('{<org>.*?<orgunit>(.*?)</orgunit>.*?</org>}is', $tagcontents, $matches)) {
$group->category = trim($matches[1]);
}
@@ -376,7 +379,10 @@ function process_group_tag($tagcontents) {
$courseconfig = get_config('moodlecourse'); // Load Moodle Course shell defaults
$course = new stdClass();
$course->fullname = $group->description;
- $course->shortname = $group->shortName;;
+ $course->shortname = $group->shortName;
+ if (!empty($group->fulldescription)) {
+ $course->summary = format_text($group->fulldescription, FORMAT_HTML);
+ }
$course->idnumber = $coursecode;
$course->format = $courseconfig->format;
$course->visible = $courseconfig->visible;
View
2 enrol/manual/lib.php
@@ -215,6 +215,7 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {
$today = time();
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
$startdateoptions[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
+ $defaultduration = $instance->enrolperiod > 0 ? $instance->enrolperiod / 86400 : '';
$modules = array('moodle-enrol_manual-quickenrolment', 'moodle-enrol_manual-quickenrolment-skin');
$arguments = array(
@@ -224,6 +225,7 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {
'url' => $manager->get_moodlepage()->url->out(false),
'optionsStartDate' => $startdateoptions,
'defaultRole' => $instance->roleid,
+ 'defaultDuration' => $defaultduration,
'disableGradeHistory' => $CFG->disablegradehistory,
'recoverGradesDefault'=> ''
);
View
6 enrol/manual/manage.php
@@ -162,13 +162,13 @@
<div class="enroloptions">
- <p><label for="roleid"><?php print_string('assignrole', 'enrol_manual') ?></label><br />
+ <p><label for="menuroleid"><?php print_string('assignrole', 'enrol_manual') ?></label><br />
<?php echo html_writer::select($roles, 'roleid', $roleid, false); ?></p>
- <p><label for="extendperiod"><?php print_string('enrolperiod', 'enrol') ?></label><br />
+ <p><label for="menuextendperiod"><?php print_string('enrolperiod', 'enrol') ?></label><br />
<?php echo html_writer::select($periodmenu, 'extendperiod', $defaultperiod, $unlimitedperiod); ?></p>
- <p><label for="extendbase"><?php print_string('startingfrom') ?></label><br />
+ <p><label for="menuextendbase"><?php print_string('startingfrom') ?></label><br />
<?php echo html_writer::select($basemenu, 'extendbase', $extendbase, false); ?></p>
</div>
View
1 enrol/self/edit_form.php
@@ -105,6 +105,7 @@ function definition() {
$mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self');
$mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), array('cols'=>'60', 'rows'=>'8'));
+ $mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self');
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
View
6 enrol/self/lang/en/enrol_self.php
@@ -25,6 +25,12 @@
*/
$string['customwelcomemessage'] = 'Custom welcome message';
+$string['customwelcomemessage_help'] = 'A custom welcome message may be added as plain text or Moodle-auto format, including HTML tags and multi-lang tags.
+
+The following placeholders may be included in the message:
+
+* Course name {$a->coursename}
+* Link to user\'s profile page {$a->profileurl}';
$string['defaultrole'] = 'Default role assignment';
$string['defaultrole_desc'] = 'Select role which should be assigned to users during self enrolment';
$string['editenrolment'] = 'Edit enrolment';
View
20 enrol/self/lib.php
@@ -267,22 +267,32 @@ protected function email_welcome_message($instance, $user) {
global $CFG, $DB;
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
+ $context = context_course::instance($course->id);
$a = new stdClass();
- $a->coursename = format_string($course->fullname);
+ $a->coursename = format_string($course->fullname, true, array('context'=>$context));
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
if (trim($instance->customtext1) !== '') {
$message = $instance->customtext1;
$message = str_replace('{$a->coursename}', $a->coursename, $message);
$message = str_replace('{$a->profileurl}', $a->profileurl, $message);
+ if (strpos($message, '<') === false) {
+ // Plain text only.
+ $messagetext = $message;
+ $messagehtml = text_to_html($messagetext, null, false, true);
+ } else {
+ // This is most probably the tag/newline soup known as FORMAT_MOODLE.
+ $messagehtml = format_text($message, FORMAT_MOODLE, array('context'=>$context, 'para'=>false, 'newlines'=>true, 'filter'=>true));
+ $messagetext = html_to_text($messagehtml);
+ }
} else {
- $message = get_string('welcometocoursetext', 'enrol_self', $a);
+ $messagetext = get_string('welcometocoursetext', 'enrol_self', $a);
+ $messagehtml = text_to_html($messagetext, null, false, true);
}
- $subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname));
+ $subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname, true, array('context'=>$context)));
- $context = context_course::instance($course->id);
$rusers = array();
if (!empty($CFG->coursecontact)) {
$croles = explode(',', $CFG->coursecontact);
@@ -295,7 +305,7 @@ protected function email_welcome_message($instance, $user) {
}
//directly emailing welcome message rather than using messaging
- email_to_user($user, $contact, $subject, $message);
+ email_to_user($user, $contact, $subject, $messagetext, $messagehtml);
}
/**
View
2 file.php
@@ -83,7 +83,7 @@
}
}
-$context = get_context_instance(CONTEXT_COURSE, $course->id);
+$context = context_course::instance($course->id);
$fs = get_file_storage();
View
3 filter/algebra/algebradebug.php
@@ -280,7 +280,8 @@ function slasharguments($texexp, $md5) {
<form action="algebradebug.php" method="get"
target="inlineframe">
<center>
- <input type="text" name="algebra" size="50"
+ <label for="algebra" class="accesshide"><?php print_string('algebraicexpression', 'filter_algebra'); ?></label>
+ <input type="text" id="algebra" name="algebra" size="50"
value="sin(z)/(x^2+y^2)" />
</center>
<ol>
View
1 filter/algebra/lang/en/filter_algebra.php
@@ -24,3 +24,4 @@
*/
$string['filtername'] = 'Algebra notation';
+$string['algebraicexpression'] = 'Algebraic expression';
View
5 filter/manage.php
@@ -181,7 +181,10 @@
} else {
$activechoices[TEXTFILTER_INHERIT] = $strdefaultoff;
}
- $row[] = html_writer::select($activechoices, str_replace('/', '_', $filter), $filterinfo->localstate, false);
+ $filtername = str_replace('/', '_', $filter);
+ $select = html_writer::label($filterinfo->localstate, 'menu'. $filtername, false, array('class' => 'accesshide'));
+ $select .= html_writer::select($activechoices, $filtername, $filterinfo->localstate, false);
+ $row[] = $select;
// Settings link, if required
if ($settingscol) {
View
2 grade/edit/outcome/edit.php
@@ -96,7 +96,7 @@
if (!$courseid) {
require_once $CFG->libdir.'/adminlib.php';
- admin_externalpage_setup('scales');
+ admin_externalpage_setup('outcomes');
}
// default return url
View
1 grade/edit/tree/calculation.php
@@ -184,6 +184,7 @@ function get_grade_tree(&$gtree, $element, $current_itemid=null, $errors=null) {
$name .= '<div class="error"><span class="error">' . $errors[$grade_item->id].'</span><br />'."\n";
$closingdiv = "</div>\n";
}
+ $name .= '<label class="accesshide" for="id_idnumber_' . $grade_item->id . '">' . get_string('gradeitems', 'grades') .'</label>';
$name .= '<input class="idnumber" id="id_idnumber_'.$grade_item->id.'" type="text" name="idnumbers['.$grade_item->id.']" />' . "\n";
$name .= $closingdiv;
}
View
2 grade/edit/tree/index.php
@@ -342,8 +342,8 @@
if (!$moving && count($grade_edit_tree->categories) > 1) {
echo '<br /><br />';
echo '<input type="hidden" name="bulkmove" value="0" id="bulkmoveinput" />';
- echo get_string('moveselectedto', 'grades') . ' ';
$attributes = array('id'=>'menumoveafter');
+ echo html_writer::label(get_string('moveselectedto', 'grades'), 'menumoveafter');
echo html_writer::select($grade_edit_tree->categories, 'moveafter', '', array(''=>'choosedots'), $attributes);
$OUTPUT->add_action_handler(new component_action('change', 'submit_bulk_move'), 'menumoveafter');
echo '<div id="noscriptgradetreeform" class="hiddenifjs">
View
3 grade/edit/tree/lib.php
@@ -673,7 +673,8 @@ public function get_category_cell($category, $levelclass, $params) {
} else {
$attributes = array();
$attributes['id'] = 'aggregation_'.$category->id;
- $aggregation = html_writer::select($options, 'aggregation_'.$category->id, $category->aggregation, null, $attributes);
+ $aggregation = html_writer::label(get_string('aggregation', 'grades'), 'aggregation_'.$category->id, false, array('class' => 'accesshide'));
+ $aggregation .= html_writer::select($options, 'aggregation_'.$category->id, $category->aggregation, null, $attributes);
$action = new component_action('change', 'update_category_aggregation', array('courseid' => $params['id'], 'category' => $category->id, 'sesskey' => sesskey()));
$OUTPUT->add_action_handler($action, 'aggregation_'.$category->id);
}
View
52 grade/export/txt/grade_export_txt.php
@@ -16,6 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
require_once($CFG->dirroot.'/grade/export/lib.php');
+require_once($CFG->libdir . '/csvlib.class.php');
class grade_export_txt extends grade_export {
@@ -54,46 +55,25 @@ public function print_grades() {
$strgrades = get_string('grades');
$profilefields = grade_helper::get_user_profile_fields($this->course->id, $this->usercustomfields);
- switch ($this->separator) {
- case 'comma':
- $separator = ",";
- break;
- case 'tab':
- default:
- $separator = "\t";
- }
-
- // Print header to force download
- if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
- @header('Cache-Control: max-age=10');
- @header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
- @header('Pragma: ');
- } else { //normal http - prevent caching at all cost
- @header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
- @header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
- @header('Pragma: no-cache');
- }
- header("Content-Type: application/download\n");
$shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
$downloadfilename = clean_filename("$shortname $strgrades");
- header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
+ $csvexport = new csv_export_writer($this->separator);
+ $csvexport->set_filename($downloadfilename);
// Print names of all the fields
- $fieldfullnames = array();
+ $exporttitle = array();
foreach ($profilefields as $field) {
- $fieldfullnames[] = $field->fullname;
+ $exporttitle[] = $field->fullname;
}
- echo implode($separator, $fieldfullnames);
+ // Add a feedback column.
foreach ($this->columns as $grade_item) {
- echo $separator.$this->format_column_name($grade_item);
-
- // Add a feedback column.
+ $exporttitle[] = $this->format_column_name($grade_item);
if ($this->export_feedback) {
- echo $separator.$this->format_column_name($grade_item, true);
+ $exporttitle[] = $this->format_column_name($grade_item, true);
}
}
- echo "\n";
+ $csvexport->add_data($exporttitle);
// Print all the lines of data.
$geub = new grade_export_update_buffer();
@@ -103,31 +83,29 @@ public function print_grades() {
$gui->init();
while ($userdata = $gui->next_user()) {
+ $exportdata = array();
$user = $userdata->user;
- $items = array();
foreach ($profilefields as $field) {
$fieldvalue = grade_helper::get_user_field_value($user, $field);
- $items[] = $fieldvalue;