Skip to content

Commit 3d6fec7

Browse files
authored
Merge pull request #18 from luceos/master
fix: hides sign up link when sign ups are disabled
2 parents 8deacce + b3e6c3d commit 3d6fec7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

locale/en.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
jslirola-login2seeplus:
22
forum:
33
post: "You have to {login} or {register} to see the full post"
4+
post_login: "You have to {login} to see the full post"
45
link: Login to see the link
56
image: Login to see the image
67
code: Login to see the code

src/HideContentInPosts.php

+14-6
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ public function __invoke($serializer, $model, $attributes)
5050
$newHTML = preg_replace('/<pre><code(.*?)>[^>]*<\/pre>/is', $this->get_link('jslirola-login2seeplus.forum.code'), $newHTML);
5151
$newHTML = preg_replace('/<code(.*?)>[^>]*<\/code>/is', $this->get_link('jslirola-login2seeplus.forum.code'), $newHTML);
5252
}
53-
5453
// show alert
55-
if ($s_post != -1)
56-
$newHTML .= '<div class="jslirolaLogin2seeplusAlert">' . $this->translator->trans('jslirola-login2seeplus.forum.post', array(
57-
'{login}' => '<a class="jslirolaLogin2seeplusLogin">' . $this->translator->trans('core.forum.header.log_in_link') . '</a>',
58-
'{register}' => '<a class="jslirolaLogin2seeplusRegister">' . $this->translator->trans('core.forum.header.sign_up_link') . '</a>'
59-
)) . '</div>';
54+
if ($s_post != -1) {
55+
$args = [
56+
'{login}' => '<a class="jslirolaLogin2seeplusLogin">' . $this->translator->trans('core.forum.header.log_in_link') . '</a>'
57+
];
58+
59+
if ($this->settings->get('allow_sign_up') === '1') {
60+
$args['register'] = '<a class="jslirolaLogin2seeplusRegister">' . $this->translator->trans('core.forum.header.sign_up_link') . '</a>';
61+
}
62+
63+
$key = $this->settings->get('allow_sign_up') === '1'
64+
? 'jslirola-login2seeplus.forum.post'
65+
: 'jslirola-login2seeplus.forum.post_login';
66+
$newHTML .= '<div class="jslirolaLogin2seeplusAlert">' . $this->translator->trans($key,$args) . '</div>';
67+
}
6068

6169
$attributes['contentHtml'] = $newHTML;
6270

0 commit comments

Comments
 (0)