Skip to content

Commit

Permalink
MDL-41690 course: remove use of deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jan 6, 2014
1 parent 07e78d9 commit 73ee2fd
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 35 deletions.
4 changes: 2 additions & 2 deletions blocks/recent_activity/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ protected function structural_change($change) {
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 '';
Expand Down
4 changes: 2 additions & 2 deletions blocks/site_main_menu/block_site_main_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function get_content() {
$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 {
Expand Down Expand Up @@ -123,7 +123,7 @@ function get_content() {
$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 {
Expand Down
4 changes: 2 additions & 2 deletions blocks/social_activities/block_social_activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function get_content() {
$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 {
Expand Down Expand Up @@ -110,7 +110,7 @@ function get_content() {

$linkcss = $mod->visible ? '' : ' class="dimmed" ';

if (!($url = $mod->get_url())) {
if (!($url = $mod->url)) {
$this->content->items[] = $content . $editbuttons;
$this->content->icons[] = '';
} else {
Expand Down
6 changes: 3 additions & 3 deletions course/dnduploadlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,15 +729,15 @@ protected function send_response($mod) {
$resp->icon = $mod->get_icon_url()->out();
$resp->name = $mod->name;
if ($mod->has_view()) {
$resp->link = $mod->get_url()->out();
$resp->link = $mod->url->out();
} else {
$resp->link = null;
}
$resp->content = $mod->get_content();
$resp->content = $mod->content;
$resp->elementid = 'module-'.$mod->id;
$actions = course_get_cm_edit_actions($mod, 0, $mod->sectionnum);
$resp->commands = ' '. $courserenderer->course_section_cm_edit_actions($actions, $mod);
$resp->onclick = $mod->get_on_click();
$resp->onclick = $mod->onclick;
$resp->visible = $mod->visible;

// If using groupings, then display grouping name.
Expand Down
8 changes: 4 additions & 4 deletions course/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ public static function get_course_contents($courseid, $options = array()) {
$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',
Expand Down
6 changes: 3 additions & 3 deletions course/format/singleactivity/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function navigation_add_activity(navigation_node $node, $cm) {
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;
Expand Down Expand Up @@ -412,13 +412,13 @@ public function page_set_course(moodle_page $page) {
// 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);
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions course/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ public function course_section_cm_name(cm_info $mod, $displayoptions = array())
// nothing to be displayed to the user
return $output;
}
$url = $mod->get_url();
$url = $mod->url;
if (!$url) {
return $output;
}
Expand Down Expand Up @@ -793,7 +793,7 @@ public function course_section_cm_name(cm_info $mod, $displayoptions = array())

// 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))) {
Expand Down Expand Up @@ -851,7 +851,7 @@ public function course_section_cm_text(cm_info $mod, $displayoptions = array())
} 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' =>
Expand Down Expand Up @@ -923,7 +923,7 @@ public function course_section_cm_availability(cm_info $mod, $displayoptions = a
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;
Expand All @@ -937,7 +937,6 @@ public function course_section_cm_list_item($course, &$completioninfo, cm_info $
*
* 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()}
Expand Down Expand Up @@ -1005,7 +1004,7 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect
}

// 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
Expand All @@ -1018,7 +1017,7 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect
// 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;
}
Expand All @@ -1027,7 +1026,7 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect
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);
Expand Down
4 changes: 2 additions & 2 deletions course/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,13 @@ public function test_get_course_contents() {
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1860,13 +1860,13 @@ protected function generate_sections_and_activities(stdClass $course) {
$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;
Expand Down Expand Up @@ -2011,7 +2011,7 @@ protected function load_stealth_activity(navigation_node $coursenode, $modinfo)
} 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);
Expand Down
6 changes: 3 additions & 3 deletions mod/folder/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion mod/resource/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
Expand Down

0 comments on commit 73ee2fd

Please sign in to comment.