can not see links if not logged in
[moodle.git] / blocks / blog_menu / block_blog_menu.php
CommitLineData
6cafc73d 1<?php //$Id$
2
3class block_blog_menu extends block_base {
4
5 function init() {
6 $this->title = get_string('blockmenutitle', 'blog');
7 $this->content_type = BLOCK_TYPE_TEXT;
8 $this->version = 2004112000;
9 }
10
11 function get_content() {
12 global $CFG, $course;
13
14 if ($CFG->bloglevel < 1) {
15 $this->content->text = '';
16 return $this->content;
17 }
18
19 if ($CFG->bloglevel < 5 && !isstudent($course->id) && !isteacher($course->id)) {
20 $this->content->text = '';
21 return $this->content;
22 }
23
24 if (!isset($userBlog)) {
25 $userBlog ->userid = 0;
26 }
27
28 global $CFG, $USER, $course;
29 if (isset($USER->id)) {
30 $userBlog->userid = $USER->id;
31 } //what is $userBlog anyway
32 if($this->content !== NULL) {
33 return $this->content;
34 }
35
36 $output = '';
37
38 $this->content = new stdClass;
39 $this->content->footer = '';
40 if (empty($this->instance) /*|| empty($CFG->blog_version)*/) {
41 // Either we're being asked for content without
42 // an associated instance of the Blog module has never been installed.
43 $this->content->text = $output;
44 return $this->content;
45 }
46
47 require_once($CFG->dirroot .'/blog/lib.php');
48
49 //if ( blog_isLoggedIn() && !isguest() ) {
50 $courseviewlink = '';
51 $addentrylink = '';
52
53 $coursearg = '';
12e01c0c 54 if(blog_isLoggedIn() && isset($course) && isset($course->id) && $course->id !=0 && $course->id!=SITEID && $CFG->bloglevel >=3 ) {
6cafc73d 55 $coursearg = '&courseid='. $course->id;
56 // a course is specified
57
58 $courseviewlink = '<a href="'. $CFG->wwwroot .'/blog/index.php?filtertype=course&filterselect='. $course->id .'">';
59 $courseviewlink .= get_string('viewcourseentries', 'blog') .'</a><br />';
60 }
61
62 $blogmodon = false;
12e01c0c 63
64 if (blog_isLoggedIn() && (isadmin() || !$blogmodon || ($blogmodon && $coursearg != '')) && $CFG->bloglevel >= 1) {
65
66 // show Add entry link - user is not admin, moderation is off, or moderation is on and the user is viewing the block within the context of a course
67 $addentrylink = '<a href="'. $CFG->wwwroot. '/blog/edit.php?userid='. $userBlog->userid . $coursearg .'">'. get_string('addnewentry', 'blog') .'</a><br />';
68
69 // show View my entries link
70 $addentrylink .= '<a href="'. $CFG->wwwroot .'/blog/index.php?userid='. $userBlog->userid.'">';
71 $addentrylink .= get_string('viewmyentries', 'blog') .'</a><br />';
72 // show link to manage blog prefs
73 $addentrylink .= '<a href="'. $CFG->wwwroot. '/blog/preferences.php?userid='. $userBlog->userid . $coursearg .'">'. get_string('blogpreferences', 'blog') .'</a><br />';
74
75 $output = $addentrylink;
76 $output .= $courseviewlink;
6cafc73d 77
78 }
79
80 // show View site entries link
81 if ($CFG->bloglevel >= 4) {
82 $output .= '<a href="'. $CFG->wwwroot .'/blog/index.php?filtertype=site&">';
83 $output .= get_string('viewsiteentries', 'blog') .'</a><br />';
84 }
85
86 // show Help with blogging link
87 //$output .= '<a href="'. $CFG->wwwroot .'/help.php?module=blog&amp;file=user.html">';
88 //$output .= get_string('helpblogging', 'blog') .'</a>';
89 //} else {
90 // $output = ''; //guest users and users who are not logged in do not get menus
91 //}
92
93 $this->content->text = $output;
94 return $this->content;
95 }
96}
97?>