3 /// Sets up blocks and navigation for index.php
5 require_once($CFG->dirroot
.'/blog/lib.php');
6 require_once($CFG->libdir
.'/pagelib.php');
7 require_once($CFG->dirroot
.'/blog/blogpage.php');
8 require_once($CFG->libdir
.'/blocklib.php');
9 require_once($CFG->dirroot
.'/course/lib.php');
11 if (!empty($THEME->customcorners
)) {
12 require_once($CFG->dirroot
.'/lib/custom_corners_lib.php');
15 $blockaction = optional_param('blockaction','', PARAM_ALPHA
);
16 $instanceid = optional_param('instanceid', 0, PARAM_INT
);
17 $blockid = optional_param('blockid', 0, PARAM_INT
);
19 /// If user has never visited this page before, install 2 blocks for him
20 blog_check_and_install_blocks();
23 if (!$course = get_record('course', 'id', $courseid)) {
24 error('The course number was incorrect ('. $courseid .')');
27 // Bounds for block widths
28 // more flexible for theme designers taken from theme config.php
29 $lmin = (empty($THEME->block_l_min_width
)) ?
160 : $THEME->block_l_min_width
;
30 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
31 $rmin = (empty($THEME->block_r_min_width
)) ?
160 : $THEME->block_r_min_width
;
32 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
34 define('BLOCK_L_MIN_WIDTH', $lmin);
35 define('BLOCK_L_MAX_WIDTH', $lmax);
36 define('BLOCK_R_MIN_WIDTH', $rmin);
37 define('BLOCK_R_MAX_WIDTH', $rmax);
39 //_____________ new page class code ________
40 $pagetype = PAGE_BLOG_VIEW
;
41 $pageclass = 'page_blog';
43 // map our page identifier to the actual name
44 // of the class which will be handling its operations.
45 page_map_class($pagetype, $pageclass);
47 // Now, create our page object.
48 if (empty($USER->id
)) {
49 $PAGE = page_create_object($pagetype);
51 $PAGE = page_create_object($pagetype, $USER->id
);
53 $PAGE->courseid
= $courseid;
54 $PAGE->filtertype
= $filtertype;
55 $PAGE->filterselect
= $filterselect;
56 $PAGE->tagid
= $tagid;
58 $PAGE->init_full(); //init the BlogInfo object and the courserecord object
61 if ($PAGE->user_allowed_editing()) {
62 $editing = $PAGE->user_is_editing();
65 // Calculate the preferred width for left, right and center (both center positions will use the same)
66 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
68 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
71 // Display the blocks and allow blocklib to handle any block action requested
72 $pageblocks = blocks_get_by_page($PAGE);
75 if (!empty($blockaction) && confirm_sesskey()) {
76 if (!empty($blockid)) {
77 blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), intval($blockid));
78 } else if (!empty($instanceid)) {
79 $instance = blocks_find_instance($instanceid, $pageblocks);
80 blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), $instance);
82 // This re-query could be eliminated by judicious programming in blocks_execute_action(),
83 // but I'm not sure if it's worth the complexity increase...
84 $pageblocks = blocks_get_by_page($PAGE);
86 $missingblocks = blocks_get_missing($PAGE, $pageblocks);
90 $taginstance = get_record('tags', 'id', $tagid);
94 $tagrec = get_record('tags', 'text', $tag);
96 $taginstance = get_record('tags', 'id', $tagid);
101 /// site blogs - sitefullname -> blogs -> (?tag)
102 /// course blogs - sitefullname -> course fullname ->blogs ->(?tag)
103 /// group blogs - sitefullname -> course fullname ->group ->(?tag)
104 /// user blogs - sitefullname -> (?coursefullname) -> participants -> blogs -> (?tag)
106 $blogstring = get_string('blogs','blog');
107 $tagstring = get_string('tag');
109 // needed also for user tabs later
110 if (!$course = get_record('course', 'id', $courseid)) {
111 error('Wrong course id');
115 /// This is very messy atm.
117 switch ($filtertype) {
119 if ($tagid ||
!empty($tag)) {
120 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
121 '<a href="index.php?filtertype=site">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
123 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
124 $blogstring,'','',true,$PAGE->get_extra_header_string());
129 if ($tagid ||
!empty($tag)) {
130 print_header("$course->shortname: $blogstring", $course->fullname
,
131 '<a href="index.php?filtertype=course&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
133 print_header("$course->shortname: $blogstring", $course->fullname
,
134 $blogstring,'','',true,$PAGE->get_extra_header_string());
140 if ($thisgroup = groups_get_group($filterselect, false)) { //TODO:
141 if ($tagid ||
!empty($tag)) {
142 print_header("$course->shortname: $blogstring", $course->fullname
,
143 '<a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'&group='.$filterselect.'">'.$thisgroup->name
.'</a> ->
144 <a href="index.php?filtertype=group&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
146 print_header("$course->shortname: $blogstring", $course->fullname
,
147 '<a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'&group='.$filterselect.'">'.$thisgroup->name
."</a> ->
148 $blogstring",'','',true,$PAGE->get_extra_header_string());
151 print_error('Unable to find group');
157 $participants = get_string('participants');
158 if (!$user = get_record('user', 'id', $filterselect)) {
159 error('Wrong user id');
162 if ($course->id
!= SITEID
) {
163 if ($tagid ||
!empty($tag)) {
164 print_header("$course->shortname: $blogstring", $course->fullname
,
165 '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$course->id
.'">'.$course->shortname
.'</a> ->
166 <a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'">'.$participants.'</a> ->
167 <a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'&course='.$course->id
.'">'.fullname($user).'</a> ->
168 <a href="index.php?courseid='.$course->id
.'&filtertype=user&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
171 print_header("$course->shortname: $blogstring", $course->fullname
,
172 '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$course->id
.'">'.$course->shortname
.'</a> ->
173 <a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'">'.$participants.'</a> ->
174 <a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'&course='.$course->id
.'">'.fullname($user).'</a> ->
175 '.$blogstring,'','',true,$PAGE->get_extra_header_string());
182 if ($tagid ||
!empty($tag)) {
183 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
184 '<a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
185 <a href="index.php?filtertype=user&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
188 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
189 '<a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
190 '.$blogstring,'','',true,$PAGE->get_extra_header_string());
198 error ('Error unknown filtertype');
204 if ($filtertype=='user') {
209 $currenttab = 'blogs';
211 require_once($CFG->dirroot
.'/user/tabs.php');
214 /// Layout the whole page as three big columns.
215 print '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">' . "\n";
216 print '<tr valign="top">' . "\n";
218 /// The left column ...
219 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
220 print '<td style="vertical-align: top; width: '. $preferred_width_left .'px;" id="left-column">' . "\n";
221 print '<!-- Begin left side blocks -->' . "\n";
222 if (!empty($THEME->customcorners
)) print_custom_corners_start();
223 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
224 if (!empty($THEME->customcorners
)) print_custom_corners_end();
225 print '<!-- End left side blocks -->' . "\n";
226 print '</td>' . "\n";
229 /// Start main column
230 print '<!-- Begin page content -->' . "\n";
232 if (!empty($THEME->customcorners
)) print_custom_corners_start();