Skip to content
Newer
Older
100644 102 lines (83 sloc) 3.38 KB
60812eb @sammarshallou Initial public release
sammarshallou authored
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17 /**
18 * Main forum page view.
19 * @package mod
20 * @subpackage forumng
21 * @copyright 2011 The Open University
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24 require_once('../../config.php');
25
26 require_once('mod_forumng.php');
27
28 // Require ID parameter here. Other parameters may be required in forum type.
29 $id = required_param('id', PARAM_INT);
30
31 // On the view page ONLY we allow a default for the clone parameter that won't
32 // cause an error if it's omitted. All other pages have default 0, which will
33 // show up any errors caused if the parameter is omitted somewhere.
34 $cloneid = optional_param('clone', mod_forumng::CLONE_DIRECT, PARAM_INT);
35
36 $params = array('id' => $id);
37 if ($cloneid !== mod_forumng::CLONE_DIRECT) {
38 $params['clone'] = $cloneid;
39 }
40 $pageurl = new moodle_url('/mod/forumng/view.php', $params);
41
42 // Construct forum variable (will check id is valid)
43 $forum = mod_forumng::get_from_cmid($id, $cloneid);
44 $course = $forum->get_course();
45 $cm = $forum->get_course_module();
46
47 // If this is a clone, redirect to original
48 if ($forum->is_clone()) {
49 $forum->redirect_to_original();
50 }
51
52 // Check that forum can be viewed [Handles all other permissions]
53 $groupid = mod_forumng::get_activity_group($cm, true);
54 $forum->require_view($groupid, 0, true);
55
56 // Get update button, if allowed for current user
57 $strforum = get_string("modulename", "forum");
58
59 // Atom header meta tag
60 $feedtype = $forum->get_effective_feed_option();
61 if ($feedtype == mod_forumng::FEEDTYPE_DISCUSSIONS ||
62 ($feedtype == mod_forumng::FEEDTYPE_ALL_POSTS
63 && $forum->can_view_discussions())) {
64 $atomurl = $forum->get_feed_url(mod_forumng::FEEDFORMAT_ATOM, $groupid);
65 $meta = '<link rel="alternate" type="application/atom+xml" ' .
66 'title="Atom feed" href="' . htmlspecialchars($atomurl) . '" />';
67 } else {
68 $meta = '';
69 }
70
71 // Initialize $PAGE, compute blocks
72 global $CURRENTFORUM;
73 $CURRENTFORUM = $forum;
74
75 // Update completion 'viewed' flag if in use
76 $completion = new completion_info($course);
77 $completion->set_module_viewed($cm);
78 // Display header. Because this pagelib class doesn't actually have a
79 // $buttontext parameter, there has to be a really evil hack
80 $out = $forum->init_page($pageurl);
81 print $out->header();
82 $forum->print_js($cm->id);
83
8930907 @jason-platts OSEP: Forum redesign #105096
jason-platts authored
84 print $out->render_forum_header($forum, $groupid);
85
60812eb @sammarshallou Initial public release
sammarshallou authored
86 // Display group selector if required
87 groups_print_activity_menu($cm, $forum->get_url(mod_forumng::PARAM_HTML));
88
89 print $out->container_start('forumng-main');
90 print $out->render_switch_link($forum);
4d6532e @sammarshallou ForumNG: Change intro handling, also theme styling #1106
sammarshallou authored
91 print $out->skip_link_target();
60812eb @sammarshallou Initial public release
sammarshallou authored
92 // Get forum type to display main part of page
93 $forum->get_type()->print_view_page($forum, $groupid);
94
95 print $out->container_end();
96
97 // Log request
98 $forum->log('view');
99
100 // Display footer
101 print $out->footer($course);
Something went wrong with that request. Please try again.