move extension specific parts out of user and into extensions
This commit is contained in:
		
							parent
							
								
									f9dffb96cb
								
							
						
					
					
						commit
						12cccde8f8
					
				| @ -84,19 +84,5 @@ class User { | |||||||
| 		$hash = md5(strtolower($this->name) . $password); | 		$hash = md5(strtolower($this->name) . $password); | ||||||
| 		$this->database->Execute("UPDATE users SET pass=? WHERE id=?", array($hash, $this->id)); | 		$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)); |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
| ?>
 | ?>
 | ||||||
|  | |||||||
| @ -47,6 +47,11 @@ class Comment { // {{{ | |||||||
| 		$this->poster_ip =  $row['poster_ip']; | 		$this->poster_ip =  $row['poster_ip']; | ||||||
| 		$this->posted =  $row['posted']; | 		$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 { | class CommentList implements Extension { | ||||||
|  | |||||||
| @ -122,12 +122,9 @@ class UserPageTheme extends Themelet { | |||||||
| 		global $database; | 		global $database; | ||||||
| 		global $config; | 		global $config; | ||||||
| 
 | 
 | ||||||
| 		$i_days_old = int_escape($duser->get_days_old()); |  | ||||||
| 		$h_join_date = html_escape($duser->join_date); | 		$h_join_date = html_escape($duser->join_date); | ||||||
| 		$i_image_count = int_escape($duser->get_image_count()); | 		$i_image_count = Image::count_images($config, $database, array("user_id={$duser->id}")); | ||||||
| 		$i_comment_count = int_escape($duser->get_comment_count()); | 		$i_comment_count = Comment::count_comments_by_user($duser); | ||||||
| 
 |  | ||||||
| 		$i_days_old2 = ($i_days_old == 0) ? 1 : $i_days_old; |  | ||||||
| 
 | 
 | ||||||
| 		$h_image_rate = sprintf("%3.1f", ($i_image_count / $i_days_old2)); | 		$h_image_rate = sprintf("%3.1f", ($i_image_count / $i_days_old2)); | ||||||
| 		$h_comment_rate = sprintf("%3.1f", ($i_comment_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"); | 		$images_link = make_link("post/list/user_id=$u_id/1"); | ||||||
| 
 | 
 | ||||||
| 		return " | 		return " | ||||||
| 			Join date: $h_join_date ($i_days_old days old) | 			Join date: $h_join_date | ||||||
| 			<br><a href='$images_link'>Images uploaded</a>: $i_image_count ($h_image_rate / day) | 			<br><a href='$images_link'>Images uploaded</a>: $i_image_count ($h_image_rate / day) | ||||||
| 			<br>Comments made: $i_comment_count ($h_comment_rate / day) | 			<br>Comments made: $i_comment_count ($h_comment_rate / day) | ||||||
| 			";
 | 			";
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user