Skip to content

Commit

Permalink
Simplify fields.inc configuration. (CFM-218)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen committed Sep 24, 2025
1 parent 3cfe0ea commit 093219c
Show file tree
Hide file tree
Showing 34 changed files with 203 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ if(!$vv_status->locked) {
$fields = [
'password',
'password2' => [
'fieldOptions' => [
'type' => 'password'
]
'type' => 'password'
]
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
$fields = [
'server_id',
'table_prefix' => [
'fieldOptions' => [
'default' => 'sp_'
]
'default' => 'sp_'
]
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ foreach([
'url_type_id'
] as $field) {
$fields[$field] = [
'fieldOptions' => [
'required' => false
]
'required' => false
];
}

Expand Down
59 changes: 25 additions & 34 deletions app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,17 @@ if($vv_action !== 'edit') {
return;
}

// Used for placeholders
$defaultValues = array_combine(
array_values($defaults),
array_keys($defaults)
);

$fields = [
'mode',
'message_template_id',
'request_validity' => [
'fieldOptions' => [
'placeholder' => $defaultValues['DefaultVerificationValidity']
]
]
];

// Establish the before and after field-supplements for the 'verification_code_regex'
$checked = !empty($vv_obj?->verification_code_charset) ? 'checked' : '';
$otherLabel = __d('core_enroller','field.EmailVerifiers.verification_code_charset.other_value');
$beforeField = <<<OTHER
<div class="field-suppliment">
<div class="field-supplement">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="other-toggle" $checked/>
<label class="form-check-label" for="other-toggle">$otherLabel</label>
Expand Down Expand Up @@ -91,43 +83,42 @@ document.addEventListener('DOMContentLoaded', function() {
JS;

$regexDisplayFirstTime = empty($vv_obj?->verification_code_charset) && empty($vv_obj?->verification_code_regex);
$fields['verification_code_regex'] = [
'fieldLabel' => __d('core_enroller','field.EmailVerifiers.verification_code_charset'),
'groupedControls' => [
'verification_code_regex' => [
'fieldOptions' => [

// List the fields
$fields = [
'mode',
'message_template_id',
'request_validity' => [
'placeholder' => $defaultValues['DefaultVerificationValidity']
],
'verification_code_regex' => [
'fieldLabel' => __d('core_enroller','field.EmailVerifiers.verification_code_charset'),
'groupedControls' => [
'verification_code_regex' => [
'id' => 'verification-code-regex',
'required' => false,
'empty' => true,
'style' => $regexDisplayFirstTime || !empty($vv_obj?->verification_code_regex) ? '' : 'display: none;',
'fieldType' => 'select',
'fieldSelectOptions' => $permittedCharacters
],
'fieldType' => 'select',
'fieldSelectOptions' => $permittedCharacters,
],
'verification_code_charset' => [
'fieldOptions' => [
'verification_code_charset' => [
'type' => 'text',
'label' => false,
'id' => 'verification-code-charset',
'style' => !empty($vv_obj?->verification_code_charset) ? '' : 'display: none;',
'required' => false,
'checked' => !empty($vv_obj?->verification_code_charset) ? 'checked' : ''
]
]
],
'beforeField' => $beforeField,
'afterField' => $afterField
],
'beforeField' => $beforeField,
'afterField' => $afterField
];

$fields['verification_code_length'] = [
'fieldOptions' => [
'verification_code_length' => [
'required' => false,
'placeholder' => $defaultValues['DefaultCodeLength']
]
];

$fields['enable_blockonfailure'] = [
'fieldOptions' => [
'default' => true,
],
'enable_blockonfailure' => [
'default' => true
]
];
29 changes: 7 additions & 22 deletions app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ $fields = [
'status',
'ordr',
'required' => [
// XXX flatten fieldOptions
'fieldOptions' => [
'default' => true
]
'default' => true
]
];

Expand All @@ -91,9 +88,7 @@ if (
&& count($vv_supported_attributes[$attribute_type]['mveaParents']) > 0
) {
$fields['attribute_mvea_parent'] = [
'fieldOptions' => [
'empty' => false
],
'empty' => false,
'fieldType' => 'select',
'fieldSelectOptions' => array_combine(
$vv_supported_attributes[$attribute_type]['mveaParents'],
Expand All @@ -110,9 +105,7 @@ if (
if ($this->get($mveaAutoPopulatedVariable) !== null) {
$fields['attribute_type'] = [
'fieldLabel' => $attributes[$attribute_type] . ' Type',
'fieldOptions' => [
'empty' => false
],
'empty' => false,
'fieldType' => 'select',
'fieldSelectOptions' => $this->get($mveaAutoPopulatedVariable)
];
Expand All @@ -129,9 +122,7 @@ if(str_ends_with($attribute_type, '_id')) {
$defaultValuesPopulated = 'defaultValue' . $suffix;
if ($this->get($defaultValuesPopulated) !== null) {
$fields['default_value'] = [
'fieldOptions' => [
'empty' => true
],
'empty' => true,
'fieldType' => 'select',
'fieldSelectOptions' => $this->get($defaultValuesPopulated)
];
Expand All @@ -145,9 +136,7 @@ if(str_ends_with($attribute_type, '_id')) {
*/
if (\in_array($attribute_type, ['adHocAttribute'], true)) {
$fields['attribute_tag'] = [
'fieldOptions' => [
'required' => true
]
'required' => true
];
}

Expand Down Expand Up @@ -195,9 +184,7 @@ if($attribute_type === 'valid_from') {
if($attribute_type === 'valid_through') {
$fields['default_value'] = [
'fieldDescription' => __d('core_enroller', 'field.AttributeCollectors.valid_through.default.after.desc'),
'fieldOptions' => [
'type' => 'number'
]
'type' => 'number'
];
}

Expand All @@ -210,9 +197,7 @@ if (
&& \in_array($vv_supported_attributes[$attribute_type]['model'], ['PersonRole', 'Person', 'Group'], true)
) {
$fields['modifiable'] = [
'fieldOptions' => [
'default' => true
]
'default' => true
];

$fields[] = 'hidden';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ if($vv_action !== 'edit') {

$fields = [
'invitation_validity' => [
'fieldOptions' => [
'default' => 1440
]
'default' => 1440
],
'welcome_message'
];
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
$fields = [
'attribute',
'type_id' => [ // type_id is a hidden field used to persist the type
'fieldOptions' => [
'type' => 'integer'
]
'type' => 'integer'
]
];

Expand Down
14 changes: 4 additions & 10 deletions app/plugins/CoreServer/templates/Oauth2Servers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,19 @@ if($vv_action !== 'edit') {
// Render the Redirect URI
$fields = [
'redirect_uri' => [
'fieldOptions' => [
'readOnly' => true,
'default' => $vv_redirect_uri
]
'readonly' => true,
'default' => $vv_redirect_uri
],
'url',
'access_grant_type' => [
'fieldSelectOptions' => $types,
'fieldType' => 'select',
'fieldOptions' => [
'empty' => false,
]
'empty' => false
],
'clientid',
'client_secret',
'scope' => [
'fieldOptions' => [
'placeholder' => '/authenticate',
]
'placeholder' => '/authenticate',
]
];

Expand Down
8 changes: 2 additions & 6 deletions app/plugins/CoreServer/templates/SmtpServers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ if($vv_action !== 'edit') {
$fields = [
'hostname',
'port' => [
'fieldOptions' => [
'default' => 587
]
'default' => 587
],
'username',
'password',
'use_tls' => [
'fieldOptions' => [
'default' => true
]
'default' => true
],
'default_from',
'default_reply_to',
Expand Down
4 changes: 1 addition & 3 deletions app/plugins/EnvSource/templates/EnvSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ foreach([
'env_title'
] as $field) {
$fields[$field] = [
'fieldOptions' => [
'default' => $defaultNames[$field]
]
'default' => $defaultNames[$field]
];
}
29 changes: 9 additions & 20 deletions app/plugins/OrcidSource/templates/OrcidSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,29 @@ if (filter_var($vv_obj->scope_inherit, FILTER_VALIDATE_BOOLEAN)) {
$fields = [
// Render the Redirect URI
'redirect_uri' => [
'fieldOptions' => [
'readOnly' => true,
'default' => $vv_redirect_uri
]
'readonly' => true,
'default' => $vv_redirect_uri
],
'server_id' => [
'fieldOptions' => [
'empty' => false,
'required' => true,
]
'empty' => false,
'required' => true
],
'api_type' => [
'fieldSelectOptions' => $api_types,
'fieldType' => 'select',
'fieldOptions' => [
'empty' => false,
'required' => true,
]
'empty' => false,
'required' => true
],
'api_tier' => [
'fieldSelectOptions' => $api_tiers,
'fieldType' => 'select',
'fieldOptions' => [
'empty' => false,
'required' => true,
]
'empty' => false,
'required' => true
],
'scope_inherit',
// Render active scopes
'Scope' => [
'fieldOptions' => [
'readOnly' => true,
'default' => $vv_inherited_scopes
]
'readonly' => true,
],
'SUBTITLE' => [
'subtitle' => __d('orcid_source', 'information.OrcidSources.default.types')
Expand Down
4 changes: 1 addition & 3 deletions app/plugins/SshKeyAuthenticator/templates/SshKeys/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ if($vv_action == 'add') {
// As of v3.2.0, we only allow uploading of SSH Keys, not manually adding or editing
$fields = [
'keyFile' => [
'fieldOptions' => [
'type' => 'file'
]
'type' => 'file'
]
];
} elseif($vv_action == 'view') {
Expand Down
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ msgstr "{0} MFA Exemptions"
msgid "Groups.group_type"
msgstr "Group Type"

msgid "Groups.members_group_id"
msgstr "Members Group"

msgid "Groups.nesting_mode_all"
msgstr "Nesting Mode: All"

Expand Down
Loading

0 comments on commit 093219c

Please sign in to comment.