1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-30 06:11:38 +08:00

完善文章和提问浏览权限

This commit is contained in:
koogua 2021-05-13 19:42:44 +08:00
parent f77d9b475d
commit b5fd0b182a
5 changed files with 23 additions and 7 deletions

View File

@ -100,9 +100,7 @@ class ArticleController extends Controller
$article = $service->handle($id);
$owned = $this->authUser->id == $article['owner']['id'];
if ($article['private'] == 1 && !$owned) {
if ($article['me']['owned'] == 0) {
$this->response->redirect(['for' => 'home.error.403']);
}

View File

@ -99,6 +99,10 @@ class QuestionController extends Controller
$question = $service->handle($id);
if ($question['me']['owned'] == 0) {
$this->response->redirect(['for' => 'home.error.403']);
}
$this->seo->prependTitle($question['title']);
$this->seo->setDescription($question['summary']);

View File

@ -70,8 +70,17 @@ class ArticleInfo extends LogicService
$me = [
'liked' => 0,
'favorited' => 0,
'owned' => 0,
];
$isOwner = $user->id == $article->owner_id;
if ($article->published == ArticleModel::PUBLISH_APPROVED) {
$me['owned'] = 1;
} else {
$me['owned'] = $isOwner ? 1 : 0;
}
if ($user->id > 0) {
$likeRepo = new ArticleLikeRepo();

View File

@ -91,8 +91,17 @@ class QuestionInfo extends LogicService
'liked' => 0,
'favorited' => 0,
'answered' => 0,
'owned' => 0,
];
$isOwner = $user->id == $question->owner_id;
if ($question->published == QuestionModel::PUBLISH_APPROVED) {
$me['owned'] = 1;
} else {
$me['owned'] = $isOwner ? 1 : 0;
}
if ($user->id > 0) {
$likeRepo = new QuestionLikeRepo();

View File

@ -577,10 +577,6 @@
color: #666;
}
.article-info .meta a {
color: #666;
}
.article-info .meta .left span {
margin-right: 10px;
}