3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * Form page for blog preferences
24 * @copyright 2009 Nicolas Connault
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 require_once('../config.php');
29 require_once($CFG->dirroot
.'/blog/lib.php');
30 require_once('preferences_form.php');
32 $courseid = optional_param('courseid', SITEID
, PARAM_INT
);
33 $modid = optional_param('modid', null, PARAM_INT
);
34 $userid = optional_param('userid', null, PARAM_INT
);
35 $tagid = optional_param('tagid', null, PARAM_INT
);
36 $groupid = optional_param('groupid', null, PARAM_INT
);
38 $url = new moodle_url('/blog/preferences.php');
39 if ($courseid !== SITEID
) {
40 $url->param('courseid', $courseid);
42 if ($modid !== null) {
43 $url->param('modid', $modid);
45 if ($userid !== null) {
46 $url->param('userid', $userid);
48 if ($tagid !== null) {
49 $url->param('tagid', $tagid);
51 if ($groupid !== null) {
52 $url->param('groupid', $groupid);
56 $PAGE->set_pagelayout('standard');
58 if ($courseid == SITEID
) {
60 $context = get_context_instance(CONTEXT_SYSTEM
);
61 $PAGE->set_context($context);
63 require_login($courseid);
64 $context = get_context_instance(CONTEXT_COURSE
, $courseid);
67 if (empty($CFG->bloglevel
)) {
68 print_error('blogdisable', 'blog');
71 require_capability('moodle/blog:view', $context);
73 /// If data submitted, then process and store.
75 $mform = new blog_preferences_form('preferences.php');
76 $mform->set_data(array('pagesize' => get_user_preferences('blogpagesize')));
78 if (!$mform->is_cancelled() && $data = $mform->get_data()) {
79 $pagesize = $data->pagesize
;
82 print_error('invalidpagesize');
84 set_user_preference('blogpagesize', $pagesize);
87 if ($mform->is_cancelled()){
88 redirect($CFG->wwwroot
. '/blog/index.php');
93 $strpreferences = get_string('preferences');
94 $strblogs = get_string('blogs', 'blog');
96 $title = "$site->shortname: $strblogs : $strpreferences";
97 $PAGE->set_title($title);
98 $PAGE->set_heading($title);
100 echo $OUTPUT->header();
102 echo $OUTPUT->heading("$strblogs : $strpreferences", 2);
106 echo $OUTPUT->footer();