Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
39ba8686
Commit
39ba8686
authored
Apr 04, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #876 from fraenki/multi_certs
support multiple values in CertificateField
parents
6c79ec95
f5cd82c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
CertificateField.php
.../app/models/OPNsense/Base/FieldTypes/CertificateField.php
+31
-4
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CertificateField.php
View file @
39ba8686
...
...
@@ -30,6 +30,7 @@
namespace
OPNsense\Base\FieldTypes
;
use
Phalcon\Validation\Validator\InclusionIn
;
use
OPNsense\Base\Validators\CsvListValidator
;
use
OPNsense\Core\Config
;
/**
...
...
@@ -49,6 +50,11 @@ class CertificateField extends BaseField
*/
private
$certificateType
=
"cert"
;
/**
* @var bool field may contain multiple certs at once
*/
private
$internalMultiSelect
=
false
;
/**
* @var string default validation message string
*/
...
...
@@ -59,7 +65,6 @@ class CertificateField extends BaseField
*/
private
static
$internalOptionList
=
array
();
/**
* set certificate type (cert/ca)
* @param $value certificate type
...
...
@@ -73,6 +78,19 @@ class CertificateField extends BaseField
}
}
/**
* select if multiple certs may be selected at once
* @param $value boolean value Y/N
*/
public
function
setMultiple
(
$value
)
{
if
(
trim
(
strtoupper
(
$value
))
==
"Y"
)
{
$this
->
internalMultiSelect
=
true
;
}
else
{
$this
->
internalMultiSelect
=
false
;
}
}
/**
* generate validation data (list of certificates)
*/
...
...
@@ -97,8 +115,10 @@ class CertificateField extends BaseField
if
(
!
$this
->
internalIsRequired
)
{
$result
[
""
]
=
array
(
"value"
=>
gettext
(
"none"
),
"selected"
=>
0
);
}
$certs
=
explode
(
','
,
$this
->
internalValue
);
foreach
(
self
::
$internalOptionList
as
$optKey
=>
$optValue
)
{
if
(
$optKey
==
$this
->
internalValue
)
{
if
(
in_array
(
$optKey
,
$certs
)
)
{
$selected
=
1
;
}
else
{
$selected
=
0
;
...
...
@@ -117,8 +137,15 @@ class CertificateField extends BaseField
{
$validators
=
parent
::
getValidators
();
if
(
$this
->
internalValue
!=
null
)
{
$validators
[]
=
new
InclusionIn
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'domain'
=>
array_keys
(
self
::
$internalOptionList
)));
if
(
$this
->
internalMultiSelect
)
{
// field may contain more than one country
$validators
[]
=
new
CsvListValidator
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'domain'
=>
array_keys
(
self
::
$internalOptionList
)));
}
else
{
// single country selection
$validators
[]
=
new
InclusionIn
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'domain'
=>
array_keys
(
self
::
$internalOptionList
)));
}
}
return
$validators
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment