diff --git a/app/Http/Home/Controllers/ArticleController.php b/app/Http/Home/Controllers/ArticleController.php index 87dac7ea..72cf8c46 100644 --- a/app/Http/Home/Controllers/ArticleController.php +++ b/app/Http/Home/Controllers/ArticleController.php @@ -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']); } diff --git a/app/Http/Home/Controllers/QuestionController.php b/app/Http/Home/Controllers/QuestionController.php index 78fcbf20..cc616caf 100644 --- a/app/Http/Home/Controllers/QuestionController.php +++ b/app/Http/Home/Controllers/QuestionController.php @@ -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']); diff --git a/app/Services/Logic/Article/ArticleInfo.php b/app/Services/Logic/Article/ArticleInfo.php index bbe63c0c..201ff557 100644 --- a/app/Services/Logic/Article/ArticleInfo.php +++ b/app/Services/Logic/Article/ArticleInfo.php @@ -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(); diff --git a/app/Services/Logic/Question/QuestionInfo.php b/app/Services/Logic/Question/QuestionInfo.php index 192e19b8..3ec8e782 100644 --- a/app/Services/Logic/Question/QuestionInfo.php +++ b/app/Services/Logic/Question/QuestionInfo.php @@ -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(); diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index 609ed47d..727d1878 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -577,10 +577,6 @@ color: #666; } -.article-info .meta a { - color: #666; -} - .article-info .meta .left span { margin-right: 10px; }