~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to blocks/admin/block_admin.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?PHP //$Id: block_admin.php,v 1.8.2.3 2004/10/09 13:11:49 stronk7 Exp $
 
1
<?php //$Id: block_admin.php,v 1.28.2.1 2005/05/24 16:55:37 moodler Exp $
2
2
 
3
 
class CourseBlock_admin extends MoodleBlock {
4
 
    function CourseBlock_admin($course) {
 
3
class block_admin extends block_list {
 
4
    function init() {
5
5
        $this->title = get_string('administration');
6
 
        $this->content_type = BLOCK_TYPE_LIST;
7
 
        $this->course = $course;
8
6
        $this->version = 2004081200;
9
7
    }
10
8
 
14
12
            return $this->content;
15
13
        }
16
14
 
17
 
        $this->content = New object;
 
15
        $this->content = new stdClass;
18
16
        $this->content->items = array();
19
17
        $this->content->icons = array();
20
18
        $this->content->footer = '';
21
19
 
22
 
        if (empty($this->course)) {
 
20
        if (empty($this->instance)) {
23
21
            $this->content = '';
24
 
        } else if ($this->course->id == SITEID) {
 
22
        } else if ($this->instance->pageid == SITEID) {
25
23
            $this->load_content_for_site();
26
24
        } else {
27
25
            $this->load_content_for_course();
35
33
        global $CFG, $USER;
36
34
 
37
35
        if (isadmin()) {
38
 
            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/configure.php">'.get_string('configuration').'</a>...';
 
36
            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/configure.php">'.get_string('configuration').'</a>';
39
37
            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/admin.gif" height="16" width="16" alt="" />';
40
38
 
41
 
            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/users.php">'.get_string('users').'</a>...';
 
39
            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/users.php">'.get_string('users').'</a>';
42
40
            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
43
41
 
44
 
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.SITEID.'">'.get_string('backup').'...</a>';
45
 
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="">';
 
42
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.SITEID.'">'.get_string('backup').'</a>';
 
43
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />';
46
44
 
47
 
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'&amp;wdir=/backupdata">'.get_string('restore').'...</a>';
48
 
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="">';
 
45
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'&amp;wdir=/backupdata">'.get_string('restore').'</a>';
 
46
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
49
47
        }
50
48
 
51
49
        if (iscreator()) {
52
 
            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on&sesskey='.$USER->sesskey.'">'.get_string('courses').'</a>';
 
50
            $this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on&amp;sesskey='.sesskey().'">'.get_string('courses').'</a>';
53
51
            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/course.gif" height="16" width="16" alt="" />';
54
52
        }
55
53
 
64
62
                $this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').'</a>';
65
63
                $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/db.gif" height="16" width="16" alt="" />';
66
64
            }
67
 
            $this->content->footer = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/">'.get_string('admin').'</a>...';
 
65
            $this->content->footer = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/">'.get_string('admin').'...</a>';
68
66
        }
69
67
    }
70
68
 
77
75
            return $this->content;
78
76
        }
79
77
 
