2004-10-09 13:22:59 +00:00
|
|
|
<?php //$Id$
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-11-23 18:53:34 +00:00
|
|
|
class block_admin extends block_base {
|
2004-10-19 21:04:28 +00:00
|
|
|
function init() {
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->title = get_string('administration');
|
|
|
|
$this->content_type = BLOCK_TYPE_LIST;
|
2004-08-12 04:44:14 +00:00
|
|
|
$this->version = 2004081200;
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
2004-05-28 10:53:54 +00:00
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
function get_content() {
|
|
|
|
|
|
|
|
if($this->content !== NULL) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content = new stdClass;
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->items = array();
|
|
|
|
$this->content->icons = array();
|
|
|
|
$this->content->footer = '';
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if (empty($this->instance)) {
|
2004-08-11 09:00:53 +00:00
|
|
|
$this->content = '';
|
2004-10-19 21:04:28 +00:00
|
|
|
} else if ($this->instance->pageid == SITEID) {
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->load_content_for_site();
|
2004-08-11 09:00:53 +00:00
|
|
|
} else {
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->load_content_for_course();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function load_content_for_site() {
|
2004-10-09 13:22:59 +00:00
|
|
|
global $CFG, $USER;
|
2004-05-28 10:53:54 +00:00
|
|
|
|
|
|
|
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="" />';
|
2004-09-25 11:37:10 +00:00
|
|
|
|
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.SITEID.'">'.get_string('backup').'...</a>';
|
2004-09-28 09:02:33 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />';
|
2004-09-25 11:37:10 +00:00
|
|
|
|
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'&wdir=/backupdata">'.get_string('restore').'...</a>';
|
2004-09-28 09:02:33 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
|
2004-05-28 10:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (iscreator()) {
|
2004-10-09 13:22:59 +00:00
|
|
|
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.get_string('courses').'</a>';
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/course.gif" height="16" width="16" alt="" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isadmin()) {
|
2004-09-25 11:37:10 +00:00
|
|
|
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/log.php?id='.SITEID.'">'.get_string('logs').'</a>';
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
|
|
|
|
|
2004-09-25 11:37:10 +00:00
|
|
|
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'">'.get_string('sitefiles').'</a>';
|
2004-05-28 10:53:54 +00:00
|
|
|
$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() {
|
2004-06-09 22:00:51 +00:00
|
|
|
global $CFG, $USER;
|
2004-08-11 11:19:09 +00:00
|
|
|
|
2004-05-28 10:53:54 +00:00
|
|
|
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
if (isguest()) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$course = get_record('course', 'id', $this->instance->pageid);
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if (isteacher($this->instance->pageid)) {
|
|
|
|
|
|
|
|
$isteacheredit = isteacheredit($this->instance->pageid);
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
if ($isteacheredit) {
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" />';
|
2004-10-19 21:04:28 +00:00
|
|
|
if (isediting($this->instance->pageid)) {
|
|
|
|
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=off">'.get_string('turneditingoff').'</a>';
|
2004-04-18 23:20:53 +00:00
|
|
|
} else {
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=on">'.get_string('turneditingon').'</a>';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if (iscreator() || !empty($CFG->teacherassignteachers)) {
|
|
|
|
if (!$course->teachers) {
|
|
|
|
$course->teachers = get_string('defaultcourseteachers');
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="teacher.php?id='.$this->instance->pageid.'">'.$course->teachers.'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if (!$course->students) {
|
|
|
|
$course->students = get_string('defaultcoursestudents');
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="student.php?id='.$this->instance->pageid.'">'.$course->students.'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&wdir=/backupdata">'.get_string('restore').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="grades.php?id='.$this->instance->pageid.'">'.get_string('grades').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="log.php?id='.$this->instance->pageid.'">'.get_string('logs').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
if ($isteacheredit) {
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->instance->pageid.'&file=teacher.html">'.get_string('help').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if ($teacherforum = forum_get_course_forum($this->instance->pageid, 'teacher')) {
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$teacherforum->id.'">'.get_string('nameteacher', 'forum').'</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/forum/icon.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!isguest()) { // Students menu
|
2004-05-28 10:53:54 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
if ($course->showgrades) {
|
|
|
|
$this->content->items[]='<a href="grade.php?id='.$this->instance->pageid.'">'.get_string('grades').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
2004-10-19 21:04:28 +00:00
|
|
|
if ($course->showreports) {
|
|
|
|
$this->content->items[]='<a href="user.php?id='.$this->instance->pageid.'&user='.$USER->id.'">'.get_string('activityreport').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
if (is_internal_auth()) {
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
} else if ($CFG->changepassword) {
|
|
|
|
$this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
if ($CFG->allowunenroll) {
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'...</a>';
|
2004-09-12 21:55:34 +00:00
|
|
|
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|