Permalink
Browse files

fixed a bunch more foreach loops to test for null value on the iterated

collection
  • Loading branch information...
1 parent 2f22658 commit 88521dee99a8b7f4f25bb2613509e50eef4d1e91 jungwirr committed May 4, 2004
@@ -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 = "<A class=\"dimmed\" HREF=\"view.php?id=$attendance->coursemodule\">$attendance->name</A>";
@@ -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";
@@ -130,7 +130,7 @@
$students = attendance_get_course_students($form->course, "u.lastname ASC");
$i=0;
- foreach ($students as $student) {
+ if ($students) foreach ($students as $student) {
echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->idnumber."</td>\n";
@@ -170,7 +170,7 @@
$students = attendance_get_course_students($form->course, "u.lastname ASC");
$i=0;
- foreach ($students as $student) {
+ if ($students) foreach ($students as $student) {
echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->idnumber."</td>\n";
@@ -529,3 +529,5 @@ function attendance_HeaderingExcel($filename) {
}
?>
+
+http://www.alpine-usa.com/company_info/press_release/010804_ipad.html
@@ -1,4 +1,4 @@
-<? // $Id$
+sou<? // $Id$
/// This page prints all instances of attendance in a given week
require_once("../../config.php");
@@ -49,7 +49,7 @@
/// create an array of all the attendance objects for the week
$numatt=0;
$numhours=0;
- foreach ($attendances as $attendance){
+ if ($attendances) foreach ($attendances as $attendance){
// store the raw attendance object
$cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id);
$attendance->cmid = $cm->id;
@@ -123,7 +123,7 @@
$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 @@
$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 @@
$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 "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";

0 comments on commit 88521de

Please sign in to comment.