Included forum_get_participants() function.

This commit is contained in:
stronk7 2003-09-07 21:28:31 +00:00
parent 17880f080c
commit eaa3298b07

View File

@ -2105,5 +2105,48 @@ function forum_set_display_mode($mode=0) {
}
}
function forum_get_participants($forumid) {
//Returns the users with data in one forum
//(users with records in forum_subscriptions, forum_posts and forum_ratings, students)
global $CFG;
//Get students from forum_subscriptions
$st_subscriptions = get_records_sql("SELECT DISTINCT u.*
FROM {$CFG->prefix}user u,
{$CFG->prefix}forum_subscriptions s
WHERE s.forum = '$forumid' and
u.id = s.userid");
//Get students from forum_posts
$st_posts = get_records_sql("SELECT DISTINCT u.*
FROM {$CFG->prefix}user u,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p
WHERE d.forum = '$forumid' and
p.discussion = d.id and
u.id = p.userid");
//Get students from forum_ratings
$st_ratings = get_records_sql("SELECT DISTINCT u.*
FROM {$CFG->prefix}user u,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_ratings r
WHERE d.forum = '$forumid' and
p.discussion = d.id and
r.post = p.id and
u.id = r.userid");
//Add st_posts to st_subscriptions
foreach ($st_posts as $st_post) {
$st_subscriptions[$st_post->id] = $st_post;
}
//Add st_ratings to st_subscriptions
foreach ($st_ratings as $st_rating) {
$st_subscriptions[$st_rating->id] = $st_rating;
}
//Return st_subscriptions array (it contains an array of unique users)
return ($st_subscriptions);
}
?>