moodle/blog/preferences.php

84 lines
2.3 KiB
PHP
Raw Normal View History

2009-09-04 00:36:43 +00:00
<?php
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
// 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/>.
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
/**
* Form page for blog preferences
*
* @package moodlecore
* @subpackage blog
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
require_once('../config.php');
require_once($CFG->dirroot.'/blog/lib.php');
require_once('preferences_form.php');
$courseid = optional_param('courseid', SITEID, PARAM_INT);
$PAGE->set_url('blog/preferences.php', array('courseid' => $courseid));
if ($courseid == SITEID) {
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
} else {
require_login($courseid);
$context = get_context_instance(CONTEXT_COURSE, $courseid);
}
2009-09-04 00:36:43 +00:00
if (empty($CFG->bloglevel)) {
print_error('blogdisable', 'blog');
}
require_capability('moodle/blog:view', $context);
2006-03-10 06:53:01 +00:00
/// If data submitted, then process and store.
2009-09-04 00:36:43 +00:00
$mform = new blog_preferences_form('preferences.php');
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
if (!$mform->is_cancelled() && $data = $mform->get_data()) {
$pagesize = $data->pagesize;
2009-09-04 00:36:43 +00:00
if ($pagesize < 1) {
print_error('invalidpagesize');
2006-03-10 06:53:01 +00:00
}
2009-09-04 00:36:43 +00:00
set_user_preference('blogpagesize', $pagesize);
}
if ($mform->is_cancelled()){
redirect($CFG->wwwroot . '/blog/index.php');
}
$site = get_site();
$strpreferences = get_string('preferences');
$strblogs = get_string('blogs', 'blog');
2009-09-04 00:36:43 +00:00
$title = "$site->shortname: $strblogs : $strpreferences";
$PAGE->set_title($title);
$PAGE->set_heading($title);
2009-09-07 10:01:26 +00:00
$PAGE->navbar->add($strblogs, new moodle_url($CFG->wwwroot.'/blog/'));
$PAGE->navbar->add($strpreferences);
2006-03-10 06:53:01 +00:00
2009-09-07 10:01:26 +00:00
echo $OUTPUT->header();
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
echo $OUTPUT->heading("$strblogs : $strpreferences", 2);
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
$mform->display();
2006-03-10 06:53:01 +00:00
2009-09-04 00:36:43 +00:00
echo $OUTPUT->footer();