Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cfd_research_migration.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ cfd_research_migration.abstract_bulk_approval_form:
requirements:
_permission: 'Research Migration bulk manage abstract'
cfd_research_migration.edit_upload_abstract_code_form:
path: /research-migration-project/abstract-code/edit-upload-files
path: /research-migration-project/abstract-code/edit-upload-files/{proposal_id}
defaults:
_title: 'Research Migration Project Directory edit uploaded files for proposal'
_form: \Drupal\cfd_research_migration\Form\CfdResearchMigrationEditUploadAbstractCodeForm
Expand Down
37 changes: 22 additions & 15 deletions src/Form/CfdResearchMigrationEditUploadAbstractCodeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Drupal\Core\Link;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\r_case_study\Form\stdClass;

use Drupal\Core\Database\Database;

class CfdResearchMigrationEditUploadAbstractCodeForm extends FormBase {

Expand Down Expand Up @@ -69,7 +69,7 @@ public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $for
'#markup' => $proposal_data->contributor_name,
'#title' => t('Contributor Name'),
];
$existing_uploaded_A_file = default_value_for_uploaded_files("A", $proposal_data->id);
$existing_uploaded_A_file = \Drupal::service("cfd_research_migration_global")->default_value_for_uploaded_files("A", $proposal_data->id);
if (!$existing_uploaded_A_file) {
$existing_uploaded_A_file = new stdClass();
$existing_uploaded_A_file->filename = "No file uploaded";
Expand All @@ -78,9 +78,9 @@ public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $for
'#type' => 'file',
'#title' => t('Upload the Synopsis'),
//'#required' => TRUE,
'#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_A_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('resource_upload_extensions', '') . '</span>',
'#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_A_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . \Drupal::config('cfd_research_migration.settings')->get('resource_upload_extensions', '') . '</span>',
];
$existing_uploaded_S_file = default_value_for_uploaded_files("S", $proposal_data->id);
$existing_uploaded_S_file = \Drupal::service("cfd_research_migration_global")->default_value_for_uploaded_files("S", $proposal_data->id);
if (!$existing_uploaded_S_file) {
$existing_uploaded_S_file = new stdClass();
$existing_uploaded_S_file->filename = "No file uploaded";
Expand All @@ -89,22 +89,25 @@ public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $for
'#type' => 'file',
'#title' => t('Upload the Case Directory'),
//'#required' => TRUE,
'#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('research_migration_project_files_extensions', '') . '</span>',
'#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . \Drupal::config('cfd_research_migration.settings')->get('research_migration_project_files_extensions', '') . '</span>',
];
$form['prop_id'] = [
'#type' => 'hidden',
'#value' => $proposal_data->id,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
'#submit' => [
'cfd_research_migration_edit_upload_abstract_code_form_submit'
],
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
];


$form['cancel'] = [
'#type' => 'item',
// '#markup' => l(t('Cancel'), 'research-migration-project/manage-proposal/edit-upload-file'),
'#markup' => Link::fromTextAndUrl(
$this->t('Cancel'),
Url::fromUserInput('/research-migration-project/abstract-code/edit-upload-files'))->toString(),

];
return $form;
}
Expand Down Expand Up @@ -135,10 +138,10 @@ public function validateForm(array &$form, \Drupal\Core\Form\FormStateInterface
$allowed_extensions_str = '';
switch ($file_type) {
case 'A':
$allowed_extensions_str = variable_get('resource_upload_extensions', '');
$allowed_extensions_str = \Drupal::config('cfd_research_migration.settings')->get('resource_upload_extensions', '');
break;
case 'S':
$allowed_extensions_str = variable_get('research_migration_project_files_extensions', '');
$allowed_extensions_str = \Drupal::config('cfd_research_migration.settings')->get('research_migration_project_files_extensions', '');
break;
} //$file_type
/* checking file type */
Expand Down Expand Up @@ -171,7 +174,7 @@ public function validateForm(array &$form, \Drupal\Core\Form\FormStateInterface
public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
$user = \Drupal::currentUser();
$v = $form_state->getValues();
$root_path = cfd_research_migration_path();
$root_path = \Drupal::service("cfd_research_migration_global")->cfd_research_migration_path();
$query = \Drupal::database()->select('research_migration_proposal');
$query->fields('research_migration_proposal');
$query->condition('id', $v['prop_id']);
Expand Down Expand Up @@ -258,6 +261,10 @@ public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $f
// \Drupal::messenger()->addMessage('Error sending email message.', 'error');
// }
// drupal_goto('research -migration-project/abstract-code/edit-upload-files');
$form_state->setRedirect(
'cfd_research_migration.edit_upload_abstract_code_form',
['proposal_id' => $v['prop_id']]
);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/CfdResearchMigrationGlobalFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function cfd_research_migration_get_proposal() {
}


function default_value_for_uploaded_files($filetype, $proposal_id)
public function default_value_for_uploaded_files($filetype, $proposal_id)
{
$database = Database::getConnection();
$query = $database->select('research_migration_submitted_abstracts_file', 'rmsaf')
Expand Down