|
@@ -11,9 +11,10 @@
|
|
|
*
|
|
|
*/
|
|
|
function tripal_registration_form($form, &$form_state) {
|
|
|
- dpm($form_state);
|
|
|
- $form_state['storage']['participants'] =
|
|
|
- isset($form_state['storage']['details']['funding']) ? $form_state['storage']['details']['funding'] : 0;
|
|
|
+ $form_data = unserialize(variable_get('tripal_site_registration', NULL));
|
|
|
+
|
|
|
+ $form_state['details']['funding'] =
|
|
|
+ isset($form_state['details']['funding']) ? $form_state['details']['funding'] : 1;
|
|
|
|
|
|
$form['description'] = array(
|
|
|
'#markup' => t('Registering your Tripal site is important. When you
|
|
@@ -22,10 +23,10 @@ function tripal_registration_form($form, &$form_state) {
|
|
|
into usage so we can build features the community needs. </br></br>'),
|
|
|
);
|
|
|
|
|
|
- $form['disable'] = array(
|
|
|
+ $form['disable_tripal_reporting'] = array(
|
|
|
'#type' => 'checkbox',
|
|
|
'#title' => t('Disable registration reminder'),
|
|
|
- '#default_value' => FALSE,
|
|
|
+ '#default_value' => isset($form_data['input']['disable_tripal_reporting']) ? $form_data['input']['disable_tripal_reporting'] : NULL,
|
|
|
'#description' => "If you do not want to register your site please check
|
|
|
this box as it will stop the reminder notifications.",
|
|
|
);
|
|
@@ -33,43 +34,48 @@ function tripal_registration_form($form, &$form_state) {
|
|
|
$form['details']['principal_investigator'] = array(
|
|
|
'#type' => 'fieldset',
|
|
|
'#title' => t('Principal Investigator Contact Information'),
|
|
|
- '#collapsible' => true,
|
|
|
- '#collapsed' => false,
|
|
|
+ '#collapsible' => TRUE,
|
|
|
+ '#collapsed' => FALSE,
|
|
|
);
|
|
|
|
|
|
- $form['details']['principal_investigator']['name'] = array(
|
|
|
+ $form['details']['principal_investigator']['principal_investigator_name'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Name'),
|
|
|
+ '#default_value' => isset($form_data['input']['principal_investigator_name']) ? $form_data['input']['principal_investigator_name'] : NULL,
|
|
|
'#required' => TRUE,
|
|
|
);
|
|
|
|
|
|
- $form['details']['principal_investigator']['email'] = array(
|
|
|
+ $form['details']['principal_investigator']['principal_investigator_email'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Email'),
|
|
|
+ '#default_value' => isset($form_data['input']['principal_investigator_email']) ? $form_data['input']['principal_investigator_email'] : NULL,
|
|
|
'#required' => TRUE,
|
|
|
);
|
|
|
- $form['details']['site_admin'] = array(
|
|
|
+ $form['details']['tripal_reg_site_admin'] = array(
|
|
|
'#type' => 'fieldset',
|
|
|
'#title' => t('Site Administrator (if different from the principal investigator)'),
|
|
|
- '#collapsible' => true,
|
|
|
- '#collapsed' => false,
|
|
|
+ '#collapsible' => TRUE,
|
|
|
+ '#collapsed' => FALSE,
|
|
|
);
|
|
|
|
|
|
- $form['details']['site_admin']['name'] = array(
|
|
|
+ $form['details']['tripal_reg_site_admin']['tripal_reg_site_admin_name'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Name'),
|
|
|
+ '#default_value' => isset($form_data['input']['tripal_reg_site_admin_name']) ? $form_data['input']['tripal_reg_site_admin_name'] : NULL,
|
|
|
'#required' => FALSE,
|
|
|
);
|
|
|
|
|
|
- $form['details']['site_admin']['email'] = array(
|
|
|
+ $form['details']['tripal_reg_site_admin']['tripal_reg_site_admin_email'] = array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Email'),
|
|
|
+ '#default_value' => isset($form_data['input']['tripal_reg_site_admin_email']) ? $form_data['input']['tripal_reg_site_admin_email'] : NULL,
|
|
|
'#required' => FALSE,
|
|
|
);
|
|
|
|
|
|
- $form['details']['description']= array(
|
|
|
+ $form['details']['tripal_reg_site_description']= array(
|
|
|
'#type' => 'textarea',
|
|
|
'#title' => t('Description of the site'),
|
|
|
+ '#default_value' => isset($form_data['input']['tripal_reg_site_description']) ? $form_data['input']['tripal_reg_site_description'] : NULL,
|
|
|
'#required' => FALSE,
|
|
|
);
|
|
|
|
|
@@ -79,29 +85,50 @@ function tripal_registration_form($form, &$form_state) {
|
|
|
'#prefix' => '<div id="funding">',
|
|
|
'#suffix' => '</div>',
|
|
|
);
|
|
|
-
|
|
|
- for ($i = 1; $i <= $form_state['storage']['details']['funding']; $i++) {
|
|
|
- $form['details']['funding'][$i] = array(
|
|
|
- '#type' => 'fieldset',
|
|
|
- '#tree' => true,
|
|
|
- );
|
|
|
-
|
|
|
- $form['details']['funding'][$i]['agency'] = array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Agency'),
|
|
|
- );
|
|
|
-
|
|
|
- $form['details']['funding'][$i]['grant'] = array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Grant Number'),
|
|
|
- );
|
|
|
-
|
|
|
- $form['details']['funding'][$i]['funding_period'] = array(
|
|
|
- '#type' => 'textfield',
|
|
|
- '#title' => t('Funding Period'),
|
|
|
- );
|
|
|
|
|
|
- }
|
|
|
+ $count = count($form_data['input']['funding']);
|
|
|
+ $form_state['details']['funding'] = $form_state['details']['funding'] + $count;
|
|
|
+ for ($i = 1; $i <= $form_state['details']['funding']; $i++) {
|
|
|
+ $form['details']['funding'][$i] = array(
|
|
|
+ '#type' => 'fieldset',
|
|
|
+ '#title' => t("Funding Period $i"),
|
|
|
+ '#tree' => TRUE,
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['details']['funding'][$i]['tripal_reg_site_agency'] = array(
|
|
|
+ '#type' => 'textfield',
|
|
|
+ '#default_value' => isset($form_data['input']['funding'][$i]['tripal_reg_site_agency']) ? $form_data['input']['funding'][$i]['tripal_reg_site_agency'] : NULL,
|
|
|
+ '#title' => t('Agency'),
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['details']['funding'][$i]['tripal_reg_site_grant'] = array(
|
|
|
+ '#type' => 'textfield',
|
|
|
+ '#default_value' => isset($form_data['input']['funding'][$i]['tripal_reg_site_grant']) ? $form_data['input']['funding'][$i]['tripal_reg_site_grant'] : NULL,
|
|
|
+ '#title' => t('Grant Number'),
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['details']['funding'][$i]['funding_period'] = array(
|
|
|
+ '#type' => 'fieldset',
|
|
|
+ '#title' => t('Funding Period'),
|
|
|
+ '#tree' => TRUE,
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['details']['funding'][$i]['funding_period']['tripal_reg_site_start'] = array(
|
|
|
+ '#type' => 'date_select',
|
|
|
+ '#title' => t("Start"),
|
|
|
+ '#default_value' => isset($form_data['input']['funding'][$i]['funding_period']['tripal_reg_site_start']) ? $form_data['input']['funding'][$i]['funding_period']['tripal_reg_site_start'] : date('Y', time()),
|
|
|
+ '#date_year_range' => '-20:+20',
|
|
|
+ '#date_format' => 'Y',
|
|
|
+ );
|
|
|
+
|
|
|
+ $form['details']['funding'][$i]['funding_period']['tripal_reg_site_end'] = array(
|
|
|
+ '#type' => 'date_select',
|
|
|
+ '#title' => t('End'),
|
|
|
+ '#default_value' => isset($form_data['input']['funding'][$i]['funding_period']['tripal_reg_site_end']) ? $form_data['input']['funding'][$i]['funding_period']['tripal_reg_site_end'] : date('Y', time()),
|
|
|
+ '#date_year_range' => '-20:+20',
|
|
|
+ '#date_format' => 'Y',
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
$form['details']['funding']['add_funding'] = array(
|
|
|
'#type' => 'button',
|
|
@@ -114,29 +141,124 @@ function tripal_registration_form($form, &$form_state) {
|
|
|
);
|
|
|
|
|
|
$purpose = array(0 => t('Production'), 1 => t('Development'));
|
|
|
- $form['details']['purpose'] = array(
|
|
|
+ $form['details']['tripal_reg_site_purpose'] = array(
|
|
|
'#type' => 'radios',
|
|
|
'#title' => t('Purpose of site'),
|
|
|
- '#default_value' => isset($node->purpose) ? $node->purpose : 1,
|
|
|
+ '#default_value' => isset($form_data['input']['tripal_reg_site_purpose']) ? $form_data['input']['tripal_reg_site_purpose'] : NULL,
|
|
|
'#options' => $purpose,
|
|
|
'#required' => TRUE,
|
|
|
);
|
|
|
|
|
|
- $form['details']['modules'] = array(
|
|
|
+ $form['details']['tripal_reg_site_modules'] = array(
|
|
|
'#type' => 'checkbox',
|
|
|
+ '#default_value' => isset($form_data['input']['tripal_reg_site_modules']) ? $form_data['input']['tripal_reg_site_modules'] : NULL,
|
|
|
'#title' => t('Provide Tripal (not other 3rd party modules) module usage information.'),
|
|
|
);
|
|
|
+ $form_state['details']['funding']++;
|
|
|
+
|
|
|
+ // Provide a submit button.
|
|
|
+ if (!empty($form_data)) {
|
|
|
+ $form['submit'] = array(
|
|
|
+ '#type' => 'submit',
|
|
|
+ '#value' => 'Update registeration information',
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $form['submit'] = array(
|
|
|
+ '#type' => 'submit',
|
|
|
+ '#value' => 'Register Site',
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- $form['submit'] = array(
|
|
|
- '#type' => 'submit',
|
|
|
- '#value' => t('Submit'),
|
|
|
- );
|
|
|
- $form_state['storage']['details']['funding']++;
|
|
|
return $form;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
function custom_registration_ajax_add_funding($form, $form_state) {
|
|
|
+ // Get current list of modules.
|
|
|
+ $files = system_rebuild_module_data();
|
|
|
+
|
|
|
+ // Remove hidden modules from display list.
|
|
|
+ $visible_files = $files;
|
|
|
+ foreach ($visible_files as $filename => $file) {
|
|
|
+ if (!empty($file->info['hidden'])) {
|
|
|
+ unset($visible_files[$filename]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ uasort($visible_files, 'system_sort_modules_by_info_name');
|
|
|
+
|
|
|
+ // Iterate through each of the modules.
|
|
|
+ foreach ($visible_files as $filename => $module) {
|
|
|
+ $extra = array();
|
|
|
+ $extra['enabled'] = (bool)$module->status;
|
|
|
+ dpm($module);
|
|
|
+ }
|
|
|
+
|
|
|
return $form['details']['funding'];
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements validation from the Form API.
|
|
|
+ *
|
|
|
+ * @param $form
|
|
|
+ * A structured array containing the elements and properties of the form.
|
|
|
+ * @param $form_state
|
|
|
+ * An array that stores information about the form's current state
|
|
|
+ * during processing.
|
|
|
+ */
|
|
|
+function tripal_registration_form_validate($form, &$form_state){
|
|
|
+ $mail_pi = $form_state['values']['principal_investigator_email'];
|
|
|
+ $mail_sa = $form_state['values']['tripal_reg_site_admin_email'];
|
|
|
+ if (!valid_email_address($mail_pi)) {
|
|
|
+ form_set_error('[details][principal_investigator][principal_investigator_email]', t('The email address for the principal investigator appears to be invalid.'));
|
|
|
+ }
|
|
|
+ if (!valid_email_address($mail_sa) && !empty($mail_sa)) {
|
|
|
+ form_set_error('[details][site_admin][tripal_reg_site_admin_email]', t("The email address for the site administrator appears to be invalid."));
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements submit from the Form API.
|
|
|
+ *
|
|
|
+ * @param $form
|
|
|
+ * A structured array containing the elements and properties of the form.
|
|
|
+ * @param $form_state
|
|
|
+ * An array that stores information about the form's current state
|
|
|
+ * during processing.
|
|
|
+ */
|
|
|
+function tripal_registration_form_submit($form, &$form_state) {
|
|
|
+ $registration = serialize($form_state);
|
|
|
+ variable_set('tripal_site_registration', $registration);
|
|
|
+ //Now send the updated info to the Tripal Site.
|
|
|
+ tripal_registration_remote_submit($registration);
|
|
|
+}
|
|
|
+
|
|
|
+function tripal_registration_remote_submit($data) {
|
|
|
+ $endpoint = 'endpoint';
|
|
|
+ //Are we getting the modules?
|
|
|
+ $form_data = unserialize($data);
|
|
|
+ if ($form_data['input']['tripal_reg_site_modules']) {
|
|
|
+ // Get current list of modules.
|
|
|
+ $files = system_rebuild_module_data();
|
|
|
+
|
|
|
+ // Remove hidden modules from display list.
|
|
|
+ $visible_files = $files;
|
|
|
+ foreach ($visible_files as $filename => $file) {
|
|
|
+ if (!empty($file->info['hidden'])) {
|
|
|
+ unset($visible_files[$filename]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ uasort($visible_files, 'system_sort_modules_by_info_name');
|
|
|
+
|
|
|
+ // Iterate through each of the modules.
|
|
|
+ foreach ($visible_files as $filename => $module) {
|
|
|
+ $extra = array();
|
|
|
+ $extra['enabled'] = (bool)$module->status;
|
|
|
+ if (!empty($module->info['required'])) {
|
|
|
+ $extra['disabled'] = true;
|
|
|
+ $extra['required_by'][] = $distribution_name . (!empty($module->info['explanation']) ? ' (' . $module->info['explanation'] . ')' : '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|