moodle/blog/preferences.php
skodak e96f2a77db Code cleanup in blog.
MDL-6805  Fixed redirects in blog; MDL-6807  partially fixed use of capabilitites - it needs more testing and possibly minor fixing, the commit contains other blog bugfixes too. In general it should work exactly the same. The introduction of roles makes proper setup more difficult :-(

Expect some more fixes soon, no other bigger changes...
2006-10-06 10:11:52 +00:00

57 lines
1.6 KiB
PHP
Executable File

<?php // $Id$
// preferences.php - user prefs for blog modeled on calendar
require_once('../config.php');
require_once($CFG->dirroot.'/blog/lib.php');
$courseid = optional_param('courseid', SITEID, PARAM_INT);
if ($courseid == SITEID) {
require_login();
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
} else {
require_login($courseid);
$context = get_context_instance(CONTEXT_COURSE, $courseid);
}
if (empty($CFG->bloglevel)) {
error('Blogging is disabled!');
}
require_capability('moodle/blog:view', $context);
/// If data submitted, then process and store.
if (data_submitted()) {
$pagesize = required_param('pagesize', PARAM_INT);
if ($pagesize < 1) {
error('invalid page size');
}
set_user_preference('blogpagesize', $pagesize);
// now try to guess where to go from here ;-)
if ($courseid == SITEID) {
redirect($CFG->wwwroot.'/blog/index.php');
} else {
redirect($CFG->wwwroot.'/blog/index.php?filtertype=course&amp;filterselect='.$courseid);
}
}
$site = get_site();
$strpreferences = get_string('preferences');
$strblogs = get_string('blogs', 'blog');
$navigation = "<a href='".$CFG->wwwroot."/blog/'>$strblogs</a> -> $strpreferences";
print_header("$site->shortname: $strblogs : $strpreferences", $strblogs, $navigation);
print_heading($strpreferences);
print_simple_box_start('center', '', '');
require('./preferences.html');
print_simple_box_end();
print_footer();
?>