Skip to content
Snippets Groups Projects
Commit 4ba80a36 authored by Jared Hancock's avatar Jared Hancock
Browse files

kb: Add setting to enable only for authenticated clients

parent e8cedfd6
No related branches found
No related tags found
No related merge requests found
...@@ -210,6 +210,13 @@ class OsticketConfig extends Config { ...@@ -210,6 +210,13 @@ class OsticketConfig extends Config {
} }
function isKnowledgebaseEnabled() { function isKnowledgebaseEnabled() {
global $thisclient;
if ($this->get('restrict_kb', false)
&& (!$thisclient || $thisclient->isGuest())
) {
return false;
}
require_once(INCLUDE_DIR.'class.faq.php'); require_once(INCLUDE_DIR.'class.faq.php');
return ($this->get('enable_kb') && FAQ::countPublishedFAQs()); return ($this->get('enable_kb') && FAQ::countPublishedFAQs());
} }
...@@ -1089,11 +1096,16 @@ class OsticketConfig extends Config { ...@@ -1089,11 +1096,16 @@ class OsticketConfig extends Config {
function updateKBSettings($vars, &$errors) { function updateKBSettings($vars, &$errors) {
if($errors) return false; if ($vars['restrict_kb'] && !$this->isClientRegistrationEnabled())
$errors['restrict_kb'] =
__('The knowledge base cannot be restricted unless client registration is enabled');
if ($errors) return false;
return $this->updateAll(array( return $this->updateAll(array(
'enable_kb'=>isset($vars['enable_kb'])?1:0, 'enable_kb'=>isset($vars['enable_kb'])?1:0,
'enable_premade'=>isset($vars['enable_premade'])?1:0, 'restrict_kb'=>isset($vars['restrict_kb'])?1:0,
'enable_premade'=>isset($vars['enable_premade'])?1:0,
)); ));
} }
......
...@@ -28,6 +28,15 @@ knowledge_base_status: ...@@ -28,6 +28,15 @@ knowledge_base_status:
- title: Manage Knowledge Base - title: Manage Knowledge Base
href: /scp/kb.php href: /scp/kb.php
restrict_kb:
title: Resctrict Access to the Knowledge Base
content: >
Enable this setting to prevent unregistered users from accessing
your knowledge base articles on the client interface.
links:
- title: Access Control Settings
href: /scp/settings.php?t=access
canned_responses: canned_responses:
title: Canned Responses title: Canned Responses
content: > content: >
......
...@@ -16,12 +16,16 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config) ...@@ -16,12 +16,16 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config)
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td width="180"><?php echo __('Knowledge Base Status'); ?>:</td> <td width="180" valign="top"><?php echo __('Knowledge Base Status'); ?>:</td>
<td> <td>
<input type="checkbox" name="enable_kb" value="1" <?php echo $config['enable_kb']?'checked="checked"':''; ?>> <input type="checkbox" name="enable_kb" value="1" <?php echo $config['enable_kb']?'checked="checked"':''; ?>>
<?php echo __('Enable Knowledge Base'); ?> <?php echo __('Enable Knowledge Base'); ?>
&nbsp;<font class="error">&nbsp;<?php echo $errors['enable_kb']; ?></font>
<i class="help-tip icon-question-sign" href="#knowledge_base_status"></i> <i class="help-tip icon-question-sign" href="#knowledge_base_status"></i>
<div class="error"><?php echo $errors['enable_kb']; ?></div>
<input type="checkbox" name="restrict_kb" value="1" <?php echo $config['restrict_kb']?'checked="checked"':''; ?> >
<?php echo __('Require Client Login'); ?>
<i class="help-tip icon-question-sign" href="#restrict_kb"></i>
<div class="error"><?php echo $errors['restrict_kb']; ?></div>
</td> </td>
</tr> </tr>
<tr> <tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment