@@ -32,6 +32,11 @@ function scratchpads_gbif_registry_client_admin_settings()
3232
3333 $ nonBio = !variable_get ('biological_vids ' );
3434
35+ $ default_description = implode (' | ' , array_filter ([
36+ variable_get ('site_slogan ' , '' ),
37+ strip_tags (variable_get ('front_page_welcome_message ' , ['value ' =>'' ])['value ' ])
38+ ]));
39+
3540 $ form += array (
3641 'scratchpads_gbif_registry_client_registration_enabled ' => array (
3742 '#type ' => 'checkbox ' ,
@@ -40,6 +45,12 @@ function scratchpads_gbif_registry_client_admin_settings()
4045 '#description ' => t ("Whether to register this scratchpad with GBIF. " ),
4146 '#disabled ' => $ nonBio
4247 ),
48+ 'scratchpads_gbif_registry_client_description ' => array (
49+ '#type ' => 'textarea ' ,
50+ '#title ' => t ('Dataset description ' ),
51+ '#default_value ' => variable_get ('scratchpads_gbif_registry_client_description ' , $ default_description ),
52+ '#description ' => t ('A summary of the dataset. This will appear on the GBIF web page for your dataset and in GBIF search results. ' )
53+ ),
4354 'scratchpads_gbif_registry_client_registration_licence ' => array (
4455 '#type ' => 'select ' ,
4556 '#options ' => $ licence_options ,
@@ -61,18 +72,43 @@ function scratchpads_gbif_registry_client_admin_settings()
6172 }
6273
6374 $ form ['#submit ' ][] = 'scratchpads_gbif_registry_client_admin_settings_form_submit ' ;
75+ $ form ['#validate ' ][] = 'scratchpads_gbif_registry_client_admin_settings_form_validate ' ;
6476
6577 // use the system_settings_form function so that we don't have to implement our own submit function
6678 return system_settings_form ($ form );
6779}
6880
81+ /**
82+ * Validation handler for settings form
83+ */
84+ function scratchpads_gbif_registry_client_admin_settings_form_validate ($ form , &$ form_state ) {
85+ $ enabled = $ form_state ['values ' ]['scratchpads_gbif_registry_client_registration_enabled ' ];
86+ $ description = $ form_state ['values ' ]['scratchpads_gbif_registry_client_description ' ];
87+
88+ if ($ enabled && !$ description ) {
89+ form_set_error ('scratchpads_gbif_registry_client_description ' , t ('You must proide a description to submit your dataset to GBIF. ' ));
90+ }
91+ }
92+
6993/**
7094 * Submit handler for the scratchpads_gbif_registry_client_admin_settings form.
7195 */
7296function scratchpads_gbif_registry_client_admin_settings_form_submit ($ form , &$ form_state )
7397{
7498 variable_del ('scratchpads_gbif_registry_client_last_update ' );
7599
100+ $ new_desc = $ form_state ['values ' ]['scratchpads_gbif_registry_client_description ' ];
101+
102+ if ($ form ['scratchpads_gbif_registry_client_description ' ]['#default_value ' ] !== $ new_desc ) {
103+ $ uuid = variable_get ('scratchpads_gbif_registry_client_uuid ' , false );
104+ if ($ uuid ) {
105+ GBIFRegistry::singleton ();
106+ $ dataset = new GBIF \Dataset ($ uuid );
107+ $ dataset ->setDescription ($ new_desc );
108+ $ dataset ->save ();
109+ }
110+ }
111+
76112 if (module_exists ('dwcarchiver ' )) {
77113 dwcarchiver_rebuild ('gbif-dwca ' , false );
78114 menu_rebuild ();
0 commit comments