From: stronk7 Date: Fri, 10 Oct 2003 18:57:38 +0000 (+0000) Subject: Added the dialogue_get_participants() function X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=aefbd27636c98c00f33430ba82e1eac115a367fb;p=moodle.git Added the dialogue_get_participants() function to use it in backup/restore. --- diff --git a/mod/dialogue/lib.php b/mod/dialogue/lib.php index 9c59265467..6fc211d8d9 100644 --- a/mod/dialogue/lib.php +++ b/mod/dialogue/lib.php @@ -356,7 +356,37 @@ function dialogue_delete_expired_conversations() { } } } - + +function dialogue_get_participants($dialogueid) { +//Returns the users with data in one dialogue +//(users with records in dialogue_conversations, creators and receivers) + + global $CFG; + + //Get conversation's creators + $creators = get_records_sql("SELECT DISTINCT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}dialogue_conversations c + WHERE c.dialogueid = '$dialogueid' and + u.id = c.userid"); + + //Get conversation's receivers + $receivers = get_records_sql("SELECT DISTINCT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}dialogue_conversations c + WHERE c.dialogueid = '$dialogueid' and + u.id = c.recipientid"); + + //Add receivers to creators + if ($receivers) { + foreach ($receivers as $receiver) { + $creators[$receiver->id] = $receiver; + } + } + + //Return creators array (it contains an array of unique users, creators and receivers) + return ($creators); +} ////////////////////////////////////////////////////////////////////////////////////// function dialogue_get_available_users($dialogue) {