-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkposts.php
More file actions
105 lines (87 loc) · 3.54 KB
/
Copy pathmarkposts.php
File metadata and controls
105 lines (87 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Set tracking option for the anonforum.
*
* @package mod-anonforum
* @copyright 2005 mchurch
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
require_once("lib.php");
$f = required_param('f',PARAM_INT); // The anonymous forum to mark
$mark = required_param('mark',PARAM_ALPHA); // Read or unread?
$d = optional_param('d',0,PARAM_INT); // Discussion to mark.
$returnpage = optional_param('returnpage', 'index.php', PARAM_FILE); // Page to return to.
$url = new moodle_url('/mod/anonforum/markposts.php', array('f'=>$f, 'mark'=>$mark));
if ($d !== 0) {
$url->param('d', $d);
}
if ($returnpage !== 'index.php') {
$url->param('returnpage', $returnpage);
}
$PAGE->set_url($url);
if (! $anonforum = $DB->get_record("anonforum", array("id" => $f))) {
print_error('invalidanonforumid', 'anonforum');
}
if (! $course = $DB->get_record("course", array("id" => $anonforum->course))) {
print_error('invalidcourseid');
}
if (!$cm = get_coursemodule_from_instance("anonforum", $anonforum->id, $course->id)) {
print_error('invalidcoursemodule');
}
$user = $USER;
require_login($course, false, $cm);
if ($returnpage == 'index.php') {
$returnto = anonforum_go_back_to($returnpage.'?id='.$course->id);
} else {
$returnto = anonforum_go_back_to($returnpage.'?f='.$anonforum->id);
}
if (isguestuser()) { // Guests can't change anonforum
$PAGE->set_title($course->shortname);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('noguesttracking', 'anonforum').'<br /><br />'.get_string('liketologin'), get_login_url(), $returnto);
echo $OUTPUT->footer();
exit;
}
$info = new stdClass();
$info->name = fullname($user);
$info->anonforum = format_string($anonforum->name);
if ($mark == 'read') {
if (!empty($d)) {
if (! $discussion = $DB->get_record('anonforum_discussions', array('id'=> $d, 'anonforum'=> $anonforum->id))) {
print_error('invaliddiscussionid', 'anonforum');
}
} else {
// Mark all messages read in current group
$currentgroup = groups_get_activity_group($cm);
if(!$currentgroup) {
// mark_anonymous forum_read requires ===false, while get_activity_group
// may return 0
$currentgroup=false;
}
}
/// FUTURE - Add ability to mark them as unread.
// } else { // subscribe
// if (anonforum_tp_start_tracking($anonymous forum->id, $user->id)) {
// add_to_log($course->id, "anonforum", "mark unread", "view.php?f=$anonforum->id", $anonymous forum->id, $cm->id);
// redirect($returnto, get_string("nowtracking", "anonymous forum", $info), 1);
// } else {
// print_error("Could not start tracking that anonymous forum", $_SERVER["HTTP_REFERER"]);
// }
}
redirect($returnto);