mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-30 22:24:55 +08:00
完善文章和提问浏览权限
This commit is contained in:
parent
f77d9b475d
commit
b5fd0b182a
@ -100,9 +100,7 @@ class ArticleController extends Controller
|
|||||||
|
|
||||||
$article = $service->handle($id);
|
$article = $service->handle($id);
|
||||||
|
|
||||||
$owned = $this->authUser->id == $article['owner']['id'];
|
if ($article['me']['owned'] == 0) {
|
||||||
|
|
||||||
if ($article['private'] == 1 && !$owned) {
|
|
||||||
$this->response->redirect(['for' => 'home.error.403']);
|
$this->response->redirect(['for' => 'home.error.403']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +99,10 @@ class QuestionController extends Controller
|
|||||||
|
|
||||||
$question = $service->handle($id);
|
$question = $service->handle($id);
|
||||||
|
|
||||||
|
if ($question['me']['owned'] == 0) {
|
||||||
|
$this->response->redirect(['for' => 'home.error.403']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->seo->prependTitle($question['title']);
|
$this->seo->prependTitle($question['title']);
|
||||||
$this->seo->setDescription($question['summary']);
|
$this->seo->setDescription($question['summary']);
|
||||||
|
|
||||||
|
@ -70,8 +70,17 @@ class ArticleInfo extends LogicService
|
|||||||
$me = [
|
$me = [
|
||||||
'liked' => 0,
|
'liked' => 0,
|
||||||
'favorited' => 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) {
|
if ($user->id > 0) {
|
||||||
|
|
||||||
$likeRepo = new ArticleLikeRepo();
|
$likeRepo = new ArticleLikeRepo();
|
||||||
|
@ -91,8 +91,17 @@ class QuestionInfo extends LogicService
|
|||||||
'liked' => 0,
|
'liked' => 0,
|
||||||
'favorited' => 0,
|
'favorited' => 0,
|
||||||
'answered' => 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) {
|
if ($user->id > 0) {
|
||||||
|
|
||||||
$likeRepo = new QuestionLikeRepo();
|
$likeRepo = new QuestionLikeRepo();
|
||||||
|
@ -577,10 +577,6 @@
|
|||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-info .meta a {
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-info .meta .left span {
|
.article-info .meta .left span {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user