rewrite ui

This commit is contained in:
mrilyew 2024-12-11 20:50:24 +03:00
parent 4ac2958e90
commit 39cd4fe217
13 changed files with 239 additions and 6 deletions

View file

@ -52,8 +52,6 @@ final class Users extends VKAPIRequestHandler
"last_name" => $usr->getLastName(true), "last_name" => $usr->getLastName(true),
"is_closed" => $usr->isClosed(), "is_closed" => $usr->isClosed(),
"can_access_closed" => (bool)$usr->canBeViewedBy($this->getUser()), "can_access_closed" => (bool)$usr->canBeViewedBy($this->getUser()),
"blacklisted" => false,
"blacklisted_by_me" => false,
]; ];
$flds = explode(',', $fields); $flds = explode(',', $fields);
@ -268,6 +266,20 @@ final class Users extends VKAPIRequestHandler
case 'nickname': case 'nickname':
$response[$i]->nickname = $usr->getPseudo(); $response[$i]->nickname = $usr->getPseudo();
break; 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;
} }
} }

View file

@ -511,7 +511,7 @@ class User extends RowModel
else if($user->getId() === $this->getId()) else if($user->getId() === $this->getId())
return true; return true;
if($permission != "messages.write" && !$this->canBeViewedBy($user)) if(/*$permission != "messages.write" && */!$this->canBeViewedBy($user, true))
return false; return false;
switch($permStatus) { switch($permStatus) {
@ -1301,7 +1301,7 @@ class User extends RowModel
return true; return true;
} }
if($user->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)) { if($user->isAdmin() && !(OPENVK_ROOT_CONF['openvk']['preferences']['blacklists']['applyToAdmins'] ?? true)) {
return true; return true;
} }
@ -1517,6 +1517,18 @@ class User extends RowModel
"target" => $user->getRealId(), "target" => $user->getRealId(),
"created" => time(), "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; return true;
} }

View file

@ -119,7 +119,7 @@ final class GroupPresenter extends OpenVKPresenter
$this->template->paginatorConf = (object) [ $this->template->paginatorConf = (object) [
"count" => $this->template->count, "count" => $this->template->count,
"page" => $this->queryParam("p") ?? 1, "page" => $this->queryParam("p") ?? 1,
"amount" => NULL, "amount" => 10,
"perPage" => OPENVK_DEFAULT_PER_PAGE, "perPage" => OPENVK_DEFAULT_PER_PAGE,
]; ];
} }

View file

