Permalink
Browse files

Merging the changes from 1.4 dev branch (site index blocks + various …

…bugfixes)
  • Loading branch information...
defacer
defacer committed May 28, 2004
1 parent 87722d4 commit 89adb17442815058ff107ae4778919c5417682ce
@@ -5,13 +5,16 @@ function CourseBlock_admin($course) {
$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;
}
@@ -21,6 +24,52 @@ function get_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;
}
@@ -82,6 +131,7 @@ function get_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="">';
@@ -102,8 +152,6 @@ function get_content() {
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
}
}
-
- return $this->content;
}
}
@@ -5,7 +5,11 @@ function CourseBlock_calendar_month($course) {
$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() {
@@ -5,7 +5,11 @@ function CourseBlock_calendar_upcoming ($course) {
$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() {
@@ -22,7 +26,7 @@ function get_content() {
$this->content = New object;
$this->content->text = '';
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/calendar/view.php?view=upcoming&amp;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&amp;course='.$this->course->id.'">'.get_string('newevent', 'calendar').'</a>...';
if($this->course === NULL) {
// Overrides: use no course at all
@@ -5,7 +5,11 @@ function CourseBlock_course_list ($course) {
$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() {
@@ -40,7 +44,7 @@ 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;
}
}
@@ -53,20 +57,20 @@ function get_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\" ";
$this->content->items[]="<a $linkcss title=\"$course->shortname\" ".
"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();
@@ -5,20 +5,22 @@ function CourseBlock_course_summary ($course) {
$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;
}
@@ -69,19 +69,19 @@ function print_block() {
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:
if(empty($this->content->items) && empty($this->content->footer)) {
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;
}
@@ -93,6 +93,7 @@ function print_shadow() {
}
print_side_block($title, '&nbsp;', NULL, NULL, '');
}
+
function add_edit_controls($options, $blockid) {
global $CFG, $THEME;
@@ -179,7 +180,7 @@ function _self_test() {
$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;
@@ -216,8 +217,8 @@ function hide_header() {
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());
}
}
@@ -5,7 +5,11 @@ function CourseBlock_news_items ($course) {
$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() {
@@ -16,6 +20,7 @@ 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 = '';
@@ -5,7 +5,11 @@ function CourseBlock_online_users ($course) {
$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;}
@@ -5,7 +5,7 @@ function CourseBlock_participants ($course) {
$this->title = get_string('people');
$this->content_type = BLOCK_TYPE_LIST;
$this->course = $course;
- $this->version = 2004041800;
+ $this->version = 2004052600;
}
function get_content() {
@@ -38,14 +38,16 @@ function get_content() {
}
}
- $fullname = fullname($USER, true);
- $editmyprofile = '<a title="'.$fullname.'" href="../user/edit.php?id='.$USER->id.'&amp;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.'&amp;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;
}
@@ -14,9 +14,9 @@ function CourseBlock_section_links ($course) {
}
$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);
}
@@ -62,9 +62,8 @@ function get_content() {
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;
Oops, something went wrong.

0 comments on commit 89adb17

Please sign in to comment.