80
 
        if (isteacher($this->course->id)) {
81
 
 
82
 
            $isteacheredit = isteacheredit($this->course->id);
 
78
        $course = get_record('course', 'id', $this->instance->pageid);
 
79
 
 
80
 
 
81
 
 
82
        if (isteacher($this->instance->pageid)) {
 
83
 
 
84
            $isteacheredit = isteacheredit($this->instance->pageid);
83
85
 
84
86
            if ($isteacheredit) {
85
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="">';
86
 
                if (isediting($this->course->id)) {
87
 
                    $this->content->items[]='<a href="view.php?id='.$this->course->id.'&amp;edit=off">'.get_string('turneditingoff').'</a>';
 
87
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" />';
 
88
                if (isediting($this->instance->pageid)) {
 
89
                    $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=off">'.get_string('turneditingoff').'</a>';
88
90
                } else {
89
 
                    $this->content->items[]='<a href="view.php?id='.$this->course->id.'&amp;edit=on">'.get_string('turneditingon').'</a>';
 
91
                    $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=on">'.get_string('turneditingon').'</a>';
90
92
                }
91
 
                $this->content->items[]='<a href="edit.php?id='.$this->course->id.'">'.get_string('settings').'...</a>';
92
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" height="16" width="16" alt="">';
93
 
 
94
 
                if (iscreator() or !empty($CFG->teacherassignteachers)) {
95
 
                    if (!$this->course->teachers) {
96
 
                        $this->course->teachers = get_string('defaultcourseteachers');
 
93
                
 
94
                $this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'</a>';
 
95
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" height="16" width="16" alt="" />';
 
96
 
 
97
 
 
98
            $fullname = fullname($USER, true);
 
99
            $editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&amp;course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
 
100
            if (empty($USER->description)) {
 
101
                $this->content->items[]= $editmyprofile." <blink>*</blink>";
 
102
            } else {
 
103
                $this->content->items[]= $editmyprofile;
 
104
            }
 
105
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
 
106
 
 
107
 
 
108
                if (iscreator() || !empty($CFG->teacherassignteachers)) {
 
109
                    if (!$course->teachers) {
 
110
                        $course->teachers = get_string('defaultcourseteachers');
97
111
                    }
98
 
                    $this->content->items[]='<a href="teacher.php?id='.$this->course->id.'">'.$this->course->teachers.'...</a>';
 
112
                    $this->content->items[]='<a href="teacher.php?id='.$this->instance->pageid.'">'.$course->teachers.'</a>';
 
113
                    $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
 
114
                }
 
115
 
 
116
                if (!$course->students) {
 
117
                    $course->students = get_string('defaultcoursestudents');
 
118
                } 
 
119
                if (!$course->metacourse) {
 
120
                    $this->content->items[]='<a href="student.php?id='.$this->instance->pageid.'">'.$course->students.'</a>';
 
121
                    $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
 
122
                } else {
 
123
                    $this->content->items[]='<a href="importstudents.php?id='.$this->instance->pageid.'">'.$course->students.'</a>';
99
124
                    $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
100
125
                }
101
 
 
102
 
                if (!$this->course->students) {
103
 
                    $this->course->students = get_string('defaultcoursestudents');
 
126
                if ($course->groupmode || !$course->groupmodeforce) {
 
127
                    $strgroups = get_string('groups');
 
128
                    $this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/course/groups.php?id='.$this->instance->pageid.'">'.$strgroups.'</a>';
 
129
                    $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" height="16" width="16" alt="" />';
104
130
                }
105
 
                $this->content->items[]='<a href="student.php?id='.$this->course->id.'">'.$this->course->students.'...</a>';
106
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
107
 
 
108
 
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->course->id.'">'.get_string('backup').'...</a>';
109
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="">';
110
 
 
111
 
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->course->id.'&amp;wdir=/backupdata">'.get_string('restore').'...</a>';
112
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="">';
113
 
                $this->content->items[]='<a href="scales.php?id='.$this->course->id.'">'.get_string('scales').'...</a>';
114
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="">';
 
131
 
 
132
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'</a>';
 
133
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />';
 
134
 
 
135
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&amp;wdir=/backupdata">'.get_string('restore').'</a>';
 
136
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
 
137
 
 
138
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$this->instance->pageid.'">'.get_string('importdata').'</a>';
 
139
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
 
140
 
 
141
                $this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'</a>';
 
142
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="" />';
115
143
            }
116
144
 
117
 
            $this->content->items[]='<a href="grades.php?id='.$this->course->id.'">'.get_string('grades').'...</a>';
118
 
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="">';
 
145
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
 
146
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
119
147
 
120
 
            $this->content->items[]='<a href="log.php?id='.$this->course->id.'">'.get_string('logs').'...</a>';
121
 
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="">';
 
148
            $this->content->items[]='<a href="log.php?id='.$this->instance->pageid.'">'.get_string('logs').'</a>';
 
149
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
122
150
 
123
151
            if ($isteacheredit) {
124
 
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->course->id.'">'.get_string('files').'...</a>';
125
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="">';
 
152
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'</a>';
 
153
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
126
154
            }
127
155
 
128
 
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->course->id.'&amp;file=teacher.html">'.get_string('help').'...</a>';
129
 
            $this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" height="16" width="16" alt="">';
 
156
            $this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->instance->pageid.'&amp;file=teacher.html">'.get_string('help').'</a>';
 
157
            $this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" height="16" width="16" alt="" />';
130
158
 
131
 
            if ($teacherforum = forum_get_course_forum($this->course->id, 'teacher')) {
 
159
            if ($teacherforum = forum_get_course_forum($this->instance->pageid, 'teacher')) {
132
160
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$teacherforum->id.'">'.get_string('nameteacher', 'forum').'</a>';
133
 
                $this->content->icons[]='<img src="'.$CFG->modpixpath.'/forum/icon.gif" height="16" width="16" alt="">';
 
161
                $this->content->icons[]='<img src="'.$CFG->modpixpath.'/forum/icon.gif" height="16" width="16" alt="" />';
134
162
            }
135
163
 
136
164
        } else if (!isguest()) {  // Students menu
137
165
 
138
 
            if ($this->course->showgrades) {
139
 
                $this->content->items[]='<a href="grade.php?id='.$this->course->id.'">'.get_string('grades').'...</a>';
140
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="">';
141
 
            }
142
 
            if ($this->course->showreports) {
143
 
                $this->content->items[]='<a href="user.php?id='.$this->course->id.'&amp;user='.$USER->id.'">'.get_string('activityreport').'...</a>';
144
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" height="16" width="16" alt="">';
145
 
            }
 
166
            if ($course->showgrades) {
 
167
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
 
168
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
 
169
            }
 
170
            if ($course->showreports) {
 
171
                $this->content->items[]='<a href="user.php?id='.$this->instance->pageid.'&amp;user='.$USER->id.'">'.get_string('activityreport').'</a>';
 
172
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" height="16" width="16" alt="" />';
 
173
            }
 
174
 
 
175
            $fullname = fullname($USER, true);
 
176
            $editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.
 
177
                             $USER->id.'&amp;course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
 
178
            if (empty($USER->description)) {
 
179
                $this->content->items[]= $editmyprofile." <blink>*</blink>";
 
180
            } else {
 
181
                $this->content->items[]= $editmyprofile;
 
182
            }
 
183
            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
 
184
 
146
185
            if (is_internal_auth()) {
147
 
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->course->id.'">'.get_string('changepassword').'...</a>';
148
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
 
186
                $this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'</a>';
 
187
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
149
188
            } else if ($CFG->changepassword) {
150
 
                $this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'...</a>';
151
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
 
189
                $this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'</a>';
 
190
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
152
191
            }
153
192
            if ($CFG->allowunenroll) {
154
 
                $this->content->items[]='<a href="unenrol.php?id='.$this->course->id.'">'.get_string('unenrolme', '', $this->course->shortname).'...</a>';
155
 
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
 
193
                $this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
 
194
                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
156
195
            }
157
196
        }
158
197
    }