="'.TIME.'") AND ns.news_draft=0 AND '.groupaccess('ns.news_visibility').' '.(multilang_table('NS') ? 'AND '.in_group('ns.news_language', LANGUAGE) : ''); break; case 'P': $query = 'SELECT p.photo_title as title FROM '.DB_PHOTOS.' AS p INNER JOIN '.DB_PHOTO_ALBUMS.' AS a ON p.album_id=a.album_id WHERE p.photo_id=:id AND '.groupaccess('a.album_access').' '.(multilang_table('PG') ? 'AND '.in_group('a.album_language', LANGUAGE) : ''); break; default: $cache[$key] = FALSE; return FALSE; } $result = dbquery($query, [':id' => $item_id]); $cache[$key] = dbrows($result) ? dbarray($result)['title'] : FALSE; } return $cache[$key]; } function latest_comments_get_comment_start($type, $item_id, $comment_id) { static $cache = []; $key = $type.$item_id; if (!isset($cache[$key])) { $cache[$key] = dbcount('(comment_id)', DB_COMMENTS, 'comment_item_id="'.$item_id.'" AND comment_type="'.$type.'" AND comment_id<'.$comment_id); } return $cache[$key]--; } if (dbrows($result)) { while ($data = dbarray($result)) { $item_title = latest_comments_get_item_title($data['comment_type'], $data['comment_item_id']); if (!$item_title) { continue; } $comment_start = latest_comments_get_comment_start($data['comment_type'], $data['comment_item_id'], $data['comment_id']); switch ($data['comment_type']) { case 'A': $comment_start = $comments_sorting_asc || $comment_start >= $comments_per_page ? '&c_start_A'.$data['comment_item_id'].'='.(floor($comment_start / $comments_per_page) * $comments_per_page) : ''; $url = INFUSIONS.'articles/articles.php?article_id='.$data['comment_item_id']; break; case 'B': $comment_start = $comments_sorting_asc || $comment_start >= $comments_per_page ? '&c_start_blog_comments='.(floor($comment_start / $comments_per_page) * $comments_per_page) : ''; $url = INFUSIONS.'blog/blog.php?readmore='.$data['comment_item_id']; break; case 'D': $comment_start = $comments_sorting_asc || $comment_start >= $comments_per_page ? '&c_start_D'.$data['comment_item_id'].'='.(floor($comment_start / $comments_per_page) * $comments_per_page) : ''; $url = INFUSIONS.'downloads/downloads.php?download_id='.$data['comment_item_id']; break; case 'N': $comment_start = $comments_sorting_asc || $comment_start >= $comments_per_page ? '&c_start_news_comments='.(floor($comment_start / $comments_per_page) * $comments_per_page) : ''; $url = INFUSIONS.'news/news.php?readmore='.$data['comment_item_id']; break; case 'P': $comment_start = $comments_sorting_asc || $comment_start >= $comments_per_page ? '&c_start_P'.$data['comment_item_id'].'='.(floor($comment_start / $comments_per_page) * $comments_per_page) : ''; $url = INFUSIONS.'gallery/gallery.php?photo_id='.$data['comment_item_id']; break; default: continue 2; } $info['item'][] = [ 'data' => $data, 'url' => $url, 'title' => $item_title, 'c_url' => $url.$comment_start.'#c'.$data['comment_id'] ]; } } else { $info['no_rows'] = $locale['global_026']; } render_latest_comments($info);