mirror of
https://github.com/openvk/openvk
synced 2024-11-15 11:39:13 +03:00
Compare commits
5 commits
179664a63b
...
ee3a587805
Author | SHA1 | Date | |
---|---|---|---|
|
ee3a587805 | ||
|
bbef3a8518 | ||
|
c5644a51d6 | ||
|
4c78617a9c | ||
89157a832b |
21 changed files with 136 additions and 46 deletions
|
@ -147,7 +147,7 @@ final class Friends extends VKAPIRequestHandler
|
|||
return $response;
|
||||
}
|
||||
|
||||
function getRequests(string $fields = "", int $offset = 0, int $count = 100, int $extended = 0): object
|
||||
function getRequests(string $fields = "", int $out = 0, int $offset = 0, int $count = 100, int $extended = 0): object
|
||||
{
|
||||
if ($count >= 1000)
|
||||
$this->fail(100, "One of the required parameters was not passed or is invalid.");
|
||||
|
@ -158,10 +158,19 @@ final class Friends extends VKAPIRequestHandler
|
|||
$offset++;
|
||||
$followers = [];
|
||||
|
||||
if ($out != 0) {
|
||||
foreach($this->getUser()->getFollowers($offset, $count) as $follower) {
|
||||
$followers[$i] = $follower->getId();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->getUser()->getRequests($offset, $count) as $follower) {
|
||||
$followers[$i] = $follower->getId();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$response = $followers;
|
||||
$usersApi = new Users($this->getUser());
|
||||
|
|
|
@ -39,4 +39,25 @@ trait TSubscribable
|
|||
$sub->delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
function changeFlags(User $user, int $flags, bool $reverse): bool
|
||||
{
|
||||
$ctx = DatabaseConnection::i()->getContext();
|
||||
$data = [
|
||||
"follower" => $reverse ? $this->getId() : $user->getId(),
|
||||
"model" => static::class,
|
||||
"target" => $reverse ? $user->getId() : $this->getId(),
|
||||
];
|
||||
$sub = $ctx->table("subscriptions")->where($data);
|
||||
|
||||
bdump($data);
|
||||
|
||||
if (!$sub)
|
||||
return false;
|
||||
|
||||
$sub->update([
|
||||
'flags' => $flags
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,6 +592,16 @@ class User extends RowModel
|
|||
return $this->_abstractRelationCount("get-followers");
|
||||
}
|
||||
|
||||
function getRequests(int $page = 1, int $limit = 6): \Traversable
|
||||
{
|
||||
return $this->_abstractRelationGenerator("get-requests", $page, $limit);
|
||||
}
|
||||
|
||||
function getRequestsCount(): int
|
||||
{
|
||||
return $this->_abstractRelationCount("get-requests");
|
||||
}
|
||||
|
||||
function getSubscriptions(int $page = 1, int $limit = 6): \Traversable
|
||||
{
|
||||
return $this->_abstractRelationGenerator("get-subscriptions-user", $page, $limit);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(SELECT DISTINCT(follower) AS __id FROM
|
||||
(SELECT follower FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
(SELECT follower, flags FROM subscriptions WHERE target=? AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
LEFT JOIN
|
||||
(SELECT target FROM subscriptions WHERE follower=? AND model="openvk\\Web\\Models\\Entities\\User") u1
|
||||
ON u0.follower = u1.target WHERE u1.target IS NULL) u2
|
||||
|
|
6
Web/Models/sql/get-requests.tsql
Executable file
6
Web/Models/sql/get-requests.tsql
Executable file
|
@ -0,0 +1,6 @@
|
|||
(SELECT DISTINCT(follower) AS __id FROM
|
||||
(SELECT follower FROM subscriptions WHERE target=? AND flags=0 AND model="openvk\\Web\\Models\\Entities\\User") u0
|
||||
LEFT JOIN
|
||||
(SELECT target FROM subscriptions WHERE follower=? AND flags=0 AND model="openvk\\Web\\Models\\Entities\\User") u1
|
||||
ON u0.follower = u1.target WHERE u1.target IS NULL) u2
|
||||
INNER JOIN profiles ON profiles.id = u2.__id
|
|
@ -329,9 +329,12 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$user = $this->users->get((int) $this->postParam("id"));
|
||||
if(!$user) exit("Invalid state");
|
||||
|
||||
if ($this->postParam("act") == "rej")
|
||||
$user->changeFlags($this->user->identity, 0b10000000, true);
|
||||
else
|
||||
$user->toggleSubscription($this->user->identity);
|
||||
|
||||
$this->redirect($user->getURL());
|
||||
$this->redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
function renderSetAvatar()
|
||||
|
|
|
@ -178,9 +178,9 @@
|
|||
<a href="/edit" class="link edit-button">{_edit_button}</a>
|
||||
<a href="{$thisUser->getURL()}" class="link" title="{_my_page} [Alt+Shift+.]" accesskey=".">{_my_page}</a>
|
||||
<a href="/friends{$thisUser->getId()}" class="link">{_my_friends}
|
||||
<object type="internal/link" n:if="$thisUser->getFollowersCount() > 0">
|
||||
<object type="internal/link" n:if="$thisUser->getRequestsCount() > 0">
|
||||
<a href="/friends{$thisUser->getId()}?act=incoming" class="linkunderline">
|
||||
(<b>{$thisUser->getFollowersCount()}</b>)
|
||||
(<b>{$thisUser->getRequestsCount()}</b>)
|
||||
</a>
|
||||
</object>
|
||||
</a>
|
||||
|
@ -403,13 +403,6 @@
|
|||
{script "js/al_notifs.js"}
|
||||
{/ifset}
|
||||
|
||||
{if OPENVK_ROOT_CONF['openvk']['preferences']['bellsAndWhistles']['fartscroll']}
|
||||
<script src="https://unpkg.com/fartscroll@1.0.0/fartscroll.js"></script>
|
||||
<script>
|
||||
fartscroll(400);
|
||||
</script>
|
||||
{/if}
|
||||
|
||||
<script>bsdnHydrate();</script>
|
||||
|
||||
<script n:if="OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['enable']" async defer data-domain="{php echo OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['domain']}" src="{php echo OPENVK_ROOT_CONF['openvk']['telemetry']['plausible']['server']}js/plausible.js"></script>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
{include description, x => $dat}
|
||||
{/ifset}
|
||||
</td>
|
||||
<td n:ifset="actions" valign="top" class="action_links" style="width: 150px;">
|
||||
<td n:ifset="actions" valign="top" class="action_links" style="min-width: 150px;">
|
||||
{include actions, x => $dat}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -255,17 +255,6 @@
|
|||
Disabled
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">
|
||||
Fartscroll
|
||||
</td>
|
||||
<td class="v">
|
||||
{php echo OPENVK_ROOT_CONF["openvk"]["preferences"]["bellsAndWhistles"]["fartscroll"] ? "Enabled" : "Disabled"}
|
||||
</td>
|
||||
<td class="v">
|
||||
Disabled
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="e">
|
||||
NDA Test Label
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
{var $act = $_GET["act"] ?? "friends"}
|
||||
|
||||
{if $act == "incoming"}
|
||||
{var $iterator = iterator_to_array($user->getFollowers($page))}
|
||||
{var $count = $user->getFollowersCount()}
|
||||
{var $iterator = iterator_to_array($user->getRequests($page))}
|
||||
{var $count = $user->getRequestsCount()}
|
||||
{elseif $act == "outcoming"}
|
||||
{var $iterator = iterator_to_array($user->getSubscriptions($page))}
|
||||
{var $count = $user->getSubscriptionsCount()}
|
||||
{elseif $act == "followers"}
|
||||
{var $iterator = iterator_to_array($user->getFollowers($page))}
|
||||
{var $count = $user->getFollowersCount()}
|
||||
{elseif $act == "online"}
|
||||
{var $iterator = iterator_to_array($user->getFriendsOnline($page))}
|
||||
{var $count = $user->getFriendsOnlineCount()}
|
||||
|
@ -22,6 +25,8 @@
|
|||
{_incoming_req}
|
||||
{elseif $act == "outcoming"}
|
||||
{_outcoming_req}
|
||||
{elseif $act == "followers"}
|
||||
{_followers}
|
||||
{elseif $act == "online"}
|
||||
{_friends_online}
|
||||
{else}
|
||||
|
@ -38,6 +43,8 @@
|
|||
{_incoming_req}
|
||||
{elseif $act == "outcoming"}
|
||||
{_outcoming_req}
|
||||
{elseif $act == "followers"}
|
||||
{_followers}
|
||||
{elseif $act == "online"}
|
||||
{_friends_online}
|
||||
{else}
|
||||
|
@ -53,18 +60,23 @@
|
|||
<div n:attr="id => ($act === 'online' ? 'activetabs' : 'ki')" class="tab">
|
||||
<a n:attr="id => ($act === 'online' ? 'act_tab_a' : 'ki')" href="?act=online">{_online}</a>
|
||||
</div>
|
||||
<div n:if="!is_null($thisUser) && $user->getId() === $thisUser->getId()" n:attr="id => ($act === 'incoming' || $act === 'outcoming' ? 'activetabs' : 'ki')" class="tab">
|
||||
<a n:attr="id => ($act === 'incoming' || $act === 'outcoming' ? 'act_tab_a' : 'ki')" href="?act=incoming">{_req}</a>
|
||||
<div n:if="!is_null($thisUser) && $user->getId() === $thisUser->getId()" n:attr="id => ($act === 'incoming' || $act === 'followers' || $act === 'outcoming' ? 'activetabs' : 'ki')" class="tab">
|
||||
<a n:attr="id => ($act === 'incoming' || $act === 'followers' || $act === 'outcoming' ? 'act_tab_a' : 'ki')" href="?act=incoming">{_req}</a>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block size}
|
||||
<div n:if="$act === 'incoming' || $act === 'outcoming'" class="mb_tabs">
|
||||
<div n:if="$act === 'incoming' || $act === 'followers' || $act === 'outcoming'" class="mb_tabs">
|
||||
<div n:attr="id => ($act === 'incoming' ? 'active' : 'ki')" class="mb_tab">
|
||||
<div>
|
||||
<a href="?act=incoming">{_incoming_req}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div n:attr="id => ($act === 'followers' ? 'active' : 'ki')" class="mb_tab">
|
||||
<div>
|
||||
<a href="?act=followers">{_followers}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div n:attr="id => ($act === 'outcoming' ? 'active' : 'ki')" class="mb_tab">
|
||||
<div>
|
||||
<a href="?act=outcoming">{_outcoming_req}</a>
|
||||
|
@ -78,6 +90,8 @@
|
|||
{tr("req", $count)}
|
||||
{elseif $act == "outcoming"}
|
||||
{tr("req", $count)}
|
||||
{elseif $act == "followers"}
|
||||
{tr("followers", $count)}
|
||||
{elseif $act == "online"}
|
||||
{tr("friends_list_online", $count)}
|
||||
{else}
|
||||
|
@ -131,21 +145,29 @@
|
|||
{if ($x->getId() !== $thisUser->getId()) && ($thisUser->getId() === $user->getId())}
|
||||
{var $subStatus = $x->getSubscriptionStatus($thisUser)}
|
||||
{if $subStatus === 0}
|
||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
||||
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||
<input type="hidden" name="act" value="add" />
|
||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
<input type="submit" class="profile_link" value="{_friends_add}" />
|
||||
</form>
|
||||
{elseif $subStatus === 1}
|
||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
||||
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||
<input type="hidden" name="act" value="add" />
|
||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
<input type="submit" class="profile_link" value="{_friends_accept}" />
|
||||
</form>
|
||||
{if $act !== 'followers'}
|
||||
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||
<input type="hidden" name="act" value="rej" />
|
||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
<input type="submit" class="profile_link" value="{_friends_leave_in_flw}" />
|
||||
</form>
|
||||
{/if}
|
||||
{elseif $subStatus === 2}
|
||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
||||
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||
<input type="hidden" name="act" value="rem" />
|
||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
|
@ -153,7 +175,7 @@
|
|||
</form>
|
||||
{elseif $subStatus === 3}
|
||||
<a href="/im?sel={$x->getId()}" class="profile_link">{_send_message}</a>
|
||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
||||
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||
<input type="hidden" name="act" value="rem" />
|
||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
|
|
|
@ -427,6 +427,22 @@ h1 {
|
|||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
.action_links.disable>a,
|
||||
.action_links.disable>form>input,
|
||||
.action_links.disable {
|
||||
cursor: not-allowed;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
.action_links.loading::after {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
background-image: url('/assets/packages/static/openvk/img/loading_mini.gif');
|
||||
width: 30px;
|
||||
height: 7px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.profile_link.disable>a,
|
||||
.profile_link.disable {
|
||||
cursor: not-allowed;
|
||||
|
@ -2068,20 +2084,17 @@ table td[width="120"] {
|
|||
font-weight: bold;
|
||||
margin-right: 10px;
|
||||
display: inline-block;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.mb_tab div {
|
||||
padding: 3px 7px;
|
||||
padding: 5px 9px;
|
||||
}
|
||||
|
||||
.mb_tab#active {
|
||||
background-color: #898989;
|
||||
}
|
||||
|
||||
.mb_tab#active div {
|
||||
border: 2px solid #5f5f5f;
|
||||
}
|
||||
|
||||
.mb_tab#active a {
|
||||
color: white;
|
||||
}
|
||||
|
|
|
@ -167,6 +167,23 @@ document.addEventListener("DOMContentLoaded", function() { //BEGIN
|
|||
return false;
|
||||
});
|
||||
|
||||
u("#_submitUserSubscriptionAction").handle("submit", async function(e) {
|
||||
u(this).nodes[0].parentElement.classList.add('loading');
|
||||
u(this).nodes[0].parentElement.classList.add('disable');
|
||||
console.log(e.target);
|
||||
const data = await fetch(u(this).attr('action'), { method: 'POST', body: new FormData(e.target) });
|
||||
if (data.ok) {
|
||||
u(this).nodes[0].parentElement.classList.remove('loading');
|
||||
u(this).nodes[0].parentElement.classList.remove('disable');
|
||||
if (e.target[0].value == "add") {
|
||||
u(this).nodes[0].parentElement.innerHTML = tr("friends_add_msg");
|
||||
} else if (e.target[0].value == "rej") {
|
||||
u(this).nodes[0].parentElement.innerHTML = tr("friends_rej_msg");
|
||||
} else if (e.target[0].value == "rem") {
|
||||
u(this).nodes[0].parentElement.innerHTML = tr("friends_rem_msg");
|
||||
}
|
||||
}
|
||||
})
|
||||
}); //END ONREADY DECLS
|
||||
|
||||
async function repostPost(id, hash) {
|
||||
|
|
|
@ -63,7 +63,6 @@ openvk:
|
|||
caption: "Ad caption"
|
||||
link: "https://example.org/product.aspx?id=10&from=ovk"
|
||||
bellsAndWhistles:
|
||||
fartscroll: false
|
||||
testLabel: false
|
||||
defaultMobileTheme: ""
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ openvk:
|
|||
caption: "Ad caption"
|
||||
link: "https://example.org/product.aspx?id=10&from=ovk"
|
||||
bellsAndWhistles:
|
||||
fartscroll: false
|
||||
testLabel: false
|
||||
defaultMobileTheme: ""
|
||||
defaultFeaturePhoneTheme: ""
|
||||
|
|
|
@ -97,7 +97,6 @@ data:
|
|||
caption: "Ad caption"
|
||||
link: "https://example.org/product.aspx?id=10&from=ovk"
|
||||
bellsAndWhistles:
|
||||
fartscroll: false
|
||||
testLabel: false
|
||||
defaultMobileTheme: ""
|
||||
|
||||
|
|
1
install/sqls/00046-deny-request.sql
Executable file
1
install/sqls/00046-deny-request.sql
Executable file
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `subscriptions` ADD `flags` tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER `target`
|
|
@ -131,6 +131,7 @@
|
|||
"friends_delete" = "Выдаліць з сяброў";
|
||||
"friends_reject" = "Адмяніць заяўку";
|
||||
"friends_accept" = "Прыняць заяўку";
|
||||
"friends_leave_in_flw" = "Пакінуть у падпісчыках";
|
||||
"send_message" = "Адправіць паведамленне";
|
||||
"incoming_req" = "Падпісанты";
|
||||
"outcoming_req" = "Заяўкі";
|
||||
|
|
|
@ -259,6 +259,10 @@
|
|||
"friends_delete" = "Remove from friends";
|
||||
"friends_reject" = "Reject request";
|
||||
"friends_accept" = "Accept request";
|
||||
"friends_leave_in_flw" = "Leave in followers";
|
||||
"friends_add_msg" = "Now you're friends.";
|
||||
"friends_rej_msg" = "You left this user as subscriber.";
|
||||
"friends_rem_msg" = "You deleted this user from your friend list.";
|
||||
"send_message" = "Send a message";
|
||||
"incoming_req" = "Pending";
|
||||
"outcoming_req" = "Outgoing";
|
||||
|
|
|
@ -239,6 +239,10 @@
|
|||
"friends_delete" = "Удалить из друзей";
|
||||
"friends_reject" = "Отменить заявку";
|
||||
"friends_accept" = "Принять заявку";
|
||||
"friends_leave_in_flw" = "Оставить в подписчиках";
|
||||
"friends_add_msg" = "Теперь вы друзья.";
|
||||
"friends_rej_msg" = "Вы оставили пользователя в подписчиках.";
|
||||
"friends_rem_msg" = "Вы удалили пользователя из списка своих друзей.";
|
||||
"send_message" = "Отправить сообщение";
|
||||
"incoming_req" = "Входящие";
|
||||
"outcoming_req" = "Исходящие";
|
||||
|
|
|
@ -213,6 +213,7 @@
|
|||
"friends_delete" = "Видалити з друзів";
|
||||
"friends_reject" = "Скасувати заявку";
|
||||
"friends_accept" = "Прийняти заявку";
|
||||
"friends_leave_in_flw" = "Залишити у підписниках";
|
||||
"send_message" = "Відправити повідомлення";
|
||||
"incoming_req" = "Підписники";
|
||||
"outcoming_req" = "Вихідні";
|
||||
|
|
|
@ -101,7 +101,6 @@ openvk:
|
|||
caption: "Ad caption"
|
||||
link: "https://example.org/product.aspx?id=10&from=ovk"
|
||||
bellsAndWhistles:
|
||||
fartscroll: false
|
||||
testLabel: false
|
||||
defaultMobileTheme: ""
|
||||
defaultFeaturePhoneTheme: ""
|
||||
|
|
Loading…
Reference in a new issue