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 <?php
/** /**
* Copyright (C) 2015 Deciso B.V. * Copyright (C) 2015-2016 Deciso B.V.
* *
* All rights reserved. * All rights reserved.
* *
...@@ -98,11 +98,12 @@ class CertificateField extends BaseField ...@@ -98,11 +98,12 @@ class CertificateField extends BaseField
*/ */
public function eventPostLoading() public function eventPostLoading()
{ {
if (count($this->internalOptionList) ==0) { if (!array_key_exists($this->certificateType, self::$internalOptionList)) {
$configObj = Config::getInstance()->object(); self::$internalOptionList[$this->certificateType] = array();
foreach ($configObj->{$this->certificateType} as $cert) { $configObj = Config::getInstance()->object();
self::$internalOptionList[(string)$cert->refid] = (string)$cert->descr ; foreach ($configObj->{$this->certificateType} as $cert) {
} self::$internalOptionList[$this->certificateType][(string)$cert->refid] = (string)$cert->descr ;
}
} }
} }
...@@ -119,7 +120,7 @@ class CertificateField extends BaseField ...@@ -119,7 +120,7 @@ class CertificateField extends BaseField
} }
$certs = explode(',', $this->internalValue); $certs = explode(',', $this->internalValue);
foreach (self::$internalOptionList as $optKey => $optValue) { foreach (self::$internalOptionList[$this->certificateType] as $optKey => $optValue) {
if (in_array($optKey, $certs)) { if (in_array($optKey, $certs)) {
$selected = 1; $selected = 1;
} else { } else {
...@@ -140,13 +141,13 @@ class CertificateField extends BaseField ...@@ -140,13 +141,13 @@ class CertificateField extends BaseField
$validators = parent::getValidators(); $validators = parent::getValidators();
if ($this->internalValue != null) { if ($this->internalValue != null) {
if ($this->internalMultiSelect) { if ($this->internalMultiSelect) {
// field may contain more than one country // field may contain more than one cert
$validators[] = new CsvListValidator(array('message' => $this->internalValidationMessage, $validators[] = new CsvListValidator(array('message' => $this->internalValidationMessage,
'domain'=>array_keys(self::$internalOptionList))); 'domain'=>array_keys(self::$internalOptionList[$this->certificateType])));
} else { } else {
// single country selection // single cert selection
$validators[] = new InclusionIn(array('message' => $this->internalValidationMessage, $validators[] = new InclusionIn(array('message' => $this->internalValidationMessage,
'domain'=>array_keys(self::$internalOptionList))); 'domain'=>array_keys(self::$internalOptionList[$this->certificateType])));
} }
} }
return $validators; 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