]> git.mjollnir.org Git - moodle.git/commitdiff
Added the dialogue_get_participants() function
authorstronk7 <stronk7>
Fri, 10 Oct 2003 18:57:38 +0000 (18:57 +0000)
committerstronk7 <stronk7>
Fri, 10 Oct 2003 18:57:38 +0000 (18:57 +0000)
to use it in backup/restore.

mod/dialogue/lib.php

index 9c59265467138ab2e3582bc122bd1ae45e007d86..6fc211d8d91e1116fc8bfeb81069cb1806b93471 100644 (file)
@@ -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) {