includes/comment.php
changeset 1298 510187db2b32
parent 1280 871f17a0d27d
equal deleted inserted replaced
1297:f3eaf6b3ee1b 1298:510187db2b32
   131 				if ( $page > 0 )
   131 				if ( $page > 0 )
   132 				{
   132 				{
   133 					$ret['mode'] = 'refetch';
   133 					$ret['mode'] = 'refetch';
   134 				}
   134 				}
   135 				$limit_clause = "LIMIT $per_page OFFSET " . ($page * $per_page);
   135 				$limit_clause = "LIMIT $per_page OFFSET " . ($page * $per_page);
   136 				$q = $db->sql_query('SELECT c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,( c.ip_address IS NOT NULL ) AS have_ip,u.user_level,u.user_id,u.email,u.signature,u.user_has_avatar,u.avatar_type, b.buddy_id IS NOT NULL AS is_buddy, ( b.is_friend IS NOT NULL AND b.is_friend=1 ) AS is_friend FROM '.table_prefix.'comments AS c
   136 				$q = $db->sql_query('SELECT c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,( c.ip_address IS NOT NULL ) AS have_ip,u.username,u.user_level,u.user_id,u.email,u.signature,u.user_has_avatar,u.avatar_type, b.buddy_id IS NOT NULL AS is_buddy, ( b.is_friend IS NOT NULL AND b.is_friend=1 ) AS is_friend FROM '.table_prefix.'comments AS c
   137  															LEFT JOIN '.table_prefix.'users AS u
   137  															LEFT JOIN '.table_prefix.'users AS u
   138  																ON (u.user_id=c.user_id)
   138  																ON (u.user_id=c.user_id)
   139  															LEFT JOIN '.table_prefix.'buddies AS b
   139  															LEFT JOIN '.table_prefix.'buddies AS b
   140  																ON ( ( b.user_id=' . $session->user_id.' AND b.buddy_user_id=c.user_id ) OR b.user_id IS NULL)
   140  																ON ( ( b.user_id=' . $session->user_id.' AND b.buddy_user_id=c.user_id ) OR b.user_id IS NULL)
   141  															LEFT JOIN '.table_prefix.'ranks AS r
   141  															LEFT JOIN '.table_prefix.'ranks AS r
   142  																ON ( ( u.user_rank = r.rank_id ) )
   142  																ON ( ( u.user_rank = r.rank_id ) )
   143  															WHERE page_id=\'' . $this->page_id . '\'
   143  															WHERE page_id=\'' . $this->page_id . '\'
   144  																AND namespace=\'' . $this->namespace . '\'
   144  																AND namespace=\'' . $this->namespace . '\'
   145  																' . $approve_clause . '
   145  																' . $approve_clause . '
   146  															GROUP BY c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,c.ip_address,u.user_level,u.user_id,u.email,u.signature,u.user_has_avatar,u.avatar_type,b.buddy_id,b.is_friend
   146  															GROUP BY c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,c.ip_address,u.username,u.user_level,u.user_id,u.email,u.signature,u.user_has_avatar,u.avatar_type,b.buddy_id,b.is_friend
   147  															ORDER BY c.time ASC
   147  															ORDER BY c.time ASC
   148  															' . $limit_clause . ';');
   148  															' . $limit_clause . ';');
   149 				$ret['comments'] = Array();
   149 				$ret['comments'] = Array();
   150 				if (!$q)
   150 				if (!$q)
   151 					$db->die_json();
   151 					$db->die_json();
   190 						// Do we have the IP?
   190 						// Do we have the IP?
   191 						$row['have_ip'] = ( $row['have_ip'] == 1 );
   191 						$row['have_ip'] = ( $row['have_ip'] == 1 );
   192 						
   192 						
   193 						// Avatar URL
   193 						// Avatar URL
   194 						$row['avatar_path'] = make_avatar_url($row['user_id'], $row['avatar_type'], $row['email']);
   194 						$row['avatar_path'] = make_avatar_url($row['user_id'], $row['avatar_type'], $row['email']);
       
   195 						
       
   196 						// Name
       
   197 						//if ( $row['user_id'] > 1 )
       
   198 						//	$row['name'] = $row['username'];
   195 						
   199 						
   196 						// Add the comment to the list
   200 						// Add the comment to the list
   197 						$ret['comments'][] = $row;
   201 						$ret['comments'][] = $row;
   198 						
   202 						
   199 					} while ( $row = $db->fetchrow($q) );
   203 					} while ( $row = $db->fetchrow($q) );