f9903ed0 |
1 | <? // $Id$ |
97c270e9 |
2 | // Library of useful functions |
f9903ed0 |
3 | |
f9903ed0 |
4 | |
97c270e9 |
5 | $COURSE_MAX_LOG_DISPLAY = 150; // days |
d9d1c35d |
6 | |
97c270e9 |
7 | $COURSE_TEACHER_COLOR = "#990000"; // To hilight certain items that are teacher-only |
87ffed0d |
8 | |
97c270e9 |
9 | $COURSE_LIVELOG_REFRESH = 60; // Seconds |
ef58b822 |
10 | |
f9903ed0 |
11 | |
f9903ed0 |
12 | function print_log_selector_form($course, $selecteduser=0, $selecteddate="today") { |
13 | |
9481285b |
14 | global $USER, $CFG; |
15 | |
f9903ed0 |
16 | // Get all the possible users |
17 | $users = array(); |
720a43ce |
18 | |
19 | if ($course->category) { |
20 | if ($students = get_records_sql("SELECT u.* FROM user u, user_students s |
21 | WHERE s.course = '$course->id' AND s.user = u.id |
22 | ORDER BY u.lastaccess DESC")) { |
23 | foreach ($students as $student) { |
24 | $users["$student->id"] = "$student->firstname $student->lastname"; |
25 | } |
26 | } |
27 | if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t |
28 | WHERE t.course = '$course->id' AND t.user = u.id |
29 | ORDER BY u.lastaccess DESC")) { |
30 | foreach ($teachers as $teacher) { |
31 | $users["$teacher->id"] = "$teacher->firstname $teacher->lastname"; |
32 | } |
f9903ed0 |
33 | } |
122cffc9 |
34 | if ($guest = get_user_info_from_db("username", "guest")) { |
35 | $users["$guest->id"] = "$guest->firstname $guest->lastname"; |
36 | } |
f9903ed0 |
37 | } |
720a43ce |
38 | |
39 | if (isadmin()) { |
40 | if ($ccc = get_records_sql("SELECT * FROM course ORDER BY fullname")) { |
41 | foreach ($ccc as $cc) { |
cfa5d3f2 |
42 | if ($cc->category) { |
43 | $courses["$cc->id"] = "$cc->fullname"; |
44 | } else { |
45 | $courses["$cc->id"] = " $cc->fullname (Site)"; |
46 | } |
720a43ce |
47 | } |
f9903ed0 |
48 | } |
cfa5d3f2 |
49 | asort($courses); |
f9903ed0 |
50 | } |
51 | |
52 | asort($users); |
53 | |
54 | // Get all the possible dates |
9481285b |
55 | // Note that we are keeping track of real (GMT) time and user time |
56 | // User time is only used in displays - all calcs and passing is GMT |
57 | |
58 | $timenow = time(); // GMT |
59 | |
60 | // What day is it now for the user, and when is midnight that day (in GMT). |
9604ccb1 |
61 | $timemidnight = $today = usergetmidnight($timenow); |
9481285b |
62 | |
63 | // Put today up the top of the list |
62c13a2f |
64 | $dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, "%d %B %Y") ); |
9481285b |
65 | |
66 | if (! $course->startdate) { |
67 | $course->startdate = $course->timecreated; |
68 | } |
f9903ed0 |
69 | |
9481285b |
70 | $numdates = 1; |
71 | while ($timemidnight > $course->startdate and $numdates < 365) { |
f9903ed0 |
72 | $timemidnight = $timemidnight - 86400; |
9481285b |
73 | $timenow = $timenow - 86400; |
62c13a2f |
74 | $dates["$timemidnight"] = userdate($timenow, "%A, %d %B %Y"); |
9481285b |
75 | $numdates++; |
f9903ed0 |
76 | } |
77 | |
78 | if ($selecteddate == "today") { |
79 | $selecteddate = $today; |
80 | } |
81 | |
82 | echo "<CENTER>"; |
83 | echo "<FORM ACTION=log.php METHOD=get>"; |
720a43ce |
84 | if (isadmin()) { |
849bc02a |
85 | choose_from_menu ($courses, "id", $course->id, ""); |
720a43ce |
86 | } else { |
87 | echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">"; |
88 | } |
89 | if ($course->category) { |
97c270e9 |
90 | choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") ); |
720a43ce |
91 | } |
97c270e9 |
92 | choose_from_menu ($dates, "date", $selecteddate, get_string("alldays")); |
93 | echo "<INPUT TYPE=submit VALUE=\"".get_string("showtheselogs")."\">"; |
f9903ed0 |
94 | echo "</FORM>"; |
95 | echo "</CENTER>"; |
96 | } |
97 | |
600149be |
98 | function make_log_url($module, $url) { |
99 | switch ($module) { |
100 | case "course": |
101 | case "user": |
102 | case "file": |
103 | case "login": |
104 | case "lib": |
105 | case "admin": |
106 | return "/$module/$url"; |
107 | break; |
108 | default: |
109 | return "/mod/$module/$url"; |
110 | break; |
111 | } |
112 | } |
113 | |
114 | |
f9903ed0 |
115 | function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") { |
9481285b |
116 | // It is assumed that $date is the GMT time of midnight for that day, |
117 | // and so the next 86400 seconds worth of logs are printed. |
f9903ed0 |
118 | |
720a43ce |
119 | if ($course->category) { |
120 | $selector = "WHERE l.course='$course->id' AND l.user = u.id"; |
a2ab3b05 |
121 | |
720a43ce |
122 | } else { |
123 | $selector = "WHERE l.user = u.id"; // Show all courses |
124 | if ($ccc = get_records_sql("SELECT * FROM course ORDER BY fullname")) { |
125 | foreach ($ccc as $cc) { |
126 | $courses[$cc->id] = "$cc->shortname"; |
127 | } |
128 | } |
129 | } |
f9903ed0 |
130 | |
131 | if ($user) { |
132 | $selector .= " AND l.user = '$user'"; |
133 | } |
134 | |
135 | if ($date) { |
136 | $enddate = $date + 86400; |
137 | $selector .= " AND l.time > '$date' AND l.time < '$enddate'"; |
138 | } |
139 | |
140 | if (!$logs = get_records_sql("SELECT l.*, u.firstname, u.lastname, u.picture |
600149be |
141 | FROM log l, user u $selector $order")){ |
f9903ed0 |
142 | notify("No logs found!"); |
143 | print_footer($course); |
144 | exit; |
145 | } |
146 | |
147 | $count=0; |
148 | $tt = getdate(time()); |
149 | $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]); |
150 | echo "<P ALIGN=CENTER>Displaying ".count($logs)." records</P>"; |
151 | echo "<TABLE BORDER=0 ALIGN=center CELLPADDING=3 CELLSPACING=3>"; |
152 | foreach ($logs as $log) { |
600149be |
153 | |
154 | if ($ld = get_record_sql("SELECT * FROM log_display WHERE module='$log->module' AND action='$log->action'")) { |
565f7a95 |
155 | $log->info = get_field($ld->mtable, $ld->field, "id", $log->info); |
600149be |
156 | } |
157 | |
f58d18bc |
158 | echo "<TR NOWRAP>"; |
720a43ce |
159 | if (! $course->category) { |
f58d18bc |
160 | echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"view.php?id=$log->course\">".$courses[$log->course]."</A></TD>"; |
720a43ce |
161 | } |
f58d18bc |
162 | echo "<TD NOWRAP ALIGN=right><FONT SIZE=2>".userdate($log->time, "%A")."</TD>"; |
62c13a2f |
163 | echo "<TD NOWRAP><FONT SIZE=2>".userdate($log->time, "%d %B %Y, %I:%M %p")."</TD>"; |
ebea4e27 |
164 | echo "<TD NOWRAP><FONT SIZE=2>"; |
ef4743b9 |
165 | link_to_popup_window("$CFG->wwwroot/lib/ipatlas/plot.php?address=$log->ip&user=$log->user", "ipatlas","$log->ip", 400, 700); |
ebea4e27 |
166 | echo "</TD>"; |
f58d18bc |
167 | echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"../user/view.php?id=$log->user&course=$log->course\"><B>$log->firstname $log->lastname</B></TD>"; |
168 | echo "<TD NOWRAP><FONT SIZE=2>"; |
600149be |
169 | link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600); |
f9903ed0 |
170 | echo "</TD>"; |
f58d18bc |
171 | echo "<TD NOWRAP><FONT SIZE=2>$log->info</TD>"; |
f9903ed0 |
172 | echo "</TR>"; |
173 | } |
174 | echo "</TABLE>"; |
175 | } |
176 | |
177 | |
776dc270 |
178 | function print_all_courses($category="all", $style="full", $maxcount=999, $width=180) { |
0a263205 |
179 | global $CFG, $USER; |
d887b5a7 |
180 | |
ba2e5d73 |
181 | if ($category == "all") { |
182 | $courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC"); |
0a263205 |
183 | |
184 | } else if ($category == "my") { |
185 | if (isset($USER->id)) { |
186 | if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC")) { |
187 | foreach ($courses as $key => $course) { |
188 | if (!isteacher($course->id) and !isstudent($course->id)) { |
189 | unset($courses[$key]); |
190 | } |
191 | } |
192 | } |
193 | } |
194 | |
ba2e5d73 |
195 | } else { |
196 | $courses = get_records("course", "category", $category, "fullname ASC"); |
197 | } |
198 | |
199 | if ($courses) { |
94361e02 |
200 | if ($style == "minimal") { |
201 | $count = 0; |
97c270e9 |
202 | $icon = "<IMG SRC=\"pix/i/course.gif\" HEIGHT=16 WIDTH=16 ALT=\"".get_string("course")."\">"; |
94361e02 |
203 | foreach ($courses as $course) { |
565f7a95 |
204 | $moddata[]="<A TITLE=\"$course->shortname\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A>"; |
94361e02 |
205 | $modicon[]=$icon; |
206 | if ($count++ >= $maxcount) { |
207 | break; |
208 | } |
209 | } |
210 | $fulllist = "<P><A HREF=\"$CFG->wwwroot/course/\">".get_string("fulllistofcourses")."</A>..."; |
776dc270 |
211 | print_side_block(get_string("courses"), "", $moddata, $modicon, $fulllist, $width); |
94361e02 |
212 | |
213 | } else { |
214 | foreach ($courses as $course) { |
215 | print_course($course); |
216 | echo "<BR>\n"; |
217 | } |
d887b5a7 |
218 | } |
219 | |
220 | } else { |
cf38360f |
221 | echo "<H3>".get_string("nocoursesyet")."</H3>"; |
d887b5a7 |
222 | } |
223 | } |
224 | |
225 | |
f9903ed0 |
226 | function print_course($course) { |
227 | |
d887b5a7 |
228 | global $CFG; |
229 | |
a83fded1 |
230 | if (! $site = get_site()) { |
f9903ed0 |
231 | error("Could not find a site!"); |
232 | } |
233 | |
d887b5a7 |
234 | print_simple_box_start("CENTER", "100%"); |
f9903ed0 |
235 | |
236 | echo "<TABLE WIDTH=100%>"; |
da5c172a |
237 | echo "<TR VALIGN=top>"; |
238 | echo "<TD VALIGN=top WIDTH=50%>"; |
7a302afc |
239 | echo "<P><FONT SIZE=3><B><A TITLE=\"".get_string("entercourse")."\" |
9481285b |
240 | HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>"; |
0c71c9ae |
241 | if ($teachers = get_course_teachers($course->id)) { |
f9903ed0 |
242 | echo "<P><FONT SIZE=1>\n"; |
243 | foreach ($teachers as $teacher) { |
0c71c9ae |
244 | if ($teacher->authority > 0) { |
b4d7002e |
245 | if (!$teacher->role) { |
246 | $teacher->role = $course->teacher; |
247 | } |
248 | echo "$teacher->role: <A HREF=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>"; |
0c71c9ae |
249 | } |
f9903ed0 |
250 | } |
251 | echo "</FONT></P>"; |
da5c172a |
252 | } |
f25f1e1b |
253 | if ($course->guest) { |
5e367a2d |
254 | $strallowguests = get_string("allowguests"); |
255 | echo "<A TITLE=\"$strallowguests\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">"; |
256 | echo "<IMG VSPACE=4 ALT=\"$strallowguests\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/user/user.gif\"></A> "; |
da5c172a |
257 | } |
258 | if ($course->password) { |
5e367a2d |
259 | $strrequireskey = get_string("requireskey"); |
260 | echo "<A TITLE=\"$strrequireskey\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">"; |
261 | echo "<IMG VSPACE=4 ALT=\"$strrequireskey\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/pix/i/key.gif\"></A>"; |
da5c172a |
262 | } |
263 | |
264 | |
265 | echo "</TD><TD VALIGN=top WIDTH=50%>"; |
266 | echo "<P><FONT SIZE=2>".text_to_html($course->summary)."</FONT></P>"; |
267 | echo "</TD></TR>"; |
268 | echo "</TABLE>"; |
f9903ed0 |
269 | |
da5c172a |
270 | print_simple_box_end(); |
f9903ed0 |
271 | } |
272 | |
600149be |
273 | function print_headline($text, $size=2) { |
274 | echo "<B><FONT SIZE=\"$size\">$text</FONT></B><BR>\n"; |
275 | } |
276 | |
277 | function print_recent_activity($course) { |
278 | // $course is an object |
279 | // This function trawls through the logs looking for |
280 | // anything new since the user's last login |
281 | |
97c270e9 |
282 | global $CFG, $USER, $COURSE_TEACHER_COLOR; |
600149be |
283 | |
284 | if (! $USER->lastlogin ) { |
4c654ee3 |
285 | echo "<P ALIGN=CENTER><FONT SIZE=1>"; |
4b1371a7 |
286 | print_string("welcometocourse", "", $course->shortname); |
4c654ee3 |
287 | echo "</FONT></P>"; |
600149be |
288 | return; |
4c654ee3 |
289 | } else { |
290 | echo "<P ALIGN=CENTER><FONT SIZE=1>"; |
291 | echo get_string("yourlastlogin").":<BR>"; |
62c13a2f |
292 | echo userdate($USER->lastlogin, "%A, %d %b %Y, %H:%M"); |
4c654ee3 |
293 | echo "</FONT></P>"; |
600149be |
294 | } |
295 | |
296 | if (! $logs = get_records_sql("SELECT * FROM log WHERE time > '$USER->lastlogin' AND course = '$course->id' ORDER BY time ASC")) { |
297 | return; |
298 | } |
299 | |
300 | |
301 | // Firstly, have there been any new enrolments? |
302 | |
303 | $heading = false; |
304 | $content = false; |
305 | foreach ($logs as $log) { |
306 | if ($log->module == "course" and $log->action == "enrol") { |
307 | if (! $heading) { |
4c654ee3 |
308 | print_headline(get_string("newusers").":"); |
600149be |
309 | $heading = true; |
310 | $content = true; |
311 | } |
312 | $user = get_record("user", "id", $log->info); |
d578afc8 |
313 | if (isstudent($course->id, $user->id)) { |
314 | echo "<P><FONT SIZE=1><A HREF=\"../user/view.php?id=$user->id&course=$course->id\">$user->firstname $user->lastname</A></FONT></P>"; |
315 | } |
600149be |
316 | } |
317 | } |
318 | |
319 | // Next, have there been any changes to the course structure? |
320 | |
600149be |
321 | foreach ($logs as $log) { |
322 | if ($log->module == "course") { |
323 | if ($log->action == "add mod" or $log->action == "update mod" or $log->action == "delete mod") { |
600149be |
324 | $info = split(" ", $log->info); |
325 | $modname = get_field($info[0], "name", "id", $info[1]); |
326 | |
600149be |
327 | switch ($log->action) { |
328 | case "add mod": |
27038d9f |
329 | $stradded = get_string("added", "moodle", get_string("modulename", $info[0])); |
4c654ee3 |
330 | $changelist["$log->info"] = array ("operation" => "add", "text" => "$stradded:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>"); |
600149be |
331 | break; |
332 | case "update mod": |
27038d9f |
333 | $strupdated = get_string("updated", "moodle", get_string("modulename", $info[0])); |
ef25340c |
334 | if (! $changelist["$log->info"]) { |
4c654ee3 |
335 | $changelist["$log->info"] = array ("operation" => "update", "text" => "$strupdated:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>"); |
ef25340c |
336 | } |
600149be |
337 | break; |
338 | case "delete mod": |
ef25340c |
339 | if ($changelist["$log->info"]["operation"] == "add") { |
340 | $changelist["$log->info"] = NULL; |
341 | } else { |
27038d9f |
342 | $strdeleted = get_string("deletedactivity", "moodle", get_string("modulename", $info[0])); |
4c654ee3 |
343 | $changelist["$log->info"] = array ("operation" => "delete", "text" => $strdeleted); |
ef25340c |
344 | } |
600149be |
345 | break; |
346 | } |
ef25340c |
347 | } |
348 | } |
349 | } |
350 | |
351 | if ($changelist) { |
352 | foreach ($changelist as $changeinfo => $change) { |
353 | if ($change) { |
354 | $changes[$changeinfo] = $change; |
355 | } |
356 | } |
357 | if (count($changes) > 0) { |
4c654ee3 |
358 | print_headline(get_string("courseupdates").":"); |
ef25340c |
359 | $content = true; |
360 | foreach ($changes as $changeinfo => $change) { |
361 | echo "<P><FONT SIZE=1>".$change["text"]."</FONT></P>"; |
600149be |
362 | } |
363 | } |
364 | } |
365 | |
366 | |
3869a2ac |
367 | // Now display new things from each module |
600149be |
368 | |
3869a2ac |
369 | $mods = get_list_of_plugins("mod"); |
600149be |
370 | |
3869a2ac |
371 | foreach ($mods as $mod) { |
372 | include_once("$CFG->dirroot/mod/$mod/lib.php"); |
373 | $print_recent_activity = $mod."_print_recent_activity"; |
374 | if (function_exists($print_recent_activity)) { |
375 | $modcontent = $print_recent_activity($logs, isteacher($course->id)); |
376 | if ($modcontent) { |
377 | $content = true; |
600149be |
378 | } |
600149be |
379 | } |
380 | } |
381 | |
3869a2ac |
382 | |
600149be |
383 | if (! $content) { |
97c270e9 |
384 | echo "<FONT SIZE=2>".get_string("nothingnew")."</FONT>"; |
600149be |
385 | } |
600149be |
386 | } |
387 | |
e1360728 |
388 | |
d897cae4 |
389 | function get_array_of_activities($courseid) { |
390 | // For a given course, returns an array of course activity objects |
391 | // Each item in the array contains he following properties: |
392 | // cm - course module id |
393 | // mod - name of the module (eg forum) |
394 | // section - the number of the section (eg week or topic) |
395 | // name - the name of the instance |
396 | |
397 | $mod = array(); |
398 | |
399 | if (!$rawmods = get_records_sql("SELECT cm.*, m.name as modname |
400 | FROM modules m, course_modules cm |
401 | WHERE cm.course = '$courseid' |
402 | AND cm.deleted = '0' |
403 | AND cm.module = m.id ") ) { |
404 | return NULL; |
405 | } |
406 | |
407 | if ($sections = get_records("course_sections", "course", $courseid, "section ASC")) { |
408 | foreach ($sections as $section) { |
409 | if ($section->sequence) { |
410 | $sequence = explode(",", $section->sequence); |
411 | foreach ($sequence as $seq) { |
412 | $mod[$seq]->cm = $rawmods[$seq]->id; |
413 | $mod[$seq]->mod = $rawmods[$seq]->modname; |
414 | $mod[$seq]->section = $section->section; |
415 | $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance)); |
416 | } |
417 | } |
418 | } |
419 | } |
420 | return $mod; |
421 | } |
422 | |
423 | |
424 | |
e1360728 |
425 | |
90845098 |
426 | function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) { |
427 | // Returns a number of useful structures for course displays |
7468bf01 |
428 | |
90845098 |
429 | $mods = NULL; // course modules indexed by id |
430 | $modnames = NULL; // all course module names |
94361e02 |
431 | $modnamesplural= NULL; // all course module names (plural form) |
90845098 |
432 | $modnamesused = NULL; // course module names used |
7468bf01 |
433 | |
90845098 |
434 | if ($allmods = get_records_sql("SELECT * FROM modules") ) { |
435 | foreach ($allmods as $mod) { |
436 | $modnames[$mod->name] = get_string("modulename", "$mod->name"); |
437 | $modnamesplural[$mod->name] = get_string("modulenameplural", "$mod->name"); |
438 | } |
439 | asort($modnames); |
440 | } else { |
441 | error("No modules are installed!"); |
442 | } |
443 | |
444 | if ($rawmods = get_records_sql("SELECT cm.*, m.name as modname |
445 | FROM modules m, course_modules cm |
446 | WHERE cm.course = '$courseid' |
447 | AND cm.deleted = '0' |
94361e02 |
448 | AND cm.module = m.id ") ) { |
7468bf01 |
449 | foreach($rawmods as $mod) { // Index the mods |
450 | $mods[$mod->id] = $mod; |
90845098 |
451 | $mods[$mod->id]->modfullname = $modnames[$mod->modname]; |
452 | $modnamesused[$mod->modname] = $modnames[$mod->modname]; |
7468bf01 |
453 | } |
90845098 |
454 | asort($modnamesused); |
7468bf01 |
455 | } |
7468bf01 |
456 | } |
457 | |
458 | function get_all_sections($courseid) { |
459 | |
460 | return get_records_sql("SELECT section, id, course, summary, sequence |
461 | FROM course_sections |
462 | WHERE course = '$courseid' |
463 | ORDER BY section"); |
464 | } |
465 | |
ba2e5d73 |
466 | function get_all_categories() { |
467 | return get_records_sql("SELECT * FROM course_categories ORDER by name"); |
468 | } |
469 | |
5e367a2d |
470 | function print_section_block($heading, $course, $section, $mods, $modnames, $modnamesused, |
471 | $absolute=true, $width="100%", $isediting=false) { |
472 | |
473 | global $CFG; |
474 | |
475 | $modinfo = unserialize($course->modinfo); |
476 | $moddata = array(); |
477 | $modicon = array(); |
478 | $editbuttons = ""; |
479 | |
480 | if ($section->sequence) { |
481 | |
482 | $sectionmods = explode(",", $section->sequence); |
483 | |
484 | foreach ($sectionmods as $modnumber) { |
485 | $mod = $mods[$modnumber]; |
486 | if ($isediting) { |
487 | $editbuttons = make_editing_buttons($mod->id, $absolute); |
488 | } |
489 | $instancename = urldecode($modinfo[$modnumber]->name); |
490 | $modicon[] = "<img src=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" height=\"16\" width=\"16\" alt=\"$mod->modfullname\">"; |
491 | $moddata[] = "<a title=\"$mod->modfullname\" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a><BR>$editbuttons"; |
492 | } |
493 | } |
494 | if (isediting($site->id)) { |
495 | $editmenu = popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=0&add=", |
496 | $modnames, "section0", "", get_string("add")."...", "mods", get_string("activities"), true); |
497 | $editmenu = "<DIV ALIGN=right>$editmenu</DIV>"; |
498 | } |
499 | |
500 | print_side_block($heading, "", $moddata, $modicon, $editmenu, $width); |
501 | } |
502 | |
503 | |
d897cae4 |
504 | function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%") { |
94361e02 |
505 | global $CFG; |
506 | |
c408b0c4 |
507 | $modinfo = unserialize($course->modinfo); |
94361e02 |
508 | |
19a55d67 |
509 | echo "<TABLE WIDTH=\"$width\"><TR><TD>\n"; |
94361e02 |
510 | if ($section->sequence) { |
511 | |
512 | $sectionmods = explode(",", $section->sequence); |
513 | |
514 | foreach ($sectionmods as $modnumber) { |
515 | $mod = $mods[$modnumber]; |
c408b0c4 |
516 | $instancename = urldecode($modinfo[$modnumber]->name); |
94361e02 |
517 | echo "<IMG SRC=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; |
a7ad3ea6 |
518 | echo " <FONT SIZE=2><A TITLE=\"$mod->modfullname\""; |
519 | echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</A></FONT>"; |
d897cae4 |
520 | if (isediting($course->id)) { |
5e367a2d |
521 | echo " "; |
94361e02 |
522 | echo make_editing_buttons($mod->id, $absolute); |
523 | } |
524 | echo "<BR>\n"; |
525 | } |
526 | } |
47ef8795 |
527 | echo "</TD></TR></TABLE><BR>\n\n"; |
a7ad3ea6 |
528 | } |
529 | |
7541bc3e |
530 | function print_heading_block($heading, $width="100%", $class="headingblock") { |
5e367a2d |
531 | global $THEME; |
532 | |
7541bc3e |
533 | echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">"; |
534 | echo "<tr><td bgcolor=\"$THEME->cellheading\" class=\"$class\">"; |
5e367a2d |
535 | echo stripslashes($heading); |
536 | echo "</td></tr></table>"; |
5e367a2d |
537 | } |
538 | |
539 | function print_side_block($heading="", $content="", $list=NULL, $icons=NULL, $footer="", $width=180) { |
540 | // Prints a nice side block with an optional header. The content can either |
541 | // be a block of HTML or a list of text with optional icons. |
a7ad3ea6 |
542 | |
5e367a2d |
543 | global $THEME; |
544 | |
7541bc3e |
545 | print_side_block_start($heading, $width); |
546 | |
5e367a2d |
547 | if ($content) { |
7541bc3e |
548 | echo "$content"; |
5e367a2d |
549 | } else { |
5e367a2d |
550 | echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">"; |
551 | foreach ($list as $key => $string) { |
7541bc3e |
552 | echo "<tr bgcolor=\"$THEME->cellcontent2\">"; |
5e367a2d |
553 | if ($icons) { |
7541bc3e |
554 | echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">".$icons[$key]."</td>"; |
a7ad3ea6 |
555 | } |
7541bc3e |
556 | echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>"; |
5e367a2d |
557 | echo "</tr>"; |
a7ad3ea6 |
558 | } |
5e367a2d |
559 | if ($footer) { |
7541bc3e |
560 | echo "<tr bgcolor=\"$THEME->cellcontent2\">"; |
5e367a2d |
561 | if ($icons) { |
7541bc3e |
562 | echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\"> </td>"; |
5e367a2d |
563 | } |
7541bc3e |
564 | echo "<td class=\"sideblocklinks\"><font size=\"-1\">$footer</td>"; |
5e367a2d |
565 | echo "</tr>"; |
566 | } |
567 | echo "</table>"; |
a7ad3ea6 |
568 | } |
5e367a2d |
569 | |
7541bc3e |
570 | print_side_block_end(); |
571 | } |
572 | |
573 | function print_side_block_start($heading="", $width=180, $class="sideblockmain") { |
574 | // Starts a nice side block with an optional header. |
575 | |
576 | global $THEME; |
577 | |
578 | echo "<table class=\"sideblock\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">"; |
579 | if ($heading) { |
580 | echo "<tr>"; |
581 | echo "<td class=\"sideblockheading\" bgcolor=\"$THEME->cellheading\">$heading</td>"; |
582 | echo "</tr>"; |
583 | } |
584 | echo "<tr>"; |
585 | echo "<td class=\"$class\" bgcolor=\"$THEME->cellcontent2\">"; |
586 | } |
587 | |
588 | function print_side_block_end() { |
589 | echo "</td></tr>"; |
5e367a2d |
590 | echo "</table><br \>"; |
94361e02 |
591 | } |
592 | |
5e367a2d |
593 | |
670fddf1 |
594 | function print_admin_links ($siteid, $width=180) { |
2b25f2a0 |
595 | global $THEME, $CFG; |
596 | |
2b25f2a0 |
597 | $icon = "<IMG SRC=\"$CFG->wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
74944b73 |
598 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/config.php\">".get_string("configvariables")."</A>"; |
2b25f2a0 |
599 | $modicon[]=$icon; |
600 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/site.php\">".get_string("sitesettings")."</A>"; |
601 | $modicon[]=$icon; |
74944b73 |
602 | $moddata[]="<A HREF=\"$CFG->wwwroot/course/log.php?id=$siteid\">".get_string("sitelogs")."</A>"; |
603 | $modicon[]=$icon; |
1e3e716f |
604 | $moddata[]="<A HREF=\"$CFG->wwwroot/theme/index.php\">".get_string("choosetheme")."</A>"; |
605 | $modicon[]=$icon; |
31410e9a |
606 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/lang.php\">".get_string("checklanguage")."</A>"; |
607 | $modicon[]=$icon; |
077f9a67 |
608 | if (file_exists("$CFG->dirroot/admin/$CFG->dbtype")) { |
609 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/$CFG->dbtype/\">".get_string("managedatabase")."</A>"; |
610 | $modicon[]=$icon; |
611 | } |
74944b73 |
612 | $moddata[]="<HR>"; |
613 | $modicon[]=""; |
2b25f2a0 |
614 | $moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>"; |
615 | $modicon[]=$icon; |
ba2e5d73 |
616 | $moddata[]="<A HREF=\"$CFG->wwwroot/course/categories.php\">".get_string("categories")."</A>"; |
617 | $modicon[]=$icon; |
2b25f2a0 |
618 | $moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>"; |
619 | $modicon[]=$icon; |
620 | $moddata[]="<A HREF=\"$CFG->wwwroot/course/delete.php\">".get_string("deletecourse")."</A>"; |
621 | $modicon[]=$icon; |
74944b73 |
622 | $moddata[]="<HR>"; |
623 | $modicon[]=""; |
2b25f2a0 |
624 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/user.php?newuser=true\">".get_string("addnewuser")."</A>"; |
625 | $modicon[]=$icon; |
626 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/user.php\">".get_string("edituser")."</A>"; |
627 | $modicon[]=$icon; |
d7facad8 |
628 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/admin.php\">".get_string("assignadmins")."</A>"; |
629 | $modicon[]=$icon; |
60459ef7 |
630 | $moddata[]="<A HREF=\"$CFG->wwwroot/admin/auth.php\">".get_string("authentication")."</A>"; |
631 | $modicon[]=$icon; |
2b25f2a0 |
632 | $fulladmin = "<P><A HREF=\"$CFG->wwwroot/admin/\">".get_string("admin")."</A>..."; |
5e367a2d |
633 | |
634 | print_side_block(get_string("administration"), "", $moddata, $modicon, $fulladmin, $width); |
635 | |
19a55d67 |
636 | echo "<IMG SRC=\"$CFG->wwwroot/pix/spacer.gif\" WIDTH=\"$width\" HEIGHT=1><BR>"; |
2b25f2a0 |
637 | } |
638 | |
b4d7002e |
639 | function print_course_admin_links($course, $width=180) { |
44dad735 |
640 | global $THEME, $CFG; |
641 | |
44dad735 |
642 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
b4d7002e |
643 | if (isediting($course->id)) { |
644 | $admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">".get_string("turneditingoff")."</A>"; |
44dad735 |
645 | } else { |
b4d7002e |
646 | $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">".get_string("turneditingon")."</A>"; |
647 | } |
648 | $admindata[]="<A HREF=\"edit.php?id=$course->id\">".get_string("settings")."...</A>"; |
649 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
650 | if (!$course->teachers) { |
651 | $course->teachers = get_string("defaultcourseteachers"); |
44dad735 |
652 | } |
b4d7002e |
653 | $admindata[]="<A HREF=\"teachers.php?id=$course->id\">$course->teachers...</A>"; |
44dad735 |
654 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
b4d7002e |
655 | |
3486b7be |
656 | $admindata[]="<A HREF=\"grades.php?id=$course->id\">".get_string("grades")."...</A>"; |
657 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/grades.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
658 | |
b4d7002e |
659 | $admindata[]="<A HREF=\"log.php?id=$course->id\">".get_string("logs")."...</A>"; |
44dad735 |
660 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
b4d7002e |
661 | $admindata[]="<A HREF=\"$CFG->wwwroot/files/index.php?id=$course->id\">".get_string("files")."...</A>"; |
44dad735 |
662 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
663 | |
b4d7002e |
664 | $admindata[]="<A HREF=\"$CFG->wwwroot/doc/view.php?id=$course->id&file=teacher.html\">".get_string("help")."...</A>"; |
2a439ba7 |
665 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/mod/resource/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
44dad735 |
666 | |
b4d7002e |
667 | |
668 | if ($teacherforum = forum_get_course_forum($course->id, "teacher")) { |
669 | $admindata[]="<A HREF=\"$CFG->wwwroot/mod/forum/view.php?f=$teacherforum->id\">".get_string("nameteacher", "forum")."</A>"; |
44dad735 |
670 | $adminicon[]="<IMG SRC=\"$CFG->wwwroot/mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">"; |
671 | } |
672 | |
5e367a2d |
673 | print_side_block(get_string("administration"), "", $admindata, $adminicon, "", $width); |
44dad735 |
674 | } |
2b25f2a0 |
675 | |
ba2e5d73 |
676 | function print_course_categories($categories, $selected="none", $width=180) { |
0a263205 |
677 | global $CFG, $THEME, $USER; |
85098089 |
678 | |
679 | $strallowguests = get_string("allowguests"); |
680 | $strrequireskey = get_string("requireskey"); |
ba2e5d73 |
681 | |
0c656181 |
682 | if ($selected == "index") { // Print comprehensive index of categories with courses |
683 | if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY shortname")) { |
684 | if (isset($USER->id) and !isadmin()) { |
39246b72 |
685 | print_simple_box_start("CENTER", "100%", $THEME->cellheading); |
0c656181 |
686 | print_heading("<A HREF=\"course/index.php?category=my\">".get_string("mycourses")."</A>", "LEFT"); |
687 | $some = false; |
688 | echo "<UL>"; |
689 | foreach ($courses as $key => $course) { |
690 | if (isteacher($course->id) or isstudent($course->id)) { |
85098089 |
691 | echo "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A>"; |
692 | echo "<BR>"; |
0c656181 |
693 | $some = true; |
694 | } |
695 | } |
696 | if (!$some) { |
697 | print_string("nocoursesyet"); |
698 | } |
699 | echo "</UL>"; |
700 | print_simple_box_end(); |
701 | print_spacer(8,1); |
702 | } |
703 | foreach ($categories as $category) { |
bd4707bf |
704 | print_simple_box_start("CENTER", "100%"); |
7ef459eb |
705 | print_heading("<A HREF=\"course/index.php?category=$category->id\">$category->name</A>", "LEFT"); |
0c656181 |
706 | $some = false; |
707 | echo "<UL>"; |
708 | foreach ($courses as $key => $course) { |
709 | if ($course->category == $category->id) { |
85098089 |
710 | echo "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A>"; |
711 | echo " "; |
0c656181 |
712 | unset($courses[$key]); |
85098089 |
713 | if ($course->guest ) { |
714 | echo "<A TITLE=\"$strallowguests\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">"; |
715 | echo "<IMG ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/user/user.gif\"></A>"; |
716 | } |
717 | if ($course->password) { |
718 | echo "<A TITLE=\"$strrequireskey\" HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">"; |
719 | echo "<IMG ALT=\"\" HEIGHT=16 WIDTH=16 BORDER=0 SRC=\"$CFG->wwwroot/pix/i/key.gif\"></A>"; |
720 | } |
721 | echo "<BR>"; |
0c656181 |
722 | $some = true; |
723 | } |
724 | } |
725 | if (!$some) { |
726 | print_string("nocoursesyet"); |
727 | } |
728 | echo "</UL>"; |
729 | print_simple_box_end(); |
730 | print_spacer(8,1); |
731 | } |
ba2e5d73 |
732 | } |
0c656181 |
733 | |
734 | } else { // Print short list of categories only |
735 | foreach ($categories as $cat) { |
736 | $caticon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>"; |
737 | if ($cat->id == $selected) { |
738 | $catdata[]="$cat->name"; |
739 | } else { |
740 | $catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>"; |
741 | } |
742 | } |
743 | $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>"; |
744 | if (isset($USER->id)) { |
745 | $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=my\">".get_string("mycourses")."</A>"; |
746 | } |
5e367a2d |
747 | print_side_block(get_string("categories"), "", $catdata, $caticon, $showall.$mine, $width); |
ba2e5d73 |
748 | } |
ba2e5d73 |
749 | } |
94361e02 |
750 | |
2b8cef80 |
751 | function print_log_graph($course, $userid=0, $type="course.png", $date=0) { |
752 | global $CFG; |
753 | echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">"; |
754 | } |
755 | |
11b0c469 |
756 | |
757 | |
758 | /// MODULE FUNCTIONS ///////////////////////////////////////////////////////////////// |
759 | |
760 | function add_course_module($mod) { |
761 | GLOBAL $db; |
762 | |
e5dfd0f3 |
763 | $mod->added = time(); |
11b0c469 |
764 | |
e5dfd0f3 |
765 | return insert_record("course_modules", $mod); |
11b0c469 |
766 | } |
767 | |
768 | function add_mod_to_section($mod) { |
769 | // Returns the course_sections ID where the mod is inserted |
770 | GLOBAL $db; |
771 | |
e5dfd0f3 |
772 | if ($section = get_record_sql("SELECT * FROM course_sections |
773 | WHERE course = '$mod->course' AND section = '$mod->section'") ) { |
11b0c469 |
774 | |
e5dfd0f3 |
775 | if ($section->sequence) { |
776 | $newsequence = "$section->sequence,$mod->coursemodule"; |
11b0c469 |
777 | } else { |
778 | $newsequence = "$mod->coursemodule"; |
779 | } |
e5dfd0f3 |
780 | if (set_field("course_sections", "sequence", $newsequence, "id", $section->id)) { |
781 | return $section->id; // Return course_sections ID that was used. |
11b0c469 |
782 | } else { |
e5dfd0f3 |
783 | return 0; |
11b0c469 |
784 | } |
785 | |
786 | } else { // Insert a new record |
e5dfd0f3 |
787 | $section->course = $mod->course; |
788 | $section->section = $mod->section; |
789 | $section->summary = ""; |
790 | $section->sequence = $mod->coursemodule; |
791 | return insert_record("course_sections", $section); |
11b0c469 |
792 | } |
793 | } |
794 | |
795 | function delete_course_module($mod) { |
796 | return set_field("course_modules", "deleted", 1, "id", $mod); |
797 | } |
798 | |
799 | function delete_mod_from_section($mod, $section) { |
800 | GLOBAL $db; |
801 | |
e5dfd0f3 |
802 | if ($section = get_record("course_sections", "id", "$section") ) { |
11b0c469 |
803 | |
e5dfd0f3 |
804 | $modarray = explode(",", $section->sequence); |
11b0c469 |
805 | |
806 | if ($key = array_keys ($modarray, $mod)) { |
807 | array_splice($modarray, $key[0], 1); |
808 | $newsequence = implode(",", $modarray); |
e5dfd0f3 |
809 | return set_field("course_sections", "sequence", $newsequence, "id", $section->id); |
11b0c469 |
810 | } else { |
811 | return false; |
812 | } |
813 | |
814 | } else { |
815 | return false; |
816 | } |
817 | } |
818 | |
819 | |
7c0f2984 |
820 | function move_module($cm, $move) { |
11b0c469 |
821 | GLOBAL $db; |
822 | |
823 | if (!$move) { |
824 | return true; |
825 | } |
826 | |
11b0c469 |
827 | if (! $thissection = get_record("course_sections", "id", $cm->section)) { |
828 | error("This course section doesn't exist"); |
829 | } |
830 | |
831 | $mods = explode(",", $thissection->sequence); |
832 | |
833 | $len = count($mods); |
834 | $pos = array_keys($mods, $cm->id); |
835 | $thepos = $pos[0]; |
836 | |
837 | if ($len == 0 || count($pos) == 0 ) { |
838 | error("Very strange. Could not find the required module in this section."); |
839 | } |
840 | |
841 | if ($len == 1) { |
842 | $first = true; |
843 | $last = true; |
844 | } else { |
845 | $first = ($thepos == 0); |
846 | $last = ($thepos == $len - 1); |
847 | } |
848 | |
849 | if ($move < 0) { // Moving the module up |
850 | |
851 | if ($first) { |
852 | if ($thissection->section == 1) { // First section, do nothing |
853 | return true; |
854 | } else { // Push onto end of previous section |
855 | $prevsectionnumber = $thissection->section - 1; |
856 | if (! $prevsection = get_record_sql("SELECT * FROM course_sections |
857 | WHERE course='$thissection->course' |
858 | AND section='$prevsectionnumber' ")) { |
859 | error("Previous section ($prevsection->id) doesn't exist"); |
860 | } |
861 | |
862 | if ($prevsection->sequence) { |
863 | $newsequence = "$prevsection->sequence,$cm->id"; |
864 | } else { |
865 | $newsequence = "$cm->id"; |
866 | } |
867 | |
868 | if (! set_field("course_sections", "sequence", $newsequence, "id", $prevsection->id)) { |
869 | error("Previous section could not be updated"); |
870 | } |
871 | |
872 | if (! set_field("course_modules", "section", $prevsection->id, "id", $cm->id)) { |
873 | error("Module could not be updated"); |
874 | } |
875 | |
876 | array_splice($mods, 0, 1); |
877 | $newsequence = implode(",", $mods); |
878 | if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) { |
879 | error("Module could not be updated"); |
880 | } |
881 | |
882 | return true; |
883 | |
884 | } |
885 | } else { // move up within this section |
886 | $swap = $mods[$thepos-1]; |
887 | $mods[$thepos-1] = $mods[$thepos]; |
888 | $mods[$thepos] = $swap; |
889 | |
890 | $newsequence = implode(",", $mods); |
891 | if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) { |
892 | error("This section could not be updated"); |
893 | } |
894 | return true; |
895 | } |
896 | |
897 | } else { // Moving the module down |
898 | |
899 | if ($last) { |
900 | $nextsectionnumber = $thissection->section + 1; |
901 | if ($nextsection = get_record_sql("SELECT * FROM course_sections |
902 | WHERE course='$thissection->course' |
903 | AND section='$nextsectionnumber' ")) { |
904 | |
905 | if ($nextsection->sequence) { |
906 | $newsequence = "$cm->id,$nextsection->sequence"; |
907 | } else { |
908 | $newsequence = "$cm->id"; |
909 | } |
910 | |
911 | if (! set_field("course_sections", "sequence", $newsequence, "id", $nextsection->id)) { |
912 | error("Next section could not be updated"); |
913 | } |
914 | |
915 | if (! set_field("course_modules", "section", $nextsection->id, "id", $cm->id)) { |
916 | error("Module could not be updated"); |
917 | } |
918 | |
919 | array_splice($mods, $thepos, 1); |
920 | $newsequence = implode(",", $mods); |
921 | if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) { |
922 | error("This section could not be updated"); |
923 | } |
924 | return true; |
925 | |
926 | } else { // There is no next section, so just return |
927 | return true; |
928 | |
929 | } |
930 | } else { // move down within this section |
931 | $swap = $mods[$thepos+1]; |
932 | $mods[$thepos+1] = $mods[$thepos]; |
933 | $mods[$thepos] = $swap; |
934 | |
935 | $newsequence = implode(",", $mods); |
936 | if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) { |
937 | error("This section could not be updated"); |
938 | } |
939 | return true; |
940 | } |
941 | } |
942 | } |
943 | |
94361e02 |
944 | function make_editing_buttons($moduleid, $absolute=false) { |
945 | global $CFG; |
946 | |
90845098 |
947 | $delete = get_string("delete"); |
948 | $moveup = get_string("moveup"); |
949 | $movedown = get_string("movedown"); |
950 | $update = get_string("update"); |
94361e02 |
951 | |
952 | if ($absolute) { |
953 | $path = "$CFG->wwwroot/course/"; |
954 | } else { |
955 | $path = ""; |
956 | } |
5e367a2d |
957 | return "<A TITLE=\"$delete\" HREF=\"".$path."mod.php?delete=$moduleid\"><IMG |
97c270e9 |
958 | SRC=".$path."../pix/t/delete.gif BORDER=0></A> |
959 | <A TITLE=\"$moveup\" HREF=\"".$path."mod.php?id=$moduleid&move=-1\"><IMG |
960 | SRC=".$path."../pix/t/up.gif BORDER=0></A> |
961 | <A TITLE=\"$movedown\" HREF=\"".$path."mod.php?id=$moduleid&move=1\"><IMG |
962 | SRC=".$path."../pix/t/down.gif BORDER=0></A> |
963 | <A TITLE=\"$update\" HREF=\"".$path."mod.php?update=$moduleid\"><IMG |
964 | SRC=".$path."../pix/t/edit.gif BORDER=0></A>"; |
90845098 |
965 | } |
966 | |
f9903ed0 |
967 | ?> |