Fixing my moodle bug in forum track posts display
[moodle.git] / blog / preferences.php
CommitLineData
4a173181 1<?php // $Id$
2 // preferences.php - user prefs for blog modeled on calendar
3
4 require_once('../config.php');
5 require_once($CFG->dirroot.'/blog/lib.php');
6
7 require_login();
8 global $USER;
9
10 // detemine where the user is coming from in case we need to send them back there
11 if (isset($_SERVER['HTTP_REFERER'])) {
12 $referrer = $_SERVER['HTTP_REFERER'];
13 } else {
14 $referrer = $CFG->wwwroot;
15 }
16
17 //ensure that the logged in user is not using the guest account
18 if (isguest()) {
19 error(get_string('noguestpost', 'forum'), $referrer);
20 }
21
22 if (!blog_isLoggedIn() ) {
23 error(get_string('noguestpost', 'forum'), $referrer);
24 }
25 $userid = $USER->id;
26 $bloginfo =& new BlogInfo($userid);
27
28/// If data submitted, then process and store.
29
30 if ($post = data_submitted()) {
31 print_header();
32 if (!isset($post->blogtitle) || !isset($post->blogtagline) ) {
33 error(get_string('settingsupdatederror', 'blog'), $referrer);
34 }
35
36 if (! $bloginfo->set_blog_title($post->blogtitle)) {
37 error(get_string('settingsupdatederror', 'blog'), $referrer );
38 }
39
40 if (! $bloginfo->set_blog_tagline($post->blogtagline)) {
41 error(get_string('settingsupdatederror', 'blog'), $referrer );
42 }
43
44 if (isset($post->theme)) {
45 if (! $bloginfo->set_blog_theme($post->theme)) {
46 error(get_string('settingsupdatederror', 'blog'), $referrer );
47 }
48 }
49
50 set_user_preference('blogpagesize', optional_param('pagesize'));
51
52 redirect($referrer, get_string('changessaved'), 1);
53 exit;
54 }
55
56 $site = get_site();
57 $pageMeta = '<script language="javascript" type="text/javascript" src="'. $CFG->wwwroot .'/blog/blog.js"></script>' . "\n";
58
59 $strpreferences = get_string('preferences', 'calendar');
60
61 $navigation = '<a href="'. $bloginfo->get_blog_url() .'">'. $bloginfo->get_blog_title() . '</a> -> '. $strpreferences;
62
63 print_header("$site->shortname: ". $bloginfo->get_blog_title() .": $strpreferences", $bloginfo->get_blog_title(), $navigation, '', $pageMeta, true, '', '');
64
65 print_heading($strpreferences);
66
67 print_simple_box_start('center', '', '');
68
69 include('./preferences.html');
70 print_simple_box_end();
71
72 print_footer();
73?>