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

topics: Forbid setting disabled topic as default

parent 7b241891
No related branches found
No related tags found
No related merge requests found
...@@ -931,7 +931,7 @@ class OsticketConfig extends Config { ...@@ -931,7 +931,7 @@ class OsticketConfig extends Config {
if($vars['enable_captcha']) { if($vars['enable_captcha']) {
if (!extension_loaded('gd')) if (!extension_loaded('gd'))
$errors['enable_captcha']='The GD extension required'; $errors['enable_captcha']='The GD extension is required';
elseif(!function_exists('imagepng')) elseif(!function_exists('imagepng'))
$errors['enable_captcha']='PNG support required for Image Captcha'; $errors['enable_captcha']='PNG support required for Image Captcha';
} }
...@@ -957,7 +957,11 @@ class OsticketConfig extends Config { ...@@ -957,7 +957,11 @@ class OsticketConfig extends Config {
$errors['max_staff_file_uploads']='Invalid selection. Must be less than '.$maxfileuploads; $errors['max_staff_file_uploads']='Invalid selection. Must be less than '.$maxfileuploads;
} }
if ($vars['default_help_topic']
&& ($T = Topic::lookup($vars['default_help_topic']))
&& !$T->isActive()) {
$errors['default_help_topic'] = 'Default help topic must be set to active';
}
if(!Validator::process($f, $vars, $errors) || $errors) if(!Validator::process($f, $vars, $errors) || $errors)
return false; return false;
......
...@@ -23,6 +23,8 @@ class Topic { ...@@ -23,6 +23,8 @@ class Topic {
var $page; var $page;
var $form; var $form;
const DISPLAY_DISABLED = 2;
function Topic($id) { function Topic($id) {
$this->id=0; $this->id=0;
$this->load($id); $this->load($id);
...@@ -250,8 +252,6 @@ class Topic { ...@@ -250,8 +252,6 @@ class Topic {
$names[$id] = $name; $names[$id] = $name;
} }
} }
if ($disabled && !$publicOnly)
return $names;
// Apply requested filters // Apply requested filters
$requested_names = array(); $requested_names = array();
...@@ -261,6 +261,8 @@ class Topic { ...@@ -261,6 +261,8 @@ class Topic {
continue; continue;
if (!$disabled && $info['disabled']) if (!$disabled && $info['disabled'])
continue; continue;
if ($disabled === self::DISPLAY_DISABLED && $info['disabled'])
$n .= " — (disabled)";
$requested_names[$id] = $n; $requested_names[$id] = $n;
} }
......
...@@ -68,12 +68,13 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) ...@@ -68,12 +68,13 @@ if(!($maxfileuploads=ini_get('max_file_uploads')))
<td> <td>
<select name="default_help_topic"> <select name="default_help_topic">
<option value="0">&mdash; None &mdash;</option><?php <option value="0">&mdash; None &mdash;</option><?php
$topics = Topic::getHelpTopics(); $topics = Topic::getHelpTopics(false, Topic::DISPLAY_DISABLED);
while (list($id,$topic) = each($topics)) { ?> while (list($id,$topic) = each($topics)) { ?>
<option value="<?php echo $id; ?>"<?php echo ($config['default_help_topic']==$id)?'selected':''; ?>><?php echo $topic; ?></option> <option value="<?php echo $id; ?>"<?php echo ($config['default_help_topic']==$id)?'selected':''; ?>><?php echo $topic; ?></option>
<?php <?php
} ?> } ?>
</select> </select><br/>
<span class="error"><?php echo $errors['default_help_topic']; ?></span>
</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