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