Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sfb-commons
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
RDP INF
sfb-commons
Commits
2ff024e2
Commit
2ff024e2
authored
3 years ago
by
Jonas Adrian Rieling
Browse files
Options
Downloads
Patches
Plain Diff
added validation for rorid entries
parent
22a852d1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/WorkingGroup.php
+10
-0
10 additions, 0 deletions
classes/WorkingGroup.php
includes/sfb_commons_config_groups_add.inc
+6
-1
6 additions, 1 deletion
includes/sfb_commons_config_groups_add.inc
includes/sfb_commons_config_groups_edit.inc
+3
-0
3 additions, 0 deletions
includes/sfb_commons_config_groups_edit.inc
with
19 additions
and
1 deletion
classes/WorkingGroup.php
+
10
−
0
View file @
2ff024e2
...
...
@@ -365,4 +365,14 @@ class WorkingGroup {
);
}
/**
* @param string $rorid
* @return bool
*/
public
static
function
validateRorId
(
$rorid
){
return
(
preg_match
(
"/[0-9a-zA-Z]
{
9
}
$/"
,
$rorid
)
||
(
$rorid
==
'unknown'
)
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
includes/sfb_commons_config_groups_add.inc
+
6
−
1
View file @
2ff024e2
...
...
@@ -59,6 +59,7 @@ function sfb_commons_config_groups_add(){
'#title'
=>
t
(
'Leader\'s institutions ROR ID'
),
'#description'
=>
t
(
'Institutions ROR ID'
),
'#default_value'
=>
$working_group
->
getLeaderInstitution
(),
);
$form
[
'leader_orcid'
]
=
array
(
'#type'
=>
'textfield'
,
...
...
@@ -80,9 +81,13 @@ function sfb_commons_config_groups_add(){
* Validation for group add form.
*/
function
sfb_commons_config_groups_add_validate
(
$form
,
&
$form_state
){
/** ORCID format validation */
/** format validation */
if
(
!
WorkingGroup
::
validateORCID
(
$form_state
[
'values'
][
'leader_orcid'
]))
form_set_error
(
'leader_orcid'
,
t
(
'Give a valid ORCID (e.g. 0000-0000-0000-0000) or leave field with \'unknown\'.'
));
if
(
!
WorkingGroup
::
validateRorId
(
$form_state
[
'values'
][
'leader_institution_ror_id'
]))
form_set_error
(
'leader_institution_ror_id'
,
t
(
'Give a valid ROR ID (e.g. 021ft0n22) or leave field with \'unknown\'.'
));
}
/**
...
...
This diff is collapsed.
Click to expand it.
includes/sfb_commons_config_groups_edit.inc
+
3
−
0
View file @
2ff024e2
...
...
@@ -65,6 +65,7 @@ function sfb_commons_config_groups_edit($form, &$form_state, $working_group_id)
'#title'
=>
t
(
'Leader\'s institutions ROR ID'
),
'#description'
=>
t
(
'Institutions ROR ID'
),
'#default_value'
=>
$working_group
->
getLeaderInstitutionRorId
(),
];
$form
[
'leader_orcid'
]
=
[
'#type'
=>
'textfield'
,
...
...
@@ -151,6 +152,8 @@ function sfb_commons_config_groups_edit_validate($form, &$form_state) {
if
(
!
WorkingGroup
::
validateORCID
(
$form_state
[
'values'
][
'leader_orcid'
]))
form_set_error
(
'leader_orcid'
,
t
(
'Give a valid ORCID (e.g. 0000-0000-0000-0000) or leave field with \'unknown\'.'
));
if
(
!
WorkingGroup
::
validateRorId
(
$form_state
[
'values'
][
'leader_institution_ror_id'
]))
form_set_error
(
'leader_institution_ror_id'
,
t
(
'Give a valid ROR ID (e.g. 021ft0n22) or leave field with \'unknown\'.'
));
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment