Merge branch 'MDL-25708' of git://github.com/stronk7/moodle

This commit is contained in:
Petr Skoda 2011-01-31 14:21:53 +01:00
commit 8afc38bd39
53 changed files with 514 additions and 526 deletions

View file

@ -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;
}
if (!empty($user2) && $user2->id==$rd->id) {
$user2->iscontact = true;
}
} else {
$offlinecontacts[] = $rd;
}
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
@ -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);
}