mirror of
https://github.com/openvk/openvk
synced 2024-12-25 01:51:03 +03:00
Some apis + locales
This commit is contained in:
parent
51775a9ccf
commit
eaaa454a45
5 changed files with 76 additions and 8 deletions
|
@ -1,9 +1,9 @@
|
|||
<?php declare(strict_types=1);
|
||||
namespace openvk\VKAPI\Handlers;
|
||||
use Chandler\Database\DatabaseConnection;
|
||||
use openvk\Web\Models\Repositories\Posts as PostsRepo;
|
||||
use openvk\Web\Models\Repositories\Posts as PostsRepo, Users as UsersRepo, Clubs;
|
||||
use openvk\Web\Models\Entities\User;
|
||||
use openvk\VKAPI\Handlers\Wall;
|
||||
use openvk\VKAPI\Handlers\{Wall, Users, Groups};
|
||||
|
||||
final class Newsfeed extends VKAPIRequestHandler
|
||||
{
|
||||
|
@ -56,6 +56,12 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
if($this->getUser()->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||
$queryBase .= " AND `nsfw` = 0";
|
||||
|
||||
if(($ignoredCount = $this->getUser()->getIgnoredSourcesCount()) > 0) {
|
||||
$sources = implode("', '", $this->getUser()->getIgnoredSources(1, $ignoredCount, true));
|
||||
|
||||
$queryBase .= " AND `posts`.`wall` NOT IN ('$sources')";
|
||||
}
|
||||
|
||||
$start_from = empty($start_from) ? PHP_INT_MAX : $start_from;
|
||||
$start_time = empty($start_time) ? 0 : $start_time;
|
||||
$end_time = empty($end_time) ? PHP_INT_MAX : $end_time;
|
||||
|
@ -73,4 +79,52 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
|
||||
return $response;
|
||||
}
|
||||
|
||||
function getBanned(int $extended = 0, string $fields = "", string $name_case = "nom")
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
$count = 50;
|
||||
$offset = 0;
|
||||
|
||||
$banned = array_slice($this->getUser()->getIgnoredSources(1, $count + $offset, true), $offset);
|
||||
|
||||
if($extended == 0) {
|
||||
$retArr/*d*/ = [
|
||||
"groups" => [],
|
||||
"members" => [] # why
|
||||
];
|
||||
|
||||
foreach($banned as $ban) {
|
||||
if($ban > 0) {
|
||||
$retArr["members"][] = $ban;
|
||||
} else {
|
||||
$retArr["groups"][] = $ban;
|
||||
}
|
||||
}
|
||||
|
||||
return $retArr;
|
||||
} else {
|
||||
$retArr = [
|
||||
"groups" => [],
|
||||
"profiles" => []
|
||||
];
|
||||
|
||||
$usIds = "";
|
||||
$clubIds = "";
|
||||
|
||||
foreach($banned as $ban) {
|
||||
if($ban > 0) {
|
||||
$usIds .= $ban . ",";
|
||||
} else {
|
||||
$clubIds .= ($ban * -1) . ",";
|
||||
}
|
||||
}
|
||||
|
||||
$retArr["profiles"][] = (new Users)->get($usIds, $fields);
|
||||
$retArr["groups"][] = (new Groups)->getById($clubIds, $fields);
|
||||
|
||||
return $retArr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,21 +594,25 @@ final class WallPresenter extends OpenVKPresenter
|
|||
$ignoredSource = (int)$this->postParam("source");
|
||||
|
||||
if($this->user->identity->getIgnoredSourcesCount() > 50)
|
||||
$this->flashFail("err", "Error", "Max ignors count is 50", null, true);
|
||||
$this->flashFail("err", "Error", tr("max_ignores", 50), null, true);
|
||||
|
||||
if($ignoredSource > 0) {
|
||||
$ignoredSourceModel = (new Users)->get($ignoredSource);
|
||||
|
||||
if(!$ignoredSourceModel)
|
||||
$this->flashFail("err", "Error", "Invalid user", null, true);
|
||||
$this->flashFail("err", "Error", tr("invalid_user"), null, true);
|
||||
|
||||
if($ignoredSourceModel->getId() == $this->user->id)
|
||||
$this->flashFail("err", "Error", "Can't ignore yourself", null, true);
|
||||
$this->flashFail("err", "Error", tr("cant_ignore_self"), null, true);
|
||||
} else {
|
||||
$ignoredSourceModel = (new Clubs)->get(abs($ignoredSource));
|
||||
|
||||
if(!$ignoredSourceModel)
|
||||
$this->flashFail("err", "Error", "Invalid club", null, true);
|
||||
$this->flashFail("err", "Error", tr("invalid_club"), null, true);
|
||||
|
||||
if($ignoredSourceModel->isHideFromGlobalFeedEnabled()) {
|
||||
$this->flashFail("err", "Error", tr("no_sense"), null, true);
|
||||
}
|
||||
}
|
||||
|
||||
if($ignoredSourceModel->isIgnoredBy($this->user->identity)) {
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
{var $canReport = $thisUser->getId() != $club->getOwner()->getId()}
|
||||
{if $canReport}
|
||||
<a class="profile_link" style="display:block;" href="javascript:reportVideo()">{_report}</a>
|
||||
<a class="profile_link" style="display:block;" id="ignoreSomeone" data-id="-{$club->getId()}">
|
||||
<a n:if="!$club->isHideFromGlobalFeedEnabled()" class="profile_link" style="display:block;" id="ignoreSomeone" data-id="-{$club->getId()}">
|
||||
{if !$club->isIgnoredBy($thisUser)}{_ignore_club}{else}{_unignore_club}{/if}
|
||||
</a>
|
||||
|
||||
|
|
|
@ -1285,6 +1285,11 @@
|
|||
"group_is_banned" = "Group was successfully banned";
|
||||
|
||||
"description_too_long" = "Description is too long.";
|
||||
"invalid_club" = "This group does not exists.";
|
||||
"invalid_user" = "This user does not exists.";
|
||||
"no_sense" = "No sense.";
|
||||
"cant_ignore_self" = "Can't ignore urself.";
|
||||
"max_ignores" = "Max ignores — $1";
|
||||
|
||||
/* Admin actions */
|
||||
|
||||
|
|
|
@ -1179,6 +1179,11 @@
|
|||
"group_owner_is_banned" = "Создатель сообщества успешно забанен.";
|
||||
"group_is_banned" = "Сообщество успешно забанено";
|
||||
"description_too_long" = "Описание слишком длинное.";
|
||||
"invalid_club" = "Такой группы не существует.";
|
||||
"invalid_user" = "Такого пользователя не существует.";
|
||||
"no_sense" = "Нет смысла.";
|
||||
"cant_ignore_self" = "Нельзя игнорировать себя.";
|
||||
"max_ignores" = "Максимальное число игноров — $1";
|
||||
|
||||
/* Admin actions */
|
||||
|
||||
|
|
Loading…
Reference in a new issue