5 * index page to view blogs. if no blog is specified then site wide entries are shown
6 * if a blog id is specified then the latest entries from that blog are shown
9 if (!file_exists('../config.php')) {
10 header('Location: ../install.php');
14 require_once('../config.php');
15 require_once($CFG->dirroot
.'/blog/lib.php');
16 require_once($CFG->libdir
.'/blocklib.php');
18 $id = optional_param('id', 0, PARAM_INT
);
19 $limit = optional_param('limit', 0, PARAM_INT
);
20 $start = optional_param('formstart', 0, PARAM_INT
);
21 $userid = optional_param('userid',0,PARAM_INT
);
22 $courseid = optional_param('courseid',SITEID
,PARAM_INT
);
23 $tag = optional_param('tag', '', PARAM_NOTAGS
);
24 $tagid = optional_param('tagid', 0, PARAM_INT
);
25 $postid = optional_param('postid',0,PARAM_INT
);
26 $filtertype = optional_param('filtertype', '', PARAM_ALPHA
);
27 $filterselect = optional_param('filterselect', 0, PARAM_INT
);
29 /// overwrite filter code here
32 switch ($filtertype) {
36 $userid = $filterselect;
46 $courseid = $filterselect;
47 $course = get_record('course','id',$courseid);
56 $groupid = $filterselect;
57 $group = get_record('groups','id',$groupid);
58 $course = get_record('course','id',$group->courseid
);
59 $courseid = $course->id
;
69 $userid = $filterselect;
78 } else if ($userid) { //default to user
80 $filterselect = $userid;
88 switch ($filtertype) {
90 if ($CFG->bloglevel
< BLOG_SITE_LEVEL
&& (!isadmin())) {
91 error ('site blogs is not enabled');
92 } else if ($CFG->bloglevel
< BLOG_GLOBAL_LEVEL
) {
97 if ($CFG->bloglevel
< BLOG_COURSE_LEVEL
&& (!isadmin())) {
98 error ('course blogs is not enabled');
101 if (!isstudent($filterselect) && !isteacher($filterselect)) {
102 error ('you must be a student in this course to view course blogs');
104 /// check if viewer is student
107 if ($CFG->bloglevel
< BLOG_GROUP_LEVEL
&& (!isadmin())) {
108 error ('group blogs is not enabled');
110 if (!isteacheredit($course) and (groupmode($course) == SEPARATEGROUPS
)) {
111 if (!ismember($filterselect)) {
112 error ('you are not in this group');
115 /// check if user is editting teacher, or if spg, is member
118 if ($CFG->bloglevel
< BLOG_USER_LEVEL
&& (!isadmin())) {
119 error ('Blogs is not enabled');
122 if ($CFG->bloglevel
== BLOG_USER_LEVEL
and $USER->id
!= $filterselect and !isadmin()) {
123 error ('Under this setting, you can only view your own blogs');
126 /// check to see if the viewer is sharing no_group, visible group course.
127 /// if not , check if the viewer is in any spg group as the user
128 blog_user_can_view_user_post($filterselect);
135 // first set the start and end day equal to the day argument passed in from the get vars
136 if ($limit == 'none') {
137 $limit = get_user_preferences('blogpagesize',10);
140 include($CFG->dirroot
.'/blog/header.php');
142 $blogpage = optional_param('blogpage',0,PARAM_INT
);
144 blog_print_html_formatted_entries($userid, $postid, $limit, ($blogpage * $limit) ,$filtertype, $filterselect, $tagid, $tag, $filtertype, $filterselect);
146 add_to_log($courseid, 'blog', 'view', 'index.php?filtertype='.$filtertype.'&filterselect='.$filterselect.'&postid='.$postid.'&tagid='.$tagid.'&tag='.$tag, 'view blog entry');
148 include($CFG->dirroot
.'/blog/footer.php');