properly join. Thanks to nobody.
authorgarvinhicking <garvinhicking>
Mon, 12 Sep 2005 13:34:55 +0000 (13:34 +0000)
committergarvinhicking <garvinhicking>
Mon, 12 Sep 2005 13:34:55 +0000 (13:34 +0000)
include/functions_config.inc.php

index a2313973690454abe5dbe11bc38f3fb5b13101cd..90c2d4a66db6eff81fe95edce29119f27c77e14c 100644 (file)
@@ -1025,15 +1025,14 @@ function serendipity_ACLCheck($authorid, $artifact_id, $artifact_type, $artifact
    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');
@@ -1070,7 +1069,11 @@ function serendipity_ACL_SQL(&$cond, $append_category = false) {
         $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 ';
@@ -1080,9 +1083,6 @@ function serendipity_ACL_SQL(&$cond, $append_category = false) {
 
         $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 . ")
                                     )