From: jungwirr Date: Tue, 4 May 2004 19:13:53 +0000 (+0000) Subject: fixed a bunch more foreach loops to test for null value on the iterated X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=88521dee99a8b7f4f25bb2613509e50eef4d1e91;p=moodle.git fixed a bunch more foreach loops to test for null value on the iterated collection --- diff --git a/mod/attendance/index.php b/mod/attendance/index.php index bd33774275..0d99c1db0f 100644 --- a/mod/attendance/index.php +++ b/mod/attendance/index.php @@ -57,7 +57,7 @@ $table->align = array ("LEFT", "LEFT", "LEFT"); } - foreach ($attendances as $attendance) { + if ($attendances) foreach ($attendances as $attendance) { if (!$attendance->visible) { //Show dimmed if the mod is hidden $link = "coursemodule\">$attendance->name"; diff --git a/mod/attendance/lib.php b/mod/attendance/lib.php index 54063dd793..276da0d09e 100755 --- a/mod/attendance/lib.php +++ b/mod/attendance/lib.php @@ -101,7 +101,7 @@ function attendance_update_instance($attendance) { if ($data = data_submitted()) { // Peel out all the data from variable names. $attrec->dayid = $attendance->id; - foreach ($data as $key => $val) { + if ($data) foreach ($data as $key => $val) { $pieces = explode('_',$key); if ($pieces[0] == 'student') { $attrec->userid=$pieces[1]; @@ -186,7 +186,7 @@ function attendance_user_outline($course, $user, $mod, $attendance) { } else { // build array of all tardies $tarr = array(); - foreach ($tardyrecs as $tardyrec) { + if ($tardyrecs) foreach ($tardyrecs as $tardyrec) { array_push($tarr, $tardyrec->hour); $tardystring = $tardystring . ", " . $tardyrec->hour; } @@ -204,7 +204,7 @@ function attendance_user_outline($course, $user, $mod, $attendance) { } else { // build array of all absences $aarr = array(); - foreach ($absrecs as $absrec) { + if ($absrecs) foreach ($absrecs as $absrec) { array_push($aarr, $absrec->hour); } $end=array_pop($aarr); @@ -270,7 +270,7 @@ function attendance_cron () { } $td = attendance_find_today(time()); $tm = attendance_find_tomorrow(time()); - foreach($attendances as $attendance) { + if ($attendances) foreach($attendances as $attendance) { if (($attendance->day >=$td ) && ($attendance->day < $tm)) { echo "Attendance: Taking attendance for $attendance->name\n"; diff --git a/mod/attendance/mod.html b/mod/attendance/mod.html index b40ae258a8..e9b36771d4 100755 --- a/mod/attendance/mod.html +++ b/mod/attendance/mod.html @@ -130,7 +130,7 @@ if ($form->hours >1) { $students = attendance_get_course_students($form->course, "u.lastname ASC"); $i=0; - foreach ($students as $student) { + if ($students) foreach ($students as $student) { echo "".$student->lastname."\n"; echo "".$student->firstname."\n"; echo "".$student->idnumber."\n"; diff --git a/mod/attendance/teacheredit.php b/mod/attendance/teacheredit.php index b93308074f..953fe51baf 100755 --- a/mod/attendance/teacheredit.php +++ b/mod/attendance/teacheredit.php @@ -170,7 +170,7 @@ if ($form->hours >1) { $students = attendance_get_course_students($form->course, "u.lastname ASC"); $i=0; - foreach ($students as $student) { + if ($students) foreach ($students as $student) { echo "".$student->lastname."\n"; echo "".$student->firstname."\n"; echo "".$student->idnumber."\n"; diff --git a/mod/attendance/viewall.php b/mod/attendance/viewall.php index c96cf9b400..73903d2b54 100644 --- a/mod/attendance/viewall.php +++ b/mod/attendance/viewall.php @@ -529,3 +529,5 @@ function attendance_HeaderingExcel($filename) { } ?> + +http://www.alpine-usa.com/company_info/press_release/010804_ipad.html diff --git a/mod/attendance/viewweek.php b/mod/attendance/viewweek.php index c8f721fe77..5b29b1070b 100644 --- a/mod/attendance/viewweek.php +++ b/mod/attendance/viewweek.php @@ -1,4 +1,4 @@ -id, $course->id); $attendance->cmid = $cm->id; @@ -123,7 +123,7 @@ if ($dlsub== "all") { $T = get_string("tardyshort","attendance"); $P = get_string("presentshort","attendance"); $row=4; - foreach ($students as $student) { + if ($students) foreach ($students as $student) { $myxls->write_string($row,0,$student->lastname); $myxls->write_string($row,1,$student->firstname); $studentid=(($student->idnumber != "") ? $student->idnumber : " "); @@ -188,7 +188,7 @@ if ($dlsub== "all") { $T = get_string("tardyshort","attendance"); $P = get_string("presentshort","attendance"); $row=3; - foreach ($students as $student) { + if ($students) foreach ($students as $student) { echo $student->lastname; echo "\t".$student->firstname; $studentid=(($student->idnumber != "") ? $student->idnumber : " "); @@ -403,7 +403,7 @@ while (($multipage || $onepage) && (!$endonepage)) { $A = get_string("absentshort","attendance"); $T = get_string("tardyshort","attendance"); $P = get_string("presentshort","attendance"); - foreach ($students as $student) { + if ($students) foreach ($students as $student) { if (isteacher($course->id)) { echo "".$student->lastname."\n"; echo "".$student->firstname."\n";