mirror of
https://github.com/openvk/openvk
synced 2024-11-15 03:31:18 +03:00
Compare commits
6 commits
c332510b24
...
a99ffbdafe
Author | SHA1 | Date | |
---|---|---|---|
|
a99ffbdafe | ||
|
874a654bd4 | ||
|
484b19dd8c | ||
|
66852e4334 | ||
|
eaaa454a45 | ||
|
51775a9ccf |
28 changed files with 395 additions and 649 deletions
|
@ -143,4 +143,30 @@ class Wall implements Handler
|
|||
|
||||
$resolve($arr);
|
||||
}
|
||||
|
||||
function getIgnoredSources(int $page = 1, callable $resolve, callable $reject)
|
||||
{
|
||||
$surses = $this->user->getIgnoredSources($page, 10);
|
||||
|
||||
$arr = [
|
||||
"count" => $this->user->getIgnoredSourcesCount(),
|
||||
"items" => []
|
||||
];
|
||||
|
||||
foreach($surses as $surs) {
|
||||
$arr["items"][] = [
|
||||
"id" => $surs->getRealId(),
|
||||
"name" => $surs->getCanonicalName(),
|
||||
"additional" => (($surs->getRealId() > 0 ? $surs->getStatus() : $surs->getDescription()) ?? "..."),
|
||||
"avatar" => $surs->getAvatarURL(),
|
||||
"url" => $surs->getURL(),
|
||||
];
|
||||
}
|
||||
|
||||
if(rand(0, 200) == 50) {
|
||||
$arr["fact"] = $this->user->getIgnoresCount();
|
||||
}
|
||||
|
||||
$resolve($arr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -32,7 +32,6 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
->select("id")
|
||||
->where("wall IN (?)", $ids)
|
||||
->where("deleted", 0)
|
||||
->where("suggested", 0)
|
||||
->where("id < (?)", empty($start_from) ? PHP_INT_MAX : $start_from)
|
||||
->where("? <= created", empty($start_time) ? 0 : $start_time)
|
||||
->where("? >= created", empty($end_time) ? PHP_INT_MAX : $end_time)
|
||||
|
@ -48,7 +47,7 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
return $response;
|
||||
}
|
||||
|
||||
function getGlobal(string $fields = "", int $start_from = 0, int $start_time = 0, int $end_time = 0, int $offset = 0, int $count = 30, int $extended = 0)
|
||||
function getGlobal(string $fields = "", int $start_from = 0, int $start_time = 0, int $end_time = 0, int $offset = 0, int $count = 30, int $extended = 0, int $return_banned = 0)
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
|
@ -58,20 +57,17 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
if($this->getUser()->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||
$queryBase .= " AND `nsfw` = 0";
|
||||
|
||||
if($return_banned == 0) {
|
||||
$ignored_sources_ids = $this->getUser()->getIgnoredSources(0, OPENVK_ROOT_CONF['openvk']['preferences']['newsfeed']['ignoredSourcesLimit'] ?? 50, true);
|
||||
if(($ignoredCount = $this->getUser()->getIgnoredSourcesCount()) > 0 && $return_banned == 0) {
|
||||
$sources = implode("', '", $this->getUser()->getIgnoredSources(1, $ignoredCount, true));
|
||||
|
||||
if(sizeof($ignored_sources_ids) > 0) {
|
||||
$imploded_ids = implode("', '", $ignored_sources_ids);
|
||||
$queryBase .= " AND `posts`.`wall` NOT IN ('$imploded_ids')";
|
||||
}
|
||||
$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;
|
||||
$posts = DatabaseConnection::i()->getConnection()->query("SELECT `posts`.`id` " . $queryBase . " AND `posts`.`id` <= " . $start_from . " AND " . $start_time . " <= `posts`.`created` AND `posts`.`created` <= " . $end_time . " ORDER BY `created` DESC LIMIT " . $count . " OFFSET " . $offset);
|
||||
|
||||
|
||||
$rposts = [];
|
||||
$ids = [];
|
||||
foreach($posts as $post) {
|
||||
|
@ -85,151 +81,129 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
return $response;
|
||||
}
|
||||
|
||||
function getByType(string $feed_type = 'top', string $fields = "", int $start_from = 0, int $start_time = 0, int $end_time = 0, int $offset = 0, int $count = 30, int $extended = 0, int $return_banned = 0)
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
switch($feed_type) {
|
||||
case 'top':
|
||||
return $this->getGlobal($fields, $start_from, $start_time, $end_time, $offset, $count, $extended, $return_banned);
|
||||
break;
|
||||
default:
|
||||
return $this->get($fields, $start_from, $start_time, $end_time, $offset, $count, $extended);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function getBanned(int $extended = 0, string $fields = "", string $name_case = "nom", int $merge = 0): object
|
||||
function getBanned(int $extended = 0, string $fields = "", string $name_case = "nom")
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
$count = 50;
|
||||
$offset = 0;
|
||||
$count = OPENVK_ROOT_CONF['openvk']['preferences']['newsfeed']['ignoredSourcesLimit'] ?? 50;
|
||||
$banned = $this->getUser()->getIgnoredSources($offset, $count, ($extended != 1));
|
||||
$return_object = (object) [
|
||||
'groups' => [],
|
||||
'members' => [],
|
||||
];
|
||||
|
||||
$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)
|
||||
$return_object->members[] = $ban;
|
||||
else
|
||||
$return_object->groups[] = $ban;
|
||||
if($ban > 0) {
|
||||
$retArr["members"][] = $ban;
|
||||
} else {
|
||||
$retArr["groups"][] = $ban;
|
||||
}
|
||||
}
|
||||
|
||||
return $retArr;
|
||||
} else {
|
||||
if($merge == 1) {
|
||||
$return_object = (object) [
|
||||
'count' => sizeof($banned),
|
||||
'items' => [],
|
||||
];
|
||||
$retArr = [
|
||||
"groups" => [],
|
||||
"profiles" => []
|
||||
];
|
||||
|
||||
foreach($banned as $ban) {
|
||||
$return_object->items[] = $ban->toVkApiStruct($this->getUser(), $fields);
|
||||
}
|
||||
} else {
|
||||
$return_object = (object) [
|
||||
'groups' => [],
|
||||
'profiles' => [],
|
||||
];
|
||||
|
||||
foreach($banned as $ban) {
|
||||
if($ban->getRealId() > 0)
|
||||
$return_object->profiles[] = $ban->toVkApiStruct($this->getUser(), $fields);
|
||||
else
|
||||
$return_object->groups[] = $ban->toVkApiStruct($this->getUser(), $fields);
|
||||
$usIds = "";
|
||||
$clubIds = "";
|
||||
|
||||
foreach($banned as $ban) {
|
||||
if($ban > 0) {
|
||||
$usIds .= $ban . ",";
|
||||
} else {
|
||||
$clubIds .= ($ban * -1) . ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return_object;
|
||||
$retArr["profiles"][] = (new Users)->get($usIds, $fields);
|
||||
$retArr["groups"][] = (new Groups)->getById($clubIds, $fields);
|
||||
|
||||
return $retArr;
|
||||
}
|
||||
}
|
||||
|
||||
function addBan(string $user_ids = "", string $group_ids = "")
|
||||
{
|
||||
$this->requireUser();
|
||||
$this->willExecuteWriteAction();
|
||||
|
||||
# Formatting input ids
|
||||
|
||||
if(empty($user_ids) && empty($group_ids))
|
||||
$this->fail(52, "Provide 'user_ids' or 'groups_ids'");
|
||||
|
||||
$arr = [];
|
||||
|
||||
if(!empty($user_ids)) {
|
||||
$user_ids = array_map(function($el) {
|
||||
$arr = array_merge($arr, array_map(function($el) {
|
||||
return (int)$el;
|
||||
}, explode(',', $user_ids));
|
||||
$user_ids = array_unique($user_ids);
|
||||
} else
|
||||
$user_ids = [];
|
||||
}, explode(",", $user_ids)));
|
||||
}
|
||||
|
||||
if(!empty($group_ids)) {
|
||||
$group_ids = array_map(function($el) {
|
||||
$arr = array_merge($arr, array_map(function($el) {
|
||||
return abs((int)$el) * -1;
|
||||
}, explode(',', $group_ids));
|
||||
$group_ids = array_unique($group_ids);
|
||||
} else
|
||||
$group_ids = [];
|
||||
|
||||
$ids = array_merge($user_ids, $group_ids);
|
||||
if(sizeof($ids) < 1)
|
||||
return 0;
|
||||
|
||||
if(sizeof($ids) > 10)
|
||||
$this->fail(-10, "Limit of 'ids' is 10");
|
||||
|
||||
$config_limit = OPENVK_ROOT_CONF['openvk']['preferences']['newsfeed']['ignoredSourcesLimit'] ?? 50;
|
||||
$user_ignores = $this->getUser()->getIgnoredSourcesCount();
|
||||
if(($user_ignores + sizeof($ids)) > $config_limit) {
|
||||
$this->fail(-50, "Ignoring limit exceeded");
|
||||
}, explode(",", $group_ids)));
|
||||
}
|
||||
|
||||
$entities = get_entities($ids);
|
||||
$arr = array_unique($arr);
|
||||
if(sizeof($arr) > 10 || sizeof($arr) < 1)
|
||||
$this->fail(20, "You can ignore only 10 users/groups at once");
|
||||
|
||||
$successes = 0;
|
||||
foreach($entities as $entity) {
|
||||
if(!$entity || $entity->getRealId() === $this->getUser()->getRealId() || $entity->isHideFromGlobalFeedEnabled() || $entity->isIgnoredBy($this->getUser())) continue;
|
||||
foreach($arr as $ar) {
|
||||
$entity = getEntity($ar);
|
||||
|
||||
$entity->addIgnore($this->getUser());
|
||||
if(!$entity || $entity->isHideFromGlobalFeedEnabled() || $entity->isIgnoredBy($this->getUser())) continue;
|
||||
|
||||
$entity->toggleIgnore($this->getUser());
|
||||
$successes += 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return (int)($successes > 0);
|
||||
}
|
||||
|
||||
function deleteBan(string $user_ids = "", string $group_ids = "")
|
||||
{
|
||||
$this->requireUser();
|
||||
$this->willExecuteWriteAction();
|
||||
|
||||
|
||||
if(empty($user_ids) && empty($group_ids))
|
||||
$this->fail(52, "Provide 'user_ids' or 'groups_ids'");
|
||||
|
||||
$arr = [];
|
||||
|
||||
if(!empty($user_ids)) {
|
||||
$user_ids = array_map(function($el) {
|
||||
$arr = array_merge($arr, array_map(function($el) {
|
||||
return (int)$el;
|
||||
}, explode(',', $user_ids));
|
||||
$user_ids = array_unique($user_ids);
|
||||
} else
|
||||
$user_ids = [];
|
||||
}, explode(",", $user_ids)));
|
||||
}
|
||||
|
||||
if(!empty($group_ids)) {
|
||||
$group_ids = array_map(function($el) {
|
||||
$arr = array_merge($arr, array_map(function($el) {
|
||||
return abs((int)$el) * -1;
|
||||
}, explode(',', $group_ids));
|
||||
$group_ids = array_unique($group_ids);
|
||||
} else
|
||||
$group_ids = [];
|
||||
}, explode(",", $group_ids)));
|
||||
}
|
||||
|
||||
$ids = array_merge($user_ids, $group_ids);
|
||||
if(sizeof($ids) < 1)
|
||||
return 0;
|
||||
|
||||
if(sizeof($ids) > 10)
|
||||
$this->fail(-10, "Limit of ids is 10");
|
||||
|
||||
$entities = get_entities($ids);
|
||||
$arr = array_unique($arr);
|
||||
if(sizeof($arr) > 10 || sizeof($arr) < 1)
|
||||
$this->fail(20, "You can unignore only 10 users/groups at once");
|
||||
|
||||
$successes = 0;
|
||||
foreach($entities as $entity) {
|
||||
if(!$entity || $entity->getRealId() === $this->getUser()->getRealId() || !$entity->isIgnoredBy($this->getUser())) continue;
|
||||
foreach($arr as $ar) {
|
||||
$entity = getEntity($ar);
|
||||
|
||||
$entity->removeIgnore($this->getUser());
|
||||
if(!$entity || $entity->isHideFromGlobalFeedEnabled() || !$entity->isIgnoredBy($this->getUser())) continue;
|
||||
|
||||
$entity->toggleIgnore($this->getUser());
|
||||
$successes += 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return (int)($successes > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,10 @@ class Club extends RowModel
|
|||
return iterator_to_array($avPhotos)[0] ?? NULL;
|
||||
}
|
||||
|
||||
function getAvatarUrl(string $size = "miniscule", $avPhoto = NULL): string
|
||||
function getAvatarUrl(string $size = "miniscule"): string
|
||||
{
|
||||
$serverUrl = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
|
||||
if(!$avPhoto)
|
||||
$avPhoto = $this->getAvatarPhoto();
|
||||
$avPhoto = $this->getAvatarPhoto();
|
||||
|
||||
return is_null($avPhoto) ? "$serverUrl/assets/packages/static/openvk/img/camera_200.png" : $avPhoto->getURLBySizeId($size);
|
||||
}
|
||||
|
@ -444,52 +443,26 @@ class Club extends RowModel
|
|||
|
||||
$res->id = $this->getId();
|
||||
$res->name = $this->getName();
|
||||
$res->screen_name = $this->getShortCode() ?? "club".$this->getId();
|
||||
$res->is_closed = false;
|
||||
$res->type = 'group';
|
||||
$res->is_member = $user ? (int)$this->getSubscriptionStatus($user) : 0;
|
||||
$res->screen_name = $this->getShortCode();
|
||||
$res->is_closed = 0;
|
||||
$res->deactivated = NULL;
|
||||
$res->can_access_closed = true;
|
||||
$res->is_admin = $user && $this->canBeModifiedBy($user);
|
||||
|
||||
if(!is_array($fields))
|
||||
$fields = explode(',', $fields);
|
||||
|
||||
$avatar_photo = $this->getAvatarPhoto();
|
||||
foreach($fields as $field) {
|
||||
switch($field) {
|
||||
case 'verified':
|
||||
$res->verified = (int)$this->isVerified();
|
||||
break;
|
||||
case 'site':
|
||||
$res->site = $this->getWebsite();
|
||||
break;
|
||||
case 'description':
|
||||
$res->description = $this->getDescription();
|
||||
break;
|
||||
case 'background':
|
||||
$res->background = $this->getBackDropPictureURLs();
|
||||
break;
|
||||
case 'photo_50':
|
||||
$res->photo_50 = $this->getAvatarUrl('miniscule', $avatar_photo);
|
||||
break;
|
||||
case 'photo_100':
|
||||
$res->photo_100 = $this->getAvatarUrl('tiny', $avatar_photo);
|
||||
break;
|
||||
case 'photo_200':
|
||||
$res->photo_200 = $this->getAvatarUrl('normal', $avatar_photo);
|
||||
break;
|
||||
case 'photo_max':
|
||||
$res->photo_max = $this->getAvatarUrl('original', $avatar_photo);
|
||||
break;
|
||||
case 'members_count':
|
||||
$res->members_count = $this->getFollowersCount();
|
||||
break;
|
||||
case 'real_id':
|
||||
$res->real_id = $this->getRealId();
|
||||
break;
|
||||
}
|
||||
if($user && $this->canBeModifiedBy($user)) {
|
||||
$res->admin_level = 3;
|
||||
}
|
||||
|
||||
$res->is_member = $user && $this->getSubscriptionStatus($user) ? 1 : 0;
|
||||
|
||||
$res->type = "group";
|
||||
$res->photo_50 = $this->getAvatarUrl("miniscule");
|
||||
$res->photo_100 = $this->getAvatarUrl("tiny");
|
||||
$res->photo_200 = $this->getAvatarUrl("normal");
|
||||
|
||||
$res->can_create_topic = $user && $this->canBeModifiedBy($user) ? 1 : ($this->isEveryoneCanCreateTopics() ? 1 : 0);
|
||||
|
||||
$res->can_post = $user && $this->canBeModifiedBy($user) ? 1 : ($this->canPost() ? 1 : 0);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,42 +9,38 @@ trait TIgnorable
|
|||
{
|
||||
$ctx = DatabaseConnection::i()->getContext();
|
||||
$data = [
|
||||
"owner" => $user->getId(),
|
||||
"source" => $this->getRealId(),
|
||||
"owner" => $user->getId(),
|
||||
"ignored_source" => $this->getRealId(),
|
||||
];
|
||||
|
||||
$sub = $ctx->table("ignored_sources")->where($data);
|
||||
return $sub->count() > 0;
|
||||
}
|
||||
|
||||
function addIgnore(User $for_user): bool
|
||||
{
|
||||
DatabaseConnection::i()->getContext()->table("ignored_sources")->insert([
|
||||
"owner" => $for_user->getId(),
|
||||
"source" => $this->getRealId(),
|
||||
]);
|
||||
|
||||
if(!$sub->fetch()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeIgnore(User $for_user): bool
|
||||
function getIgnoresCount()
|
||||
{
|
||||
DatabaseConnection::i()->getContext()->table("ignored_sources")->where([
|
||||
"owner" => $for_user->getId(),
|
||||
"source" => $this->getRealId(),
|
||||
])->delete();
|
||||
|
||||
return true;
|
||||
return sizeof(DatabaseConnection::i()->getContext()->table("ignored_sources")->where("ignored_source", $this->getRealId()));
|
||||
}
|
||||
|
||||
function toggleIgnore(User $for_user): bool
|
||||
function toggleIgnore(User $user): bool
|
||||
{
|
||||
if($this->isIgnoredBy($for_user)) {
|
||||
$this->removeIgnore($for_user);
|
||||
if($this->isIgnoredBy($user)) {
|
||||
DatabaseConnection::i()->getContext()->table("ignored_sources")->where([
|
||||
"owner" => $user->getId(),
|
||||
"ignored_source" => $this->getRealId(),
|
||||
])->delete();
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$this->addIgnore($for_user);
|
||||
DatabaseConnection::i()->getContext()->table("ignored_sources")->insert([
|
||||
"owner" => $user->getId(),
|
||||
"ignored_source" => $this->getRealId(),
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class User extends RowModel
|
|||
return "/id" . $this->getId();
|
||||
}
|
||||
|
||||
function getAvatarUrl(string $size = "miniscule", $avPhoto = NULL): string
|
||||
function getAvatarUrl(string $size = "miniscule"): string
|
||||
{
|
||||
$serverUrl = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
|
||||
|
||||
|
@ -121,9 +121,7 @@ class User extends RowModel
|
|||
else if($this->isBanned())
|
||||
return "$serverUrl/assets/packages/static/openvk/img/banned.jpg";
|
||||
|
||||
if(!$avPhoto)
|
||||
$avPhoto = $this->getAvatarPhoto();
|
||||
|
||||
$avPhoto = $this->getAvatarPhoto();
|
||||
if(is_null($avPhoto))
|
||||
return "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
|
||||
else
|
||||
|
@ -1346,6 +1344,11 @@ class User extends RowModel
|
|||
$res->first_name = $this->getFirstName();
|
||||
$res->last_name = $this->getLastName();
|
||||
$res->deactivated = $this->isDeactivated();
|
||||
$res->photo_50 = $this->getAvatarURL();
|
||||
$res->photo_100 = $this->getAvatarURL("tiny");
|
||||
$res->photo_200 = $this->getAvatarURL("normal");
|
||||
$res->photo_id = !is_null($this->getAvatarPhoto()) ? $this->getAvatarPhoto()->getPrettyId() : NULL;
|
||||
|
||||
$res->is_closed = $this->isClosed();
|
||||
|
||||
if(!is_null($user))
|
||||
|
@ -1354,53 +1357,10 @@ class User extends RowModel
|
|||
if(!is_array($fields))
|
||||
$fields = explode(',', $fields);
|
||||
|
||||
$avatar_photo = $this->getAvatarPhoto();
|
||||
foreach($fields as $field) {
|
||||
switch($field) {
|
||||
case 'is_dead':
|
||||
$res->is_dead = $this->isDead();
|
||||
break;
|
||||
case 'verified':
|
||||
$res->verified = (int)$this->isVerified();
|
||||
break;
|
||||
case 'sex':
|
||||
$res->sex = $this->isFemale() ? 1 : ($this->isNeutral() ? 0 : 2);
|
||||
break;
|
||||
case 'photo_50':
|
||||
$res->photo_50 = $this->getAvatarUrl('miniscule', $avatar_photo);
|
||||
break;
|
||||
case 'photo_100':
|
||||
$res->photo_100 = $this->getAvatarUrl('tiny', $avatar_photo);
|
||||
break;
|
||||
case 'photo_200':
|
||||
$res->photo_200 = $this->getAvatarUrl('normal', $avatar_photo);
|
||||
break;
|
||||
case 'photo_max':
|
||||
$res->photo_max = $this->getAvatarUrl('original', $avatar_photo);
|
||||
break;
|
||||
case 'photo_id':
|
||||
$res->photo_id = $avatar_photo ? $avatar_photo->getPrettyId() : NULL;
|
||||
break;
|
||||
case 'background':
|
||||
$res->background = $this->getBackDropPictureURLs();
|
||||
break;
|
||||
case 'reg_date':
|
||||
$res->reg_date = $this->getRegistrationTime()->timestamp();
|
||||
break;
|
||||
case 'nickname':
|
||||
$res->nickname = $this->getPseudo();
|
||||
break;
|
||||
case 'rating':
|
||||
$res->rating = $this->getRating();
|
||||
break;
|
||||
case 'status':
|
||||
$res->status = $this->getStatus();
|
||||
break;
|
||||
case 'screen_name':
|
||||
$res->screen_name = $this->getShortCode() ?? "id".$this->getId();
|
||||
break;
|
||||
case 'real_id':
|
||||
$res->real_id = $this->getRealId();
|
||||
$res->is_dead = $user->isDead();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1408,6 +1368,36 @@ class User extends RowModel
|
|||
return $res;
|
||||
}
|
||||
|
||||
function getIgnoredSources(int $page = 1, int $perPage = 10, bool $onlyIds = false)
|
||||
{
|
||||
$sources = DatabaseConnection::i()->getContext()->table("ignored_sources")->where("owner", $this->getId())->page($page, $perPage);
|
||||
$arr = [];
|
||||
|
||||
foreach($sources as $source) {
|
||||
$ignoredSource = (int)$source->ignored_source;
|
||||
|
||||
if($ignoredSource > 0)
|
||||
$ignoredSourceModel = (new Users)->get($ignoredSource);
|
||||
else
|
||||
$ignoredSourceModel = (new Clubs)->get(abs($ignoredSource));
|
||||
|
||||
if(!$ignoredSourceModel)
|
||||
continue;
|
||||
|
||||
if(!$onlyIds)
|
||||
$arr[] = $ignoredSourceModel;
|
||||
else
|
||||
$arr[] = $ignoredSourceModel->getRealId();
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getIgnoredSourcesCount()
|
||||
{
|
||||
return sizeof(DatabaseConnection::i()->getContext()->table("ignored_sources")->where("owner", $this->getId()));
|
||||
}
|
||||
|
||||
function getAudiosCollectionSize()
|
||||
{
|
||||
return (new \openvk\Web\Models\Repositories\Audios)->getUserCollectionSize($this);
|
||||
|
@ -1447,36 +1437,9 @@ class User extends RowModel
|
|||
return $returnArr;
|
||||
}
|
||||
|
||||
function getIgnoredSources(int $offset = 0, int $limit = 10, bool $onlyIds = false)
|
||||
function isHideFromGlobalFeedEnabled(): bool
|
||||
{
|
||||
$sources = DatabaseConnection::i()->getContext()->table("ignored_sources")->where("owner", $this->getId())->limit($limit, $offset)->order('id DESC');
|
||||
$output_array = [];
|
||||
|
||||
foreach($sources as $source) {
|
||||
if($onlyIds) {
|
||||
$output_array[] = (int)$source->source;
|
||||
} else {
|
||||
$ignored_source_model = NULL;
|
||||
$ignored_source_id = (int)$source->source;
|
||||
|
||||
if($ignored_source_id > 0)
|
||||
$ignored_source_model = (new Users)->get($ignored_source_id);
|
||||
else
|
||||
$ignored_source_model = (new Clubs)->get(abs($ignored_source_id));
|
||||
|
||||
if(!$ignored_source_model)
|
||||
continue;
|
||||
|
||||
$output_array[] = $ignored_source_model;
|
||||
}
|
||||
}
|
||||
|
||||
return $output_array;
|
||||
}
|
||||
|
||||
function getIgnoredSourcesCount()
|
||||
{
|
||||
return DatabaseConnection::i()->getContext()->table("ignored_sources")->where("owner", $this->getId())->count();
|
||||
return $this->isClosed();
|
||||
}
|
||||
|
||||
use Traits\TBackDrops;
|
||||
|
|
|
@ -43,18 +43,6 @@ class Clubs
|
|||
return $this->toClub($this->clubs->get($id));
|
||||
}
|
||||
|
||||
function getByIds(array $ids = []): array
|
||||
{
|
||||
$clubs = $this->clubs->select('*')->where('id IN (?)', $ids);
|
||||
$clubs_array = [];
|
||||
|
||||
foreach($clubs as $club) {
|
||||
$clubs_array[] = $this->toClub($club);
|
||||
}
|
||||
|
||||
return $clubs_array;
|
||||
}
|
||||
|
||||
function find(string $query, array $params = [], array $order = ['type' => 'id', 'invert' => false], int $page = 1, ?int $perPage = NULL): \Traversable
|
||||
{
|
||||
$query = "%$query%";
|
||||
|
|
|
@ -28,18 +28,6 @@ class Users
|
|||
{
|
||||
return $this->toUser($this->users->get($id));
|
||||
}
|
||||
|
||||
function getByIds(array $ids = []): array
|
||||
{
|
||||
$users = $this->users->select('*')->where('id IN (?)', $ids);
|
||||
$users_array = [];
|
||||
|
||||
foreach($users as $user) {
|
||||
$users_array[] = $this->toUser($user);
|
||||
}
|
||||
|
||||
return $users_array;
|
||||
}
|
||||
|
||||
function getByShortURL(string $url): ?User
|
||||
{
|
||||
|
|
|
@ -43,7 +43,6 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
}
|
||||
|
||||
$this->template->club = $club;
|
||||
$this->template->ignore_status = $club->isIgnoredBy($this->user->identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,6 @@ final class SearchPresenter extends OpenVKPresenter
|
|||
'pageCount' => ceil($count / $this->template->perPage),
|
||||
];
|
||||
$this->template->extendedPaginatorConf = clone $this->template->paginatorConf;
|
||||
$this->template->extendedPaginatorConf->space = 11;
|
||||
$this->template->extendedPaginatorConf->space = 12;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,10 +54,6 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$this->template->audioStatus = $user->getCurrentAudioStatus();
|
||||
|
||||
$this->template->user = $user;
|
||||
|
||||
if($id !== $this->user->id) {
|
||||
$this->template->ignore_status = $user->isIgnoredBy($this->user->identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,14 +197,10 @@ final class WallPresenter extends OpenVKPresenter
|
|||
if($this->user->identity->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||
$queryBase .= " AND `nsfw` = 0";
|
||||
|
||||
if(((int)$this->queryParam('return_banned')) == 0) {
|
||||
$ignored_sources_ids = $this->user->identity->getIgnoredSources(0, OPENVK_ROOT_CONF['openvk']['preferences']['newsfeed']['ignoredSourcesLimit'] ?? 50, true);
|
||||
if(($ignoredCount = $this->user->identity->getIgnoredSourcesCount()) > 0) {
|
||||
$sources = implode("', '", $this->user->identity->getIgnoredSources(1, $ignoredCount, true));
|
||||
|
||||
if(sizeof($ignored_sources_ids) > 0) {
|
||||
$imploded_ids = implode("', '", $ignored_sources_ids);
|
||||
|
||||
$queryBase .= " AND `posts`.`wall` NOT IN ('$imploded_ids')";
|
||||
}
|
||||
$queryBase .= " AND `posts`.`wall` NOT IN ('$sources')";
|
||||
}
|
||||
|
||||
$posts = DatabaseConnection::i()->getConnection()->query("SELECT `posts`.`id` " . $queryBase . " ORDER BY `created` DESC LIMIT " . $pPage . " OFFSET " . ($page - 1) * $pPage);
|
||||
|
@ -660,7 +656,61 @@ final class WallPresenter extends OpenVKPresenter
|
|||
"avatar" => $post->getOwner()->getAvatarUrl()
|
||||
]]);
|
||||
}
|
||||
|
||||
function renderIgnoreSource()
|
||||
{
|
||||
$this->assertUserLoggedIn();
|
||||
$this->willExecuteWriteAction(true);
|
||||
|
||||
if($_SERVER["REQUEST_METHOD"] !== "POST")
|
||||
exit("");
|
||||
|
||||
$owner = $this->user->id;
|
||||
$ignoredSource = (int)$this->postParam("source");
|
||||
|
||||
if($this->user->identity->getIgnoredSourcesCount() > 50)
|
||||
$this->flashFail("err", "Error", tr("max_ignores", 50), null, true);
|
||||
|
||||
if($ignoredSource > 0) {
|
||||
$ignoredSourceModel = (new Users)->get($ignoredSource);
|
||||
|
||||
if(!$ignoredSourceModel)
|
||||
$this->flashFail("err", "Error", tr("invalid_user"), null, true);
|
||||
|
||||
if($ignoredSourceModel->getId() == $this->user->id)
|
||||
$this->flashFail("err", "Error", tr("cant_ignore_self"), null, true);
|
||||
|
||||
if($ignoredSourceModel->isClosed())
|
||||
$this->flashFail("err", "Error", tr("no_sense"), null, true);
|
||||
} else {
|
||||
$ignoredSourceModel = (new Clubs)->get(abs($ignoredSource));
|
||||
|
||||
if(!$ignoredSourceModel)
|
||||
$this->flashFail("err", "Error", tr("invalid_club"), null, true);
|
||||
|
||||
if($ignoredSourceModel->isHideFromGlobalFeedEnabled())
|
||||
$this->flashFail("err", "Error", tr("no_sense"), null, true);
|
||||
}
|
||||
|
||||
if(!$ignoredSourceModel->toggleIgnore($this->user->identity)) {
|
||||
$tr = "";
|
||||
|
||||
if($ignoredSource > 0)
|
||||
$tr = tr("ignore_user");
|
||||
else
|
||||
$tr = tr("ignore_club");
|
||||
|
||||
$this->returnJson(["success" => true, "act" => "unignored", "text" => $tr]);
|
||||
} else {
|
||||
if($ignoredSource > 0)
|
||||
$tr = tr("unignore_user");
|
||||
else
|
||||
$tr = tr("unignore_club");
|
||||
|
||||
$this->returnJson(["success" => true, "act" => "ignored", "text" => $tr]);
|
||||
}
|
||||
}
|
||||
|
||||
function renderAccept() {
|
||||
$this->assertUserLoggedIn();
|
||||
$this->willExecuteWriteAction(true);
|
||||
|
|
|
@ -169,6 +169,9 @@
|
|||
{var $canReport = $thisUser->getId() != $club->getOwner()->getId()}
|
||||
{if $canReport}
|
||||
<a class="profile_link" style="display:block;" href="javascript:reportVideo()">{_report}</a>
|
||||
<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>
|
||||
|
||||
<script>
|
||||
function reportVideo() {
|
||||
|
@ -194,9 +197,6 @@
|
|||
}
|
||||
</script>
|
||||
{/if}
|
||||
<a n:if="!$club->isHideFromGlobalFeedEnabled()" class="profile_link" style="display:block;" id="__ignoreSomeone" data-val='{!$ignore_status ? 1 : 0}' data-id="{$club->getRealId()}">
|
||||
{if !$ignore_status}{_ignore_club}{else}{_unignore_club}{/if}
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="content_title_expanded" onclick="hidePanel(this);">
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
<div n:class='page_wrap_content_main, $section == "audios" && $count > 0 ? audios_padding'>
|
||||
{if $count > 0}
|
||||
{if $section === 'users'}
|
||||
<div class='search_content content def_row_content' n:foreach="$data as $dat">
|
||||
<div class='search_content def_row_content' n:foreach="$data as $dat">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<a href="{$dat->getURL()}">
|
||||
<img src="{$dat->getAvatarUrl('tiny')}" width="75" alt="{_photo}" loading='lazy' />
|
||||
<img src="{$dat->getAvatarUrl('miniscule')}" width="75" alt="{_photo}" loading='lazy' />
|
||||
</a>
|
||||
</td>
|
||||
<td valign="top" style="width: 100%">
|
||||
|
@ -128,13 +128,13 @@
|
|||
highlightText({$query}, '.page_wrap_content_main', ['text'])
|
||||
</script>
|
||||
{elseif $section === 'groups'}
|
||||
<div class='search_content content def_row_content' n:foreach="$data as $dat">
|
||||
<div class='search_content def_row_content' n:foreach="$data as $dat">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<a href="{$dat->getURL()}">
|
||||
<img src="{$dat->getAvatarUrl('tiny')}" width="75" alt="{_photo}" loading='lazy' />
|
||||
<img src="{$dat->getAvatarUrl('miniscule')}" width="75" alt="{_photo}" loading='lazy' />
|
||||
</a>
|
||||
</td>
|
||||
<td valign="top" style="width: 100%">
|
||||
|
@ -183,7 +183,7 @@
|
|||
highlightText({$query}, '.page_wrap_content_main', ['text', "td[data-highlight='_clubDesc']"])
|
||||
</script>
|
||||
{elseif $section === 'apps'}
|
||||
<div class='search_content content def_row_content' n:foreach="$data as $dat">
|
||||
<div class='search_content def_row_content' n:foreach="$data as $dat">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
|
|
@ -166,8 +166,8 @@
|
|||
{/if}
|
||||
|
||||
<a class="profile_link" style="display:block;width:96%;" href="javascript:reportUser()">{_report}</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()}">
|
||||
{if !$ignore_status}{_ignore_user}{else}{_unignore_user}{/if}
|
||||
<a class="profile_link" style="display:block;width:96%;" id="ignoreSomeone" data-id="{$user->getId()}">
|
||||
{if !$user->isIgnoredBy($thisUser)}{_ignore_user}{else}{_unignore_user}{/if}
|
||||
</a>
|
||||
<script>
|
||||
function reportUser() {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<a n:attr="id => (isset($globalFeed) ? 'act_tab_a' : 'ki')" href="/feed/all">{_all_news}</a>
|
||||
</div>
|
||||
|
||||
<a href='#' id="__feed_settings_link" data-pagescount='{ceil($paginatorConf->count / $paginatorConf->perPage)}'>{_feed_settings}</a>
|
||||
<span n:if="isset($globalFeed) && $thisUser->getIgnoredSourcesCount() > 0" id="_ignoredSourcesLink">{_ignored_sources}</span>
|
||||
</div>
|
||||
|
||||
<div n:class="postFeedWrapper, $thisUser->hasMicroblogEnabled() ? postFeedWrapperMicroblog">
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
<span n:if="$comment->getEditTime()" class="edited editedMark">({_edited_short})</span>
|
||||
</a>
|
||||
{if !$timeOnly}
|
||||
|
|
||||
{if $comment->canBeDeletedBy($thisUser)}
|
||||
|
|
||||
<a href="/comment{$comment->getId()}/delete">{_delete}</a>
|
||||
{/if}
|
||||
{if $comment->canBeEditedBy($thisUser)}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<a href="/video{$video->getPrettyId()}" data-id="{$video->getId()}">
|
||||
<div class="video-preview">
|
||||
<div class="video-preview">
|
||||
<a href="/video{$video->getPrettyId()}" {$videoModal ? "id='videoOpen'" : ''} data-id="{$video->getId()}">
|
||||
<img src="{$video->getThumbnailURL()}"
|
||||
style="max-width: 170px; max-height: 127px; margin: auto;" >
|
||||
</div>
|
||||
</a>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td valign="top" style="width: 100%">
|
||||
{ifset infotable}
|
||||
|
|
|
@ -141,6 +141,8 @@ routes:
|
|||
handler: "Wall->delete"
|
||||
- url: "/wall{num}_{num}/pin"
|
||||
handler: "Wall->pin"
|
||||
- url: "/wall/ignoreSource"
|
||||
handler: "Wall->ignoreSource"
|
||||
- url: "/wall/accept"
|
||||
handler: "Wall->accept"
|
||||
- url: "/wall/decline"
|
||||
|
|
|
@ -549,7 +549,6 @@
|
|||
|
||||
.playlistListView .playlistInfo .playlistName {
|
||||
font-weight: 600;
|
||||
line-height: 12px;
|
||||
}
|
||||
|
||||
.playlistListView .playlistInfo .playlistMeta, .playlistListView .playlistInfo .playlistMeta span {
|
||||
|
|
|
@ -88,7 +88,3 @@ div.ovk-video > div > img
|
|||
height: 31px;
|
||||
min-width: 30px;
|
||||
}
|
||||
|
||||
.entity_vertical_list .entity_vertical_list_item img {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
|
|
@ -621,16 +621,6 @@ input[type=checkbox]:checked:disabled {
|
|||
background-position: 0 -42px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
border: 1px solid #C0CAD5;
|
||||
padding: 3px;
|
||||
font-size: 11px;
|
||||
font-family: tahoma, verdana, arial, sans-serif;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#auth {
|
||||
padding: 10px;
|
||||
}
|
||||
|
@ -2112,10 +2102,6 @@ table td[width="120"] {
|
|||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.mb_tab:hover {
|
||||
background: #e2e0e0;
|
||||
}
|
||||
|
||||
.mb_tab div, .mb_tab > a {
|
||||
padding: 5px 9px;
|
||||
display: block;
|
||||
|
@ -3202,6 +3188,43 @@ body.article .floating_sidebar, body.article .page_content {
|
|||
background: #E9F0F1 !important;
|
||||
}
|
||||
|
||||
#_ignoredSourcesLink {
|
||||
float: right;
|
||||
margin-right: 3px;
|
||||
margin-top: 2px;
|
||||
color: #2B587A;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#_ignoredSourcesLink:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
._ignorredList {
|
||||
height: 87%;
|
||||
border: 1px solid gray;
|
||||
overflow-y: auto;
|
||||
margin-top: 4px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
._ignorredList ._ignoredListContent img {
|
||||
width: 38px;
|
||||
}
|
||||
|
||||
._ignorredList ._ignoredListContent {
|
||||
height: 42px;
|
||||
padding-bottom: 9px;
|
||||
}
|
||||
|
||||
.searchOptions.newer {
|
||||
padding-left: 6px;
|
||||
border-top: unset !important;
|
||||
height: unset !important;
|
||||
border-left: 1px solid #d8d8d8;
|
||||
width: 26% !important;
|
||||
}
|
||||
|
||||
hr {
|
||||
background-color: #d8d8d8;
|
||||
border: none;
|
||||
|
@ -3276,44 +3299,3 @@ hr {
|
|||
width: 30px;
|
||||
height: 7px;
|
||||
}
|
||||
|
||||
#__feed_settings_link {
|
||||
float: right;
|
||||
margin-right: 3px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
#__feed_settings_link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#_feed_settings_container {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#_feed_settings_container #__content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 5px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#_feed_settings_container #__content .settings_item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#_feed_settings_container #__content .final_settings_item {
|
||||
align-self: end;
|
||||
margin-top: 74px;
|
||||
}
|
||||
|
||||
#_feed_settings_container #pageNumber {
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
#_feed_settings_container .entity_vertical_list {
|
||||
height: 206px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
|
|
@ -1,243 +1,80 @@
|
|||
//u('.postFeedPageSelect').attr('style', 'display:none')
|
||||
// Source ignoring
|
||||
u(document).on("click", "#__ignoreSomeone", async (e) => {
|
||||
e.preventDefault()
|
||||
$(document).on("click", "#_ignoredSourcesLink", (e) => {
|
||||
let body = `
|
||||
<span id="ignoredClubersList">${tr("ignored_clubsers_list")}</span>
|
||||
<div class="_ignorredList"></div>
|
||||
`
|
||||
MessageBox(tr("ignored_sources"), body, [tr("cancel")], [Function.noop]);
|
||||
|
||||
const TARGET = u(e.target)
|
||||
const ENTITY_ID = Number(e.target.dataset.id)
|
||||
const VAL = Number(e.target.dataset.val)
|
||||
const ACT = VAL == 1 ? 'ignore' : 'unignore'
|
||||
const METHOD_NAME = ACT == 'ignore' ? 'addBan' : 'deleteBan'
|
||||
const PARAM_NAME = ENTITY_ID < 0 ? 'group_ids' : 'user_ids'
|
||||
const ENTITY_NAME = ENTITY_ID < 0 ? 'club' : 'user'
|
||||
const URL = `/method/newsfeed.${METHOD_NAME}?auth_mechanism=roaming&${PARAM_NAME}=${Math.abs(ENTITY_ID)}`
|
||||
|
||||
TARGET.addClass('lagged')
|
||||
const REQ = await fetch(URL)
|
||||
const RES = await REQ.json()
|
||||
TARGET.removeClass('lagged')
|
||||
document.querySelector(".ovk-diag-body").style.padding = "10px"
|
||||
document.querySelector(".ovk-diag-body").style.height = "330px"
|
||||
|
||||
if(RES.error_code) {
|
||||
switch(RES.error_code) {
|
||||
case -10:
|
||||
fastError(';/')
|
||||
break
|
||||
case -50:
|
||||
fastError(tr('ignored_sources_limit'))
|
||||
break
|
||||
default:
|
||||
fastError(res.error_msg)
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
async function insertMoreSources(page) {
|
||||
document.querySelector("._ignorredList").insertAdjacentHTML("beforeend", `<img id="loader" src="/assets/packages/static/openvk/img/loading_mini.gif">`)
|
||||
let ar = await API.Wall.getIgnoredSources(page)
|
||||
u("#loader").remove()
|
||||
|
||||
if(RES.response == 1) {
|
||||
if(ACT == 'unignore') {
|
||||
TARGET.attr('data-val', '1')
|
||||
TARGET.html(tr(`ignore_${ENTITY_NAME}`))
|
||||
} else {
|
||||
TARGET.attr('data-val', '0')
|
||||
TARGET.html(tr(`unignore_${ENTITY_NAME}`))
|
||||
}
|
||||
}
|
||||
})
|
||||
let pagesCount = Math.ceil(Number(ar.count) / 10)
|
||||
|
||||
u(document).on('click', '#__feed_settings_link', (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
let current_tab = 'main';
|
||||
const body = `
|
||||
<div id='_feed_settings_container'>
|
||||
<div id='_tabs'>
|
||||
<div class="mb_tabs">
|
||||
<div class="mb_tab" data-name='main'>
|
||||
<a>
|
||||
${tr('main')}
|
||||
</a>
|
||||
</div>
|
||||
<div class="mb_tab" data-name='ignored'>
|
||||
<a>
|
||||
${tr('ignored_sources')}
|
||||
</a>
|
||||
for(const a of ar.items) {
|
||||
document.querySelector("._ignorredList").insertAdjacentHTML("beforeend", `
|
||||
<div class="_ignoredListContent">
|
||||
<a href="${a.url}" target="_blank">
|
||||
<img style="float: left" class="ava" src="${a.avatar}">
|
||||
</a>
|
||||
<div style="float: left;margin-left: 6px;">
|
||||
<a href="${a.url}" target="_blank">${ovk_proc_strtr(escapeHtml(a.name), 30)}</a><br>
|
||||
<a class="profile_link" id="ignoreSomeone" data-id="${a.id}">${a.id > 0 ? tr("unignore_user") : tr("unignore_club")}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id='__content'></div>
|
||||
</div>
|
||||
`
|
||||
`)
|
||||
}
|
||||
|
||||
MessageBox(tr("feed_settings"), body, [tr("close")], [Function.noop])
|
||||
u('.ovk-diag-body').attr('style', 'padding:0px;height: 255px;')
|
||||
if(ar.fact && document.querySelector("#ignoredClubersList").dataset.fact != 1) {
|
||||
document.querySelector("#ignoredClubersList").innerHTML += " "+tr("interesting_fact", Number(ar.fact))
|
||||
document.querySelector("#ignoredClubersList").setAttribute("data-fact", "1")
|
||||
}
|
||||
|
||||
async function __switchTab(tab)
|
||||
{
|
||||
current_tab = tab
|
||||
u(`#_feed_settings_container .mb_tab`).attr('id', 'ki')
|
||||
u(`#_feed_settings_container .mb_tab[data-name='${tab}']`).attr('id', 'active')
|
||||
u(`#_feed_settings_container .mb_tabs input`).remove()
|
||||
|
||||
switch(current_tab) {
|
||||
case 'main':
|
||||
const __temp_url = new URL(location.href)
|
||||
const PAGES_COUNT = Number(e.target.dataset.pagescount ?? '10')
|
||||
const CURRENT_PERPAGE = Number(__temp_url.searchParams.get('posts') ?? 10)
|
||||
const CURRENT_PAGE = Number(__temp_url.searchParams.get('p') ?? 1)
|
||||
const CURRENT_RETURN_BANNED = Number(__temp_url.searchParams.get('return_banned') ?? 0)
|
||||
const COUNT = [1, 5, 10, 20, 30, 40, 50]
|
||||
u('#_feed_settings_container #__content').html(`
|
||||
<div class='settings_item'>
|
||||
${tr('posts_per_page')}:
|
||||
<select id="pageSelect"></select>
|
||||
</div>
|
||||
<div class='settings_item'>
|
||||
${tr('start_from_page')}
|
||||
<input type='number' min='1' max='${PAGES_COUNT}' id='pageNumber' value='${CURRENT_PAGE}' placeholder='${CURRENT_PAGE}'>
|
||||
</div>
|
||||
<div class='settings_item'>
|
||||
<label>
|
||||
<input type='checkbox' id="showIgnored" ${CURRENT_RETURN_BANNED == 1 ? 'checked' : ''}>
|
||||
${tr('show_ignored_sources')}
|
||||
</label>
|
||||
</div>
|
||||
<div class='final_settings_item'>
|
||||
<input class='button' type='button' value='${tr('apply')}'>
|
||||
</div>
|
||||
`)
|
||||
|
||||
u('#_feed_settings_container').on('click', '.final_settings_item input', (e) => {
|
||||
const INPUT_PAGES_COUNT = parseInt(u('#_feed_settings_container #pageSelect').nodes[0].selectedOptions[0].value ?? '10')
|
||||
const INPUT_PAGE = parseInt(u('#pageNumber').nodes[0].value ?? '1')
|
||||
const INPUT_IGNORED = Number(u('#showIgnored').nodes[0].checked ?? false)
|
||||
|
||||
const FINAL_URL = new URL(location.href)
|
||||
|
||||
if(CURRENT_PERPAGE != INPUT_PAGES_COUNT) {
|
||||
FINAL_URL.searchParams.set('posts', INPUT_PAGES_COUNT)
|
||||
}
|
||||
|
||||
if(CURRENT_PAGE != INPUT_PAGE && INPUT_PAGE <= PAGES_COUNT) {
|
||||
FINAL_URL.searchParams.set('p', Math.max(1, INPUT_PAGE))
|
||||
}
|
||||
|
||||
if(INPUT_IGNORED == 1) {
|
||||
FINAL_URL.searchParams.set('return_banned', 1)
|
||||
} else {
|
||||
FINAL_URL.searchParams.delete('return_banned')
|
||||
}
|
||||
|
||||
window.location.assign(FINAL_URL.href)
|
||||
})
|
||||
|
||||
COUNT.forEach(item => {
|
||||
u('#_feed_settings_container #pageSelect').append(`
|
||||
<option value="${item}" ${item == CURRENT_PERPAGE ? 'selected' : ''}>${item}</option>
|
||||
`)
|
||||
})
|
||||
|
||||
break
|
||||
case 'ignored':
|
||||
u('#_feed_settings_container #__content').html(`
|
||||
<div id='gif_loader'></div>
|
||||
`)
|
||||
if(!window.openvk.ignored_list) {
|
||||
const IGNORED_RES = await fetch('/method/newsfeed.getBanned?auth_mechanism=roaming&extended=1&fields=real_id,screen_name,photo_50&merge=1')
|
||||
const IGNORED_LIST = await IGNORED_RES.json()
|
||||
|
||||
window.openvk.ignored_list = IGNORED_LIST
|
||||
}
|
||||
|
||||
u('#_feed_settings_container #__content').html(`
|
||||
<div class='entity_vertical_list mini'></div>
|
||||
`)
|
||||
|
||||
u('#_feed_settings_container .mb_tabs').append(`
|
||||
<input class='button lagged' id='_remove_ignores' type='button' value='${tr('stop_ignore')}'>
|
||||
`)
|
||||
|
||||
if(window.openvk.ignored_list.error_code) {
|
||||
fastError(IGNORED_LIST.error_msg)
|
||||
return
|
||||
}
|
||||
|
||||
if(window.openvk.ignored_list.response.items.length < 1) {
|
||||
u('#_feed_settings_container #__content').html(tr('no_ignores_count'))
|
||||
u('#_remove_ignores').remove()
|
||||
}
|
||||
|
||||
window.openvk.ignored_list.response.items.forEach(ignore_item => {
|
||||
let name = ignore_item.name
|
||||
if(!name) {
|
||||
name = ignore_item.first_name + ' ' + ignore_item.last_name
|
||||
}
|
||||
|
||||
u('#_feed_settings_container #__content .entity_vertical_list').append(`
|
||||
<label class='entity_vertical_list_item with_third_column' data-id='${ignore_item.real_id}'>
|
||||
<div class='first_column'>
|
||||
<a href='/${ignore_item.screen_name}' class='avatar'>
|
||||
<img src='${ignore_item.photo_50}'>
|
||||
</a>
|
||||
|
||||
<div class='info'>
|
||||
<b class='noOverflow'>${ovk_proc_strtr(escapeHtml(name), 100)}</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='third_column'>
|
||||
<input type='checkbox' name='remove_me'>
|
||||
</div>
|
||||
</label>
|
||||
`)
|
||||
})
|
||||
|
||||
u("#_feed_settings_container").on("click", "input[name='remove_me']", async (e) => {
|
||||
const checks_count = u(`input[name='remove_me']:checked`).length
|
||||
if(checks_count > 0) {
|
||||
u('.mb_tabs #_remove_ignores').removeClass('lagged')
|
||||
} else {
|
||||
u('.mb_tabs #_remove_ignores').addClass('lagged')
|
||||
}
|
||||
|
||||
if(checks_count > 10) {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
u('#_feed_settings_container').on('click', '#_remove_ignores', async (e) => {
|
||||
e.target.classList.add('lagged')
|
||||
|
||||
const ids = []
|
||||
u('#__content .entity_vertical_list label').nodes.forEach(item => {
|
||||
const _checkbox = item.querySelector(`input[type='checkbox'][name='remove_me']`)
|
||||
if(_checkbox.checked) {
|
||||
ids.push(item.dataset.id)
|
||||
}
|
||||
})
|
||||
|
||||
const user_ids = []
|
||||
const group_ids = []
|
||||
ids.forEach(id => {
|
||||
id > 0 ? user_ids.push(id) : group_ids.push(Math.abs(id))
|
||||
})
|
||||
|
||||
const res = await fetch(`/method/newsfeed.deleteBan?auth_mechanism=roaming&user_ids=${user_ids.join(',')}&group_ids=${group_ids.join(',')}`)
|
||||
const resp = await res.json()
|
||||
if(resp.error_code) {
|
||||
console.error(resp.error_msg)
|
||||
return
|
||||
}
|
||||
|
||||
window.openvk.ignored_list = null
|
||||
__switchTab('ignored')
|
||||
})
|
||||
|
||||
break
|
||||
if(page < pagesCount) {
|
||||
document.querySelector("._ignorredList").insertAdjacentHTML("beforeend", `
|
||||
<div id="showMoreIgnors" data-pagesCount="${pagesCount}" data-page="${page + 1}" style="width: 99%;text-align: center;background: #d5d5d5;height: 22px;padding-top: 9px;cursor:pointer;">
|
||||
<span>more...</span>
|
||||
</div>`)
|
||||
}
|
||||
}
|
||||
|
||||
u("#_feed_settings_container").on("click", ".mb_tab a", async (e) => {
|
||||
await __switchTab(u(e.target).closest('.mb_tab').attr('data-name'))
|
||||
})
|
||||
insertMoreSources(1)
|
||||
|
||||
__switchTab('main')
|
||||
$(".ignorredList .list").on("click", "#showMoreIgnors", (e) => {
|
||||
u(e.currentTarget).remove()
|
||||
insertMoreSources(Number(e.currentTarget.dataset.page))
|
||||
})
|
||||
})
|
||||
|
||||
$(document).on("click", "#ignoreSomeone", (e) => {
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open("POST", "/wall/ignoreSource")
|
||||
|
||||
xhr.onloadstart = () => {
|
||||
e.currentTarget.classList.add("lagged")
|
||||
}
|
||||
|
||||
xhr.onerror = xhr.ontimeout = () => {
|
||||
MessageBox(tr("error"), "Unknown error occured", [tr("ok")], [Function.noop]);
|
||||
}
|
||||
|
||||
xhr.onload = () => {
|
||||
let result = JSON.parse(xhr.responseText)
|
||||
e.currentTarget.classList.remove("lagged")
|
||||
if(result.success) {
|
||||
e.currentTarget.innerHTML = result.text
|
||||
} else {
|
||||
MessageBox(tr("error"), result.flash.message, [tr("ok")], [Function.noop]);
|
||||
}
|
||||
}
|
||||
|
||||
let formdata = new FormData
|
||||
formdata.append("hash", u("meta[name=csrf]").attr("value"))
|
||||
formdata.append("source", e.currentTarget.dataset.id)
|
||||
|
||||
xhr.send(formdata)
|
||||
})
|
||||
|
|
|
@ -277,45 +277,13 @@ function parseAttachments(string $attachments): array
|
|||
return $returnArr;
|
||||
}
|
||||
|
||||
function get_entity_by_id(int $id)
|
||||
{
|
||||
function getEntity(int $id) {
|
||||
if($id > 0)
|
||||
return (new openvk\Web\Models\Repositories\Users)->get($id);
|
||||
|
||||
return (new openvk\Web\Models\Repositories\Clubs)->get(abs($id));
|
||||
}
|
||||
|
||||
function get_entities(array $ids = []): array
|
||||
{
|
||||
$main_result = [];
|
||||
$users = [];
|
||||
$clubs = [];
|
||||
foreach($ids as $id) {
|
||||
$id = (int)$id;
|
||||
if($id < 0)
|
||||
$clubs[] = abs($id);
|
||||
|
||||
if($id > 0)
|
||||
$users[] = $id;
|
||||
}
|
||||
|
||||
if(sizeof($users) > 0) {
|
||||
$users_tmp = (new openvk\Web\Models\Repositories\Users)->getByIds($users);
|
||||
foreach($users_tmp as $user) {
|
||||
$main_result[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
if(sizeof($clubs) > 0) {
|
||||
$clubs_tmp = (new openvk\Web\Models\Repositories\Clubs)->getByIds($clubs);
|
||||
foreach($clubs_tmp as $club) {
|
||||
$main_result[] = $club;
|
||||
}
|
||||
}
|
||||
|
||||
return $main_result;
|
||||
}
|
||||
|
||||
function ovk_scheme(bool $with_slashes = false): string
|
||||
{
|
||||
$scheme = ovk_is_ssl() ? "https" : "http";
|
||||
|
|
6
install/sqls/00041-ignored-sources.sql
Normal file
6
install/sqls/00041-ignored-sources.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE `ignored_sources` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`owner` bigint(20) UNSIGNED NOT NULL,
|
||||
`ignored_source` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
|
|
@ -1,2 +0,0 @@
|
|||
CREATE TABLE `openvk`.`ignored_sources` (`id` BIGINT(20) UNSIGNED NULL AUTO_INCREMENT , `owner` BIGINT(20) UNSIGNED NOT NULL , `source` BIGINT(20) NOT NULL , PRIMARY KEY (`id`), INDEX (`owner`)) ENGINE = InnoDB;
|
||||
ALTER TABLE `openvk`.`ignored_sources` ADD INDEX `owner_source` (`owner`, `source`);
|
|
@ -219,7 +219,6 @@
|
|||
"my_news" = "My news";
|
||||
"all_news" = "All news";
|
||||
"posts_per_page" = "Number of posts per page";
|
||||
"show_ignored_sources" = "Show ignored sources";
|
||||
|
||||
"attachment" = "Attachment";
|
||||
"post_as_group" = "Post as group";
|
||||
|
@ -246,16 +245,20 @@
|
|||
|
||||
"edited_short" = "edited";
|
||||
|
||||
"feed_settings" = "Feed settings";
|
||||
"ignored_sources" = "Ignored sources";
|
||||
"ignore_user" = "Ignore user";
|
||||
"unignore_user" = "Unignore user";
|
||||
"unignore_user" = "Stop ignoring user";
|
||||
|
||||
"ignore_club" = "Ignore club";
|
||||
"unignore_club" = "Unignore club";
|
||||
"no_ignores_count" = "No ignored sources.";
|
||||
"stop_ignore" = "Unignore";
|
||||
"start_from_page" = "Start from page";
|
||||
"unignore_club" = "Stop ignoring club";
|
||||
|
||||
"ignored_clubsers_list" = "This users and clubs doesn't appears in your global feed.";
|
||||
"interesting_fact_zero" = "Fun fact: you doesn't have been ignored!";
|
||||
"interesting_fact_one" = "Fun fact: you have been ignored by one user";
|
||||
"interesting_fact_few" = "Fun fact: you have been ignored by $1 users.";
|
||||
"interesting_fact_many" = "Fun fact: you have been ignored by $1 users.";
|
||||
"interesting_fact_other" = "Fun fact: you have been ignored by $1 users.";
|
||||
"add_new_ignores" = "Add new";
|
||||
|
||||
"all_posts" = "All posts";
|
||||
"users_posts" = "Posts by $1";
|
||||
|
@ -1549,7 +1552,9 @@
|
|||
"description_too_long" = "Description is too long.";
|
||||
"invalid_club" = "This group does not exists.";
|
||||
"invalid_user" = "This user does not exists.";
|
||||
"ignored_sources_limit" = "Limit of ignored sources has exceed";
|
||||
"no_sense" = "No sense.";
|
||||
"cant_ignore_self" = "Can't ignore urself.";
|
||||
"max_ignores" = "Max ignores — $1";
|
||||
|
||||
"invalid_audio" = "Invalid audio.";
|
||||
"do_not_have_audio" = "You don't have this audio.";
|
||||
|
@ -1764,7 +1769,6 @@
|
|||
"question_confirm" = "This action can't be undone. Do you really wanna do it?";
|
||||
"confirm_m" = "Confirm";
|
||||
"action_successfully" = "Success";
|
||||
"apply" = "Apply";
|
||||
|
||||
/* User Alerts */
|
||||
|
||||
|
|
|
@ -204,7 +204,6 @@
|
|||
"my_news" = "Мои новости";
|
||||
"all_news" = "Все новости";
|
||||
"posts_per_page" = "Количество записей на странице";
|
||||
"show_ignored_sources" = "Показывать игнорируемые источники";
|
||||
"attachment" = "Вложение";
|
||||
"post_as_group" = "От имени сообщества";
|
||||
"comment_as_group" = "От имени сообщества";
|
||||
|
@ -226,16 +225,19 @@
|
|||
"post_is_ad" = "Этот пост был размещён за взятку.";
|
||||
"edited_short" = "ред.";
|
||||
|
||||
"feed_settings" = "Настройки ленты";
|
||||
"ignored_sources" = "Игнорируемые источники";
|
||||
"ignore_user" = "Игнорировать пользователя";
|
||||
"unignore_user" = "Не игнорировать пользователя";
|
||||
|
||||
"ignore_club" = "Игнорировать группу";
|
||||
"unignore_club" = "Не игнорировать группу";
|
||||
"no_ignores_count" = "Игнорируемых источников нет.";
|
||||
"stop_ignore" = "Не игнорировать";
|
||||
"start_from_page" = "Начинать со страницы";
|
||||
"ignored_clubsers_list" = "Эти пользователи и группы не показываются в глобальной ленте.";
|
||||
"interesting_fact_zero" = "Интересный факт: вас никто не игнорирует!";
|
||||
"interesting_fact_one" = "Интересный факт: вас игнорирует один пользователь.";
|
||||
"interesting_fact_few" = "Интересный факт: вас игнорирует $1 пользователя.";
|
||||
"interesting_fact_many" = "Интересный факт: вас игнорирует $1 пользователей.";
|
||||
"interesting_fact_other" = "Интересный факт: вас игнорирует $1 пользователей.";
|
||||
"add_new_ignores" = "Добавить новое";
|
||||
|
||||
"all_posts" = "Все записи";
|
||||
"users_posts" = "Записи $1";
|
||||
|
@ -1453,7 +1455,9 @@
|
|||
|
||||
"invalid_club" = "Такой группы не существует.";
|
||||
"invalid_user" = "Такого пользователя не существует.";
|
||||
"ignored_sources_limit" = "Превышен лимит игнорируемых источников.";
|
||||
"no_sense" = "Нет смысла.";
|
||||
"cant_ignore_self" = "Нельзя игнорировать себя.";
|
||||
"max_ignores" = "Максимальное число игноров — $1";
|
||||
|
||||
"invalid_audio" = "Такой аудиозаписи не существует.";
|
||||
"do_not_have_audio" = "У вас нет этой аудиозаписи.";
|
||||
|
@ -1658,7 +1662,6 @@
|
|||
"question_confirm" = "Это действие нельзя отменить. Вы действительно уверены в том что хотите сделать?";
|
||||
"confirm_m" = "Подтвердить";
|
||||
"action_successfully" = "Операция успешна";
|
||||
"apply" = "Применить";
|
||||
|
||||
/* User alerts */
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ openvk:
|
|||
strict: false
|
||||
music:
|
||||
exposeOriginalURLs: true
|
||||
newsfeed:
|
||||
ignoredSourcesLimit: 50
|
||||
wall:
|
||||
christian: false
|
||||
anonymousPosting:
|
||||
|
|
Loading…
Reference in a new issue