mirror of
https://github.com/moodle/moodle.git
synced 2025-02-13 03:45:49 +01:00
This check-in removes about 400 lines of code. I hope I have not screwed anything up. I would be grateful if people could review this change, and keep an eye on the navigation bar in modules. Any navigation bar bugs you find in the near future, feel free to file them in the tracker and assign them to me. Thanks. If not to many problems are found, I think I would like to backport this to 1.9 stable, but I am not sure that is a good idea. Opinions to the General Developer Forum please. I am about to start a thread there.
64 lines
2.3 KiB
PHP
64 lines
2.3 KiB
PHP
<?php
|
|
|
|
// Set tracking option for the forum.
|
|
|
|
require_once("../../config.php");
|
|
require_once("lib.php");
|
|
|
|
$id = required_param('id',PARAM_INT); // The forum to subscribe or unsubscribe to
|
|
$returnpage = optional_param('returnpage', 'index.php', PARAM_FILE); // Page to return to.
|
|
|
|
if (! $forum = get_record("forum", "id", $id)) {
|
|
error("Forum ID was incorrect");
|
|
}
|
|
|
|
if (! $course = get_record("course", "id", $forum->course)) {
|
|
error("Forum doesn't belong to a course!");
|
|
}
|
|
|
|
if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) {
|
|
$cm->id = NULL;
|
|
}
|
|
|
|
$user = $USER;
|
|
|
|
require_course_login($course, false, $cm);
|
|
|
|
if (isguest()) { // Guests can't change tracking
|
|
$wwwroot = $CFG->wwwroot.'/login/index.php';
|
|
if (!empty($CFG->loginhttps)) {
|
|
$wwwroot = str_replace('http:','https:', $wwwroot);
|
|
}
|
|
|
|
$navigation = build_navigation('', $cm);
|
|
print_header($course->shortname, $course->fullname, $navigation, '', '', true, "", navmenu($course, $cm));
|
|
notice_yesno(get_string('noguesttracking', 'forum').'<br /><br />'.get_string('liketologin'),
|
|
$wwwroot, $_SERVER['HTTP_REFERER']);
|
|
print_footer($course);
|
|
exit;
|
|
}
|
|
|
|
$returnto = forum_go_back_to($returnpage.'?id='.$course->id.'&f='.$forum->id);
|
|
|
|
$info->name = fullname($user);
|
|
$info->forum = format_string($forum->name);
|
|
|
|
if ( forum_tp_is_tracked($forum->id, $user->id) ) {
|
|
if (forum_tp_stop_tracking($forum->id, $user->id)) {
|
|
add_to_log($course->id, "forum", "stop tracking", "view.php?f=$forum->id", $forum->id, $cm->id);
|
|
redirect($returnto, get_string("nownottracking", "forum", $info), 1);
|
|
} else {
|
|
error("Could not stop tracking that forum", $_SERVER["HTTP_REFERER"]);
|
|
}
|
|
|
|
} else { // subscribe
|
|
if (forum_tp_start_tracking($forum->id, $user->id)) {
|
|
add_to_log($course->id, "forum", "start tracking", "view.php?f=$forum->id", $forum->id, $cm->id);
|
|
redirect($returnto, get_string("nowtracking", "forum", $info), 1);
|
|
} else {
|
|
error("Could not start tracking that forum", $_SERVER["HTTP_REFERER"]);
|
|
}
|
|
}
|
|
|
|
?>
|