From dec2ac7f2cb651a0f97bb22c6981dcb80efb048e Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Wed, 28 Oct 2009 14:15:51 -0500 Subject: [PATCH] Fixed Warning into group DT#5496 --- main/inc/lib/groupmanager.lib.php | 41 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 9560ebad2e..6d343cd857 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -183,25 +183,26 @@ class GroupManager { } $groups = array (); - while ($thisGroup = Database::fetch_array($groupList)) - { - if ($thisGroup['category_id'] == VIRTUAL_COURSE_CATEGORY) - { - $sql = "SELECT title FROM $table_course WHERE code = '".$thisGroup['name']."'"; - $obj = Database::fetch_object(Database::query($sql,__FILE__,__LINE__)); - $thisGroup['name'] = $obj->title; - } - if($thisGroup['session_id']!=0) - { - $sql_session = 'SELECT name FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$thisGroup['session_id']; - $rs_session = Database::query($sql_session,__FILE__,__LINE__); - if (Database::num_rows($rs_session)>0) { - $thisGroup['session_name'] = Database::result($rs_session,0,0); - } else { - //the session has probably been removed, so the group is now orphaned + if(is_array($thisGroup = Database::fetch_array($groupList))){ + while ($thisGroup = Database::fetch_array($groupList)) { + if ($thisGroup['category_id'] == VIRTUAL_COURSE_CATEGORY) + { + $sql = "SELECT title FROM $table_course WHERE code = '".$thisGroup['name']."'"; + $obj = Database::fetch_object(Database::query($sql,__FILE__,__LINE__)); + $thisGroup['name'] = $obj->title; } + if($thisGroup['session_id']!=0) + { + $sql_session = 'SELECT name FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$thisGroup['session_id']; + $rs_session = Database::query($sql_session,__FILE__,__LINE__); + if (Database::num_rows($rs_session)>0) { + $thisGroup['session_name'] = Database::result($rs_session,0,0); + } else { + //the session has probably been removed, so the group is now orphaned + } + } + $groups[] = $thisGroup; } - $groups[] = $thisGroup; } return $groups; } @@ -809,8 +810,8 @@ class GroupManager { $i--; } } - if(count($group_ids)==0) - return false; + if(count($group_ids)==0){ + return false;} } global $_course; @@ -825,7 +826,7 @@ class GroupManager { * Retrieve all the groups where enrollment is still allowed * (reverse) ordered by the number of place available */ - $sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student + echo $sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student FROM ".$group_table." g LEFT JOIN ".$group_user_table." ug ON `g`.`id` = `ug`.`group_id`