mirror of
https://github.com/openvk/openvk
synced 2025-04-23 16:43:02 +03:00
Improvements 2 api
This commit is contained in:
parent
f58518300c
commit
c8ef5ccd64
5 changed files with 80 additions and 14 deletions
|
@ -2,6 +2,7 @@
|
||||||
namespace openvk\VKAPI\Handlers;
|
namespace openvk\VKAPI\Handlers;
|
||||||
use openvk\Web\Models\Repositories\Clubs as ClubsRepo;
|
use openvk\Web\Models\Repositories\Clubs as ClubsRepo;
|
||||||
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
||||||
|
use openvk\Web\Models\Repositories\Posts as PostsRepo;
|
||||||
use openvk\Web\Models\Entities\Club;
|
use openvk\Web\Models\Entities\Club;
|
||||||
|
|
||||||
final class Groups extends VKAPIRequestHandler
|
final class Groups extends VKAPIRequestHandler
|
||||||
|
@ -81,6 +82,22 @@ final class Groups extends VKAPIRequestHandler
|
||||||
case "members_count":
|
case "members_count":
|
||||||
$rClubs[$i]->members_count = $usr->getFollowersCount();
|
$rClubs[$i]->members_count = $usr->getFollowersCount();
|
||||||
break;
|
break;
|
||||||
|
case "can_suggest":
|
||||||
|
$rClubs[$i]->can_suggest = !$usr->canBeModifiedBy($this->getUser()) && $usr->getWallType() == 2;
|
||||||
|
break;
|
||||||
|
# unstandard feild
|
||||||
|
case "suggested_count":
|
||||||
|
if($usr->getWallType() != 2) {
|
||||||
|
$rClubs[$i]->suggested_count = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($usr->canBeModifiedBy($this->getUser()))
|
||||||
|
$rClubs[$i]->suggested_count = $usr->getSuggestedPostsCount();
|
||||||
|
else
|
||||||
|
$rClubs[$i]->suggested_count = (new PostsRepo)->getSuggestedPostsCountByUser($usr->getId(), $this->getUser()->getId());
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +205,22 @@ final class Groups extends VKAPIRequestHandler
|
||||||
case "description":
|
case "description":
|
||||||
$response[$i]->description = $clb->getDescription();
|
$response[$i]->description = $clb->getDescription();
|
||||||
break;
|
break;
|
||||||
|
case "can_suggest":
|
||||||
|
$response[$i]->can_suggest = !$clb->canBeModifiedBy($this->getUser()) && $clb->getWallType() == 2;
|
||||||
|
break;
|
||||||
|
# unstandard feild
|
||||||
|
case "suggested_count":
|
||||||
|
if($clb->getWallType() != 2) {
|
||||||
|
$response[$i]->suggested_count = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($clb->canBeModifiedBy($this->getUser()))
|
||||||
|
$response[$i]->suggested_count = $clb->getSuggestedPostsCount();
|
||||||
|
else
|
||||||
|
$response[$i]->suggested_count = (new PostsRepo)->getSuggestedPostsCountByUser($clb->getId(), $this->getUser()->getId());
|
||||||
|
|
||||||
|
break;
|
||||||
case "contacts":
|
case "contacts":
|
||||||
$contacts;
|
$contacts;
|
||||||
$contactTmp = $clb->getManagers(1, true);
|
$contactTmp = $clb->getManagers(1, true);
|
||||||
|
|
|
@ -51,7 +51,7 @@ final class Newsfeed extends VKAPIRequestHandler
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
|
|
||||||
$queryBase = "FROM `posts` LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`) WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND `posts`.`deleted` = 0";
|
$queryBase = "FROM `posts` LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`) WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND `posts`.`deleted` = 0 AND `posts`.`suggested` = 0";
|
||||||
|
|
||||||
if($this->getUser()->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
if($this->getUser()->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||||
$queryBase .= " AND `nsfw` = 0";
|
$queryBase .= " AND `nsfw` = 0";
|
||||||
|
|
|
@ -49,13 +49,13 @@ final class Wall extends VKAPIRequestHandler
|
||||||
$cnt = $posts->getPostCountOnUserWall($owner_id);
|
$cnt = $posts->getPostCountOnUserWall($owner_id);
|
||||||
break;
|
break;
|
||||||
case "owner":
|
case "owner":
|
||||||
$this->fail(66666, "Not implemented :(");
|
$this->fail(66666, "Not implemented");
|
||||||
break;
|
break;
|
||||||
case "others":
|
case "others":
|
||||||
$this->fail(66666, "Not implemented :(");
|
$this->fail(66666, "Not implemented");
|
||||||
break;
|
break;
|
||||||
case "postponed":
|
case "postponed":
|
||||||
$this->fail(66666, "Otlojka is not implemented :)");
|
$this->fail(66666, "Postponed posts are not implemented.");
|
||||||
break;
|
break;
|
||||||
case "suggests":
|
case "suggests":
|
||||||
if($owner_id < 0) {
|
if($owner_id < 0) {
|
||||||
|
@ -149,12 +149,23 @@ final class Wall extends VKAPIRequestHandler
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$postType = "post";
|
||||||
|
$signerId = NULL;
|
||||||
|
if($post->getSuggestionType() != 0) {
|
||||||
|
$postType = "suggest";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($post->isSigned()) {
|
||||||
|
$actualAuthor = $post->getOwner(false);
|
||||||
|
$signerId = $actualAuthor->getId();
|
||||||
|
}
|
||||||
|
|
||||||
$items[] = (object)[
|
$items[] = (object)[
|
||||||
"id" => $post->getVirtualId(),
|
"id" => $post->getVirtualId(),
|
||||||
"from_id" => $from_id,
|
"from_id" => $from_id,
|
||||||
"owner_id" => $post->getTargetWall(),
|
"owner_id" => $post->getTargetWall(),
|
||||||
"date" => $post->getPublicationTime()->timestamp(),
|
"date" => $post->getPublicationTime()->timestamp(),
|
||||||
"post_type" => "post",
|
"post_type" => $postType,
|
||||||
"text" => $post->getText(false),
|
"text" => $post->getText(false),
|
||||||
"copy_history" => $repost,
|
"copy_history" => $repost,
|
||||||
"can_edit" => 0, # TODO
|
"can_edit" => 0, # TODO
|
||||||
|
@ -166,6 +177,7 @@ final class Wall extends VKAPIRequestHandler
|
||||||
"is_explicit" => $post->isExplicit(),
|
"is_explicit" => $post->isExplicit(),
|
||||||
"attachments" => $attachments,
|
"attachments" => $attachments,
|
||||||
"post_source" => $post_source,
|
"post_source" => $post_source,
|
||||||
|
"signer_id" => $signerId,
|
||||||
"comments" => (object)[
|
"comments" => (object)[
|
||||||
"count" => $post->getCommentsCount(),
|
"count" => $post->getCommentsCount(),
|
||||||
"can_post" => 1
|
"can_post" => 1
|
||||||
|
@ -187,6 +199,9 @@ final class Wall extends VKAPIRequestHandler
|
||||||
else
|
else
|
||||||
$groups[] = $from_id * -1;
|
$groups[] = $from_id * -1;
|
||||||
|
|
||||||
|
/*if($post->isSigned())
|
||||||
|
$profiles[] = $post->getOwner(false)->getId();*/
|
||||||
|
|
||||||
$attachments = NULL; # free attachments so it will not clone everythingg
|
$attachments = NULL; # free attachments so it will not clone everythingg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,12 +339,24 @@ final class Wall extends VKAPIRequestHandler
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: $post->getVkApiType()
|
||||||
|
$postType = "post";
|
||||||
|
$signerId = NULL;
|
||||||
|
if($post->getSuggestionType() != 0) {
|
||||||
|
$postType = "suggest";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($post->isSigned()) {
|
||||||
|
$actualAuthor = $post->getOwner(false);
|
||||||
|
$signerId = $actualAuthor->getId();
|
||||||
|
}
|
||||||
|
|
||||||
$items[] = (object)[
|
$items[] = (object)[
|
||||||
"id" => $post->getVirtualId(),
|
"id" => $post->getVirtualId(),
|
||||||
"from_id" => $from_id,
|
"from_id" => $from_id,
|
||||||
"owner_id" => $post->getTargetWall(),
|
"owner_id" => $post->getTargetWall(),
|
||||||
"date" => $post->getPublicationTime()->timestamp(),
|
"date" => $post->getPublicationTime()->timestamp(),
|
||||||
"post_type" => "post",
|
"post_type" => $postType,
|
||||||
"text" => $post->getText(false),
|
"text" => $post->getText(false),
|
||||||
"copy_history" => $repost,
|
"copy_history" => $repost,
|
||||||
"can_edit" => 0, # TODO
|
"can_edit" => 0, # TODO
|
||||||
|
@ -340,6 +367,7 @@ final class Wall extends VKAPIRequestHandler
|
||||||
"is_pinned" => $post->isPinned(),
|
"is_pinned" => $post->isPinned(),
|
||||||
"is_explicit" => $post->isExplicit(),
|
"is_explicit" => $post->isExplicit(),
|
||||||
"post_source" => $post_source,
|
"post_source" => $post_source,
|
||||||
|
"signer_id" => $signerId,
|
||||||
"attachments" => $attachments,
|
"attachments" => $attachments,
|
||||||
"comments" => (object)[
|
"comments" => (object)[
|
||||||
"count" => $post->getCommentsCount(),
|
"count" => $post->getCommentsCount(),
|
||||||
|
@ -362,6 +390,9 @@ final class Wall extends VKAPIRequestHandler
|
||||||
else
|
else
|
||||||
$groups[] = $from_id * -1;
|
$groups[] = $from_id * -1;
|
||||||
|
|
||||||
|
/*if($post->isSigned())
|
||||||
|
$profiles[] = $post->getOwner(false)->getId();*/
|
||||||
|
|
||||||
$attachments = NULL; # free attachments so it will not clone everything
|
$attachments = NULL; # free attachments so it will not clone everything
|
||||||
$repost = NULL; # same
|
$repost = NULL; # same
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@
|
||||||
{$club->getName()}
|
{$club->getName()}
|
||||||
|
|
||||||
<object type="internal/link" style="white-space: normal;" id="sug{$club->getId()}" n:if="$club->getSuggestedPostsCount() > 0 && $club->getWallType() == 2">
|
<object type="internal/link" style="white-space: normal;" id="sug{$club->getId()}" n:if="$club->getSuggestedPostsCount() > 0 && $club->getWallType() == 2">
|
||||||
<a href="/club{$club->getId()}/suggested">
|
<a href="/club{$club->getId()}/suggested" class="linkunderline">
|
||||||
(<b>{$club->getSuggestedPostsCount()}</b>)
|
(<b>{$club->getSuggestedPostsCount()}</b>)
|
||||||
</a>
|
</a>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -12,14 +12,16 @@
|
||||||
{include "../components/error.xml", title => "", description => $type == "my" ? tr("no_suggested_posts_by_you") : tr("no_suggested_posts_by_people")}
|
{include "../components/error.xml", title => "", description => $type == "my" ? tr("no_suggested_posts_by_you") : tr("no_suggested_posts_by_people")}
|
||||||
{else}
|
{else}
|
||||||
<h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4>
|
<h4 id="cound">{if $type == "my"}{tr("suggested_posts_in_group_by_you", $count)}{else}{tr("suggested_posts_in_group", $count)}{/if}</h4>
|
||||||
<div id="postz">
|
<div id="postz" class="infContainer">
|
||||||
{var $microblog = $thisUser->hasMicroblogEnabled()}
|
{var $microblog = $thisUser->hasMicroblogEnabled()}
|
||||||
{foreach $posts as $post}
|
{foreach $posts as $post}
|
||||||
|
<div class="infObj">
|
||||||
{if $microblog}
|
{if $microblog}
|
||||||
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
|
{include "../components/post/microblogpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
|
||||||
{else}
|
{else}
|
||||||
{include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
|
{include "../components/post/oldpost.xml", post => $post, commentSection => false, suggestion => true, forceNoCommentsLink => true, forceNoPinLink => true, forceNoLike => true, forceNoShareLink => true, forceNoDeleteLink => false}
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
{include "../components/paginator.xml", conf => (object) [
|
{include "../components/paginator.xml", conf => (object) [
|
||||||
|
|
Loading…
Reference in a new issue