$this->title = get_string('administration');
$this->content_type = BLOCK_TYPE_LIST;
$this->course = $course;
- $this->version = 2004041000;
+ $this->version = 2005052800;
}
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
+ }
+
function get_content() {
global $USER, $CFG, $THEME;
- require_once($CFG->dirroot.'/mod/forum/lib.php');
-
if($this->content !== NULL) {
return $this->content;
}
$this->content->icons = array();
$this->content->footer = '';
+ if($this->course->id == 1) {
+ $this->load_content_for_site();
+ }
+ else {
+ $this->load_content_for_course();
+ }
+
+ return $this->content;
+ }
+
+
+ function load_content_for_site() {
+ global $CFG;
+
+ if (isadmin()) {
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/configure.php">'.get_string('configuration').'</a>...';
+ $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/admin.gif" height="16" width="16" alt="" />';
+
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/users.php">'.get_string('users').'</a>...';
+ $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
+ }
+
+ if (iscreator()) {
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on">'.get_string('courses').'</a>';
+ $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/course.gif" height="16" width="16" alt="" />';
+ }
+
+ if (isadmin()) {
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/log.php?id=1">'.get_string('logs').'</a>';
+ $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
+
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id=1">'.get_string('sitefiles').'</a>';
+ $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
+
+ if (file_exists($CFG->dirroot.'/'.$CFG->admin.'/'.$CFG->dbtype)) {
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').'</a>';
+ $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/db.gif" height="16" width="16" alt="" />';
+ }
+ $this->content->footer = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/">'.get_string('admin').'</a>...';
+ }
+ }
+
+ function load_content_for_course() {
+ global $CFG;
+ require_once($CFG->dirroot.'/mod/forum/lib.php');
+
if (isguest()) {
return $this->content;
}
}
} else if (!isguest()) { // Students menu
+
if ($this->course->showgrades) {
$this->content->items[]='<a href="grade.php?id='.$this->course->id.'">'.get_string('grades').'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="">';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
}
}
-
- return $this->content;
}
}
$this->title = get_string('calendar', 'calendar');
$this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
- $this->version = 2004052400;
+ $this->version = 2005052600;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
}
function get_content() {
$this->title = get_string('upcomingevents', 'calendar');
$this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
- $this->version = 2004052400;
+ $this->version = 2004052600;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
}
function get_content() {
$this->content = New object;
$this->content->text = '';
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/calendar/view.php?view=upcoming&course='.$this->course->id.'">'.get_string('gotocalendar', 'calendar').'</a>...';
- $this->content->footer .= '<br /><a href="'.$CFG->wwwroot.'/calendar/event.php?action=new">'.get_string('newevent', 'calendar').'</a>...';
+ $this->content->footer .= '<br /><a href="'.$CFG->wwwroot.'/calendar/event.php?action=new&course='.$this->course->id.'">'.get_string('newevent', 'calendar').'</a>...';
if($this->course === NULL) {
// Overrides: use no course at all
$this->title = get_string('mycourses');
$this->content_type = BLOCK_TYPE_LIST;
$this->course = $course;
- $this->version = 2004041800;
+ $this->version = 2005052600;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
}
function get_content() {
$this->content->icons[]=$icon;
}
$this->title = get_string('mycourses');
- $this->content->footer = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
+ $this->content->footer = "<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
return $this->content;
}
}
$this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
$this->content->icons[]=$icon;
}
- $this->content->footer = "<p><a href=\"$CFG->wwwroot/course/\">".get_string("searchcourses")."</a>...";
+ $this->content->footer = "<a href=\"$CFG->wwwroot/course/\">".get_string("searchcourses")."</a>...";
$this->title = get_string('categories');
} else { // Just print course names of single category
$category = array_shift($categories);
$courses = get_courses($category->id);
-
+
if ($courses) {
foreach ($courses as $course) {
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
$this->content->icons[]=$icon;
}
- $this->content->footer = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
+ $this->content->footer = "<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
} else {
$this->content->items = array();
$this->content->icons = array();
$this->title = get_string('blockname','block_course_summary');
$this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
- $this->version = 2004041400;
+ $this->version = 2004052600;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
}
function get_content() {
- global $USER, $CFG;
if($this->content !== NULL) {
return $this->content;
}
$this->content = New object;
- $this->content->text = '';
- $this->content->footer = '';
$this->content->text = format_text($this->course->summary, FORMAT_HTML);
+ $this->content->footer = '';
return $this->content;
}
break;
}
if ($this->edit_controls !== NULL || !$this->hide_header()) {
- print_side_block($title, $this->content->text, NULL, NULL, $this->content->footer);
+ print_side_block($title, $this->content->text, NULL, NULL, $this->content->footer, $this->html_attributes());
} else {
- print_side_block(NULL, $this->content->text, NULL, NULL, $this->content->footer);
+ print_side_block(NULL, $this->content->text, NULL, NULL, $this->content->footer, $this->html_attributes());
}
break;
case BLOCK_TYPE_LIST:
break;
}
if ($this->edit_controls !== NULL || !$this->hide_header()) {
- print_side_block($title, '', $this->content->items, $this->content->icons, $this->content->footer);
+ print_side_block($title, '', $this->content->items, $this->content->icons, $this->content->footer, $this->html_attributes());
} else {
- print_side_block(NULL, '', $this->content->items, $this->content->icons, $this->content->footer);
+ print_side_block(NULL, '', $this->content->items, $this->content->icons, $this->content->footer, $this->html_attributes());
}
break;
}
}
print_side_block($title, ' ', NULL, NULL, '');
}
+
function add_edit_controls($options, $blockid) {
global $CFG, $THEME;
$errors[] = 'version_not_set';
$correct = false;
}
- $allformats = COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL;
+ $allformats = COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
if(!($this->applicable_formats() & $allformats)) {
$errors[] = 'no_course_formats';
$correct = false;
return false;
}
function html_attributes() {
- // Default case: we want no extra attributes
- return false;
+ // Default case: just an id for the block, with our name in it
+ return array('id' => 'block_'.$this->name());
}
}
$this->title = get_string('latestnews');
$this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
- $this->version = 2004041200;
+ $this->version = 2004052600;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
}
function get_content() {
}
require_once($CFG->dirroot.'/course/lib.php');
+ require_once($CFG->dirroot.'/mod/forum/lib.php');
$this->content = New object;
$this->content->text = '';
$this->title = get_string('blockname','block_online_users');
$this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
- $this->version = 2004041800;
+ $this->version = 2004052700;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
}
function has_config() {return true;}
$this->title = get_string('people');
$this->content_type = BLOCK_TYPE_LIST;
$this->course = $course;
- $this->version = 2004041800;
+ $this->version = 2004052600;
}
function get_content() {
}
}
- $fullname = fullname($USER, true);
- $editmyprofile = '<a title="'.$fullname.'" href="../user/edit.php?id='.$USER->id.'&course='.$this->course->id.'">'.get_string('editmyprofile').'</a>';
- if ($USER->description) {
- $this->content->items[]= $editmyprofile;
- } else {
- $this->content->items[]= $editmyprofile." <blink>*</blink>";
+ if(!empty($USER)) {
+ $fullname = fullname($USER, true);
+ $editmyprofile = '<a title="'.$fullname.'" href="../user/edit.php?id='.$USER->id.'&course='.$this->course->id.'">'.get_string('editmyprofile').'</a>';
+ if ($USER->description) {
+ $this->content->items[]= $editmyprofile;
+ } else {
+ $this->content->items[]= $editmyprofile." <blink>*</blink>";
+ }
+ $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
}
- $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
return $this->content;
}
}
$this->content_type = BLOCK_TYPE_TEXT;
$this->course = $course;
- $this->version = 2004050500;
+ $this->version = 2004052800;
}
-
+
function applicable_formats() {
return (COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS);
}
if ($highlight) {
$text .= "<br><a href=\"$link#$highlight\">$linktext</a>";
}
-
- $this->content = New object;
- $this->content->header = 'Hello';
+
+ $this->content = New stdClass;
$this->content->footer = '';
$this->content->text = $text;
return $this->content;
--- /dev/null
+<?php //$Id$
+
+class CourseBlock_site_main_menu extends MoodleBlock {
+ function CourseBlock_site_main_menu ($course) {
+ $this->title = get_string('mainmenu');
+ $this->content_type = BLOCK_TYPE_LIST;
+ $this->course = $course;
+ $this->version = 2004052700;
+ }
+
+ function applicable_formats() {
+ return COURSE_FORMAT_SITE;
+ }
+
+ function get_content() {
+ global $USER, $CFG;
+
+ if($this->content !== NULL) {
+ return $this->content;
+ }
+
+ $this->content = New stdClass;
+ $this->content->items = array();
+ $this->content->icons = array();
+ $this->content->footer = '';
+
+ $isteacher = isteacher($this->course->id);
+ $isediting = isediting($this->course->id);
+ $ismoving = ismoving($this->course->id);
+
+ $sections = get_all_sections($this->course->id);
+ $section = $sections[0];
+
+ if($section->sequence || $isediting) {
+ get_all_mods($this->course->id, $mods, $modnames, $modnamesplural, $modnamesused);
+ }
+
+ $groupbuttons = $this->course->groupmode;
+ $groupbuttonslink = (!$this->course->groupmodeforce);
+
+ if ($ismoving) {
+ $strmovehere = get_string('movehere');
+ $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
+ $strcancel= get_string('cancel');
+ $stractivityclipboard = $USER->activitycopyname;
+ }
+
+ $modinfo = unserialize($this->course->modinfo);
+ $editbuttons = '';
+
+ if ($ismoving) {
+ $this->content->items[] = ' <img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
+ $this->content->icons[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
+ }
+
+ if (!empty($section->sequence)) {
+ $sectionmods = explode(',', $section->sequence);
+ foreach ($sectionmods as $modnumber) {
+ if (empty($mods[$modnumber])) {
+ continue;
+ }
+ $mod = $mods[$modnumber];
+ if ($isediting && !$ismoving) {
+ if ($groupbuttons) {
+ if (! $mod->groupmodelink = $groupbuttonslink) {
+ $mod->groupmode = $this->course->groupmode;
+ }
+
+ } else {
+ $mod->groupmode = false;
+ }
+ $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
+ } else {
+ $editbuttons = '';
+ }
+ if ($mod->visible || $isteacher) {
+ if ($ismoving) {
+ if ($mod->id == $USER->activitycopy) {
+ continue;
+ }
+ $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'">'.
+ '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
+ $this->content->icons[] = '';
+ }
+ $instancename = urldecode($modinfo[$modnumber]->name);
+ if (!empty($CFG->filterall)) {
+ $instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
+ }
+ $linkcss = $mod->visible ? '' : ' class="dimmed" ';
+ if (!empty($modinfo[$modnumber]->extra)) {
+ $extra = urldecode($modinfo[$modnumber]->extra);
+ } else {
+ $extra = '';
+ }
+
+ if ($mod->modname == 'label') {
+ $this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
+ $this->content->icons[] = '';
+ } else {
+ $this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
+ ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
+ $this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$mod->modname.'/icon.gif" height="16" width="16" alt="'.$mod->modfullname.'">';
+ }
+ }
+ }
+ }
+
+ if ($ismoving) {
+ $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'">'.
+ '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
+ $this->content->icons[] = '';
+ }
+
+ if ($isediting && $modnames) {
+ $this->content->footer = '<div style="text-align: right;">'.
+ popup_form($CFG->wwwroot.'/course/mod.php?id='.$this->course->id.'&section='.$section->section.'&add=',
+ $modnames, 'section0', '', get_string('add').'...', 'mods', get_string('activities'), true) . '</div>';
+ } else {
+ $this->content->footer = '';
+ }
+
+ return $this->content;
+ }
+}
+
+?>
// database (blocks_version) to determine whether upgrades should
// be performed (see db/backup_*.php)
-$blocks_version = 2004052400; // The current version is a date (YYYYMMDDXX)
+$blocks_version = 2004052700; // The current version is a date (YYYYMMDDXX)
$defaultformat = FORMAT_MOODLE;
}
+ // If a course has been supplied in the URL, change the filters to show that one
+ if(!empty($_GET['course'])) {
+ if(is_numeric($_GET['course']) && $_GET['course'] > 0 && record_exists('course', 'id', $_GET['course'])) {
+ if($_GET['course'] == 1) {
+ // If coming from the home page, show all courses
+ $SESSION->cal_courses_shown = calendar_get_default_courses(true);
+ calendar_set_referring_course(0);
+ }
+ else {
+ // Otherwise show just this one
+ $SESSION->cal_courses_shown = intval($_GET['course']);
+ calendar_set_referring_course($SESSION->cal_courses_shown);
+ }
+ }
+ }
+
switch($_REQUEST['action']) {
case 'delete':
$title = get_string('deleteevent', 'calendar');
$d = $eventtime['mday'];
$y = $eventtime['year'];
// Display confirmation form
- print_side_block_start(get_string('deleteevent', 'calendar').': '.$event->name, '', 'mycalendar');
+ print_side_block_start(get_string('deleteevent', 'calendar').': '.$event->name, array('class' => 'mycalendar'));
include('event_delete.html');
print_side_block_end();
}
$form->minutes = '';
}
}
- print_side_block_start(get_string('editevent', 'calendar'), '', 'mycalendar');
+ print_side_block_start(get_string('editevent', 'calendar'), array('class' => 'mycalendar'));
include('event_edit.html');
print_side_block_end();
if ($usehtmleditor) {
$header = ' ('.$header.')';
}
- print_side_block_start(get_string('newevent', 'calendar').$header, '', 'mycalendar');
+ print_side_block_start(get_string('newevent', 'calendar').$header, array('class' => 'mycalendar'));
if($_REQUEST['type'] == 'select') {
$defaultcourse = $SESSION->cal_course_referer;
if(isteacheredit($defaultcourse, $USER->id)) {
echo calendar_overlib_html();
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
- print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain');
+ print_side_block_start(get_string('monthlyview', 'calendar'));
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
$allowed->courses = false; // This may change just below
$allowed->site = isadmin($USER->id);
- if(!empty($SESSION->cal_course_referer) && isteacheredit($SESSION->cal_course_referer, $USER->id)) {
+ if(!empty($SESSION->cal_course_referer) && $SESSION->cal_course_referer > 1 && isteacheredit($SESSION->cal_course_referer, $USER->id)) {
$allowed->courses = array($SESSION->cal_course_referer => 1);
$allowed->groups = get_groups($SESSION->cal_course_referer);
}
$SESSION->cal_show_course = true;
}
if(!isset($SESSION->cal_show_user)) {
- $SESSION->cal_show_user = isset($USER->id) ? $USER->id : false;
+ $SESSION->cal_show_user = true;
}
if(empty($SESSION->cal_courses_shown)) {
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
}
+ if(empty($SESSION->cal_users_shown)) {
+ // The empty() instead of !isset() here makes a whole world of difference,
+ // as it will automatically change to the user's id when the user first logs
+ // in. With !isset(), it would never do that.
+ $SESSION->cal_users_shown = isset($USER->id) ? $USER->id : false;
+ }
+ else if(is_numeric($SESSION->cal_users_shown) && !empty($USER->id) && $SESSION->cal_users_shown != $USER->id) {
+ // Follow the white rabbit, for example if a teacher logs in as a student
+ $SESSION->cal_users_shown = $USER->id;
+ }
}
function calendar_overlib_html() {
}
if($SESSION->cal_show_user || $ignorefilters) {
- // This ignores the "which user to see" setting
- // The functionality to do that does exist, but this was
- // the most painless way to solve bug 1323. And anyway,
- // it wasn't being used anywhere.
- $user = $USER->id;
- //$user = $SESSION->cal_show_user;
+ // This doesn't work for arrays yet (maybe someday it will)
+ $user = $SESSION->cal_users_shown;
}
else {
$user = false;
// For each course...
foreach($groupcourses as $courseid) {
// If the user is an editing teacher in there,
- if(isteacheredit($courseid, $USER->id)) {
+ if(!empty($USER) && isteacheredit($courseid, $USER->id)) {
// Show events from all groups
if(($grouprecords = get_groups($courseid)) !== false) {
$grouparray = array_merge($grouparray, array_keys($grouprecords));
optional_variable($_GET['cal_y']);
switch($_GET['var']) {
+ case 'setuser':
+ // Not implemented yet (or possibly at all)
+ break;
case 'setcourse':
$id = intval($_GET['id']);
if($id == 0) {
$SESSION->cal_show_global = !$SESSION->cal_show_global;
break;
case 'showuser':
- if($SESSION->cal_show_user) {
- $SESSION->cal_show_user = false;
- }
- else {
- $SESSION->cal_show_user = $USER->id;
- }
+ $SESSION->cal_show_user = !$SESSION->cal_show_user;
break;
}
// If a course has been supplied in the URL, change the filters to show that one
if(!empty($_GET['course'])) {
if(is_numeric($_GET['course']) && $_GET['course'] > 0 && record_exists('course', 'id', $_GET['course'])) {
- $SESSION->cal_courses_shown = intval($_GET['course']);
- calendar_set_referring_course($SESSION->cal_courses_shown);
+ if($_GET['course'] == 1) {
+ // If coming from the home page, show all courses
+ $SESSION->cal_courses_shown = calendar_get_default_courses(true);
+ calendar_set_referring_course(0);
+ }
+ else {
+ // Otherwise show just this one
+ $SESSION->cal_courses_shown = intval($_GET['course']);
+ calendar_set_referring_course($SESSION->cal_courses_shown);
+ }
}
}
// START: Last column (3-month display)
echo '<td style="vertical-align: top; width: 180px;">';
- print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain');
+ print_side_block_start(get_string('monthlyview', 'calendar'));
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
$getvars = 'cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
$text.= '</form></div>';
}
- print_side_block_start($text, '', 'mycalendar');
+ print_side_block_start($text, array('class' => 'mycalendar'));
echo '<p>'.calendar_top_controls('day', array('d' => $d, 'm' => $m, 'y' => $y)).'</p>';
if (empty($events)) {
$text.= '</form></div>';
}
- print_side_block_start($text, '', 'mycalendar');
+ print_side_block_start($text, array('class' => 'mycalendar'));
echo calendar_top_controls('month', array('m' => $m, 'y' => $y));
$text.= '</form></div>';
}
- print_side_block_start($text, '', 'mycalendar');
+ print_side_block_start($text, array('class' => 'mycalendar'));
if ($events) {
foreach ($events as $event) {
calendar_print_event($event);
$thissection = $sections[$section];
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
- echo "<tr>";
+ echo '<tr id="section_0">';
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\" valign=top width=20> </td>";
echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontent\" width=\"100%\">";
echo "</td>";
if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students
- echo "<td valign=top align=center $colormain width=\"100%\">";
+ echo '<td id="section_'.($section).'" style="vertical-align:top; text-align: center; width: 100%;" '.$colormain.'>';
echo get_string("notavailable");
echo "</td>";
} else {
- echo "<td valign=top $colormain width=\"100%\">";
+ echo '<td id="section_'.($section).'" style="vertical-align:top; width: 100%;" '.$colormain.'>';
echo format_text($thissection->summary, FORMAT_HTML);
// Get all the possible users
$users = array();
-
+
if ($course->category) {
$courseusers = get_course_users($course->id);
} else {
$courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname");
- }
-
+ }
+
if ($courseusers) {
foreach ($courseusers as $courseuser) {
$users[$courseuser->id] = fullname($courseuser, $isteacher);
if ($guest = get_guest()) {
$users[$guest->id] = fullname($guest);
}
-
+
if (isadmin()) {
if ($ccc = get_records("course", "", "", "fullname")) {
foreach ($ccc as $cc) {
$courses["$cc->id"] = "$cc->fullname";
} else {
$courses["$cc->id"] = " $cc->fullname (Site)";
- }
+ }
}
}
asort($courses);
foreach ($modinfo as $mod) {
if ($mod->mod == "label") {
continue;
- }
+ }
if (!$mod->visible and !$isteacher) {
continue;
}
}
-function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
+function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
$url="", $modname="", $modid=0, $modaction="") {
-// It is assumed that $date is the GMT time of midnight for that day,
+// It is assumed that $date is the GMT time of midnight for that day,
// and so the next 86400 seconds worth of logs are printed.
global $CFG, $db;
function print_recent_activity($course) {
// $course is an object
- // This function trawls through the logs looking for
+ // This function trawls through the logs looking for
// anything new since the user's last login
global $CFG, $USER, $THEME, $SESSION;
// Next, have there been any modifications to the course structure?
- $logs = get_records_select("log", "time > '$timestart' AND course = '$course->id' AND
+ $logs = get_records_select("log", "time > '$timestart' AND course = '$course->id' AND
module = 'course' AND action LIKE '% mod'", "time ASC");
if ($logs) {
$tempmod->id = $info[1];
//Obtain the visible property from the instance
$modvisible = instance_is_visible($info[0],$tempmod);
-
+
//Only if the mod is visible
if ($modvisible) {
switch ($log->action) {
}
break;
case "delete mod":
- if (!empty($changelist["$log->info"]["operation"]) and
+ if (!empty($changelist["$log->info"]["operation"]) and
$changelist["$log->info"]["operation"] == "add") {
$changelist["$log->info"] = NULL;
} else {
}
}
}
- }
+ }
// If this site uses Library module, then print recent items
function get_array_of_activities($courseid) {
-// For a given course, returns an array of course activity objects
+// For a given course, returns an array of course activity objects
// Each item in the array contains he following properties:
// cm - course module id
// mod - name of the module (eg forum)
function get_all_sections($courseid) {
-
- return get_records("course_sections", "course", "$courseid", "section",
+
+ return get_records("course_sections", "course", "$courseid", "section",
"section, id, course, summary, sequence, visible");
}
}
}
-function print_section_block($heading, $course, $section, $mods, $modnames, $modnamesused,
- $absolute=true, $width="100%") {
-
- global $CFG, $USER, $THEME;
- static $groupbuttons;
- static $isteacher;
- static $isediting;
- static $ismoving;
- static $strmovehere;
- static $strmovefull;
- static $strcancel;
- static $stractivityclipboard;
-
- if (!isset($isteacher)) {
- $groupbuttons = $course->groupmode and !$course->groupmodeforce;
- $isteacher = isteacher($course->id);
- $isediting = isediting($course->id);
- $ismoving = ismoving($course->id);
- if ($ismoving) {
- $strmovehere = get_string("movehere");
- $strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
- $strcancel= get_string("cancel");
- $stractivityclipboard = $USER->activitycopyname;
- }
- }
-
- $modinfo = unserialize($course->modinfo);
- $moddata = array();
- $modicon = array();
- $editbuttons = "";
-
- if ($ismoving) {
- $modicon[] = " <img align=bottom src=\"$CFG->pixpath/t/move.gif\" height=\"11\" width=\"11\">";
- $moddata[] = "$USER->activitycopyname (<a href=\"$CFG->wwwroot/course/mod.php?cancelcopy=true\">$strcancel</a>)";
- }
-
- if (!empty($section->sequence)) {
-
- $sectionmods = explode(",", $section->sequence);
-
-
- foreach ($sectionmods as $modnumber) {
- if (empty($mods[$modnumber])) {
- continue;
- }
- $mod = $mods[$modnumber];
- if ($isediting and !$ismoving) {
- if (!$groupbuttons) {
- $mod->groupmode = false;
- }
- $editbuttons = "<br />".make_editing_buttons($mod, $absolute, true);
- } else {
- $editbuttons = "";
- }
- if ($mod->visible or $isteacher) {
- if ($ismoving) {
- if ($mod->id == $USER->activitycopy) {
- continue;
- }
- $modicon[] = "";
- $moddata[] = "<a title=\"$strmovefull\"".
- " href=\"$CFG->wwwroot/course/mod.php?moveto=$mod->id\">".
- "<img height=\"16\" width=\"80\" src=\"$CFG->pixpath/movehere.gif\" ".
- " alt=\"$strmovehere\" border=\"0\"></a>";
- }
- $instancename = urldecode($modinfo[$modnumber]->name);
- if (!empty($CFG->filterall)) {
- $instancename = filter_text("<nolink>$instancename</nolink>", $course->id);
- }
- $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
- if (!empty($modinfo[$modnumber]->extra)) {
- $extra = urldecode($modinfo[$modnumber]->extra);
- } else {
- $extra = "";
- }
-
- if (!empty($modinfo[$modnumber]->icon)) {
- $icon = "$CFG->pixpath/".urldecode($modinfo[$modnumber]->icon);
- } else {
- $icon = "$CFG->modpixpath/$mod->modname/icon.gif";
- }
-
- if ($mod->modname == "label") {
- $modicon[] = "";
- $moddata[] = format_text($extra, FORMAT_HTML).$editbuttons;
- } else {
- $modicon[] = "<img src=\"$icon\"".
- " height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
- $moddata[] = "<a title=\"$mod->modfullname\" $linkcss $extra".
- "href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a>".
- "$editbuttons";
- }
- }
- }
- }
- if ($ismoving) {
- $modicon[] = "";
- $moddata[] = "<a title=\"$strmovefull\"".
- " href=\"$CFG->wwwroot/course/mod.php?movetosection=$section->id\">".
- "<img height=\"16\" width=\"80\" src=\"$CFG->pixpath/movehere.gif\" ".
- " alt=\"$strmovehere\" border=\"0\"></a>";
- }
- if ($isediting) {
- $editmenu = popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section->section&add=",
- $modnames, "section0", "", get_string("add")."...", "mods", get_string("activities"), true);
- $editmenu = "<div align=right>$editmenu</div>";
- } else {
- $editmenu = "";
- }
-
- print_side_block($heading, "", $moddata, $modicon, $editmenu, $width);
-}
-
function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
/// Prints a section full of activity modules
$modinfo = unserialize($course->modinfo);
- echo "<table width=\"$width\" cellpadding=1 cellspacing=0>\n";
+ echo '<table width="'.$width.'" cellpadding="1" cellspacing="0">';
if (!empty($section->sequence)) {
$sectionmods = explode(",", $section->sequence);
echo "</td></tr></table>";
}
-function print_side_block($heading="", $content="", $list=NULL, $icons=NULL, $footer="", $width=180) {
-// Prints a nice side block with an optional header. The content can either
-// be a block of HTML or a list of text with optional icons.
-
- global $THEME;
-
- print_side_block_start($heading, $width);
-
- if ($content) {
- echo "$content";
- if ($footer) {
- echo "<center><font size=\"-2\">$footer</font></center>";
- }
- } else {
- echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
- if ($list) {
- foreach ($list as $key => $string) {
- echo "<tr bgcolor=\"$THEME->cellcontent2\">";
- if ($icons) {
- echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">".$icons[$key]."</td>";
- }
- echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>";
- echo "</tr>";
- }
- }
- if ($footer) {
- echo "<tr bgcolor=\"$THEME->cellcontent2\">";
- echo "<td class=\"sideblocklinks\" ";
- if ($icons) {
- echo ' colspan="2" ';
- }
- echo '>';
- echo "<center><font size=\"-2\">$footer</font></center>";
- echo "</td></tr>";
- }
- echo "</table>";
- }
-
- print_side_block_end();
-}
-
-function print_side_block_start($heading="", $width=180, $class="sideblockmain") {
-// Starts a nice side block with an optional header.
-
- global $THEME;
-
- echo "<table class=\"sideblock\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
- if ($heading) {
- echo "<tr>";
- echo "<td class=\"sideblockheading\" bgcolor=\"$THEME->cellheading\">$heading</td>";
- echo "</tr>";
- }
- echo "<tr>";
- echo "<td class=\"$class\" bgcolor=\"$THEME->cellcontent2\">";
-}
-
-function print_side_block_end() {
- echo "</td></tr>";
- echo "</table><br />";
-}
-
-
-function print_admin_links ($siteid, $width=180) {
- global $CFG, $THEME;
-
- if (isadmin()) {
- $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/configure.php\">".get_string("configuration")."</a>...";
- $modicon[]="<img src=\"$CFG->pixpath/i/admin.gif\" height=16 width=16 alt=\"\" />";
-
- $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/users.php\">".get_string("users")."</a>...";
- $modicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\" />";
- }
-
- if (iscreator()) {
- $moddata[]="<a href=\"$CFG->wwwroot/course/index.php?edit=on\">".get_string("courses")."</a>";
- $modicon[]="<img src=\"$CFG->pixpath/i/course.gif\" height=16 width=16 alt=\"\" />";
- $fulladmin = "";
- }
-
- if (isadmin()) {
- $moddata[]="<a href=\"$CFG->wwwroot/course/log.php?id=$siteid\">".get_string("logs")."</a>";
- $modicon[]="<img src=\"$CFG->pixpath/i/log.gif\" height=16 width=16 alt=\"\" />";
-
- $moddata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$siteid\">".get_string("sitefiles")."</a>";
- $modicon[]="<img src=\"$CFG->pixpath/i/files.gif\" height=16 width=16 alt=\"\" />";
-
- if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
- $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/$CFG->dbtype/frame.php\">".
- get_string("managedatabase")."</a>";
- $modicon[]="<img src=\"$CFG->pixpath/i/db.gif\" height=16 width=16 alt=\"\" />";
- }
- $fulladmin = "<p><a href=\"$CFG->wwwroot/$CFG->admin/\">".get_string("admin")."</a>...";
- }
-
- print_side_block(get_string("administration"), "", $moddata, $modicon, $fulladmin, $width);
-
- echo "<img src=\"$CFG->wwwroot/pix/spacer.gif\" width=\"$width\" height=1><br>";
-}
-
-function print_course_admin_links($course, $width=180) {
- global $USER, $CFG, $THEME;
-
- if (isguest()) {
- return true;
- }
-
- if (isteacher($course->id)) {
-
- $isteacheredit = isteacheredit($course->id);
-
- if ($isteacheredit) {
- $adminicon[]="<img src=\"$CFG->pixpath/i/edit.gif\" height=16 width=16 alt=\"\">";
- if (isediting($course->id)) {
- $admindata[]="<a href=\"view.php?id=$course->id&edit=off\">".get_string("turneditingoff")."</a>";
- } else {
- $admindata[]="<a href=\"view.php?id=$course->id&edit=on\">".get_string("turneditingon")."</a>";
- }
- $admindata[]="<a href=\"edit.php?id=$course->id\">".get_string("settings")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/settings.gif\" height=16 width=16 alt=\"\">";
-
- if (iscreator() or !empty($CFG->teacherassignteachers)) {
- if (!$course->teachers) {
- $course->teachers = get_string("defaultcourseteachers");
- }
- $admindata[]="<a href=\"teacher.php?id=$course->id\">$course->teachers...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
- }
-
- if (!$course->students) {
- $course->students = get_string("defaultcoursestudents");
- }
- $admindata[]="<a href=\"student.php?id=$course->id\">$course->students...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
-
- $admindata[]="<a href=\"$CFG->wwwroot/backup/backup.php?id=$course->id\">".get_string("backup")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/backup.gif\" height=16 width=16 alt=\"\">";
-
- $admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id&wdir=/backupdata\">".get_string("restore")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/restore.gif\" height=16 width=16 alt=\"\">";
- $admindata[]="<a href=\"scales.php?id=$course->id\">".get_string("scales")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/scales.gif\" height=16 width=16 alt=\"\">";
- }
-
- $admindata[]="<a href=\"grades.php?id=$course->id\">".get_string("grades")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/grades.gif\" height=16 width=16 alt=\"\">";
-
- $admindata[]="<a href=\"log.php?id=$course->id\">".get_string("logs")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/log.gif\" height=16 width=16 alt=\"\">";
-
- if ($isteacheredit) {
- $admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id\">".get_string("files")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/files.gif\" height=16 width=16 alt=\"\">";
- }
-
- $admindata[]="<a href=\"$CFG->wwwroot/doc/view.php?id=$course->id&file=teacher.html\">".get_string("help")."...</a>";
- $adminicon[]="<img src=\"$CFG->modpixpath/resource/icon.gif\" height=16 width=16 alt=\"\">";
-
- if ($teacherforum = forum_get_course_forum($course->id, "teacher")) {
- $admindata[]="<a href=\"$CFG->wwwroot/mod/forum/view.php?f=$teacherforum->id\">".get_string("nameteacher","forum")."</a>";
- $adminicon[]="<img src=\"$CFG->modpixpath/forum/icon.gif\" height=16 width=16 alt=\"\">";
- }
-
- } else if (!isguest()) { // Students menu
- if ($course->showgrades) {
- $admindata[]="<a href=\"grade.php?id=$course->id\">".get_string("grades")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/grades.gif\" height=16 width=16 alt=\"\">";
- }
- if ($course->showreports) {
- $admindata[]="<a href=\"user.php?id=$course->id&user=$USER->id\">".get_string("activityreport")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/report.gif\" height=16 width=16 alt=\"\">";
- }
- if (is_internal_auth()) {
- $admindata[]="<a href=\"$CFG->wwwroot/login/change_password.php?id=$course->id\">".
- get_string("changepassword")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
- } else if ($CFG->changepassword) {
- $admindata[]="<a href=\"$CFG->changepassword\">".get_string("changepassword")."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
- }
- if ($CFG->allowunenroll) {
- $admindata[]="<a href=\"unenrol.php?id=$course->id\">".get_string("unenrolme", "", $course->shortname)."...</a>";
- $adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
- }
- }
-
- if (!empty($admindata)) {
- print_side_block(get_string("administration"), "", $admindata, $adminicon, "", $width);
- }
-}
-
function make_categories_list(&$list, &$parents, $category=NULL, $path="") {
-/// Given an empty array, this function recursively travels the
+/// Given an empty array, this function recursively travels the
/// categories, building up a nice list for display. It also makes
/// an array that list all the parents for each category.
}
$parents[$cat->id][] = $category->id;
}
- make_categories_list($list, $parents, $cat, $path);
+ make_categories_list($list, $parents, $cat, $path);
}
}
}
function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1) {
-/// Recursive function to print out all the categories in a nice format
+/// Recursive function to print out all the categories in a nice format
/// with or without courses included
global $CFG;
if (isset($CFG->max_category_depth)&&($depth >= $CFG->max_category_depth)) {
} else {
return; // Don't bother printing children of invisible categories
}
-
+
} else {
$category->id = "0";
}
$down = $last ? false : true;
$first = false;
- print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1);
+ print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1);
}
}
}
print_spacer(10, $indent);
echo "</td>";
}
-
+
echo "<td valign=\"top\">$catimage</td>";
echo "<td valign=\"top\" width=\"100%\" class=\"categoryname\">";
echo "<a $catlinkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
echo "<img alt=\"\" height=16 width=18 border=0 src=\"$CFG->pixpath/spacer.gif\">";
}
if ($course->summary) {
- link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo",
- "<img hspace=1 alt=\"$strsummary\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/info.gif\">",
+ link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo",
+ "<img hspace=1 alt=\"$strsummary\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/info.gif\">",
400, 500, $strsummary);
} else {
echo "<img alt=\"\" height=16 width=18 border=0 src=\"$CFG->pixpath/spacer.gif\">";
print_spacer(10, $indent);
echo "</td>";
}
-
+
echo "<td valign=\"top\" width=\"100%\" class=\"categoryname\">";
echo "<a $catlinkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
echo "</td>";
echo "\n</table>\n";
}
-function print_courses_sideblock($category=0, $width="100%") {
- global $CFG, $THEME, $USER;
- if (empty($THEME->custompix)) {
- $icon = "<img src=\"$CFG->wwwroot/pix/i/course.gif\"".
- " height=\"16\" width=\"16\" alt=\"".get_string("course")."\">";
- } else {
- $icon = "<img src=\"$CFG->wwwroot/theme/$CFG->theme/pix/i/course.gif\"".
- " height=\"16\" width=\"16\" alt=\"".get_string("course")."\">";
- }
-
- if (isset($USER->id) and !isadmin()) { // Just print My Courses
- if ($courses = get_my_courses($USER->id)) {
- foreach ($courses as $course) {
- if (!$course->category) {
- continue;
- }
- $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
- $moddata[]="<a $linkcss title=\"$course->shortname\" ".
- "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
- $modicon[]=$icon;
- }
- $fulllist = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...</p>";
- print_side_block( get_string("mycourses"), "", $moddata, $modicon, $fulllist, $width);
- return;
- }
- }
-
- $categories = get_categories("0"); // Parent = 0 ie top-level categories only
- if (count($categories) > 1) { // Just print top level category links
- foreach ($categories as $category) {
- $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
- $moddata[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
- $modicon[]=$icon;
- }
- $fulllist = "<p><a href=\"$CFG->wwwroot/course/\">".get_string("searchcourses")."</a>...</p>";
- $blocktitle = get_string("categories");
-
- } else { // Just print course names of single category
- $category = array_shift($categories);
- $courses = get_courses($category->id);
-
- if ($courses) {
- foreach ($courses as $course) {
- $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
- $moddata[]="<a $linkcss title=\"$course->shortname\" ".
- "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
- $modicon[]=$icon;
- }
- $fulllist = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...</p>";
- } else {
- $moddata = array();
- $modicon = array();
- $fulllist = get_string("nocoursesyet");
- }
- $blocktitle = get_string("courses");
- }
-
- print_side_block($blocktitle, "", $moddata, $modicon, $fulllist, $width);
-}
-
-
function print_courses($category, $width="100%") {
/// Category is 0 (for all courses) or an object
echo "<table width=\"100%\">";
echo "<tr valign=top>";
echo "<td valign=top width=\"50%\" class=\"courseboxinfo\">";
- echo "<p><font size=3><b><a title=\"".get_string("entercourse")."\"
+ echo "<p><font size=3><b><a title=\"".get_string("entercourse")."\"
$linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a></b></font></p>";
if ($teachers = get_course_teachers($course->id)) {
echo "<p><font size=\"1\">\n";
} else {
$newsequence = "$section->sequence,$mod->coursemodule";
}
-
+
if (set_field("course_sections", "sequence", $newsequence, "id", $section->id)) {
return $section->id; // Return course_sections ID that was used.
} else {
return 0;
}
-
+
} else { // Insert a new record
$section->course = $mod->course;
$section->section = $mod->section;
} else {
return false;
}
-
+
}
return false;
}
/// Update module itself if necessary
if ($mod->section != $section->id) {
- $mod->section = $section->id;
+ $mod->section = $section->id;
if (!update_record("course_modules", $mod)) {
return false;
} else { // Push onto end of previous section
$prevsectionnumber = $thissection->section - 1;
- if (! $prevsection = get_record("course_sections", "course", "$thissection->course",
+ if (! $prevsection = get_record("course_sections", "course", "$thissection->course",
"section", "$prevsectionnumber")) {
error("Previous section ($prevsection->id) doesn't exist");
}
$swap = $mods[$thepos-1];
$mods[$thepos-1] = $mods[$thepos];
$mods[$thepos] = $swap;
-
+
$newsequence = implode(",", $mods);
if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
error("This section could not be updated");
if ($last) {
$nextsectionnumber = $thissection->section + 1;
- if ($nextsection = get_record("course_sections", "course", "$thissection->course",
+ if ($nextsection = get_record("course_sections", "course", "$thissection->course",
"section", "$nextsectionnumber")) {
if (!empty($nextsection->sequence)) {
$swap = $mods[$thepos+1];
$mods[$thepos+1] = $mods[$thepos];
$mods[$thepos] = $swap;
-
+
$newsequence = implode(",", $mods);
if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
error("This section could not be updated");
<?PHP // $Id$
// index.php - the front page.
-
+
require_once("config.php");
require_once("course/lib.php");
- require_once("mod/resource/lib.php");
+ require_once('lib/blocklib.php');
+ require_once("mod/resource/lib.php");
require_once("mod/forum/lib.php");
if (! $site = get_site()) {
"<meta name=\"description\" content=\"".s(strip_tags($site->summary))."\">",
true, "", "$loginstring$langmenu");
- $firstcolumn = false; // for now
- $lastcolumn = false; // for now
- $side = 175;
+ $editing = isediting($site->id);
+
+ $courseformat = COURSE_FORMAT_SITE;
+
+ // Doing this now so we can pass the results to block_action()
+ // and dodge the overhead of doing the same work twice.
- $site_summary_editbuttons = '';
- if (isediting($site->id)) {
- $site_summary_editbuttons = "<br><center><a href=\"$CFG->admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
+ $blocks = $site->blockinfo;
+ $delimpos = strpos($blocks, ':');
+
+ if($delimpos === false) {
+ // No ':' found, we have all left blocks
+ $leftblocks = explode(',', $blocks);
+ $rightblocks = array();
+ }
+ else if($delimpos === 0) {
+ // ':' at start of string, we have all right blocks
+ $blocks = substr($blocks, 1);
+ $leftblocks = array();
+ $rightblocks = explode(',', $blocks);
+ }
+ else {
+ // Both left and right blocks
+ $leftpart = substr($blocks, 0, $delimpos);
+ $rightpart = substr($blocks, $delimpos + 1);
+ $leftblocks = explode(',', $leftpart);
+ $rightblocks = explode(',', $rightpart);
}
- if ($site->summary) {
- $lastcolumn = true;
+ if($editing) {
+ if (isset($_GET['blockaction'])) {
+ if (isset($_GET['blockid'])) {
+ block_action($site, $leftblocks, $rightblocks, strtolower($_GET['blockaction']), intval($_GET['blockid']));
+ }
+ }
+
+ // This has to happen after block_action() has possibly updated the two arrays
+ $allblocks = array_merge($leftblocks, $rightblocks);
+
+ $missingblocks = array();
+ $recblocks = get_records('blocks','visible','1');
+
+ // Note down which blocks are going to get displayed
+ blocks_used($allblocks, $recblocks);
+
+ if($editing && $recblocks) {
+ foreach($recblocks as $recblock) {
+ // If it's not hidden or displayed right now...
+ if(!in_array($recblock->id, $allblocks) && !in_array(-($recblock->id), $allblocks)) {
+ // And if it's applicable for display in this format...
+ if(block_method_result($recblock->name, 'applicable_formats') & $courseformat) {
+ // Add it to the missing blocks
+ $missingblocks[] = $recblock->id;
+ }
+ }
+ }
+ }
}
+ else {
+ // Note down which blocks are going to get displayed
+ $allblocks = array_merge($leftblocks, $rightblocks);
+ $recblocks = get_records('blocks','visible','1');
+ blocks_used($allblocks, $recblocks);
+ }
+
+ // If the block width cache is not set, set it
+ if(!isset($SESSION->blockcache->width->{$site->id}) || $editing) {
+ // This query might be optimized away if we 're in editing mode
+ if(!isset($recblocks)) {
+ $recblocks = get_records('blocks','visible','1');
+ }
+ $preferred_width_left = blocks_preferred_width($leftblocks, $recblocks);
+ $preferred_width_right = blocks_preferred_width($rightblocks, $recblocks);
+ // This may be kind of organizational overkill, granted...
+ // But is there any real need to simplify the structure?
+ $SESSION->blockcache->width->{$site->id}->left = $preferred_width_left;
+ $SESSION->blockcache->width->{$site->id}->right = $preferred_width_right;
+ }
+ else {
+ $preferred_width_left = $SESSION->blockcache->width->{$site->id}->left;
+ $preferred_width_right = $SESSION->blockcache->width->{$site->id}->right;
+ }
?>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
- <?PHP
- $sections = get_all_sections($site->id);
-
- if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
-
- echo "<td width=\"$side\" valign=top nowrap>";
- $firstcolumn=true;
-
- if ($sections[0]->sequence or isediting($site->id)) {
- get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
- print_section_block(get_string("mainmenu"), $site, $sections[0],
- $mods, $modnames, $modnamesused, true, $side);
- }
-
- if (isadmin()) {
- echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
- echo "<br />";
- }
-
- switch ($CFG->frontpage) {
- case FRONTPAGENEWS: // print news links on the side
- print_courses_sideblock(0, "$side");
- break;
-
- case FRONTPAGECOURSELIST:
- case FRONTPAGECATEGORYNAMES:
- if ($site->newsitems) {
- if ($news = forum_get_course_forum($site->id, "news")) {
- print_side_block_start(get_string("latestnews"), $side, "sideblocklatestnews");
- echo "<font size=\"-2\">";
- forum_print_latest_discussions($news->id, $site->newsitems, "minimal", "", false);
- echo "</font>";
- print_side_block_end();
- }
- }
- break;
- }
- print_spacer(1,$side);
- }
-
- if (iscreator()) {
- if (!$firstcolumn) {
- echo "<td width=\"$side\" valign=top nowrap>";
- $firstcolumn=true;
- }
- print_admin_links($site->id, $side);
- }
-
- if ($firstcolumn) {
- echo "</td>";
- }
- if ($lastcolumn) {
- echo "<td width=\"70%\" valign=\"top\">";
- } else {
- echo "<td width=\"100%\" valign=\"top\">";
- }
-
- switch ($CFG->frontpage) { /// Display the main part of the front page.
- case FRONTPAGENEWS:
- if (! $newsforum = forum_get_course_forum($site->id, "news")) {
- error("Could not find or create a main news forum for the site");
- }
-
- if (isset($USER->id)) {
- $SESSION->fromdiscussion = "$CFG->wwwroot";
- if (forum_is_subscribed($USER->id, $newsforum->id)) {
- $subtext = get_string("unsubscribe", "forum");
- } else {
- $subtext = get_string("subscribe", "forum");
- }
- $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0 class=headingblockcontent><tr>
- <td>$newsforum->name</td>
- <td align=right><font size=1>
- <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
- </td></tr></table>";
- } else {
- $headertext = $newsforum->name;
- }
- print_heading_block($headertext);
- print_spacer(8,1);
- forum_print_latest_discussions($newsforum->id, $site->newsitems);
- break;
-
- case FRONTPAGECOURSELIST:
- case FRONTPAGECATEGORYNAMES:
- if (isset($USER->id) and !isset($USER->admin)) {
- print_heading_block(get_string("mycourses"));
- print_spacer(8,1);
- print_my_moodle();
- } else {
- if (count_records("course_categories") > 1) {
- if ($CFG->frontpage == FRONTPAGECOURSELIST) {
- print_heading_block(get_string("availablecourses"));
- } else {
- print_heading_block(get_string("categories"));
- }
- print_spacer(8,1);
- print_simple_box_start("center", "100%");
- print_whole_category_list();
- print_simple_box_end();
- print_course_search("", false, "short");
- } else {
- print_heading_block(get_string("availablecourses"));
- print_spacer(8,1);
- print_courses(0, "100%");
- }
- }
- break;
-
- }
-
- echo "</td>";
-
- if ($lastcolumn) {
- echo "<td width=\"30%\" valign=\"top\">";
- print_simple_box(format_text($site->summary, FORMAT_HTML).$site_summary_editbuttons,
- "", "100%", $THEME->cellcontent2, 5, "siteinfo");
- print_spacer(1,$side);
- echo "</td>";
- }
- ?>
+ <?PHP
+
+ if(block_have_active($leftblocks) || $editing) {
+ echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;">';
+ print_course_blocks($site, $leftblocks, BLOCK_LEFT);
+ echo '</td>';
+ }
+
+ echo '<td style="vertical-align: top;">';
+ switch ($CFG->frontpage) { /// Display the main part of the front page.
+ case FRONTPAGENEWS:
+ if (! $newsforum = forum_get_course_forum($site->id, "news")) {
+ error("Could not find or create a main news forum for the site");
+ }
+
+ if (isset($USER->id)) {
+ $SESSION->fromdiscussion = "$CFG->wwwroot";
+ if (forum_is_subscribed($USER->id, $newsforum->id)) {
+ $subtext = get_string("unsubscribe", "forum");
+ } else {
+ $subtext = get_string("subscribe", "forum");
+ }
+ $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0 class=headingblockcontent><tr>
+ <td>$newsforum->name</td>
+ <td align=right><font size=1>
+ <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
+ </td></tr></table>";
+ } else {
+ $headertext = $newsforum->name;
+ }
+ print_heading_block($headertext);
+ print_spacer(8,1);
+ forum_print_latest_discussions($newsforum->id, $site->newsitems);
+ break;
+
+ case FRONTPAGECOURSELIST:
+ case FRONTPAGECATEGORYNAMES:
+ if (isset($USER->id) and !isset($USER->admin)) {
+ print_heading_block(get_string("mycourses"));
+ print_spacer(8,1);
+ print_my_moodle();
+ } else {
+ if (count_records("course_categories") > 1) {
+ if ($CFG->frontpage == FRONTPAGECOURSELIST) {
+ print_heading_block(get_string("availablecourses"));
+ } else {
+ print_heading_block(get_string("categories"));
+ }
+ print_spacer(8,1);
+ print_simple_box_start("center", "100%");
+ print_whole_category_list();
+ print_simple_box_end();
+ print_course_search("", false, "short");
+ } else {
+ print_heading_block(get_string("availablecourses"));
+ print_spacer(8,1);
+ print_courses(0, "100%");
+ }
+ }
+ break;
+
+ }
+
+ echo '</td>';
+ if(block_have_active($rightblocks) || $editing || isadmin()) {
+ echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
+ if (isadmin()) {
+ echo '<div align="center">'.update_course_icon($site->id).'</div>';
+ echo '<br />';
+ }
+ print_course_blocks($site, $rightblocks, BLOCK_RIGHT);
+ if ($editing && !empty($missingblocks)) {
+ block_print_blocks_admin($site->id, $missingblocks);
+ }
+ echo '</td>';
+ }
+?>
</tr>
</table>
-<?PHP print_footer("home"); // Please do not modify this line ?>
+<?PHP print_footer('home'); // Please do not modify this line ?>
define('BLOCK_MOVE_UP', 0x04);
define('BLOCK_MOVE_DOWN', 0x08);
-define('COURSE_FORMAT_WEEKS', 0x01);
-define('COURSE_FORMAT_TOPICS', 0x02);
-define('COURSE_FORMAT_SOCIAL', 0x04);
+define('COURSE_FORMAT_SITE', 0x01);
+define('COURSE_FORMAT_WEEKS', 0x02);
+define('COURSE_FORMAT_TOPICS', 0x04);
+define('COURSE_FORMAT_SOCIAL', 0x08);
//This function retrieves a method-defined property of a class WITHOUT instantiating an object
//It seems that the only way to use the :: operator with variable class names is eval() :(
}
$menu[$block->id] = $blockobject->get_title();
}
- $content = popup_form('view.php?id='.$courseid.'&blockaction=add&blockid=',
+
+ if($courseid == 1) {
+ $target = 'index.php';
+ }
+ else {
+ $target = 'view.php';
+ }
+ $content = popup_form($target.'?id='.$courseid.'&blockaction=add&blockid=',
$menu, 'add_block', '', "$stradd...", '', '', true);
$content = '<div align="center">'.$content.'</div>';
print_side_block($strblocks, $content, NULL, NULL, NULL);
//then the function will update the field too!
function blocks_get_default_blocks ($courseid = NULL, $blocknames="") {
-
+
global $CFG;
if (empty($blocknames)) {
// to the course home page, otherwise the link will go to the site home
global $USER, $CFG, $THEME;
-
/// Course links
if ($course) {
if ($course == "home") { // special case for site home page - please do not remove
return $text;
}
+// ================================================
+// THREE FUNCTIONS MOVED HERE FROM course/lib.php
+// ================================================
+
+function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array()) {
+// Prints a nice side block with an optional header. The content can either
+// be a block of HTML or a list of text with optional icons.
+
+ global $THEME;
+
+ print_side_block_start($heading, $attributes);
+
+ if ($content) {
+ echo $content;
+ if ($footer) {
+ echo "<center><font size=\"-2\">$footer</font></center>";
+ }
+ } else {
+ echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
+ if ($list) {
+ foreach ($list as $key => $string) {
+ echo "<tr bgcolor=\"$THEME->cellcontent2\">";
+ if ($icons) {
+ echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">".$icons[$key]."</td>";
+ }
+ echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>";
+ echo "</tr>";
+ }
+ }
+ if ($footer) {
+ echo "<tr bgcolor=\"$THEME->cellcontent2\">";
+ echo "<td class=\"sideblocklinks\" ";
+ if ($icons) {
+ echo ' colspan="2" ';
+ }
+ echo '>';
+ echo "<center><font size=\"-2\">$footer</font></center>";
+ echo "</td></tr>";
+ }
+ echo "</table>";
+ }
+
+ print_side_block_end();
+}
+
+function print_side_block_start($heading='', $attributes = array()) {
+// Starts a nice side block with an optional header.
+ global $THEME;
+
+ // If there are no special attributes, give a default CSS class
+ if(empty($attributes) || !is_array($attributes)) {
+ $attributes = array('class' => 'sideblock');
+ }
+ else if(!isset($attributes['class'])) {
+ $attributes['class'] = 'sideblock';
+ }
+ else if(!strpos($attributes['class'], 'sideblock')) {
+ $attributes['class'] .= ' sideblock';
+ }
+ // OK, the class is surely there and in addition to anything
+ // else, it's tagged as a sideblock
+
+ $attrtext = '';
+ foreach($attributes as $attr => $val) {
+ $attrtext .= ' '.$attr.'="'.$val.'"';
+ }
+
+ // [pj] UGLY UGLY UGLY! I hate myself for doing this!
+ // When the Lord Moodle 2.0 cometh, his mercy shalt move all this mess
+ // to CSS and banish the evil to the abyss from whence it came.
+ echo '<table style="width: 100%;" cellspacing="0" cellpadding="5"'.$attrtext.'>';
+ if ($heading) {
+ echo '<thead class="sideblockheading"><tr><td>'.$heading.'</td></tr></thead>';
+ }
+ echo '<tbody style="background-color: '.$THEME->cellcontent2.';"><tr><td class="sideblockmain">';
+}
+
+function print_side_block_end() {
+ echo '</td></tr></tbody></table><br />';
+ echo "\n";
+}
+
+
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
?>
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2004052500; // The current version is a date (YYYYMMDDXX)
+$version = 2004052800; // The current version is a date (YYYYMMDDXX)
-$release = "1.3"; // User-friendly version number
+$release = "1.4 development"; // User-friendly version number
?>