Compare commits

..

1 commit

Author SHA1 Message Date
Ry0
991126b639
Merge d52e655a4c into 4b7d2b9b17 2025-05-27 12:01:44 +00:00
66 changed files with 703 additions and 651 deletions

View file

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace openvk\VKAPI\Handlers;
use openvk\Web\Models\Exceptions\InvalidUserNameException;
use openvk\Web\Util\Validator;
final class Account extends VKAPIRequestHandler
{
@ -96,7 +95,7 @@ final class Account extends VKAPIRequestHandler
# TODO: Filter
}
public function saveProfileInfo(string $first_name = "", string $last_name = "", string $screen_name = "", int $sex = -1, int $relation = -1, string $bdate = "", int $bdate_visibility = -1, string $home_town = "", string $status = "", string $telegram = null): object
public function saveProfileInfo(string $first_name = "", string $last_name = "", string $screen_name = "", int $sex = -1, int $relation = -1, string $bdate = "", int $bdate_visibility = -1, string $home_town = "", string $status = ""): object
{
$this->requireUser();
$this->willExecuteWriteAction();
@ -139,13 +138,13 @@ final class Account extends VKAPIRequestHandler
$user->setSex($sex == 1 ? 1 : 0);
}
if ($relation > -1 && $relation <= 8) {
if ($relation > -1) {
$user->setMarital_Status($relation);
}
if (!empty($bdate)) {
$birthday = strtotime($bdate);
if (!is_int($birthday) || $birthday > time()) {
if (!is_int($birthday)) {
$this->fail(100, "invalid value of bdate.");
}
@ -172,26 +171,9 @@ final class Account extends VKAPIRequestHandler
$user->setStatus($status);
}
if (!is_null($telegram)) {
if (empty($telegram)) {
$user->setTelegram(null);
} elseif (Validator::i()->telegramValid($telegram)) {
if (strpos($telegram, "t.me/") === 0) {
$user->setTelegram($telegram);
} else {
$user->setTelegram(ltrim($telegram, "@"));
}
}
}
if ($sex > 0 || $relation > -1 || $bdate_visibility > 1 || !is_null($telegram) || !empty("$first_name$last_name$screen_name$bdate$home_town$status")) {
if ($sex > 0 || $relation > -1 || $bdate_visibility > 1 || !empty("$first_name$last_name$screen_name$bdate$home_town$status")) {
$output["changed"] = 1;
try {
$user->save();
} catch (\TypeError $e) {
$output["changed"] = 0;
}
}
return (object) $output;
@ -201,7 +183,7 @@ final class Account extends VKAPIRequestHandler
{
$this->requireUser();
if (!OPENVK_ROOT_CONF['openvk']['preferences']['commerce']) {
$this->fail(-105, "Commerce is disabled on this instance");
$this->fail(105, "Commerce is disabled on this instance");
}
return (object) ['votes' => $this->getUser()->getCoins()];

View file

@ -14,7 +14,7 @@ use openvk\Web\Models\Entities\{Topic, Comment, User, Photo, Video};
final class Board extends VKAPIRequestHandler
{
public function addTopic(int $group_id, string $title, string $text = null, bool $from_group = true)
public function addTopic(int $group_id, string $title, string $text = "", bool $from_group = true)
{
$this->requireUser();
$this->willExecuteWriteAction();
@ -30,7 +30,6 @@ final class Board extends VKAPIRequestHandler
}
$flags = 0;
if ($from_group == true && $club->canBeModifiedBy($this->getUser())) {
$flags |= 0b10000000;
}
@ -41,10 +40,8 @@ final class Board extends VKAPIRequestHandler
$topic->setTitle(ovk_proc_strtr($title, 127));
$topic->setCreated(time());
$topic->setFlags($flags);
$topic->save();
try {
if (!empty($text)) {
$comment = new Comment();
$comment->setOwner($this->getUser()->getId());
@ -53,12 +50,8 @@ final class Board extends VKAPIRequestHandler
$comment->setContent($text);
$comment->setCreated(time());
$comment->setFlags($flags);
$comment->save();
}
} catch (\Throwable $e) {
return $topic->getId();
}
return $topic->getId();
}
@ -82,35 +75,32 @@ final class Board extends VKAPIRequestHandler
return 1;
}
public function createComment(int $group_id, int $topic_id, string $message = "", bool $from_group = true)
public function createComment(int $group_id, int $topic_id, string $message = "", string $attachments = "", bool $from_group = true)
{
$this->requireUser();
$this->willExecuteWriteAction();
if (empty($message)) {
if (empty($message) && empty($attachments)) {
$this->fail(100, "Required parameter 'message' missing.");
}
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || $topic->isDeleted() || $topic->isClosed()) {
$this->fail(15, "Access denied");
}
$flags = 0;
if ($from_group != 0 && ($topic->getClub()->canBeModifiedBy($this->user))) {
if ($from_group != 0 && !is_null($topic->getClub()) && $topic->getClub()->canBeModifiedBy($this->user)) {
$flags |= 0b10000000;
}
$comment = new Comment();
$comment->setOwner($this->getUser()->getId());
$comment->setModel(get_class($topic));
$comment->setTarget($topic->getId());
$comment->setContent($message);
$comment->setCreated(time());
$comment->setFlags($flags);
$comment->save();
return $comment->getId();
@ -123,7 +113,7 @@ final class Board extends VKAPIRequestHandler
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || $topic->isDeleted() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
if (!$topic || !$topic->getClub() || $topic->isDeleted() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
return 0;
}
@ -139,7 +129,7 @@ final class Board extends VKAPIRequestHandler
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || $topic->isDeleted() || !$topic->canBeModifiedBy($this->getUser())) {
if (!$topic || !$topic->getClub() || $topic->isDeleted() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
return 0;
}
@ -157,7 +147,7 @@ final class Board extends VKAPIRequestHandler
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
if (!$topic || !$topic->getClub() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
return 0;
}
@ -168,92 +158,75 @@ final class Board extends VKAPIRequestHandler
return 1;
}
public function getComments(int $group_id, int $topic_id, bool $need_likes = false, int $offset = 0, int $count = 10, bool $extended = false)
public function getComments(int $group_id, int $topic_id, bool $need_likes = false, int $start_comment_id = 0, int $offset = 0, int $count = 40, bool $extended = false, string $sort = "asc")
{
# start_comment_id ne robit
$this->requireUser();
if ($count < 1 || $count > 100) {
$this->fail(4, "Invalid count");
}
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || $topic->isDeleted()) {
$this->fail(5, "Not found");
if (!$topic || !$topic->getClub() || $topic->isDeleted()) {
$this->fail(5, "Invalid topic");
}
$obj = (object) [
$arr = [
"items" => [],
];
if ($extended) {
$obj->profiles = [];
$obj->groups = [];
}
$comments = array_slice(iterator_to_array($topic->getComments(1, $count + $offset)), $offset);
foreach ($comments as $comment) {
$obj->items[] = $comment->toVkApiStruct($this->getUser(), $need_likes);
$comms = array_slice(iterator_to_array($topic->getComments(1, $count + $offset)), $offset);
foreach ($comms as $comm) {
$arr["items"][] = $this->getApiBoardComment($comm, $need_likes);
if ($extended) {
$owner = $comment->getOwner();
if ($owner instanceof \openvk\Web\Models\Entities\User) {
$obj->profiles[] = $owner->toVkApiStruct();
if ($comm->getOwner() instanceof \openvk\Web\Models\Entities\User) {
$arr["profiles"][] = $comm->getOwner()->toVkApiStruct();
}
if ($owner instanceof \openvk\Web\Models\Entities\Club) {
$obj->groups[] = $owner->toVkApiStruct();
if ($comm->getOwner() instanceof \openvk\Web\Models\Entities\Club) {
$arr["groups"][] = $comm->getOwner()->toVkApiStruct();
}
}
}
return $obj;
return $arr;
}
public function getTopics(int $group_id, string $topic_ids = "", int $offset = 0, int $count = 10, bool $extended = false, int $preview = 0, int $preview_length = 90)
public function getTopics(int $group_id, string $topic_ids = "", int $order = 1, int $offset = 0, int $count = 40, bool $extended = false, int $preview = 0, int $preview_length = 90)
{
# TODO: $extended
# order и extended ничё не делают
$this->requireUser();
if ($count < 1 || $count > 100) {
$this->fail(4, "Invalid count");
}
$obj = (object) [];
$arr = [];
$club = (new ClubsRepo())->get($group_id);
if (!$club || !$club->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
}
$topics = array_slice(iterator_to_array((new TopicsRepo())->getClubTopics($club, 1, $count + $offset)), $offset);
$obj->count = (new TopicsRepo())->getClubTopicsCount($club);
$obj->items = [];
$obj->profiles = [];
$obj->can_add_topics = $club->canBeModifiedBy($this->getUser()) ? true : ($club->isEveryoneCanCreateTopics() ? true : false);
$arr["count"] = (new TopicsRepo())->getClubTopicsCount($club);
$arr["items"] = [];
$arr["default_order"] = $order;
$arr["can_add_topics"] = $club->canBeModifiedBy($this->getUser()) ? true : ($club->isEveryoneCanCreateTopics() ? true : false);
$arr["profiles"] = [];
if (empty($topic_ids)) {
foreach ($topics as $topic) {
$obj->items[] = $topic->toVkApiStruct($preview, $preview_length > 1 ? $preview_length : 90);
if ($topic->isDeleted()) {
continue;
}
$arr["items"][] = $topic->toVkApiStruct($preview, $preview_length > 1 ? $preview_length : 90);
}
} else {
$topics = explode(',', $topic_ids);
foreach ($topics as $topic_id) {
$topic = (new TopicsRepo())->getTopicById($group_id, (int) $topic_id);
foreach ($topics as $topic) {
$id = explode("_", $topic);
$topicy = (new TopicsRepo())->getTopicById((int) $id[0], (int) $id[1]);
if ($topic && !$topic->isDeleted()) {
$obj->items[] = $topic->toVkApiStruct($preview, $preview_length > 1 ? $preview_length : 90);
if ($topicy && !$topicy->isDeleted()) {
$arr["items"][] = $topicy->toVkApiStruct($preview, $preview_length > 1 ? $preview_length : 90);
}
}
}
return $obj;
return $arr;
}
public function openTopic(int $group_id, int $topic_id)
@ -263,7 +236,7 @@ final class Board extends VKAPIRequestHandler
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || !$topic->isDeleted() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
if (!$topic || !$topic->getClub() || !$topic->isDeleted() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
return 0;
}
@ -275,6 +248,11 @@ final class Board extends VKAPIRequestHandler
return 1;
}
public function restoreComment(int $group_id, int $topic_id, int $comment_id)
{
$this->fail(501, "Not implemented");
}
public function unfixTopic(int $group_id, int $topic_id)
{
$this->requireUser();
@ -282,7 +260,7 @@ final class Board extends VKAPIRequestHandler
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
if (!$topic || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
if (!$topic || !$topic->getClub() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
return 0;
}
@ -297,4 +275,33 @@ final class Board extends VKAPIRequestHandler
return 1;
}
private function getApiBoardComment(?Comment $comment, bool $need_likes = false)
{
$res = (object) [];
$res->id = $comment->getId();
$res->from_id = $comment->getOwner()->getId();
$res->date = $comment->getPublicationTime()->timestamp();
$res->text = $comment->getText(false);
$res->attachments = [];
$res->likes = [];
if ($need_likes) {
$res->likes = [
"count" => $comment->getLikesCount(),
"user_likes" => (int) $comment->hasLikeFrom($this->getUser()),
"can_like" => 1, # а чё типо не может ахахаххахах
];
}
foreach ($comment->getChildren() as $attachment) {
if ($attachment->isDeleted()) {
continue;
}
$res->attachments[] = $attachment->toVkApiStruct();
}
return $res;
}
}

View file

@ -10,33 +10,49 @@ use openvk\Web\Models\Entities\Notifications\GiftNotification;
final class Gifts extends VKAPIRequestHandler
{
public function get(int $user_id = 0, int $count = 10, int $offset = 0)
public function get(int $user_id = null, int $count = 10, int $offset = 0)
{
# There is no extended :)
$this->requireUser();
$i = 0;
$i += $offset;
$server_url = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
if ($user_id < 1) {
$user_id = $this->getUser()->getId();
if ($user_id) {
$user = (new UsersRepo())->get($user_id);
} else {
$user = $this->getUser();
}
$user = (new UsersRepo())->get($user_id);
if (!$user || $user->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(177, "Invalid user");
}
if (!$user->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
}
$gift_item = [];
$user_gifts = array_slice(iterator_to_array($user->getGifts(1, $count)), $offset, $count);
/*
if(!$user->getPrivacyPermission('gifts.read', $this->getUser()))
$this->fail(15, "Access denied: this user chose to hide his gifts");*/
foreach ($user_gifts as $gift) {
if (!$user->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
}
$gift_item = [];
$userGifts = array_slice(iterator_to_array($user->getGifts(1, $count, false)), $offset);
if (sizeof($userGifts) < 0) {
return null;
}
foreach ($userGifts as $gift) {
if ($i < $count) {
$gift_item[] = [
"id" => $i,
"from_id" => $gift->anon == true ? 0 : $gift->sender->getId(),
"message" => $gift->caption == null ? "" : $gift->caption,
"date" => $gift->sent->timestamp(),
@ -46,8 +62,11 @@ final class Gifts extends VKAPIRequestHandler
"thumb_96" => $server_url . $gift->gift->getImage(2),
"thumb_48" => $server_url . $gift->gift->getImage(2),
],
"privacy" => 0,
];
}
$i += 1;
}
return $gift_item;
}
@ -57,14 +76,14 @@ final class Gifts extends VKAPIRequestHandler
$this->requireUser();
$this->willExecuteWriteAction();
$user = (new UsersRepo())->get((int) $user_ids);
if (!OPENVK_ROOT_CONF['openvk']['preferences']['commerce']) {
$this->fail(-105, "Commerce is disabled on this instance");
$this->fail(105, "Commerce is disabled on this instance");
}
$user = (new UsersRepo())->get((int) $user_ids); # FAKE прогноз погоды (в данном случае user_ids)
if (!$user || $user->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(177, "Invalid user");
}
if (!$user->canBeViewedBy($this->getUser())) {
@ -74,7 +93,7 @@ final class Gifts extends VKAPIRequestHandler
$gift = (new GiftsRepo())->get($gift_id);
if (!$gift) {
$this->fail(15, "Invalid gift");
$this->fail(165, "Invalid gift");
}
$price = $gift->getPrice();
@ -115,17 +134,24 @@ final class Gifts extends VKAPIRequestHandler
];
}
public function getCategories(bool $extended = false, int $page = 1)
public function delete()
{
$this->requireUser();
$this->willExecuteWriteAction();
$this->fail(501, "Not implemented");
}
# в vk кстати называется gifts.getCatalog
public function getCategories(bool $extended = false, int $page = 1)
{
$cats = (new GiftsRepo())->getCategories($page);
$categ = [];
$i = 0;
$server_url = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
if (!OPENVK_ROOT_CONF['openvk']['preferences']['commerce']) {
$this->fail(-105, "Commerce is disabled on this instance");
$this->fail(105, "Commerce is disabled on this instance");
}
foreach ($cats as $cat) {
@ -158,19 +184,17 @@ final class Gifts extends VKAPIRequestHandler
$this->requireUser();
if (!OPENVK_ROOT_CONF['openvk']['preferences']['commerce']) {
$this->fail(-105, "Commerce is disabled on this instance");
$this->fail(105, "Commerce is disabled on this instance");
}
$gift_category = (new GiftsRepo())->getCat($id);
if (!$gift_category) {
$this->fail(15, "Category not found");
if (!(new GiftsRepo())->getCat($id)) {
$this->fail(177, "Category not found");
}
$gifts_list = $gift_category->getGifts($page);
$giftz = ((new GiftsRepo())->getCat($id))->getGifts($page);
$gifts = [];
foreach ($gifts_list as $gift) {
foreach ($giftz as $gift) {
$gifts[] = [
"name" => $gift->getName(),
"image" => $gift->getImage(2),

View file

@ -107,6 +107,7 @@ final class Groups extends VKAPIRequestHandler
$backgrounds = $usr->getBackDropPictureURLs();
$rClubs[$i]->background = $backgrounds;
break;
# unstandard feild
case "suggested_count":
if ($usr->getWallType() != 2) {
$rClubs[$i]->suggested_count = null;
@ -245,7 +246,7 @@ final class Groups extends VKAPIRequestHandler
$response[$i]->suggested_count = $clb->getSuggestedPostsCount($this->getUser());
break;
case "contacts":
$contacts = [];
$contacts;
$contactTmp = $clb->getManagers(1, true);
foreach ($contactTmp as $contact) {
@ -334,6 +335,23 @@ final class Groups extends VKAPIRequestHandler
return 1;
}
public function create(string $title, string $description = "", string $type = "group", int $public_category = 1, int $public_subcategory = 1, int $subtype = 1)
{
$this->requireUser();
$this->willExecuteWriteAction();
$club = new Club();
$club->setName($title);
$club->setAbout($description);
$club->setOwner($this->getUser()->getId());
$club->save();
$club->toggleSubscription($this->getUser());
return $this->getById((string) $club->getId());
}
public function edit(
int $group_id,
string $title = null,
@ -353,15 +371,13 @@ final class Groups extends VKAPIRequestHandler
$club = (new ClubsRepo())->get($group_id);
if (!$club) {
$this->fail(15, "Access denied");
$this->fail(203, "Club not found");
}
if (!$club || !$club->canBeModifiedBy($this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(15, "You can't modify this group.");
}
if (!empty($screen_name) && !$club->setShortcode($screen_name)) {
$this->fail(103, "Invalid screen_name");
$this->fail(103, "Invalid shortcode.");
}
!empty($title) ? $club->setName($title) : null;
@ -388,86 +404,260 @@ final class Groups extends VKAPIRequestHandler
try {
$club->save();
} catch (\TypeError $e) {
return 1;
$this->fail(15, "Nothing changed");
} catch (\Exception $e) {
return 0;
$this->fail(18, "An unknown error occurred: maybe you set an incorrect value?");
}
return 1;
}
public function getMembers(int $group_id, int $offset = 0, int $count = 10, string $fields = "")
public function getMembers(string $group_id, string $sort = "id_asc", int $offset = 0, int $count = 100, string $fields = "", string $filter = "any")
{
$this->requireUser();
$club = (new ClubsRepo())->get($group_id);
if (!$club || !$club->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
# bdate,can_post,can_see_all_posts,can_see_audio,can_write_private_message,city,common_count,connections,contacts,country,domain,education,has_mobile,last_seen,lists,online,online_mobile,photo_100,photo_200,photo_200_orig,photo_400_orig,photo_50,photo_max,photo_max_orig,relation,relatives,schools,sex,site,status,universities
$club = (new ClubsRepo())->get((int) $group_id);
if (!$club) {
$this->fail(125, "Invalid group id");
}
$sort_string = "follower ASC";
$members = array_slice(iterator_to_array($club->getFollowers(1, $count, $sort_string)), $offset, $count);
$sorter = "follower ASC";
$obj = (object) [
"count" => sizeof($members),
"items" => [],
switch ($sort) {
default:
case "time_asc":
case "id_asc":
$sorter = "follower ASC";
break;
case "time_desc":
case "id_desc":
$sorter = "follower DESC";
break;
}
$members = array_slice(iterator_to_array($club->getFollowers(1, $count, $sorter)), $offset);
$arr = (object) [
"count" => count($members),
"items" => []];
$filds = explode(",", $fields);
$i = 0;
foreach ($members as $member) {
if ($i > $count) {
break;
}
$arr->items[] = (object) [
"id" => $member->getId(),
"first_name" => $member->getFirstName(),
"last_name" => $member->getLastName(),
];
foreach ($members as $member) {
$obj->items[] = $member->toVkApiStruct($this->getUser(), $fields);
foreach ($filds as $fild) {
$canView = $member->canBeViewedBy($this->getUser());
switch ($fild) {
case "bdate":
if (!$canView) {
$arr->items[$i]->bdate = "01.01.1970";
break;
}
return $obj;
$arr->items[$i]->bdate = $member->getBirthday() ? $member->getBirthday()->format('%e.%m.%Y') : null;
break;
case "can_post":
$arr->items[$i]->can_post = $club->canBeModifiedBy($member);
break;
case "can_see_all_posts":
$arr->items[$i]->can_see_all_posts = 1;
break;
case "can_see_audio":
$arr->items[$i]->can_see_audio = 1;
break;
case "can_write_private_message":
$arr->items[$i]->can_write_private_message = 0;
break;
case "common_count":
$arr->items[$i]->common_count = 420;
break;
case "connections":
$arr->items[$i]->connections = 1;
break;
case "contacts":
if (!$canView) {
$arr->items[$i]->contacts = "secret@gmail.com";
break;
}
$arr->items[$i]->contacts = $member->getContactEmail();
break;
case "country":
$arr->items[$i]->country = 1;
break;
case "domain":
$arr->items[$i]->domain = "";
break;
case "education":
$arr->items[$i]->education = "";
break;
case "has_mobile":
$arr->items[$i]->has_mobile = false;
break;
case "last_seen":
if (!$canView) {
$arr->items[$i]->last_seen = 0;
break;
}
$arr->items[$i]->last_seen = $member->getOnline()->timestamp();
break;
case "lists":
$arr->items[$i]->lists = "";
break;
case "online":
if (!$canView) {
$arr->items[$i]->online = false;
break;
}
$arr->items[$i]->online = $member->isOnline();
break;
case "online_mobile":
if (!$canView) {
$arr->items[$i]->online_mobile = false;
break;
}
$arr->items[$i]->online_mobile = $member->getOnlinePlatform() == "android" || $member->getOnlinePlatform() == "iphone" || $member->getOnlinePlatform() == "mobile";
break;
case "photo_100":
$arr->items[$i]->photo_100 = $member->getAvatarURL("tiny");
break;
case "photo_200":
$arr->items[$i]->photo_200 = $member->getAvatarURL("normal");
break;
case "photo_200_orig":
$arr->items[$i]->photo_200_orig = $member->getAvatarURL("normal");
break;
case "photo_400_orig":
$arr->items[$i]->photo_400_orig = $member->getAvatarURL("normal");
break;
case "photo_max":
$arr->items[$i]->photo_max = $member->getAvatarURL("original");
break;
case "photo_max_orig":
$arr->items[$i]->photo_max_orig = $member->getAvatarURL();
break;
case "relation":
$arr->items[$i]->relation = $member->getMaritalStatus();
break;
case "relatives":
$arr->items[$i]->relatives = 0;
break;
case "schools":
$arr->items[$i]->schools = 0;
break;
case "sex":
if (!$canView) {
$arr->items[$i]->sex = -1;
break;
}
$arr->items[$i]->sex = $member->isFemale() ? 1 : 2;
break;
case "site":
if (!$canView) {
$arr->items[$i]->site = null;
break;
}
$arr->items[$i]->site = $member->getWebsite();
break;
case "status":
if (!$canView) {
$arr->items[$i]->status = "r";
break;
}
$arr->items[$i]->status = $member->getStatus();
break;
case "universities":
$arr->items[$i]->universities = 0;
break;
}
}
$i++;
}
return $arr;
}
public function getSettings(string $group_id)
{
$this->requireUser();
$club = (new ClubsRepo())->get((int) $group_id);
if (!$club || !$club->canBeModifiedBy($this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(15, "You can't get settings of this group.");
}
$arr = (object) [
"title" => $club->getName(),
"description" => $club->getDescription(),
"description" => $club->getDescription() != null ? $club->getDescription() : "",
"address" => $club->getShortcode(),
"wall" => $club->getWallType(), # is different from vk values
"wall" => $club->getWallType(), # отличается от вкшных но да ладно
"photos" => 1,
"video" => 0,
"audio" => $club->isEveryoneCanUploadAudios() ? 1 : 0,
"docs" => 1,
"docs" => 0,
"topics" => $club->isEveryoneCanCreateTopics() == true ? 1 : 0,
"wiki" => 0,
"messages" => 0,
"obscene_filter" => 0,
"obscene_stopwords" => 0,
"obscene_words" => "",
"access" => 1,
"subject" => 1,
"subject_list" => [
0 => "в",
1 => "опенвк",
2 => "нет",
3 => "категорий",
4 => "групп",
],
"rss" => "/club" . $club->getId() . "/rss",
"website" => $club->getWebsite(),
"age_limits" => 0,
"market" => [],
];
return $arr;
}
public function isMember(string $group_id, int $user_id, int $extended = 0)
public function isMember(string $group_id, int $user_id, string $user_ids = "", bool $extended = false)
{
$this->requireUser();
$id = $user_id != null ? $user_id : explode(",", $user_ids);
$input_club = (new ClubsRepo())->get(abs((int) $group_id));
$input_user = (new UsersRepo())->get(abs((int) $user_id));
if (!$input_club || !$input_club->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
if ($group_id < 0) {
$this->fail(228, "Remove the minus from group_id");
}
if (!$input_user || $input_user->isDeleted()) {
$this->fail(15, "Not found");
$club = (new ClubsRepo())->get((int) $group_id);
$usver = (new UsersRepo())->get((int) $id);
if (!$club || $group_id == 0) {
$this->fail(203, "Invalid club");
}
if ($extended == 0) {
return $input_club->getSubscriptionStatus($input_user) ? 1 : 0;
if (!$usver || $usver->isDeleted() || $user_id == 0) {
$this->fail(30, "Invalid user");
}
if ($extended == false) {
return $club->getSubscriptionStatus($usver) ? 1 : 0;
} else {
return (object)
[
"member" => $input_club->getSubscriptionStatus($input_user) ? 1 : 0,
"member" => $club->getSubscriptionStatus($usver) ? 1 : 0,
"request" => 0,
"invitation" => 0,
"can_invite" => 0,
@ -475,4 +665,11 @@ final class Groups extends VKAPIRequestHandler
];
}
}
public function remove(int $group_id, int $user_id)
{
$this->requireUser();
$this->fail(501, "Not implemented");
}
}

View file

@ -118,14 +118,7 @@ final class Likes extends VKAPIRequestHandler
}
if (!$user->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
}
if ($user->isPrivateLikes()) {
return (object) [
"liked" => 1,
"copied" => 1,
];
$this->fail(1984, "Access denied: you can't see this user");
}
$postable = null;

View file

@ -13,49 +13,38 @@ use openvk\Web\Models\Entities\{Note, Comment};
final class Notes extends VKAPIRequestHandler
{
public function add(string $title, string $text)
public function add(string $title, string $text, int $privacy = 0, int $comment_privacy = 0, string $privacy_view = "", string $privacy_comment = "")
{
$this->requireUser();
$this->willExecuteWriteAction();
if (empty($title)) {
$this->fail(100, "Required parameter 'title' missing.");
}
$note = new Note();
$note->setOwner($this->getUser()->getId());
$note->setCreated(time());
$note->setName($title);
$note->setSource($text);
$note->setEdited(time());
$note->save();
return $note->getVirtualId();
}
public function createComment(int $note_id, int $owner_id, string $message, string $attachments = "")
public function createComment(string $note_id, int $owner_id, string $message, int $reply_to = 0, string $attachments = "")
{
$this->requireUser();
$this->willExecuteWriteAction();
if (empty($message)) {
$this->fail(100, "Required parameter 'message' missing.");
}
$note = (new NotesRepo())->getNoteById($owner_id, $note_id);
$note = (new NotesRepo())->getNoteById((int) $owner_id, (int) $note_id);
if (!$note) {
$this->fail(15, "Access denied");
$this->fail(180, "Note not found");
}
if ($note->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(189, "Note is deleted");
}
if ($note->getOwner()->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(403, "Owner is deleted");
}
if (!$note->canBeViewedBy($this->getUser())) {
@ -63,7 +52,11 @@ final class Notes extends VKAPIRequestHandler
}
if (!$note->getOwner()->getPrivacyPermission('notes.read', $this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(43, "No access");
}
if (empty($message) && empty($attachments)) {
$this->fail(100, "Required parameter 'message' missing.");
}
$comment = new Comment();
@ -74,9 +67,78 @@ final class Notes extends VKAPIRequestHandler
$comment->setCreated(time());
$comment->save();
if (!empty($attachments)) {
$attachmentsArr = explode(",", $attachments);
if (sizeof($attachmentsArr) > 10) {
$this->fail(50, "Error: too many attachments");
}
foreach ($attachmentsArr as $attac) {
$attachmentType = null;
if (str_contains($attac, "photo")) {
$attachmentType = "photo";
} elseif (str_contains($attac, "video")) {
$attachmentType = "video";
} else {
$this->fail(205, "Unknown attachment type");
}
$attachment = str_replace($attachmentType, "", $attac);
$attachmentOwner = (int) explode("_", $attachment)[0];
$attachmentId = (int) end(explode("_", $attachment));
$attacc = null;
if ($attachmentType == "photo") {
$attacc = (new PhotosRepo())->getByOwnerAndVID($attachmentOwner, $attachmentId);
if (!$attacc || $attacc->isDeleted()) {
$this->fail(100, "Photo does not exists");
}
if ($attacc->getOwner()->getId() != $this->getUser()->getId()) {
$this->fail(43, "You do not have access to this photo");
}
$comment->attach($attacc);
} elseif ($attachmentType == "video") {
$attacc = (new VideosRepo())->getByOwnerAndVID($attachmentOwner, $attachmentId);
if (!$attacc || $attacc->isDeleted()) {
$this->fail(100, "Video does not exists");
}
if ($attacc->getOwner()->getId() != $this->getUser()->getId()) {
$this->fail(43, "You do not have access to this video");
}
$comment->attach($attacc);
}
}
}
return $comment->getId();
}
public function delete(string $note_id)
{
$this->requireUser();
$this->willExecuteWriteAction();
$note = (new NotesRepo())->get((int) $note_id);
if (!$note) {
$this->fail(180, "Note not found");
}
if (!$note->canBeModifiedBy($this->getUser())) {
$this->fail(15, "Access to note denied");
}
$note->delete();
return 1;
}
public function edit(string $note_id, string $title = "", string $text = "", int $privacy = 0, int $comment_privacy = 0, string $privacy_view = "", string $privacy_comment = "")
{
$this->requireUser();
@ -85,15 +147,15 @@ final class Notes extends VKAPIRequestHandler
$note = (new NotesRepo())->getNoteById($this->getUser()->getId(), (int) $note_id);
if (!$note) {
$this->fail(15, "Access denied");
$this->fail(180, "Note not found");
}
if ($note->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(189, "Note is deleted");
}
if (!$note->canBeModifiedBy($this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(403, "No access");
}
!empty($title) ? $note->setName($title) : null;
@ -109,28 +171,26 @@ final class Notes extends VKAPIRequestHandler
public function get(int $user_id, string $note_ids = "", int $offset = 0, int $count = 10, int $sort = 0)
{
$this->requireUser();
$user = (new UsersRepo())->get($user_id);
if (!$user || $user->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(15, "Invalid user");
}
if (!$user->getPrivacyPermission('notes.read', $this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(15, "Access denied: this user chose to hide his notes");
}
if (!$user->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
}
$notes_return_object = (object) [
$nodez = (object) [
"count" => 0,
"items" => [],
"notes" => [],
];
if (empty($note_ids)) {
$notes_return_object->count = (new NotesRepo())->getUserNotesCount($user);
$nodez->count = (new NotesRepo())->getUserNotesCount($user);
$notes = array_slice(iterator_to_array((new NotesRepo())->getUserNotes($user, 1, $count + $offset, $sort == 0 ? "ASC" : "DESC")), $offset);
@ -139,21 +199,25 @@ final class Notes extends VKAPIRequestHandler
continue;
}
$notes_return_object->items[] = $note->toVkApiStruct();
$nodez->notes[] = $note->toVkApiStruct();
}
} else {
$notes_splitted = explode(',', $note_ids);
$notes = explode(',', $note_ids);
foreach ($notes_splitted as $note_id) {
$note = (new NotesRepo())->getNoteById($user_id, $note_id);
foreach ($notes as $note) {
$id = explode("_", $note);
$items = [];
$note = (new NotesRepo())->getNoteById((int) $id[0], (int) $id[1]);
if ($note && !$note->isDeleted()) {
$notes_return_object->items[] = $note->toVkApiStruct();
$nodez->notes[] = $note->toVkApiStruct();
$nodez->count++;
}
}
}
return $notes_return_object;
return $nodez;
}
public function getById(int $note_id, int $owner_id, bool $need_wiki = false)
@ -163,23 +227,23 @@ final class Notes extends VKAPIRequestHandler
$note = (new NotesRepo())->getNoteById($owner_id, $note_id);
if (!$note) {
$this->fail(15, "Access denied");
$this->fail(180, "Note not found");
}
if ($note->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(189, "Note is deleted");
}
if (!$note->getOwner() || $note->getOwner()->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(177, "Owner does not exists");
}
if (!$note->getOwner()->getPrivacyPermission('notes.read', $this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(40, "Access denied: this user chose to hide his notes");
}
if (!$note->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(15, "Access to note denied");
}
return $note->toVkApiStruct();
@ -192,23 +256,23 @@ final class Notes extends VKAPIRequestHandler
$note = (new NotesRepo())->getNoteById($owner_id, $note_id);
if (!$note) {
$this->fail(15, "Access denied");
$this->fail(180, "Note not found");
}
if ($note->isDeleted()) {
$this->fail(15, "Access denied");
$this->fail(189, "Note is deleted");
}
if (!$note->getOwner()) {
$this->fail(15, "Access denied");
$this->fail(177, "Owner does not exists");
}
if (!$note->getOwner()->getPrivacyPermission('notes.read', $this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(14, "No access");
}
if (!$note->canBeViewedBy($this->getUser())) {
$this->fail(15, "Access denied");
$this->fail(15, "Access to note denied");
}
$arr = (object) [
@ -222,4 +286,14 @@ final class Notes extends VKAPIRequestHandler
return $arr;
}
public function getFriendsNotes(int $offset = 0, int $count = 0)
{
$this->fail(501, "Not implemented");
}
public function restoreComment(int $comment_id = 0, int $owner_id = 0)
{
$this->fail(501, "Not implemented");
}
}

View file

@ -120,11 +120,11 @@ final class Polls extends VKAPIRequestHandler
$poll = (new PollsRepo())->get($poll_id);
if (!$poll) {
$this->fail(15, "Access denied");
$this->fail(251, "Invalid poll");
}
if ($poll->isAnonymous()) {
$this->fail(15, "Access denied");
$this->fail(251, "Access denied: poll is anonymous.");
}
$voters = array_slice($poll->getVoters($answer_ids, 1, $offset + $count), $offset);
@ -175,4 +175,10 @@ final class Polls extends VKAPIRequestHandler
return $this->getById($poll->getId());
}
public function edit()
{
#todo
return 1;
}
}

View file

@ -20,18 +20,12 @@ final class Video extends VKAPIRequestHandler
$this->requireUser();
if (!empty($videos)) {
$vids = array_unique(explode(',', $videos));
if (sizeof($vids) > 100) {
$this->fail(15, "Too many ids given");
}
$vids = explode(',', $videos);
$profiles = [];
$groups = [];
$items = [];
foreach ($vids as $vid) {
$id = explode("_", $vid);
$items = [];
$video = (new VideosRepo())->getByOwnerAndVID(intval($id[0]), intval($id[1]));
if ($video && !$video->isDeleted()) {

View file

@ -1104,18 +1104,13 @@ final class Wall extends VKAPIRequestHandler
$post = (new PostsRepo())->getPostById($owner_id, $post_id, true);
if (!$post || $post->isDeleted()) {
$this->fail(15, "Not found");
$this->fail(583, "Invalid post");
}
$wallOwner = $post->getWallOwner();
# trying to solve the condition below.
# $post->getTargetWall() < 0 - if post on wall of club
# !$post->getWallOwner()->canBeModifiedBy($this->getUser()) - group is cannot be modifiet by %user%
# $post->getWallOwner()->getWallType() != 1 - wall is not open
# $post->getSuggestionType() == 0 - post is not suggested
if ($post->getTargetWall() < 0 && !$post->getWallOwner()->canBeModifiedBy($this->getUser()) && $post->getWallOwner()->getWallType() != 1 && $post->getSuggestionType() == 0) {
$this->fail(15, "Access denied");
$this->fail(12, "Access denied: you can't delete your accepted post.");
}
if ($post->getOwnerPost() == $this->getUser()->getId() || $post->getTargetWall() == $this->getUser()->getId() || $owner_id < 0 && $wallOwner->canBeModifiedBy($this->getUser())) {

View file

@ -429,11 +429,6 @@ class Club extends RowModel
$this->save();
}
public function delete(bool $softly = true): void
{
$this->ban("");
}
public function unban(): void
{
$this->setBlock_Reason(null);

View file

@ -60,11 +60,6 @@ abstract class MediaCollection extends RowModel
}
}
public function getOwnerId(): int
{
return (int) $this->getRecord()->owner;
}
public function getPrettyId(): string
{
return $this->getRecord()->owner . "_" . $this->getRecord()->id;

View file

@ -138,13 +138,18 @@ class Note extends Postable
{
$res = (object) [];
$res->type = "note";
$res->id = $this->getVirtualId();
$res->owner_id = $this->getOwner()->getId();
$res->title = $this->getName();
$res->text = $this->getText();
$res->date = $this->getPublicationTime()->timestamp();
$res->comments = $this->getCommentsCount();
$res->read_comments = $this->getCommentsCount();
$res->view_url = "/note" . $this->getOwner()->getId() . "_" . $this->getVirtualId();
$res->privacy_view = 1;
$res->can_comment = 1;
$res->text_wiki = "r";
return $res;
}

View file

@ -336,12 +336,7 @@ class Photo extends Media
public function getAlbum(): ?Album
{
$album = (new Albums())->getAlbumByPhotoId($this);
if (!$album || $album->isDeleted()) {
return null;
}
return $album;
return (new Albums())->getAlbumByPhotoId($this);
}
public function toVkApiStruct(bool $photo_sizes = true, bool $extended = false): object

View file

@ -260,7 +260,6 @@ class Playlist extends MediaCollection
$cover->setDescription("Playlist cover image");
$cover->setFile($file);
$cover->setCreated(time());
$cover->setSystem(true);
$cover->save();
$this->setCover_photo_id($cover->getId());

View file

@ -75,9 +75,9 @@ abstract class Postable extends Attachable
return new DateTime($edited);
}
public function getComments(int $page, ?int $perPage = null, string $sort = "ASC"): \Traversable
public function getComments(int $page, ?int $perPage = null): \Traversable
{
return (new Comments())->getCommentsByTarget($this, $page, $perPage, $sort);
return (new Comments())->getCommentsByTarget($this, $page, $perPage);
}
public function getCommentsCount(): int

View file

@ -1487,11 +1487,6 @@ class User extends RowModel
return $this->isClosed();
}
public function HideGlobalFeed(): bool
{
return (bool) $this->getRecord()->hide_global_feed;
}
public function getRealId()
{
return $this->getId();
@ -1502,7 +1497,7 @@ class User extends RowModel
return $this->getPrivacySetting("likes.read") == User::PRIVACY_NO_ONE;
}
public function toVkApiStruct(?User $relation_user = null, string $fields = ''): object
public function toVkApiStruct(?User $user = null, string $fields = ''): object
{
$res = (object) [];
@ -1512,8 +1507,8 @@ class User extends RowModel
$res->deactivated = $this->isDeactivated();
$res->is_closed = $this->isClosed();
if (!is_null($relation_user)) {
$res->can_access_closed = (bool) $this->canBeViewedBy($relation_user);
if (!is_null($user)) {
$res->can_access_closed = (bool) $this->canBeViewedBy($user);
}
if (!is_array($fields)) {
@ -1569,18 +1564,18 @@ class User extends RowModel
$res->real_id = $this->getRealId();
break;
case "blacklisted_by_me":
if (!$relation_user) {
if (!$user) {
break;
}
$res->blacklisted_by_me = (int) $this->isBlacklistedBy($relation_user);
$res->blacklisted_by_me = (int) $this->isBlacklistedBy($user);
break;
case "blacklisted":
if (!$relation_user) {
if (!$user) {
break;
}
$res->blacklisted = (int) $relation_user->isBlacklistedBy($this);
$res->blacklisted = (int) $user->isBlacklistedBy($this);
break;
case "games":
$res->games = $this->getFavoriteGames();

View file

@ -119,7 +119,6 @@ final class AdminPresenter extends OpenVKPresenter
$user->setLast_Name($this->postParam("last_name"));
$user->setPseudo($this->postParam("nickname"));
$user->setStatus($this->postParam("status"));
$user->setHide_Global_Feed(empty($this->postParam("hide_global_feed") ? 0 : 1));
if (!$user->setShortCode(empty($this->postParam("shortcode")) ? null : $this->postParam("shortcode"))) {
$this->flash("err", tr("error"), tr("error_shorturl_incorrect"));
}

View file

@ -73,10 +73,10 @@ final class DocumentsPresenter extends OpenVKPresenter
$this->template->count = $docs->size();
$this->template->docs = iterator_to_array($docs->page($page, OPENVK_DEFAULT_PER_PAGE));
$this->template->locale_string = "you_have_x_documents";
if ($current_tab != 0) {
$this->template->locale_string = "x_documents_in_tab";
} elseif ($owner_id < 0) {
if ($owner_id < 0) {
$this->template->locale_string = "group_has_x_documents";
} elseif ($current_tab != 0) {
$this->template->locale_string = "x_documents_in_tab";
}
$this->template->canUpload = $owner_id == $this->user->id || $this->template->group->canBeModifiedBy($this->user->identity);

View file

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

View file

@ -13,8 +13,6 @@ final class InternalAPIPresenter extends OpenVKPresenter
private function fail(int $code, string $message): void
{
header("HTTP/1.1 400 Bad Request");
header("Content-Type: application/x-msgpack");
exit(MessagePack::pack([
"brpc" => 1,
"error" => [
@ -27,7 +25,6 @@ final class InternalAPIPresenter extends OpenVKPresenter
private function succ($payload): void
{
header("Content-Type: application/x-msgpack");
exit(MessagePack::pack([
"brpc" => 1,
"result" => $payload,
@ -149,7 +146,7 @@ final class InternalAPIPresenter extends OpenVKPresenter
{
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
header("HTTP/1.1 405 Method Not Allowed");
$this->redirect("/");
exit("ты‍ не по адресу");
}
$type = $this->queryParam("type", false);
@ -168,7 +165,7 @@ final class InternalAPIPresenter extends OpenVKPresenter
if ($type == 'post') {
$this->template->_template = 'components/post.xml';
$this->template->post = $post;
$this->template->commentSection = $this->queryParam("from_page") == "another";
$this->template->commentSection = true;
} elseif ($type == 'comment') {
$this->template->_template = 'components/comment.xml';
$this->template->comment = $post;

View file

@ -102,7 +102,7 @@ final class NoSpamPresenter extends OpenVKPresenter
$item = new $model($item);
if (property_exists($item->unwrap(), "deleted") && $item->isDeleted()) {
if (key_exists("deleted", $item->unwrap()) && $item->isDeleted()) {
$item->setDeleted(0);
$item->save();
}

View file

@ -272,27 +272,21 @@ final class PhotosPresenter extends OpenVKPresenter
$this->assertUserLoggedIn();
$this->willExecuteWriteAction(true);
$upload_context = $this->queryParam("upload_context");
if (is_null($this->queryParam("album"))) {
if ((int) $upload_context == $this->user->id) {
$album = $this->albums->getUserWallAlbum($this->user->identity);
}
} else {
[$owner, $id] = explode("_", $this->queryParam("album"));
$album = $this->albums->get((int) $id);
}
if ($_SERVER["REQUEST_METHOD"] == "GET" || $this->queryParam("act") == "finish") {
if (!$album || $album->isCreatedBySystem()) {
$this->flashFail("err", tr("error"), tr("error_adding_to_deleted"));
}
if (!$album) {
$this->flashFail("err", tr("error"), tr("error_adding_to_deleted"), 500, true);
}
if ($album && !$album->canBeModifiedBy($this->user->identity)) {
if ($album->getOwnerId() != $this->user->id) {
$this->flashFail("err", tr("error_access_denied_short"), tr("error_access_denied"));
}
# Для быстрой загрузки фоток из пикера фотографий нужен альбом, но юзер не может загружать фото
# в системные альбомы, так что так.
if (is_null($this->user) || !is_null($this->queryParam("album")) && !$album->canBeModifiedBy($this->user->identity)) {
$this->flashFail("err", tr("error_access_denied_short"), tr("error_access_denied"), 500, true);
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
@ -312,6 +306,8 @@ final class PhotosPresenter extends OpenVKPresenter
$phot->setDescription($description);
$phot->save();
$album = $phot->getAlbum();
}
$this->returnJson(["success" => true,
@ -350,12 +346,10 @@ final class PhotosPresenter extends OpenVKPresenter
$this->flashFail("err", "Неизвестная ошибка", "Не удалось сохранить фотографию в $name.", 500, true);
}
if ($album != null) {
$album->addPhoto($photo);
$album->setEdited(time());
$album->save();
}
}
$this->returnJson(["success" => true,
"photos" => $photos]);

View file

@ -133,7 +133,6 @@ final class VideosPresenter extends OpenVKPresenter
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$video->setName(empty($this->postParam("name")) ? null : $this->postParam("name"));
$video->setDescription(empty($this->postParam("desc")) ? null : $this->postParam("desc"));
$video->setUnlisted(false);
$video->save();
$this->flash("succ", tr("changes_saved"), tr("changes_saved_video_comment"));

View file

@ -211,7 +211,7 @@ final class WallPresenter extends OpenVKPresenter
$pPage = min((int) ($_GET["posts"] ?? OPENVK_DEFAULT_PER_PAGE), 50);
$queryBase = "FROM `posts` LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`) LEFT JOIN `profiles` ON LEAST(`posts`.`wall`, 0) = 0 AND `profiles`.`id` = ABS(`posts`.`wall`)";
$queryBase .= "WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND ((`profiles`.`profile_type` = 0 AND `profiles`.`hide_global_feed` = 0) OR `profiles`.`first_name` IS NULL) AND `posts`.`deleted` = 0 AND `posts`.`suggested` = 0";
$queryBase .= "WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND (`profiles`.`profile_type` = 0 OR `profiles`.`first_name` IS NULL) AND `posts`.`deleted` = 0 AND `posts`.`suggested` = 0";
if ($this->user->identity->getNsfwTolerance() === User::NSFW_INTOLERANT) {
$queryBase .= " AND `nsfw` = 0";
@ -471,11 +471,7 @@ final class WallPresenter extends OpenVKPresenter
}
$this->template->cCount = $post->getCommentsCount();
$this->template->cPage = (int) ($_GET["p"] ?? 1);
$this->template->sort = $this->queryParam("sort") ?? "asc";
$input_sort = $this->template->sort == "asc" ? "ASC" : "DESC";
$this->template->comments = iterator_to_array($post->getComments($this->template->cPage, null, $input_sort));
$this->template->comments = iterator_to_array($post->getComments($this->template->cPage));
}
public function renderLike(int $wall, int $post_id): void

View file

@ -210,7 +210,7 @@
{var $menuLinksAvaiable = sizeof(OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links']) > 0 && $thisUser->getLeftMenuItemStatus('links')}
<div n:if="$canAccessAdminPanel || $canAccessHelpdesk || $menuLinksAvaiable" class="menu_divider"></div>
<a href="/admin" class="link" n:if="$canAccessAdminPanel" title="{_admin} [Alt+Shift+A]" accesskey="a" rel="nofollow">{_admin}</a>
<a href="/support/tickets" class="link" n:if="$canAccessHelpdesk">{_helpdesk}
<a href="/support/tickets" class="link" n:if="$canAccessHelpdesk" rel="nofollow">{_helpdesk}
{if $helpdeskTicketNotAnsweredCount > 0}
(<b>{$helpdeskTicketNotAnsweredCount}</b>)
{/if}

View file

@ -60,10 +60,6 @@
<label for="city">{_admin_verification}</label>
<input class="toggle-large" type="checkbox" id="verify" name="verify" value="1" {if $user->isVerified()} checked {/if} />
</div>
<div class="field-group">
<label for="city">{_admin_hide_global_feed}</label>
<input class="toggle-large" type="checkbox" id="hide_global_feed" name="hide_global_feed" value="1" n:attr="checked => $user->HideGlobalFeed()" />
</div>
<div class="field-group">
<label for="city">{_admin_user_online}</label>
<select name="online" class="select">

View file

@ -16,7 +16,7 @@
{block tabs}
<div n:attr="id => ($act === 'list' ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($act === 'list' ? 'act_tab_a' : 'ki')" href="/search?q=&section=apps">{_all_apps}</a>
<a n:attr="id => ($act === 'list' ? 'act_tab_a' : 'ki')" href="?act=list">{_all_apps}</a>
</div>
<div n:attr="id => ($act === 'installed' ? 'activetabs' : 'ki')" class="tab">

View file

@ -20,9 +20,15 @@
{block content}
{var $is_gallery = $current_tab == 3 || $current_tab == 4}
<div id="docs_page_wrapper">
<div class="docs_page_tabs">
<div class="mb_tabs display_flex_row display_flex_space_between">
<div>
<div class="docs_page_search">
<form action="/search" method="get">
<input type="hidden" name="section" value="docs">
<input type="search" name="q" class="input_with_search_icon" placeholder="{_search_by_documents}">
</form>
<input n:if="$canUpload" id="upload_entry_point" class="button" type="button" value="{_upload_button}" {if isset($group)}data-gid="{$group->getId()}"{/if}>
</div>
<div n:if="sizeof($tabs) > 1" class="docs_page_tabs">
<div class="mb_tabs">
<div class="mb_tab" n:attr="id => $current_tab == 0 ? active">
<a href="?tab=0">{_document_type_0}</a>
</div>
@ -33,12 +39,9 @@
</a>
</div>
</div>
<input n:if="$canUpload" id="upload_entry_point" class="button" type="button" value="{_upload_button}" {if isset($group)}data-gid="{$group->getId()}"{/if}>
</div>
</div>
<div n:class="docs_page_content, $is_gallery ? docs_page_gallery">
<div n:if="$count > 0" class="summaryBar display_flex_row display_flex_space_between">
<div class="summaryBar display_flex_row display_flex_space_between">
<div class="summary">{tr($locale_string, $count)}.</div>
<select n:if="$count > 3" name="docs_sort">

View file

@ -34,12 +34,6 @@
</a>
</td>
</tr>
<tr>
<td><span class="nobold">{_sent}: </span></td>
<td>
{$x->sent}
</td>
</tr>
<tr n:if="!empty($x->caption)">
<td><span class="nobold">{_comment}: </span></td>
<td>{$x->caption}</td>

View file

@ -55,7 +55,7 @@
<tbody>
<tr>
<td width="120" valign="top"><span class="nobold">{_pronouns}: </span></td>
<td>{$user->isFemale() ? tr("female") : ($user->isNeutral() ? tr("neutral") : tr("male"))}</td>
<td>{$x->isFemale() ? tr("female") : ($x->isNeutral() ? tr("neutral") : tr("male"))}</td>
</tr>
<tr>
<td width="120" valign="top"><span class="nobold">{_registration_date}: </span></td>

View file

@ -269,13 +269,7 @@
search();
}
});
$("#apply").on("click", (e) => {
e.preventDefault()
MessageBox(tr("warning"), tr("nospam_prevention"), [tr("no"), tr("yes")], [Function.noop, () => {
search(Number($("#noSpam-ban-type").val()));
}]);
})
$("#apply").on("click", () => { search(Number($("#noSpam-ban-type").val())); })
async function selectChange(value) {
console.log(value);

View file

@ -13,7 +13,7 @@
<textarea name="html" style="display:none;"></textarea>
<div id="editor" style="width:600px;height:300px;border:1px solid grey"></div>
<p><i>{_something_is_supported_from_xhtml|noescape}</i></p>
<p><i><a href="/kb/notes">{_something}</a> {_supports_xhtml}</i></p>
<input type="hidden" name="hash" value="{$csrfToken}" />
<button class="button">{_save}</button>

View file

@ -18,7 +18,7 @@
<textarea name="html" style="display:none;"></textarea>
<div id="editor" style="width:600px;height:300px;border:1px solid grey"></div>
<p><i>{_something_is_supported_from_xhtml|noescape}</i></p>
<p><i><a href="/kb/notes">{_something}</a> {_supports_xhtml}</i></p>
<input type="hidden" name="hash" value="{$csrfToken}" />
<button class="button">{_save}</button>

View file

@ -5,7 +5,7 @@
{block title}{_albums} {$owner->getCanonicalName()}{/block}
{block header}
{if isset($thisUser) && $thisUser->getId() == $owner->getRealId()}
{if isset($thisUser) && $thisUser->getId() == $owner->getId()}
{_my_photos}
{else}
<a href="{$owner->getURL()}">
@ -18,7 +18,7 @@
{block size}
<div style="padding-bottom: 0px; padding-top: 0;" class="summaryBar">
<div class="summary">
{if !is_null($thisUser) && $owner->getRealId() === $thisUser->getId()}
{if !is_null($thisUser) && $owner->getId() === $thisUser->getId()}
{tr("albums_list", $count)}
{else}
{tr("albums", $count)}

View file

@ -42,6 +42,6 @@
{block description}
{var $author = $x->getUser()}
{ovk_proc_strtr($x->getContext(), 200)}<br/>
{ovk_proc_strtr($x->getContext(), 50)}<br/>
<span class="nobold">{_author}: </span> <a href="{$author->getURL()}">{$author->getCanonicalName()}</a>
{/block}

View file

@ -76,4 +76,14 @@
<input type="hidden" name="hash" value="{$csrfToken}" />
</form>
<script>
$(document).ready(() => {
u("#post-buttons1 .postFileSel").on("change", function() {
handleUpload.bind(this, 1)();
});
setupWallPostInputHandlers(1);
});
</script>
{/block}

View file

@ -33,14 +33,14 @@
</td>
<td>
{if $topic->getClub()->canBeModifiedBy($thisUser)}
<label><input type="checkbox" name="pin" n:attr="checked => $topic->isPinned()" /> {_pin_topic}</label><br />
<input type="checkbox" name="pin" n:attr="checked => $topic->isPinned()" /> {_pin_topic}<br />
{/if}
<label><input type="checkbox" name="close" n:attr="checked => $topic->isClosed()" /> {_close_topic}</label>
<input type="checkbox" name="close" n:attr="checked => $topic->isClosed()" /> {_close_topic}
</td>
</tr>
<tr>
<td>
<a id="_anotherDelete" class="button" href="/topic{$topic->getPrettyId()}/delete?hash={urlencode($csrfToken)}">{_delete_topic}</a>
<a class="button" href="/topic{$topic->getPrettyId()}/delete?hash={urlencode($csrfToken)}">{_delete_topic}</a>
</td>
<td>
<input type="hidden" name="hash" value="{$csrfToken}" />

View file

@ -409,7 +409,7 @@
</td>
<td>
<select name="likes.read", style="width: 164px;">
<option value="2" {if $user->getPrivacySetting('likes.read') == 2}selected{/if}>{_privacy_value_anybody_dative}</option>
<option value="2" {if $user->getPrivacySetting('likes.read') == 2}selected{/if}>{_privacy_value_anybody}</option>
<option value="0" {if $user->getPrivacySetting('likes.read') == 0}selected{/if}>{_privacy_value_only_me_dative}</option>
</select>
</td>

View file

@ -419,7 +419,7 @@
{else}
<div class="page_status" style="display: flex;">
<div n:class="audioStatus, $thatIsThisUser ? page_status_edit_button" id="page_status_text">
<a {if !$thatIsThisUser}href="/audio0_{$audioStatus->getId()}"{/if}>{$audioStatus->getName()}</a>
{$audioStatus->getName()}
</div>
</div>
{/if}
@ -458,8 +458,8 @@
</tr>
<tr n:if="!is_null($user->getBirthday())">
<td class="label"><span class="nobold">{_birth_date}:</span></td>
<td n:if="$user->getBirthdayPrivacy() == 0" class="data">{$user->getBirthday()->format('%e %B %Y')}{if $user->onlineStatus() != 2},
{tr("years", $user->getAge())}{/if}</td>
<td n:if="$user->getBirthdayPrivacy() == 0" class="data">{$user->getBirthday()->format('%e %B %Y')},
{tr("years", $user->getAge())}</td>
<td n:if="$user->getBirthdayPrivacy() == 1" class="data">{$user->getBirthday()->format('%e %B')}</td>
</tr>
</tbody>

View file

@ -36,10 +36,9 @@
count => $cCount,
page => $cPage,
model => "posts",
parent => $post,
sort => $sort}
parent => $post }
</div>
<div style="float: left; min-height: 100px; width: 32%;padding-left: 10px;width: 30%;">
<div style="float: left; min-height: 100px; width: 32%;">
<h4>{_actions}</h4>
{if isset($thisUser)}
{var $canDelete = $post->canBeDeletedBy($thisUser)}
@ -48,7 +47,7 @@
{/if}
{/if}
<a n:if="$canDelete ?? false" id="_ajaxDelete" class="profile_link" style="display:block;width:96%;" href="/wall{$post->getPrettyId()}/delete">{_delete}</a>
<a n:if="$canDelete ?? false" class="profile_link" style="display:block;width:96%;" href="/wall{$post->getPrettyId()}/delete">{_delete}</a>
<a
n:if="isset($thisUser) && $thisUser->getChandlerUser()->can('access')->model('admin')->whichBelongsTo(NULL) AND $post->getEditTime()"
style="display:block;width:96%;"
@ -57,6 +56,29 @@
>
{_changes_history}
</a>
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportPost({$post->getId()})">{_report}</a>
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportPost()">{_report}</a>
</div>
<script n:if="$canReport ?? false">
function reportPost() {
uReportMsgTxt = tr("going_to_report_post");
uReportMsgTxt += "<br/>"+tr("report_question_text");
uReportMsgTxt += "<br/><br/><b>"+tr("report_reason")+"</b>: <input type='text' id='uReportMsgInput' placeholder='" + tr("reason") + "' />"
MessageBox(tr("report_question"), uReportMsgTxt, [tr("confirm_m"), tr("cancel")], [
(function() {
res = document.querySelector("#uReportMsgInput").value;
xhr = new XMLHttpRequest();
xhr.open("GET", "/report/" + {$post->getId()} + "?reason=" + res + "&type=post", true);
xhr.onload = (function() {
if(xhr.responseText.indexOf("reason") === -1)
MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]);
else
MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]);
});
xhr.send(null);
}),
Function.noop
]);
}
</script>
{/block}

View file

@ -17,9 +17,7 @@
{/if}
{/if}
{* remove the "n:if" if you having issues with your theme *}
<link n:if="$theme->getId() != 'mobile_ovk'" rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" />
<link rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/stylesheet/styles.css" />
{if $isXmas}
<link rel="stylesheet" href="/themepack/{$theme->getId()}/{$theme->getVersion()}/resource/xmas.css" />

View file

@ -44,7 +44,7 @@
{if !$timeOnly}
{if $comment->canBeDeletedBy($thisUser)}
|
<a href="/comment{$comment->getId()}/delete" id="_ajaxDelete">{_delete}</a>
<a href="/comment{$comment->getId()}/delete">{_delete}</a>
{/if}
{if $comment->canBeEditedBy($thisUser)}
|

View file

@ -1,18 +1,5 @@
<div>
<h4 n:if="$showTitle ?? true">{_comments} ({$count})</h4>
<h4 n:if="$showTitle ?? true">{_comments} ({$count})</h4>
{if !is_null($sort) && $count > 5}
<a class="sort_link" n:attr="href => $sort == 'desc' ? '?sort=asc' : '?sort=desc'">
{if $sort == 'desc'}
{_new_first}
{else}
{_old_first}
{/if}
<div n:class="sort_link_icon, $sort == 'desc' ? sort_link_icon_desc : sort_link_icon_asc"></div>
</a>
{/if}
</div>
<div n:ifset="$thisUser" id="standaloneCommentBox">
{var $commentsURL = "/al_comments/create/$model/" . $parent->getId()}
{var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club}
@ -24,7 +11,7 @@
{if sizeof($comments) > 0}
<div class='scroll_container'>
<div class='scroll_node' n:foreach="$comments as $comment">
{include "comment.xml", comment => $comment, no_reply_button => $readOnly}
{include "comment.xml", comment => $comment}
</div>
</div>
<div style="margin-top: 11px;">

View file

@ -58,9 +58,6 @@
<span n:if="$post->isPinned()" class="nobold">{_pinned}</span>
<a n:if="$canBeDeleted && !($forceNoDeleteLink ?? false) && $compact == false" class="delete" href="/wall{$post->getPrettyId()}/delete"></a>
<a n:if="!$canBeDeleted" class="report" title="{_report}" href="javascript:reportPost({$post->getId()})"></a>
<a n:if="$feedIgnoreButton && !$canBeDeleted" class="delete" id="__ignoreSomeoneFeed" title="{_feed_ignore}" data-val='1' data-id="{$wallOwner->getRealId()}"></a>
{if $canBePinned && !($forceNoPinLink ?? false) && $compact == false}
@ -152,7 +149,7 @@
{/if}
</div>
<div n:if="!($forceNoCommentsLink ?? false) && $commentSection == true && $compact == false" class="post-menu-s">
<a n:if="$commentsCount > 3" href="/wall{$post->getPrettyId()}" class="expand_button">{_view_other_comments} ({$commentsCount - 3})</a>
<a n:if="$commentsCount > 3" href="/wall{$post->getPrettyId()}" class="expand_button">{_view_other_comments}</a>
{foreach $comments as $comment}
{include "../comment.xml", comment => $comment, $compact => true}
{/foreach}

View file

@ -139,10 +139,6 @@
<a id="__ignoreSomeoneFeed" data-val='1' data-id="{$wallOwner->getRealId()}">{_feed_ignore}</a> &nbsp;|&nbsp;
{/if}
{if !$canBeDeleted}
<a href="javascript:reportPost({$post->getId()})">{_report}</a> &nbsp;|&nbsp;
{/if}
{if !($forceNoPinLink ?? false) && $canBePinned}
{if $post->isPinned()}
<a href="/wall{$post->getPrettyId()}/pin?act=unpin&hash={rawurlencode($csrfToken)}">{_unpin}</a>

View file

@ -2,7 +2,7 @@
{var $textAreaId = ($post ?? NULL) === NULL ? (++$GLOBALS["textAreaCtr"]) : $post->getId()}
{var $textAreaId = ($custom_id ?? NULL) === NULL ? $textAreaId : $custom_id}
<div id="write" class='model_content_textarea' style="padding: 5px 0;" data-id="{is_null($owner) || gettype($owner) == 'integer' ? $owner : $owner->getId()}">
<div id="write" class='model_content_textarea' style="padding: 5px 0;">
<form action="{$route}" method="post" enctype="multipart/form-data" style="margin:0;">
<textarea id="wall-post-input{$textAreaId}" placeholder="{_write}" name="text" style="width: 100%;resize: none;" class="small-textarea"></textarea>
<div>
@ -33,15 +33,15 @@
</script>
<label>
<input type="checkbox" name="as_group" onchange="onWallAsGroupClick(this)" checked /> {_post_as_group}
<input type="checkbox" name="as_group" onchange="onWallAsGroupClick(this)" /> {_post_as_group}
</label>
<label id="forceSignOpt" style="display: block;">
<label id="forceSignOpt" style="display: none;">
<input type="checkbox" name="force_sign" /> {_add_signature}
</label>
{/if}
{/if}
<label n:if="$anonEnabled" id="octoberAnonOpt" style="display: none;">
<label n:if="$anonEnabled" id="octoberAnonOpt">
<input type="checkbox" name="anon" /> {_as_anonymous}
</label>

View file

@ -1,5 +1,5 @@
<div class="content_divider">
<div class="content_title_expanded">
<div class="content_title_expanded" onclick="hidePanel(this);">
{_wall}
<nobold>
{tr("wall", $count)}

View file

@ -763,9 +763,8 @@
fill-opacity: .7;
}
.audioStatus a {
.audioStatus span {
color: #2B587A;
font-weight: bold;
}
.audioStatus span:hover {

View file

@ -49,7 +49,7 @@ body.dimmed > .dimmer #absolute_territory {
.ovk-diag-body {
padding: 20px;
overflow-y: auto;
max-height: 83vh
max-height: 80vh
}
.ovk-diag-action {

View file

@ -14,10 +14,6 @@ body {
line-height: 1.19;
}
body.ajax_request_made {
cursor: progress;
}
body, .ovk-fullscreen-dimmer, .ovk-photo-view-dimmer {
scrollbar-gutter: stable both-edges;
}
@ -880,7 +876,7 @@ h4 {
}
.post-geo {
margin: 8px 0px 2px -3px;
margin: 1px 0px;
padding: 0 4px;
}
@ -1579,10 +1575,6 @@ body.scrolled .toTop:hover, .toTop.has_down:hover {
color: #3c3c3c;
}
.post-has-geo.appended-geo {
padding: 6px 0px;
}
.post-source #remove_source_button, #small_remove_button {
display: inline-block;
background-repeat: no-repeat;
@ -1897,7 +1889,6 @@ body.scrolled .toTop:hover, .toTop.has_down:hover {
#ovkDraw {
border: 1px solid #757575;
min-height: 510px;
}
#ovkDraw .lc-drawing.with-gui {
@ -1906,7 +1897,6 @@ body.scrolled .toTop:hover, .toTop.has_down:hover {
#ovkDraw .literally {
border-radius: 0;
height: 510px;
}
#ovkDraw .literally .lc-picker,
@ -2685,8 +2675,7 @@ a.poll-retract-vote {
}
.post-buttons .vertical-attachment .vertical-attachment-content {
/*max-height: 27px;*/
padding: 3px 2px;
max-height: 27px;
}
.vertical-attachment .vertical-attachment-content .overflowedName {
@ -3217,11 +3206,6 @@ a.poll-retract-vote {
display: flex;
align-items: center;
gap: 1px;
padding: 5px 9px;
}
.post-buttons .attachment_note {
padding: 3px 0px;
}
.attachment_note svg {
@ -3237,10 +3221,6 @@ a.poll-retract-vote {
height: 12px;
}
.attachments .attachment_note {
padding: 5px 5px;
}
#notesList
{
overflow-y: scroll;
@ -3277,7 +3257,7 @@ body.article .floating_sidebar, body.article .page_content {
display: none;
position: absolute;
z-index: 128;
width: 98%;
width: 100%;
min-height: 100vh;
padding: 20px;
box-sizing: border-box;
@ -3311,7 +3291,6 @@ body.article .floating_sidebar, body.article .page_content {
.articleView_author > div {
display: flex;
flex-direction: column;
margin-top: 3px;
}
.articleView_author > div > span {
@ -3409,7 +3388,6 @@ body.article .floating_sidebar, body.article .page_content {
display: flex;
flex-direction: column;
gap: 22px;
padding: 5px 10px;
}
.sugglist {
@ -3683,7 +3661,7 @@ hr {
.entity_vertical_list {
display: flex;
flex-direction: column;
gap: 10px;
gap: 3px;
height: 197px;
overflow-y: auto;
}
@ -3691,7 +3669,6 @@ hr {
.entity_vertical_list.scroll_container {
height: unset;
overflow-y: unset;
padding: 5px;
}
.entity_vertical_list .entity_vertical_list_item {
@ -3709,16 +3686,12 @@ hr {
}
.entity_vertical_list.m_mini .entity_vertical_list_item .first_column {
gap: 13px;
}
.entity_vertical_list.m_mini .entity_vertical_list_item:hover .first_column a {
text-decoration: underline;
gap: 10px;
}
.entity_vertical_list.m_mini .entity_vertical_list_item .first_column .avatar img {
width: 40px;
height: 40px;
width: 30px;
height: 30px;
}
.entity_vertical_list .entity_vertical_list_item .avatar {
@ -3849,13 +3822,12 @@ hr {
display: none;
position: fixed;
top: -10%;
background: rgba(0, 0, 0, 0.8);
box-shadow: 0px 0px 2px 0px black;
background: rgba(26, 26, 26, 0.9);;
padding-top: 12px;
width: 91px;
height: 25px;
text-align: center;
border-radius: 2px;
border-radius: 1px;
margin: auto;
left: 0;
right: 0;
@ -3954,11 +3926,6 @@ hr {
height: 25px;
}
.object_fit_ava {
object-fit: cover;
object-position: top;
}
.like_tooltip_wrapper .like_tooltip_body a {
height: 25px;
}
@ -4069,7 +4036,7 @@ hr {
#docs_page_wrapper .container_white {
display: flex;
flex-direction: column;
padding: 10px 10px;
padding: 5px 10px;
}
#docs_page_wrapper .docs_page_content.docs_page_gallery .scroll_container {
@ -4212,12 +4179,11 @@ hr {
justify-content: center;
border-radius: 2px;
height: 17px;
padding: 3px 0px;
padding: 2px 0px;
}
.docListViewItem .doc_icon.no_image span {
color: #6b6b6b;
font-weight: bold;
}
.doc_icon.no_image span::before {
@ -4302,8 +4268,8 @@ hr {
.attachments .docGalleryItem {
display: block;
min-width: 170px;
min-height: 170px;
width: 60%;
height: 170px;
width: 50%;
margin-bottom: 4px;
}
@ -4329,23 +4295,3 @@ hr {
.deleted_mark_average {
padding: 5px 61px;
}
.sort_link {
padding: 5px 2px;
display: inline-block;
}
.sort_link_icon {
background: url(/assets/packages/static/openvk/img/wall.png?v=3) no-repeat;
display: inline-block;
height: 11px;
width: 9px;
}
.sort_link_icon_desc {
background-position: 0px -15px;
}
.sort_link_icon_asc {
background-position: -11px -15px;
}

View file

@ -96,16 +96,6 @@
transition-duration: 0.3s;
}
.report {
float: right;
height: 16px;
width: 16px;
overflow: auto;
background: url("/assets/packages/static/openvk/img/report.png") no-repeat 0 0;
opacity: 0.1;
transition-duration: 0.3s;
}
.ignore:hover {
opacity: 0.4;
}
@ -119,10 +109,6 @@
border-bottom: 1px #ddd solid;
}
.report:hover {
opacity: 0.4;
}
.post-author .delete {
float: right;
height: 16px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -333,7 +333,7 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_arg =
<text id="photo_com_title_photos">
${tr("select_doc")}
</text>
<span style="display: inline-flex;gap: 7px;margin-left: 5px;">
<span style="display: inline-flex;gap: 7px;">
${source != "user" ? `<a id="_doc_picker_go_to_my">${tr("go_to_my_documents")}</a>`: ""}
<a id="_doc_picker_upload">${tr("upload_button")}</a>
</span>

View file

@ -353,26 +353,3 @@ function openJsSettings() {
</tr>
`)
}
function reportPost(postId) {
uReportMsgTxt = tr("going_to_report_post");
uReportMsgTxt += "<br/>"+tr("report_question_text");
uReportMsgTxt += "<br/><br/><b>"+tr("report_reason")+"</b>: <input type='text' id='uReportMsgInput' placeholder='" + tr("reason") + "' />"
MessageBox(tr("report_question"), uReportMsgTxt, [tr("confirm_m"), tr("cancel")], [
(function() {
res = document.querySelector("#uReportMsgInput").value;
xhr = new XMLHttpRequest();
xhr.open("GET", "/report/" + postId + "?reason=" + res + "&type=post", true);
xhr.onload = (function() {
if(xhr.responseText.indexOf("reason") === -1)
MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]);
else
MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]);
});
xhr.send(null);
}),
Function.noop
]);
}

View file

@ -23,7 +23,6 @@ tippy.delegate("body", {
target: '.mention',
theme: "light vk",
content: "⌛",
delay: 300,
allowHTML: true,
interactive: true,
interactiveDebounce: 500,

View file

@ -176,7 +176,7 @@ window.player = new class {
}
}
if(window.player.listen_coef > 5) {
if(window.player.listen_coef > 10) {
this.__countListen()
window.player.listen_coef = -10
}
@ -845,14 +845,22 @@ u(document).on('click', '.audioEntry .playerButton > .playIcon', async (e) => {
if(!window.player.hasTrackWithId(id) && !window.player.isAtAudiosPage()) {
let _nodes = null
try_these_containers = [".attachments", ".content_list", ".generic_audio_list", ".audiosInsert", ".scroll_container", ".container_gray"]
try_these_containers.forEach(__container => {
if(u(e.target).closest(__container).length > 0) {
window.player.connectionType = __container
_nodes = u(e.target).closest(__container).find('.audioEmbed').nodes
if(u(e.target).closest('.attachments').length > 0) {
window.player.connectionType = '.attachments'
_nodes = u(e.target).closest('.attachments').find('.audioEmbed').nodes
} else if(u(e.target).closest('.content_list').length > 0) {
window.player.connectionType = '.content_list'
_nodes = u(e.target).closest('.content_list').find('.audioEmbed').nodes
} else if(u(e.target).closest('.generic_audio_list').length > 0) {
window.player.connectionType = '.generic_audio_list'
_nodes = u(e.target).closest('.generic_audio_list').find('.audioEmbed').nodes
} else if(u(e.target).closest('.audiosInsert').length > 0) {
window.player.connectionType = '.audiosInsert'
_nodes = u(e.target).closest('.audiosInsert').find('.audioEmbed').nodes
} else if(u(e.target).closest('.scroll_container').length > 0) {
window.player.connectionType = '.scroll_container'
_nodes = u(e.target).closest('.scroll_container').find('.audioEmbed').nodes
}
})
window.player.tracks = []
_nodes.forEach(el => {
@ -1851,7 +1859,7 @@ function showAudioAttachment(type = 'form', form = null)
}
let is_attached = false
if(type == 'form') {
is_attached = (u(form).find(`.post-vertical .vertical-attachment[data-type='audio'][data-id='${id}']`)).length > 0
is_attached = (u(form).find(`.post-vertical .vertical-attachment[data-id='${id}']`)).length > 0
} else {
is_attached = (u(form).find(`.PE_audios .vertical-attachment[data-id='${id}']`)).length > 0
}

View file

@ -12,7 +12,7 @@ $(document).on("change", ".photo_ajax_upload_button", (e) => {
return;
}
if(file.size > window.openvk.max_filesize_mb * 1024 * 1024) {
if(file.size > 5 * 1024 * 1024) {
MessageBox(tr("error"), tr("max_filesize", 5), [tr("ok")], [() => {Function.noop}])
return;
}
@ -88,6 +88,7 @@ $(document).on("click", ".photo_upload_container #endUploading", (e) => {
data.append("hash", u("meta[name=csrf]").attr("value"))
let xhr = new XMLHttpRequest()
// в самом вк на каждое изменение описания отправляется свой запрос, но тут мы экономим запросы
xhr.open("POST", "/photos/upload?act=finish&album="+document.getElementById("album").value)
xhr.onloadstart = () => {
@ -107,10 +108,10 @@ $(document).on("click", ".photo_upload_container #endUploading", (e) => {
document.querySelector(".page_content .insertPhotos").innerHTML = ""
document.getElementById("endUploading").style.display = "none"
window.router.route({url:`/album${result.owner}_${result.album}`})
NewNotification(tr("photos_successfully_uploaded"), tr("click_to_go_to_album"), null, () => {window.router.route({url:`/album${result.owner}_${result.album}`})})
/*document.querySelector(".whiteBox").style.display = "block"
document.querySelector(".insertAgain").append(document.getElementById("fakeButton"))*/
document.querySelector(".whiteBox").style.display = "block"
document.querySelector(".insertAgain").append(document.getElementById("fakeButton"))
}
e.currentTarget.removeAttribute("disabled")

View file

@ -606,22 +606,7 @@ function reportClub(club_id) {
]);
}
$(document).on("click", "#_ajaxDelete", function(e) {
MessageBox(tr('warning'), tr('question_confirm'), [
tr('yes'),
tr('no')
], [
() => {
window.router.route(e.target.href)
},
Function.noop
]);
e.stopPropagation()
return e.preventDefault();
});
$(document).on("click", "#_photoDelete, #_videoDelete, #_anotherDelete", function(e) {
$(document).on("click", "#_photoDelete, #_videoDelete", function(e) {
var formHtml = "<form id='tmpPhDelF' action='" + u(this).attr("href") + "' >";
formHtml += "<input type='hidden' name='hash' value='" + u("meta[name=csrf]").attr("value") + "' />";
formHtml += "</form>";
@ -840,7 +825,6 @@ tippy.delegate("body", {
target: '.client_app',
theme: "light vk",
content: "⌛",
delay: 400,
allowHTML: true,
interactive: true,
interactiveDebounce: 500,
@ -880,7 +864,6 @@ tippy.delegate('body', {
target: `.post-like-button[data-type]:not([data-likes="0"])`,
theme: "special vk",
content: "⌛",
delay: 400,
allowHTML: true,
interactive: true,
interactiveDebounce: 500,
@ -917,7 +900,7 @@ tippy.delegate('body', {
that._likesList.items.forEach(item => {
final_template.find('.like_tooltip_body .like_tooltip_body_grid').append(`
<a title="${escapeHtml(item.first_name + " " + item.last_name)}" href='/id${item.id}'><img class="object_fit_ava" src='${item.photo_50}' alt='.'></a>
<a title="${escapeHtml(item.first_name + " " + item.last_name)}" href='/id${item.id}'><img src='${item.photo_50}' alt='.'></a>
`)
})
that.setContent(final_template.nodes[0].outerHTML)
@ -1140,14 +1123,7 @@ u(document).on("click", "#editPost", async (e) => {
return
}
let is_at_post_page = false
try {
if(location.pathname.indexOf("wall") != -1 && location.pathname.split("_").length == 2) {
is_at_post_page = true
}
} catch(e) {}
const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}&from_page=${is_at_post_page ? "post" : "another"}`, {
const new_post_html = await (await fetch(`/iapi/getPostTemplate/${id[0]}_${id[1]}?type=${type}`, {
'method': 'POST'
})).text()
u(ev.target).removeClass('lagged')
@ -1198,7 +1174,7 @@ async function __uploadToTextarea(file, textareaNode) {
const rand = random_int(0, 1000)
textareaNode.find('.post-horizontal').append(`<a id='temp_filler${rand}' class="upload-item lagged"><img src='${temp_url}'></a>`)
const res = await fetch(`/photos/upload?upload_context=${textareaNode.nodes[0].dataset.id}`, {
const res = await fetch(`/photos/upload`, {
method: 'POST',
body: form_data
})
@ -1366,7 +1342,7 @@ u(document).on("click", "#__photoAttachment", async (e) => {
if(album == 0) {
photos = await window.OVKAPI.call('photos.getAll', {'owner_id': window.openvk.current_id, 'photo_sizes': 1, 'count': photos_per_page, 'offset': page * photos_per_page})
} else {
photos = await window.OVKAPI.call('photos.get', {'owner_id': club != 0 ? Math.abs(club) * -1 : window.openvk.current_id, 'album_id': album, 'photo_sizes': 1, 'count': photos_per_page, 'offset': page * photos_per_page})
photos = await window.OVKAPI.call('photos.get', {'owner_id': window.openvk.current_id, 'album_id': album, 'photo_sizes': 1, 'count': photos_per_page, 'offset': page * photos_per_page})
}
} catch(e) {
u("#attachment_insert_count h4").html(tr("is_x_photos", -1))
@ -1456,7 +1432,7 @@ u(document).on("click", "#__photoAttachment", async (e) => {
window.openvk.photoalbums = await window.OVKAPI.call('photos.getAlbums', {'owner_id': club != 0 ? Math.abs(club) * -1 : window.openvk.current_id})
}
window.openvk.photoalbums.items.forEach(item => {
u('.ovk-diag-body #albumSelect').append(`<option value="${item.id}">${ovk_proc_strtr(escapeHtml(item.title), 20)}</option>`)
u('.ovk-diag-body #albumSelect').append(`<option value="${item.vid}">${ovk_proc_strtr(escapeHtml(item.title), 20)}</option>`)
})
})
@ -1669,7 +1645,7 @@ u(document).on('click', '#__notesAttachment', async (e) => {
insert_place.append(tr('no_notes'))
}
notes.items.forEach(note => {
notes.notes.forEach(note => {
is_attached = (form.find(`.upload-item[data-type='note'][data-id='${note.owner_id}_${note.id}']`)).length > 0
insert_place.append(`
<div class='display_flex_row _content' data-attachmentdata="${note.owner_id}_${note.id}" data-name='${escapeHtml(note.title)}'>
@ -1967,10 +1943,10 @@ async function repost(id, repost_type = 'post') {
title: tr('share'),
unique_name: 'repost_modal',
body: `
<div class='display_flex_column' style='gap: 5px;'>
<div class='display_flex_column' style='gap: 1px;'>
<b>${tr('auditory')}</b>
<div class='display_flex_column' style="gap: 2px;padding-left: 1px;">
<div class='display_flex_column'>
<label>
<input type="radio" name="repost_type" value="wall" checked>
${tr("in_wall")}
@ -1986,7 +1962,6 @@ async function repost(id, repost_type = 'post') {
<b>${tr('your_comment')}</b>
<div style="padding-left: 1px;">
<input type='hidden' id='repost_attachments'>
<textarea id='repostMsgInput' placeholder='...'></textarea>
@ -1995,7 +1970,6 @@ async function repost(id, repost_type = 'post') {
<label><input type='checkbox' name="signed">${tr('add_signature')}</label>
</div>
</div>
</div>
`,
buttons: [tr('send'), tr('cancel')],
callbacks: [
@ -2062,7 +2036,7 @@ async function repost(id, repost_type = 'post') {
]
});
u('.ovk-diag-body').attr('style', 'padding: 18px;')
u('.ovk-diag-body').attr('style', 'padding: 14px;')
u('.ovk-diag-body').on('change', `input[name='repost_type']`, (e) => {
const value = e.target.value
@ -2088,7 +2062,6 @@ async function repost(id, repost_type = 'post') {
if(window.openvk.writeableClubs.items.length < 1) {
u(`input[name='repost_type'][value='group']`).attr('disabled', 'disabled')
u(`input[name='repost_type'][value='group']`).closest("label").addClass("lagged")
}
}
@ -2398,10 +2371,7 @@ async function __processPaginatorNextPage(page)
const new_url = new URL(location.href)
new_url.hash = page
//history.replaceState(null, null, new_url)
showMoreObserver.disconnect()
showMoreObserver.observe(u('.paginator:not(.paginator-at-top)').nodes[0])
history.replaceState(null, null, new_url)
if(typeof __scrollHook != 'undefined') {
__scrollHook(page)
@ -2427,9 +2397,6 @@ const showMoreObserver = new IntersectionObserver(entries => {
if(target.length < 1 || target.hasClass('paginator-at-top')) {
return
}
if(target.hasClass('lagged')) {
return
}
const current_url = new URL(location.href)
if(current_url.searchParams && !isNaN(parseInt(current_url.searchParams.get('p')))) {
@ -2470,7 +2437,8 @@ u(document).on('click', '#__sourceAttacher', (e) => {
MessageBox(tr('add_source'), `
<div id='source_flex_kunteynir'>
<span>${tr('set_source_tip')}</span>
<input type='text' maxlength='400' placeholder='...'>
<!-- давай, копируй ссылку и переходи по ней -->
<input type='text' maxlength='400' placeholder='https://www.youtube.com/watch?v=lkWuk_nzzVA'>
</div>
`, [tr('cancel')], [
() => {Function.noop}
@ -2578,12 +2546,7 @@ u(document).on('mouseover mousemove mouseout', `div[data-tip='simple']`, (e) =>
})
function setStatusEditorShown(shown) {
if(shown) {
document.getElementById("status_editor").style.display = "block"
document.querySelector("#status_editor input").focus()
} else {
document.getElementById("status_editor").style.display = "none"
}
document.getElementById("status_editor").style.display = shown ? "block" : "none";
}
u(document).on('click', (event) => {
@ -2685,7 +2648,7 @@ u(document).on('click', "#__geoAttacher", async (e) => {
${tplMapIcon}
<span>${escapeHtml(geo_name)}</span>
<div id="small_remove_button"></div>
`).addClass("appended-geo")
`)
}, () => {}]
})
@ -2988,28 +2951,3 @@ u(document).on("submit", "#additional_fields_form", (e) => {
}
})
})
if(Number(localStorage.getItem('ux.gif_autoplay') ?? 0) == 1) {
const showMoreObserver = new IntersectionObserver(entries => {
entries.forEach(async x => {
doc_item = x.target.closest(".docGalleryItem")
if(doc_item.querySelector(".play-button") != null) {
if(x.isIntersecting) {
doc_item.classList.add("playing")
} else {
doc_item.classList.remove("playing")
}
}
})
}, {
root: null,
rootMargin: '0px',
threshold: 0,
})
if(u('.docGalleryItem').length > 0) {
u('.docGalleryItem').nodes.forEach(item => {
showMoreObserver.observe(item)
})
}
}

View file

@ -211,8 +211,6 @@ window.router = new class {
history.replaceState({'from_router': 1}, '', url)
}
u('body').addClass('ajax_request_made')
const parser = new DOMParser
const next_page_request = await fetch(next_page_url, {
method: 'AJAX',
@ -230,8 +228,6 @@ window.router = new class {
this.__closeMsgs()
this.__unlinkObservers()
u('body').removeClass('ajax_request_made')
try {
this.__appendPage(parsed_content)
await this.__integratePage()
@ -401,10 +397,8 @@ window.addEventListener('popstate', (e) => {
return
}*/
if(e.state != null) {
window.router.route({
url: location.href,
push_state: false,
})
}
})

View file

@ -6429,21 +6429,6 @@ tools.ToolWithStroke = ToolWithStroke = (function(superClass) {
module.exports = tools;
},{}]},{},[22])(22)
});
document.addEventListener('keydown', function (e) {
const redoBtn = document.querySelector(".lc-redo")
const undoBtn = document.querySelector(".lc-undo")
if (e.ctrlKey && undoBtn && redoBtn) {
if ((e.code === "KeyY") || (e.code === "KeyZ" && e.shiftKey)) {
e.preventDefault()
redoBtn.click()
}
else if (e.code === "KeyZ") {
e.preventDefault()
undoBtn.click()
}
}
})

View file

@ -1 +0,0 @@
ALTER TABLE `profiles` ADD COLUMN `hide_global_feed` boolean DEFAULT 0 NOT NULL AFTER `deleted`;

View file

@ -510,7 +510,7 @@
"edit_photo" = "Edit photo";
"creating_album" = "Creating album";
"delete_photo" = "Delete photo";
"sure_deleting_photo" = "Do you sure you want to delete this photo from album?";
"sure_deleting_photo" = "Do you really want to delete this picture?";
"upload_photo" = "Upload photo";
"photo" = "Photo";
"upload_button" = "Upload";
@ -624,7 +624,6 @@
"notes_closed" = "You can't attach a note to the post because only you can see them.<br> You can change this in <a href=\"/settings?act=privacy\">settings</a>.";
"do_not_attach_note" = "Do not attach a note";
"something_is_supported_from_xhtml" = "<a href='/kb/notes'>Something</a> from (X)HTML supported.";
"something" = "Something";
"supports_xhtml" = "from (X)HTML supported.";
@ -873,9 +872,6 @@
"sort_up" = "Sort by ID up";
"sort_down" = "Sort by ID down";
"new_first" = "New frist";
"old_first" = "Old first";
/* Videos */
"videos" = "Videos";
@ -1205,7 +1201,6 @@
"coins_other" = "$1 votes";
"users_gifts" = "Gifts";
"sent" = "Sent";
/* Apps */
"app" = "Application";
@ -1689,7 +1684,6 @@
"admin_first_known_ip" = "First known IP";
"admin_shortcode" = "Short code";
"admin_verification" = "Verification";
"admin_hide_global_feed" = "Hide global feed";
"admin_banreason" = "Ban reason";
"admin_banned" = "banned";
"admin_gender" = "Sex";
@ -2332,8 +2326,6 @@
"roll_back" = "rollback";
"roll_backed" = "rollbacked";
"nospam_prevention" = "This action will affect a lot of data. Are you sure you want to apply?";
/* RSS */
"post_deact_in_general" = "Page deletion";

View file

@ -494,7 +494,7 @@
"edit_photo" = "Изменить фотографию";
"creating_album" = "Создание альбома";
"delete_photo" = "Удалить фотографию";
"sure_deleting_photo" = "Вы уверены, что хотите удалить эту фотографию из альбома?";
"sure_deleting_photo" = "Вы уверены, что хотите удалить эту фотографию?";
"upload_photo" = "Загрузить фотографию";
"photo" = "Фотография";
"upload_button" = "Загрузить";
@ -608,7 +608,6 @@
"notes_closed" = "Вы не можете прикрепить заметку к записи, так как ваши заметки видны только вам.<br><br> Вы можете поменять это в <a href=\"/settings?act=privacy\">настройках</a>.";
"do_not_attach_note" = "Не прикреплять заметку";
"something_is_supported_from_xhtml" = "<a href='/kb/notes'>Кое-что</a> из (X)HTML поддерживается.";
"something" = "Кое-что";
"supports_xhtml" = "из (X)HTML поддерживается.";
@ -831,9 +830,6 @@
"sort_up" = "Сортировать по дате создания вверх";
"sort_down" = "Сортировать по дате создания вниз";
"new_first" = "Сначала новые";
"old_first" = "Сначала старые";
/* Videos */
"videos" = "Видеозаписи";
@ -1147,7 +1143,6 @@
"coins_many" = "$1 голосов";
"coins_other" = "$1 голосов";
"users_gifts" = "Подарки";
"sent" = "Отправлено";
/* Apps */
"app" = "Приложение";
@ -1592,7 +1587,6 @@
"admin_first_known_ip" = "Первый IP";
"admin_shortcode" = "Короткий адрес";
"admin_verification" = "Верификация";
"admin_hide_global_feed" = "Не отображать в глобальной ленте";
"admin_banreason" = "Причина блокировки";
"admin_banned" = "заблокирован";
"admin_actions" = "Действия";
@ -2227,8 +2221,6 @@
"roll_back" = "откатить";
"roll_backed" = "откачено";
"nospam_prevention" = "Данное действие затронет множество данных. Вы действительно хотите применить?";
/* RSS */
"post_deact_in_general" = "Удаление страницы";

View file

@ -448,7 +448,6 @@
"notes_closed" = "Vy ne možete prikrepití zametku k zapisi, tak kak vaši zametki vidny tolíko vam.<br><br> Vy možete pomenjatí eto v <a href=\"/settings?act=privacy\">nastrojkah</a>.";
"do_not_attach_note" = "Ne prikrepljatí zametku";
"something_is_supported_from_xhtml" = "<a href='/kb/notes'>Koe-čto</a> iz (X)HTML podderživaetsja.";
"something" = "Koe-čto";
"supports_xhtml" = "iz (X)HTML podderživaetsja.";

View file

@ -584,7 +584,6 @@
"notes_closed" = "Ви не можете прикріпити нотатку до запису, оскільки Ваші нотатки видно тільки Вам.<br><br> Ви можете змінити це в <a href=\"/settings?act=privacy\">налаштуваннях</a>.";
"do_not_attach_note" = "Не прикріплювати нотатку";
"something_is_supported_from_xhtml" = "<a href='/kb/notes'>Певні</a> теги з (X)HTML підтримується.";
"something" = "Певні";
"supports_xhtml" = "теги з (X)HTML підтримується.";