diff options
author | Jayaram R Pai | 2014-10-31 14:48:11 +0530 |
---|---|---|
committer | Jayaram R Pai | 2014-10-31 14:48:11 +0530 |
commit | 6ceb0fd9b7a9f8e85f5f4035d11c7112a42136f1 (patch) | |
tree | ad4122fe5a438aa5354646ce4604f818917f4965 | |
parent | 3db4a0509c98a24c9ffea7f152aa0769b2086699 (diff) | |
download | conference_proposal-6ceb0fd9b7a9f8e85f5f4035d11c7112a42136f1.tar.gz conference_proposal-6ceb0fd9b7a9f8e85f5f4035d11c7112a42136f1.tar.bz2 conference_proposal-6ceb0fd9b7a9f8e85f5f4035d11c7112a42136f1.zip |
fixed supported file warnings
-rwxr-xr-x[-rw-r--r--] | .gitignore | 0 | ||||
-rwxr-xr-x | conference_proposal.module | 71 |
2 files changed, 30 insertions, 41 deletions
diff --git a/.gitignore b/.gitignore index b72f9be..b72f9be 100644..100755 --- a/.gitignore +++ b/.gitignore diff --git a/conference_proposal.module b/conference_proposal.module index 3c7cf22..5c06e1a 100755 --- a/conference_proposal.module +++ b/conference_proposal.module @@ -127,7 +127,7 @@ "#title" => t("Title"), "#required" => TRUE, '#attributes' => array( - "placeholder" => "Please enter your title" + "placeholder" => "Please enter the title of your abstract" ) ); // $form["wrapper"]["abstract"] = array( @@ -175,14 +175,16 @@ } function conference_proposal_application_form_validate($form, &$form_state) { - $abstractfile = file_save_upload('abstract_file', array( + if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['contact'])) + form_set_error('contact', t('Invalid concat number')); + $abstractfile = file_save_upload('abstract_file', array( // Validate extensions. 'file_validate_extensions' => array('pdf'), )); // If the file passed validation: - if ($abstractfile) { + if (!empty($abstractfile->filename)) { // Move the file into the Drupal file system. if ($abstractfile = file_move($abstractfile, 'public://')) { @@ -207,7 +209,7 @@ 'file_validate_extensions' => array('zip'), )); // If the file passed validation: - if ($supportedfile) { + if (!empty($supportedfile->filename)) { // Move the file into the Drupal file system. if ($supportedfile = file_move($supportedfile, 'public://')) { // Save the file for use in the submit handler. @@ -218,7 +220,7 @@ } } else { - form_set_error('supported_file', t('No file was uploaded.')); + // form_set_error('supported_file', t('No file was uploaded.')); } } @@ -226,7 +228,10 @@ $v = $form_state["values"]; $abstract_file = $form_state["storage"]["abstract_file"]; - $supported_file = $form_state["storage"]["supported_file"]; + if(isset($supported_file)) { + $supported_file = $form_state["storage"]["supported_file"]; + } + $query = " INSERT INTO proposal_applications (first_name, last_name, contributer, contact, email, title, bio, link, proposal_file, supported_file, proposal_id, uid) @@ -245,55 +250,38 @@ ":bio" => $v["bio"], ":link" => $v["link"], ":abstract_file" => $abstract_file->filename, - ":supported_file" => $supported_file->filename, + ":supported_file" => isset($supported_file) ? $supported_file->filename : 'None', ":proposal_id" => $v["proposal_id"], ":user_id" => $v["user_id"], ); /* storing the row id in $result */ $result = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID)); - dpm($result); - - /* moving the file to uploads */ + /* moving the file to uploads */ $base_path = $_SERVER['DOCUMENT_ROOT'] . base_path(); $uploads_dir = $base_path . "uploads/proposal_file"; if(!file_exists($uploads_dir . "/{$result}/")) { mkdir($uploads_dir . "/{$result}/", 0755, TRUE); } - - - // $from = "abstarct@scilab.in"; - // $to = $v["email"]; - // // $cc = $emails; - // $bcc = "rush2jrp@gmail.com"; - // $subject = "Test Mail"; - // $message = " - - // <p><em>Please check the abstract to this mail.</em></p> - // "; - // $file = $uploads_dir . "/{$result}/" . $abstract_file->filename; - // dpm($file); - // $mail_status = send_mail_attachment($from, $to, "", $bcc, $subject, $message, $file); - // if(!$mail_status) { - // drupal_set_message("An error occurred while sending mail.", "error"); - // } else { - // drupal_set_message("We have received your application. Thank you!", "status"); - // } - - file_unmanaged_move($abstract_file->uri, $uploads_dir . "/{$result}/{$abstract_file->filename}"); - drupal_set_message("Abstract Uploaded Succesfully"); - file_unmanaged_move($supported_file->uri, $uploads_dir . "/{$result}/{$supported_file->filename}"); - drupal_set_message("Supported files Uploaded Succesfully"); + + if($abstract_file->filename){ + file_unmanaged_move($abstract_file->uri, $uploads_dir . "/{$result}/{$abstract_file->filename}"); + file_delete($abstract_file); + drupal_set_message("Abstract Uploaded Succesfully"); + } + if(isset($supported_file)) { + file_unmanaged_move($supported_file->uri, $uploads_dir . "/{$result}/{$supported_file->filename}"); + file_delete($supported_file); + drupal_set_message("Supported files Uploaded Succesfully"); + } /* cleaning up temporary storage */ - file_delete($abstract_file); unset($form["storage"]["abstract_file"]); - file_delete($supported_file); unset($form["storage"]["supported_file"]); drupal_set_message("Thank you for submitting your abstract"); /* sending notification to the applicant */ - $subject = "Abstract received"; + $subject = " {$v['title']} - Abstract received"; $message = " Dear {$v['fname']}, @@ -301,9 +289,9 @@ We will get back to you shortly. Regards, - FOSSEE Team + Scilab Team "; - send_mail("contact@fossee.in", $v["email"], $subject, $message); + send_mail("conference@scilab.in", $v["email"], $subject, $message); } @@ -473,7 +461,7 @@ $query = " UPDATE proposal_applications SET selected = !selected - WHERE id = aid + WHERE id = :aid "; $args = array( ":aid" => $key @@ -539,7 +527,8 @@ 'From' => $from, 'Sender' => $from, 'Return-Path' => $from, - 'Bcc' => 'prashantsinalkar@gmail.com', + 'cc' =>'conference@scilab.in', + 'Bcc' => 'prashantsinalkar@gmail.com , priyankabhagwat085@gmail.com', ), ); $system = drupal_mail_system($my_module, $my_mail_token); |