diff --git a/core/user.class.php b/core/user.class.php index ddc3aceb..ce7691a1 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -84,19 +84,5 @@ class User { $hash = md5(strtolower($this->name) . $password); $this->database->Execute("UPDATE users SET pass=? WHERE id=?", array($hash, $this->id)); } - - public function get_days_old() { - return 0; // FIXME calculate this - } - - public function get_image_count() { - global $database; - return $database->db->GetOne("SELECT COUNT(*) AS count FROM images WHERE owner_id=?", array($this->id)); - } - - public function get_comment_count() { - global $database; - return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($this->id)); - } } ?> diff --git a/ext/comment/main.php b/ext/comment/main.php index 70348a30..607d71f2 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -47,6 +47,11 @@ class Comment { // {{{ $this->poster_ip = $row['poster_ip']; $this->posted = $row['posted']; } + + public static function count_comments_by_user($user) { + global $database; + return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($user->id)); + } } // }}} class CommentList implements Extension { diff --git a/ext/user/theme.php b/ext/user/theme.php index f26c8809..e5024ab4 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -122,12 +122,9 @@ class UserPageTheme extends Themelet { global $database; global $config; - $i_days_old = int_escape($duser->get_days_old()); $h_join_date = html_escape($duser->join_date); - $i_image_count = int_escape($duser->get_image_count()); - $i_comment_count = int_escape($duser->get_comment_count()); - - $i_days_old2 = ($i_days_old == 0) ? 1 : $i_days_old; + $i_image_count = Image::count_images($config, $database, array("user_id={$duser->id}")); + $i_comment_count = Comment::count_comments_by_user($duser); $h_image_rate = sprintf("%3.1f", ($i_image_count / $i_days_old2)); $h_comment_rate = sprintf("%3.1f", ($i_comment_count / $i_days_old2)); @@ -136,7 +133,7 @@ class UserPageTheme extends Themelet { $images_link = make_link("post/list/user_id=$u_id/1"); return " - Join date: $h_join_date ($i_days_old days old) + Join date: $h_join_date
Images uploaded: $i_image_count ($h_image_rate / day)
Comments made: $i_comment_count ($h_comment_rate / day) ";