Commit f1841369 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(model) CertificateField missing cert type in cache, closes...

(model) CertificateField missing cert type in cache, closes https://github.com/opnsense/core/issues/1095

(cherry picked from commit 2dc8de2c)
(cherry picked from commit 27148ac6)
parent 79cba43f
<?php
/**
* Copyright (C) 2015 Deciso B.V.
* Copyright (C) 2015-2016 Deciso B.V.
*
* All rights reserved.
*
......@@ -98,10 +98,11 @@ class CertificateField extends BaseField
*/
public function eventPostLoading()
{
if (count($this->internalOptionList) ==0) {
if (!array_key_exists($this->certificateType, self::$internalOptionList)) {
self::$internalOptionList[$this->certificateType] = array();
$configObj = Config::getInstance()->object();
foreach ($configObj->{$this->certificateType} as $cert) {
self::$internalOptionList[(string)$cert->refid] = (string)$cert->descr ;
self::$internalOptionList[$this->certificateType][(string)$cert->refid] = (string)$cert->descr ;
}
}
}
......@@ -119,7 +120,7 @@ class CertificateField extends BaseField
}
$certs = explode(',', $this->internalValue);
foreach (self::$internalOptionList as $optKey => $optValue) {
foreach (self::$internalOptionList[$this->certificateType] as $optKey => $optValue) {
if (in_array($optKey, $certs)) {
$selected = 1;
} else {
......@@ -140,13 +141,13 @@ class CertificateField extends BaseField
$validators = parent::getValidators();
if ($this->internalValue != null) {
if ($this->internalMultiSelect) {
// field may contain more than one country
// field may contain more than one cert
$validators[] = new CsvListValidator(array('message' => $this->internalValidationMessage,
'domain'=>array_keys(self::$internalOptionList)));
'domain'=>array_keys(self::$internalOptionList[$this->certificateType])));
} else {
// single country selection
// single cert selection
$validators[] = new InclusionIn(array('message' => $this->internalValidationMessage,
'domain'=>array_keys(self::$internalOptionList)));
'domain'=>array_keys(self::$internalOptionList[$this->certificateType])));
}
}
return $validators;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment