mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-30 14:14:55 +08:00
完善文章和提问浏览权限
This commit is contained in:
parent
f77d9b475d
commit
b5fd0b182a
@ -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']);
|
||||
}
|
||||
|
||||
|
@ -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']);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -577,10 +577,6 @@
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.article-info .meta a {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.article-info .meta .left span {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user