Commit 2a393444 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

when getting forum moderators no longer check if they are forum members (as...

when getting forum moderators no longer check if they are forum members (as they are removed when they leave the group)
parent 0caa5c6d
......@@ -40,12 +40,7 @@ $post = get_record_sql(
INNER JOIN {interaction_forum_post} p2 ON (p2.topic = t.id AND p2.parent IS NULL)
INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1)
INNER JOIN {group} g ON (g.id = f.group AND g.deleted = ?)
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m ON (m.forum = f.id AND m.user = p.poster)
LEFT JOIN {interaction_forum_moderator} m ON (m.forum = f.id AND m.user = p.poster)
INNER JOIN {interaction_forum_post} p3 ON (p.poster = p3.poster AND p3.deleted != 1)
INNER JOIN {interaction_forum_topic} t2 ON (t2.deleted != 1 AND p3.topic = t2.id)
INNER JOIN {interaction_instance} f2 ON (t2.forum = f2.id AND f2.deleted != 1 AND f2.group = f.group)
......
......@@ -41,12 +41,7 @@ $topic = get_record_sql(
INNER JOIN {interaction_instance} f ON (f.id = t.forum AND f.deleted != 1)
INNER JOIN {group} g ON (g.id = f.group AND g.deleted = ?)
INNER JOIN {interaction_forum_post} p ON (p.topic = t.id AND p.parent IS NULL)
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m ON (m.user = p.poster AND m.forum = t.forum)
LEFT JOIN {interaction_forum_moderator} m ON (m.user = p.poster AND m.forum = t.forum)
INNER JOIN {interaction_forum_post} p2 ON (p.poster = p2.poster AND p2.deleted != 1)
INNER JOIN {interaction_forum_topic} t2 ON (t2.deleted != 1 AND p2.topic = t2.id)
INNER JOIN {interaction_instance} f2 ON (t2.forum = f2.id AND f2.deleted != 1 AND f2.group = f.group)
......
......@@ -59,12 +59,7 @@ $parent = get_record_sql(
INNER JOIN {interaction_forum_topic} t ON (p.topic = t.id AND t.deleted != 1)
INNER JOIN {interaction_forum_post} p2 ON (p2.topic = t.id AND p2.parent IS NULL)
INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1)
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m ON (m.user = p.poster AND m.forum = f.id)
LEFT JOIN {interaction_forum_moderator} m ON (m.user = p.poster AND m.forum = f.id)
INNER JOIN {group} g ON (g.id = f.group AND g.deleted = ?)
INNER JOIN {interaction_forum_post} p3 ON (p.poster = p3.poster AND p3.deleted != 1)
INNER JOIN {interaction_forum_topic} t2 ON (t2.deleted != 1 AND p3.topic = t2.id)
......
......@@ -65,12 +65,7 @@ $breadcrumbs = array(
$forums = get_records_sql_array(
'SELECT f.id, f.title, f.description, m.user AS moderator, COUNT(t.*), s.forum AS subscribed
FROM {interaction_instance} f
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m ON m.forum = f.id
LEFT JOIN {interaction_forum_moderator} m ON m.forum = f.id
LEFT JOIN {interaction_forum_topic} t ON (t.forum = f.id AND t.deleted != 1)
INNER JOIN {interaction_forum_instance_config} c ON (c.forum = f.id AND c.field = \'weight\')
LEFT JOIN {interaction_forum_subscription_forum} s ON (s.forum = f.id AND s."user" = ?)
......
......@@ -29,14 +29,7 @@ class PluginInteractionForum extends PluginInteraction {
public static function instance_config_form($group, $instance=null) {
if (isset($instance)) {
$weight = get_field('interaction_forum_instance_config', 'value', 'field', 'weight', 'forum', $instance->get('id'));
$moderators = get_column_sql(
'SELECT fm.user
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON f.id = fm.forum
INNER JOIN {group_member} gm ON gm.group = f.group AND fm.user = gm.member
WHERE fm.forum = ?',
array($instance->get('id'))
);
$moderators = get_column('interaction_forum_moderator', '"user"', 'forum', $instance->get('id'));
}
if ($instance === null) {
......
......@@ -108,21 +108,11 @@ $posts = get_records_sql_array(
INNER JOIN {interaction_forum_post} p2 ON (p1.poster = p2.poster AND p2.deleted != 1)
INNER JOIN {interaction_forum_topic} t2 ON (t2.deleted != 1 AND p2.topic = t2.id)
INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1 AND f.group = ?)
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m oN (t.forum = m.forum AND p1.poster = m.user)
LEFT JOIN {interaction_forum_moderator} m oN (t.forum = m.forum AND p1.poster = m.user)
LEFT JOIN {interaction_forum_edit} e ON e.post = p1.id
LEFT JOIN {interaction_forum_post} p3 ON p3.id = e.post
LEFT JOIN {interaction_forum_topic} t3 ON t3.id = p3.topic
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m2 ON t3.forum = m2.forum AND e.user = m2.user
LEFT JOIN {interaction_forum_moderator} m2 ON t3.forum = m2.forum AND e.user = m2.user
WHERE p1.topic = ?
GROUP BY 1, 2, 3, 4, 5, p1.ctime, 7, 8, 10, 11, 12, e.ctime
ORDER BY p1.ctime, p1.id, e.ctime',
......
......@@ -66,14 +66,7 @@ if (!$membership) {
define('TITLE', $forum->groupname . ' - ' . $forum->title);
$moderators = get_column_sql(
'SELECT m.user
FROM {interaction_forum_moderator} m
INNER JOIN {group_member} gm ON (m.user = gm.member AND gm.group = ?)
WHERE m.forum = ?
ORDER BY m.user',
array($forum->group, $forumid)
);
$moderators = get_column('interaction_forum_moderator', '"user"', 'forum', $forumid);
// updates the selected topics as subscribed/closed/sticky
if (isset($_POST['checked'])) {
......@@ -178,12 +171,7 @@ $forum->subscribe = pieform(array(
$sql = 'SELECT t.id, p1.subject, p1.body, p1.poster, p1.deleted, m.user AS moderator, COUNT(p2.*), t.closed, s.topic AS subscribed, p4.id AS lastpost, ' . db_format_tsfield('p4.ctime', 'lastposttime') . ', p4.poster AS lastposter, m2.user AS lastpostermoderator
FROM interaction_forum_topic t
INNER JOIN {interaction_forum_post} p1 ON (p1.topic = t.id AND p1.parent IS NULL)
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m ON (m.forum = t.forum AND p1.poster = m.user)
LEFT JOIN {interaction_forum_moderator} m ON (m.forum = t.forum AND p1.poster = m.user)
INNER JOIN {interaction_forum_post} p2 ON (p2.topic = t.id AND p2.deleted != 1)
LEFT JOIN {interaction_forum_subscription_topic} s ON (s.topic = t.id AND s."user" = ?)
INNER JOIN (
......@@ -200,12 +188,7 @@ $sql = 'SELECT t.id, p1.subject, p1.body, p1.poster, p1.deleted, m.user AS moder
) p3 ON p3.topic = t.id
LEFT JOIN {interaction_forum_post} p4 ON (p4.id = p3.post)
LEFT JOIN {interaction_forum_topic} t2 ON (p4.topic = t2.id)
LEFT JOIN (
SELECT fm.user, fm.forum
FROM {interaction_forum_moderator} fm
INNER JOIN {interaction_instance} f ON (fm.forum = f.id)
INNER JOIN {group_member} gm ON (gm.group = f.group AND gm.member = fm.user)
) m2 ON (p4.poster = m2.user AND t2.forum = m2.forum)
LEFT JOIN {interaction_forum_moderator} m2 ON (p4.poster = m2.user AND t2.forum = m2.forum)
WHERE t.forum = ?
AND t.sticky = ?
AND t.deleted != 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment