}
function get_content() {
- global $USER, $CFG, $SESSION;
+ global $USER, $CFG, $SESSION, $COURSE;
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
// [pj] To me it looks like this if would never be needed, but Penny added it
// when committing the /my/ stuff. Reminder to discuss and learn what it's about.
// It definitely needs SOME comment here!
- if (!empty($this->instance->pageid)) {
- $courseshown = $this->instance->pageid;
- }
- else {
- $courseshown = SITEID;
- }
+ $courseshown = $COURSE->id;
if($courseshown == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
// No filters for now
- } elseif (!empty($courseshown)) {
+ } else {
// For any other course
$this->content->text .= calendar_overlib_html();
$this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
- $course = get_record('course', 'id', $this->instance->pageid);
- $this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $course).'</div>';
+ $this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div>';
}
}
function get_content() {
- global $USER, $CFG, $SESSION;
+ global $USER, $CFG, $SESSION, $COURSE;
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
$this->content->footer = '';
} else {
- if (!empty($this->instance->pageid)) {
- $courseshown = $this->instance->pageid;
- }
- else {
- $courseshown = SITEID;
- }
+ $courseshown = $COURSE->id;
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.
'/calendar/view.php?view=upcoming&course='.$courseshown.'">'.
get_string('gotocalendar', 'calendar').'</a>...';
}
function specialization() {
- if($this->instance->pagetype == PAGE_COURSE_VIEW && $this->instance->pageid != SITEID) {
+ global $COURSE;
+ if($this->instance->pagetype == PAGE_COURSE_VIEW && $COURSE->id != SITEID) {
$this->title = get_string('coursesummary', 'block_course_summary');
}
}
function get_content() {
- global $CFG, $THEME;
+ global $CFG, $COURSE;
if($this->content !== NULL) {
return $this->content;
return '';
}
- if (empty($this->instance->pageid)) {
- $this->instance->pageid = SITEID;
- }
- $course = get_record('course', 'id', $this->instance->pageid);
-
$this->content = New stdClass;
$options->noclean = true; // Don't clean Javascripts etc
- $this->content->text = format_text($course->summary, FORMAT_HTML, $options);
- if(isediting($this->instance->pageid)) {
- if($this->instance->pageid == SITEID) {
+ $this->content->text = format_text($COURSE->summary, FORMAT_HTML, $options);
+ if(isediting($COURSE->id)) {
+ if($COURSE->id == SITEID) {
$editpage = $CFG->wwwroot.'/'.$CFG->admin.'/site.php';
} else {
- $editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->instance->pageid;
+ $editpage = $CFG->wwwroot.'/course/edit.php?id='.$COURSE->id;
}
$this->content->text .= "<div align=\"right\"><a href=\"$editpage\"><img src=\"$CFG->pixpath/t/edit.gif\" alt=\"\" /></a></div>";
}
}
function specialization() {
- global $CFG;
- $this->course = get_record('course', 'id', $this->instance->pageid);
+ global $CFG, $COURSE;
+ $this->course = $COURSE;
// load userdefined title and make sure it's never empty
if (empty($this->config->title)) {
}
function get_content() {
- global $CFG, $USER;
+ global $CFG, $USER, $COURSE;
if ($this->content !== NULL) {
return $this->content;
}
- if ($this->instance->pageid == 0) {
- $this->instance->pageid = SITEID;
- }
- $course = get_record('course', 'id', $this->instance->pageid);
-
- if ($course->newsitems) { // Create a nice listing of recent postings
+ if ($COURSE->newsitems) { // Create a nice listing of recent postings
require_once($CFG->dirroot.'/mod/forum/lib.php'); // We'll need this
$text = '';
- if (!$forum = forum_get_course_forum($course->id, 'news')) {
+ if (!$forum = forum_get_course_forum($COURSE->id, 'news')) {
return $this->content;
}
/// First work out whether we can post to this group and if so, include a link
- if (isteacheredit($course->id)) { /// Teachers can always post
+ if (isteacheredit($COURSE->id)) { /// Teachers can always post
$visiblegroups = -1;
$text .= '<div align="center" class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
get_string('addanewtopic', 'forum').'</a>...</div>';
} else { /// Check the group situation
- $currentgroup = get_current_group($course->id);
+ $currentgroup = get_current_group($COURSE->id);
if (forum_user_can_post_discussion($forum, $currentgroup)) {
$text .= '<div align="center" class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
get_string('addanewtopic', 'forum').'</a>...</div>';
}
- if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
+ if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) {
$this->content->text = $text;
return $this->content;
}
- $groupmode = groupmode($course, $cm);
+ $groupmode = groupmode($COURSE, $cm);
/// Decides if current user is allowed to see ALL the current discussions or not
/// Get all the recent discussions we're allowed to see
if (! $discussions = forum_get_discussions($forum->id, 'p.modified DESC', 0, false,
- $visiblegroups, $course->newsitems) ) {
+ $visiblegroups, $COURSE->newsitems) ) {
$text .= '('.get_string('nonews', 'forum').')';
$this->content->text = $text;
return $this->content;
} else {
$userid = $USER->id;
}
- $this->content->footer .= '<br />'.rss_get_link($course->id, $userid, 'forum', $forum->id, $tooltiptext);
+ $this->content->footer .= '<br />'.rss_get_link($COURSE->id, $userid, 'forum', $forum->id, $tooltiptext);
}
}
function has_config() {return true;}
function get_content() {
- global $USER, $CFG;
+ global $USER, $CFG, $COURSE;
if ($this->content !== NULL) {
return $this->content;
return $this->content;
}
- $course = get_record('course', 'id', $this->instance->pageid);
-
$timetoshowusers = 300; //Seconds default
if (isset($CFG->block_online_users_timetosee)) {
$timetoshowusers = $CFG->block_online_users_timetosee * 60;
$timefrom = time()-$timetoshowusers;
//Calculate if we are in separate groups
- $isseparategroups = ($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce && !isteacheredit($this->instance->pageid));
+ $isseparategroups = ($COURSE->groupmode == SEPARATEGROUPS && $COURSE->groupmodeforce && !isteacheredit($COURSE->id));
//Get the user current group
- $currentgroup = $isseparategroups ? get_current_group($this->instance->pageid) : NULL;
+ $currentgroup = $isseparategroups ? get_current_group($COURSE->id) : NULL;
$groupmembers = "";
$groupselect = "";
$groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
}
- if ($this->instance->pageid == SITEID) { // Site-level
+ if ($COURSE->id == SITEID) { // Site-level
$courseselect = '';
$timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)";
} else {
- $courseselect = "AND s.course = '".$this->instance->pageid."'";
+ $courseselect = "AND s.course = '".$COURSE->id."'";
$timeselect = "AND s.timeaccess > $timefrom";
}
}
}
- if ($this->instance->pageid == SITEID && $CFG->allusersaresitestudents) {
+ if ($COURSE->id == SITEID && $CFG->allusersaresitestudents) {
if ($siteusers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess
FROM {$CFG->prefix}user u
WHERE u.lastaccess > $timefrom AND u.username <> 'guest'
$groupmembers
WHERE u.id = s.userid $courseselect $groupselect $timeselect ";
- if (!isteacher($course->id)) {
+ if (!isteacher($COURSE->id)) {
// Hide hidden teachers from students.
$findteacherssql .= 'AND s.authority > 0 ';
}
foreach ($users as $user) {
$this->content->text .= '<li class="listentry">';
$timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage
- $this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 16, true).' ';
- $this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">'.$user->fullname.'</a>';
+ $this->content->text .= print_user_picture($user->id, $COURSE->id, $user->picture, 16, true).' ';
+ $this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$COURSE->id.'" title="'.$timeago.'">'.$user->fullname.'</a>';
if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and !isguest()) { // Only when logged in
$this->content->text .= "\n".' <a title="'.get_string('messageselectadd').'" target="message_'.$user->id.'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'
.'<img class="icon message" src="'.$CFG->pixpath.'/t/message.gif" alt="'. get_string('messageselectadd') .'" /></a>';
}
function get_content() {
+ global $COURSE;
if ($this->content !== NULL) {
return $this->content;
$this->content->text = '';
$this->content->footer = '';
- $course = get_record('course', 'id', $this->instance->pageid);
-
// Slightly hacky way to do it but...
ob_start();
- print_recent_activity($course);
+ print_recent_activity($COURSE);
$this->content->text = ob_get_contents();
ob_end_clean();
}
function get_content() {
- global $CFG, $editing;
+ global $CFG, $editing, $COURSE;
require_once($CFG->libdir .'/rsslib.php');
$isteacher = false;
$this->courseid = SITEID;
if ($this->instance->pagetype == PAGE_COURSE_VIEW) {
- $this->courseid = $this->instance->pageid;
+ $this->courseid = $COURSE->id;
$isteacher = isteacher($this->courseid);
}