Skip to content

Commit

Permalink
taking out user_student table reference in SQL, replaced with role_as…
Browse files Browse the repository at this point in the history
…signment
  • Loading branch information
toyomoyo committed Sep 14, 2006
1 parent b88b740 commit 9dcc11e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,21 +456,21 @@ function fetch_entries($userid, $postid='', $fetchlimit=10, $fetchstart='', $fil

case 'course':
if ($filterselect != SITEID) {

// all users with a role assigned
$context = get_context_instance(CONTEXT_COURSE, $filterselect);
if ($parents = get_parent_contexts($context)) {
$contextlists = 'OR ra.contextid IN ('.implode(',', $parents).'))';
} else {
$contextlists = ')';
}

$SQL = '(SELECT '.$requiredfields.' FROM '.$CFG->prefix.'post p, '.$tagtablesql
.$CFG->prefix.'user_students s, '.$CFG->prefix.'user u
WHERE p.userid = s.userid '.$tagquerysql.'
AND s.course = '.$filterselect.'
AND u.id = p.userid
AND (p.publishstate = \'site\' OR p.publishstate = \'public\' OR p.userid = '.$USER->id.'))
UNION
(SELECT '.$requiredfields.' FROM '.$CFG->prefix.'post p, '.$tagtablesql
.$CFG->prefix.'user_teachers t, '.$CFG->prefix.'user u
WHERE p.userid = t.userid '.$tagquerysql.'
AND t.course = '.$filterselect.'
.$CFG->prefix.'role_assignments ra, '.$CFG->prefix.'user u
WHERE p.userid = ra.userid '.$tagquerysql.'
AND (ra.contextid = '.$context->id.' '.$contextlists.'
AND u.id = p.userid
AND (p.publishstate = \'site\' OR p.publishstate = \'public\' OR p.userid = '.$USER->id.'))'; //this will break for postgres, i think
AND (p.publishstate = \'site\' OR p.publishstate = \'public\' OR p.userid = '.$USER->id.'))';
} else {

if (isloggedin()) {
Expand Down

0 comments on commit 9dcc11e

Please sign in to comment.