Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blog/preferences.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 
00028 require_once('../config.php');
00029 require_once($CFG->dirroot.'/blog/lib.php');
00030 require_once('preferences_form.php');
00031 
00032 $courseid = optional_param('courseid', SITEID, PARAM_INT);
00033 $modid    = optional_param('modid', null, PARAM_INT);
00034 $userid   = optional_param('userid', null, PARAM_INT);
00035 $tagid    = optional_param('tagid', null, PARAM_INT);
00036 $groupid      = optional_param('groupid', null, PARAM_INT);
00037 
00038 $url = new moodle_url('/blog/preferences.php');
00039 if ($courseid !== SITEID) {
00040     $url->param('courseid', $courseid);
00041 }
00042 if ($modid !== null) {
00043     $url->param('modid', $modid);
00044 }
00045 if ($userid !== null) {
00046     $url->param('userid', $userid);
00047 }
00048 if ($tagid !== null) {
00049     $url->param('tagid', $tagid);
00050 }
00051 if ($groupid !== null) {
00052     $url->param('groupid', $groupid);
00053 }
00054 
00055 $PAGE->set_url($url);
00056 $PAGE->set_pagelayout('standard');
00057 
00058 if ($courseid == SITEID) {
00059     require_login();
00060     $context = get_context_instance(CONTEXT_SYSTEM);
00061     $PAGE->set_context($context);
00062 } else {
00063     require_login($courseid);
00064     $context = get_context_instance(CONTEXT_COURSE, $courseid);
00065 }
00066 
00067 if (empty($CFG->bloglevel)) {
00068     print_error('blogdisable', 'blog');
00069 }
00070 
00071 require_capability('moodle/blog:view', $context);
00072 
00074 
00075 $mform = new blog_preferences_form('preferences.php');
00076 $mform->set_data(array('pagesize' => get_user_preferences('blogpagesize')));
00077 
00078 if (!$mform->is_cancelled() && $data = $mform->get_data()) {
00079     $pagesize = $data->pagesize;
00080 
00081     if ($pagesize < 1) {
00082         print_error('invalidpagesize');
00083     }
00084     set_user_preference('blogpagesize', $pagesize);
00085 }
00086 
00087 if ($mform->is_cancelled()){
00088     redirect($CFG->wwwroot . '/blog/index.php');
00089 }
00090 
00091 $site = get_site();
00092 
00093 $strpreferences = get_string('preferences');
00094 $strblogs       = get_string('blogs', 'blog');
00095 
00096 $title = "$site->shortname: $strblogs : $strpreferences";
00097 $PAGE->set_title($title);
00098 $PAGE->set_heading($title);
00099 
00100 echo $OUTPUT->header();
00101 
00102 echo $OUTPUT->heading("$strblogs : $strpreferences", 2);
00103 
00104 $mform->display();
00105 
00106 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations