Skip to content

Commit

Permalink
MDL-25708 recordsets - fix message/lib.php
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 25, 2011
1 parent 1b42e67 commit 20222a3
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions message/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,24 +269,21 @@ function message_get_contacts($user1=null, &$user2=null) {
GROUP BY $userfields
ORDER BY u.firstname ASC";

if ($rs = $DB->get_recordset_sql($contactsql, array($user1->id, $user1->id))){
foreach($rs as $rd){
$rs = $DB->get_recordset_sql($contactsql, array($user1->id, $user1->id));
foreach ($rs as $rd) {
if ($rd->lastaccess >= $timefrom) {
// they have been active recently, so are counted online
$onlinecontacts[] = $rd;

if($rd->lastaccess >= $timefrom){
// they have been active recently, so are counted online
$onlinecontacts[] = $rd;

}else{
$offlinecontacts[] = $rd;
}
} else {
$offlinecontacts[] = $rd;
}

if (!empty($user2) && $user2->id==$rd->id) {
$user2->iscontact = true;
}
if (!empty($user2) && $user2->id==$rd->id) {
$user2->iscontact = true;
}
unset($rd);
$rs->close();
}
$rs->close();

// get messages from anyone who isn't in our contact list and count the number
// of messages we have from each of them
Expand All @@ -298,13 +295,11 @@ function message_get_contacts($user1=null, &$user2=null) {
GROUP BY $userfields
ORDER BY u.firstname ASC";

if($rs = $DB->get_recordset_sql($strangersql, array($USER->id))){
foreach($rs as $rd){
$strangers[] = $rd;
}
unset($rd);
$rs->close();
$rs = $DB->get_recordset_sql($strangersql, array($USER->id));
foreach ($rs as $rd) {
$strangers[] = $rd;
}
$rs->close();

return array($onlinecontacts, $offlinecontacts, $strangers);
}
Expand Down

0 comments on commit 20222a3

Please sign in to comment.