$followers=$this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followerUserID WHERE followedUserID = ? ORDER BY followedSince DESC',[$id])->result_array();
$this->db->cache_on();
$followers=$this->setDefaultImages($followers);
$followers=$this->mergeFollowerCount($followers);
return$followers;
}
functiongetUserByID($id)
{
$result=$this->db->query('SELECT ID, original_name, username, displayname, email, rank, profile_picture, header_image, is_activated, about, lastLogin, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE ID = ? AND is_activated = TRUE LIMIT 1',[$id])->result_array();
$following=$this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followedUserID WHERE followerUserID = ? ORDER BY followedSince DESC',[$id])->result_array();
$this->db->cache_on();
$following=$this->setDefaultImages($following);
$following=$this->mergeFollowerCount($following);
return$following;
}
functiongetUserComments($id,$count,$offset)
{
$comments=$this->db->query('SELECT *, p.postUrl FROM blog_comments c LEFT JOIN blog_posts p ON p.postID = c.post_id WHERE user_id = ? ORDER BY date_created DESC LIMIT ? OFFSET ?',[$id,$count,$offset])->result_array();
$posts=$this->db->query('SELECT * FROM blog_posts WHERE postIsDeleted = FALSE AND postState = 1 AND postAuthorID = ? ORDER BY postPublishDate DESC LIMIT ? OFFSET ?',[$id,$count,$offset])->result_array();
$blogResults=$this->db->query('SELECT COUNT(*) blogCount, (SELECT COUNT(*) FROM blog_comments WHERE user_id = ?) commentCount FROM blog_posts WHERE postIsDeleted = FALSE AND postState = 1 AND postAuthorID = ?',[$userID,$userID])->result_array()[0];
$response=$this->db->query('SELECT followedUserID FROM user_followers WHERE followerUserID = ? AND followedUserID = ?',[$followerID,$followingID])->result_array();
$this->db->cache_off();
return!empty($response);
}
functionunfollow($followerID,$followedID)
{
$this->db->query('DELETE FROM user_followers WHERE followerUserID = ? AND followedUserID = ?',[$followerID,$followedID]);
$this->db->query('UPDATE users SET isCurrentlyOnline = 1, lastOnlineUpdate = NOW() WHERE ID = ? LIMIT 1',[$id]);
}
functiongetActiveUsers($count)
{
$data=$this->db->query('SELECT username, displayname, profile_picture, lastLogin, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users WHERE isCurrentlyOnline = TRUE ORDER BY lastLogin DESC LIMIT ?',[$count])->result_array();
$data=$this->setDefaultImages($data);
return$data;
}
publicfunctiongetNewestUsers($count)
{
$data=$this->db->query('SELECT username, displayname, profile_picture, date_created, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users ORDER BY date_created DESC LIMIT ?',[$count])->result_array();
$data=$this->db->query('SELECT username, displayname, profile_picture, header_image, about, rank FROM users WHERE '.$dbClause.' LIMIT ? OFFSET ?',$inputs)->result_array();
$data=$this->setDefaultImages($data);
$data=$this->setRankname($data);
return$data;
}
publicfunctiongetAvailableCountries(){
return$this->db->query('SELECT country, count(*) countryUserCount FROM users WHERE country IS NOT NULL AND country != "" GROUP BY country ORDER BY country')->result_array();
}
publicfunctiongetAvailableLanguages(){
return$this->db->query('SELECT language, count(*) langUserCount FROM users GROUP BY language ORDER BY language')->result_array();