mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
knowledge: add access area
This commit is contained in:
parent
3275b96a0a
commit
f1c62e2732
@ -20,8 +20,14 @@ class KnowledgeController extends Controller
|
|||||||
if (!$knowledge) abort(500, __('user.knowledge.fetch.knowledge_not_exist'));
|
if (!$knowledge) abort(500, __('user.knowledge.fetch.knowledge_not_exist'));
|
||||||
$user = User::find($request->session()->get('id'));
|
$user = User::find($request->session()->get('id'));
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
$appleId = $userService->isAvailable($user) ? config('v2board.apple_id') : __('user.knowledge.fetch.apple_id_must_be_plan');
|
if ($userService->isAvailable($user)) {
|
||||||
$appleIdPassword = $userService->isAvailable($user) ? config('v2board.apple_id_password') : __('user.knowledge.fetch.apple_id_must_be_plan');
|
$appleId = config('v2board.apple_id');
|
||||||
|
$appleIdPassword = config('v2board.apple_id_password');
|
||||||
|
} else {
|
||||||
|
$appleId = __('user.knowledge.fetch.apple_id_must_be_plan');
|
||||||
|
$appleIdPassword = __('user.knowledge.fetch.apple_id_must_be_plan');
|
||||||
|
$this->formatAccessData($knowledge['body']);
|
||||||
|
}
|
||||||
$subscribeUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'];
|
$subscribeUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||||
$knowledge['body'] = str_replace('{{siteName}}', config('v2board.app_name', 'V2Board'), $knowledge['body']);
|
$knowledge['body'] = str_replace('{{siteName}}', config('v2board.app_name', 'V2Board'), $knowledge['body']);
|
||||||
$knowledge['body'] = str_replace('{{appleId}}', $appleId, $knowledge['body']);
|
$knowledge['body'] = str_replace('{{appleId}}', $appleId, $knowledge['body']);
|
||||||
@ -51,4 +57,13 @@ class KnowledgeController extends Controller
|
|||||||
'data' => $knowledges
|
'data' => $knowledges
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function formatAccessData(&$body)
|
||||||
|
{
|
||||||
|
function getBetween($input, $start, $end){$substr = substr($input, strlen($start)+strpos($input, $start),(strlen($input) - strpos($input, $end))*(-1));return $substr;}
|
||||||
|
$accessData = getBetween($body, '<!--access start-->', '<!--access end-->');
|
||||||
|
if ($accessData) {
|
||||||
|
$body = str_replace($accessData, '<div class="v2board-no-access">'. __('user.knowledge.formatAccessData.no_access') .'</div>', $body);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
2
public/assets/user/umi.css
vendored
2
public/assets/user/umi.css
vendored
File diff suppressed because one or more lines are too long
@ -112,6 +112,9 @@ return [
|
|||||||
'fetch' => [
|
'fetch' => [
|
||||||
'knowledge_not_exist' => 'Article does not exist',
|
'knowledge_not_exist' => 'Article does not exist',
|
||||||
'apple_id_must_be_plan' => 'No active subscription. Unable to use our provided Apple ID'
|
'apple_id_must_be_plan' => 'No active subscription. Unable to use our provided Apple ID'
|
||||||
|
],
|
||||||
|
'formatAccessData' => [
|
||||||
|
'no_access' => 'You must have a valid subscription to view content in this area'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'invite' => [
|
'invite' => [
|
||||||
|
@ -112,6 +112,9 @@ return [
|
|||||||
'fetch' => [
|
'fetch' => [
|
||||||
'knowledge_not_exist' => '文章不存在',
|
'knowledge_not_exist' => '文章不存在',
|
||||||
'apple_id_must_be_plan' => '无有效订阅,无法使用本站提供的 AppleID'
|
'apple_id_must_be_plan' => '无有效订阅,无法使用本站提供的 AppleID'
|
||||||
|
],
|
||||||
|
'formatAccessData' => [
|
||||||
|
'no_access' => '你必须拥有有效的订阅才可以查看该区域的内容'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'invite' => [
|
'invite' => [
|
||||||
|
Loading…
Reference in New Issue
Block a user