LEFT OUTER JOIN {$serendipity['dbPrefix']}authorgroups AS ag
ON ag.authorid = ". (int)$authorid . "
LEFT OUTER JOIN {$serendipity['dbPrefix']}access AS a
- ON (a.artifact_id = " . (int)$artifact_id . " AND (ag.groupid = a.groupid OR a.groupid = 0) )
+ ON ( a.artifact_type = '" . serendipity_db_escape_string($artifact_type) . "'
+ AND a.artifact_id = " . (int)$artifact_id . "
+ AND a.artifact_mode = '" . serendipity_db_escape_string($artifact_mode) . "'
+ AND (ag.groupid = a.groupid OR a.groupid = 0)
+ )
WHERE {$artifact_sql['cond']}
- AND ((
- a.artifact_type = '" . serendipity_db_escape_string($artifact_type) . "'
- AND a.artifact_mode = '" . serendipity_db_escape_string($artifact_mode) . "'
- )
- {$artifact_sql['where']}
- )
+ AND ( {$artifact_sql['where']} )
GROUP BY result";
$res = serendipity_db_query($sql, true, 'assoc');
$cond['joins'] .= " LEFT JOIN {$serendipity['dbPrefix']}authorgroups AS acl_a
ON acl_a.authorid = " . $read_id . "
LEFT JOIN {$serendipity['dbPrefix']}access AS acl_acc
- ON acl_acc.groupid = " . $read_id_sql;
+ ON ( acl_acc.artifact_mode = 'read'
+ AND acl_acc.artifact_type = 'category'
+ AND acl_acc.artifact_id = c.categoryid
+ AND acl_acc.groupid = " . $read_id_sql . "
+ )";
if (empty($cond['and'])) {
$cond['and'] .= ' WHERE ';
$cond['and'] .= " (
c.categoryid IS NULL
- OR (acl_acc.artifact_type = 'category'
- AND acl_acc.artifact_mode = 'read'
- AND acl_acc.artifact_id = c.categoryid)
OR (acl_acc.artifact_id IS NULL
AND (c.authorid = 0 OR c.authorid = " . $read_id . ")
)