mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
Merge branch 'MDL-41690-master' of git://github.com/danpoltawski/moodle
Conflicts: course/dnduploadlib.php
This commit is contained in:
commit
5490662ade
@ -114,11 +114,11 @@ class block_recent_activity_renderer extends plugin_renderer_base {
|
||||
break;
|
||||
case 'add mod':
|
||||
$text = get_string('added', 'moodle', $cm->modfullname). '<br />'.
|
||||
html_writer::link($cm->get_url(), format_string($cm->name, true));
|
||||
html_writer::link($cm->url, format_string($cm->name, true));
|
||||
break;
|
||||
case 'update mod':
|
||||
$text = get_string('updated', 'moodle', $cm->modfullname). '<br />'.
|
||||
html_writer::link($cm->get_url(), format_string($cm->name, true));
|
||||
html_writer::link($cm->url, format_string($cm->name, true));
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
|
@ -44,7 +44,7 @@ class block_site_main_menu extends block_list {
|
||||
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||
$instancename = $cm->get_formatted_name();
|
||||
|
||||
if (!($url = $cm->get_url())) {
|
||||
if (!($url = $cm->url)) {
|
||||
$this->content->items[] = $content;
|
||||
$this->content->icons[] = '';
|
||||
} else {
|
||||
@ -123,7 +123,7 @@ class block_site_main_menu extends block_list {
|
||||
$instancename = $mod->get_formatted_name();
|
||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||
|
||||
if (!($url = $mod->get_url())) {
|
||||
if (!($url = $mod->url)) {
|
||||
$this->content->items[] = $content . $editbuttons;
|
||||
$this->content->icons[] = '';
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ class block_social_activities extends block_list {
|
||||
$content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
|
||||
$instancename = $cm->get_formatted_name();
|
||||
|
||||
if (!($url = $cm->get_url())) {
|
||||
if (!($url = $cm->url)) {
|
||||
$this->content->items[] = $content;
|
||||
$this->content->icons[] = '';
|
||||
} else {
|
||||
@ -110,7 +110,7 @@ class block_social_activities extends block_list {
|
||||
|
||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||
|
||||
if (!($url = $mod->get_url())) {
|
||||
if (!($url = $mod->url)) {
|
||||
$this->content->items[] = $content . $editbuttons;
|
||||
$this->content->icons[] = '';
|
||||
} else {
|
||||
|
@ -148,15 +148,15 @@ class core_course_external extends external_api {
|
||||
$modcontext = context_module::instance($cm->id);
|
||||
|
||||
if (!empty($cm->showdescription) or $cm->modname == 'label') {
|
||||
// We want to use the external format. However from reading get_formatted_content(), get_content() format is always FORMAT_HTML.
|
||||
list($module['description'], $descriptionformat) = external_format_text($cm->get_content(),
|
||||
// We want to use the external format. However from reading get_formatted_content(), $cm->content format is always FORMAT_HTML.
|
||||
list($module['description'], $descriptionformat) = external_format_text($cm->content,
|
||||
FORMAT_HTML, $modcontext->id, $cm->modname, 'intro', $cm->id);
|
||||
}
|
||||
|
||||
//url of the module
|
||||
$url = $cm->get_url();
|
||||
$url = $cm->url;
|
||||
if ($url) { //labels don't have url
|
||||
$module['url'] = $cm->get_url()->out(false);
|
||||
$module['url'] = $url->out(false);
|
||||
}
|
||||
|
||||
$canviewhidden = has_capability('moodle/course:viewhiddenactivities',
|
||||
|
@ -100,7 +100,7 @@ class format_singleactivity extends format_base {
|
||||
if (!$cm->uservisible) {
|
||||
return null;
|
||||
}
|
||||
$action = $cm->get_url();
|
||||
$action = $cm->url;
|
||||
if (!$action) {
|
||||
// Do not add to navigation activity without url (i.e. labels).
|
||||
return null;
|
||||
@ -412,13 +412,13 @@ class format_singleactivity extends format_base {
|
||||
// Student views an empty course page.
|
||||
return;
|
||||
}
|
||||
} else if (!$cm->uservisible || !$cm->get_url()) {
|
||||
} else if (!$cm->uservisible || !$cm->url) {
|
||||
// Activity is set but not visible to current user or does not have url.
|
||||
// Display course page (either empty or with availability restriction info).
|
||||
return;
|
||||
} else {
|
||||
// Everything is set up and accessible, redirect to the activity page!
|
||||
redirect($cm->get_url());
|
||||
redirect($cm->url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
// nothing to be displayed to the user
|
||||
return $output;
|
||||
}
|
||||
$url = $mod->get_url();
|
||||
$url = $mod->url;
|
||||
if (!$url) {
|
||||
return $output;
|
||||
}
|
||||
@ -793,7 +793,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
|
||||
// Get on-click attribute value if specified and decode the onclick - it
|
||||
// has already been encoded for display (puke).
|
||||
$onclick = htmlspecialchars_decode($mod->get_on_click(), ENT_QUOTES);
|
||||
$onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES);
|
||||
|
||||
$groupinglabel = '';
|
||||
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', context_course::instance($mod->course))) {
|
||||
@ -851,7 +851,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$textclasses .= ' dimmed_text';
|
||||
}
|
||||
if ($mod->get_url()) {
|
||||
if ($mod->url) {
|
||||
if ($content) {
|
||||
// If specified, display extra content after link.
|
||||
$output = html_writer::tag('div', $content, array('class' =>
|
||||
@ -923,7 +923,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
|
||||
$output = '';
|
||||
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
|
||||
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->get_extra_classes();
|
||||
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;
|
||||
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
|
||||
}
|
||||
return $output;
|
||||
@ -937,7 +937,6 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
*
|
||||
* This function calls:
|
||||
* {@link core_course_renderer::course_section_cm_name()}
|
||||
* {@link cm_info::get_after_link()}
|
||||
* {@link core_course_renderer::course_section_cm_text()}
|
||||
* {@link core_course_renderer::course_section_cm_availability()}
|
||||
* {@link core_course_renderer::course_section_cm_completion()}
|
||||
@ -1005,7 +1004,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
// Module can put text after the link (e.g. forum unread)
|
||||
$output .= $mod->get_after_link();
|
||||
$output .= $mod->afterlink;
|
||||
|
||||
// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.
|
||||
$output .= html_writer::end_tag('div'); // .activityinstance
|
||||
@ -1018,7 +1017,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
// it should work similarly (at least in terms of ordering) to an
|
||||
// activity.
|
||||
$contentpart = $this->course_section_cm_text($mod, $displayoptions);
|
||||
$url = $mod->get_url();
|
||||
$url = $mod->url;
|
||||
if (empty($url)) {
|
||||
$output .= $contentpart;
|
||||
}
|
||||
@ -1027,7 +1026,7 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
if ($this->page->user_is_editing()) {
|
||||
$editactions = course_get_cm_edit_actions($mod, $mod->indent, $sectionreturn);
|
||||
$modicons .= ' '. $this->course_section_cm_edit_actions($editactions, $mod, $displayoptions);
|
||||
$modicons .= $mod->get_after_edit_icons();
|
||||
$modicons .= $mod->afterediticons;
|
||||
}
|
||||
|
||||
$modicons .= $this->course_section_cm_completion($course, $completioninfo, $mod, $displayoptions);
|
||||
|
@ -600,13 +600,13 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
||||
foreach($firstsection['modules'] as $module) {
|
||||
if ($module['id'] == $forumcm->id and $module['modname'] == 'forum') {
|
||||
$cm = $modinfo->cms[$forumcm->id];
|
||||
$formattedtext = format_text($cm->get_content(), FORMAT_HTML,
|
||||
$formattedtext = format_text($cm->content, FORMAT_HTML,
|
||||
array('noclean' => true, 'para' => false, 'filter' => false));
|
||||
$this->assertEquals($formattedtext, $module['description']);
|
||||
$testexecuted = $testexecuted + 1;
|
||||
} else if ($module['id'] == $labelcm->id and $module['modname'] == 'label') {
|
||||
$cm = $modinfo->cms[$labelcm->id];
|
||||
$formattedtext = format_text($cm->get_content(), FORMAT_HTML,
|
||||
$formattedtext = format_text($cm->content, FORMAT_HTML,
|
||||
array('noclean' => true, 'para' => false, 'filter' => false));
|
||||
$this->assertEquals($formattedtext, $module['description']);
|
||||
$testexecuted = $testexecuted + 1;
|
||||
|
@ -1167,7 +1167,17 @@ class cm_info implements IteratorAggregate {
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
global $CFG;
|
||||
|
||||
if (in_array($name, self::$standardmethods)) {
|
||||
if ($CFG->debugdeveloper) {
|
||||
if ($alternative = array_search($name, self::$standardproperties)) {
|
||||
// All standard methods do not have arguments anyway.
|
||||
debugging("cm_info::$name() is deprecated, please use the property cm_info->$alternative instead.", DEBUG_DEVELOPER);
|
||||
} else {
|
||||
debugging("cm_info::$name() is deprecated and should not be used.", DEBUG_DEVELOPER);
|
||||
}
|
||||
}
|
||||
// All standard methods do not have arguments anyway.
|
||||
return $this->$name();
|
||||
}
|
||||
|
@ -1860,13 +1860,13 @@ class global_navigation extends navigation_node {
|
||||
$activity->hidden = (!$cm->visible);
|
||||
$activity->modname = $cm->modname;
|
||||
$activity->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
$activity->onclick = $cm->get_on_click();
|
||||
$url = $cm->get_url();
|
||||
$activity->onclick = $cm->onclick;
|
||||
$url = $cm->url;
|
||||
if (!$url) {
|
||||
$activity->url = null;
|
||||
$activity->display = false;
|
||||
} else {
|
||||
$activity->url = $cm->get_url()->out();
|
||||
$activity->url = $url->out();
|
||||
$activity->display = $cm->uservisible ? true : false;
|
||||
if (self::module_extends_navigation($cm->modname)) {
|
||||
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
|
||||
@ -2011,7 +2011,7 @@ class global_navigation extends navigation_node {
|
||||
} else {
|
||||
$icon = new pix_icon('icon', get_string('modulename', $cm->modname), $cm->modname);
|
||||
}
|
||||
$url = $cm->get_url();
|
||||
$url = $cm->url;
|
||||
$activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon);
|
||||
$activitynode->title(get_string('modulename', $cm->modname));
|
||||
$activitynode->hidden = (!$cm->visible);
|
||||
|
@ -657,4 +657,42 @@ class core_modinfolib_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cm->uservisible);
|
||||
$this->assertTrue($cm->is_user_access_restricted_by_capability());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that various deprecated cm_info methods are throwing debuggign messages
|
||||
*/
|
||||
public function test_cm_info_property_deprecations() {
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course( array('format' => 'topics', 'numsections' => 3),
|
||||
array('createsections' => true));
|
||||
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
|
||||
$cm = get_fast_modinfo($course->id)->instances['forum'][$forum->id];
|
||||
|
||||
$cm->get_url();
|
||||
$this->assertDebuggingCalled('cm_info::get_url() is deprecated, please use the property cm_info->url instead.');
|
||||
|
||||
$cm->get_content();
|
||||
$this->assertDebuggingCalled('cm_info::get_content() is deprecated, please use the property cm_info->content instead.');
|
||||
|
||||
$cm->get_extra_classes();
|
||||
$this->assertDebuggingCalled('cm_info::get_extra_classes() is deprecated, please use the property cm_info->extraclasses instead.');
|
||||
|
||||
$cm->get_on_click();
|
||||
$this->assertDebuggingCalled('cm_info::get_on_click() is deprecated, please use the property cm_info->onclick instead.');
|
||||
|
||||
$cm->get_custom_data();
|
||||
$this->assertDebuggingCalled('cm_info::get_custom_data() is deprecated, please use the property cm_info->customdata instead.');
|
||||
|
||||
$cm->get_after_link();
|
||||
$this->assertDebuggingCalled('cm_info::get_after_link() is deprecated, please use the property cm_info->afterlink instead.');
|
||||
|
||||
$cm->get_after_edit_icons();
|
||||
$this->assertDebuggingCalled('cm_info::get_after_edit_icons() is deprecated, please use the property cm_info->afterediticons instead.');
|
||||
|
||||
$cm->obtain_dynamic_data();
|
||||
$this->assertDebuggingCalled('cm_info::obtain_dynamic_data() is deprecated and should not be used.');
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ DEPRECATIONS:
|
||||
* mod_feedback\event\instances_list_viewed has been deprecated. Please use mod_feedback\event\course_module_instance_list_viewed instead.
|
||||
* mod_page\event\instances_list_viewed has been deprecated. Please use mod_page\event\course_module_instance_list_viewed instead.
|
||||
* The constants FRONTPAGECOURSELIST, FRONTPAGETOPICONLY & FRONTPAGECOURSELIMIT have been removed.
|
||||
* Various cm_info methods have been deprecated in favour of their read-only properties (get_url(), get_content(), get_extra_classes(),
|
||||
get_on_click(), get_custom_data(), get_after_link, get_after_edit_icons)
|
||||
|
||||
YUI:
|
||||
* The lightbox attribute for moodle-core-notification-dialogue has been
|
||||
|
@ -460,7 +460,7 @@ function folder_get_coursemodule_info($cm) {
|
||||
* @param cm_info $cm
|
||||
*/
|
||||
function folder_cm_info_dynamic(cm_info $cm) {
|
||||
if ($cm->get_custom_data()) {
|
||||
if ($cm->customdata) {
|
||||
// the field 'customdata' is not empty IF AND ONLY IF we display contens inline
|
||||
$cm->set_no_view_link();
|
||||
}
|
||||
@ -474,12 +474,12 @@ function folder_cm_info_dynamic(cm_info $cm) {
|
||||
*/
|
||||
function folder_cm_info_view(cm_info $cm) {
|
||||
global $PAGE;
|
||||
if ($cm->uservisible && $cm->get_custom_data() &&
|
||||
if ($cm->uservisible && $cm->customdata &&
|
||||
has_capability('mod/folder:view', $cm->context)) {
|
||||
// Restore folder object from customdata.
|
||||
// Note the field 'customdata' is not empty IF AND ONLY IF we display contens inline.
|
||||
// Otherwise the content is default.
|
||||
$folder = $cm->get_custom_data();
|
||||
$folder = $cm->customdata;
|
||||
$folder->id = (int)$cm->instance;
|
||||
$folder->course = (int)$cm->course;
|
||||
$folder->display = FOLDER_DISPLAY_INLINE;
|
||||
|
@ -8009,7 +8009,7 @@ function forum_cm_info_view(cm_info $cm) {
|
||||
|
||||
if (forum_tp_can_track_forums()) {
|
||||
if ($unread = forum_tp_count_forum_unread_posts($cm, $cm->get_course())) {
|
||||
$out = '<span class="unread"> <a href="' . $cm->get_url() . '">';
|
||||
$out = '<span class="unread"> <a href="' . $cm->url . '">';
|
||||
if ($unread == 1) {
|
||||
$out .= get_string('unreadpostsone', 'forum');
|
||||
} else {
|
||||
|
@ -288,7 +288,7 @@ function resource_get_coursemodule_info($coursemodule) {
|
||||
* @param cm_info $cm Course module information
|
||||
*/
|
||||
function resource_cm_info_view(cm_info $cm) {
|
||||
$details = $cm->get_custom_data();
|
||||
$details = $cm->customdata;
|
||||
if ($details) {
|
||||
$cm->set_after_link(' ' . html_writer::tag('span', $details,
|
||||
array('class' => 'resourcelinkdetails')));
|
||||
|
Loading…
x
Reference in New Issue
Block a user