diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php
index cc8e5393..7dc68f3b 100644
--- a/VKAPI/Handlers/Users.php
+++ b/VKAPI/Handlers/Users.php
@@ -52,8 +52,6 @@ final class Users extends VKAPIRequestHandler
"last_name" => $usr->getLastName(true),
"is_closed" => $usr->isClosed(),
"can_access_closed" => (bool)$usr->canBeViewedBy($this->getUser()),
- "blacklisted" => false,
- "blacklisted_by_me" => false,
];
$flds = explode(',', $fields);
@@ -268,6 +266,20 @@ final class Users extends VKAPIRequestHandler
case 'nickname':
$response[$i]->nickname = $usr->getPseudo();
break;
+ case 'blacklisted_by_me':
+ if(!$authuser) {
+ continue;
+ }
+
+ $response[$i]->blacklisted_by_me = (int)$usr->isBlacklistedBy($this->getUser());
+ break;
+ case 'blacklisted':
+ if(!$authuser) {
+ continue;
+ }
+
+ $response[$i]->blacklisted = (int)$this->getUser()->isBlacklistedBy($usr);
+ break;
}
}
diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php
index 03b2fe5f..c74a2538 100644
--- a/Web/Models/Entities/User.php
+++ b/Web/Models/Entities/User.php
@@ -511,7 +511,7 @@ class User extends RowModel
else if($user->getId() === $this->getId())
return true;
- if($permission != "messages.write" && !$this->canBeViewedBy($user))
+ if(/*$permission != "messages.write" && */!$this->canBeViewedBy($user, true))
return false;
switch($permStatus) {
@@ -1301,7 +1301,7 @@ class User extends RowModel
return true;
}
- if($user->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)) {
+ if($user->isAdmin() && !(OPENVK_ROOT_CONF['openvk']['preferences']['blacklists']['applyToAdmins'] ?? true)) {
return true;
}
@@ -1517,6 +1517,18 @@ class User extends RowModel
"target" => $user->getRealId(),
"created" => time(),
]);
+
+ DatabaseConnection::i()->getContext()->table("subscriptions")->where([
+ "follower" => $user->getId(),
+ "model" => static::class,
+ "target" => $this->getId(),
+ ])->delete();
+
+ DatabaseConnection::i()->getContext()->table("subscriptions")->where([
+ "follower" => $this->getId(),
+ "model" => static::class,
+ "target" => $user->getId(),
+ ])->delete();
return true;
}
diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php
index 61b6d67c..fd0e9a3d 100644
--- a/Web/Presenters/GroupPresenter.php
+++ b/Web/Presenters/GroupPresenter.php
@@ -119,7 +119,7 @@ final class GroupPresenter extends OpenVKPresenter
$this->template->paginatorConf = (object) [
"count" => $this->template->count,
"page" => $this->queryParam("p") ?? 1,
- "amount" => NULL,
+ "amount" => 10,
"perPage" => OPENVK_DEFAULT_PER_PAGE,
];
}
diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php
index 0f617f9b..e253f4bb 100644
--- a/Web/Presenters/UserPresenter.php
+++ b/Web/Presenters/UserPresenter.php
@@ -34,6 +34,12 @@ final class UserPresenter extends OpenVKPresenter
if(!is_null($user) && $user->isDeactivated()) {
$this->template->_template = "User/deactivated.xml";
+ $this->template->user = $user;
+ } else if($user->isBlacklistedBy($this->user->identity)) {
+ $this->template->_template = "User/blacklisted_pov.xml";
+ $this->template->user = $user;
+ } else if($this->user->identity->isBlacklistedBy($user)) {
+ $this->template->_template = "User/blacklisted.xml";
$this->template->user = $user;
} else if(!is_null($user) && !$user->canBeViewedBy($this->user->identity)) {
$this->template->_template = "User/private.xml";
@@ -58,6 +64,7 @@ final class UserPresenter extends OpenVKPresenter
if($id !== $this->user->id) {
$this->template->ignore_status = $user->isIgnoredBy($this->user->identity);
+ $this->template->blacklist_status = $user->isBlacklistedBy($this->user->identity);
}
}
}
@@ -579,7 +586,7 @@ final class UserPresenter extends OpenVKPresenter
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
}
$this->template->mode = in_array($this->queryParam("act"), [
- "main", "security", "privacy", "finance", "finance.top-up", "interface"
+ "main", "security", "privacy", "finance", "finance.top-up", "interface", "blacklist"
]) ? $this->queryParam("act")
: "main";
@@ -592,6 +599,19 @@ final class UserPresenter extends OpenVKPresenter
$this->template->qrCodeType = substr($qrCode[0], 5);
$this->template->qrCodeData = $qrCode[1];
+ } else if($this->template->mode === "blacklist") {
+ $page = (int)($this->queryParam('p') ?? 1);
+ $count = 10;
+ $offset = ($page - 1) * $count;
+
+ $this->template->blSize = $this->user->identity->getBlacklistSize();
+ $this->template->blItems = $this->user->identity->getBlacklist($offset, $count);
+ $this->template->paginatorConf = (object) [
+ "count" => $this->template->blSize,
+ "page" => $page,
+ "amount" => sizeof($this->template->blItems),
+ "perPage" => OPENVK_DEFAULT_PER_PAGE,
+ ];
}
$this->template->user = $user;
diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml
index 9e9f091b..e7f4b5ac 100644
--- a/Web/Presenters/templates/User/Settings.xml
+++ b/Web/Presenters/templates/User/Settings.xml
@@ -13,6 +13,7 @@
{var $isFinance = $mode === 'finance'}
{var $isFinanceTU = $mode === 'finance.top-up'}
{var $isInterface = $mode === 'interface'}
+{var $isBl = $mode === 'blacklist'}
@@ -24,6 +25,9 @@
+
@@ -713,6 +717,29 @@
+ {elseif $isBl}
+ {if $blSize < 1}
+ {include "../components/error.xml", description => tr("bl_count_zero_desc")}
+ {else}
+
{tr("bl_count", $blSize)}.
+
+ {include "../components/paginator.xml", conf => $paginatorConf}
+ {/if}
{/if}
diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml
index 10801053..b4625f68 100644
--- a/Web/Presenters/templates/User/View.xml
+++ b/Web/Presenters/templates/User/View.xml
@@ -166,6 +166,7 @@
{/if}
{_report}
+
{_bl_add}
{if !$ignore_status}{_ignore_user}{else}{_unignore_user}{/if}
diff --git a/Web/Presenters/templates/User/blacklisted.xml b/Web/Presenters/templates/User/blacklisted.xml
new file mode 100644
index 00000000..c88a24dc
--- /dev/null
+++ b/Web/Presenters/templates/User/blacklisted.xml
@@ -0,0 +1,37 @@
+{extends "../@layout.xml"}
+{block title}{$user->getCanonicalName()}{/block}
+
+{block header}
+ {$user->getCanonicalName()}
+
+{/block}
+
+{block content}
+
+
+
+
+
+
+
+
+
+
+
+
{$user->getFullName()}
+
+
+
+ {var $m = $user->isFemale() ? "f" : "m"}
+ {tr("limited_access_to_page_$m", $user->getFirstName())}
+
+
+
+{/block}
diff --git a/Web/Presenters/templates/User/blacklisted_pov.xml b/Web/Presenters/templates/User/blacklisted_pov.xml
new file mode 100644
index 00000000..1fcd2fca
--- /dev/null
+++ b/Web/Presenters/templates/User/blacklisted_pov.xml
@@ -0,0 +1,37 @@
+{extends "../@layout.xml"}
+{block title}{$user->getCanonicalName()}{/block}
+
+{block header}
+ {$user->getCanonicalName()}
+
+{/block}
+
+{block content}
+
+
+
+
+
+
+
+
+
+
+
+
{$user->getFullName()}
+
+
+
+ {tr("you_blacklisted", $user->getMorphedName("genitive", false))}.
+
+
+
+{/block}
diff --git a/Web/static/css/main.css b/Web/static/css/main.css
index 8f465432..82c8e6eb 100644
--- a/Web/static/css/main.css
+++ b/Web/static/css/main.css
@@ -3597,6 +3597,11 @@ hr {
overflow-y: auto;
}
+.entity_vertical_list.scroll_container {
+ height: unset;
+ overflow-y: unset;
+}
+
.entity_vertical_list .entity_vertical_list_item {
display: flex;
flex-direction: row;
@@ -3611,6 +3616,15 @@ hr {
gap: 4px;
}
+.entity_vertical_list.m_mini .entity_vertical_list_item .first_column {
+ gap: 10px;
+}
+
+.entity_vertical_list.m_mini .entity_vertical_list_item .first_column .avatar img {
+ width: 30px;
+ height: 30px;
+}
+
.entity_vertical_list .entity_vertical_list_item .avatar {
display: block;
}
diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js
index 95aeebeb..5cecddb0 100644
--- a/Web/static/js/al_wall.js
+++ b/Web/static/js/al_wall.js
@@ -2587,3 +2587,42 @@ async function changeStatus() {
document.status_popup_form.submit.innerHTML = tr("send");
document.status_popup_form.submit.disabled = false;
}
+
+u(document).on('click', '#_bl_toggler', async (e) => {
+ e.preventDefault()
+
+ const target = u(e.target)
+ const val = Number(target.attr('data-val'))
+ const id = Number(target.attr('data-id'))
+ const name = target.attr('data-name')
+
+ const fallback = (e) => {
+ fastError(e.message)
+ target.removeClass('lagged')
+ }
+
+ if(val == 1) {
+ const msg = new CMessageBox({
+ title: tr('addition_to_bl'),
+ body: `
${escapeHtml(tr('adding_to_bl_sure', name))}`,
+ buttons: [tr('yes'), tr('no')],
+ callbacks: [async () => {
+ try {
+ target.addClass('lagged')
+ await window.OVKAPI.call('account.ban', {'owner_id': id})
+ window.router.route(location.href)
+ } catch(e) {
+ fallback(e)
+ }
+ }, () => Function.noop]
+ })
+ } else {
+ try {
+ target.addClass('lagged')
+ await window.OVKAPI.call('account.unban', {'owner_id': id})
+ window.router.route(location.href)
+ } catch(e) {
+ fallback(e)
+ }
+ }
+})
diff --git a/Web/static/js/router.js b/Web/static/js/router.js
index d72249c5..0d748f07 100644
--- a/Web/static/js/router.js
+++ b/Web/static/js/router.js
@@ -289,6 +289,10 @@ u(document).on('click', 'a', async (e) => {
})
u(document).on('submit', 'form', async (e) => {
+ if(e.defaultPrevented) {
+ return
+ }
+
if(u('#ajloader').hasClass('shown')) {
e.preventDefault()
return
diff --git a/locales/en.strings b/locales/en.strings
index 1ce0cc14..cdf6ff26 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -1823,6 +1823,21 @@
"user_blacklisted" = "$1 has been blacklisted";
"user_removed_from_the_blacklist" = "$1 has been removed from the blacklist.";
+"adding_to_bl_sure" = "You sure you want to blacklist $1?";
+
+"bl_count_zero_desc" = "There are no users on your blacklist yet.";
+"bl_count_zero" = "There are no users on your blacklist";
+"bl_count_one" = "You have one user on your blacklist";
+"bl_count_few" = "You have $1 users on your blacklist";
+"bl_count_many" = "You have $1 users on your blacklist";
+"bl_count_other" = "You have $1 users on your blacklist";
+
+"you_blacklisted" = "You blacklisted $1";
+"bl_add" = "Add to blacklist";
+"bl_remove" = "Remove from blacklist";
+
+"addition_to_bl" = "Addition to blacklist";
+
/* Away */
"transition_is_blocked" = "Transition is blocked";
diff --git a/locales/ru.strings b/locales/ru.strings
index 2fce1af5..67e8116d 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -1719,6 +1719,21 @@
"user_blacklisted" = "$1 занесён в чёрный список.";
"user_removed_from_the_blacklist" = "$1 удалён из чёрного списка.";
+"adding_to_bl_sure" = "Вы уверены, что хотите внести $1 в чёрный список?";
+
+"bl_count_zero_desc" = "В вашем чёрном списке ещё нет пользователей.";
+"bl_count_zero" = "В вашем чёрном списке нет пользователей";
+"bl_count_one" = "В вашем чёрном списке один пользователь";
+"bl_count_few" = "В вашем чёрном списке $1 пользователя";
+"bl_count_many" = "В вашем чёрном списке $1 пользователей";
+"bl_count_other" = "В вашем чёрном списке $1 пользователей";
+
+"you_blacklisted" = "Вы внесли $1 в чёрный список";
+"bl_add" = "Добавить в чёрный список";
+"bl_remove" = "Удалить из чёрного списка";
+
+"addition_to_bl" = "Добавление в чёрный список";
+
/* Away */
"transition_is_blocked" = "Переход по ссылке заблокирован";