community block MDL-24826 'Save a link to this course' redirect to the original course

This commit is contained in:
jerome mouneyrac 2010-10-27 08:42:38 +00:00
parent c6619b6c1e
commit 9e32912bca
3 changed files with 21 additions and 6 deletions

View File

@ -77,8 +77,11 @@ if ($add != -1 and $confirm and confirm_sesskey()) {
$course->url = optional_param('courseurl', '', PARAM_URL);
$course->imageurl = optional_param('courseimageurl', '', PARAM_URL);
$communitymanager->block_community_add_course($course, $USER->id);
$notificationmessage = $OUTPUT->notification(get_string('addedtoblock', 'community_hub'),
'notifysuccess');
echo $OUTPUT->header();
echo $renderer->save_link_success(
new moodle_url('/course/view.php', array('id' => $courseid)));
echo $OUTPUT->footer();
die();
}
/// Delete temp file when cancel restore
@ -204,9 +207,6 @@ if (optional_param('executesearch', 0, PARAM_INTEGER) and confirm_sesskey()) {
// OUTPUT
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('searchcommunitycourse', 'block_community'), 3, 'main');
if (!empty($notificationmessage)) {
echo $notificationmessage;
}
$hubselectorform->display();
if (!empty($errormessage)) {
echo $errormessage;

View File

@ -26,7 +26,7 @@
$string['activities'] = 'Activities';
$string['add'] = 'Add';
$string['addedtoblock'] = 'A link to this course has been added in your community block';
$string['addedtoblock'] = 'A link to this course has been added in your community finder block';
$string['addtocommunityblock'] = 'Save a link to this course';
$string['addcommunitycourse'] = 'Add community course';
$string['additionalcoursedesc'] = '{$a->lang} Creator: {$a->creatorname} - Publisher: {$a->publishername} - Subject: {$a->subject}

View File

@ -60,6 +60,21 @@ class block_community_renderer extends plugin_renderer_base {
return $html;
}
/**
* Display add community course success message and a button to be redirected to te referer page
* @param moodle_url $url the page to be redirected to
* @return string html
*/
public function save_link_success(moodle_url $url) {
$html = $this->output->notification(get_string('addedtoblock', 'block_community'),
'notifysuccess');
$continuebutton = new single_button($url,
get_string('continue', 'block_community'));
$html .= html_writer::tag('div', $this->output->render($continuebutton),
array('class' => 'continuebutton'));
return $html;
}
/**
* The 'Next'/'more course result' link for a courses search
* @param array $data - the form parameter to execute the search on more result