Merge pull request #358 from jgen/master
PHP Notice being generated in comment.php
This commit is contained in:
commit
7d3d331272
@ -293,6 +293,8 @@ class CommentList extends Extension {
|
|||||||
$user_ratings = Ratings::get_user_privs($user);
|
$user_ratings = Ratings::get_user_privs($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : "";
|
||||||
|
|
||||||
$total_pages = $database->cache->get("comment_pages");
|
$total_pages = $database->cache->get("comment_pages");
|
||||||
if(empty($total_pages)) {
|
if(empty($total_pages)) {
|
||||||
$total_pages = (int)($database->get_one("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments $where GROUP BY image_id) AS s1") / 10);
|
$total_pages = (int)($database->get_one("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments $where GROUP BY image_id) AS s1") / 10);
|
||||||
@ -307,7 +309,6 @@ class CommentList extends Extension {
|
|||||||
$threads_per_page = 10;
|
$threads_per_page = 10;
|
||||||
$start = $threads_per_page * ($current_page - 1);
|
$start = $threads_per_page * ($current_page - 1);
|
||||||
|
|
||||||
$where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : "";
|
|
||||||
$get_threads = "
|
$get_threads = "
|
||||||
SELECT image_id,MAX(posted) AS latest
|
SELECT image_id,MAX(posted) AS latest
|
||||||
FROM comments $where
|
FROM comments $where
|
||||||
@ -320,13 +321,15 @@ class CommentList extends Extension {
|
|||||||
$images = array();
|
$images = array();
|
||||||
while($row = $result->fetch()) {
|
while($row = $result->fetch()) {
|
||||||
$image = Image::by_id($row["image_id"]);
|
$image = Image::by_id($row["image_id"]);
|
||||||
$comments = $this->get_comments($image->id);
|
if (!is_null($image)) {
|
||||||
if(class_exists("Ratings")) {
|
$comments = $this->get_comments($image->id);
|
||||||
if(strpos($user_ratings, $image->rating) === FALSE) {
|
if(class_exists("Ratings")) {
|
||||||
$image = null; // this is "clever", I may live to regret it
|
if(strpos($user_ratings, $image->rating) === FALSE) {
|
||||||
|
$image = null; // this is "clever", I may live to regret it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(!is_null($image)) $images[] = array($image, $comments);
|
||||||
}
|
}
|
||||||
if(!is_null($image)) $images[] = array($image, $comments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->theme->display_comment_list($images, $current_page, $total_pages, $user->can("create_comment"));
|
$this->theme->display_comment_list($images, $current_page, $total_pages, $user->can("create_comment"));
|
||||||
@ -335,8 +338,7 @@ class CommentList extends Extension {
|
|||||||
|
|
||||||
// get comments {{{
|
// get comments {{{
|
||||||
private function get_recent_comments($count) {
|
private function get_recent_comments($count) {
|
||||||
global $config;
|
global $config, $database;
|
||||||
global $database;
|
|
||||||
$rows = $database->get_all("
|
$rows = $database->get_all("
|
||||||
SELECT
|
SELECT
|
||||||
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
||||||
@ -356,8 +358,7 @@ class CommentList extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function get_user_comments(/*int*/ $user_id, /*int*/ $count, /*int*/ $offset=0) {
|
private function get_user_comments(/*int*/ $user_id, /*int*/ $count, /*int*/ $offset=0) {
|
||||||
global $config;
|
global $config, $database;
|
||||||
global $database;
|
|
||||||
$rows = $database->get_all("
|
$rows = $database->get_all("
|
||||||
SELECT
|
SELECT
|
||||||
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
||||||
@ -378,8 +379,7 @@ class CommentList extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function get_comments(/*int*/ $image_id) {
|
private function get_comments(/*int*/ $image_id) {
|
||||||
global $config;
|
global $config, $database;
|
||||||
global $database;
|
|
||||||
$i_image_id = int_escape($image_id);
|
$i_image_id = int_escape($image_id);
|
||||||
$rows = $database->get_all("
|
$rows = $database->get_all("
|
||||||
SELECT
|
SELECT
|
||||||
@ -402,9 +402,7 @@ class CommentList extends Extension {
|
|||||||
|
|
||||||
// add / remove / edit comments {{{
|
// add / remove / edit comments {{{
|
||||||
private function is_comment_limit_hit() {
|
private function is_comment_limit_hit() {
|
||||||
global $user;
|
global $user, $config, $database;
|
||||||
global $config;
|
|
||||||
global $database;
|
|
||||||
|
|
||||||
// sqlite fails at intervals
|
// sqlite fails at intervals
|
||||||
if($database->get_driver_name() === "sqlite") return false;
|
if($database->get_driver_name() === "sqlite") return false;
|
||||||
@ -493,9 +491,9 @@ class CommentList extends Extension {
|
|||||||
}
|
}
|
||||||
return $pagenum;
|
return $pagenum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_comment_wrapper(/*int*/ $image_id, User $user, /*string*/ $comment) {
|
private function add_comment_wrapper(/*int*/ $image_id, User $user, /*string*/ $comment) {
|
||||||
global $database;
|
global $database, $config;
|
||||||
global $config;
|
|
||||||
|
|
||||||
// basic sanity checks
|
// basic sanity checks
|
||||||
if(!$user->can("create_comment")) {
|
if(!$user->can("create_comment")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user