mirror of
https://github.com/openvk/openvk
synced 2024-11-13 10:39:24 +03:00
parent
e782d502b8
commit
ec4757f356
8 changed files with 43 additions and 8 deletions
|
@ -216,12 +216,15 @@ class User extends RowModel
|
|||
|
||||
function getCoins(): int
|
||||
{
|
||||
if(!OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"])
|
||||
return 0;
|
||||
|
||||
return $this->getRecord()->coins;
|
||||
}
|
||||
|
||||
function getRating(): int
|
||||
{
|
||||
return $this->getRecord()->rating;
|
||||
return OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"] ? $this->getRecord()->rating : 0;
|
||||
}
|
||||
|
||||
function getReputation(): int
|
||||
|
@ -400,11 +403,9 @@ class User extends RowModel
|
|||
$total = max(100 - $incompleteness + $this->getRating(), 0);
|
||||
if(ovkGetQuirk("profile.rating-bar-behaviour") === 0)
|
||||
if ($total >= 100)
|
||||
$percent = round(($total / 10**strlen(strval($total))) * 100, 0);
|
||||
else
|
||||
$percent = min($total, 100);
|
||||
$percent = round(($total / 10**strlen(strval($total))) * 100, 0);
|
||||
else
|
||||
$percent = min($total, 100);
|
||||
$percent = min($total, 100);
|
||||
|
||||
return (object) [
|
||||
"total" => $total,
|
||||
|
|
|
@ -20,6 +20,12 @@ final class AdminPresenter extends OpenVKPresenter
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
private function warnIfNoCommerce(): void
|
||||
{
|
||||
if(!OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"])
|
||||
$this->flash("warn", "Коммерция отключена системным администратором", "Настройки ваучеров и подарков будут сохранены, но не будут оказывать никакого влияния.");
|
||||
}
|
||||
|
||||
private function searchResults(object $repo, &$count)
|
||||
{
|
||||
$query = $this->queryParam("q") ?? "";
|
||||
|
@ -112,12 +118,16 @@ final class AdminPresenter extends OpenVKPresenter
|
|||
|
||||
function renderVouchers(): void
|
||||
{
|
||||
$this->warnIfNoCommerce();
|
||||
|
||||
$this->template->count = $this->vouchers->size();
|
||||
$this->template->vouchers = iterator_to_array($this->vouchers->enumerate((int) ($this->queryParam("p") ?? 1)));
|
||||
}
|
||||
|
||||
function renderVoucher(int $id): void
|
||||
{
|
||||
$this->warnIfNoCommerce();
|
||||
|
||||
$voucher = NULL;
|
||||
$this->template->form = (object) [];
|
||||
if($id === 0) {
|
||||
|
@ -163,12 +173,16 @@ final class AdminPresenter extends OpenVKPresenter
|
|||
|
||||
function renderGiftCategories(): void
|
||||
{
|
||||
$this->warnIfNoCommerce();
|
||||
|
||||
$this->template->act = $this->queryParam("act") ?? "list";
|
||||
$this->template->categories = iterator_to_array($this->gifts->getCategories((int) ($this->queryParam("p") ?? 1), NULL, $this->template->count));
|
||||
}
|
||||
|
||||
function renderGiftCategory(string $slug, int $id): void
|
||||
{
|
||||
$this->warnIfNoCommerce();
|
||||
|
||||
$cat;
|
||||
$gen = false;
|
||||
if($id !== 0) {
|
||||
|
@ -222,6 +236,8 @@ final class AdminPresenter extends OpenVKPresenter
|
|||
|
||||
function renderGifts(string $catSlug, int $catId): void
|
||||
{
|
||||
$this->warnIfNoCommerce();
|
||||
|
||||
$cat = $this->gifts->getCat($catId);
|
||||
if(!$cat)
|
||||
$this->notFound();
|
||||
|
@ -234,6 +250,8 @@ final class AdminPresenter extends OpenVKPresenter
|
|||
|
||||
function renderGift(int $id): void
|
||||
{
|
||||
$this->warnIfNoCommerce();
|
||||
|
||||
$gift = $this->gifts->get($id);
|
||||
$act = $this->queryParam("act") ?? "edit";
|
||||
switch($act) {
|
||||
|
|
|
@ -129,4 +129,12 @@ final class GiftsPresenter extends OpenVKPresenter
|
|||
header("Content-Type: image/png");
|
||||
exit($image);
|
||||
}
|
||||
|
||||
function onStartup(): void
|
||||
{
|
||||
if(!OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"])
|
||||
$this->flashFail("err", tr("error"), tr("feature_disabled"));
|
||||
|
||||
parent::onStartup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,6 +225,9 @@ final class UserPresenter extends OpenVKPresenter
|
|||
if(!$id)
|
||||
$this->notFound();
|
||||
|
||||
if(in_array($this->queryParam("act"), ["finance", "finance.top-up"]) && !OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"])
|
||||
$this->flashFail("err", tr("error"), tr("feature_disabled"));
|
||||
|
||||
$user = $this->users->get($id);
|
||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$this->willExecuteWriteAction();
|
||||
|
|
|
@ -140,6 +140,10 @@
|
|||
</div>
|
||||
{/ifset}
|
||||
|
||||
{ifset preHeader}
|
||||
{include preHeader}
|
||||
{/ifset}
|
||||
|
||||
<header class="aui-page-header">
|
||||
<div class="aui-page-header-inner">
|
||||
<div class="aui-page-header-main">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<div n:attr="id => ($isPrivacy ? 'activetabs' : 'ki')" class="tab">
|
||||
<a n:attr="id => ($isPrivacy ? 'act_tab_a' : 'ki')" href="/settings?act=privacy">{_"privacy"}</a>
|
||||
</div>
|
||||
<div 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>
|
||||
</div>
|
||||
<div n:attr="id => ($isInterface ? 'activetabs' : 'ki')" class="tab">
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
</a>
|
||||
{/if}
|
||||
|
||||
<a href="/gifts?act=pick&user={$user->getId()}" class="profile_link">{_send_gift}</a>
|
||||
<a n:if="OPENVK_ROOT_CONF['openvk']['preferences']['commerce']" href="/gifts?act=pick&user={$user->getId()}" class="profile_link">{_send_gift}</a>
|
||||
|
||||
{var subStatus = $user->getSubscriptionStatus($thisUser)}
|
||||
{if $subStatus === 0}
|
||||
|
@ -152,7 +152,7 @@
|
|||
{/if}
|
||||
</div>
|
||||
<br />
|
||||
<div n:if="($giftCount = $user->getGiftCount()) > 0">
|
||||
<div n:if="OPENVK_ROOT_CONF['openvk']['preferences']['commerce'] && ($giftCount = $user->getGiftCount()) > 0">
|
||||
<div class="content_title_expanded" onclick="hidePanel(this, {$giftCount});">
|
||||
{_gifts}
|
||||
</div>
|
||||
|
|
|
@ -37,6 +37,7 @@ openvk:
|
|||
maxSize: 60000
|
||||
processingLimit: 3000
|
||||
emojiProcessingLimit: 1000
|
||||
commerce: false
|
||||
menu:
|
||||
links:
|
||||
|
||||
|
|
Loading…
Reference in a new issue