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 $blockaction = optional_param('blockaction','', PARAM_ALPHA
);
12 $instanceid = optional_param('instanceid', 0, PARAM_INT
);
13 $blockid = optional_param('blockid', 0, PARAM_INT
);
15 /// If user has never visited this page before, install 2 blocks for him
16 blog_check_and_install_blocks();
19 if (!$course = get_record('course', 'id', $courseid)) {
20 error('The course number was incorrect ('. $courseid .')');
23 // Bounds for block widths within this page
24 define('BLOCK_L_MIN_WIDTH', 160);
25 define('BLOCK_L_MAX_WIDTH', 210);
26 define('BLOCK_R_MIN_WIDTH', 160);
27 define('BLOCK_R_MAX_WIDTH', 210);
29 //_____________ new page class code ________
30 $pagetype = PAGE_BLOG_VIEW
;
31 $pageclass = 'page_blog';
33 // map our page identifier to the actual name
34 // of the class which will be handling its operations.
35 page_map_class($pagetype, $pageclass);
37 // Now, create our page object.
38 if (empty($USER->id
)) {
39 $PAGE = page_create_object($pagetype);
41 $PAGE = page_create_object($pagetype, $USER->id
);
43 $PAGE->courseid
= $courseid;
44 $PAGE->filtertype
= $filtertype;
45 $PAGE->filterselect
= $filterselect;
46 $PAGE->tagid
= $tagid;
48 $PAGE->init_full(); //init the BlogInfo object and the courserecord object
51 if ($PAGE->user_allowed_editing()) {
52 $editing = $PAGE->user_is_editing();
55 // Calculate the preferred width for left, right and center (both center positions will use the same)
56 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
58 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
61 // Display the blocks and allow blocklib to handle any block action requested
62 $pageblocks = blocks_get_by_page($PAGE);
65 if (!empty($blockaction) && confirm_sesskey()) {
66 if (!empty($blockid)) {
67 blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), intval($blockid));
68 } else if (!empty($instanceid)) {
69 $instance = blocks_find_instance($instanceid, $pageblocks);
70 blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), $instance);
72 // This re-query could be eliminated by judicious programming in blocks_execute_action(),
73 // but I'm not sure if it's worth the complexity increase...
74 $pageblocks = blocks_get_by_page($PAGE);
76 $missingblocks = blocks_get_missing($PAGE, $pageblocks);
80 $taginstance = get_record('tags', 'id', $tagid);
84 $tagrec = get_record('tags', 'text', $tag);
86 $taginstance = get_record('tags', 'id', $tagid);
91 /// site blogs - sitefullname -> blogs -> (?tag)
92 /// course blogs - sitefullname -> course fullname ->blogs ->(?tag)
93 /// group blogs - sitefullname -> course fullname ->group ->(?tag)
94 /// user blogs - sitefullname -> (?coursefullname) -> participants -> blogs -> (?tag)
96 $blogstring = get_string('blogs','blog');
97 $tagstring = get_string('tag');
99 // needed also for user tabs later
100 if (!$course = get_record('course', 'id', $courseid)) {
101 error('Wrong course id');
105 /// This is very messy atm.
107 switch ($filtertype) {
109 if ($tagid ||
!empty($tag)) {
110 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
111 '<a href="index.php?filtertype=site">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
113 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
114 $blogstring,'','',true,$PAGE->get_extra_header_string());
119 if ($tagid ||
!empty($tag)) {
120 print_header("$course->shortname: $blogstring", $course->fullname
,
121 '<a href="index.php?filtertype=course&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
123 print_header("$course->shortname: $blogstring", $course->fullname
,
124 $blogstring,'','',true,$PAGE->get_extra_header_string());
130 if ($thisgroup = groups_get_group($filterselect, false)) { //TODO:
131 if ($tagid ||
!empty($tag)) {
132 print_header("$course->shortname: $blogstring", $course->fullname
,
133 '<a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'&group='.$filterselect.'">'.$thisgroup->name
.'</a> ->
134 <a href="index.php?filtertype=group&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
136 print_header("$course->shortname: $blogstring", $course->fullname
,
137 '<a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'&group='.$filterselect.'">'.$thisgroup->name
."</a> ->
138 $blogstring",'','',true,$PAGE->get_extra_header_string());
141 print_error('Unable to find group');
147 $participants = get_string('participants');
148 if (!$user = get_record('user', 'id', $filterselect)) {
149 error('Wrong user id');
152 if ($course->id
!= SITEID
) {
153 if ($tagid ||
!empty($tag)) {
154 print_header("$course->shortname: $blogstring", $course->fullname
,
155 '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$course->id
.'">'.$course->shortname
.'</a> ->
156 <a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'">'.$participants.'</a> ->
157 <a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'&course='.$course->id
.'">'.fullname($user).'</a> ->
158 <a href="index.php?courseid='.$course->id
.'&filtertype=user&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
161 print_header("$course->shortname: $blogstring", $course->fullname
,
162 '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$course->id
.'">'.$course->shortname
.'</a> ->
163 <a href="'.$CFG->wwwroot
.'/user/index.php?id='.$course->id
.'">'.$participants.'</a> ->
164 <a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'&course='.$course->id
.'">'.fullname($user).'</a> ->
165 '.$blogstring,'','',true,$PAGE->get_extra_header_string());
172 if ($tagid ||
!empty($tag)) {
173 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
174 '<a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
175 <a href="index.php?filtertype=user&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
178 print_header("$SITE->shortname: $blogstring", $SITE->fullname
,
179 '<a href="'.$CFG->wwwroot
.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
180 '.$blogstring,'','',true,$PAGE->get_extra_header_string());
188 error ('Error unknown filtertype');
194 if ($filtertype=='user') {
199 $currenttab = 'blogs';
201 require_once($CFG->dirroot
.'/user/tabs.php');
204 /// Layout the whole page as three big columns.
205 print '<table border="0" cellpadding="3" cellspacing="0" width="100%">' . "\n";
206 print '<tr valign="top">' . "\n";
208 /// The left column ...
209 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
210 print '<td style="vertical-align: top; width: '. $preferred_width_left .'px;">' . "\n";
211 print '<!-- Begin left side blocks -->' . "\n";
212 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
213 print '<!-- End left side blocks -->' . "\n";
214 print '</td>' . "\n";
217 /// Start main column
218 print '<!-- Begin page content -->' . "\n";
219 print '<td width="*">';
223 <td height
="100%" valign
="top">