Turning off "usexml" for forum/mod/view.php
[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
814 if (empty($USER)) {
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 }
963 }
7977cffd 964 if ($ismoving) {
1c919752 965 echo '<tr><td><a title="'.$strmovefull.'"'.
966 ' href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'">'.
967 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" '.
968 ' alt="'.$strmovehere.'" border="0" /></a></td></tr>
969 ';
7977cffd 970 }
c9f6251e 971 echo "</table>\n\n";
a7ad3ea6 972}
973
5867bfb5 974
cb57e6f4 975function print_section_add_menus($course, $section, $modnames, $vertical=false, $return=false) {
e0161bff 976// Prints the menus to add activities and resources
977
2e2a6351 978 global $CFG;
6da4b261 979 static $straddactivity, $stractivities, $straddresource, $resources;
e0161bff 980
981 if (!isset($straddactivity)) {
982 $straddactivity = get_string('addactivity');
983 $straddresource = get_string('addresource');
6da4b261 984
985 /// Standard resource types
986 require_once("$CFG->dirroot/mod/resource/lib.php");
987 $resourceraw = resource_get_resource_types();
988
989 foreach ($resourceraw as $type => $name) {
839f2456 990 $resources["resource&amp;type=$type"] = $name;
e0161bff 991 }
e0161bff 992 $resources['label'] = get_string('resourcetypelabel', 'resource');
993 }
994
cb57e6f4 995 $output = '';
996
997 $output .= '<div align="right"><table align="right"><tr><td>';
839f2456 998 $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&amp;add=",
6da4b261 999 $resources, "ressection$section", "", $straddresource, 'resource/types', $straddresource, true);
cb57e6f4 1000 $output .= '</td>';
1001
1002 if ($vertical) {
1003 $output .= '</tr><tr>';
1004 }
1005
1006 $output .= '<td>';
839f2456 1007 $output .= popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&amp;add=",
6da4b261 1008 $modnames, "section$section", "", $straddactivity, 'mods', $straddactivity, true);
cb57e6f4 1009 $output .= '</td></tr></table>';
1010 $output .= '</div>';
1011
1012 if ($return) {
1013 return $output;
1014 } else {
1015 echo $output;
1016 }
e0161bff 1017}
1018
5867bfb5 1019function rebuild_course_cache($courseid=0) {
1020// Rebuilds the cached list of course activities stored in the database
1021// If a courseid is not specified, then all are rebuilt
1022
1023 if ($courseid) {
1024 $select = "id = '$courseid'";
1025 } else {
1026 $select = "";
1027 }
1028
1029 if ($courses = get_records_select("course", $select)) {
1030 foreach ($courses as $course) {
1031 $modinfo = serialize(get_array_of_activities($course->id));
1032 if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
1033 notify("Could not cache module information for course '$course->fullname'!");
1034 }
1035 }
1036 }
1037}
1038
1039
7541bc3e 1040function print_heading_block($heading, $width="100%", $class="headingblock") {
5e367a2d 1041 global $THEME;
1042
7541bc3e 1043 echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
1044 echo "<tr><td bgcolor=\"$THEME->cellheading\" class=\"$class\">";
5e367a2d 1045 echo stripslashes($heading);
1046 echo "</td></tr></table>";
5e367a2d 1047}
1048
c2cb4545 1049
1050function make_categories_list(&$list, &$parents, $category=NULL, $path="") {
89adb174 1051/// Given an empty array, this function recursively travels the
c2cb4545 1052/// categories, building up a nice list for display. It also makes
1053/// an array that list all the parents for each category.
1054
1055 if ($category) {
1056 if ($path) {
1057 $path = "$path / $category->name";
1058 } else {
1059 $path = "$category->name";
1060 }
1061 $list[$category->id] = $path;
1062 } else {
1063 $category->id = 0;
1064 }
1065
1066 if ($categories = get_categories("$category->id")) { // Print all the children recursively
1067 foreach ($categories as $cat) {
1068 if (!empty($category->id)) {
3bd4de22 1069 if (isset($parents[$category->id])) {
2832badf 1070 $parents[$cat->id] = $parents[$category->id];
1071 }
c2cb4545 1072 $parents[$cat->id][] = $category->id;
1073 }
89adb174 1074 make_categories_list($list, $parents, $cat, $path);
c2cb4545 1075 }
1076 }
1077}
1078
1079
c2cb4545 1080function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1) {
89adb174 1081/// Recursive function to print out all the categories in a nice format
c2cb4545 1082/// with or without courses included
9ff5310a 1083 global $CFG;
1084 if (isset($CFG->max_category_depth)&&($depth >= $CFG->max_category_depth)) {
1085 return;
1086 }
c2cb4545 1087
1088 if (!$displaylist) {
e92fe848 1089 make_categories_list($displaylist, $parentslist);
c2cb4545 1090 }
1091
1092 if ($category) {
3af6e1db 1093 if ($category->visible or iscreator()) {
d2b6ba70 1094 print_category_info($category, $depth);
c2cb4545 1095 } else {
1096 return; // Don't bother printing children of invisible categories
1097 }
89adb174 1098
c2cb4545 1099 } else {
c2cb4545 1100 $category->id = "0";
1101 }
1102
1103 if ($categories = get_categories($category->id)) { // Print all the children recursively
1104 $countcats = count($categories);
1105 $count = 0;
1106 $first = true;
1107 $last = false;
1108 foreach ($categories as $cat) {
1109 $count++;
1110 if ($count == $countcats) {
1111 $last = true;
1112 }
1113 $up = $first ? false : true;
1114 $down = $last ? false : true;
1115 $first = false;
1116
89adb174 1117 print_whole_category_list($cat, $displaylist, $parentslist, $depth + 1);
c2cb4545 1118 }
1119 }
c2cb4545 1120}
1121
1122
d2b6ba70 1123function print_category_info($category, $depth) {
1124/// Prints the category info in indented fashion
1125/// This function is only used by print_whole_category_list() above
c2cb4545 1126
1127 global $CFG;
b48f834c 1128 static $strallowguests, $strrequireskey, $strsummary;
c2cb4545 1129
b48f834c 1130 if (empty($strsummary)) {
1131 $strallowguests = get_string("allowguests");
1132 $strrequireskey = get_string("requireskey");
1133 $strsummary = get_string("summary");
1134 }
ba2e5d73 1135
d5f26b07 1136 $catlinkcss = $category->visible ? "" : " class=\"dimmed\" ";
1137
8ef9cb56 1138 if ($CFG->frontpage == FRONTPAGECOURSELIST) {
839f2456 1139 $catimage = '<img src="'.$CFG->pixpath.'/i/course.gif" width="16" height="16" border="0" alt="" />';
b48f834c 1140 } else {
1141 $catimage = "&nbsp";
8ef9cb56 1142 }
b48f834c 1143
1c919752 1144 echo "\n\n".'<table border="0" cellpadding="3" cellspacing="0" width="100%"><tr>';
d2b6ba70 1145
c2cb4545 1146 if ($CFG->frontpage == FRONTPAGECOURSELIST) {
b48f834c 1147 $courses = get_courses($category->id);
1148
1149 echo "<tr>";
1150
1151 if ($depth) {
1152 $indent = $depth*30;
1153 $rows = count($courses) + 1;
1c919752 1154 echo '<td rowspan="'.$rows.'" valign="top" width="'.$indent.'">';
b48f834c 1155 print_spacer(10, $indent);
1156 echo "</td>";
1157 }
89adb174 1158
b48f834c 1159 echo "<td valign=\"top\">$catimage</td>";
cb29b020 1160 echo "<td valign=\"top\" width=\"100%\" class=\"categoryname\">";
b48f834c 1161 echo "<a $catlinkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
cb29b020 1162 echo "</td>";
1163 echo "<td class=\"categoryname\">&nbsp;</td>";
b48f834c 1164 echo "</tr>\n";
1165
9ff5310a 1166 if ($courses && !(isset($CFG->max_category_depth)&&($depth>=$CFG->max_category_depth-1))) {
c2cb4545 1167 foreach ($courses as $course) {
1168 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
b48f834c 1169 echo "<tr><td valign=\"top\" width=\"30\">&nbsp;";
cb29b020 1170 echo "</td>\n<td valign=\"top\" width=\"100%\" class=\"coursename\">";
a6870f0c 1171 echo "<a $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
24f2b65a 1172 echo "</td>\n<td align=\"right\" valign=\"top\" nowrap=\"nowrap\" class=\"coursename\">";
c2cb4545 1173 if ($course->guest ) {
1174 echo "<a title=\"$strallowguests\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
26686b7a 1175 echo "<img hspace=\"1\" alt=\"$strallowguests\" height=\"16\" width=\"16\" border=\"0\" src=\"$CFG->pixpath/i/guest.gif\" /></a>";
ebe8ddc1 1176 } else {
26686b7a 1177 echo "<img alt=\"\" height=\"16\" width=\"18\" border=\"0\" src=\"$CFG->pixpath/spacer.gif\" />";
0c656181 1178 }
c2cb4545 1179 if ($course->password) {
1180 echo "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
26686b7a 1181 echo "<img hspace=\"1\" alt=\"$strrequireskey\" height=\"16\" width=\"16\" border=\"0\" src=\"$CFG->pixpath/i/key.gif\" /></a>";
ebe8ddc1 1182 } else {
26686b7a 1183 echo "<img alt=\"\" height=\"16\" width=\"18\" border=\"0\" src=\"$CFG->pixpath/spacer.gif\" />";
b48f834c 1184 }
1185 if ($course->summary) {
89adb174 1186 link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo",
26686b7a 1187 "<img hspace=\"1\" alt=\"$strsummary\" height=\"16\" width=\"16\" border=\"0\" src=\"$CFG->pixpath/i/info.gif\" />",
b48f834c 1188 400, 500, $strsummary);
ebe8ddc1 1189 } else {
26686b7a 1190 echo "<img alt=\"\" height=\"16\" width=\"18\" border=\"0\" src=\"$CFG->pixpath/spacer.gif\" />";
0c656181 1191 }
b48f834c 1192 echo "</td></tr>\n";
0c656181 1193 }
ba2e5d73 1194 }
d2b6ba70 1195 } else {
b48f834c 1196
1197 if ($depth) {
1198 $indent = $depth*20;
1199 echo "<td valign=\"top\" width=\"$indent\">";
1200 print_spacer(10, $indent);
1201 echo "</td>";
d2b6ba70 1202 }
89adb174 1203
cb29b020 1204 echo "<td valign=\"top\" width=\"100%\" class=\"categoryname\">";
b48f834c 1205 echo "<a $catlinkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
cb29b020 1206 echo "</td>";
a0456978 1207 echo "<td valign=\"top\" class=\"categorynumber\">$category->coursecount</td></tr>";
c2cb4545 1208 }
b48f834c 1209 echo "\n</table>\n";
c2cb4545 1210}
1211
c2cb4545 1212
c2cb4545 1213function print_courses($category, $width="100%") {
1214/// Category is 0 (for all courses) or an object
1215
1216 global $CFG, $THEME;
1217
1218 if (empty($category)) {
90c2ca2e 1219 $categories = get_categories(0); // Parent = 0 ie top-level categories only
1220 if (count($categories) == 1) {
1221 $category = array_shift($categories);
d2b6ba70 1222 $courses = get_courses($category->id);
90c2ca2e 1223 } else {
d2b6ba70 1224 $courses = get_courses("all");
90c2ca2e 1225 }
1226 unset($categories);
607809b3 1227 } else {
c2cb4545 1228 $categories = get_categories($category->id); // sub categories
d2b6ba70 1229 $courses = get_courses($category->id);
c2cb4545 1230 }
1231
c2cb4545 1232 if ($courses) {
1233 foreach ($courses as $course) {
1234 print_course($course, $width);
1235 echo "<br />\n";
1236 }
1237 } else {
1238 print_heading(get_string("nocoursesyet"));
1239 }
1240
1241}
1242
1243
1244function print_course($course, $width="100%") {
1245
1246 global $CFG, $THEME;
1247
146bbb8f 1248 static $enrol;
1249
1250 if (empty($enrol)) {
1251 require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
1252 $enrol = new enrolment_plugin;
1253 }
1254
1b6a4b1d 1255 print_simple_box_start("center", "$width", $THEME->cellcontent, 5, "coursebox");
c2cb4545 1256
22288704 1257 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
1258
c2cb4545 1259 echo "<table width=\"100%\">";
e5e81e78 1260 echo '<tr valign="top">';
1261 echo '<td valign="top" width="50%" class="courseboxinfo">';
1262 echo '<p><font size="3"><b><a title="'.get_string('entercourse').'"'.
1263 $linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
1264 $course->fullname.'</a></b></font></p>';
c2cb4545 1265 if ($teachers = get_course_teachers($course->id)) {
1266 echo "<p><font size=\"1\">\n";
1267 foreach ($teachers as $teacher) {
1268 if ($teacher->authority > 0) {
1269 if (!$teacher->role) {
1270 $teacher->role = $course->teacher;
1271 }
2ac64806 1272 $fullname = fullname($teacher, isteacher($course->id)); // is the USER a teacher of that course
8bd84b4d 1273 echo $teacher->role.': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.
1274 '&amp;course='.SITEID.'">'.$fullname.'</a><br />';
c2cb4545 1275 }
1276 }
1277 echo "</font></p>";
1278 }
c2cb4545 1279
146bbb8f 1280 echo $enrol->get_access_icons($course);
c2cb4545 1281
e5e81e78 1282 echo '</td><td valign="top" width="50%" class="courseboxsummary">';
1283 echo '<p><font size="2">'.filter_text(text_to_html($course->summary), $course->id).'</font></p>';
c2cb4545 1284 echo "</td></tr>";
1285 echo "</table>";
1286
1287 print_simple_box_end();
1288}
1289
1290
1291function print_my_moodle() {
1292/// Prints custom user information on the home page.
1293/// Over time this can include all sorts of information
1294
1295 global $USER, $CFG;
1296
1297 if (!isset($USER->id)) {
1298 error("It shouldn't be possible to see My Moodle without being logged in.");
1299 }
1300
1301 if ($courses = get_my_courses($USER->id)) {
1302 foreach ($courses as $course) {
c81696e5 1303 if (!$course->category) {
1304 continue;
1305 }
c2cb4545 1306 print_course($course, "100%");
1307 echo "<br />\n";
1308 }
38a10939 1309
7f989948 1310 if (count_records("course") > (count($courses) + 1) ) { // Some courses not being displayed
1311 echo "<table width=\"100%\"><tr><td align=\"center\">";
1312 print_course_search("", false, "short");
1313 echo "</td><td align=\"center\">";
1314 print_single_button("$CFG->wwwroot/course/index.php", NULL, get_string("fulllistofcourses"), "get");
1315 echo "</td></tr></table>\n";
1316 }
26330001 1317 } else {
1318 if (count_records("course_categories") > 1) {
cb29b020 1319 print_simple_box_start("center", "100%", "#FFFFFF", 5, "categorybox");
26330001 1320 print_whole_category_list();
1321 print_simple_box_end();
1322 } else {
1323 print_courses(0, "100%");
1324 }
607809b3 1325 }
2b8cef80 1326}
1327
11b0c469 1328
a8b56716 1329function print_course_search($value="", $return=false, $format="plain") {
38a10939 1330
1331 global $CFG;
1332
1333 $strsearchcourses= get_string("searchcourses");
1334
1c919752 1335 if ($format == 'plain') {
1336 $output = '<center><p align="center" class="coursesearchbox">';
1337 $output .= '<form name="coursesearch" action="'.$CFG->wwwroot.'/course/search.php" method="get">';
1338 $output .= '<input type="text" size="30" name="search" value="'.$value.'" />';
1339 $output .= '<input type="submit" value="'.$strsearchcourses.'" />';
1340 $output .= '</form></p></center>';
1341 } else if ($format == 'short') {
1342 $output = '<center><p align="center" class="coursesearchbox">';
1343 $output .= '<form name="coursesearch" action="'.$CFG->wwwroot.'/course/search.php" method="get">';
1344 $output .= '<input type="text" size="12" name="search" value="'.$value.'" />';
1345 $output .= '<input type="submit" value="'.$strsearchcourses.'" />';
1346 $output .= '</form></p></center>';
1347 } else if ($format == 'navbar') {
1348 $output = '<table border="0" cellpadding="0" cellspacing="0"><tr><td nowrap="nowrap">';
1349 $output .= '<form name="coursesearch" action="'.$CFG->wwwroot.'/course/search.php" method="get">';
1350 $output .= '<input type="text" size="20" name="search" value="'.$value.'" />';
1351 $output .= '<input type="submit" value="'.$strsearchcourses.'" />';
1352 $output .= '</form>';
1353 $output .= '</td></tr></table>';
a8b56716 1354 }
1355
1356 if ($return) {
1357 return $output;
1358 }
1359 echo $output;
38a10939 1360}
11b0c469 1361
1362/// MODULE FUNCTIONS /////////////////////////////////////////////////////////////////
1363
1364function add_course_module($mod) {
11b0c469 1365
e5dfd0f3 1366 $mod->added = time();
53f4ad2c 1367 unset($mod->id);
11b0c469 1368
e5dfd0f3 1369 return insert_record("course_modules", $mod);
11b0c469 1370}
1371
7977cffd 1372function add_mod_to_section($mod, $beforemod=NULL) {
1373/// Given a full mod object with section and course already defined
1374/// If $before is specified, then this is an existing ID which we
1375/// will insert the new module before
1376///
1377/// Returns the course_sections ID where the mod is inserted
11b0c469 1378
9fa49e22 1379 if ($section = get_record("course_sections", "course", "$mod->course", "section", "$mod->section")) {
7977cffd 1380
1381 $section->sequence = trim($section->sequence);
1382
1383 if (empty($section->sequence)) {
11b0c469 1384 $newsequence = "$mod->coursemodule";
7977cffd 1385
1386 } else if ($beforemod) {
1387 $modarray = explode(",", $section->sequence);
1388
1389 if ($key = array_keys ($modarray, $beforemod->id)) {
1390 $insertarray = array($mod->id, $beforemod->id);
1391 array_splice($modarray, $key[0], 1, $insertarray);
1392 $newsequence = implode(",", $modarray);
1393
1394 } else { // Just tack it on the end anyway
1395 $newsequence = "$section->sequence,$mod->coursemodule";
1396 }
1397
1398 } else {
1399 $newsequence = "$section->sequence,$mod->coursemodule";
11b0c469 1400 }
89adb174 1401
e5dfd0f3 1402 if (set_field("course_sections", "sequence", $newsequence, "id", $section->id)) {
1403 return $section->id; // Return course_sections ID that was used.
11b0c469 1404 } else {
e5dfd0f3 1405 return 0;
11b0c469 1406 }
89adb174 1407
11b0c469 1408 } else { // Insert a new record
e5dfd0f3 1409 $section->course = $mod->course;
1410 $section->section = $mod->section;
1411 $section->summary = "";
1412 $section->sequence = $mod->coursemodule;
1413 return insert_record("course_sections", $section);
11b0c469 1414 }
1415}
1416
3d575e6f 1417function set_groupmode_for_module($id, $groupmode) {
1418 return set_field("course_modules", "groupmode", $groupmode, "id", $id);
1419}
1420
1acfbce5 1421function hide_course_module($mod) {
dcd338ff 1422 $cm = get_record('course_modules', 'id', $mod);
1423 $modulename = get_field('modules', 'name', 'id', $cm->module);
1424 if ($events = get_records_select('event', "instance = '$cm->instance' AND modulename = '$modulename'")) {
1425 foreach($events as $event) {
1426 hide_event($event);
1427 }
1428 }
1acfbce5 1429 return set_field("course_modules", "visible", 0, "id", $mod);
1430}
1431
1432function show_course_module($mod) {
dcd338ff 1433 $cm = get_record('course_modules', 'id', $mod);
1434 $modulename = get_field('modules', 'name', 'id', $cm->module);
1435 if ($events = get_records_select('event', "instance = '$cm->instance' AND modulename = '$modulename'")) {
1436 foreach($events as $event) {
1437 show_event($event);
1438 }
1439 }
1acfbce5 1440 return set_field("course_modules", "visible", 1, "id", $mod);
1441}
1442
11b0c469 1443function delete_course_module($mod) {
1444 return set_field("course_modules", "deleted", 1, "id", $mod);
1445}
1446
1447function delete_mod_from_section($mod, $section) {
11b0c469 1448
e5dfd0f3 1449 if ($section = get_record("course_sections", "id", "$section") ) {
11b0c469 1450
e5dfd0f3 1451 $modarray = explode(",", $section->sequence);
11b0c469 1452
1453 if ($key = array_keys ($modarray, $mod)) {
1454 array_splice($modarray, $key[0], 1);
1455 $newsequence = implode(",", $modarray);
e5dfd0f3 1456 return set_field("course_sections", "sequence", $newsequence, "id", $section->id);
11b0c469 1457 } else {
1458 return false;
1459 }
89adb174 1460
11b0c469 1461 }
7977cffd 1462 return false;
11b0c469 1463}
1464
12905134 1465function move_section($course, $section, $move) {
1466/// Moves a whole course section up and down within the course
1467
1468 if (!$move) {
1469 return true;
1470 }
1471
1472 $sectiondest = $section + $move;
1473
1474 if ($sectiondest > $course->numsections or $sectiondest < 1) {
1475 return false;
1476 }
1477
1478 if (!$sectionrecord = get_record("course_sections", "course", $course->id, "section", $section)) {
1479 return false;
1480 }
1481
1482 if (!$sectiondestrecord = get_record("course_sections", "course", $course->id, "section", $sectiondest)) {
1483 return false;
1484 }
1485
56e34ee4 1486 if (!set_field("course_sections", "section", $sectiondest, "id", $sectionrecord->id)) {
12905134 1487 return false;
1488 }
56e34ee4 1489 if (!set_field("course_sections", "section", $section, "id", $sectiondestrecord->id)) {
12905134 1490 return false;
1491 }
1492 return true;
1493}
1494
1495
7977cffd 1496function moveto_module($mod, $section, $beforemod=NULL) {
1497/// All parameters are objects
1498/// Move the module object $mod to the specified $section
1499/// If $beforemod exists then that is the module
1500/// before which $modid should be inserted
1501
1502/// Remove original module from original section
1503
1504 if (! delete_mod_from_section($mod->id, $mod->section)) {
1505 notify("Could not delete module from existing section");
1506 }
1507
1508/// Update module itself if necessary
1509
1510 if ($mod->section != $section->id) {
89adb174 1511 $mod->section = $section->id;
7977cffd 1512
1513 if (!update_record("course_modules", $mod)) {
1514 return false;
1515 }
1516 }
1517
1518/// Add the module into the new section
1519
1520 $mod->course = $section->course;
1521 $mod->section = $section->section; // need relative reference
1522 $mod->coursemodule = $mod->id;
1523
1524 if (! add_mod_to_section($mod, $beforemod)) {
1525 return false;
1526 }
1527
1528 return true;
1529
1530}
1531
1532
11b0c469 1533
7c0f2984 1534function move_module($cm, $move) {
12905134 1535/// Moves an activity module up and down within the course
11b0c469 1536
1537 if (!$move) {
1538 return true;
1539 }
1540
11b0c469 1541 if (! $thissection = get_record("course_sections", "id", $cm->section)) {
1542 error("This course section doesn't exist");
1543 }
1544
1545 $mods = explode(",", $thissection->sequence);
1546
1547 $len = count($mods);
1548 $pos = array_keys($mods, $cm->id);
1549 $thepos = $pos[0];
1550
1551 if ($len == 0 || count($pos) == 0 ) {
1552 error("Very strange. Could not find the required module in this section.");
1553 }
1554
1555 if ($len == 1) {
1556 $first = true;
1557 $last = true;
1558 } else {
1559 $first = ($thepos == 0);
1560 $last = ($thepos == $len - 1);
1561 }
1562
1563 if ($move < 0) { // Moving the module up
1564
1565 if ($first) {
ad41694c 1566 if ($thissection->section == 0) { // First section, do nothing
11b0c469 1567 return true;
ad41694c 1568
11b0c469 1569 } else { // Push onto end of previous section
1570 $prevsectionnumber = $thissection->section - 1;
89adb174 1571 if (! $prevsection = get_record("course_sections", "course", "$thissection->course",
9fa49e22 1572 "section", "$prevsectionnumber")) {
11b0c469 1573 error("Previous section ($prevsection->id) doesn't exist");
1574 }
1575
74666583 1576 if (!empty($prevsection->sequence)) {
11b0c469 1577 $newsequence = "$prevsection->sequence,$cm->id";
1578 } else {
1579 $newsequence = "$cm->id";
1580 }
1581
1582 if (! set_field("course_sections", "sequence", $newsequence, "id", $prevsection->id)) {
1583 error("Previous section could not be updated");
1584 }
1585
1586 if (! set_field("course_modules", "section", $prevsection->id, "id", $cm->id)) {
1587 error("Module could not be updated");
1588 }
1589
1590 array_splice($mods, 0, 1);
1591 $newsequence = implode(",", $mods);
1592 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1593 error("Module could not be updated");
1594 }
1595
1596 return true;
1597
1598 }
1599 } else { // move up within this section
1600 $swap = $mods[$thepos-1];
1601 $mods[$thepos-1] = $mods[$thepos];
1602 $mods[$thepos] = $swap;
89adb174 1603
11b0c469 1604 $newsequence = implode(",", $mods);
1605 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1606 error("This section could not be updated");
1607 }
1608 return true;
1609 }
1610
1611 } else { // Moving the module down
1612
1613 if ($last) {
1614 $nextsectionnumber = $thissection->section + 1;
89adb174 1615 if ($nextsection = get_record("course_sections", "course", "$thissection->course",
9fa49e22 1616 "section", "$nextsectionnumber")) {
11b0c469 1617
74666583 1618 if (!empty($nextsection->sequence)) {
11b0c469 1619 $newsequence = "$cm->id,$nextsection->sequence";
1620 } else {
1621 $newsequence = "$cm->id";
1622 }
1623
1624 if (! set_field("course_sections", "sequence", $newsequence, "id", $nextsection->id)) {
1625 error("Next section could not be updated");
1626 }
1627
1628 if (! set_field("course_modules", "section", $nextsection->id, "id", $cm->id)) {
1629 error("Module could not be updated");
1630 }
1631
1632 array_splice($mods, $thepos, 1);
1633 $newsequence = implode(",", $mods);
1634 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1635 error("This section could not be updated");
1636 }
1637 return true;
1638
1639 } else { // There is no next section, so just return
1640 return true;
1641
1642 }
1643 } else { // move down within this section
1644 $swap = $mods[$thepos+1];
1645 $mods[$thepos+1] = $mods[$thepos];
1646 $mods[$thepos] = $swap;
89adb174 1647
11b0c469 1648 $newsequence = implode(",", $mods);
1649 if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
1650 error("This section could not be updated");
1651 }
1652 return true;
1653 }
1654 }
1655}
1656
3d575e6f 1657function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-1) {
dc0dc7d5 1658 global $CFG, $THEME;
94361e02 1659
3d575e6f 1660 static $str;
1661
1662 if (!isset($str)) {
1663 $str->delete = get_string("delete");
1664 $str->move = get_string("move");
1665 $str->moveup = get_string("moveup");
1666 $str->movedown = get_string("movedown");
1667 $str->moveright = get_string("moveright");
1668 $str->moveleft = get_string("moveleft");
1669 $str->update = get_string("update");
d33a2a6f 1670 $str->duplicate = get_string("duplicate");
3d575e6f 1671 $str->hide = get_string("hide");
1672 $str->show = get_string("show");
1673 $str->clicktochange = get_string("clicktochange");
32d03b7b 1674 $str->forcedmode = get_string("forcedmode");
3d575e6f 1675 $str->groupsnone = get_string("groupsnone");
1676 $str->groupsseparate = get_string("groupsseparate");
1677 $str->groupsvisible = get_string("groupsvisible");
1acfbce5 1678 }
94361e02 1679
1680 if ($absolute) {
dc0dc7d5 1681 $path = "$CFG->wwwroot/course";
1682 } else {
1683 $path = ".";
1684 }
1685
1686 if (empty($THEME->custompix)) {
1687 $pixpath = "$path/../pix";
94361e02 1688 } else {
dc0dc7d5 1689 $pixpath = "$path/../theme/$CFG->theme/pix";
94361e02 1690 }
1acfbce5 1691
3d575e6f 1692 if ($mod->visible) {
1693 $hideshow = "<a title=\"$str->hide\" href=\"$path/mod.php?hide=$mod->id\"><img".
839f2456 1694 " src=\"$pixpath/t/hide.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"$str->hide\" /></a> ";
1acfbce5 1695 } else {
3d575e6f 1696 $hideshow = "<a title=\"$str->show\" href=\"$path/mod.php?show=$mod->id\"><img".
dbcd54b7 1697 " src=\"$pixpath/t/show.gif\" hspace=\"2\" height=\"11\" width=\"11\" ".
839f2456 1698 "border=\"0\" alt=\"$str->show\" /></a> ";
7977cffd 1699 }
3d575e6f 1700 if ($mod->groupmode !== false) {
1701 if ($mod->groupmode == SEPARATEGROUPS) {
32d03b7b 1702 $grouptitle = $str->groupsseparate;
1703 $groupimage = "$pixpath/t/groups.gif";
839f2456 1704 $grouplink = "$path/mod.php?id=$mod->id&amp;groupmode=0";
3d575e6f 1705 } else if ($mod->groupmode == VISIBLEGROUPS) {
32d03b7b 1706 $grouptitle = $str->groupsvisible;
1707 $groupimage = "$pixpath/t/groupv.gif";
839f2456 1708 $grouplink = "$path/mod.php?id=$mod->id&amp;groupmode=1";
32d03b7b 1709 } else {
1710 $grouptitle = $str->groupsnone;
1711 $groupimage = "$pixpath/t/groupn.gif";
839f2456 1712 $grouplink = "$path/mod.php?id=$mod->id&amp;groupmode=2";
32d03b7b 1713 }
1714 if ($mod->groupmodelink) {
1715 $groupmode = "<a title=\"$grouptitle ($str->clicktochange)\" href=\"$grouplink\">".
dbcd54b7 1716 "<img src=\"$groupimage\" hspace=\"2\" height=\"11\" width=\"11\" ".
26686b7a 1717 "border=\"0\" alt=\"$grouptitle\" /></a>";
3d575e6f 1718 } else {
32d03b7b 1719 $groupmode = "<img title=\"$grouptitle ($str->forcedmode)\" ".
dbcd54b7 1720 " src=\"$groupimage\" hspace=\"2\" height=\"11\" width=\"11\" ".
26686b7a 1721 "border=\"0\" alt=\"$grouptitle\" />";
3d575e6f 1722 }
1723 } else {
1724 $groupmode = "";
1725 }
7977cffd 1726
1727 if ($moveselect) {
3d575e6f 1728 $move = "<a title=\"$str->move\" href=\"$path/mod.php?copy=$mod->id\"><img".
dbcd54b7 1729 " src=\"$pixpath/t/move.gif\" hspace=\"2\" height=\"11\" width=\"11\" ".
26686b7a 1730 " border=\"0\" alt=\"$str->move\" /></a>";
493486c4 1731 } else {
839f2456 1732 $move = "<a title=\"$str->moveup\" href=\"$path/mod.php?id=$mod->id&amp;move=-1\"><img".
dbcd54b7 1733 " src=\"$pixpath/t/up.gif\" hspace=\"2\" height=\"11\" width=\"11\" ".
26686b7a 1734 " border=\"0\" alt=\"$str->moveup\" /></a>".
839f2456 1735 "<a title=\"$str->movedown\" href=\"$path/mod.php?id=$mod->id&amp;move=1\"><img".
dbcd54b7 1736 " src=\"$pixpath/t/down.gif\" hspace=\"2\" height=\"11\" width=\"11\" ".
26686b7a 1737 " border=\"0\" alt=\"$str->movedown\" /></a>";
7977cffd 1738 }
1739
aac94fd0 1740 $leftright = "";
1741 if ($indent > 0) {
839f2456 1742 $leftright .= "<a title=\"$str->moveleft\" href=\"$path/mod.php?id=$mod->id&amp;indent=-1\"><img".
dbcd54b7 1743 " src=\"$pixpath/t/left.gif\" hspace=\"2\" height=\"11\" width=\"11\" ".
839f2456 1744 " border=\"0\" alt=\"$str->moveleft\" /></a>";
aac94fd0 1745 }
1746 if ($indent >= 0) {
839f2456 1747 $leftright .= "<a title=\"$str->moveright\" href=\"$path/mod.php?id=$mod->id&amp;indent=1\"><img".
dbcd54b7 1748 " src=\"$pixpath/t/right.gif\" hspace=\"2\" height=\"11\" width=\"11\" ".
839f2456 1749 " border=\"0\" alt=\"$str->moveright\" /></a>";
aac94fd0 1750 }
1751
bf1241ad 1752 return "$leftright$move".
3d575e6f 1753 "<a title=\"$str->update\" href=\"$path/mod.php?update=$mod->id\"><img".
dbcd54b7 1754 " src=\"$pixpath/t/edit.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" ".
839f2456 1755 " alt=\"$str->update\" /></a>".
d4bfbe4d 1756 // Following line is commented out until this feature is more definite -- martin
1757 // "<a title=\"$str->duplicate\" href=\"$path/mod.php?duplicate=$mod->id\"> 2 </a>".
3d575e6f 1758 "<a title=\"$str->delete\" href=\"$path/mod.php?delete=$mod->id\"><img".
dbcd54b7 1759 " src=\"$pixpath/t/delete.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" ".
839f2456 1760 " alt=\"$str->delete\" /></a>$hideshow$groupmode";
90845098 1761}
1762
1c919752 1763?>