Skip to content

Commit

Permalink
Merge branch MDL-29186-master of git://github.com/samhemelryk/moodle
Browse files Browse the repository at this point in the history
- resolved conflicts, minor whitespace and fixed quote.
- note: textlib_get_instance() is already deprecated
  • Loading branch information
Aparup Banerjee committed Sep 13, 2011
2 parents 7eae2c5 + 91d284c commit d1e3624
Show file tree
Hide file tree
Showing 31 changed files with 101 additions and 54 deletions.
8 changes: 6 additions & 2 deletions admin/handlevirus.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@
$action = clam_handle_infected_file($file,$log->userid,true);
clam_replace_infected_file($file);

list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid";
$course = $DB->get_record_sql($sql, array('courseid' => $log->course));
context_instance_preload($course);

$user = $DB->get_record("user", array("id"=>$log->userid));
$course = $DB->get_record("course", array("id"=>$log->course));
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
$a->date = userdate($log->time);

$a->action = $action;
$a->course = $course->fullname;
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$a->user = fullname($user);

notify_user($user,$subject,$a);
Expand Down
18 changes: 14 additions & 4 deletions admin/oacleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ function online_assignment_cleanup($output=false) {


/// get a list of all courses on this site
$courses = $DB->get_records('course');
list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT c.* $ctxselect FROM {course} c $ctxjoin";
$courses = $DB->get_records_sql($sql);

/// cycle through each course
foreach ($courses as $course) {
context_instance_preload($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);

$fullname = empty($course->fullname) ? 'Course: '.$course->id : $course->fullname;
if (empty($course->fullname)) {
$fullname = get_string('course').': '.$course->id;
} else {
$fullname = format_string($course->fullname, true, array('context' => $context));
}
if ($output) echo $OUTPUT->heading($fullname);

/// retrieve a list of sections beyond what is currently being shown
Expand Down Expand Up @@ -96,7 +104,9 @@ function online_assignment_cleanup($output=false) {

/// grab the section record
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'<br />';
if ($output) {
echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. $fullname .'<br />';
}
continue;
}

Expand All @@ -117,7 +127,7 @@ function online_assignment_cleanup($output=false) {

/// grab the old section record
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$course->fullname.'<br />';
if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$fullname.'<br />';
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion admin/registration/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function definition() {
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
if ($sitename === false) {
$sitename = $site->fullname;
$sitename = format_string($site->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
}
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
if ($sitedescription === false) {
Expand Down
4 changes: 2 additions & 2 deletions backup/util/ui/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public function render_restore_course_search(restore_course_search $component) {
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$course->id)),
format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
$course->fullname
format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))
);
$table->data[] = $row;
}
Expand Down Expand Up @@ -588,7 +588,7 @@ public function render_import_course_search(import_course_search $component) {
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'importid', 'value'=>$course->id)),
format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
$course->fullname
format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))
);
$table->data[] = $row;
}
Expand Down
2 changes: 1 addition & 1 deletion blog/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function definition() {
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$a = new stdClass();
$a->coursename = $course->fullname;
$a->coursename = format_string($course->fullname, true, array('context' => $context));
$contextid = $context->id;
} else {
$sql = 'SELECT fullname FROM {course} cr LEFT JOIN {context} ct ON ct.instanceid = cr.id WHERE ct.id = ?';
Expand Down
6 changes: 3 additions & 3 deletions blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

$a = new stdClass();
$a->user = fullname($user);
$a->course = $course->fullname;
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesbyuseraboutcourse', 'blog', $a);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
Expand All @@ -870,7 +870,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

$a = new stdClass();
$a->group = $group->name;
$a->course = $course->fullname;
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesbygroupaboutcourse', 'blog', $a);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
Expand Down Expand Up @@ -927,7 +927,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesabout', 'blog', $course->fullname);
$headers['heading'] = get_string('blogentriesabout', 'blog', format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid))));
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewblogentries', 'blog', $a);
$blogurl->remove_params(array('userid'));
Expand Down
3 changes: 2 additions & 1 deletion blog/rsslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ function blog_rss_get_feed($context, $args) {
break;
case 'course':
$info = $DB->get_field('course', 'fullname', array('id'=>$id));
$info = format_string($info, true, array('context' => get_context_instance(CONTEXT_COURSE, $id)));
break;
case 'site':
$info = $SITE->fullname;
$info = format_string($SITE->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
break;
case 'group':
$group = groups_get_group($id);
Expand Down
11 changes: 9 additions & 2 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,12 @@ function calendar_add_event_metadata($event) {
}
$icon = $OUTPUT->pix_url('icon', $event->modulename) . '';

$context = get_context_instance(CONTEXT_COURSE, $module->course);
$fullname = format_string($coursecache[$module->course]->fullname, true, array('context' => $context));

$event->icon = '<img height="16" width="16" src="'.$icon.'" alt="'.$eventtype.'" title="'.$modulename.'" style="vertical-align: middle;" />';
$event->referer = '<a href="'.$CFG->wwwroot.'/mod/'.$event->modulename.'/view.php?id='.$module->id.'">'.$event->name.'</a>';
$event->courselink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$module->course.'">'.$coursecache[$module->course]->fullname.'</a>';
$event->courselink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$module->course.'">'.$fullname.'</a>';
$event->cmid = $module->id;


Expand All @@ -548,8 +551,12 @@ function calendar_add_event_metadata($event) {
$event->cssclass = 'calendar_event_global';
} else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) { // Course event
calendar_get_course_cached($coursecache, $event->courseid);

$context = get_context_instance(CONTEXT_COURSE, $event->courseid);
$fullname = format_string($coursecache[$event->courseid]->fullname, true, array('context' => $context));

$event->icon = '<img height="16" width="16" src="'.$OUTPUT->pix_url('c/course') . '" alt="'.get_string('courseevent', 'calendar').'" style="vertical-align: middle;" />';
$event->courselink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$event->courseid.'">'.$coursecache[$event->courseid]->fullname.'</a>';
$event->courselink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$event->courseid.'">'.$fullname.'</a>';
$event->cssclass = 'calendar_event_course';
} else if ($event->groupid) { // Group event
$event->icon = '<img height="16" width="16" src="'.$OUTPUT->pix_url('c/group') . '" alt="'.get_string('groupevent', 'calendar').'" style="vertical-align: middle;" />';
Expand Down
2 changes: 1 addition & 1 deletion course/completion_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function definition() {
$selectbox = array();
$selected = array();
foreach ($courses as $c) {
$selectbox[$c->id] = $list[$c->category] . ' / ' . s($c->fullname);
$selectbox[$c->id] = $list[$c->category] . ' / ' . format_string($c->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $c->id)));

// If already selected
if ($c->selected) {
Expand Down
5 changes: 4 additions & 1 deletion course/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
print_error("invalidcourseid", 'error', '', $id);
}

$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);

if (!can_delete_course($id)) {
print_error('cannotdeletecourse');
}
Expand All @@ -45,7 +47,8 @@
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();

$message = "$strdeletecoursecheck<br /><br />" . format_string($course->fullname) . " (" . $courseshortname . ")";
$message = "$strdeletecoursecheck<br /><br />" . format_string($course->fullname, true, array('context' => $coursecontext)) . " (" . $courseshortname . ")";

echo $OUTPUT->confirm($message, "delete.php?id=$course->id&delete=".md5($course->timemodified), "category.php?id=$course->category");

echo $OUTPUT->footer();
Expand Down
11 changes: 6 additions & 5 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,13 +861,14 @@ function print_overview($courses, array $remote_courses=array()) {
}
}
foreach ($courses as $course) {
$fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
echo $OUTPUT->box_start('coursebox');
$attributes = array('title' => s($course->fullname));
$attributes = array('title' => s($fullname));
if (empty($course->visible)) {
$attributes['class'] = 'dimmed';
}
echo $OUTPUT->heading(html_writer::link(
new moodle_url('/course/view.php', array('id' => $course->id)), format_string($course->fullname), $attributes), 3);
new moodle_url('/course/view.php', array('id' => $course->id)), $fullname, $attributes), 3);
if (array_key_exists($course->id,$htmlarray)) {
foreach ($htmlarray[$course->id] as $modname => $html) {
echo $html;
Expand Down Expand Up @@ -3276,8 +3277,8 @@ function course_format_name ($course,$max=100) {

$context = get_context_instance(CONTEXT_COURSE, $course->id);
$shortname = format_string($course->shortname, true, array('context' => $context));

$str = $shortname.': '. $course->fullname;
$fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$str = $shortname.': '. $fullname;
if (textlib::strlen($str) <= $max) {
return $str;
}
Expand Down Expand Up @@ -4247,7 +4248,7 @@ public function approve() {
$this->delete();

$a = new stdClass();
$a->name = $course->fullname;
$a->name = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$a->url = $CFG->wwwroot.'/course/view.php?id=' . $course->id;
$this->notify($user, $USER, 'courserequestapproved', get_string('courseapprovedsubject'), get_string('courseapprovedemail2', 'moodle', $a));

Expand Down
2 changes: 1 addition & 1 deletion course/report/completion/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ function csv_quote($value) {

// Display icon
$iconlink = $CFG->wwwroot.'/course/view.php?id='.$criterion->courseinstance;
$icontitle = $crs->fullname;
$icontitle = format_string($crs->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $crs->id, MUST_EXIST)));
$iconalt = format_string($crs->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $crs->id)));
break;

Expand Down
5 changes: 3 additions & 2 deletions course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@

// Get course info
$c_course = $DB->get_record('course', array('id' => $c_info->course_id));
$course_name = $c_course->fullname;
$course_context = get_context_instance(CONTEXT_COURSE, $c_course->id, MUST_EXIST);
$course_name = format_string($c_course->fullname, true, array('context' => $course_context));

// Get completions
$completions = $c_info->get_completions($user->id);
Expand Down Expand Up @@ -541,7 +542,7 @@

// Display course name on first row
if ($first_row) {
echo '<tr><td class="c0"><a href="'.$CFG->wwwroot.'/course/view.php?id='.$c_course->id.'">'.format_string($course_name).'</a></td>';
echo '<tr><td class="c0"><a href="'.$CFG->wwwroot.'/course/view.php?id='.$c_course->id.'">'.$course_name.'</a></td>';
} else {
echo '<tr><td class="c0"></td>';
}
Expand Down
3 changes: 2 additions & 1 deletion enrol/authorize/localfuncs.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ function send_welcome_messages($orderdata) {
$lastuserid = $ei->userid;

while ($ei && $ei->userid == $lastuserid) {
$usercourses[] = $ei->fullname;
$context = get_context_instance(CONTEXT_COURSE, $ei->courseid);
$usercourses[] = format_string($ei->fullname, true, array('context' => $context));
if (!$rs->valid()) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/uploadcsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function authorize_process_csv($filename) {
$eventdata->name = 'authorize_enrolment';
$eventdata->userfrom = $admin;
$eventdata->userto = $admin;
$eventdata->subject = "$SITE->fullname: Authorize.net CSV ERROR LOG";
$eventdata->subject = format_string($SITE->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))).': Authorize.net CSV ERROR LOG';
$eventdata->fullmessage = $ignoredlines;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
Expand Down
4 changes: 2 additions & 2 deletions enrol/flatfile/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private function process_records($action, $roleid, $user, $course, $timestart, $
if (!empty($mailstudents)) {
// Send mail to students
$a = new stdClass();
$a->coursename = "$course->fullname";
$a->coursename = format_string($course->fullname, true, array('context' => $context));
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id";
$subject = get_string("enrolmentnew", 'enrol', format_string($course->shortname, true, array('context' => $context)));

Expand All @@ -297,7 +297,7 @@ private function process_records($action, $roleid, $user, $course, $timestart, $
// Send mail to teachers
foreach($teachers as $teacher) {
$a = new stdClass();
$a->course = "$course->fullname";
$a->course = format_string($course->fullname, true, array('context' => $context));
$a->user = fullname($user);
$subject = get_string("enrolmentnew", 'enrol', format_string($course->shortname, true, array('context' => $context)));

Expand Down
8 changes: 5 additions & 3 deletions enrol/paypal/ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
die;
}

$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);

// Check that amount paid is the correct amount
if ( (float) $plugin_instance->cost <= 0 ) {
$cost = (float) $plugin->get_config('cost');
Expand Down Expand Up @@ -232,7 +234,7 @@


if (!empty($mailstudents)) {
$a->coursename = $course->fullname;
$a->coursename = format_string($course->fullname, true, array('context' => $coursecontext));
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";

$eventdata = new stdClass();
Expand All @@ -251,7 +253,7 @@
}

if (!empty($mailteachers)) {
$a->course = $course->fullname;
$a->course = format_string($course->fullname, true, array('context' => $coursecontext));
$a->user = fullname($user);

$eventdata = new stdClass();
Expand All @@ -269,7 +271,7 @@
}

if (!empty($mailadmins)) {
$a->course = $course->fullname;
$a->course = format_string($course->fullname, true, array('context' => $coursecontext));
$a->user = fullname($user);
$admins = get_admins();
foreach ($admins as $admin) {
Expand Down
6 changes: 4 additions & 2 deletions enrol/paypal/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
}

$fullname = format_string($course->fullname, true, array('context' => $context));

if (is_enrolled($context, NULL, '', true)) { // TODO: use real paypal check
redirect($destination, get_string('paymentthanks', '', $course->fullname));
redirect($destination, get_string('paymentthanks', '', $fullname));

} else { /// Somehow they aren't enrolled yet! :-(
$PAGE->set_url($destination);
echo $OUTPUT->header();
$a = new stdClass();
$a->teacher = get_string('defaultcourseteacher');
$a->fullname = format_string($course->fullname);
$a->fullname = $fullname;
notice(get_string('paymentsorry', '', $a), $destination);
}

Expand Down
2 changes: 1 addition & 1 deletion files/coursefilesedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
require_capability('moodle/course:managefiles', $context);

$PAGE->set_url($url);
$heading = get_string('coursefiles') . ': ' . $course->fullname;
$heading = get_string('coursefiles') . ': ' . format_string($course->fullname, true, array('context' => $context));
$strfiles = get_string("files");
if ($node = $PAGE->settingsnav->find('coursefiles', navigation_node::TYPE_SETTING)) {
$node->make_active();
Expand Down
Loading

0 comments on commit d1e3624

Please sign in to comment.