MDL-17445 course deletion cleanup and adding new event that is triggered after removi...
[moodle.git] / blog / preferences.php
CommitLineData
cae83708 1<?php
4a173181 2
cae83708 3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
4a173181 17
e96f2a77 18
cae83708 19/**
20 * Form page for blog preferences
21 *
22 * @package moodlecore
23 * @subpackage blog
24 * @copyright 2009 Nicolas Connault
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
4a173181 27
cae83708 28require_once('../config.php');
29require_once($CFG->dirroot.'/blog/lib.php');
30require_once('preferences_form.php');
31
32$courseid = optional_param('courseid', SITEID, PARAM_INT);
b0e90a0c 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);
37
a6855934 38$PAGE->set_url('/blog/preferences.php', array('courseid' => $courseid, 'modid' => $modid, 'userid' => $userid, 'tagid' => $tagid, 'groupid' => $groupid));
cae83708 39
40if ($courseid == SITEID) {
41 require_login();
42 $context = get_context_instance(CONTEXT_SYSTEM);
43} else {
44 require_login($courseid);
45 $context = get_context_instance(CONTEXT_COURSE, $courseid);
46}
ab2f17b0 47
cae83708 48if (empty($CFG->bloglevel)) {
49 print_error('blogdisable', 'blog');
50}
51
52require_capability('moodle/blog:view', $context);
4a173181 53
54/// If data submitted, then process and store.
55
cae83708 56$mform = new blog_preferences_form('preferences.php');
4a173181 57
cae83708 58if (!$mform->is_cancelled() && $data = $mform->get_data()) {
59 $pagesize = $data->pagesize;
e96f2a77 60
cae83708 61 if ($pagesize < 1) {
62 print_error('invalidpagesize');
4a173181 63 }
cae83708 64 set_user_preference('blogpagesize', $pagesize);
65}
66
67if ($mform->is_cancelled()){
68 redirect($CFG->wwwroot . '/blog/index.php');
69}
70
71$site = get_site();
72
73$strpreferences = get_string('preferences');
74$strblogs = get_string('blogs', 'blog');
db837673 75
cae83708 76$title = "$site->shortname: $strblogs : $strpreferences";
77$PAGE->set_title($title);
78$PAGE->set_heading($title);
a6855934 79$PAGE->navbar->add($strblogs, new moodle_url('/blog/'));
e640790e 80$PAGE->navbar->add($strpreferences);
4a173181 81
e640790e 82echo $OUTPUT->header();
4a173181 83
cae83708 84echo $OUTPUT->heading("$strblogs : $strpreferences", 2);
4a173181 85
cae83708 86$mform->display();
4a173181 87
cae83708 88echo $OUTPUT->footer();