summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xarduino_projects_blog.info6
-rwxr-xr-xarduino_projects_blog.module712
-rwxr-xr-xdownload.inc102
-rwxr-xr-xemail.inc361
-rwxr-xr-xgeneral_deletion.inc48
-rwxr-xr-xmanage_proposal.inc1006
-rw-r--r--my_proposals.inc565
-rwxr-xr-xproposal.inc663
-rwxr-xr-xsettings.inc58
9 files changed, 3521 insertions, 0 deletions
diff --git a/arduino_projects_blog.info b/arduino_projects_blog.info
new file mode 100755
index 0000000..0515d16
--- /dev/null
+++ b/arduino_projects_blog.info
@@ -0,0 +1,6 @@
+name = Arduino Projects Blog
+description = Module to accept Arduino projects
+package = IITB
+version = 7.1
+core = 7.x
+
diff --git a/arduino_projects_blog.module b/arduino_projects_blog.module
new file mode 100755
index 0000000..76acdb1
--- /dev/null
+++ b/arduino_projects_blog.module
@@ -0,0 +1,712 @@
+<?php
+// $Id$
+/*error_reporting(E_ALL);
+ini_set('display_errors', TRUE);
+ini_set('display_startup_errors', TRUE);*/
+require_once('general_deletion.inc');
+require_once('email.inc');
+/**
+ * Implementation of hook_menu().
+ */
+function arduino_projects_blog_menu()
+{
+ $items = array();
+ /* PROPOSAL */
+ $items['arduino-projects/proposal'] = array(
+ 'title' => 'Arduino Projects Proposal Form',
+ 'description' => 'Arduino Projects Proposal Form',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects create proposal'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'proposal.inc'
+ );
+ $items['arduino-projects/my-proposals'] = array(
+ 'title' => 'My Arduino Projects Proposals',
+ 'description' => 'My Arduino Projects Proposals',
+ 'page callback' => 'arduino_projects_blog_my_proposal',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'arduino projects display own proposal'
+ ),
+ 'file' => 'proposal.inc'
+ );
+ $items['arduino-projects/my-proposals/edit'] = array(
+ 'title' => 'Edit My Proposal',
+ 'description' => 'Edit My Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_my_proposal_edit_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects edit own proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'my_proposals.inc'
+ );
+ $items['arduino-projects/my-proposals/view'] = array(
+ 'title' => 'View My Proposal',
+ 'description' => 'View My Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_my_proposal_view_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects view own proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'my_proposals.inc'
+ );
+ $items['arduino-projects/manage-proposal'] = array(
+ 'title' => 'Manage Arduino Projects Proposals',
+ 'description' => 'Manage Arduino Projects Proposals',
+ 'page callback' => 'arduino_projects_blog_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'arduino projects manage proposal'
+ ),
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['arduino-projects/manage-proposal/pending'] = array(
+ 'title' => 'Pending Proposals',
+ 'description' => 'Pending arduino projects Proposals Queue',
+ 'page callback' => 'arduino_projects_blog_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'arduino projects manage proposal'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['arduino-projects/manage-proposal/all'] = array(
+ 'title' => 'All Proposals',
+ 'description' => 'All Proposals',
+ 'page callback' => 'arduino_projects_blog_proposal_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'arduino projects manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['arduino-projects/manage-proposal/approve'] = array(
+ 'title' => 'Proposal Approval Form',
+ 'description' => 'Proposal Approval Form',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['arduino-projects/manage-proposal/edit'] = array(
+ 'title' => 'Edit Proposal',
+ 'description' => 'Edit Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_proposal_edit_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects edit proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['arduino-projects/manage-proposal/status'] = array(
+ 'title' => 'Proposal Status',
+ 'description' => 'Proposal Status',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_proposal_status_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects approve proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['arduino-projects/abstract-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_abstract_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects bulk manage abstract'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'abstract_bulk_approval.inc'
+ );
+ /* CODE UPLOAD */
+ $items['arduino-projects/abstract-code'] = array(
+ 'title' => 'Abstract and Arduino Projects Submission',
+ 'description' => 'Abstract Submission',
+ 'page callback' => 'arduino_projects_blog_abstract',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'arduino projects upload code'
+ ),
+ 'file' => 'upload_code.inc'
+ );
+ $items['arduino-projects/abstract-code/upload'] = array(
+ 'title' => 'Abstract and Arduino Projects Submission',
+ 'description' => 'Abstract Submission',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_upload_abstract_code_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects upload code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 2
+ );
+ /* CODE DOWNLOADS */
+ $items['arduino-projects/download/reference-images'] = array(
+ 'title' => 'Download Reference Images',
+ 'description' => 'Download Reference Images',
+ 'page callback' => 'arduino_projects_blog_download_reference_images',
+ 'access arguments' => array(
+ 'arduino projects download reference images'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['arduino-projects/download/abstract-file'] = array(
+ 'title' => 'Download abstract file',
+ 'description' => 'Download abstract file',
+ 'page callback' => 'arduino_projects_blog_project_files',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['arduino-projects/download/file'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'arduino_projects_blog_download_solution_file',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['arduino-projects/full-download/project'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'arduino_projects_blog_download_full_project',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ /* COMPLETED arduino projectsS */
+ $items['arduino-projects/completed-pssp'] = array(
+ 'title' => 'Completed Arduino Projectss',
+ 'page callback' => 'arduino_projects_blog_completed_proposals_all',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'file' => 'pssp_details.inc'
+ );
+ /* LABS IN PROGRESS */
+ $items['arduino-projects/pssp-progress'] = array(
+ 'title' => 'Arduino Projectss in Progress',
+ 'page callback' => 'arduino_projects_blog_progress_all',
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'file' => 'pssp_details.inc'
+ );
+ /* DOWNLOAD FOR EVERYONE */
+ $items['arduino-projects/arduino-projects-run'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_run_form'
+ ),
+ 'access arguments' => array(
+ 'arduino projects download code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc'
+ );
+ /* ADMIN SETTINGS */
+ $items['admin/settings/arduino-projects'] = array(
+ 'title' => 'Arduino Projects Settings',
+ 'description' => 'Arduino Projects Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'arduino_projects_blog_settings_form'
+ ),
+ 'access arguments' => array(
+ 'administer arduino projects'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'settings.inc'
+ );
+ /* AJAX REQUEST */
+ $items['arduino-projects/certificates'] = array(
+ 'title' => 'List of Arduino Projects Certificates',
+ 'description' => 'List of Arduino Projects Certificates',
+ 'page callback' => '_list_pssp_certificates',
+ 'access arguments' => array(
+ 'list Arduino Projects certificates'
+ ),
+ 'file' => 'pdf/list_pssp_certificate.inc'
+ );
+ $items['arduino-projects/certificates/generate-pdf'] = array(
+ 'title' => 'Download Certificate',
+ 'description' => 'Download Certificate',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'generate_pdf'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'access arguments' => array(
+ 'generate pdf'
+ ),
+ 'file' => 'pdf/cert_new.inc'
+ );
+ $items['arduino-projects/certificates-custom'] = array(
+ 'title' => 'List of Arduino Projects Custom Certificates',
+ 'description' => 'List of Arduino Projects Custom Certificates',
+ 'page callback' => '_list_pssp_custom_certificates',
+ 'access arguments' => array(
+ 'list Arduino Projects custom certificates'
+ ),
+ 'file' => 'pdf/list_mentor_certificates.inc'
+ );
+ $items['arduino-projects/certificates-custom/pdf'] = array(
+ 'title' => 'Download Certificate',
+ 'description' => 'Download Certificate',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'generate_pdf'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'access arguments' => array(
+ 'generate pdf'
+ ),
+ 'file' => 'pdf/mentor_cert_pdf.inc'
+ );
+ $items["arduino-projects/certificates/verify"] = array(
+ "title" => "Certificate Verification",
+ "page callback" => "verify_certificates",
+ "access arguments" => array(
+ "verify certificates"
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'pdf/verify_certificates.inc'
+ );
+ return $items;
+}
+/**
+ * Implementation of hook_perm().
+ */
+function arduino_projects_blog_permission()
+{
+ return array(
+ 'arduino projects create proposal' => array(
+ 'title' => t('arduino projects create proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects display own proposal' => array(
+ 'title' => t('arduino projects display own proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects manage proposal' => array(
+ 'title' => t('arduino projects manage proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects edit proposal' => array(
+ 'title' => t('arduino projects edit proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects edit own proposal' => array(
+ 'title' => t('arduino projects edit own proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects view own proposal' => array(
+ 'title' => t('arduino projects view own proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects approve proposal' => array(
+ 'title' => t('arduino projects approve proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects propose solution' => array(
+ 'title' => t('arduino projects propose solution'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects approve abstract' => array(
+ 'title' => t('arduino projects approve code'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects bulk manage abstract' => array(
+ 'title' => t('arduino projects bulk manage abstract'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects bulk delete code' => array(
+ 'title' => t('arduino projects bulk delete code'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects upload code' => array(
+ 'title' => t('arduino projects upload code'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects download code' => array(
+ 'title' => t('arduino projects download code'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects download reference images' => array(
+ 'title' => t('arduino projects download reference images'),
+ 'restrict access' =>TRUE
+ ),
+ 'administer arduino projects' => array(
+ 'title' => t('administer arduino projects'),
+ 'restrict access' => TRUE
+ ),
+ 'arduino projects generate abstract' => array(
+ 'title' => t('arduino projects generate abstract'),
+ 'restrict access' => TRUE
+ ),
+ "list Arduino Projects certificates" => array(
+ "title" => t("list Arduino Projects certificates"),
+ "description" => t("Allows users to list Arduino Projects certificates.")
+ ),
+ "list Arduino Projects custom certificates" => array(
+ "title" => t("list Arduino Projects custom certificates"),
+ "description" => t("Allows users to list Arduino Projects custom certificates.")
+ ),
+ "generate pdf" => array(
+ "title" => t("Generate pdf"),
+ "description" => t("Allows users to Generate pdf.")
+ )
+ );
+ // return array('arduino projects create proposal', 'arduino projects manage proposal', 'arduino projects edit proposal', 'arduino projects approve proposal', 'arduino projects propose solution', 'arduino projects approve code', 'arduino projects bulk manage abstract', 'arduino projects bulk delete code', 'arduino projects upload code', 'arduino projects download code', 'administer arduino projects', 'arduino projects generate lab');
+}
+
+/*************************** VALIDATION FUNCTIONS *****************************/
+function arduino_projects_blog_check_valid_filename($file_name)
+{
+ if (!preg_match('/^[0-9a-zA-Z\.\_]+$/', $file_name))
+ return FALSE;
+ else if (substr_count($file_name, ".") > 1)
+ return FALSE;
+ else
+ return TRUE;
+}
+function arduino_projects_blog_check_name($name = '')
+{
+ if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
+ return FALSE;
+ else
+ return TRUE;
+}
+function arduino_projects_blog_check_code_number($number = '')
+{
+ if (!preg_match('/^[0-9]+$/', $number))
+ return FALSE;
+ else
+ return TRUE;
+}
+/************************* USER VERIFICATION FUNCTIONS ************************/
+function arduino_projects_blog_get_proposal()
+{
+ global $user;
+ //$proposal_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message("You do not have any approved arduino projects proposal. Please propose the Arduino Projects proposal", 'error');
+ drupal_goto('');
+ } //!$proposal_data
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ drupal_set_message(t('Proposal is awaiting approval.'), 'status');
+ return FALSE;
+ case 1:
+ return $proposal_data;
+ case 2:
+ drupal_set_message(t('Proposal has been dis-approved.'), 'error');
+ return FALSE;
+ case 3:
+ drupal_set_message(t('Proposal has been marked as completed.'), 'status');
+ return FALSE;
+ default:
+ drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
+ return FALSE;
+ } //$proposal_data->approval_status
+ return FALSE;
+}
+/*************************************************************************/
+/***** Function To convert only first charater of string in uppercase ****/
+/*************************************************************************/
+function ucname($string)
+ {
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ }
+ }
+ return $string;
+ }
+function arduino_projects_blog_ucname($string)
+{
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'' ) as $delimiter
+ return $string;
+}
+function _df_sentence_case($string)
+{
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'' ) as $delimiter
+ return $string;
+}
+
+function _df_list_of_states()
+{
+ $states = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_states_of_india');
+ $query->fields('list_states_of_india');
+ //$query->orderBy('', '');
+ $states_list = $query->execute();
+ while ($states_list_data = $states_list->fetchObject())
+ {
+ $states[$states_list_data->state] = $states_list_data->state;
+ } //$states_list_data = $states_list->fetchObject()
+ return $states;
+}
+function _df_list_of_cities()
+{
+ $city = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_cities_of_india');
+ $query->fields('list_cities_of_india');
+ $query->orderBy('city', 'ASC');
+ $city_list = $query->execute();
+ while ($city_list_data = $city_list->fetchObject())
+ {
+ $city[$city_list_data->city] = $city_list_data->city;
+ } //$city_list_data = $city_list->fetchObject()
+ return $city;
+}
+function _df_list_of_pincodes()
+{
+ $pincode = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_of_all_india_pincode');
+ $query->fields('list_of_all_india_pincode');
+ $query->orderBy('pincode', 'ASC');
+ $pincode_list = $query->execute();
+ while ($pincode_list_data = $pincode_list->fetchObject())
+ {
+ $pincode[$pincode_list_data->pincode] = $pincode_list_data->pincode;
+ } //$pincode_list_data = $pincode_list->fetchObject()
+ return $pincode;
+}
+function _df_list_of_departments()
+{
+ $department = array();
+ $query = db_select('list_of_departments');
+ $query->fields('list_of_departments');
+ $query->orderBy('id', 'DESC');
+ $department_list = $query->execute();
+ while ($department_list_data = $department_list->fetchObject())
+ {
+ $department[$department_list_data->department] = $department_list_data->department;
+ } //$department_list_data = $department_list->fetchObject()
+ return $department;
+}
+function _apb_dir_name($project, $proposar_name)
+{
+
+ $project_title = ucname($project);
+ $proposar_name = ucname($proposar_name);
+ $dir_name = $project_title . ' By ' . $proposar_name;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", str_replace("/", " ", $dir_name)));
+ return $directory_name;
+}
+function arduino_projects_blog_files_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'project_uploads/';
+}
+function DF_RenameDir($proposal_id, $dir_name)
+{
+ $proposal_id = $proposal_id;
+ $dir_name = $dir_name;
+ $query = db_query("SELECT directory_name,id FROM arduino_projects_blog_proposal WHERE id = :proposal_id", array(
+ ':proposal_id' => $proposal_id
+ ));
+ $result = $query->fetchObject();
+ if ($result != NULL)
+ {
+ $files = scandir(arduino_projects_blog_path());
+ $files_id_dir = arduino_projects_blog_path() . $result->id;
+ //var_dump($files);die;
+ $file_dir = arduino_projects_blog_path() . $result->directory_name;
+ if (is_dir($file_dir))
+ {
+ $new_directory_name = rename(arduino_projects_blog_path() . $result->directory_name, arduino_projects_blog_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($file_dir)
+ else if (is_dir($files_id_dir))
+ {
+ $new_directory_name = rename(arduino_projects_blog_path() . $result->id, arduino_projects_blog_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($files_id_dir)
+ else
+ {
+ drupal_set_message('Directory not available for rename.');
+ return;
+ }
+ } //$result != NULL
+ else
+ {
+ drupal_set_message('Project directory name not present in databse');
+ return;
+ }
+ //var_dump($files);die;
+ /* if ($files != NULL)
+ {
+ $new_directory_name = rename(arduino_projects_blog_path() . $result->directory_name, arduino_projects_blog_path() . $dir_name) or drupal_set_message("Unable to rename folder");
+ }
+ else
+ {
+ $new_directory_name = 'Can not rename the directory. Directory not present';
+ }*/
+ return;
+}
+function CreateReadmeFileOmPSSPProject($proposal_id)
+{
+ $result = db_query("
+ SELECT * from arduino_projects_blog_proposal WHERE id = :proposal_id", array(
+ ":proposal_id" => $proposal_id
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = arduino_projects_blog_path();
+ $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!");
+ $txt = "";
+ $txt .= "About the Arduino Projects";
+ $txt .= "\n" . "\n";
+ $txt .= "Title Of The Arduino Projects Project: " . $proposal_data->project_title . "\n";
+ $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n";
+ $txt .= "University: " . $proposal_data->university . "\n";
+ $txt .= "\n" . "\n";
+ $txt .= "Arduino Projects Project By FOSSEE, IIT Bombay" . "\n";
+ fwrite($readme_file, $txt);
+ fclose($readme_file);
+ return $txt;
+}
+function rrmdir_project($prop_id)
+{
+ $proposal_id = $prop_id;
+ $result = db_query("
+ SELECT * from arduino_projects_blog_proposal WHERE id = :proposal_id", array(
+ ":proposal_id" => $proposal_id
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = arduino_projects_blog_path();
+ $dir = $root_path . $proposal_data->directory_name;
+ if ($proposal_data->id == $prop_id)
+ {
+ if (is_dir($dir))
+ {
+ $objects = scandir($dir);
+ foreach ($objects as $object)
+ {
+ if ($object != "." && $object != "..")
+ {
+ if (filetype($dir . "/" . $object) == "dir")
+ {
+ rrmdir($dir . "/" . $object);
+ } //filetype($dir . "/" . $object) == "dir"
+ else
+ {
+ unlink($dir . "/" . $object);
+ }
+ } //$object != "." && $object != ".."
+ } //$objects as $object
+ reset($objects);
+ rmdir($dir);
+ $msg = drupal_set_message("Directory deleted successfully");
+ return $msg;
+ } //is_dir($dir)
+ $msg = drupal_set_message("Directory not present");
+ return $msg;
+ } //$proposal_data->id == $prop_id
+ else
+ {
+ $msg = drupal_set_message("Data not found");
+ return $msg;
+ }
+}
+function rrmdir($dir)
+{
+ if (is_dir($dir))
+ {
+ $objects = scandir($dir);
+ foreach ($objects as $object)
+ {
+ if ($object != "." && $object != "..")
+ {
+ if (filetype($dir . "/" . $object) == "dir")
+ rrmdir($dir . "/" . $object);
+ else
+ unlink($dir . "/" . $object);
+ } //$object != "." && $object != ".."
+ } //$objects as $object
+ reset($objects);
+ rmdir($dir);
+ } //is_dir($dir)
+} \ No newline at end of file
diff --git a/download.inc b/download.inc
new file mode 100755
index 0000000..9f9aea9
--- /dev/null
+++ b/download.inc
@@ -0,0 +1,102 @@
+<?php
+// $Id$
+function arduino_projects_blog_download_reference_images()
+{
+ global $user;
+ $id = arg(3);
+ $root_path = arduino_projects_blog_files_path();
+ //var_dump($root_path);die;
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $id);
+ $arduino_projects_q = $query->execute();
+ $arduino_projects_data = $arduino_projects_q->fetchObject();
+ $arduino_projects_directory_path = $arduino_projects_data->directory_name . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive();
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ /*$query = db_select('om_pssp_proposal');
+ $query->fields('om_pssp_proposal');
+ $query->condition('id', $id);
+ $om_pssp_udc_q = $query->execute();
+ $query = db_select('om_pssp_proposal');
+ $query->fields('om_pssp_proposal');
+ $query->condition('id', $id);*/
+ $query = db_select('arduino_projects_blog_proposal_images');
+ $query->fields('arduino_projects_blog_proposal_images');
+ $query->condition('proposal_id', $id);
+ $reference_images = $query->execute();
+ while ($reference_images_files = $reference_images->fetchObject()) {
+ $zip->addFile($root_path . $reference_images_files->path, $arduino_projects_directory_path . str_replace(' ', '_', basename($reference_images_files->name)));
+ }
+ $zip_file_count = $zip->numFiles;
+ //var_dump($zip_file_count);die;
+ $zip->close();
+ if ($zip_file_count > 0) {
+ if ($user->uid) {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $arduino_projects_data->project_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ } //$user->uid
+ else {
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $arduino_projects_data->project_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ } //$zip_file_count > 0
+ else {
+ drupal_set_message("There are no power system simulation project in this proposal to download", 'error');
+ drupal_goto('powersystems');
+ }
+}
+/*
+function arduino_projects_blog_download_reference_images() {
+ $proposal_id = arg(3);
+ $root_path = arduino_projects_blog_files_path();
+ $query = db_select('arduino_projects_blog_proposal_images');
+ $query->fields('arduino_projects_blog_proposal_images');
+ $query->condition('proposal_id', $proposal_id);
+ $result = $query->execute();
+ while($arduino_projects_blog_project_files = $result->fetchObject()){
+ //var_dump($arduino_projects_blog_project_files);die;
+ $query1 = db_select('arduino_projects_blog_proposal');
+ $query1->fields('arduino_projects_blog_proposal');
+ $query1->condition('id', $proposal_id);
+ $result1 = $query1->execute();
+ $arduino_projects_blog = $result1->fetchObject();
+ $directory_name = $arduino_projects_blog->directory_name . '/project_files/';
+ $samplecodename = $arduino_projects_blog_project_files->path;
+ ob_clean();
+ header("Pragma: public");
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+ header("Cache-Control: public");
+ header("Content-Description: File Transfer");
+ header("Content-Type: application/zip");
+ header('Content-disposition: attachment; filename="' . $samplecodename . '"');
+ header("Content-Length: " . filesize($root_path . $samplecodename));
+ header("Content-Transfer-Encoding: binary");
+ header("Expires: 0");
+ header("Pragma: no-cache");
+ readfile($root_path . $samplecodename);
+ ob_end_flush();
+ ob_clean();
+}
+}
+*/ \ No newline at end of file
diff --git a/email.inc b/email.inc
new file mode 100755
index 0000000..831bec5
--- /dev/null
+++ b/email.inc
@@ -0,0 +1,361 @@
+<?php
+/**
+ * Implementation of hook_mail().
+ */
+function arduino_projects_blog_mail($key, &$message, $params)
+{
+ global $user;
+ $language = $message['language'];
+ //$language = user_preferred_language($user);
+ switch ($key)
+ {
+ case 'arduino_projects_blog_proposal_received':
+ /* initializing data */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['arduino_projects_blog_proposal_received']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $phpdate = time( $proposal_data->creation_date );
+ $user_data = user_load($params['arduino_projects_blog_proposal_received']['user_id']);
+ $message['headers'] = $params['arduino_projects_blog_proposal_received']['headers'];
+ $message['subject'] = t('[!site_name][Arduino Project] Your Arduino Project proposal has been received', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+Thank you for submitting proposal for the Arduino Project. The details of your proposal are as below :
+
+Full Name: ' . $proposal_data->contributor_name . '
+Email: ' . $user_data->mail . '
+University/Institute: ' . $proposal_data->university . '
+City: ' . $proposal_data->city . '
+How did you hear about us:' . $proposal_data->how_did_you_hear_about_us . '
+Project Title: ' . $proposal_data->project_title . '
+Abstract: ' . $proposal_data->abstract . '
+References: ' . $proposal_data->reference . '
+
+
+Your proposal is under review. You will be notified via email about the approval/disapproval within ten working days.
+
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'arduino_projects_blog_proposal_resubmit':
+ /* initializing data */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['arduino_projects_blog_proposal_resubmit']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $phpdate = time( $proposal_data->creation_date );
+ $user_data = user_load($params['arduino_projects_blog_proposal_resubmit']['user_id']);
+ $message['headers'] = $params['arduino_projects_blog_proposal_resubmit']['headers'];
+ $message['subject'] = t('[!site_name][Arduino Project] Your Arduino Project proposal has been marked for resubmission', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+Please resubmit your proposal with the following detailss:
+
+Full Name: ' . $proposal_data->contributor_name . '
+Email: ' . $user_data->mail . '
+University/Institute: ' . $proposal_data->university . '
+City: ' . $proposal_data->city . '
+How did you hear about us:' . $proposal_data->how_did_you_hear_about_us . '
+Project Title: ' . $proposal_data->project_title . '
+Abstract: ' . $proposal_data->abstract . '
+References: ' . $proposal_data->reference . '
+Reason(s) / Feedback: ' . $proposal_data->resubmit_comment . '
+
+
+Your proposal is under review. You will be notified via email about the approval/disapproval within ten working days.
+
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'arduino_projects_blog_proposal_disapproved':
+ /* initializing data */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['arduino_projects_blog_proposal_disapproved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $phpdate = time( $proposal_data->creation_date );
+ $user_data = user_load($params['arduino_projects_blog_proposal_disapproved']['user_id']);
+ $message['headers'] = $params['arduino_projects_blog_proposal_disapproved']['headers'];
+ $message['subject'] = t('[!site_name][Arduino Project] Your Arduino Project Project proposal has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+We regret to inform you that your Arduino Project proposal, with following details, has been disapproved.
+
+Full Name: ' . $proposal_data->contributor_name . '
+Email: ' . $user_data->mail . '
+University/Institute: ' . $proposal_data->university . '
+City: ' . $proposal_data->city . '
+
+Project Title: ' . $proposal_data->project_title . '
+Abstract: ' . $proposal_data->abstract . '
+
+Reason(s) / Feedback: ' . $proposal_data->dissapproval_reason . '
+
+Please note that any files that were uploaded along with the proposal form will be deleted from all our database(s).
+
+Thank you for participating in the Arduino Project. You are welcome to submit a new proposal.
+
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'arduino_projects_blog_proposal_approved':
+ /* initializing data */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['arduino_projects_blog_proposal_approved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['arduino_projects_blog_proposal_approved']['user_id']);
+ $url = 'https://om.fossee.in/powersystems/pssp/coding-guidelines';
+ $message['headers'] = $params['arduino_projects_blog_proposal_approved']['headers'];
+ $message['subject'] = t('[!site_name][Power Simulation Simulation Project] Your Power Simulation Simulation Project proposal has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+Congratulations! Your proposal for Arduino Project with the following details is approved.
+
+Full Name: ' . $proposal_data->contributor_name . '
+Email: ' . $user_data->mail . '
+University/Institute: ' . $proposal_data->university . '
+City: ' . $proposal_data->city . '
+
+Project Title: ' . $proposal_data->project_title . '
+Abstract: ' . $proposal_data->abstract . '
+
+
+Please ensure that ALL the guidelines for coding at https://om.fossee.in/powersystems/pssp/coding-guidelines are strictly followed. Refer https://om.fossee.in/powersystems/pssp/internship for the further procedure for submission of the project. Kindly ensure that the completed model and abstract are submitted within 1 month.
+
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'arduino_projects_blog_proposal_completed':
+ /* initializing data */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['arduino_projects_blog_proposal_completed']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['arduino_projects_blog_proposal_completed']['user_id']);
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $message['headers'] = $params['arduino_projects_blog_proposal_completed']['headers'];
+ $message['subject'] = t('[!site_name][Arduino Project Project] Your OpenModelica Arduino Project Project proposal has been completed', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+Your simulation and abstract for Arduino Project at FOSSEE on the following process have been published successfully.
+
+
+Full Name : ' . $proposal_data->contributor_name . '
+Project Title : ' . $proposal_data->project_title . '
+
+Kindly access this link to download the same.
+https://om.fossee.in/powersystems/pssp/completed-pssp
+
+
+Thank you for participating in the Arduino Project Project. You are welcome to propose a new proposal.
+
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'arduino_projects_blog_proposal_deleted':
+ /* initializing data */
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['arduino_projects_blog_proposal_deleted']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['arduino_projects_blog_proposal_deleted']['user_id']);
+
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $message['headers'] = $params['arduino_projects_blog_proposal_deleted']['headers'];
+ $message['subject'] = t('[!site_name][Arduino Project Project] Your OpenModelica Arduino Project Project proposal has been deleted', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+Your Arduino Project proposal with the following details has been deleted:
+
+Full Name : ' . $proposal_data->contributor_name . '
+Email : ' . $user_data->mail . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+
+Project Title : ' . $proposal_data->project_title . '
+Abstract: ' . $proposal_data->abstract .'
+
+
+
+You can propose a new Arduino project.
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ /**************************************************************/
+ case 'abstract_uploaded':
+ // $solution_q = db_query("SELECT * FROM {arduino_projects_blog_solution} WHERE id = %d LIMIT 1", $params['abstract_uploaded']['solution_id']);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $params['abstract_uploaded']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+
+ $user_data = user_load($params['abstract_uploaded']['user_id']);
+ $message['subject'] = t('[!site_name][Arduino Project Project] You have uploaded OpenModelica model and abstract', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['headers'] = $params['abstract_uploaded']['headers'];
+ $message['body'] = array(
+ 'body' => t('
+Dear ' . $proposal_data->contributor_name . ',
+
+You have successfully uploaded your simulation and abstract for Arduino Project with the following details.
+
+Full Name : ' . $proposal_data->contributor_name . '
+Email : ' . $user_data->mail . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+
+Project Title : ' . $proposal_data->project_title . '
+Abstract: ' . $proposal_data->abstract .'
+
+You shall be notified via email after the model and abstract are reviewed and approved / disapproved. This may take upto 30 working days.
+
+Best Wishes,
+
+!site_name Arduino Projects Team,
+FOSSEE, IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'standard':
+ $message['subject'] = $params['standard']['subject'];
+ $message['body'] = $params['standard']['body'];
+ $message['headers'] = $params['standard']['headers'];
+ break;
+ } //$key
+}
diff --git a/general_deletion.inc b/general_deletion.inc
new file mode 100755
index 0000000..b6527ae
--- /dev/null
+++ b/general_deletion.inc
@@ -0,0 +1,48 @@
+<?php
+/******************************************************************************/
+/****************************** DELETION FUNCTIONS ****************************/
+/******************************************************************************/
+function arduino_projects_blog_abstract_delete_project($proposal_id)
+{
+ $status = TRUE;
+ $root_path = arduino_projects_blog_path();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message('Invalid power system simulation Project.', 'error');
+ return FALSE;
+ } //!$proposal_data
+ $query = db_select('arduino_projects_blog_submitted_abstracts_file');
+ $query->fields('arduino_projects_blog_submitted_abstracts_file');
+ $query->condition('proposal_id', $proposal_id);
+ $abstract_q = $query->execute();
+ $dir_project_files = $root_path . $proposal_data->directory_name . '/project_files';
+ while ($abstract_data = $abstract_q->fetchObject())
+ {
+ if (is_dir($dir_project_files)){
+
+ unlink($root_path . $proposal_data->directory_name . '/project_files/' . $abstract_data->filepath);
+ }
+ else
+ {
+ drupal_set_message('Invalid power system simulation project abstract.', 'error');
+ }
+ db_delete('arduino_projects_blog_submitted_abstracts_file')->condition('proposal_id', $proposal_id)->execute();
+ //!arduino_projects_blog_delete_abstract_file($abstract_data->id)
+ }
+ $res = rmdir($root_path . $proposal_data->directory_name . '/project_files');
+ $dir_path_udc = $root_path . $proposal_data->directory_name;
+ if (is_dir($dir_path_udc))
+ {
+ unlink($root_path . $proposal_data->samplefilepath);
+ $res = rmdir($dir_path_udc);
+ } //is_dir($dir_path_udc)
+ db_delete('arduino_projects_blog_proposal')->condition('id', $proposal_data->id)->execute();
+
+ db_delete('arduino_projects_blog_submitted_abstracts')->condition('proposal_id', $proposal_id)->execute();
+ return $status;
+} \ No newline at end of file
diff --git a/manage_proposal.inc b/manage_proposal.inc
new file mode 100755
index 0000000..f4c3508
--- /dev/null
+++ b/manage_proposal.inc
@@ -0,0 +1,1006 @@
+<?php
+// $Id$
+function arduino_projects_blog_proposal_pending()
+{
+ /* get pending proposals to be approved */
+ $pending_rows = array();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('approval_status', 0);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject())
+ {
+ $pending_rows[$pending_data->id] = array(
+ date('d-m-Y', $pending_data->creation_date),
+ l($pending_data->contributor_name, 'user/' . $pending_data->uid),
+ $pending_data->project_title,
+ l('View', 'arduino-projects/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'arduino-projects/manage-proposal/edit/' . $pending_data->id)
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$pending_rows)
+ {
+ drupal_set_message(t('There are no pending proposals.'), 'status');
+ return '';
+ } //!$pending_rows
+ $pending_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the Project',
+ 'Action'
+ );
+ //$output = theme_table($pending_header, $pending_rows);
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows
+ ));
+ return $output;
+}
+function arduino_projects_blog_proposal_all()
+{
+ /* get pending proposals to be approved */
+ $proposal_rows = array();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->orderBy('id', 'DESC');
+ $proposal_q = $query->execute();
+ while ($proposal_data = $proposal_q->fetchObject())
+ {
+ $approval_status = '';
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ $approval_status = 'Pending';
+ break;
+ case 1:
+ $approval_status = 'Approved';
+ break;
+ case 2:
+ $approval_status = 'Marked for resubmission';
+ break;
+ case 3:
+ $approval_status = 'Completed';
+ break;
+ case 4:
+ $approval_status = 'Disapproved';
+ break;
+ default:
+ $approval_status = 'Unknown';
+ break;
+ } //$proposal_data->approval_status
+ if ($proposal_data->actual_completion_date == 0)
+ {
+ $actual_completion_date = "Not Completed";
+ } //$proposal_data->actual_completion_date == 0
+ else
+ {
+ $actual_completion_date = date('d-m-Y', $proposal_data->actual_completion_date);
+ }
+ $proposal_rows[] = array(
+ date('d-m-Y', $proposal_data->creation_date),
+ l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ $proposal_data->project_title,
+ $actual_completion_date,
+ $approval_status,
+ l('Status', 'arduino-projects/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'arduino-projects/manage-proposal/edit/' . $proposal_data->id)
+ );
+ } //$proposal_data = $proposal_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$proposal_rows)
+ {
+ drupal_set_message(t('There are no proposals.'), 'status');
+ return '';
+ } //!$proposal_rows
+ $proposal_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the project',
+ 'Date of Completion',
+ 'Status',
+ 'Action'
+ );
+ $output = theme('table', array(
+ 'header' => $proposal_header,
+ 'rows' => $proposal_rows
+ ));
+ return $output;
+}
+/******************************************************************************/
+/************************** PROPOSAL APPROVAL FORM ****************************/
+/******************************************************************************/
+function arduino_projects_blog_proposal_approval_form($form, &$form_state)
+{
+ global $user;
+ $root_path = arduino_projects_blog_files_path();
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ if ($proposal_data->contact_no == "NULL" || $proposal_data->contact_no == "")
+ {
+ $contact_no = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $contact_no = $proposal_data->contact_no;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Contributor name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['contributor_contact_no'] = array(
+ '#title' => t('Contact No.'),
+ '#type' => 'item',
+ '#markup' => $contact_no,
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute/Organisation')
+ );
+ $form['position'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->position,
+ '#title' => t('Position')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['how_did_you_hear_about_us'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->how_did_you_hear_about_us,
+ '#title' => t('How did you hear about us')
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Project')
+ );
+ $form['abstract'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->abstract,
+ '#title' => t('Abstract')
+ );
+ $form['reference'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->reference,
+ '#title' => t('References')
+ );
+ $form['reference_images'] = array(
+ '#type' => 'item',
+ '#title' => t('Reference Images'),
+ '#markup' => l('Download Reference Images', 'arduino-projects/download/reference-images/' . $proposal_id)
+ );
+ $form['creation_date'] = array(
+ '#type' => 'item',
+ '#title' => t('Submission date'),
+ '#markup' => date('d-m-Y', $proposal_data->creation_date)
+ );
+ $form['expected_date_of_completion'] =array(
+ '#type' => 'item',
+ '#title' => t('Expected Completion date'),
+ '#markup' => date('d-m-Y', $proposal_data->expected_date_of_completion)
+ );
+ $form['approval'] = array(
+ '#type' => 'radios',
+ '#title' => t('Action performed on the proposal'),
+ '#options' => array(
+ '1' => 'Approve the proposal',
+ '2' => 'Resubmit proposal',
+ '3' => 'Disapprove the proposal'
+ ),
+ '#required' => TRUE
+ );
+ $form['resubmit_comment'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Comment for resubmitting the proposal'),
+ '#attributes' => array(
+ 'placeholder' => t('Minimum 30 characters '),
+ 'cols' => 50,
+ 'rows' => 4
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="approval"]' => array(
+ 'value' => '2'
+ )
+ )
+ )
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reason for disapproval'),
+ '#attributes' => array(
+ 'placeholder' => t('Enter reason for disapproval in minimum 30 characters '),
+ 'cols' => 50,
+ 'rows' => 4
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="approval"]' => array(
+ 'value' => '3'
+ )
+ )
+ )
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'arduino-projects/manage-proposal')
+ );
+ return $form;
+}
+function arduino_projects_blog_proposal_approval_form_validate($form, &$form_state)
+{
+ if ($form_state['values']['approval'] == 2) {
+ if ($form_state['values']['resubmit_comment'] == '')
+ {
+ form_set_error('resubmit_comment', t('Please enter comment for resubmitting the proposal'));
+ }
+ }
+ if ($form_state['values']['approval'] == 3)
+ {
+ if ($form_state['values']['message'] == '')
+ {
+ form_set_error('message', t('Reason for disapproval could not be empty'));
+ } //$form_state['values']['message'] == ''
+ } //$form_state['values']['approval'] == 2
+}
+function arduino_projects_blog_proposal_approval_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ if ($form_state['values']['approval'] == 1)
+ {
+ $query = "UPDATE {arduino_projects_blog_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 1 WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":proposal_id" => $proposal_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('arduino_projects_blog_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('arduino_projects_blog_bcc_emails', '');
+ $cc = variable_get('arduino_projects_blog_cc_emails', '');
+ $params['arduino_projects_blog_proposal_approved']['proposal_id'] = $proposal_id;
+ $params['arduino_projects_blog_proposal_approved']['user_id'] = $proposal_data->uid;
+ $params['arduino_projects_blog_proposal_approved']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_approved', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Arduino project proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 1
+ else if ($form_state['values']['approval'] == 2)
+ {
+ $query = "UPDATE {arduino_projects_blog_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, resubmit_comment = :resubmit_comment WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":resubmit_comment" => $form_state['values']['resubmit_comment'],
+ ":proposal_id" => $proposal_id
+ );
+ $result = db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('arduino_projects_blog_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('arduino_projects_blog_bcc_emails', '');
+ $cc = variable_get('arduino_projects_blog_cc_emails', '');
+ $params['arduino_projects_blog_proposal_resubmit']['proposal_id'] = $proposal_id;
+ $params['arduino_projects_blog_proposal_resubmit']['user_id'] = $proposal_data->uid;
+ $params['arduino_projects_blog_proposal_resubmit']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_resubmit', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Proposal has been marked for resubmission . User has been notified.', 'status');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ else if ($form_state['values']['approval'] == 3)
+ {
+ $query = "UPDATE {arduino_projects_blog_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 4, dissapproval_reason = :dissapproval_reason WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":dissapproval_reason" => $form_state['values']['message'],
+ ":proposal_id" => $proposal_id
+ );
+ $result = db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('arduino_projects_blog_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('arduino_projects_blog_bcc_emails', '');
+ $cc = variable_get('arduino_projects_blog_cc_emails', '');
+ $params['arduino_projects_blog_proposal_disapproved']['proposal_id'] = $proposal_id;
+ $params['arduino_projects_blog_proposal_disapproved']['user_id'] = $proposal_data->uid;
+ $params['arduino_projects_blog_proposal_disapproved']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_disapproved', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Arduino project proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 2
+}
+/******************************************************************************/
+/*************************** PROPOSAL STATUS FORM *****************************/
+/******************************************************************************/
+function arduino_projects_blog_proposal_status_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Student name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ /*$form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#disabled' => TRUE
+ );*/
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide'),
+ '#markup' => $proposal_data->project_guide_name
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide email'),
+ '#markup' => $proposal_data->project_guide_email_id
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Project')
+ );
+ if (($proposal_data->samplefilepath != "") && ($proposal_data->samplefilepath != 'NULL'))
+ {
+ $str = substr($proposal_data->samplefilepath,strrpos($proposal_data->samplefilepath, '/'));
+ $resource_file =ltrim($str, '/');
+
+ $form['samplefilepath'] = array(
+ '#type' => 'item',
+ '#title' => t('Abstract file '),
+ '#markup' => l($resource_file, 'arduino-projects/download/resource-file/' . $proposal_id) . ""
+ );
+ } //$proposal_data->user_defined_compound_filepath != ""
+ else
+ {
+ $form['samplefilepath'] = array(
+ '#type' => 'item',
+ '#title' => t('Abstract file '),
+ '#markup' => "Not uploaded<br><br>"
+ );
+ }
+ /************************** reference link filter *******************/
+ $url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
+ $reference = preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $proposal_data->reference);
+ /******************************/
+ $form['reference'] = array(
+ '#type' => 'item',
+ '#markup' => $reference,
+ '#title' => t('References')
+ );
+ $proposal_status = '';
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ $proposal_status = t('Pending');
+ break;
+ case 1:
+ $proposal_status = t('Approved');
+ break;
+ case 2:
+ $proposal_status = t('Dis-approved');
+ break;
+ case 3:
+ $proposal_status = t('Completed');
+ break;
+ default:
+ $proposal_status = t('Unkown');
+ break;
+ }
+ $form['proposal_status'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_status,
+ '#title' => t('Proposal Status')
+ );
+ if ($proposal_data->approval_status == 0)
+ {
+ $form['approve'] = array(
+ '#type' => 'item',
+ '#markup' => l('Click here', 'arduino-projects/manage-proposal/approve/' . $proposal_id),
+ '#title' => t('Approve')
+ );
+ } //$proposal_data->approval_status == 0
+ if ($proposal_data->approval_status == 1)
+ {
+ $form['completed'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Completed'),
+ '#description' => t('Check if user has provided all the required files and pdfs.')
+ );
+ } //$proposal_data->approval_status == 1
+ if ($proposal_data->approval_status == 2)
+ {
+ $form['message'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->message,
+ '#title' => t('Reason for disapproval')
+ );
+ } //$proposal_data->approval_status == 2
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#markup' => l(t('Cancel'), 'arduino-projects/manage-proposal/all')
+ );
+ return $form;
+}
+function arduino_projects_blog_proposal_status_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ /* set the book status to completed */
+ if ($form_state['values']['completed'] == 1)
+ {
+ $up_query = "UPDATE arduino_projects_blog_proposal SET approval_status = :approval_status , actual_completion_date = :expected_completion_date WHERE id = :proposal_id";
+ $args = array(
+ ":approval_status" => '3',
+ ":proposal_id" => $proposal_id,
+ ":expected_completion_date" => time()
+ );
+ $result = db_query($up_query, $args);
+ CreateReadmeFileOmPSSPProject($proposal_id);
+ if (!$result)
+ {
+ drupal_set_message('Error in update status', 'error');
+ return;
+ } //!$result
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('arduino_projects_blog_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('arduino_projects_blog_bcc_emails', '');
+ $cc = variable_get('arduino_projects_blog_cc_emails', '');
+ $params['arduino_projects_blog_proposal_completed']['proposal_id'] = $proposal_id;
+ $params['arduino_projects_blog_proposal_completed']['user_id'] = $proposal_data->uid;
+ $params['arduino_projects_blog_proposal_completed']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_completed', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Congratulations! proposal has been marked as completed. User has been notified of the completion.', 'status');
+ }
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+
+}
+/******************************************************************************/
+/**************************** PROPOSAL EDIT FORM ******************************/
+/******************************************************************************/
+function arduino_projects_blog_proposal_edit_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ $user_data = user_load($proposal_data->uid);
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof',
+ 'Mr' => 'Mr',
+ 'Mrs' => 'Mrs',
+ 'Ms' => 'Ms'
+ ),
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->name_title
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Proposer'),
+ '#size' => 350,
+ '#maxlength' => 350,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->contributor_name
+ );
+ $form['student_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Email'),
+ '#markup' => $user_data->mail
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#required' => FALSE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute'),
+ '#size' => 200,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->university
+ );
+ if($proposal_data->country == 'India'){
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#default_value' => $proposal_data->country,
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#default_value' => $proposal_data->state,
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+}
+else{
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Country(Other than India)'),
+ '#size' => 100,
+ '#default_value' => $proposal_data->country,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State(Other than India)'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#default_value' => $proposal_data->state,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City(Other than India)'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+}
+
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#default_value' => $proposal_data->pincode,
+ '#attributes' => array(
+ 'placeholder' => 'Insert pincode of your city/ village....'
+ )
+ );
+ $form['project_title'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Title of the Project'),
+ '#size' => 300,
+ '#maxlength' => 350,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->project_title
+ );
+ $form['description'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Description of the Project'),
+ '#size' => 250,
+ '#maxlength' => 250,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->description
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reference'),
+ '#size' => 10000,
+ '#attributes' => array(
+ 'placeholder' => 'Links of must be provided....'
+ ),
+ '#default_value' => $proposal_data->reference
+ );
+ $form['delete_proposal'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete Proposal')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'arduino-projects/manage-proposal')
+ );
+ return $form;
+}
+function arduino_projects_blog_proposal_edit_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ /* delete proposal */
+ if ($form_state['values']['delete_proposal'] == 1)
+ {
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('arduino_projects_blog_from_email', '');
+ $bcc = variable_get('arduino_projects_blog_bcc_emails', '');
+ $cc = variable_get('arduino_projects_blog_cc_emails', '');
+ $params['arduino_projects_blog_proposal_deleted']['proposal_id'] = $proposal_id;
+ $params['arduino_projects_blog_proposal_deleted']['user_id'] = $proposal_data->uid;
+ $params['arduino_projects_blog_proposal_deleted']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_deleted', $email_to, user_preferred_language($user), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message(t('Power system simulation proposal has been deleted.'), 'status');
+ if (rrmdir_project($proposal_id) == TRUE)
+ {
+ $query = db_delete('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $num_deleted = $query->execute();
+ drupal_set_message(t('Proposal Deleted'), 'status');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ } //rrmdir_project($proposal_id) == TRUE
+ } //$form_state['values']['delete_proposal'] == 1
+ /* update proposal */
+ $v = $form_state['values'];
+ $str = substr($proposal_data->samplefilepath,strrpos($proposal_data->samplefilepath, '/'));
+ $resource_file =ltrim($str, '/');
+ $project_title = $v['project_title'];
+ $proposar_name = $v['name_title'] . ' ' . $v['contributor_name'];
+ $university = $v['university'];
+ $directory_names = _df_dir_name($project_title, $proposar_name);
+ if (DF_RenameDir($proposal_id, $directory_names))
+ {
+ $directory_name = $directory_names;
+ } //LM_RenameDir($proposal_id, $directory_names)
+ else
+ {
+ return;
+ }
+ $samplefilepath = $directory_name . '/' . $resource_file;
+ $query = "UPDATE arduino_projects_blog_proposal SET
+ name_title=:name_title,
+ contributor_name=:contributor_name,
+ university=:university,
+ city=:city,
+ pincode=:pincode,
+ state=:state,
+ project_title=:project_title,
+ description=:description,
+ reference=:reference,
+ directory_name=:directory_name,
+ samplefilepath=:samplefilepath
+ WHERE id=:proposal_id";
+ $args = array(
+ ':name_title' => $v['name_title'],
+ ':contributor_name' => $v['contributor_name'],
+ ':university' => $v['university'],
+ ':city' => $v['city'],
+ ':pincode' => $v['pincode'],
+ ':state' => $v['all_state'],
+ ':project_title' => $project_title,
+ ':description' => $v['description'],
+ ':reference' => $v['reference'],
+ ':directory_name' => $directory_name,
+ ':samplefilepath' => $samplefilepath,
+ ':proposal_id' => $proposal_id
+ );
+ $result = db_query($query, $args);
+ drupal_set_message(t('Proposal Updated'), 'status');
+} \ No newline at end of file
diff --git a/my_proposals.inc b/my_proposals.inc
new file mode 100644
index 0000000..4c3ff5f
--- /dev/null
+++ b/my_proposals.inc
@@ -0,0 +1,565 @@
+<?php
+/******************************************************************************/
+/**************************** MY PROPOSAL EDIT FORM ******************************/
+/******************************************************************************/
+function arduino_projects_blog_my_proposal_edit_form($form, &$form_state, $no_js_use = FALSE)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {arduino_projects_blog_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ /*if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ /*} //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }*/
+ $user_data = user_load($proposal_data->uid);
+ $form['contributor_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Contributor'),
+ '#size' => 350,
+ '#maxlength' => 350,
+ '#default_value' => $proposal_data->contributor_name,
+ '#disabled' => TRUE
+ );
+ $form['student_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Email'),
+ '#markup' => $user_data->mail
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute/Organisation'),
+ '#size' => 200,
+ '#maxlength' => 200,
+ '#default_value' => $proposal_data->university,
+ '#disabled' => TRUE
+ );
+ $form['position'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Position'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#disabled' => TRUE,
+ '#default_value' => $proposal_data->position
+ );
+ $form['how_did_you_hear_about_us'] = array(
+ '#type' => 'textfield',
+ '#title' => t('How did you hear about us?'),
+ '#default_value' => $proposal_data->how_did_you_hear_about_us,
+ '#disabled' => TRUE
+ );
+ if($proposal_data->country == 'India'){
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#default_value' => $proposal_data->country,
+ '#tree' => TRUE,
+ '#validated' => TRUE,
+ '#disabled' => TRUE
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#default_value' => $proposal_data->state,
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ ),
+ '#disabled' => TRUE
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ ),
+ '#disabled' => TRUE
+ );
+}
+else{
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Country(Other than India)'),
+ '#size' => 100,
+ '#default_value' => $proposal_data->country,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#disabled' => TRUE
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State(Other than India)'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#default_value' => $proposal_data->state,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#disabled' => TRUE
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City(Other than India)'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#disabled' => TRUE
+ );
+}
+
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#default_value' => $proposal_data->pincode,
+ '#attributes' => array(
+ 'placeholder' => 'Insert pincode of your city/ village....'
+ ),
+ '#disabled' => TRUE
+ );
+ $form['project_title'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Title of the Project'),
+ '#size' => 300,
+ '#maxlength' => 350,
+ '#default_value' => $proposal_data->project_title,
+ '#disabled' => TRUE
+ );
+ $form['abstract'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Abstract'),
+ '#size' => 600,
+ '#maxlength' => 600,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->abstract
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reference'),
+ '#size' => 10000,
+ '#default_value' => $proposal_data->reference,
+ '#required' => TRUE
+ );
+ $form['uplpoaded_images'] = array(
+ '#markup' => '<h5><p> Edit existing reference images</p></h5>(Select Check box to delete existing photos)',
+ '#prefix' => '<div id="uploaded_images"><table><tr>',
+ '#suffix' => ''
+ );
+ $query1 = db_select('arduino_projects_blog_proposal_images');
+ $query1->fields('arduino_projects_blog_proposal_images');
+ $query1->condition('proposal_id', $proposal_id);
+ $result1 = $query1->execute();
+ while ($row1 = $result1->fetchObject()) {
+ $form['imagecheck@' . $row1->id] = array(
+ '#type' => 'checkbox',
+ '#field_suffix' => '<img style="width:500px; padding-left :20px;height:350px" src=' . $GLOBALS['base_url'] . "/project_uploads/" . $row1->path . ' />'
+ );
+ }
+ $form['enduploadphotos'] = array(
+ '#markup' => '',
+ '#prefix' => '',
+ '#suffix' => '</tr></table></div>'
+ );
+ $form['reference_files'] = array(
+ '#type' => 'fieldset',
+ '#tree' => TRUE,
+ '#prefix' => '<div id="names-fieldset-wrapper">',
+ '#suffix' => '</div>',
+ '#title' => t('Upload Reference images'),
+ );
+ if (empty($form_state['num_names'])) {
+ $form_state['num_names'] = 1;
+ }
+ for ($i = 0; $i < $form_state['num_names']; $i++) {
+ $temp_no = $i;
+ $form['reference_files'][$i]['image'] = array(
+ //'#title' => t('Add Event Image'),
+ '#type' => 'file',
+ '#weight' => '5',
+ '#description' => t('Upload filenames with allowed extensions only. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions: ') . variable_get('reference_image_extensions', '') . '</span>',
+ // We need this to know which file element this is.
+ // By default drupal would name all as files[reference_files]
+ '#name' => 'files[reference_files_' . $i . '_name]'
+ );
+ $form['reference_files']["images_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp_no
+ );
+ }
+ if($i < 5){
+ $form['reference_files']['add_name'] = array(
+ '#type' => 'submit',
+ '#value' => t('Add Image'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'reference_files_add_more_add_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'reference_files_add_more_callback',
+ 'wrapper' => 'names-fieldset-wrapper'
+ )
+ );
+ }
+ if ($form_state['num_names'] > 1) {
+ $form['reference_files']['remove_name'] = array(
+ '#type' => 'submit',
+ '#value' => t('Remove Image'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'reference_files_add_more_remove_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'reference_files_add_more_callback',
+ 'wrapper' => 'names-fieldset-wrapper'
+ )
+ );
+ }
+ if ($no_js_use) {
+ if (!empty($form['reference_files']['remove_name']['#ajax'])) {
+ unset($form['reference_files']['remove_name']['#ajax']);
+ }
+ unset($form['reference_files']['add_name']['#ajax']);
+ }
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'arduino-projects/my-proposals')
+ );
+ return $form;
+}
+function reference_files_add_more_callback($form, $form_state) {
+ return $form['reference_files'];
+}
+
+
+function reference_files_add_more_add_one($form, &$form_state) {
+ $form_state['num_names']++;
+ $form_state['rebuild'] = TRUE;
+ //$form_state['no_redirect'] = TRUE;
+}
+
+
+function reference_files_add_more_remove_one($form, &$form_state) {
+ if ($form_state['num_names'] > 1) {
+ $form_state['num_names']--;
+ }
+ $form_state['rebuild'] = TRUE;
+}
+function arduino_projects_blog_my_proposal_edit_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ /* update proposal */
+ $v = $form_state['values'];
+ $query = "UPDATE arduino_projects_blog_proposal SET
+ abstract=:abstract,
+ reference=:reference
+ WHERE id=:proposal_id";
+ $args = array(
+ ':abstract' => $v['abstract'],
+ ':reference' => $v['reference'],
+ ':proposal_id' => $proposal_id
+ );
+ $result = db_query($query, $args);
+ $deletecounter = 0;
+ $query_img = db_select('arduino_projects_blog_proposal_images');
+ $query_img->fields('arduino_projects_blog_proposal_images');
+ $query_img->condition('proposal_id', $proposal_id);
+ $result_img = $query_img->execute();
+ $root_path= arduino_projects_blog_files_path();
+ while ($row_img = $result_img->fetchObject()) {
+ if ($form_state['values']['imagecheck@' . $row_img->id] == 1) {
+ if (file_exists($root_path . $row_img->path)) {
+ unlink($root_path .$row_img->path);
+ $query2 = db_delete('arduino_projects_blog_proposal_images');
+ $query2->condition('id', $row_img->id);
+ $delete_img = $query2->execute();
+ if ($delete_img != 0) {
+ $deletecounter++;
+ }
+ }
+ else {
+ drupal_set_message(t('Error Could not delete :') . $filename . t(', file does not exist'), 'error');
+ }
+ }
+ }
+ /* For adding more images to existing event */
+ $items = array();
+ $root_path = arduino_projects_blog_files_path();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $result = $query->execute();
+ $row_folder = $result->fetchObject();
+ //var_dump($row_folder);die;
+ $eventfolder = $row_folder->directory_name . '/proposal_images/';
+ $dest_path = $eventfolder;
+ if (!is_dir($root_path . $dest_path)) {
+ mkdir($root_path . $dest_path);
+ }
+ $imageupload = 0;
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) {
+ drupal_set_message(t("Error uploading file. File !filename already exists."), array(
+ '!filename' => $_FILES['files']['name'][$file_form_name]
+ ), 'error');
+ return;
+ }
+
+ /* uploading file */
+ else if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) {
+ $imagequery = "INSERT INTO arduino_projects_blog_proposal_images(proposal_id,name,path) VALUES
+ (:proposal_id,:name, :path)";
+ $imageargs = array(
+ ":proposal_id" => $proposal_id,
+ ":name" => $_FILES['files']['name'][$file_form_name],
+ ":path" => $dest_path . $_FILES['files']['name'][$file_form_name]
+ );
+ /* storing the row id in $result */
+ $imageresult = db_query($imagequery, $imageargs, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if ($imageresult != 0) {
+ $imageupload++;
+ }
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ }
+ else {
+ drupal_set_message($file_name . $dest_path . t('was having an error while uploading :') , 'error');
+ }
+ }
+ }
+ if (!$result && $imageupload == 0 && $deletecounter == 0) {
+ drupal_set_message(t("Something went wrong, please try again."), "error");
+ }
+ else {
+ if ($imageupload != 0) {
+ drupal_set_message(t("Event's Pictures are added successfully"), "status");
+ }
+ if ($deletecounter != 0) {
+ drupal_set_message(t("Event's Pictures are deleted successfully"), "status");
+ }
+ }
+
+ drupal_set_message(t('Proposal Updated'), 'status');
+}
+
+function arduino_projects_blog_my_proposal_view_form($form, &$form_state)
+{
+ global $user;
+ $root_path = arduino_projects_blog_files_path();
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('arduino-projects/manage-proposal');
+ return;
+ }
+ if ($proposal_data->contact_no == "NULL" || $proposal_data->contact_no == "")
+ {
+ $contact_no = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $contact_no = $proposal_data->contact_no;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#title' => t('Contributor name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['contributor_contact_no'] = array(
+ '#title' => t('Contact No.'),
+ '#type' => 'item',
+ '#markup' => $contact_no,
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['position'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->position,
+ '#title' => t('Position')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['how_did_you_hear_about_us'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->how_did_you_hear_about_us,
+ '#title' => t('How did you hear about us')
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Project')
+ );
+ $form['abstract'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->abstract,
+ '#title' => t('Abstract')
+ );
+ $form['reference'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->reference,
+ '#title' => t('References')
+ );
+ /*$form['reference_images'] = array(
+ '#type' => 'item',
+ '#title' => t('Reference Images'),
+ '#markup' => l('Download Reference Images', 'arduino-projects/download/reference-images/' . $proposal_id)
+ );*/
+ $form['creation_date'] = array(
+ '#type' => 'item',
+ '#title' => t('Submission date'),
+ '#markup' => date('d-m-Y', $proposal_data->creation_date)
+ );
+ $form['expected_date_of_completion'] =array(
+ '#type' => 'item',
+ '#title' => t('Expected Completion date'),
+ '#markup' => date('d-m-Y', $proposal_data->expected_date_of_completion)
+ );
+ if($proposal_data->resubmit_comment){
+ $form['resubmit_comment'] = array(
+ '#type' => 'item',
+ '#title' => t('Comment from the Reviewer'),
+ '#markup' => $proposal_data->resubmit_comment
+ );
+ }
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'arduino-projects/my-proposals')
+ );
+ return $form;
+} \ No newline at end of file
diff --git a/proposal.inc b/proposal.inc
new file mode 100755
index 0000000..ad99f21
--- /dev/null
+++ b/proposal.inc
@@ -0,0 +1,663 @@
+<?php
+// $Id$
+/*
+Approval Status :
+0 - Pending
+1 - Approved
+4 - Dis-Approved
+2 - Resubmit proposal
+3 - Completed
+Solution Status :
+0 - Pending
+1 - Approved
+2 - Dis-Approved
+Solution Display :
+0 - No
+1 - Yes
+*/
+function arduino_projects_blog_proposal_form($form, &$form_state, $no_js_use = FALSE)
+{
+ global $user;
+ /************************ start approve book details ************************/
+ if ($user->uid == 0)
+ {
+ $msg = drupal_set_message(t('It is mandatory to ' . l('login', 'user') . ' on this website to access the proposal form. If you are new user please create a new account first.'), 'error');
+ //drupal_goto('/pssp');
+ drupal_goto('user');
+ return $msg;
+ } //$user->uid == 0
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data)
+ {
+ if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1)
+ {
+ drupal_set_message(t('We have already received your proposal.'), 'status');
+ drupal_goto('');
+ return;
+ } //$proposal_data->approval_status == 0 || $proposal_data->approval_status == 1
+ } //$proposal_data
+ $imp = t('<span style="color: red;">*This is a mandatory field</span>');
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the contributor'),
+ '#size' => 350,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your full name.....')
+ ),
+ '#maxlength' => 350,
+ '#required' => TRUE,
+ );
+ $form['contributor_contact_no'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Contact No.'),
+ '#size' => 10,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your contact number')
+ ),
+ '#maxlength' => 250
+ );
+ $form['contributor_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 30,
+ '#value' => $user->mail,
+ '#disabled' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute/Organisation'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ );
+ $form['position'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Position'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ ),
+ '#description' => $imp
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 6
+ );
+ $form['how_did_you_hear_about_us'] = array(
+ '#type' => 'select',
+ '#title' => t('How did you hear about us?'),
+ '#options' => array(
+ 'FOSSEE website' => 'FOSSEE website',
+ 'Spoken-tutorial website' => 'Spoken-tutorial website',
+ 'Attended the workshop' => 'Attended the workshop',
+ 'Recommended by friend or family' => 'Recommended by friend or family'
+ ),
+ );
+
+ /***************************************************************************/
+ $form['hr'] = array(
+ '#type' => 'item',
+ '#markup' => '<hr>'
+ );
+ $form['project_title'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Title of the Project'),
+ '#size' => 255,
+ '#description' => t('Maximum character limit is 255, minimum character 10'),
+ '#required' => TRUE
+ );
+ $form['abstract'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Abstract'),
+ '#size' => 600,
+ '#description' => t('Minimum character limit is 300'),
+ '#required' => TRUE
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('References'),
+ '#size' => 500,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'The links to the documents or websites which are referenced while proposing this project.'
+ )
+
+ );
+ /*$form['reference_files']['reference_image'] = array(
+ '#type' => 'file',
+ '#size' => 48,
+ '#description' => t('Upload filenames with allowed extensions only. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions: ') . variable_get('reference_image_extensions', '') . '</span>'
+ );*/
+ $form['reference_files'] = array(
+ '#type' => 'fieldset',
+ '#tree' => TRUE,
+ '#prefix' => '<div id="names-fieldset-wrapper">',
+ '#suffix' => '</div>',
+ '#title' => t('Upload Reference images'),
+ );
+ if (empty($form_state['num_names'])) {
+ $form_state['num_names'] = 1;
+ }
+ for ($i = 0; $i < $form_state['num_names']; $i++) {
+ $temp_no = $i;
+ $form['reference_files'][$i]['image'] = array(
+ //'#title' => t('Add Event Image'),
+ '#type' => 'file',
+ '#weight' => '5',
+ '#description' => t('Upload filenames with allowed extensions only. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions: ') . variable_get('reference_image_extensions', '') . '</span>',
+ // We need this to know which file element this is.
+ // By default drupal would name all as files[reference_files]
+ '#name' => 'files[reference_files_' . $i . '_name]'
+ );
+ $form['reference_files']["images_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp_no
+ );
+ }
+ if($i < 5){
+ $form['reference_files']['add_name'] = array(
+ '#type' => 'submit',
+ '#value' => t('Add Image'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'reference_files_add_more_add_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'reference_files_add_more_callback',
+ 'wrapper' => 'names-fieldset-wrapper'
+ )
+ );
+ }
+ if ($form_state['num_names'] > 1) {
+ $form['reference_files']['remove_name'] = array(
+ '#type' => 'submit',
+ '#value' => t('Remove Image'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'reference_files_add_more_remove_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'reference_files_add_more_callback',
+ 'wrapper' => 'names-fieldset-wrapper'
+ )
+ );
+ }
+ if ($no_js_use) {
+ if (!empty($form['reference_files']['remove_name']['#ajax'])) {
+ unset($form['reference_files']['remove_name']['#ajax']);
+ }
+ unset($form['reference_files']['add_name']['#ajax']);
+ }
+ $form['expected_date_of_completion'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Expected completion date',
+ '#disabled' => TRUE,
+ '#value' => date('d-m-Y', strtotime("+1 months", strtotime("NOW")))
+ );
+ $form['term_condition'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Terms And Conditions'),
+ '#options' => array(
+ 'status' => t('<a href="/arduino-projects/terms-and-conditions" target="_blank">I agree to the Terms and Conditions</a>')
+ ),
+ '#required' => TRUE
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
+function reference_files_add_more_callback($form, $form_state) {
+ return $form['reference_files'];
+}
+
+
+function reference_files_add_more_add_one($form, &$form_state) {
+ $form_state['num_names']++;
+ $form_state['rebuild'] = TRUE;
+ //$form_state['no_redirect'] = TRUE;
+}
+
+
+function reference_files_add_more_remove_one($form, &$form_state) {
+ if ($form_state['num_names'] > 1) {
+ $form_state['num_names']--;
+ }
+ $form_state['rebuild'] = TRUE;
+}
+
+function arduino_projects_blog_proposal_form_validate($form, &$form_state)
+{
+ $project_title = $form_state['values']['project_title'];
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ $query->condition('project_title', $project_title);
+ $query->condition(db_or()->condition('approval_status',1)->condition('approval_status',3));
+ $result = $query->execute()->rowCount();
+ //var_dump($result);die;
+ if ($result >= 1)
+ {
+ form_set_error('project_title', t('Project title name already exists'));
+ return;
+ }
+ if ($form_state['values']['term_condition'] == '1')
+ {
+ form_set_error('term_condition', t('Please check the terms and conditions'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['term_condition'] == '1'
+ if ($form_state['values']['country'] == 'Others')
+ {
+ if ($form_state['values']['other_country'] == '')
+ {
+ form_set_error('other_country', t('Enter country name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_country'] == ''
+ else
+ {
+ $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ if ($form_state['values']['other_state'] == '')
+ {
+ form_set_error('other_state', t('Enter state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_state'] == ''
+ else
+ {
+ $form_state['values']['all_state'] = $form_state['values']['other_state'];
+ }
+ if ($form_state['values']['other_city'] == '')
+ {
+ form_set_error('other_city', t('Enter city name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_city'] == ''
+ else
+ {
+ $form_state['values']['city'] = $form_state['values']['other_city'];
+ }
+ } //$form_state['values']['country'] == 'Others'
+ else
+ {
+ if ($form_state['values']['country'] == '0')
+ {
+ form_set_error('country', t('Select country name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['country'] == ''
+ if ($form_state['values']['all_state'] == '0')
+ {
+ form_set_error('all_state', t('Select state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['all_state'] == ''
+ if ($form_state['values']['city'] == '0')
+ {
+ form_set_error('city', t('Select city name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['city'] == ''
+ }
+ //Validation for project title
+ $form_state['values']['project_title'] = trim($form_state['values']['project_title']);
+ if ($form_state['values']['project_title'] != '')
+ {
+ if (strlen($form_state['values']['project_title']) > 255)
+ {
+ form_set_error('project_title', t('Maximum charater limit is 255 charaters only, please check the length of the project title'));
+ } //strlen($form_state['values']['project_title']) > 250
+ else if (strlen($form_state['values']['project_title']) < 10)
+ {
+ form_set_error('project_title', t('Minimum charater limit is 10 charaters, please check the length of the project title'));
+ } //strlen($form_state['values']['project_title']) < 10
+ } //$form_state['values']['project_title'] != ''
+ else
+ {
+ form_set_error('project_title', t('Project title shoud not be empty'));
+ }
+ $form_state['values']['abstract'] = trim($form_state['values']['abstract']);
+ if ($form_state['values']['abstract'] != '')
+ {
+ if (strlen($form_state['values']['abstract']) > 500)
+ {
+ form_set_error('abstract', t('Maximum charater limit is 500 charaters only, please check the length of the description'));
+ } //strlen($form_state['values']['project_title']) > 250
+ else if (strlen($form_state['values']['abstract']) < 300)
+ {
+ form_set_error('abstract', t('Minimum charater limit is 300 charaters, please check the length of the description'));
+ } //strlen($form_state['values']['project_title']) < 10
+ } //$form_state['values']['project_title'] != ''
+ else
+ {
+ form_set_error('description', t('Abstract shoud not be empty'));
+ }
+
+if (isset($_FILES['files']))
+ {
+ /* check if atleast one source or result file is uploaded */
+ /*if (!($_FILES['files']['name']))
+ form_set_error('reference_image', t('Please upload the abstract file.'));*/
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ $allowed_extensions_str = variable_get('reference_image_extensions', '');
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($fnames);
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if valid file name */
+ /*if (!_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));*/
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ }
+ return $form_state;
+}
+function arduino_projects_blog_proposal_form_submit($form, &$form_state)
+{
+ global $user;
+ $root_path = arduino_projects_blog_files_path();
+ if (!$user->uid)
+ {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
+ } //!$user->uid
+ /* inserting the user proposal */
+ $v = $form_state["values"];
+ $project_title = trim($v['project_title']);
+ $proposar_name = $v['contributor_name'];
+ $directory_name = _apb_dir_name($project_title, $proposar_name);
+ list($d, $m, $y) = explode('-', $form_state['values']['expected_date_of_completion']);
+ $expected_completion_date_timestamp = mktime(0, 0, 0, $m, $d, $y);
+ $result = "INSERT INTO {arduino_projects_blog_proposal}
+ (
+ uid,
+ approver_uid,
+ contributor_name,
+ contact_no,
+ university,
+ city,
+ pincode,
+ state,
+ country,
+ position,
+ how_did_you_hear_about_us,
+ project_title,
+ abstract,
+ reference,
+ directory_name,
+ approval_status,
+ is_completed,
+ dissapproval_reason,
+ creation_date,
+ expected_date_of_completion,
+ approval_date
+ ) VALUES
+ (
+ :uid,
+ :approver_uid,
+ :contributor_name,
+ :contact_no,
+ :university,
+ :city,
+ :pincode,
+ :state,
+ :country,
+ :position,
+ :how_did_you_hear_about_us,
+ :project_title,
+ :abstract,
+ :reference,
+ :directory_name,
+ :approval_status,
+ :is_completed,
+ :dissapproval_reason,
+ :creation_date,
+ :expected_date_of_completion,
+ :approval_date
+ )";
+ $args = array(
+ ":uid" => $user->uid,
+ ":approver_uid" => 0,
+ ":contributor_name" => _df_sentence_case(trim($v['contributor_name'])),
+ ":contact_no" => $v['contributor_contact_no'],
+ ":university" => _df_sentence_case($v['university']),
+ ":city" => $v['city'],
+ ":pincode" => $v['pincode'],
+ ":state" => $v['all_state'],
+ ":country" => $v['country'],
+ ":position" => $v['position'],
+ ":how_did_you_hear_about_us" => $v['how_did_you_hear_about_us'],
+ ":project_title" => $v['project_title'],
+ ":abstract" => _df_sentence_case($v['abstract']),
+ ":reference" => $v['reference'],
+ ":directory_name" => $directory_name,
+ ":approval_status" => 0,
+ ":is_completed" => 0,
+ ":dissapproval_reason" => "NULL",
+ ":creation_date" => time(),
+ ":expected_date_of_completion" => $expected_completion_date_timestamp,
+ ":approval_date" => 0
+ );
+ // var_dump($args);die;
+ //var_dump($result);die;
+ $proposal_id = db_query($result, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ $proposal_dir_path = $directory_name . '/';
+ $dest_path = $proposal_dir_path . 'proposal_images/';
+ //var_dump($dest_path1);die;
+ if (!is_dir($root_path . $proposal_dir_path))
+ mkdir($root_path . $proposal_dir_path);
+ //var_dump($root_path . $proposal_dir_path);die;
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ //var_dump($root_path . $dest_path);die;
+ $imageupload = 0;
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) {
+ drupal_set_message(t("Error uploading file. File !filename already exists."), array(
+ '!filename' => $_FILES['files']['name'][$file_form_name]
+ ), 'error');
+ return;
+ }
+ /* uploading file */
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) {
+ $imagequery = "INSERT INTO arduino_projects_blog_proposal_images(proposal_id,name,path) VALUES
+ (:proposal_id,:name, :path)";
+ $imageargs = array(
+ ":proposal_id" => $proposal_id,
+ ":name" => $_FILES['files']['name'][$file_form_name],
+ ":path" => $dest_path . $_FILES['files']['name'][$file_form_name]
+ );
+ /* storing the row id in $result */
+ $imageresult = db_query($imagequery, $imageargs, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if ($imageresult != 0) {
+ $imageupload++;
+ }
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ }
+ else {
+ drupal_set_message($file_name . $dest_path . t('was having an error while uploading :') , 'error');
+ }
+ }
+ }
+ if (!$result && $imageupload == 0) {
+ drupal_set_message(t("Something went wrong, please try again."), "error");
+ }
+ else if ($imageupload != 0) {
+ drupal_set_message(t("Reference Images are added successfully"), "status");
+ }
+ if (!$proposal_id)
+ {
+ drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
+ return;
+ } //!$proposal_id
+ /* sending email */
+ $email_to = $user->mail;
+ $form = variable_get('arduino_projects_blog_from_email', '');
+ $bcc = variable_get('arduino_projects_blog_bcc_emails', '');
+ $cc = variable_get('arduino_projects_blog_cc_emails', '');
+ $params['arduino_projects_blog_proposal_received']['proposal_id'] = $proposal_id;
+ $params['arduino_projects_blog_proposal_received']['user_id'] = $user->uid;
+ $params['arduino_projects_blog_proposal_received']['headers'] = array(
+ 'From' => $form,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('arduino_projects_blog', 'arduino_projects_blog_proposal_received', $email_to, user_preferred_language($user), $params, $form, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message(t('We have received your proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
+
+}
+
+function arduino_projects_blog_my_proposal()
+{
+ global $user;
+ /* get pending proposals to be approved */
+ $my_proposal_rows = array();
+ $query = db_select('arduino_projects_blog_proposal');
+ $query->fields('arduino_projects_blog_proposal');
+ //$query->condition('approval_status', 2);
+ $query->condition('uid',$user->uid);
+ $query->orderBy('id', 'DESC');
+ $my_proposals_q = $query->execute();
+ while ($my_proposals_data = $my_proposals_q->fetchObject())
+ {
+ if($my_proposals_data->approval_status == 2){
+ $action = l('Edit', 'arduino-projects/my-proposals/edit/' . $my_proposals_data->id);
+ }
+ else if($my_proposals_data->approval_status == 1 or $my_proposals_data->approval_status == 3){
+ $action = l('View', 'arduino-projects/my-proposals/view/' . $my_proposals_data->id);
+ }
+ $my_proposal_rows[$my_proposals_data->id] = array(
+ date('d-m-Y', $my_proposals_data->creation_date),
+ l($my_proposals_data->contributor_name, 'user/' . $my_proposals_data->uid),
+ $my_proposals_data->project_title,
+ $action
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$my_proposal_rows)
+ {
+ drupal_set_message(t('There are no proposals to edit.'), 'status');
+ return '';
+ } //!$pending_rows
+ $my_proposal_header = array(
+ 'Date of Submission',
+ 'Contributor Name',
+ 'Title of the Project',
+ 'Action'
+ );
+ //$output = theme_table($pending_header, $pending_rows);
+ $output = theme('table', array(
+ 'header' => $my_proposal_header,
+ 'rows' => $my_proposal_rows
+ ));
+ return $output;
+} \ No newline at end of file
diff --git a/settings.inc b/settings.inc
new file mode 100755
index 0000000..d8f8457
--- /dev/null
+++ b/settings.inc
@@ -0,0 +1,58 @@
+<?php
+// $Id$
+function arduino_projects_blog_settings_form($form, $form_state)
+{
+ $form['bcc_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Bcc) Notification emails'),
+ '#description' => t('Specify emails id for Bcc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('arduino_projects_blog_bcc_emails', '')
+ );
+ $form['cc_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Cc) Notification emails'),
+ '#description' => t('Specify emails id for Cc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('arduino_projects_blog_cc_emails', '')
+ );
+ $form['from_email'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Outgoing from email address'),
+ '#description' => t('Email address to be display in the from field of all outgoing messages'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('arduino_projects_blog_from_email', '')
+ );
+ $form['extensions']['reference_image'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed file extensions for uploading resource files'),
+ '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('reference_image_extensions', '')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
+function arduino_projects_blog_settings_form_validate($form, &$form_state)
+{
+ return;
+}
+function arduino_projects_blog_settings_form_submit($form, &$form_state)
+{
+ variable_set('arduino_projects_blog_bcc_emails', $form_state['values']['bcc_emails']);
+ variable_set('arduino_projects_blog_cc_emails', $form_state['values']['cc_emails']);
+ variable_set('arduino_projects_blog_from_email', $form_state['values']['from_email']);
+ variable_set('reference_image_extensions', $form_state['values']['reference_image']);
+ drupal_set_message(t('Settings updated'), 'status');
+}