array( "title" => t("Access proposal Portal"), "description" => t("Allows users to view proposal postings.") ), "manage conference_proposal" => array( "title" => t("Manage proposal Portal"), "description" => t("Allows users to manage proposal postings.") ), "manage download_application" => array( "title" => t("Manage Download Portal"), "description" => t("Allows users to download proposal applications.") ), ); } function conference_proposal_menu() { $items = array(); $items["conference_proposal"] = array( "title" => "Abstracts", "page callback" => "conference_proposal_page", "access arguments" => array("access conference_proposal"), "type" => MENU_NORMAL_ITEM, ); $items["conference_proposal/apply"] = array( "title" => "Abstract Submission Form", "page callback" => "conference_proposal_application_page", "access arguments" => array("access conference_proposal"), "type" => MENU_CALLBACK, ); // $items["conference_proposal/edit"] = array( // "title" => "Edit Proposals form", // "page callback" => "conference_proposal_application_edit_page", // "access arguments" => array("access conference_proposal"), // "type" => MENU_CALLBACK, // ); $items["conference_proposal/view-applications"] = array( "title" => "View Applications", "page callback" => "conference_proposal_view_application_page", "access arguments" => array("manage conference_proposal"), "type" => MENU_CALLBACK, ); // $items["conference_proposal/Edit-proposals"] = array( // "title" => "Edit Proposals", // "page callback" => "edit_conference_proposal_page", // "access arguments" => array("access conference_proposal"), // "type" => MENU_CALLBACK // ); // $items["conference_proposal/downloads_proposals"] = array( // "title" => "Application Download", // "description" => "Applications Download", // "page callback" => "proposals_downloads_page", // "access arguments" => array("access proposal_portal"), // "type" => MENU_CALLBACK // ); $items["conference_proposal/ajax"] = array( "title" => "Ajax callbacks", "page callback" => "conference_proposal_ajax", "access arguments" => array("access conference_proposal"), "type" => MENU_CALLBACK ); return $items; } function conference_proposal_application_form($form, &$form_state, $proposal_id = 0) { global $user; $form = array(); $form["wrapper"] = array( "#type" => "lable", "#title" => t("Form"), ); $form["wrapper"]["fname"] = array( "#type" => "textfield", "#title" => t("First Name"), "#required" => TRUE, '#attributes' => array( "placeholder" => "Please enter your first name" ) ); $form["wrapper"]["lname"] = array( "#type" => "textfield", "#title" => t("Last Name"), "#required" => TRUE, '#attributes' => array( "placeholder" => "Please enter your last name" ) ); $form["wrapper"]["contributer"] = array( "#type" => "textfield", "#title" => t("Any Contributer"), '#attributes' => array( "placeholder" => "Please enter contributers name" ) ); $form["wrapper"]["contact"] = array( "#type" => "textfield", "#title" => t("Contact"), "#required" => TRUE, '#attributes' => array( "placeholder" => "Please enter your contact number" ) ); $form["wrapper"]["email"] = array( "#type" => "textfield", "#title" => t("Email"), "#required" => TRUE, '#default_value' => $user->mail, '#attributes' => array( "placeholder" => "Please enter your email" ) ); $form["wrapper"]["proposal_id"] = array( '#type' => 'select', '#title' => t('Proposal Type'), '#options' => get_conference_proposal_available("options"), //'#description' => t(' you like to do'), '#attributes' => array('disabled' => 'disabled'), '#default_value' => $proposal_id, ); $form["wrapper"]["title"] = array( "#type" => "textfield", "#title" => t("Title"), "#required" => TRUE, '#attributes' => array( "placeholder" => "Please enter your abstract title" ) ); // $form["wrapper"]["abstract"] = array( // "#type" => "textarea", // "#title" => t("Abstract"), // "#required" => TRUE, // '#attributes' => array( // "placeholder" => "Please enter your abstract" // ) // ); $form["wrapper"]["bio"] = array( "#type" => "textarea", "#title" => t("Bio"), "#required" => TRUE, '#attributes' => array( "placeholder" => "Please enter your short bio" ) ); $form["wrapper"]["link"] = array( "#type" => "textfield", "#title" => t("Link"), '#attributes' => array( "placeholder" => "Please enter proposal related link" ) ); $form["wrapper"]["abstract_file"] = array( "#type" => "file", "#title" => t("Abstract File" . required_star()), "#description" => t("Please upload your abstract file in [.pdf] format"), ); $form["wrapper"]["supported_file"] = array( "#type" => "file", "#title" => t("Supporting File"), "#description" => t("Please upload your suporting file in [.zip] format"), ); $form["wrapper"]["user_id"] = array( "#type" => "hidden", "#default_value" => $user->uid, ); $form["wrapper"]["submit"] = array( "#type" => "submit", "#value" => "Submit Abstract" ); return $form; } function conference_proposal_application_form_validate($form, &$form_state) { 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) { // Move the file into the Drupal file system. if ($abstractfile = file_move($abstractfile, 'public://')) { // Save the file for use in the submit handler. $form_state['storage']['abstract_file'] = $abstractfile; } else { form_set_error('abstract_file', t("Failed to uploaded file to the site's file folder.")); } } else { form_set_error('abstract_file', t('No file was uploaded.')); } /* validating email field */ if(!valid_email_address($form_state["values"]["email"])) { form_set_error('email', t('Please enter an valid email address.')); } $supportedfile = file_save_upload('supported_file', array( // Validate extensions. 'file_validate_extensions' => array('zip'), )); // If the file passed validation: if ($supportedfile) { // Move the file into the Drupal file system. if ($supportedfile = file_move($supportedfile, 'public://')) { // Save the file for use in the submit handler. $form_state['storage']['supported_file'] = $supportedfile; } else { form_set_error('supported_file', t("Failed to uploaded file to the site's file folder.")); } } // else { // form_set_error('supported_file', t('No file was uploaded.')); // } } function conference_proposal_application_form_submit($form, &$form_state) { $v = $form_state["values"]; $abstract_file = $form_state["storage"]["abstract_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) VALUES (:fname, :lname, :contributer, :contact, :email, :title, :bio, :link, :abstract_file, :supported_file, :proposal_id, :user_id) "; $args = array( ":fname" => $v["fname"], ":lname" => $v["lname"], ":contact" => $v["contact"], ":contributer" => $v["contributer"], ":email" => $v["email"], ":title" => $v["title"], //":abstract" => $v["abstract"], ":bio" => $v["bio"], ":link" => $v["link"], ":abstract_file" => $abstract_file->filename, ":supported_file" => $supported_file->filename, ":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 */ $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 = " //
Please check the abstract to this mail.
// "; // $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"); /* 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 = " {$v['title']} -Abstract received"; $message = " Dear {$v['fname']}, We have received your abstract We will get back to you shortly. Regards, FOSSEE Team "; // send_mail("conference@scilab.in", $v["email"], $subject, $message); } function conference_proposal_page(){ $output = ""; $i = 1; $result = get_conference_proposal_available(); foreach($result as $row) { $output .= " Proposal: {$row->proposal_name}