diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php
index d5726f25..2e0d0ce5 100644
--- a/Web/Models/Entities/User.php
+++ b/Web/Models/Entities/User.php
@@ -500,6 +500,16 @@ class User extends RowModel
return $this->_abstractRelationCount("get-friends");
}
+ function getFriendsOnline(int $page = 1, int $limit = 6): \Traversable
+ {
+ return $this->_abstractRelationGenerator("get-online-friends", $page, $limit);
+ }
+
+ function getFriendsOnlineCount(): int
+ {
+ return $this->_abstractRelationCount("get-online-friends");
+ }
+
function getFollowers(int $page = 1, int $limit = 6): \Traversable
{
return $this->_abstractRelationGenerator("get-followers", $page, $limit);
diff --git a/Web/Models/sql/get-online-friends.tsql b/Web/Models/sql/get-online-friends.tsql
new file mode 100755
index 00000000..ad646554
--- /dev/null
+++ b/Web/Models/sql/get-online-friends.tsql
@@ -0,0 +1,6 @@
+ (SELECT follower AS __id FROM
+ (SELECT follower FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
+ INNER JOIN
+ (SELECT target FROM subscriptions WHERE follower=? AND model="openvk\\Web\\Models\\Entities\\User") u1
+ ON u0.follower = u1.target) u2
+INNER JOIN profiles ON profiles.id = u2.__id WHERE online > (UNIX_TIMESTAMP() - 300)
\ No newline at end of file
diff --git a/Web/Presenters/templates/User/Friends.xml b/Web/Presenters/templates/User/Friends.xml
index e96c1ff8..0c06dd8f 100644
--- a/Web/Presenters/templates/User/Friends.xml
+++ b/Web/Presenters/templates/User/Friends.xml
@@ -9,6 +9,9 @@
{elseif $act == "outcoming"}
{var $iterator = iterator_to_array($user->getSubscriptions($page))}
{var $count = $user->getSubscriptionsCount()}
+{elseif $act == "online"}
+ {var $iterator = iterator_to_array($user->getFriendsOnline($page))}
+ {var $count = $user->getFriendsOnlineCount()}
{else}
{var $iterator = iterator_to_array($user->getFriends($page))}
{var $count = $user->getFriendsCount()}
@@ -19,6 +22,8 @@
{_"incoming_req"}
{elseif $act == "outcoming"}
{_"outcoming_req"}
+ {elseif $act == "online"}
+ {_"friends_online"}
{else}
{_"friends"}
{/if}
@@ -33,6 +38,8 @@
{_"incoming_req"}
{elseif $act == "outcoming"}
{_"outcoming_req"}
+ {elseif $act == "online"}
+ {_"friends_online"}
{else}
{_"friends"}
{/if}
@@ -41,7 +48,10 @@
{block tabs}
+
{_req}
@@ -68,6 +78,8 @@
{tr("req", $count)}
{elseif $act == "outcoming"}
{tr("req", $count)}
+ {elseif $act == "online"}
+ {tr("friends_list_online", $count)}
{else}
{tr("friends_list", $count)}
{/if}
diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml
index 0daeb946..cd85c76b 100644
--- a/Web/Presenters/templates/User/View.xml
+++ b/Web/Presenters/templates/User/View.xml
@@ -201,6 +201,34 @@
+
+ {var $friendOnlineCount = $user->getFriendsOnlineCount()}
+
+
+ {_"friends_online"}
+
+
+
+ {tr("friends_online", $friendOnlineCount)}
+
+
+
+
+
{_"albums"}
diff --git a/locales/en.strings b/locales/en.strings
index ef6fdf43..d1b35a2e 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -209,6 +209,8 @@
"incoming_req" = "Pending";
"outcoming_req" = "Outgoing";
"req" = "Requests";
+"friends_online" = "Friends online";
+"all_friends" = "All friends";
"req_zero" = "No requests were found...";
"req_one" = "Found $1 request";
@@ -218,10 +220,18 @@
"friends_one" = "$1 friend";
"friends_other" = "$1 friends";
+"friends_online_zero" = "No friends online";
+"friends_online_one" = "$1 friend is online";
+"friends_online_other" = "$1 friends are online";
+
"friends_list_zero" = "You have no friends yet";
"friends_list_one" = "You have $1 friend";
"friends_list_other" = "You have $1 friends";
+"friends_list_online_zero" = "You have no friends online";
+"friends_list_online_one" = "You have $1 friend online";
+"friends_list_online_other" = "You have $1 friends online";
+
"followers_zero" = "No followers";
"followers_one" = "$1 follower";
"followers_other" = "$1 followers";
diff --git a/locales/ru.strings b/locales/ru.strings
index 4b9be95c..0ffa0b78 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -216,6 +216,8 @@
"incoming_req" = "Входящие";
"outcoming_req" = "Исходящие";
"req" = "Заявки";
+"friends_online" = "Друзья он-лайн";
+"all_friends" = "Все друзья";
"req_zero" = "Не найдено ни одной заявки...";
"req_one" = "Найдена $1 заявка";
@@ -229,6 +231,12 @@
"friends_many" = "$1 друзей";
"friends_other" = "$1 друзей";
+"friends_online_zero" = "Ни одного друга он-лайн";
+"friends_online_one" = "$1 друг он-лайн";
+"friends_online_few" = "$1 друга он-лайн";
+"friends_online_many" = "$1 друзей он-лайн";
+"friends_online_other" = "$1 друзей он-лайн";
+
"friends_list_zero" = "У Вас пока нет друзей";
"friends_list_one" = "У Вас $1 друг";
"friends_list_few" = "У Вас $1 друга";
@@ -247,6 +255,12 @@
"subscriptions_many" = "$1 подписок";
"subscriptions_other" = "$1 подписок";
+"friends_list_online_zero" = "У Вас пока нет друзей он-лайн";
+"friends_list_online_one" = "У Вас $1 друг он-лайн";
+"friends_list_online_few" = "У Вас $1 друга он-лайн";
+"friends_list_online_many" = "У Вас $1 друзей он-лайн";
+"friends_list_online_other" = "У Вас $1 друзей он-лайн";
+
/* Group */
"name_group" = "Название";