mirror of
https://github.com/openvk/openvk
synced 2025-04-23 00:23:01 +03:00
Compare commits
3 commits
836eab13d4
...
f1eddb4c9a
Author | SHA1 | Date | |
---|---|---|---|
|
f1eddb4c9a | ||
|
c5ad7bbbaa | ||
|
b58f416292 |
6 changed files with 12 additions and 153 deletions
|
@ -14,8 +14,7 @@ use openvk\Web\Models\Entities\{Topic, Comment, User, Photo, Video};
|
|||
|
||||
final class Board extends VKAPIRequestHandler
|
||||
{
|
||||
# 13/13
|
||||
public function addTopic(int $group_id, string $title, string $text = "", bool $from_group = true, string $attachments = "")
|
||||
public function addTopic(int $group_id, string $title, string $text = "", bool $from_group = true)
|
||||
{
|
||||
$this->requireUser();
|
||||
$this->willExecuteWriteAction();
|
||||
|
@ -23,15 +22,14 @@ final class Board extends VKAPIRequestHandler
|
|||
$club = (new ClubsRepo())->get($group_id);
|
||||
|
||||
if (!$club) {
|
||||
$this->fail(403, "Invalid club");
|
||||
$this->fail(15, "Access denied");
|
||||
}
|
||||
|
||||
if (!$club->canBeModifiedBy($this->getUser()) && !$club->isEveryoneCanCreateTopics()) {
|
||||
$this->fail(403, "Access to club denied");
|
||||
$this->fail(15, "Access denied");
|
||||
}
|
||||
|
||||
$flags = 0;
|
||||
|
||||
if ($from_group == true && $club->canBeModifiedBy($this->getUser())) {
|
||||
$flags |= 0b10000000;
|
||||
}
|
||||
|
@ -53,59 +51,6 @@ final class Board extends VKAPIRequestHandler
|
|||
$comment->setCreated(time());
|
||||
$comment->setFlags($flags);
|
||||
$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 $topic->getId();
|
||||
|
@ -118,7 +63,7 @@ final class Board extends VKAPIRequestHandler
|
|||
|
||||
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
|
||||
|
||||
if (!$topic || !$topic->getClub() || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
|
||||
if (!$topic || !$topic->getClub()->canBeModifiedBy($this->getUser())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -140,21 +85,15 @@ final class Board extends VKAPIRequestHandler
|
|||
}
|
||||
|
||||
$topic = (new TopicsRepo())->getTopicById($group_id, $topic_id);
|
||||
|
||||
if (!$topic || $topic->isDeleted() || $topic->isClosed()) {
|
||||
$this->fail(100, "Topic is deleted, closed or invalid.");
|
||||
$this->fail(15, "Access denied");
|
||||
}
|
||||
|
||||
$flags = 0;
|
||||
|
||||
if ($from_group != 0 && !is_null($topic->getClub()) && $topic->getClub()->canBeModifiedBy($this->user)) {
|
||||
$flags |= 0b10000000;
|
||||
}
|
||||
|
||||
if (strlen($message) > 300) {
|
||||
$this->fail(20, "Comment is too long.");
|
||||
}
|
||||
|
||||
$comment = new Comment();
|
||||
$comment->setOwner($this->getUser()->getId());
|
||||
$comment->setModel(get_class($topic));
|
||||
|
@ -164,74 +103,9 @@ final class Board extends VKAPIRequestHandler
|
|||
$comment->setFlags($flags);
|
||||
$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 deleteComment(int $comment_id, int $group_id = 0, int $topic_id = 0)
|
||||
{
|
||||
$this->requireUser();
|
||||
$this->willExecuteWriteAction();
|
||||
|
||||
$comment = (new CommentsRepo())->get($comment_id);
|
||||
|
||||
if ($comment->isDeleted() || !$comment || !$comment->canBeDeletedBy($this->getUser())) {
|
||||
$this->fail(403, "Access to comment denied");
|
||||
}
|
||||
|
||||
$comment->delete();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function deleteTopic(int $group_id, int $topic_id)
|
||||
{
|
||||
$this->requireUser();
|
||||
|
@ -248,25 +122,6 @@ final class Board extends VKAPIRequestHandler
|
|||
return 1;
|
||||
}
|
||||
|
||||
public function editComment(string $message, string $attachments, int $comment_id, int $group_id = 0, int $topic_id = 0)
|
||||
{
|
||||
# FIXME
|
||||
/*
|
||||
$this->requireUser();
|
||||
$this->willExecuteWriteAction();
|
||||
|
||||
$comment = (new CommentsRepo)->get($comment_id);
|
||||
|
||||
if($comment->getOwner() != $this->getUser()->getId())
|
||||
$this->fail(15, "Access to comment denied");
|
||||
|
||||
$comment->setContent($message);
|
||||
$comment->setEdited(time());
|
||||
$comment->save();
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function editTopic(int $group_id, int $topic_id, string $title)
|
||||
{
|
||||
$this->requireUser();
|
||||
|
|
|
@ -323,7 +323,7 @@ class Club extends RowModel
|
|||
return sizeof($this->getFollowersQuery());
|
||||
}
|
||||
|
||||
public function getFollowers(int $page = 1, int $perPage = 6, string $sort = "follower ASC"): \Traversable
|
||||
public function getFollowers(int $page = 1, int $perPage = 6, string $sort = "target DESC"): \Traversable
|
||||
{
|
||||
$rels = $this->getFollowersQuery($sort)->page($page, $perPage);
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ button.bsdn_playButton {
|
|||
padding-left: 0;
|
||||
font-size: 22px;
|
||||
cursor: pointer;
|
||||
width: 22px;
|
||||
}
|
||||
|
||||
.bsdn_fullScreenButton, .bsdn_repeatButton {
|
||||
|
|
|
@ -2919,7 +2919,6 @@ a.poll-retract-vote {
|
|||
position: relative;
|
||||
}
|
||||
|
||||
/* не говновёрстка, а пиксель-пёрфект) */
|
||||
.page_header.search_expanded.search_expanded_at_all #search_and_one_more_wrapper {
|
||||
width: 547px;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ u(document).on('click', '#__feed_settings_link', (e) => {
|
|||
`
|
||||
|
||||
MessageBox(tr("feed_settings"), body, [tr("close")], [Function.noop])
|
||||
u('.ovk-diag-body').attr('style', 'padding:0px;height: 255px;')
|
||||
u('.ovk-diag-body').attr('style', 'padding:0px;height: 255px;overflow: hidden;')
|
||||
|
||||
async function __switchTab(tab)
|
||||
{
|
||||
|
|
|
@ -670,3 +670,7 @@ ul {
|
|||
background: #1e1a2b;
|
||||
border: 1px solid #403a56;
|
||||
}
|
||||
|
||||
.ovk-modal-player-window #ovk-player-info {
|
||||
background: #0e0b1a;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue