diff --git a/include/class.config.php b/include/class.config.php index e61c068140e396ed989afae21757797e90d7e714..73261e24c3df3547f3bbce2e3d2dadc48662e3b9 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -210,6 +210,13 @@ class OsticketConfig extends Config { } function isKnowledgebaseEnabled() { + global $thisclient; + + if ($this->get('restrict_kb', false) + && (!$thisclient || $thisclient->isGuest()) + ) { + return false; + } require_once(INCLUDE_DIR.'class.faq.php'); return ($this->get('enable_kb') && FAQ::countPublishedFAQs()); } @@ -1089,11 +1096,16 @@ class OsticketConfig extends Config { 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( '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, )); } diff --git a/include/i18n/en_US/help/tips/settings.kb.yaml b/include/i18n/en_US/help/tips/settings.kb.yaml index 12f4954725fd56d5befbda7ab26276487f7d1746..702dac9d573a5bf3094321069db57c20dc511331 100644 --- a/include/i18n/en_US/help/tips/settings.kb.yaml +++ b/include/i18n/en_US/help/tips/settings.kb.yaml @@ -28,6 +28,15 @@ knowledge_base_status: - title: Manage Knowledge Base 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: title: Canned Responses content: > diff --git a/include/staff/settings-kb.inc.php b/include/staff/settings-kb.inc.php index cfac97418f92f1156c0c6022911dc4aaa3bd0310..941b08e30fed4e3ca89c6023ce472ae4a452288f 100644 --- a/include/staff/settings-kb.inc.php +++ b/include/staff/settings-kb.inc.php @@ -16,12 +16,16 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config) </thead> <tbody> <tr> - <td width="180"><?php echo __('Knowledge Base Status'); ?>:</td> + <td width="180" valign="top"><?php echo __('Knowledge Base Status'); ?>:</td> <td> <input type="checkbox" name="enable_kb" value="1" <?php echo $config['enable_kb']?'checked="checked"':''; ?>> <?php echo __('Enable Knowledge Base'); ?> - <font class="error"> <?php echo $errors['enable_kb']; ?></font> <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> </tr> <tr>