]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
Merge remote-tracking branch 'upstream/develop' into 1702-no-old_pager
[friendica.git] / mod / profile.php
index ab7b7cff76f33f65e5b250afd7fc0b21fedb66fb..93f2602e23f6b8b4ef1c40be6818f246bedf3c5c 100644 (file)
@@ -240,6 +240,17 @@ function profile_content(App $a, $update = 0) {
                        $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
                }
 
+               // Belongs the profile page to a forum?
+               // If not then we can improve the performance with an additional condition
+               $r = q("SELECT `uid` FROM `user` WHERE `uid` = %d AND `page-flags` IN (%d, %d)",
+                       intval($a->profile['profile_uid']),
+                       intval(PAGE_COMMUNITY),
+                       intval(PAGE_PRVGROUP));
+
+               if (!dbm::is_result($r)) {
+                       $sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
+               }
+
                //  check if we serve a mobile device and get the user settings
                //  accordingly
                if ($a->is_mobile) {
@@ -265,14 +276,12 @@ function profile_content(App $a, $update = 0) {
                        STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
                                AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
                        WHERE `thread`.`uid` = %d AND `thread`.`visible`
-                               AND `thread`.`contact-id` = %d
                                AND NOT `thread`.`deleted`
                                AND NOT `thread`.`moderated`
                                AND `thread`.`wall`
-                               $sql_extra $sql_extra2
+                               $sql_extra3 $sql_extra $sql_extra2
                        ORDER BY `thread`.`created` DESC $pager_sql",
-                       intval($a->profile['profile_uid']),
-                       intval($a->profile['contact_id'])
+                       intval($a->profile['profile_uid'])
                );
        }