diff --git a/include/class.ticket.php b/include/class.ticket.php index 49513b52df6d61b1107366e85ff186838a9e2d6f..4a84e7757131b0456f47c44ca20c2603a3b877d6 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1006,12 +1006,16 @@ implements RestrictedAccess, Threadable, Searchable { )); break; case 'topic': + $current = array(); + if ($topic = $this->getTopic()) + $current = array($topic->getId()); + $choices = Topic::getHelpTopics(false, $topic ? (Topic::DISPLAY_DISABLED) : false, true, $current); return ChoiceField::init(array( 'id' => $fid, 'name' => "{$fid}_id", 'label' => __('Help Topic'), 'default' => $this->getTopicId(), - 'choices' => Topic::getHelpTopics(false, Topic::DISPLAY_DISABLED) + 'choices' => $choices )); break; case 'source': @@ -3338,7 +3342,7 @@ implements RestrictedAccess, Threadable, Searchable { } } - if (!$this->save()) + if (!$errors && !$this->save()) $errors['field'] = __('Unable to update field'); } } diff --git a/include/class.topic.php b/include/class.topic.php index 8ef9de2124b646f5b671c40be2e8f82382d5e025..75c06b7dfe2037147669501cbcb164714e738a37 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -329,7 +329,7 @@ implements TemplateVariable, Searchable { $this->flags &= ~$flag; } - static function getHelpTopics($publicOnly=false, $disabled=false, $localize=true) { + static function getHelpTopics($publicOnly=false, $disabled=false, $localize=true, $whitelist=array()) { global $cfg; static $topics, $names = array(); @@ -385,7 +385,8 @@ implements TemplateVariable, Searchable { $info = $topics[$id]; if ($publicOnly && !$info['public']) continue; - if (!$disabled && $info['disabled']) + //if topic is disabled + we're not getting all topics OR topic is not in whitelist + if ($info['disabled'] && (!$disabled || ($whitelist && !in_array($id, $whitelist)))) continue; if ($disabled === self::DISPLAY_DISABLED && $info['disabled']) $n .= " - ".__("(disabled)");