@ -34,6 +34,12 @@ final class UserPresenter extends OpenVKPresenter
if(!is_null($user) && $user->isDeactivated()) { if(!is_null($user) && $user->isDeactivated()) {
$this->template->_template = "User/deactivated.xml"; $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; $this->template->user = $user;
} else if(!is_null($user) && !$user->canBeViewedBy($this->user->identity)) { } else if(!is_null($user) && !$user->canBeViewedBy($this->user->identity)) {
$this->template->_template = "User/private.xml"; $this->template->_template = "User/private.xml";
@ -58,6 +64,7 @@ final class UserPresenter extends OpenVKPresenter
if($id !== $this->user->id) { if($id !== $this->user->id) {
$this->template->ignore_status = $user->isIgnoredBy($this->user->identity); $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->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
} }
$this->template->mode = in_array($this->queryParam("act"), [ $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") ]) ? $this->queryParam("act")
: "main"; : "main";
@ -592,6 +599,19 @@ final class UserPresenter extends OpenVKPresenter
$this->template->qrCodeType = substr($qrCode[0], 5); $this->template->qrCodeType = substr($qrCode[0], 5);
$this->template->qrCodeData = $qrCode[1]; $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; $this->template->user = $user;

View file

@ -13,6 +13,7 @@
{var $isFinance = $mode === 'finance'} {var $isFinance = $mode === 'finance'}
{var $isFinanceTU = $mode === 'finance.top-up'} {var $isFinanceTU = $mode === 'finance.top-up'}
{var $isInterface = $mode === 'interface'} {var $isInterface = $mode === 'interface'}
{var $isBl = $mode === 'blacklist'}
<div class="tabs"> <div class="tabs">
<div n:attr="id => ($isMain ? 'activetabs' : 'ki')" class="tab"> <div n:attr="id => ($isMain ? 'activetabs' : 'ki')" class="tab">
@ -24,6 +25,9 @@
<div n:attr="id => ($isPrivacy ? 'activetabs' : 'ki')" class="tab"> <div n:attr="id => ($isPrivacy ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($isPrivacy ? 'act_tab_a' : 'ki')" href="/settings?act=privacy">{_privacy}</a> <a n:attr="id => ($isPrivacy ? 'act_tab_a' : 'ki')" href="/settings?act=privacy">{_privacy}</a>
</div> </div>
<div n:attr="id => ($isBl ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($isBl ? 'act_tab_a' : 'ki')" href="/settings?act=blacklist">{_blacklist}</a>
</div>
<div n:if="OPENVK_ROOT_CONF['openvk']['preferences']['commerce']" n:attr="id => (($isFinance || $isFinanceTU) ? 'activetabs' : 'ki')" class="tab"> <div n:if="OPENVK_ROOT_CONF['openvk']['preferences']['commerce']" n:attr="id => (($isFinance || $isFinanceTU) ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => (($isFinance || $isFinanceTU) ? 'act_tab_a' : 'ki')" href="/settings?act=finance">{_points}</a> <a n:attr="id => (($isFinance || $isFinanceTU) ? 'act_tab_a' : 'ki')" href="/settings?act=finance">{_points}</a>
</div> </div>
@ -713,6 +717,29 @@
</tbody> </tbody>
</table> </table>
</form> </form>
{elseif $isBl}
{if $blSize < 1}
{include "../components/error.xml", description => tr("bl_count_zero_desc")}
{else}
<h4 style="margin-bottom: 10px;">{tr("bl_count", $blSize)}.</h4>
<div class='entity_vertical_list mini m_mini scroll_container'>
<div n:foreach="$blItems as $item" class="entity_vertical_list_item scroll_node">
<div class="first_column">
<a href="{$item->getURL()}" class="avatar">
<img src='{$item->getAvatarURL()}'>
</a>
<div class="info">
<b class="noOverflow">
<a href="{$item->getURL()}">
{$item->getCanonicalName()}
</a>
</b>
</div>
</div>
</div>
</div>
{include "../components/paginator.xml", conf => $paginatorConf}
{/if}
{/if} {/if}
</div> </div>

View file

@ -166,6 +166,7 @@
{/if} {/if}
<a class="profile_link" style="display:block;width:96%;" href="javascript:reportUser({$user->getId()})">{_report}</a> <a class="profile_link" style="display:block;width:96%;" href="javascript:reportUser({$user->getId()})">{_report}</a>
<a n:if="!$blacklist_status" id="_bl_toggler" data-name="{$user->getMorphedName('genitive', false)}" data-val="1" data-id="{$user->getRealId()}" class="profile_link" style="display:block;width:96%;">{_bl_add}</a>
<a n:if="!$user->isHideFromGlobalFeedEnabled()" class="profile_link" style="display:block;width:96%;" id="__ignoreSomeone" data-val='{!$ignore_status ? 1 : 0}' data-id="{$user->getId()}"> <a n:if="!$user->isHideFromGlobalFeedEnabled()" class="profile_link" style="display:block;width:96%;" id="__ignoreSomeone" data-val='{!$ignore_status ? 1 : 0}' data-id="{$user->getId()}">
{if !$ignore_status}{_ignore_user}{else}{_unignore_user}{/if} {if !$ignore_status}{_ignore_user}{else}{_unignore_user}{/if}
</a> </a>

View file

@ -0,0 +1,37 @@
{extends "../@layout.xml"}
{block title}{$user->getCanonicalName()}{/block}
{block header}
{$user->getCanonicalName()}
<img n:if="$user->isVerified()"
class="name-checkmark"
src="/assets/packages/static/openvk/img/checkmark.png"
/>
{/block}
{block content}
<div class="left_small_block">
<div>
<img src="{$user->getAvatarUrl('normal')}"
alt="{$user->getCanonicalName()}"
style="width: 100%; image-rendering: -webkit-optimize-contrast;" />
</div>
<div id="profile_links" n:if="isset($thisUser)">
<a class="profile_link" style="display:block;width:96%;" href="javascript:reportUser({$user->getId()})">{_report}</a>
</div>
</div>
<div class="right_big_block">
<div class="page_info">
<div class="accountInfo clearFix">
<div class="profileName">
<h2>{$user->getFullName()}</h2>
</div>
</div>
<div class="msg msg_yellow" style="width: 93%;margin-top: 10px;">
{var $m = $user->isFemale() ? "f" : "m"}
{tr("limited_access_to_page_$m", $user->getFirstName())}
</div>
</div>
</div>
{/block}

View file

@ -0,0 +1,37 @@
{extends "../@layout.xml"}
{block title}{$user->getCanonicalName()}{/block}
{block header}
{$user->getCanonicalName()}
<img n:if="$user->isVerified()"
class="name-checkmark"
src="/assets/packages/static/openvk/img/checkmark.png"
/>
{/block}
{block content}
<div class="left_small_block">
<div>
<img src="{$user->getAvatarUrl('normal')}"
alt="{$user->getCanonicalName()}"
style="width: 100%; image-rendering: -webkit-optimize-contrast;" />
</div>
<div id="profile_links" n:if="isset($thisUser)">
<a n:if="!$blacklist_status" id="_bl_toggler" data-val="0" data-id="{$user->getRealId()}" class="profile_link" style="display:block;width:96%;">{_bl_remove}</a>
<a class="profile_link" style="display:block;width:96%;" href="javascript:reportUser({$user->getId()})">{_report}</a>
</div>
</div>
<div class="right_big_block">
<div class="page_info">
<div class="accountInfo clearFix">
<div class="profileName">
<h2>{$user->getFullName()}</h2>
</div>
</div>
<div class="msg msg_yellow" style="width: 93%;margin-top: 10px;">
{tr("you_blacklisted", $user->getMorphedName("genitive", false))}.
</div>
</div>
</div>
{/block}

View file

@ -3597,6 +3597,11 @@ hr {
overflow-y: auto; overflow-y: auto;
} }
.entity_vertical_list.scroll_container {
height: unset;
overflow-y: unset;
}
.entity_vertical_list .entity_vertical_list_item { .entity_vertical_list .entity_vertical_list_item {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -3611,6 +3616,15 @@ hr {
gap: 4px; 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 { .entity_vertical_list .entity_vertical_list_item .avatar {
display: block; display: block;
} }

View file

@ -2587,3 +2587,42 @@ async function changeStatus() {
document.status_popup_form.submit.innerHTML = tr("send"); document.status_popup_form.submit.innerHTML = tr("send");
document.status_popup_form.submit.disabled = false; 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: `<span>${escapeHtml(tr('adding_to_bl_sure', name))}</span>`,
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)
}
}
})

View file

@ -289,6 +289,10 @@ u(document).on('click', 'a', async (e) => {
}) })
u(document).on('submit', 'form', async (e) => { u(document).on('submit', 'form', async (e) => {
if(e.defaultPrevented) {
return
}
if(u('#ajloader').hasClass('shown')) { if(u('#ajloader').hasClass('shown')) {
e.preventDefault() e.preventDefault()
return return

View file

@ -1823,6 +1823,21 @@
"user_blacklisted" = "$1 has been blacklisted"; "user_blacklisted" = "$1 has been blacklisted";
"user_removed_from_the_blacklist" = "$1 has been removed from the blacklist."; "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 */ /* Away */
"transition_is_blocked" = "Transition is blocked"; "transition_is_blocked" = "Transition is blocked";

View file

@ -1719,6 +1719,21 @@
"user_blacklisted" = "$1 занесён в чёрный список."; "user_blacklisted" = "$1 занесён в чёрный список.";
"user_removed_from_the_blacklist" = "$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 */ /* Away */
"transition_is_blocked" = "Переход по ссылке заблокирован"; "transition_is_blocked" = "Переход по ссылке заблокирован";