Tweaks
[moodle.git] / course / lib.php
CommitLineData
e4027ac9 1<?php // $Id$
97c270e9 2 // Library of useful functions
f9903ed0 3
f9903ed0 4
3d891989 5if (defined('COURSE_MAX_LOG_DISPLAY')) { // Being included again - should never happen!!
9ae687af 6 return;
7}
8
3d891989 9define('COURSE_MAX_LOG_DISPLAY', 150); // days
d9d1c35d 10
3d891989 11define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records
1c0200e0 12
3d891989 13define('COURSE_LIVELOG_REFRESH', 60); // Seconds
87ffed0d 14
cb29b020 15define('COURSE_MAX_RECENT_PERIOD', 604800); // A week, in seconds
16
17define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); // courses
ef58b822 18
c2cb4545 19define("FRONTPAGENEWS", 0);
20define("FRONTPAGECOURSELIST", 1);
21define("FRONTPAGECATEGORYNAMES", 2);
f9903ed0 22
9ae687af 23
f24cffb9 24function print_log_selector_form($course, $selecteduser=0, $selecteddate="today",
69d79bc3 25 $mod="", $modid=0, $modaction="") {
f9903ed0 26
9481285b 27 global $USER, $CFG;
28
2ac64806 29
30 $isteacher = isteacher($course->id);
f9903ed0 31 // Get all the possible users
32 $users = array();
720a43ce 33
34 if ($course->category) {
4d744a22 35 $courseusers = get_course_users($course->id);
1a5ab449 36 } else {
37 $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname");
38 }
39
40 if ($courseusers) {
41 foreach ($courseusers as $courseuser) {
2ac64806 42 $users[$courseuser->id] = fullname($courseuser, $isteacher);
122cffc9 43 }
f9903ed0 44 }
1a5ab449 45 if ($guest = get_guest()) {
f5104a2b 46 $users[$guest->id] = fullname($guest);
1a5ab449 47 }
720a43ce 48
49 if (isadmin()) {
9fa49e22 50 if ($ccc = get_records("course", "", "", "fullname")) {
720a43ce 51 foreach ($ccc as $cc) {
cfa5d3f2 52 if ($cc->category) {
53 $courses["$cc->id"] = "$cc->fullname";
54 } else {
55 $courses["$cc->id"] = " $cc->fullname (Site)";
56 }
720a43ce 57 }
f9903ed0 58 }
cfa5d3f2 59 asort($courses);
f9903ed0 60 }
61
f24cffb9 62 $activities = array();
63 $selectedactivity = "";
64
65 if ($modinfo = unserialize($course->modinfo)) {
66 $section = 0;
67 if ($course->format == 'weeks') { // Bodgy
68 $strsection = get_string("week");
69 } else {
70 $strsection = get_string("topic");
71 }
72 foreach ($modinfo as $mod) {
73 if ($mod->mod == "label") {
74 continue;
75 }
76 if ($mod->section > 0 and $section <> $mod->section) {
77 $activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------";
78 }
79 $section = $mod->section;
80 $mod->name = urldecode($mod->name);
81 if (strlen($mod->name) > 55) {
82 $mod->name = substr($mod->name, 0, 50)."...";
83 }
84 if (!$mod->visible) {
85 $mod->name = "(".$mod->name.")";
86 }
69d79bc3 87 $activities["$mod->cm"] = $mod->name;
f24cffb9 88
89 if ($mod->cm == $modid) {
69d79bc3 90 $selectedactivity = "$mod->cm";
f24cffb9 91 }
92 }
93 }
dcde9f02 94
95 $strftimedate = get_string("strftimedate");
96 $strftimedaydate = get_string("strftimedaydate");
97
f9903ed0 98 asort($users);
99
100 // Get all the possible dates
9481285b 101 // Note that we are keeping track of real (GMT) time and user time
102 // User time is only used in displays - all calcs and passing is GMT
103
104 $timenow = time(); // GMT
105
106 // What day is it now for the user, and when is midnight that day (in GMT).
9604ccb1 107 $timemidnight = $today = usergetmidnight($timenow);
9481285b 108
109 // Put today up the top of the list
dcde9f02 110 $dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, $strftimedate) );
9481285b 111
3695f5b4 112 if (!$course->startdate or ($course->startdate > $timenow)) {
9481285b 113 $course->startdate = $course->timecreated;
114 }
f9903ed0 115
9481285b 116 $numdates = 1;
117 while ($timemidnight > $course->startdate and $numdates < 365) {
f9903ed0 118 $timemidnight = $timemidnight - 86400;
9481285b 119 $timenow = $timenow - 86400;
dcde9f02 120 $dates["$timemidnight"] = userdate($timenow, $strftimedaydate);
9481285b 121 $numdates++;
f9903ed0 122 }
123
124 if ($selecteddate == "today") {
125 $selecteddate = $today;
126 }
127
f24cffb9 128 echo '<center>';
129 echo '<form action="log.php" method="get">';
130 echo '<input type=hidden name=chooselog value="1">';
720a43ce 131 if (isadmin()) {
849bc02a 132 choose_from_menu ($courses, "id", $course->id, "");
720a43ce 133 } else {
f24cffb9 134 echo "<input type=hidden name=id value=\"$course->id\">";
720a43ce 135 }
1a5ab449 136 choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
97c270e9 137 choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));
69d79bc3 138 choose_from_menu ($activities, "modid", $selectedactivity, get_string("allactivities"), "", "");
f24cffb9 139 echo "<input type=submit value=\"".get_string("showtheselogs")."\">";
140 echo "</form>";
141 echo "</center>";
f9903ed0 142}
143
600149be 144function make_log_url($module, $url) {
145 switch ($module) {
146 case "course":
147 case "user":
148 case "file":
149 case "login":
150 case "lib":
151 case "admin":
152 return "/$module/$url";
153 break;
154 default:
155 return "/mod/$module/$url";
156 break;
157 }
158}
159
160
f24cffb9 161function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
69d79bc3 162 $url="", $mod="", $modid=0, $modaction="") {
f24cffb9 163
9481285b 164// It is assumed that $date is the GMT time of midnight for that day,
165// and so the next 86400 seconds worth of logs are printed.
f9903ed0 166
f24cffb9 167 global $CFG, $db;
47f1da80 168
720a43ce 169 if ($course->category) {
519d369f 170 $selector = "l.course='$course->id' AND l.userid = u.id";
a2ab3b05 171
720a43ce 172 } else {
519d369f 173 $selector = "l.userid = u.id"; // Show all courses
1a5ab449 174 if ($ccc = get_courses("all", "c.id ASC", "c.id,c.shortname")) {
720a43ce 175 foreach ($ccc as $cc) {
176 $courses[$cc->id] = "$cc->shortname";
177 }
178 }
179 }
f9903ed0 180
f24cffb9 181 if ($mod) {
182 $selector .= " AND l.module = '$mod'";
183 }
184
69d79bc3 185 if ($modid) {
186 $selector .= " AND l.cmid = '$modid'";
187 }
188
189 if ($modaction) {
190 $selector .= " AND l.action = '$modaction'";
f24cffb9 191 }
192
f9903ed0 193 if ($user) {
ebc3bd2b 194 $selector .= " AND l.userid = '$user'";
f9903ed0 195 }
196
197 if ($date) {
198 $enddate = $date + 86400;
199 $selector .= " AND l.time > '$date' AND l.time < '$enddate'";
200 }
201
f24cffb9 202
d09f3c80 203 $totalcount = 0; // Initialise
204
519d369f 205 if (!$logs = get_logs($selector, $order, $page*$perpage, $perpage, $totalcount)) {
f9903ed0 206 notify("No logs found!");
207 print_footer($course);
208 exit;
209 }
210
211 $count=0;
212 $tt = getdate(time());
213 $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
1c0200e0 214
dcde9f02 215 $strftimedatetime = get_string("strftimedatetime");
2ac64806 216 $isteacher = isteacher($course->id);
dcde9f02 217
f9d5fd3b 218 echo "<p align=center>";
519d369f 219 print_string("displayingrecords", "", $totalcount);
f9d5fd3b 220 echo "</p>";
1c0200e0 221
519d369f 222 print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&");
223
f9d5fd3b 224 echo "<table border=0 align=center cellpadding=3 cellspacing=3>";
f9903ed0 225 foreach ($logs as $log) {
600149be 226
9fa49e22 227 if ($ld = get_record("log_display", "module", "$log->module", "action", "$log->action")) {
565f7a95 228 $log->info = get_field($ld->mtable, $ld->field, "id", $log->info);
600149be 229 }
230
f9d5fd3b 231 echo "<tr nowrap>";
720a43ce 232 if (! $course->category) {
f9d5fd3b 233 echo "<td nowrap><font size=2><a href=\"view.php?id=$log->course\">".$courses[$log->course]."</a></td>";
720a43ce 234 }
f9d5fd3b 235 echo "<td nowrap align=right><font size=2>".userdate($log->time, "%a")."</td>";
236 echo "<td nowrap><font size=2>".userdate($log->time, $strftimedatetime)."</td>";
dc0dc7d5 237 echo "<td nowrap><font size=2>";
47f1da80 238 link_to_popup_window("/lib/ipatlas/plot.php?address=$log->ip&user=$log->userid", "ipatlas","$log->ip", 400, 700);
f9d5fd3b 239 echo "</td>";
2ac64806 240 $fullname = fullname($log, $isteacher);
241 echo "<td nowrap><font size=2><a href=\"../user/view.php?id=$log->userid&course=$log->course\"><b>$fullname</b></td>";
f9d5fd3b 242 echo "<td nowrap><font size=2>";
600149be 243 link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600);
f9d5fd3b 244 echo "</td>";
245 echo "<td nowrap><font size=2>$log->info</td>";
246 echo "</tr>";
f9903ed0 247 }
f9d5fd3b 248 echo "</table>";
519d369f 249
250 print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&");
f9903ed0 251}
252
253
c2cb4545 254function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
255 global $CFG;
256 if (empty($CFG->gdversion)) {
257 echo "(".get_string("gdneed").")";
d887b5a7 258 } else {
c2cb4545 259 echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
d887b5a7 260 }
261}
262
263
f9903ed0 264
600149be 265function print_recent_activity($course) {
266 // $course is an object
267 // This function trawls through the logs looking for
268 // anything new since the user's last login
269
bf40f9c1 270 global $CFG, $USER, $THEME, $SESSION;
600149be 271
2ac64806 272 $isteacher = isteacher($course->id);
273
600149be 274 if (! $USER->lastlogin ) {
3d891989 275 echo "<p align=center><font size=1>";
4b1371a7 276 print_string("welcometocourse", "", $course->shortname);
3d891989 277 echo "</font></p>";
600149be 278 return;
4c654ee3 279 } else {
3d891989 280 echo "<p align=center><font size=1>";
4c654ee3 281 echo get_string("yourlastlogin").":<BR>";
dcde9f02 282 echo userdate($USER->lastlogin, get_string("strftimerecentfull"));
3d891989 283 echo "</font></p>";
284 }
285
286 $timestart = $USER->lastlogin;
b1992e65 287 $timemaxrecent = time() - COURSE_MAX_RECENT_PERIOD;
288 if ($timestart < $timemaxrecent) {
289 $timestart = $timemaxrecent;
600149be 290 }
291
600149be 292
293 // Firstly, have there been any new enrolments?
294
295 $heading = false;
296 $content = false;
1b5910c4 297
6c38b7e0 298 $users = get_recent_enrolments($course->id, $timestart);
1b5910c4 299
6c38b7e0 300 if ($users) {
e2b7251d 301 echo "<p>";
6c38b7e0 302 foreach ($users as $user) {
600149be 303 if (! $heading) {
4c654ee3 304 print_headline(get_string("newusers").":");
600149be 305 $heading = true;
306 $content = true;
307 }
2ac64806 308 $fullname = fullname($user, $isteacher);
309 echo "<font size=1><a href=\"../user/view.php?id=$user->id&course=$course->id\">$fullname</a></font><br />";
600149be 310 }
e2b7251d 311 echo "</p>";
600149be 312 }
313
1b5910c4 314 // Next, have there been any modifications to the course structure?
315
316 $logs = get_records_select("log", "time > '$timestart' AND course = '$course->id' AND
317 module = 'course' AND action LIKE '% mod'", "time ASC");
318
319 if ($logs) {
320 foreach ($logs as $key => $log) {
321 $info = split(" ", $log->info);
c9f6251e 322
323 if ($info[0] == "label") { // Labels are special activities
324 continue;
325 }
326
1b5910c4 327 $modname = get_field($info[0], "name", "id", $info[1]);
328 //Create a temp valid module structure (course,id)
329 $tempmod->course = $log->course;
330 $tempmod->id = $info[1];
331 //Obtain the visible property from the instance
332 $modvisible = instance_is_visible($info[0],$tempmod);
333
334 //Only if the mod is visible
335 if ($modvisible) {
336 switch ($log->action) {
337 case "add mod":
338 $stradded = get_string("added", "moodle", get_string("modulename", $info[0]));
339 $changelist["$log->info"] = array ("operation" => "add", "text" => "$stradded:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
340 break;
341 case "update mod":
342 $strupdated = get_string("updated", "moodle", get_string("modulename", $info[0]));
343 if (empty($changelist["$log->info"])) {
344 $changelist["$log->info"] = array ("operation" => "update", "text" => "$strupdated:<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
345 }
346 break;
347 case "delete mod":
348 if (!empty($changelist["$log->info"]["operation"]) and
349 $changelist["$log->info"]["operation"] == "add") {
350 $changelist["$log->info"] = NULL;
351 } else {
352 $strdeleted = get_string("deletedactivity", "moodle", get_string("modulename", $info[0]));
353 $changelist["$log->info"] = array ("operation" => "delete", "text" => $strdeleted);
354 }
355 break;
600149be 356 }
ef25340c 357 }
358 }
359 }
360
9c9f7d77 361 if (!empty($changelist)) {
ef25340c 362 foreach ($changelist as $changeinfo => $change) {
363 if ($change) {
364 $changes[$changeinfo] = $change;
365 }
366 }
8a59942e 367 if (isset($changes)){
368 if (count($changes) > 0) {
369 print_headline(get_string("courseupdates").":");
370 $content = true;
371 foreach ($changes as $changeinfo => $change) {
372 echo "<p><font size=1>".$change["text"]."</font></p>";
373 }
600149be 374 }
375 }
bf40f9c1 376 }
377
378
379 // If this site uses Library module, then print recent items
380 if (!empty($CFG->librarypath)) {
381 if (file_exists("$CFG->dirroot/$CFG->librarypath/librarylib.php")) {
382 include_once("$CFG->dirroot/$CFG->librarypath/librarylib.php");
383 if (librarysummarize(5, '', date('YmdHis',$USER->lastlogin))) {
384 $content = true;
385 }
386 }
600149be 387 }
388
3869a2ac 389 // Now display new things from each module
600149be 390
0fd7da81 391 $mods = get_records("modules", "visible", "1", "name", "id, name");
392
1b5910c4 393 foreach ($mods as $mod) { // Each module gets it's own logs and prints them
0fd7da81 394 include_once("$CFG->dirroot/mod/$mod->name/lib.php");
395 $print_recent_activity = $mod->name."_print_recent_activity";
1b5910c4 396 if (function_exists($print_recent_activity)) {
397 $modcontent = $print_recent_activity($course, $isteacher, $timestart);
3869a2ac 398 if ($modcontent) {
399 $content = true;
600149be 400 }
600149be 401 }
402 }
403
404 if (! $content) {
3d891989 405 echo "<font size=2>".get_string("nothingnew")."</font>";
600149be 406 }
600149be 407}
408
e1360728 409
d897cae4 410function get_array_of_activities($courseid) {
411// For a given course, returns an array of course activity objects
412// Each item in the array contains he following properties:
413// cm - course module id
414// mod - name of the module (eg forum)
415// section - the number of the section (eg week or topic)
416// name - the name of the instance
5867bfb5 417// visible - is the instance visible or not
86aa7ccf 418// extra - contains extra string to include in any link
d897cae4 419
8dddba42 420 global $CFG;
421
d897cae4 422 $mod = array();
423
9fa49e22 424 if (!$rawmods = get_course_mods($courseid)) {
d897cae4 425 return NULL;
426 }
427
428 if ($sections = get_records("course_sections", "course", $courseid, "section ASC")) {
429 foreach ($sections as $section) {
74666583 430 if (!empty($section->sequence)) {
d897cae4 431 $sequence = explode(",", $section->sequence);
432 foreach ($sequence as $seq) {
7af6281f 433 if (empty($rawmods[$seq])) {
434 continue;
435 }
d897cae4 436 $mod[$seq]->cm = $rawmods[$seq]->id;
437 $mod[$seq]->mod = $rawmods[$seq]->modname;
438 $mod[$seq]->section = $section->section;
439 $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
fec5a6a6 440 $mod[$seq]->visible = $rawmods[$seq]->visible;
86aa7ccf 441 $mod[$seq]->extra = "";
8dddba42 442
443 $modname = $mod[$seq]->mod;
444 $functionname = $modname."_get_coursemodule_info";
445
446 include_once("$CFG->dirroot/mod/$modname/lib.php");
447
448 if (function_exists($functionname)) {
449 if ($extra = $functionname($rawmods[$seq])) {
450 $mod[$seq]->extra = $extra;
c9f6251e 451 }
452 }
d897cae4 453 }
454 }
455 }
456 }
457 return $mod;
458}
459
460
461
e1360728 462
90845098 463function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) {
464// Returns a number of useful structures for course displays
7468bf01 465
90845098 466 $mods = NULL; // course modules indexed by id
467 $modnames = NULL; // all course module names
94361e02 468 $modnamesplural= NULL; // all course module names (plural form)
90845098 469 $modnamesused = NULL; // course module names used
7468bf01 470
9fa49e22 471 if ($allmods = get_records("modules")) {
90845098 472 foreach ($allmods as $mod) {
5867bfb5 473 if ($mod->visible) {
474 $modnames[$mod->name] = get_string("modulename", "$mod->name");
475 $modnamesplural[$mod->name] = get_string("modulenameplural", "$mod->name");
476 }
90845098 477 }
478 asort($modnames);
479 } else {
480 error("No modules are installed!");
481 }
482
9fa49e22 483 if ($rawmods = get_course_mods($courseid)) {
7468bf01 484 foreach($rawmods as $mod) { // Index the mods
485 $mods[$mod->id] = $mod;
90845098 486 $mods[$mod->id]->modfullname = $modnames[$mod->modname];
1acfbce5 487 if ($mod->visible or isteacher($courseid)) {
488 $modnamesused[$mod->modname] = $modnames[$mod->modname];
489 }
7468bf01 490 }
c7da6f7a 491 if ($modnamesused) {
492 asort($modnamesused);
493 }
7468bf01 494 }
7468bf01 495}
496
9fa49e22 497
7468bf01 498function get_all_sections($courseid) {
499
d26d7ed0 500 return get_records("course_sections", "course", "$courseid", "section",
7d99d695 501 "section, id, course, summary, sequence, visible");
7468bf01 502}
503
b86fc0e2 504function course_set_display($courseid, $display=0) {
505 global $USER;
506
507 if (empty($USER)) {
508 return false;
509 }
510
511 if ($display == "all" or empty($display)) {
512 $display = 0;
513 }
514
515 if (record_exists("course_display", "userid", $USER->id, "course", $courseid)) {
516 set_field("course_display", "display", $display, "userid", $USER->id, "course", $courseid);
517 } else {
518 $record->userid = $USER->id;
519 $record->course = $courseid;
520 $record->display = $display;
521 if (!insert_record("course_display", $record)) {
522 notify("Could not save your course display!");
523 }
524 }
525
526 return $USER->display[$courseid] = $display; // Note: = not ==
527}
528
7d99d695 529function set_section_visible($courseid, $sectionnumber, $visibility) {
530/// For a given course section, markes it visible or hidden,
531/// and does the same for every activity in that section
532
533 if ($section = get_record("course_sections", "course", $courseid, "section", $sectionnumber)) {
534 set_field("course_sections", "visible", "$visibility", "id", $section->id);
535 if (!empty($section->sequence)) {
536 $modules = explode(",", $section->sequence);
537 foreach ($modules as $moduleid) {
538 set_field("course_modules", "visible", "$visibility", "id", $moduleid);
539 }
540 }
5867bfb5 541 rebuild_course_cache($courseid);
7d99d695 542 }
543}
ba2e5d73 544
5e367a2d 545function print_section_block($heading, $course, $section, $mods, $modnames, $modnamesused,
52dcc2f9 546 $absolute=true, $width="100%") {
5e367a2d 547
2c8cb30c 548 global $CFG, $USER, $THEME;
3d575e6f 549 static $groupbuttons;
52dcc2f9 550 static $isteacher;
551 static $isediting;
2c8cb30c 552 static $ismoving;
553 static $strmovehere;
554 static $strmovefull;
3d575e6f 555 static $strcancel;
556 static $stractivityclipboard;
52dcc2f9 557
558 if (!isset($isteacher)) {
3d575e6f 559 $groupbuttons = $course->groupmode and !$course->groupmodeforce;
52dcc2f9 560 $isteacher = isteacher($course->id);
52dcc2f9 561 $isediting = isediting($course->id);
2c8cb30c 562 $ismoving = ismoving($course->id);
3d575e6f 563 if ($ismoving) {
564 $strmovehere = get_string("movehere");
565 $strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
566 $strcancel= get_string("cancel");
567 $stractivityclipboard = $USER->activitycopyname;
568 }
2c8cb30c 569 }
5e367a2d 570
571 $modinfo = unserialize($course->modinfo);
572 $moddata = array();
573 $modicon = array();
574 $editbuttons = "";
575
3d575e6f 576 if ($ismoving) {
577 $modicon[] = "&nbsp;<img align=bottom src=\"$CFG->pixpath/t/move.gif\" height=\"11\" width=\"11\">";
578 $moddata[] = "$USER->activitycopyname&nbsp;(<a href=\"$CFG->wwwroot/course/mod.php?cancelcopy=true\">$strcancel</a>)";
579 }
580
74666583 581 if (!empty($section->sequence)) {
5e367a2d 582
583 $sectionmods = explode(",", $section->sequence);
584
2c8cb30c 585
5e367a2d 586 foreach ($sectionmods as $modnumber) {
52dcc2f9 587 if (empty($mods[$modnumber])) {
588 continue;
589 }
5e367a2d 590 $mod = $mods[$modnumber];
2c8cb30c 591 if ($isediting and !$ismoving) {
3d575e6f 592 if (!$groupbuttons) {
593 $mod->groupmode = false;
594 }
595 $editbuttons = "<br />".make_editing_buttons($mod, $absolute, true);
2c8cb30c 596 } else {
597 $editbuttons = "";
1acfbce5 598 }
52dcc2f9 599 if ($mod->visible or $isteacher) {
2c8cb30c 600 if ($ismoving) {
601 if ($mod->id == $USER->activitycopy) {
602 continue;
603 }
604 $modicon[] = "";
6951a894 605 $moddata[] = "<a title=\"$strmovefull\"".
606 " href=\"$CFG->wwwroot/course/mod.php?moveto=$mod->id\">".
607 "<img height=\"16\" width=\"80\" src=\"$CFG->pixpath/movehere.gif\" ".
608 " alt=\"$strmovehere\" border=\"0\"></a>";
2c8cb30c 609 }
1acfbce5 610 $instancename = urldecode($modinfo[$modnumber]->name);
c2cb4545 611 $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
3ee3e01a 612 if (!empty($modinfo[$modnumber]->extra)) {
613 $extra = urldecode($modinfo[$modnumber]->extra);
614 } else {
615 $extra = "";
616 }
7977cffd 617
c9f6251e 618 if ($mod->modname == "label") {
619 $modicon[] = "";
620 $moddata[] = format_text($extra, FORMAT_HTML).$editbuttons;
621 } else {
e845dee2 622 $modicon[] = "<img src=\"$CFG->modpixpath/$mod->modname/icon.gif\"".
c9f6251e 623 " height=\"16\" width=\"16\" alt=\"$mod->modfullname\">";
624 $moddata[] = "<a title=\"$mod->modfullname\" $linkcss $extra".
625 "href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a>".
626 "$editbuttons";
627 }
5e367a2d 628 }
5e367a2d 629 }
630 }
2c8cb30c 631 if ($ismoving) {
632 $modicon[] = "";
6951a894 633 $moddata[] = "<a title=\"$strmovefull\"".
634 " href=\"$CFG->wwwroot/course/mod.php?movetosection=$section->id\">".
635 "<img height=\"16\" width=\"80\" src=\"$CFG->pixpath/movehere.gif\" ".
636 " alt=\"$strmovehere\" border=\"0\"></a>";
2c8cb30c 637 }
a44d18e7 638 if ($isediting) {
15ac9065 639 $editmenu = popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section->section&add=",
5e367a2d 640 $modnames, "section0", "", get_string("add")."...", "mods", get_string("activities"), true);
dfec7b01 641 $editmenu = "<div align=right>$editmenu</div>";
47f1da80 642 } else {
643 $editmenu = "";
5e367a2d 644 }
645
646 print_side_block($heading, "", $moddata, $modicon, $editmenu, $width);
647}
648
649
d897cae4 650function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
52dcc2f9 651/// Prints a section full of activity modules
7977cffd 652 global $CFG, $USER;
653
3d575e6f 654 static $groupbuttons;
52dcc2f9 655 static $isteacher;
656 static $isediting;
7977cffd 657 static $ismoving;
658 static $strmovehere;
659 static $strmovefull;
52dcc2f9 660
661 if (!isset($isteacher)) {
3d575e6f 662 $groupbuttons = $course->groupmode and !$course->groupmodeforce;
52dcc2f9 663 $isteacher = isteacher($course->id);
52dcc2f9 664 $isediting = isediting($course->id);
7977cffd 665 $ismoving = ismoving($course->id);
3d575e6f 666 if ($ismoving) {
667 $strmovehere = get_string("movehere");
668 $strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
669 }
7977cffd 670 }
94361e02 671
c408b0c4 672 $modinfo = unserialize($course->modinfo);
94361e02 673
567df742 674 echo "<table width=\"$width\" cellpadding=1 cellspacing=0>\n";
74666583 675 if (!empty($section->sequence)) {
94361e02 676
677 $sectionmods = explode(",", $section->sequence);
678
679 foreach ($sectionmods as $modnumber) {
9ae687af 680 if (empty($mods[$modnumber])) {
681 continue;
682 }
94361e02 683 $mod = $mods[$modnumber];
c9f6251e 684
52dcc2f9 685 if ($mod->visible or $isteacher) {
c9f6251e 686 echo "<tr><td class=\"activity$mod->modname\">";
7977cffd 687 if ($ismoving) {
688 if ($mod->id == $USER->activitycopy) {
689 continue;
690 }
6951a894 691 echo "<a title=\"$strmovefull\"".
692 " href=\"mod.php?moveto=$mod->id\">".
693 "<img height=\"16\" width=\"80\" src=\"$CFG->pixpath/movehere.gif\" ".
694 " alt=\"$strmovehere\" border=\"0\"></a><br />\n";
1acfbce5 695 }
7977cffd 696 $instancename = urldecode($modinfo[$modnumber]->name);
c9f6251e 697
86aa7ccf 698 if (!empty($modinfo[$modnumber]->extra)) {
699 $extra = urldecode($modinfo[$modnumber]->extra);
700 } else {
701 $extra = "";
702 }
c9f6251e 703
aac94fd0 704 if ($mod->indent) {
705 print_spacer(12, 20 * $mod->indent, false);
706 }
707
c9f6251e 708 if ($mod->modname == "label") {
aac94fd0 709 if (!$mod->visible) {
710 echo "<span class=\"dimmed_text\">";
711 }
c9f6251e 712 echo format_text($extra, FORMAT_HTML);
aac94fd0 713 if (!$mod->visible) {
714 echo "</span>";
715 }
c9f6251e 716
717 } else { // Normal activity
718 $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
e845dee2 719 echo "<img src=\"$CFG->modpixpath/$mod->modname/icon.gif\"".
c9f6251e 720 " height=16 width=16 alt=\"$mod->modfullname\">".
721 " <font size=2><a title=\"$mod->modfullname\" $linkcss $extra".
722 " href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a></font>";
723 }
c9f6251e 724 if ($isediting) {
3d575e6f 725 if (!$groupbuttons) {
726 $mod->groupmode = false;
727 }
ffc69cd3 728 echo "&nbsp;&nbsp;";
3d575e6f 729 echo make_editing_buttons($mod, $absolute, true, $mod->indent);
c9f6251e 730 }
ffc69cd3 731 echo "</td>";
c9f6251e 732 echo "</tr>";
94361e02 733 }
94361e02 734 }
735 }
7977cffd 736 if ($ismoving) {
6951a894 737 echo "<tr><td><a title=\"$strmovefull\"".
738 " href=\"mod.php?movetosection=$section->id\">".
739 "<img height=\"16\" width=\"80\" src=\"$CFG->pixpath/movehere.gif\" ".
740 " alt=\"$strmovehere\" border=\"0\"></a></td></tr>\n";
7977cffd 741 }
c9f6251e 742 echo "</table>\n\n";
a7ad3ea6 743}
744
5867bfb5 745
746function rebuild_course_cache($courseid=0) {
747// Rebuilds the cached list of course activities stored in the database
748// If a courseid is not specified, then all are rebuilt
749
750 if ($courseid) {
751 $select = "id = '$courseid'";
752 } else {
753 $select = "";
754 }
755
756 if ($courses = get_records_select("course", $select)) {
757 foreach ($courses as $course) {
758 $modinfo = serialize(get_array_of_activities($course->id));
759 if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
760 notify("Could not cache module information for course '$course->fullname'!");
761 }
762 }
763 }
764}
765
766
7541bc3e 767function print_heading_block($heading, $width="100%", $class="headingblock") {
5e367a2d 768 global $THEME;
769
7541bc3e 770 echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
771 echo "<tr><td bgcolor=\"$THEME->cellheading\" class=\"$class\">";
5e367a2d 772 echo stripslashes($heading);
773 echo "</td></tr></table>";
5e367a2d 774}
775
776function print_side_block($heading="", $content="", $list=NULL, $icons=NULL, $footer="", $width=180) {
777// Prints a nice side block with an optional header. The content can either
778// be a block of HTML or a list of text with optional icons.
a7ad3ea6 779
5e367a2d 780 global $THEME;
781
7541bc3e 782 print_side_block_start($heading, $width);
783
5e367a2d 784 if ($content) {
7541bc3e 785 echo "$content";
5e367a2d 786 } else {
5e367a2d 787 echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
788 foreach ($list as $key => $string) {
7541bc3e 789 echo "<tr bgcolor=\"$THEME->cellcontent2\">";
5e367a2d 790 if ($icons) {
7541bc3e 791 echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">".$icons[$key]."</td>";
a7ad3ea6 792 }
7541bc3e 793 echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"*\"><font size=\"-1\">$string</font></td>";
5e367a2d 794 echo "</tr>";
a7ad3ea6 795 }
5e367a2d 796 if ($footer) {
7541bc3e 797 echo "<tr bgcolor=\"$THEME->cellcontent2\">";
5e367a2d 798 if ($icons) {
7541bc3e 799 echo "<td class=\"sideblocklinks\" valign=\"top\" width=\"16\">&nbsp;</td>";
5e367a2d 800 }
7541bc3e 801 echo "<td class=\"sideblocklinks\"><font size=\"-1\">$footer</td>";
5e367a2d 802 echo "</tr>";
803 }
804 echo "</table>";
a7ad3ea6 805 }
5e367a2d 806
7541bc3e 807 print_side_block_end();
808}
809
810function print_side_block_start($heading="", $width=180, $class="sideblockmain") {
811// Starts a nice side block with an optional header.
812
813 global $THEME;
814
815 echo "<table class=\"sideblock\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
816 if ($heading) {
817 echo "<tr>";
818 echo "<td class=\"sideblockheading\" bgcolor=\"$THEME->cellheading\">$heading</td>";
819 echo "</tr>";
820 }
821 echo "<tr>";
822 echo "<td class=\"$class\" bgcolor=\"$THEME->cellcontent2\">";
823}
824
825function print_side_block_end() {
826 echo "</td></tr>";
7d99d695 827 echo "</table><br />";
94361e02 828}
829
5e367a2d 830
670fddf1 831function print_admin_links ($siteid, $width=180) {
dc0dc7d5 832 global $CFG, $THEME;
2b25f2a0 833
440eb0d7 834 if (isadmin()) {
0d0e550f 835 $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/configure.php\">".get_string("configuration")."</a>...";
836 $modicon[]="<img src=\"$CFG->pixpath/i/admin.gif\" height=16 width=16 alt=\"\" />";
2f4d324b 837
0d0e550f 838 $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/users.php\">".get_string("users")."</a>...";
839 $modicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\" />";
440eb0d7 840 }
2f4d324b 841
55e4b5f9 842 if (iscreator()) {
0d0e550f 843 $moddata[]="<a href=\"$CFG->wwwroot/course/index.php?edit=on\">".get_string("courses")."</a>";
844 $modicon[]="<img src=\"$CFG->pixpath/i/course.gif\" height=16 width=16 alt=\"\" />";
55e4b5f9 845 $fulladmin = "";
846 }
2f4d324b 847
1924074c 848 if (isadmin()) {
0d0e550f 849 $moddata[]="<a href=\"$CFG->wwwroot/course/log.php?id=$siteid\">".get_string("logs")."</a>";
850 $modicon[]="<img src=\"$CFG->pixpath/i/log.gif\" height=16 width=16 alt=\"\" />";
2f4d324b 851
0d0e550f 852 $moddata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$siteid\">".get_string("sitefiles")."</a>";
853 $modicon[]="<img src=\"$CFG->pixpath/i/files.gif\" height=16 width=16 alt=\"\" />";
2f4d324b 854
0d0e550f 855 if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
2f4d324b 856 $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/$CFG->dbtype/frame.php\">".
857 get_string("managedatabase")."</a>";
0d0e550f 858 $modicon[]="<img src=\"$CFG->pixpath/i/db.gif\" height=16 width=16 alt=\"\" />";
859 }
5867bfb5 860 $fulladmin = "<p><a href=\"$CFG->wwwroot/$CFG->admin/\">".get_string("admin")."</a>...";
1924074c 861 }
5e367a2d 862
863 print_side_block(get_string("administration"), "", $moddata, $modicon, $fulladmin, $width);
864
dc0dc7d5 865 echo "<img src=\"$CFG->wwwroot/pix/spacer.gif\" width=\"$width\" height=1><br>";
2b25f2a0 866}
867
b4d7002e 868function print_course_admin_links($course, $width=180) {
dc0dc7d5 869 global $USER, $CFG, $THEME;
44dad735 870
fce1ce13 871 if (isguest()) {
872 return true;
873 }
eef16119 874
13469b82 875 if (isteacher($course->id)) {
eef16119 876
877 $isteacheredit = isteacheredit($course->id);
878
879 if ($isteacheredit) {
c9f6251e 880 $adminicon[]="<img src=\"$CFG->pixpath/i/edit.gif\" height=16 width=16 alt=\"\">";
02ebf404 881 if (isediting($course->id)) {
882 $admindata[]="<a href=\"view.php?id=$course->id&edit=off\">".get_string("turneditingoff")."</a>";
883 } else {
884 $admindata[]="<a href=\"view.php?id=$course->id&edit=on\">".get_string("turneditingon")."</a>";
885 }
886 $admindata[]="<a href=\"edit.php?id=$course->id\">".get_string("settings")."...</a>";
c9f6251e 887 $adminicon[]="<img src=\"$CFG->pixpath/i/settings.gif\" height=16 width=16 alt=\"\">";
3b1bb969 888
889 if (iscreator() or !empty($CFG->teacherassignteachers)) {
890 if (!$course->teachers) {
891 $course->teachers = get_string("defaultcourseteachers");
892 }
893 $admindata[]="<a href=\"teacher.php?id=$course->id\">$course->teachers...</a>";
c9f6251e 894 $adminicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
02ebf404 895 }
4d9d90c0 896 }
02ebf404 897
a33c4ae8 898 if (!$course->students) {
899 $course->students = get_string("defaultcoursestudents");
3b1bb969 900 }
4d9d90c0 901 $admindata[]="<a href=\"student.php?id=$course->id\">$course->students...</a>";
c9f6251e 902 $adminicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
7d569d28 903
eef16119 904 if ($isteacheredit) {
02ebf404 905 $admindata[]="<a href=\"$CFG->wwwroot/backup/backup.php?id=$course->id\">".get_string("backup")."...</a>";
c9f6251e 906 $adminicon[]="<img src=\"$CFG->pixpath/i/backup.gif\" height=16 width=16 alt=\"\">";
02ebf404 907
07bc2435 908 $admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id&wdir=/backupdata\">".get_string("restore")."...</a>";
c9f6251e 909 $adminicon[]="<img src=\"$CFG->pixpath/i/restore.gif\" height=16 width=16 alt=\"\">";
02ebf404 910 $admindata[]="<a href=\"scales.php?id=$course->id\">".get_string("scales")."...</a>";
c9f6251e 911 $adminicon[]="<img src=\"$CFG->pixpath/i/scales.gif\" height=16 width=16 alt=\"\">";
13469b82 912 }
13469b82 913
dc0dc7d5 914 $admindata[]="<a href=\"grades.php?id=$course->id\">".get_string("grades")."...</a>";
c9f6251e 915 $adminicon[]="<img src=\"$CFG->pixpath/i/grades.gif\" height=16 width=16 alt=\"\">";
13469b82 916
dc0dc7d5 917 $admindata[]="<a href=\"log.php?id=$course->id\">".get_string("logs")."...</a>";
c9f6251e 918 $adminicon[]="<img src=\"$CFG->pixpath/i/log.gif\" height=16 width=16 alt=\"\">";
dc0dc7d5 919
eef16119 920 if ($isteacheredit) {
921 $admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id\">".get_string("files")."...</a>";
922 $adminicon[]="<img src=\"$CFG->pixpath/i/files.gif\" height=16 width=16 alt=\"\">";
923 }
f354106d 924
dc0dc7d5 925 $admindata[]="<a href=\"$CFG->wwwroot/doc/view.php?id=$course->id&file=teacher.html\">".get_string("help")."...</a>";
c9f6251e 926 $adminicon[]="<img src=\"$CFG->modpixpath/resource/icon.gif\" height=16 width=16 alt=\"\">";
b4d7002e 927
13469b82 928 if ($teacherforum = forum_get_course_forum($course->id, "teacher")) {
eafc0b44 929 $admindata[]="<a href=\"$CFG->wwwroot/mod/forum/view.php?f=$teacherforum->id\">$teacherforum->name</a>";
c9f6251e 930 $adminicon[]="<img src=\"$CFG->modpixpath/forum/icon.gif\" height=16 width=16 alt=\"\">";
13469b82 931 }
f354106d 932
e550e2d6 933 } else if (!isguest()) { // Students menu
5b8540e0 934 if ($course->showgrades) {
fff79722 935 $admindata[]="<a href=\"grade.php?id=$course->id\">".get_string("grades")."...</a>";
c9f6251e 936 $adminicon[]="<img src=\"$CFG->pixpath/i/grades.gif\" height=16 width=16 alt=\"\">";
fff79722 937 }
3f125001 938 if ($course->showreports) {
939 $admindata[]="<a href=\"user.php?id=$course->id&user=$USER->id\">".get_string("activityreport")."...</a>";
940 $adminicon[]="<img src=\"$CFG->pixpath/i/report.gif\" height=16 width=16 alt=\"\">";
941 }
4fc2eb7a 942 if (is_internal_auth()) {
e550e2d6 943 $admindata[]="<a href=\"$CFG->wwwroot/login/change_password.php?id=$course->id\">".
944 get_string("changepassword")."...</a>";
c9f6251e 945 $adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
e550e2d6 946 } else if ($CFG->changepassword) {
947 $admindata[]="<a href=\"$CFG->changepassword\">".get_string("changepassword")."...</a>";
c9f6251e 948 $adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
e550e2d6 949 }
5204d831 950 if ($CFG->allowunenroll) {
951 $admindata[]="<a href=\"unenrol.php?id=$course->id\">".get_string("unenrolme", "", $course->shortname)."...</a>";
3f125001 952 $adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
5204d831 953 }
13469b82 954 }
44dad735 955
f354106d 956 if (!empty($admindata)) {
957 print_side_block(get_string("administration"), "", $admindata, $adminicon, "", $width);
958 }
44dad735 959}
2b25f2a0 960
c2cb4545 961
962function make_categories_list(&$list, &$parents, $category=NULL, $path="") {
963/// Given an empty array, this function recursively travels the
964/// categories, building up a nice list for display. It also makes
965/// an array that list all the parents for each category.
966
967 if ($category) {
968 if ($path) {
969 $path = "$path / $category->name";
970 } else {
971 $path = "$category->name";
972 }
973 $list[$category->id] = $path;
974 } else {
975 $category->id = 0;
976 }
977
978 if ($categories = get_categories("$category->id")) { // Print all the children recursively
979 foreach ($categories as $cat) {
980 if (!empty($category->id)) {
3bd4de22 981 if (isset($parents[$category->id])) {
2832badf 982 $parents[$cat->id] = $parents[$category->id];
983 }
c2cb4545 984 $parents[$cat->id][] = $category->id;
985 }
e92fe848 986 make_categories_list($list, $parents, $cat, $path);
c2cb4545 987 }
988 }
989}
990
991
c2cb4545 992function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1) {
993/// Recursive function to print out all the categories in a nice format
994/// with or without courses included
995
996 if (!$displaylist) {
e92fe848 997 make_categories_list($displaylist, $parentslist);
c2cb4545 998 }
999
1000 if ($category) {
3af6e1db 1001 if ($category->visible or iscreator()) {
d2b6ba70 1002 print_category_info($category, $depth);
c2cb4545 1003 } else {
1004 return; // Don't bother printing children of invisible categories
1005 }
1006
1007 } else {
c2cb4545 1008 $category->id = "0";
1009 }
1010
1011 if ($categories = get_categories($category->id)) { // Print all the children recursively
1012 $countcats = count($categories);
1013 $count = 0;
1014 $first = true;
1015 $last = false;
1016 foreach ($categories as $cat) {
1017 $count++;
1018 if ($count == $countcats) {
1019 $last = true;
1020 }
1021 $up = $first ? false : true;
1022 $down = $last ? false : true;
1023 $first = false;
1024
1025 print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1);
1026 }
1027 }
c2cb4545 1028}
1029
1030
d2b6ba70 1031function print_category_info($category, $depth) {
1032/// Prints the category info in indented fashion
1033/// This function is only used by print_whole_category_list() above
c2cb4545 1034
1035 global $CFG;
b48f834c 1036 static $strallowguests, $strrequireskey, $strsummary;
c2cb4545 1037
b48f834c 1038 if (empty($strsummary)) {
1039 $strallowguests = get_string("allowguests");
1040 $strrequireskey = get_string("requireskey");
1041 $strsummary = get_string("summary");
1042 }
ba2e5d73 1043
d5f26b07 1044 $catlinkcss = $category->visible ? "" : " class=\"dimmed\" ";
1045
8ef9cb56 1046 if ($CFG->frontpage == FRONTPAGECOURSELIST) {
c9f6251e 1047 $catimage = "<img src=\"$CFG->pixpath/i/course.gif\" width=16 height=16 border=0>";
b48f834c 1048 } else {
1049 $catimage = "&nbsp";
8ef9cb56 1050 }
b48f834c 1051
1052 echo "\n\n<table border=0 cellpadding=3 cellspacing=0 width=\"100%\"><tr>";
d2b6ba70 1053
c2cb4545 1054 if ($CFG->frontpage == FRONTPAGECOURSELIST) {
b48f834c 1055 $courses = get_courses($category->id);
1056
1057 echo "<tr>";
1058
1059 if ($depth) {
1060 $indent = $depth*30;
1061 $rows = count($courses) + 1;
1062 echo "<td rowspan=\"$rows\" valign=\"top\" width=\"$indent\">";
1063 print_spacer(10, $indent);
1064 echo "</td>";
1065 }
1066
1067 echo "<td valign=\"top\">$catimage</td>";
cb29b020 1068 echo "<td valign=\"top\" width=\"100%\" class=\"categoryname\">";
b48f834c 1069 echo "<a $catlinkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
cb29b020 1070 echo "</td>";
1071 echo "<td class=\"categoryname\">&nbsp;</td>";
b48f834c 1072 echo "</tr>\n";
1073
1074 if ($courses) {
c2cb4545 1075 foreach ($courses as $course) {
1076 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
b48f834c 1077 echo "<tr><td valign=\"top\" width=\"30\">&nbsp;";
cb29b020 1078 echo "</td>\n<td valign=\"top\" width=\"100%\" class=\"coursename\">";
a6870f0c 1079 echo "<a $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
cb29b020 1080 echo "</td>\n<td align=\"right\" valign=\"top\" nowrap class=\"coursename\">";
c2cb4545 1081 if ($course->guest ) {
1082 echo "<a title=\"$strallowguests\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
9928b09e 1083 echo "<img hspace=1 alt=\"$strallowguests\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/guest.gif\"></a>";
ebe8ddc1 1084 } else {
c9f6251e 1085 echo "<img alt=\"\" height=16 width=18 border=0 src=\"$CFG->pixpath/spacer.gif\">";
0c656181 1086 }
c2cb4545 1087 if ($course->password) {
1088 echo "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
9928b09e 1089 echo "<img hspace=1 alt=\"$strrequireskey\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/key.gif\"></a>";
ebe8ddc1 1090 } else {
c9f6251e 1091 echo "<img alt=\"\" height=16 width=18 border=0 src=\"$CFG->pixpath/spacer.gif\">";
b48f834c 1092 }
1093 if ($course->summary) {
1094 link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo",
9928b09e 1095 "<img hspace=1 alt=\"$strsummary\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/info.gif\">",
b48f834c 1096 400, 500, $strsummary);
ebe8ddc1 1097 } else {
c9f6251e 1098 echo "<img alt=\"\" height=16 width=18 border=0 src=\"$CFG->pixpath/spacer.gif\">";
0c656181 1099 }
b48f834c 1100 echo "</td></tr>\n";
0c656181 1101 }
ba2e5d73 1102 }
d2b6ba70 1103 } else {
b48f834c 1104
1105 if ($depth) {
1106 $indent = $depth*20;
1107 echo "<td valign=\"top\" width=\"$indent\">";
1108 print_spacer(10, $indent);
1109 echo "</td>";
d2b6ba70 1110 }
b48f834c 1111
cb29b020 1112 echo "<td valign=\"top\" width=\"100%\" class=\"categoryname\">";
b48f834c 1113 echo "<a $catlinkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
cb29b020 1114 echo "</td>";
a0456978 1115 echo "<td valign=\"top\" class=\"categorynumber\">$category->coursecount</td></tr>";
c2cb4545 1116 }
b48f834c 1117 echo "\n</table>\n";
c2cb4545 1118}
1119
1120function print_courses_sideblock($category=0, $width="100%") {
f3120024 1121 global $CFG, $THEME, $USER;
c2cb4545 1122
1123 if (empty($THEME->custompix)) {
1124 $icon = "<img src=\"$CFG->wwwroot/pix/i/course.gif\"".
1125 " height=\"16\" width=\"16\" alt=\"".get_string("course")."\">";
1126 } else {
1127 $icon = "<img src=\"$CFG->wwwroot/theme/$CFG->theme/pix/i/course.gif\"".
1128 " height=\"16\" width=\"16\" alt=\"".get_string("course")."\">";
1129 }
1130
f3120024 1131 if (isset($USER->id) and !isadmin()) { // Just print My Courses
1132 if ($courses = get_my_courses($USER->id)) {
1133 foreach ($courses as $course) {
c81696e5 1134 if (!$course->category) {
1135 continue;
1136 }
d1d74247 1137 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
f3120024 1138 $moddata[]="<a $linkcss title=\"$course->shortname\" ".
1139 "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
1140 $modicon[]=$icon;
1141 }
5dc3d80e 1142 $fulllist = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
f3120024 1143 print_side_block( get_string("mycourses"), "", $moddata, $modicon, $fulllist, $width);
1144 return;
1145 }
1146 }
1147
c571f3fc 1148 $categories = get_categories("0"); // Parent = 0 ie top-level categories only
c2cb4545 1149 if (count($categories) > 1) { // Just print top level category links
1150 foreach ($categories as $category) {
1151 $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
d2b6ba70 1152 $moddata[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
c2cb4545 1153 $modicon[]=$icon;
0c656181 1154 }
b5333476 1155 $fulllist = "<p><a href=\"$CFG->wwwroot/course/\">".get_string("searchcourses")."</a>...";
c2cb4545 1156 } else { // Just print course names of single category
90c2ca2e 1157 $category = array_shift($categories);
d2b6ba70 1158 $courses = get_courses($category->id);
1159
c2cb4545 1160 if ($courses) {
1161 foreach ($courses as $course) {
1162 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
1163 $moddata[]="<a $linkcss title=\"$course->shortname\" ".
1164 "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
1165 $modicon[]=$icon;
1166 }
5dc3d80e 1167 $fulllist = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
c2cb4545 1168 } else {
1169 $moddata = array();
1170 $modicon = array();
1171 $fulllist = get_string("nocoursesyet");
0c656181 1172 }
ba2e5d73 1173 }
c2cb4545 1174
f3120024 1175 print_side_block( get_string("courses"), "", $moddata, $modicon, $fulllist, $width);
ba2e5d73 1176}
94361e02 1177
c2cb4545 1178
1179function print_courses($category, $width="100%") {
1180/// Category is 0 (for all courses) or an object
1181
1182 global $CFG, $THEME;
1183
1184 if (empty($category)) {
90c2ca2e 1185 $categories = get_categories(0); // Parent = 0 ie top-level categories only
1186 if (count($categories) == 1) {
1187 $category = array_shift($categories);
d2b6ba70 1188 $courses = get_courses($category->id);
90c2ca2e 1189 } else {
d2b6ba70 1190 $courses = get_courses("all");
90c2ca2e 1191 }
1192 unset($categories);
607809b3 1193 } else {
c2cb4545 1194 $categories = get_categories($category->id); // sub categories
d2b6ba70 1195 $courses = get_courses($category->id);
c2cb4545 1196 }
1197
c2cb4545 1198 if ($courses) {
1199 foreach ($courses as $course) {
1200 print_course($course, $width);
1201 echo "<br />\n";
1202 }
1203 } else {
1204 print_heading(get_string("nocoursesyet"));
1205 }
1206
1207}
1208
1209
1210function print_course($course, $width="100%") {
1211
1212 global $CFG, $THEME;
1213
1214 if (! $site = get_site()) {
1215 error("Could not find a site!");
1216 }
1217
1b6a4b1d 1218 print_simple_box_start("center", "$width", $THEME->cellcontent, 5, "coursebox");
c2cb4545 1219
22288704 1220 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
1221
c2cb4545 1222 echo "<table width=\"100%\">";
1223 echo "<tr valign=top>";
1b6a4b1d 1224 echo "<td valign=top width=\"50%\" class=\"courseboxinfo\">";
c2cb4545 1225 echo "<p><font size=3><b><a title=\"".get_string("entercourse")."\"
22288704 1226 $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a></b></font></p>";
c2cb4545 1227 if ($teachers = get_course_teachers($course->id)) {
1228 echo "<p><font size=\"1\">\n";
1229 foreach ($teachers as $teacher) {
1230 if ($teacher->authority > 0) {
1231 if (!$teacher->role) {
1232 $teacher->role = $course->teacher;
1233 }
2ac64806 1234 $fullname = fullname($teacher, isteacher($course->id)); // is the USER a teacher of that course
1235 echo "$teacher->role: <a href=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$fullname</a><br />";
c2cb4545 1236 }
1237 }
1238 echo "</font></p>";
1239 }
1240 if ($course->guest) {
1241 $strallowguests = get_string("allowguests");
1242 echo "<a title=\"$strallowguests\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
a9a070e0 1243 echo "<img vspace=4 alt=\"$strallowguests\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/guest.gif\"></a>&nbsp;&nbsp;";
c2cb4545 1244 }
1245 if ($course->password) {
1246 $strrequireskey = get_string("requireskey");
1247 echo "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
c9f6251e 1248 echo "<img vspace=4 alt=\"$strrequireskey\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/key.gif\"></a>";
c2cb4545 1249 }
1250
1251
1b6a4b1d 1252 echo "</td><td valign=top width=\"50%\" class=\"courseboxsummary\">";
0d0e550f 1253 echo "<p><font size=2>".filter_text(text_to_html($course->summary), $course->id)."</font></p>";
c2cb4545 1254 echo "</td></tr>";
1255 echo "</table>";
1256
1257 print_simple_box_end();
1258}
1259
1260
1261function print_my_moodle() {
1262/// Prints custom user information on the home page.
1263/// Over time this can include all sorts of information
1264
1265 global $USER, $CFG;
1266
1267 if (!isset($USER->id)) {
1268 error("It shouldn't be possible to see My Moodle without being logged in.");
1269 }
1270
1271 if ($courses = get_my_courses($USER->id)) {
1272 foreach ($courses as $course) {
c81696e5 1273 if (!$course->category) {
1274 continue;
1275 }
c2cb4545 1276 print_course($course, "100%");
1277 echo "<br />\n";
1278 }
38a10939 1279
7f989948 1280 if (count_records("course") > (count($courses) + 1) ) { // Some courses not being displayed
1281 echo "<table width=\"100%\"><tr><td align=\"center\">";
1282 print_course_search("", false, "short");
1283 echo "</td><td align=\"center\">";
1284 print_single_button("$CFG->wwwroot/course/index.php", NULL, get_string("fulllistofcourses"), "get");
1285 echo "</td></tr></table>\n";
1286 }
26330001 1287 } else {
1288 if (count_records("course_categories") > 1) {
cb29b020 1289 print_simple_box_start("center", "100%", "#FFFFFF", 5, "categorybox");
26330001 1290 print_whole_category_list();
1291 print_simple_box_end();
1292 } else {
1293 print_courses(0, "100%");
1294 }
607809b3 1295 }
2b8cef80 1296}
1297
11b0c469 1298
a8b56716 1299function print_course_search($value="", $return=false, $format="plain") {
38a10939 1300
1301 global $CFG;
1302
1303 $strsearchcourses= get_string("searchcourses");
1304
a8b56716 1305 if ($format == "plain") {
1306 $output = "<center><p align=\"center\" class=\"coursesearchbox\">";
1307 $output .= "<form name=\"coursesearch\" action=\"$CFG->wwwroot/course/search.php\" method=\"get\">";
1308 $output .= "<input type=\"text\" size=30 name=\"search\" value=\"$value\">";
1309 $output .= "<input type=\"submit\" value=\"$strsearchcourses\">";
1310 $output .= "</form></p></center>";
e4027ac9 1311 } else if ($format == "short") {
1312 $output = "<center><p align=\"center\" class=\"coursesearchbox\">";
1313 $output .= "<form name=\"coursesearch\" action=\"$CFG->wwwroot/course/search.php\" method=\"get\">";
1314 $output .= "<input type=\"text\" size=12 name=\"search\" value=\"$value\">";
1315 $output .= "<input type=\"submit\" value=\"$strsearchcourses\">";
1316 $output .= "</form></p></center>";
a8b56716 1317 } else if ($format == "navbar") {
1318 $output = "<table border=0 cellpadding=0 cellspacing=0><tr><td nowrap>";
1319 $output .= "<form name=\"coursesearch\" action=\"$CFG->wwwroot/course/search.php\" method=\"get\">";
1320 $output .= "<input type=\"text\" size=20 name=\"search\" value=\"$value\">";
1321 $output .= "<input type=\"submit\" value=\"$strsearchcourses\">";
a8b56716 1322 $output .= "</form>";
1323 $output .= "</td></tr></table>";
1324 }
1325
1326 if ($return) {
1327 return $output;
1328 }
1329 echo $output;
38a10939 1330}
11b0c469 1331
1332/// MODULE FUNCTIONS /////////////////////////////////////////////////////////////////
1333
1334function add_course_module($mod) {
11b0c469 1335
e5dfd0f3 1336 $mod->added = time();
11b0c469 1337
e5dfd0f3 1338 return insert_record("course_modules", $mod);
11b0c469 1339}
1340
7977cffd 1341function add_mod_to_section($mod, $beforemod=NULL) {
1342/// Given a full mod object with section and course already defined
1343/// If $before is specified, then this is an existing ID which we
1344/// will insert the new module before
1345///
1346/// Returns the course_sections ID where the mod is inserted
11b0c469 1347
9fa49e22 1348 if ($section = get_record("course_sections", "course", "$mod->course", "section", "$mod->section")) {
7977cffd 1349
1350 $section->sequence = trim($section->sequence);
1351
1352 if (empty($section->sequence)) {
11b0c469 1353 $newsequence = "$mod->coursemodule";
7977cffd 1354
1355 } else if ($beforemod) {
1356 $modarray = explode(",", $section->sequence);
1357
1358 if ($key = array_keys ($modarray, $beforemod->id)) {
1359 $insertarray = array($mod->id, $beforemod->id);
1360 array_splice($modarray, $key[0], 1, $insertarray);
1361 $newsequence = implode(",", $modarray);
1362
1363 } else { // Just tack it on the end anyway
1364 $newsequence = "$section->sequence,$mod->coursemodule";
1365 }
1366
1367 } else {
1368 $newsequence = "$section->sequence,$mod->coursemodule";
11b0c469 1369 }
7977cffd 1370
e5dfd0f3 1371 if (set_field("course_sections", "sequence", $newsequence, "id", $section->id)) {
1372 return $section->id; // Return course_sections ID that was used.
11b0c469 1373 } else {
e5dfd0f3 1374 return 0;
11b0c469 1375 }
1376
1377 } else { // Insert a new record
e5dfd0f3 1378 $section->course = $mod->course;
1379 $section->section = $mod->section;
1380 $section->summary = "";
1381 $section->sequence = $mod->coursemodule;
1382 return insert_record("course_sections", $section);
11b0c469 1383 }
1384}
1385
3d575e6f 1386function set_groupmode_for_module($id, $groupmode) {
1387 return set_field("course_modules", "groupmode", $groupmode, "id", $id);
1388}
1389
1acfbce5 1390function hide_course_module($mod) {
1391 return set_field("course_modules", "visible", 0, "id", $mod);
1392}
1393
1394function show_course_module($mod) {
1395 return set_field("course_modules", "visible", 1, "id", $mod);
1396}
1397
11b0c469 1398function delete_course_module($mod) {
1399 return set_field("course_modules", "deleted", 1, "id", $mod);
1400}
1401
1402function delete_mod_from_section($mod, $section) {
11b0c469 1403
e5dfd0f3 1404 if ($section = get_record("course_sections", "id", "$section") ) {
11b0c469 1405
e5dfd0f3 1406 $modarray = explode(",", $section->sequence);
11b0c469 1407
1408 if ($key = array_keys ($modarray, $mod)) {
1409 array_splice($modarray, $key[0], 1);
1410 $newsequence = implode(",", $modarray);
e5dfd0f3 1411 return set_field("course_sections", "sequence", $newsequence, "id", $section->id);
11b0c469 1412 } else {
1413 return false;
1414 }
1415
11b0c469 1416 }
7977cffd 1417 return false;
11b0c469 1418}
1419
12905134 1420function move_section($course, $section, $move) {
1421/// Moves a whole course section up and down within the course
1422
1423 if (!$move) {
1424 return true;
1425 }
1426
1427 $sectiondest = $section + $move;
1428
1429 if ($sectiondest > $course->numsections or $sectiondest < 1) {
1430 return false;
1431 }
1432
1433 if (!$sectionrecord = get_record("course_sections", "course", $course->id, "section", $section)) {
1434 return false;
1435 }
1436
1437 if (!$sectiondestrecord = get_record("course_sections", "course", $course->id, "section", $sectiondest)) {
1438 return false;
1439 }
1440
56e34ee4 1441 if (!set_field("course_sections", "section", $sectiondest, "id", $sectionrecord->id)) {
12905134 1442 return false;
1443 }
56e34ee4 1444 if (!set_field("course_sections", "section", $section, "id", $sectiondestrecord->id)) {
12905134 1445 return false;
1446 }
1447 return true;
1448}
1449
1450
7977cffd 1451function moveto_module($mod, $section, $beforemod=NULL) {
1452/// All parameters are objects
1453/// Move the module object $mod to the specified $section
1454/// If $beforemod exists then that is the module
1455/// before which $modid should be inserted
1456
1457/// Remove original module from original section
1458
1459 if (! delete_mod_from_section($mod->id, $mod->section)) {
1460 notify("Could not delete module from existing section");
1461 }
1462
1463/// Update module itself if necessary
1464
1465 if ($mod->section != $section->id) {
1466 $mod->section = $section->id;
1467
1468 if (!update_record("course_modules", $mod)) {
1469 return false;
1470 }
1471 }
1472
1473/// Add the module into the new section
1474
1475 $mod->course = $section->course;
1476 $mod->section = $section->section; // need relative reference
1477 $mod->coursemodule = $mod->id;
1478
1479 if (! add_mod_to_section($mod, $beforemod)) {
1480 return false;
1481 }
1482
1483 return true;
1484
1485}
1486
1487
11b0c469 1488
7c0f2984 1489function move_module($cm, $move) {
12905134 1490/// Moves an activity module up and down within the course
11b0c469 1491
1492 if (!$move) {
1493 return true;
1494 }
1495
11b0c469 1496 if (! $thissection = get_record("course_sections", "id", $cm->section)) {
1497 error("This course section doesn't exist");
1498 }
1499
1500 $mods = explode(",", $thissection->sequence);
1501
1502 $len = count($mods);
1503 $pos = array_keys($mods, $cm->id);
1504 $thepos = $pos[0];
1505
1506 if ($len == 0 || count($pos) == 0 ) {
1507 error("Very strange. Could not find the required module in this section.");
1508 }
1509
1510 if ($len == 1) {
1511 $first = true;
1512 $last = true;
1513 } else {
1514 $first = ($thepos == 0);
1515 $last = ($thepos == $len - 1);
1516 }
1517
1518 if ($move < 0) { // Moving the module up
1519
1520 if ($first) {
ad41694c 1521 if ($thissection->section == 0) { // First section, do nothing
11b0c469 1522 return true;
ad41694c 1523
11b0c469 1524 } else { // Push onto end of previous section
1525 $prevsectionnumber = $thissection->section - 1;
9fa49e22 1526 if (! $prevsection = get_record("course_sections", "course", "$thissection->course",
1527 "section", "$prevsectionnumber")) {
11b0c469 1528 error("Previous section ($prevsection->id) doesn't exist");
1529 }
1530
74666583 1531 if (!empty($prevsection->sequence)) {
11b0c469 1532 $newsequence = "$prevsection->sequence,$cm->id";
1533 } else {
1534 $newsequence = "$cm->id";
1535 }
1536
1537 if (! set_field("course_sections", "sequence", $newsequence, "id", $prevsection->id)) {
1538 error("Previous section could not be updated");
1539 }
1540
1541 if (! set_field("course_modules", "section", $prevsection->id, "id", $cm->id)) {
1542 error("Module could not be updated");
1543 }
1544
1545 array_splice($mods, 0, 1);
1546 $newsequence = implode(",", $mods);
1547 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1548 error("Module could not be updated");
1549 }
1550
1551 return true;
1552
1553 }
1554 } else { // move up within this section
1555 $swap = $mods[$thepos-1];
1556 $mods[$thepos-1] = $mods[$thepos];
1557 $mods[$thepos] = $swap;
1558
1559 $newsequence = implode(",", $mods);
1560 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1561 error("This section could not be updated");
1562 }
1563 return true;
1564 }
1565
1566 } else { // Moving the module down
1567
1568 if ($last) {
1569 $nextsectionnumber = $thissection->section + 1;
9fa49e22 1570 if ($nextsection = get_record("course_sections", "course", "$thissection->course",
1571 "section", "$nextsectionnumber")) {
11b0c469 1572
74666583 1573 if (!empty($nextsection->sequence)) {
11b0c469 1574 $newsequence = "$cm->id,$nextsection->sequence";
1575 } else {
1576 $newsequence = "$cm->id";
1577 }
1578
1579 if (! set_field("course_sections", "sequence", $newsequence, "id", $nextsection->id)) {
1580 error("Next section could not be updated");
1581 }
1582
1583 if (! set_field("course_modules", "section", $nextsection->id, "id", $cm->id)) {
1584 error("Module could not be updated");
1585 }
1586
1587 array_splice($mods, $thepos, 1);
1588 $newsequence = implode(",", $mods);
1589 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1590 error("This section could not be updated");
1591 }
1592 return true;
1593
1594 } else { // There is no next section, so just return
1595 return true;
1596
1597 }
1598 } else { // move down within this section
1599 $swap = $mods[$thepos+1];
1600 $mods[$thepos+1] = $mods[$thepos];
1601 $mods[$thepos] = $swap;
1602
1603 $newsequence = implode(",", $mods);
1604 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1605 error("This section could not be updated");
1606 }
1607 return true;
1608 }
1609 }
1610}
1611
3d575e6f 1612function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-1) {
dc0dc7d5 1613 global $CFG, $THEME;
94361e02 1614
3d575e6f 1615 static $str;
1616
1617 if (!isset($str)) {
1618 $str->delete = get_string("delete");
1619 $str->move = get_string("move");
1620 $str->moveup = get_string("moveup");
1621 $str->movedown = get_string("movedown");
1622 $str->moveright = get_string("moveright");
1623 $str->moveleft = get_string("moveleft");
1624 $str->update = get_string("update");
1625 $str->hide = get_string("hide");
1626 $str->show = get_string("show");
1627 $str->clicktochange = get_string("clicktochange");
1628 $str->groupsnone = get_string("groupsnone");
1629 $str->groupsseparate = get_string("groupsseparate");
1630 $str->groupsvisible = get_string("groupsvisible");
1acfbce5 1631 }
94361e02 1632
1633 if ($absolute) {
dc0dc7d5 1634 $path = "$CFG->wwwroot/course";
1635 } else {
1636 $path = ".";
1637 }
1638
1639 if (empty($THEME->custompix)) {
1640 $pixpath = "$path/../pix";
94361e02 1641 } else {
dc0dc7d5 1642 $pixpath = "$path/../theme/$CFG->theme/pix";
94361e02 1643 }
1acfbce5 1644
3d575e6f 1645 if ($mod->visible) {
1646 $hideshow = "<a title=\"$str->hide\" href=\"$path/mod.php?hide=$mod->id\"><img".
7977cffd 1647 " src=\"$pixpath/t/hide.gif\" hspace=2 height=11 width=11 border=0></a> ";
1acfbce5 1648 } else {
3d575e6f 1649 $hideshow = "<a title=\"$str->show\" href=\"$path/mod.php?show=$mod->id\"><img".
7977cffd 1650 " src=\"$pixpath/t/show.gif\" hspace=2 height=11 width=11 border=0></a> ";
1651 }
3d575e6f 1652 if ($mod->groupmode !== false) {
1653 if ($mod->groupmode == SEPARATEGROUPS) {
1654 $groupmode = "<a title=\"$str->groupsseparate ($str->clicktochange)\" ".
1655 " href=\"$path/mod.php?id=$mod->id&groupmode=0\"><img".
1656 " src=\"$pixpath/t/groups.gif\" hspace=2 height=11 width=11 border=0></a> ";
1657 } else if ($mod->groupmode == VISIBLEGROUPS) {
1658 $groupmode = "<a title=\"$str->groupsvisible ($str->clicktochange)\" ".
1659 " href=\"$path/mod.php?id=$mod->id&groupmode=1\"><img".
1660 " src=\"$pixpath/t/groupv.gif\" hspace=2 height=11 width=11 border=0></a> ";
1661 } else {
1662 $groupmode = "<a title=\"$str->groupsnone ($str->clicktochange)\" ".
1663 " href=\"$path/mod.php?id=$mod->id&groupmode=2\"><img".
1664 " src=\"$pixpath/t/groupn.gif\" hspace=2 height=11 width=11 border=0></a> ";
1665 }
1666 } else {
1667 $groupmode = "";
1668 }
7977cffd 1669
1670 if ($moveselect) {
3d575e6f 1671 $move = "<a title=\"$str->move\" href=\"$path/mod.php?copy=$mod->id\"><img".
bf1241ad 1672 " src=\"$pixpath/t/move.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\"></a>";
493486c4 1673 } else {
3d575e6f 1674 $move = "<a title=\"$str->moveup\" href=\"$path/mod.php?id=$mod->id&move=-1\"><img".
bf1241ad 1675 " src=\"$pixpath/t/up.gif\" hspace=\"2\" height=11 width=11 border=0></a>".
3d575e6f 1676 "<a title=\"$str->movedown\" href=\"$path/mod.php?id=$mod->id&move=1\"><img".
bf1241ad 1677 " src=\"$pixpath/t/down.gif\" hspace=\"2\" height=11 width=11 border=0></a>";
7977cffd 1678 }
1679
aac94fd0 1680 $leftright = "";
1681 if ($indent > 0) {
3d575e6f 1682 $leftright .= "<a title=\"$str->moveleft\" href=\"$path/mod.php?id=$mod->id&indent=-1\"><img".
bf1241ad 1683 " src=\"$pixpath/t/left.gif\" hspace=\"2\" height=11 width=11 border=0></a>";
aac94fd0 1684 }
1685 if ($indent >= 0) {
3d575e6f 1686 $leftright .= "<a title=\"$str->moveright\" href=\"$path/mod.php?id=$mod->id&indent=1\"><img".
bf1241ad 1687 " src=\"$pixpath/t/right.gif\" hspace=\"2\" height=11 width=11 border=0></a>";
aac94fd0 1688 }
1689
bf1241ad 1690 return "$leftright$move".
3d575e6f 1691 "<a title=\"$str->update\" href=\"$path/mod.php?update=$mod->id\"><img".
bf1241ad 1692 " src=\"$pixpath/t/edit.gif\" hspace=\"2\" height=11 width=11 border=0></a>".
3d575e6f 1693 "<a title=\"$str->delete\" href=\"$path/mod.php?delete=$mod->id\"><img".
1694 " src=\"$pixpath/t/delete.gif\" hspace=\"2\" height=11 width=11 border=0></a>$hideshow$groupmode";
90845098 1695}
1696
f9903ed0 1697?>