MDL-20523 Script for upgrading sites that use the old bloglevel settings.
[moodle.git] / blog / blogpage.php
CommitLineData
4a173181 1<?php // $Id$
2
9cfa80b5 3if (!defined('MOODLE_INTERNAL')) {
4 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
5}
6
4a173181 7/**
8* Definition of blog page type.
9 */
10define('PAGE_BLOG_VIEW', 'blog-view');
11
12// Blog class derived from moodle's page class
13class page_blog extends page_base {
14
15 var $editing = false;
e96f2a77 16 var $filtertype = NULL;
17 var $filterselect = NULL;
47b87873 18 var $tagid = NULL;
e96f2a77 19
4a173181 20 // Do any validation of the officially recognized bits of the data and forward to parent.
21 // Do NOT load up "expensive" resouces (e.g. SQL data) here!
22 function init_quick($data) {
23 parent::init_quick($data);
24 if (empty($data->pageid)) {
25 //if no pageid then the user is viewing a collection of blog entries
26 $this->id = 0; //set blog id to 0
27 }
28 }
e96f2a77 29
45df7de3 30 /**
31 * Here you should load up all heavy-duty data for your page. Basically everything that
32 * does not NEED to be loaded for the class to make basic decisions should NOT be loaded
33 * in init_quick() and instead deferred here. Of course this function had better recognize
34 * $this->full_init_done to prevent wasteful multiple-time data retrieval.
35 */
4a173181 36 function init_full() {
45df7de3 37 global $DB;
38
4a173181 39 if ($this->full_init_done) {
40 return;
41 }
42 // I need to determine how best to utilize this function. Most init
43 // is already done before we get here in blogFilter and blogInfo
6524adcf 44
4a173181 45 if ($this->courseid == 0 || $this->courseid == 1 || !is_numeric($this->courseid) ) {
46 $this->courseid = '';
4a173181 47 }
48 $this->full_init_done = true;
e96f2a77 49 }
4a173181 50
4a173181 51 //over-ride parent method's print_header because blog already passes more than just the title along
52 function print_header($pageTitle='', $pageHeading='', $pageNavigation='', $pageFocus='', $pageMeta='') {
b80e3a9c 53 global $CFG, $USER;
e96f2a77 54
4a173181 55 $this->init_full();
56 $extraheader = '';
b80e3a9c 57 if (!empty($USER) && !empty($USER->id) && $this->user_allowed_editing()) {
830dd6e9 58 if ($this->user_is_editing()) {
d87c9c6e 59 $editingString = get_string('turneditingoff');
60 } else {
61 $editingString = get_string('turneditingon');
62 }
e96f2a77 63
ad52c04f 64 $params = $this->url->params();
830dd6e9 65 $params['edit'] = $this->user_is_editing() ? 0 : 1;
e96f2a77 66 $paramstring = '';
67 foreach ($params as $key=>$val) {
68 $paramstring .= '<input type="hidden" name="'.$key.'" value="'.s($val).'" />';
69 }
e25cb710 70
b80e3a9c 71 $extraheader = '<form '.$CFG->frametarget.' method="get" action="'.$this->url->out(false).'"><div>'
7a4a9005 72 .$paramstring.'<input type="submit" value="'.$editingString.'" /></div></form>';
4a173181 73 }
b80e3a9c 74 print_header($pageTitle, $pageHeading, $pageNavigation, $pageFocus, $pageMeta, true, $extraheader );
e96f2a77 75 }
4a173181 76}
3daaa618 77?>