summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lab_migration.info6
-rw-r--r--lab_migration.install194
-rw-r--r--lab_migration.module274
-rw-r--r--manage_proposal.inc431
-rw-r--r--migrated_labs.inc73
-rw-r--r--proposal.inc244
-rw-r--r--settings.inc49
-rw-r--r--solution.inc261
8 files changed, 0 insertions, 1532 deletions
diff --git a/lab_migration.info b/lab_migration.info
deleted file mode 100644
index f76bc68..0000000
--- a/lab_migration.info
+++ /dev/null
@@ -1,6 +0,0 @@
-name = Lab Migration
-description = IIT Bombay Lab Migration project
-package = IITB
-version = VERSION
-core = 6.x
-
diff --git a/lab_migration.install b/lab_migration.install
deleted file mode 100644
index 8573b97..0000000
--- a/lab_migration.install
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php
-// $Id$
-
-/**
- * Implementation of hook_install().
- */
-function lab_migration_install()
-{
- // Create tables.
- drupal_install_schema('lab_migration');
- // Set variables
- variable_set('lab_migration_emails', '');
- variable_set('lab_migration_from_email', '');
- variable_set('lab_migration_uploads_extensions', '');
-
- /* creating upload directory */
- if (!is_dir($_SERVER['DOCUMENT_ROOT'] . base_path() . 'sites/default/files/lab_migration/'))
- mkdir($_SERVER['DOCUMENT_ROOT'] . base_path() . 'sites/default/files/lab_migration/');
-}
-
-/**
- * Implementation of hook_uninstall().
- */
-function lab_migration_uninstall()
-{
- // Remove tables.
- drupal_uninstall_schema('lab_migration');
- // Remove variables
- variable_del('lab_migration_emails');
- variable_del('lab_migration_from_email');
- variable_del('lab_migration_uploads_extensions');
-}
-
-/**
- * Implementation of hook_schema().
- */
-function lab_migration_schema()
-{
- $schema['lab_migration_proposal'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approver_uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'solver_uid' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'name_title' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '5',
- 'not null' => TRUE,
- ),
- 'name' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'contact_ph' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '15',
- 'not null' => TRUE,
- ),
- 'department' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'university' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'lab_title' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'problem_topic' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'approval_status' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'length' => '1',
- 'not null' => TRUE,
- ),
- 'solution_status' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'length' => '1',
- 'not null' => TRUE,
- ),
- 'creation_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'approval_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'solution_date' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'message' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'text',
- 'size' => 'medium',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- $schema['lab_migration_files'] = array(
- 'description' => t('TODO: please describe this table!'),
- 'fields' => array(
- 'id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'link_id' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'filename' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'filepath' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '500',
- 'not null' => TRUE,
- ),
- 'filemime' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'filesize' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'filetype' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'varchar',
- 'length' => '1',
- 'not null' => TRUE,
- ),
- 'timestamp' => array(
- 'description' => t('TODO: please describe this field!'),
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('id'),
- );
-
- return $schema;
-}
-
diff --git a/lab_migration.module b/lab_migration.module
deleted file mode 100644
index 8dde472..0000000
--- a/lab_migration.module
+++ /dev/null
@@ -1,274 +0,0 @@
-<?php
-// $Id$
-
-/**
- * Implementation of hook_menu().
- */
-function lab_migration_menu()
-{
- $items = array();
-
- $items['lab_migration/proposal'] = array(
- 'title' => 'Lab Migration Proposal',
- 'description' => 'Lab Migration Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_proposal_form'),
- 'access arguments' => array('create proposal'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'proposal.inc',
- );
-
- $items['lab_migration/labs'] = array(
- 'title' => 'Migrated Labs',
- 'description' => 'Migrated Labs',
- 'page callback' => 'migrated_labs',
- 'access arguments' => array('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'migrated_labs.inc',
- );
-
- /* for reviewers */
- $items['lab_migration/manage_proposal'] = array(
- 'title' => 'Manage Lab Migration',
- 'description' => 'Manage Lab Migration Proposals',
- 'page callback' => '_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('manage proposal'),
- 'file' => 'manage_proposal.inc',
- );
- $items['lab_migration/manage_proposal/pending'] = array(
- 'title' => 'Pending Proposals',
- 'description' => 'Pending Lab Migration Proposals Queue',
- 'page callback' => '_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('manage proposal'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab_migration/manage_proposal/pending_solution'] = array(
- 'title' => 'Pending Solution',
- 'description' => 'Pending Lab Migration Solution',
- 'page callback' => '_proposal_pending_solution',
- 'access callback' => 'user_access',
- 'access arguments' => array('manage proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'solution.inc',
- );
- $items['lab_migration/manage_proposal/all'] = array(
- 'title' => 'All Proposals',
- 'description' => 'All Proposals',
- 'page callback' => '_proposal_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('manage proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab_migration/manage_proposal/approve'] = array(
- 'title' => 'Approve Proposal',
- 'description' => 'Approve Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('proposal_approval_form'),
- 'access arguments' => array('manage proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab_migration/manage_proposal/edit'] = array(
- 'title' => 'Edit Proposal',
- 'description' => 'Edit Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('proposal_edit_form'),
- 'access arguments' => array('manage proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['lab_migration/manage_proposal/solution'] = array(
- 'title' => 'Proposal Solution',
- 'description' => 'Proposal Solution',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('proposal_solution_form'),
- 'access arguments' => array('manage proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'solution.inc',
- );
-
- /* for admin */
- $items['admin/settings/lab_migration'] = array(
- 'title' => 'Lab Migration Settings',
- 'description' => 'Lab Migration Settings',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('lab_migration_settings_form'),
- 'access arguments' => array('administer lab migration'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'settings.inc',
- );
-
- return $items;
-}
-
-/**
- * Implementation of hook_perm().
- */
-function lab_migration_perm()
-{
- return array('create proposal', 'manage proposal', 'administer lab migration');
-}
-
-/**
- * Implementation of hook_mail().
- */
-function lab_migration_mail($key, &$message, $params)
-{
- global $user;
- $language = $message['language'];
- switch ($key) {
- case 'proposal_received':
- /* initializing data */
- $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $user_data = user_load($params['proposal_received']['user_id']);
-
- $message['subject'] = t('[!site_name] Your Lab migration proposal has been received', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have received your proposal to migrate the lab in to Scilab, following details was submitted by you:
-
-Name of the Proposer : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
-Email : ' . $user_data->mail . '
-Contact Phone No. : ' . $proposal_data->contact_ph . '
-Department/Branch : ' . $proposal_data->department . '
-University/Institute : ' . $proposal_data->university . '
-Title of the Lab : ' . $proposal_data->lab_title . '
-Topic of the Problem : ' . $proposal_data->problem_topic . '
-
-Your proposal is under review and you will soon receive an email from us regarding the same.
-
-Best Wishes,
-
-Lab Migration Team
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'proposal_disapproved':
- /* initializing data */
- $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $user_data = user_load($params['proposal_disapproved']['user_id']);
-
- $message['subject'] = t('[!site_name] Your Lab migration proposal has been disapproved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following Lab migration proposal has been disapproved:
-
-Reason for disapproval: ' . $proposal_data->message . '
-
-Name of the Proposer : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
-Email : ' . $user_data->mail . '
-Contact Phone No. : ' . $proposal_data->contact_ph . '
-Department/Branch : ' . $proposal_data->department . '
-University/Institute : ' . $proposal_data->university . '
-Title of the Lab : ' . $proposal_data->lab_title . '
-Topic of the Problem : ' . $proposal_data->problem_topic . '
-
-Best Wishes,
-
-Lab Migration Team
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'proposal_approved':
- /* initializing data */
- $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $user_data = user_load($params['proposal_approved']['user_id']);
-
- $message['subject'] = t('[!site_name] Your Lab migration proposal has been approved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following Lab migration proposal has been approved and solution is in progress. You will receive an email from us as soon as we will upload the solution. Please note that your solution will be made available on the Scilab portal.
-
-Name of the Proposer : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
-Email : ' . $user_data->mail . '
-Contact Phone No. : ' . $proposal_data->contact_ph . '
-Department/Branch : ' . $proposal_data->department . '
-University/Institute : ' . $proposal_data->university . '
-Title of the Lab : ' . $proposal_data->lab_title . '
-Topic of the Problem : ' . $proposal_data->problem_topic . '
-
-Best Wishes,
-
-Lab Migration Team
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'solution_uploaded':
- /* initializing data */
- $dl_root_path = 'sites/default/files/lab_migration/';
- $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_uploaded']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $sol_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A' LIMIT 1", $params['solution_uploaded']['proposal_id']);
- $sol_data = db_fetch_object($sol_q);
-
- $user_data = user_load($params['solution_uploaded']['user_id']);
-
- $message['subject'] = t('[!site_name] Solution of problem statement submitted by you', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have uploaded the solutions of problem statement submitted by you, solution is available at following link.
-
-http://scilab.in/' . $dl_root_path . $sol_data->filepath . '
-
-Name of the Proposer : ' . $proposal_data->name_title . ' ' . $proposal_data->name . '
-Email : ' . $user_data->mail . '
-Contact Phone No. : ' . $proposal_data->contact_ph . '
-Department/Branch : ' . $proposal_data->department . '
-University/Institute : ' . $proposal_data->university . '
-Title of the Lab : ' . $proposal_data->lab_title . '
-Topic of the Problem : ' . $proposal_data->problem_topic . '
-Solution : ' . 'http://scilab.in/' . $dl_root_path . $sol_data->filepath . '
-
-Please feel free to contact us for any further clarifications.
-
-Best Wishes,
-
-Lab Migration Team
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'standard':
- $message['subject'] = $params['standard']['subject'];
- $message['body'] = $params['standard']['body'];
- break;
- }
-}
-
-/******************************************************************************/
-/**************************** GENERAL FUNCTION ********************************/
-/******************************************************************************/
-
-function lab_migration_path()
-{
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'sites/default/files/lab_migration/';
-}
-
-/******************************************************************************/
-/*************************** VALIDATION FUNCTIONS *****************************/
-/******************************************************************************/
-
-function lab_migration_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;
-}
-
diff --git a/manage_proposal.inc b/manage_proposal.inc
deleted file mode 100644
index 71ec5b0..0000000
--- a/manage_proposal.inc
+++ /dev/null
@@ -1,431 +0,0 @@
-<?php
-// $Id$
-
-function _proposal_pending()
-{
- /* get pending proposals to be approved */
- $pending_rows = array();
- $pending_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 0 ORDER BY id DESC");
- while ($pending_data = db_fetch_object($pending_q)) {
- $pending_rows[$pending_data->id] = array(date('d-m-Y', $pending_data->creation_date), l($pending_data->name_title . ' ' . $pending_data->name, 'user/' . $pending_data->uid), $pending_data->department, $pending_data->university, $pending_data->lab_title, l('Approve', 'lab_migration/manage_proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'lab_migration/manage_proposal/edit/' . $pending_data->id));
- }
-
- /* check if there are any pending proposals */
- if (!$pending_rows) {
- drupal_set_message(t('There are no pending proposals.'), 'status');
- return '';
- }
-
- $pending_header = array('Date of Submission', 'Name of the Proposer', 'Department/Branch', 'University/Institute', 'Title of the Lab', 'Action');
- $output = theme_table($pending_header, $pending_rows);
- return $output;
-}
-
-function _proposal_all()
-{
- /* get pending proposals to be approved */
- $proposal_rows = array();
- $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} ORDER BY id DESC");
- while ($proposal_data = db_fetch_object($proposal_q)) {
- $proposal_status = '';
- switch ($proposal_data->approval_status) {
- case 0: $proposal_status = 'Pending'; break;
- case 1: $proposal_status = 'Approved'; break;
- case 2: $proposal_status = 'Dis-approved'; break;
- default: $proposal_status = 'Unknown'; break;
- }
- if ($proposal_data->solution_status == 1) {
- $proposal_status = 'Migrated';
- $proposal_rows[] = array(date('d-m-Y', $proposal_data->creation_date), l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid), $proposal_data->department, $proposal_data->university, $proposal_data->lab_title, $proposal_status, l('Reupload Solution', 'lab_migration/manage_proposal/solution/' . $proposal_data->id) . ' | ' . l('Edit', 'lab_migration/manage_proposal/edit/' . $proposal_data->id));
- } else {
- $proposal_rows[] = array(date('d-m-Y', $proposal_data->creation_date), l($proposal_data->name_title . ' ' . $proposal_data->name, 'user/' . $proposal_data->uid), $proposal_data->department, $proposal_data->university, $proposal_data->lab_title, $proposal_status, l('Approve', 'lab_migration/manage_proposal/approve/' . $proposal_data->id) . ' | ' . l('Edit', 'lab_migration/manage_proposal/edit/' . $proposal_data->id));
- }
- }
-
- /* check if there are any pending proposals */
- if (!$proposal_rows) {
- drupal_set_message(t('There are no proposals.'), 'status');
- return '';
- }
-
- $proposal_header = array('Date of Submission', 'Name of the Proposer', 'Department/Branch', 'University/Institute', 'Title of the Lab', 'Status', 'Action');
- $output = theme_table($proposal_header, $proposal_rows);
- return $output;
-}
-
-/******************************************************************************/
-/************************** PROPOSAL APPROVAL FORM ****************************/
-/******************************************************************************/
-
-function proposal_approval_form($form_state)
-{
- global $user;
- $dl_root_path = 'sites/default/files/lab_migration/';
-
- /* get current proposal */
- $proposal_id = arg(3);
- $result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- if (!($row = db_fetch_object($result))) {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
- if ($row->solution_status != 0) {
- drupal_set_message(t('Cannot change approval status of solved approval.'), 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
-
- $form['name_title'] = array(
- '#type' => 'item',
- '#value' => $row->name_title,
- '#title' => t('Title'),
- );
- $form['name'] = array(
- '#type' => 'item',
- '#value' => l($row->name, 'user/' . $row->uid),
- '#title' => t('Name of the Proposer'),
- );
- $form['email'] = array(
- '#type' => 'item',
- '#value' => user_load($row->uid)->mail,
- '#title' => t('Email'),
- );
- $form['contact_ph'] = array(
- '#type' => 'item',
- '#value' => $row->contact_ph,
- '#title' => t('Contact Phone No.'),
- );
- $form['department'] = array(
- '#type' => 'item',
- '#value' => $row->department,
- '#title' => t('Department/Branch'),
- );
- $form['university'] = array(
- '#type' => 'item',
- '#value' => $row->university,
- '#title' => t('University/Institute'),
- );
- $form['lab_title'] = array(
- '#type' => 'item',
- '#value' => $row->lab_title,
- '#title' => t('Title of the Lab'),
- );
- $form['problem_topic'] = array(
- '#type' => 'item',
- '#value' => $row->problem_topic,
- '#title' => t('Topic of the Problem'),
- );
-
- $problem_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'P'", $row->id);
- $problem_file_data = db_fetch_object($problem_file_q);
- if ($problem_file_data) {
- $form['problem_file'] = array(
- '#type' => 'item',
- '#value' => l($problem_file_data->filename, $dl_root_path . $problem_file_data->filepath),
- '#title' => t('Problem statement'),
- );
- }
-
- $sup_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'S'", $row->id);
- $sup_file_data = db_fetch_object($sup_file_q);
- if ($sup_file_data) {
- $form['supplementary_file'] = array(
- '#type' => 'item',
- '#value' => l($sup_file_data->filename, $dl_root_path . $sup_file_data->filepath),
- '#title' => t('Supplementary file'),
- );
- }
-
- if ($row->approval_status > 0) {
- $form['approval'] = array(
- '#type' => 'radios',
- '#title' => t('Lab migration proposal'),
- '#options' => array('1' => 'Approve', '2' => 'Disapprove'),
- '#required' => TRUE,
- '#default_value' => $row->approval_status,
- );
- $approver_user_data = user_load($row->approver_uid );
- $form['approval_details'] = array(
- '#type' => 'item',
- '#value' => 'By : ' . l($approver_user_data->name, 'user/' . $row->approver_uid) . '<br />'
- . 'On : ' . date('d-m-Y', $row->approval_date),
- );
- } else {
- $form['approval'] = array(
- '#type' => 'radios',
- '#title' => t('Lab migration proposal'),
- '#options' => array('1' => 'Approve', '2' => 'Disapprove'),
- '#required' => TRUE,
- );
- }
-
- $form['message'] = array(
- '#type' => 'textarea',
- '#title' => t('Reason for disapproval'),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'lab_migration/manage_proposal'),
- );
-
- return $form;
-}
-
-function proposal_approval_form_submit($form, &$form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = (int)arg(3);
- $result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- if (!($row = db_fetch_object($result))) {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
-
- if ($form_state['values']['approval'] == 1) {
- db_query("UPDATE {lab_migration_proposal} SET approver_uid = %d, approval_date = %d, approval_status = 1 WHERE id = %d", $user->uid, time(), $proposal_id);
-
- /* sending email */
- $user_data = user_load($row->uid);
- $email_to = $user_data->mail;
- $param['proposal_approved']['proposal_id'] = $proposal_id;
- $param['proposal_approved']['user_id'] = $row->uid;
- if (!drupal_mail('lab_migration', 'proposal_approved', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');;
- if (!drupal_mail('lab_migration', 'proposal_approved', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message('Lab migration proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
- drupal_goto('lab_migration/manage_proposal');
- return;
- } else if ($form_state['values']['approval'] == 2) {
- db_query("UPDATE {lab_migration_proposal} SET approver_uid = %d, approval_date = %d, approval_status = 2, message = '%s' WHERE id = %d", $user->uid, time(), $form_state['values']['message'], $proposal_id);
-
- /* sending email */
- $user_data = user_load($row->uid);
- $email_to = $user_data->mail;
- $param['proposal_disapproved']['proposal_id'] = $proposal_id;
- $param['proposal_disapproved']['user_id'] = $row->uid;
- if (!drupal_mail('lab_migration', 'proposal_disapproved', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');;
- if (!drupal_mail('lab_migration', 'proposal_disapproved', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message('Lab migration proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
-}
-
-/******************************************************************************/
-/**************************** PROPOSAL EDIT FORM ******************************/
-/******************************************************************************/
-
-function proposal_edit_form($form_state)
-{
- global $user;
- $dl_root_path = 'sites/default/files/lab_migration/';
-
- /* get current proposal */
- $proposal_id = arg(3);
- $result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- if (!($row = db_fetch_object($result))) {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
-
- $user_data = user_load($proposal_data->uid);
-
- $form['name_title'] = array(
- '#type' => 'select',
- '#title' => t('Title'),
- '#options' => array('Mr' => 'Mr', 'Ms' => 'Ms', 'Mrs' => 'Mrs', 'Dr' => 'Dr', 'Prof' => 'Prof'),
- '#required' => TRUE,
- '#default_value' => $row->name_title,
- );
- $form['name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the Proposer'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $row->name,
- );
- $form['email_id'] = array(
- '#type' => 'item',
- '#title' => t('Email'),
- '#value' => $user->mail,
- );
- $form['contact_ph'] = array(
- '#type' => 'textfield',
- '#title' => t('Contact Phone No.'),
- '#size' => 30,
- '#maxlength' => 15,
- '#required' => TRUE,
- '#default_value' => $row->contact_ph,
- );
- $form['department'] = array(
- '#type' => 'select',
- '#title' => t('Department/Branch'),
- '#options' => array('' => 'Please select...',
- 'Computer Engineering' => 'Computer Engineering',
- 'Electrical Engineering' => 'Electrical Engineering',
- 'Electronics Engineering' => 'Electronics Engineering',
- 'Chemical Engineering' => 'Chemical Engineering',
- 'Instrumentation Engineering' => 'Instrumentation Engineering',
- 'Mechanical Engineering' => 'Mechanical Engineering',
- 'Civil Engineering' => 'Civil Engineering',
- 'Physics' => 'Physics',
- 'Mathematics' => 'Mathematics',
- 'Others' => 'Others'),
- '#required' => TRUE,
- '#default_value' => $row->department,
- );
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/Institute'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $row->university,
- );
- $form['lab_title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the Lab'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $row->lab_title,
- );
- $form['problem_topic'] = array(
- '#type' => 'textfield',
- '#title' => t('Topic of the Problem'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $row->problem_topic,
- );
-
- $problem_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'P'", $row->id);
- $problem_file_data = db_fetch_object($problem_file_q);
- if ($problem_file_data) {
- $form['problem_file'] = array(
- '#type' => 'item',
- '#value' => l($problem_file_data->filename, $dl_root_path . $problem_file_data->filepath),
- '#title' => t('Problem statement'),
- );
- }
-
- $sup_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'S'", $row->id);
- $sup_file_data = db_fetch_object($sup_file_q);
- if ($sup_file_data) {
- $form['supplementary_file'] = array(
- '#type' => 'item',
- '#value' => l($sup_file_data->filename, $dl_root_path . $sup_file_data->filepath),
- '#title' => t('Supplementary file'),
- );
- }
-
- if ($row->solution_status == 1) {
- $sol_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $row->id);
- $sol_file_data = db_fetch_object($sol_file_q);
- if ($sol_file_data) {
- $form['solution_file'] = array(
- '#type' => 'item',
- '#value' => l($sol_file_data->filename, $dl_root_path . $sol_file_data->filepath),
- '#title' => t('Solution file'),
- );
- }
- }
-
- $form['delete_proposal'] = array(
- '#type' => 'checkbox',
- '#title' => t('Delete Proposal')
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'lab_migration/manage_proposal'),
- );
- return $form;
-}
-
-function proposal_edit_form_validate($form, &$form_state)
-{
- /* contact phone */
- if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile']))
- form_set_error('mobile', t('Invalid mobile number'));
- return;
-}
-
-function proposal_edit_form_submit($form, &$form_state)
-{
- $root_path = lab_migration_path();
-
- /* get current proposal */
- $proposal_id = arg(3);
- $result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- if (!($row = db_fetch_object($result))) {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
-
- if ($form_state['values']['delete_proposal'] == 1) {
- $files_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d", $proposal_id);
- while ($file_data = db_fetch_object($files_q)) {
- if (!file_exists($root_path . $file_data->filepath)) {
- drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $file_data->filepath)), 'error');
- return;
- }
- /* removing file */
- if (!unlink($root_path . $file_data->filepath)) {
- drupal_set_message(t('Error deleting !file', array('!file' => $file_data->filepath)), 'error');
- return;
- } else {
- /* deleting example files database entries */
- db_query("DELETE FROM {lab_migration_files} WHERE id = %d", $file_data->id);
- }
- }
- if (!rmdir($root_path . $proposal_id . '/')) {
- drupal_set_message(t('Error deleting !folder', array('!folder' => $root_path . $proposal_id . '/')), 'error');
- return;
- }
- db_query("DELETE FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- drupal_set_message(t('Proposal Delete'), 'status');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
-
- db_query("UPDATE {lab_migration_proposal} SET name_title = '%s', name = '%s', contact_ph = '%s', department = '%s', university = '%s', lab_title = '%s', problem_topic = '%s' WHERE id = %d",
- $form_state['values']['name_title'],
- $form_state['values']['name'],
- $form_state['values']['contact_ph'],
- $form_state['values']['department'],
- $form_state['values']['university'],
- $form_state['values']['lab_title'],
- $form_state['values']['problem_topic'],
- $row->id
- );
- drupal_set_message(t('Proposal Updated'), 'status');
- drupal_goto('lab_migration/manage_proposal');
-}
-
diff --git a/migrated_labs.inc b/migrated_labs.inc
deleted file mode 100644
index 4e5dcdb..0000000
--- a/migrated_labs.inc
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-// $Id$
-
-function migrated_labs()
-{
- global $user;
- $dl_root_path = 'sites/default/files/lab_migration/';
-
- /* get pending proposals to be approved */
- $labs_rows = array();
- $labs_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 ORDER BY id DESC");
- while ($labs_data = db_fetch_object($labs_q)) {
- /* file attachments */
- $file_links = '';
- $problem_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'P'", $labs_data->id);
- $problem_data = db_fetch_object($problem_q);
- $file_links .= '<br/>' . l('Problem Statement', $dl_root_path . $problem_data->filepath);
- $sup_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'S'", $labs_data->id);
- $sup_data = db_fetch_object($sup_q);
- if ($sup_data)
- $file_links .= '<br/>' . l('Suplementary Files', $dl_root_path . $sup_data->filepath);
-
- $migration_status = '';
- if ($labs_data->solution_status == 0) {
- $migration_status = 'In Progress';
- } else if ($labs_data->solution_status == 1) {
- $migration_status = 'Migrated';
- if (($user->uid == $labs_data->uid) || user_access('manage proposal')) {
- $sol_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $labs_data->id);
- $sol_data = db_fetch_object($sol_q);
- $file_links .= '<br/>' . l('Solution File', $dl_root_path . $sol_data->filepath);
- }
- }
-
- $labs_rows[] = array($labs_data->university, $labs_data->lab_title, $labs_data->problem_topic . $file_links, l($labs_data->name_title . ' ' . $labs_data->name, 'user/' . $labs_data->uid) . '<br/>' . $labs_data->department, $migration_status);
- }
-
- /* check if there are any pending proposals */
- //if (!$labs_rows) {
- // drupal_set_message(t('There are no lab migrations.'), 'status');
- // return '';
- //}
-
- $output = "
-<p>
- Labs Migration Project: Do you want to shift your labs from MATLAB&nbsp; to Scilab?<br />
- <br />
- Please get in touch with us at contact@scilab.in and we will help you.</p>
-<p>
- Here are some previous labs that we have shifted from MATLAB to Scilab:</p>
-<h4>
- Delhi University</h4>
-<ol>
- <li>
- <a href='http://scilab.in/files/labs_migration/experiments/Delhi_University/DU-Signals.pdf'>Signals and Systems</a></li>
- <li>
- <a href='http://scilab.in/files/labs_migration/experiments/Delhi_University/DU-Numerical-Methods.pdf'>Numerical Methods</a></li>
-</ol>
-<h4>
- SASTRA University</h4>
-<ol>
- <li>
- Signal Processing</li>
-</ol>
-<p>
- If you are a teacher <strong>and</strong> want access to the codes, please get in touch with us at contact@scilab.in from your official email ID.&nbsp;</p>
- ";
-
- $labs_header = array('University/Institute', 'Title of the Lab', 'Title of the Problem', 'Name of the Proposer and Department', 'Status');
- $output .= theme_table($labs_header, $labs_rows);
- return $output;
-}
-
diff --git a/proposal.inc b/proposal.inc
deleted file mode 100644
index 37bd91c..0000000
--- a/proposal.inc
+++ /dev/null
@@ -1,244 +0,0 @@
-<?php
-// $Id$
-
-function lab_migration_proposal_form($form_state)
-{
- global $user;
-
- if (!$user->uid) {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- $form['#attributes'] = array('enctype' => "multipart/form-data");
-
- $form['name_title'] = array(
- '#type' => 'select',
- '#title' => t('Title'),
- '#options' => array('Mr' => 'Mr', 'Ms' => 'Ms', 'Mrs' => 'Mrs', 'Dr' => 'Dr', 'Prof' => 'Prof'),
- '#required' => TRUE,
- );
- $form['name'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of the Proposer'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Email'),
- '#size' => 30,
- '#value' => $user->mail,
- '#disabled' => TRUE,
- );
- $form['contact_ph'] = array(
- '#type' => 'textfield',
- '#title' => t('Contact Phone No.'),
- '#size' => 30,
- '#maxlength' => 15,
- '#required' => TRUE,
- );
- $form['department'] = array(
- '#type' => 'select',
- '#title' => t('Department/Branch'),
- '#options' => array('' => 'Please select...',
- 'Computer Engineering' => 'Computer Engineering',
- 'Electrical Engineering' => 'Electrical Engineering',
- 'Electronics Engineering' => 'Electronics Engineering',
- 'Chemical Engineering' => 'Chemical Engineering',
- 'Instrumentation Engineering' => 'Instrumentation Engineering',
- 'Mechanical Engineering' => 'Mechanical Engineering',
- 'Civil Engineering' => 'Civil Engineering',
- 'Physics' => 'Physics',
- 'Mathematics' => 'Mathematics',
- 'Others' => 'Others'),
- '#required' => TRUE,
- );
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/Institute'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['lab_title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the Lab'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['problem_topic'] = array(
- '#type' => 'textfield',
- '#title' => t('Topic of the Problem'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['problem_file'] = array(
- '#type' => 'file',
- '#title' => t('Upload problem statement'),
- '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_uploads_extensions', ''),
- );
- $form['supplementary_file'] = array(
- '#type' => 'file',
- '#title' => t('Upload supplementary files (eg. existing solution of problem in any other software)'),
- '#description' => t('If more than one file, then compress and upload as .zip or .tar file') . '<br />' .
- t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_uploads_extensions', ''),
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
-}
-
-function lab_migration_proposal_form_validate($form, &$form_state)
-{
- if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['contact_ph']))
- form_set_error('mobile', t('Invalid contact phone number'));
-
- if ( ! ($_FILES['files']['name']['problem_file'])) {
- form_set_error('problem_file', t('Problem statement file is required.'));
- } else {
- $allowed_extensions_str = variable_get('lab_migration_uploads_extensions', '');
- $allowed_extensions = explode(',' , $allowed_extensions_str);
- $temp_extension = end(explode('.', strtolower($_FILES['files']['name']['problem_file'])));
- if (!in_array($temp_extension, $allowed_extensions))
- form_set_error('problem_file', t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
- if ($_FILES['files']['size']['problem_file'] <= 0)
- form_set_error('problem_file', t('File size cannot be zero.'));
-
- /* check if valid file name */
- if (!lab_migration_check_valid_filename($_FILES['files']['name']['problem_file']))
- form_set_error('problem_file', t('Invalid file name specified. Only alphabets, numbers and underscore is allowed as a valid filename.'));
- }
-
- if ($_FILES['files']['name']['supplementary_file']) {
- $allowed_extensions_str = variable_get('lab_migration_uploads_extensions', '');
- $allowed_extensions = explode(',' , $allowed_extensions_str);
- $temp_extension = end(explode('.', strtolower($_FILES['files']['name']['supplementary_file'])));
- if (!in_array($temp_extension, $allowed_extensions))
- form_set_error('supplementary_file', t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
- if ($_FILES['files']['size']['supplementary_file'] <= 0)
- form_set_error('supplementary_file', t('File size cannot be zero.'));
-
- /* check if valid file name */
- if (!lab_migration_check_valid_filename($_FILES['files']['name']['supplementary_file']))
- form_set_error('supplementary_file', t('Invalid file name specified. Only alphabets, numbers and underscore is allowed as a valid filename.'));
-
- /* if file already exists */
- if ($_FILES['files']['name']['problem_file'] == $_FILES['files']['name']['supplementary_file']) {
- form_set_error('supplementary_file', t('Supplementary file cannot be same as the problem statement file.'));
- }
- }
- return;
-}
-
-function lab_migration_proposal_form_submit($form, &$form_state)
-{
- global $user;
-
- if (!$user->uid) {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- $root_path = lab_migration_path();
-
- /* inserting the user proposal */
- $result = db_query("INSERT INTO {lab_migration_proposal}
- (uid, approver_uid, solver_uid, name_title, name, contact_ph, department, university, lab_title, problem_topic, approval_status, solution_status, creation_date, approval_date, solution_date) VALUES
- (%d, %d, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, %d, %d, 0)",
- $user->uid,
- 0,
- $form_state['values']['name_title'],
- $form_state['values']['name'],
- $form_state['values']['contact_ph'],
- $form_state['values']['department'],
- $form_state['values']['university'],
- $form_state['values']['lab_title'],
- $form_state['values']['problem_topic'],
- 0,
- time(),
- 0
- );
- if (!$result)
- {
- drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
- return;
- }
- /* proposal id */
- $proposal_id = db_last_insert_id('lab_migration_proposal', 'id');
-
- /************** uploading file *******************/
- /* creating directories */
- $dest_path = $proposal_id . '/';
- if (!is_dir($root_path . $dest_path))
- mkdir($root_path . $dest_path);
-
- if (file_exists($root_path . $dest_path . $_FILES['files']['name']['problem_file']))
- {
- drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name']['problem_file'])), 'error');
- return;
- }
-
- /* uploading file */
- $filename = $_FILES['files']['name']['problem_file'];
- if (move_uploaded_file($_FILES['files']['tmp_name']['problem_file'], $root_path . $dest_path . $filename))
- {
- /* for uploaded files making an entry in the database */
- db_query("INSERT INTO {lab_migration_files} (link_id, filename, filepath, filemime, filesize, filetype, timestamp)
- VALUES (%d, '%s', '%s', '%s', %d, '%s', %d)",
- $proposal_id,
- $filename,
- $dest_path . $filename,
- $_FILES['files']['type']['problem_file'],
- $_FILES['files']['size']['problem_file'],
- 'P',
- time()
- );
- } else {
- drupal_set_message('Error uploading file : ' . $dest_path . '/' . $filename, 'error');
- }
-
- /* uploading file */
- if ($_FILES['files']['name']['supplementary_file']) {
- $filename = $_FILES['files']['name']['supplementary_file'];
- if (move_uploaded_file($_FILES['files']['tmp_name']['supplementary_file'], $root_path . $dest_path . $filename))
- {
- /* for uploaded files making an entry in the database */
- db_query("INSERT INTO {lab_migration_files} (link_id, filename, filepath, filemime, filesize, filetype, timestamp)
- VALUES (%d, '%s', '%s', '%s', %d, '%s', %d)",
- $proposal_id,
- $filename,
- $dest_path . $filename,
- $_FILES['files']['type']['supplementary_file'],
- $_FILES['files']['size']['supplementary_file'],
- 'S',
- time()
- );
- } else {
- drupal_set_message('Error uploading file : ' . $dest_path . '/' . $filename, 'error');
- }
- }
-
- /* sending email */
- $email_to = $user->mail;
- $param['proposal_received']['proposal_id'] = $proposal_id;
- $param['proposal_received']['user_id'] = $user->uid;
- if (!drupal_mail('lab_migration', 'proposal_received', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- /* sending email */
- $email_to = variable_get('lab_migration_emails', '');
- if (!drupal_mail('lab_migration', 'proposal_received', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message(t('We have received you lab migration proposal. We will get back to you soon.'), 'status');
- drupal_goto('');
-}
-
diff --git a/settings.inc b/settings.inc
deleted file mode 100644
index e7dcd39..0000000
--- a/settings.inc
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-// $Id$
-
-function lab_migration_settings_form($form_state)
-{
- $form['emails'] = array(
- '#type' => 'textfield',
- '#title' => t('Notification emails'),
- '#description' => t('A comma separated list of email addresses to receive notifications emails'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_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('lab_migration_from_email', ''),
- );
-
- $form['upload_extensions'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed source file extensions'),
- '#description' => t('A comma separated list WITHOUT SPACE of file extensions that are permitted to be uploaded on the server'),
- '#size' => 50,
- '#maxlength' => 255,
- '#required' => TRUE,
- '#default_value' => variable_get('lab_migration_uploads_extensions', ''),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
-}
-
-function lab_migration_settings_form_submit($form, &$form_state)
-{
- variable_set('lab_migration_emails', $form_state['values']['emails']);
- variable_set('lab_migration_from_email', $form_state['values']['from_email']);
- variable_set('lab_migration_uploads_extensions', $form_state['values']['upload_extensions']);
- drupal_set_message(t('Settings updated'), 'status');
-}
diff --git a/solution.inc b/solution.inc
deleted file mode 100644
index 143776b..0000000
--- a/solution.inc
+++ /dev/null
@@ -1,261 +0,0 @@
-<?php
-// $Id$
-
-function _proposal_pending_solution()
-{
- /* get pending proposals to be approved */
- $pending_rows = array();
- $pending_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE approval_status = 1 AND solution_status = 0 ORDER BY id DESC");
- while ($pending_data = db_fetch_object($pending_q)) {
- $pending_rows[$pending_data->id] = array(date('d-m-Y', $pending_data->creation_date), l($pending_data->name_title . ' ' . $pending_data->name, 'user/' . $pending_data->uid), $pending_data->department, $pending_data->university, $pending_data->lab_title, l('Upload Solution', 'lab_migration/manage_proposal/solution/' . $pending_data->id));
- }
-
- /* check if there are any pending proposals */
- if (!$pending_rows) {
- drupal_set_message(t('There are no pending proposals to be solved.'), 'status');
- return '';
- }
-
- $pending_header = array('Date of Submission', 'Name of the Proposer', 'Department/Branch', 'University/Institute', 'Title of the Lab', 'Action');
- $output = theme_table($pending_header, $pending_rows);
- return $output;
-}
-
-/******************************************************************************/
-/************************** PROPOSAL SOLUTION FORM ****************************/
-/******************************************************************************/
-
-function proposal_solution_form($form_state)
-{
- global $user;
- $dl_root_path = 'sites/default/files/lab_migration/';
-
- /* get current proposal */
- $proposal_id = arg(3);
- $result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- if (!($row = db_fetch_object($result))) {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab_migration/manage_proposal/pending_proposal');
- return;
- }
- if ($row->approval_status != 1) {
- drupal_set_message(t('Selected Proposal has not been approved yet.'), 'error');
- drupal_goto('lab_migration/manage_proposal/pending_proposal');
- return;
- }
- if ($row->solution_status != 0) {
- drupal_set_message(t('Selected Proposal has already been solved. You can reupload a new solution.'), 'status');
- }
-
- $form['#attributes'] = array('enctype' => "multipart/form-data");
-
- $form['name_title'] = array(
- '#type' => 'item',
- '#value' => $row->name_title,
- '#title' => t('Title'),
- );
- $form['name'] = array(
- '#type' => 'item',
- '#value' => l($row->name, 'user/' . $row->uid),
- '#title' => t('Name of the Proposer'),
- );
- $form['email'] = array(
- '#type' => 'item',
- '#value' => user_load($row->uid)->mail,
- '#title' => t('Email'),
- );
- $form['contact_ph'] = array(
- '#type' => 'item',
- '#value' => $row->contact_ph,
- '#title' => t('Contact Phone No.'),
- );
- $form['department'] = array(
- '#type' => 'item',
- '#value' => $row->department,
- '#title' => t('Department/Branch'),
- );
- $form['university'] = array(
- '#type' => 'item',
- '#value' => $row->university,
- '#title' => t('University/Institute'),
- );
- $form['lab_title'] = array(
- '#type' => 'item',
- '#value' => $row->lab_title,
- '#title' => t('Title of the Lab'),
- );
- $form['problem_topic'] = array(
- '#type' => 'item',
- '#value' => $row->problem_topic,
- '#title' => t('Topic of the Problem'),
- );
-
- $problem_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'P'", $row->id);
- $problem_file_data = db_fetch_object($problem_file_q);
- if ($problem_file_data) {
- $form['problem_file'] = array(
- '#type' => 'item',
- '#value' => l($problem_file_data->filename, $dl_root_path . $problem_file_data->filepath),
- '#title' => t('Problem statement'),
- );
- }
-
- $sup_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'S'", $row->id);
- $sup_file_data = db_fetch_object($sup_file_q);
- if ($sup_file_data) {
- $form['supplementary_file'] = array(
- '#type' => 'item',
- '#value' => l($sup_file_data->filename, $dl_root_path . $sup_file_data->filepath),
- '#title' => t('Supplementary file'),
- );
- }
-
- $approver_user_data = user_load($row->approver_uid );
- $form['approval_details'] = array(
- '#type' => 'item',
- '#value' => 'By : ' . l($approver_user_data->name, 'user/' . $row->approver_uid) . '<br />'
- . 'On : ' . date('d-m-Y', $row->approval_date),
- );
-
- $sol_file_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $row->id);
- $sol_file_data = db_fetch_object($sol_file_q);
- if ($sol_file_data) {
- $form['sol_file'] = array(
- '#type' => 'item',
- '#value' => l($sol_file_data->filename, $dl_root_path . $sol_file_data->filepath),
- '#title' => t('Solution file'),
- );
- }
-
- $form['solution_file'] = array(
- '#type' => 'file',
- '#title' => t('Upload solution statement'),
- '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' .
- t('Allowed file extensions : ') . variable_get('lab_migration_uploads_extensions', ''),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'lab_migration/manage_proposal/pending_solution'),
- );
-
- return $form;
-}
-
-function proposal_solution_form_validate($form, &$form_state)
-{
- $proposal_id = arg(3);
-
- if ( ! ($_FILES['files']['name']['solution_file'])) {
- form_set_error('problem_file', t('Solution statement file is required.'));
- } else {
- $allowed_extensions_str = variable_get('lab_migration_uploads_extensions', '');
- $allowed_extensions = explode(',' , $allowed_extensions_str);
- $temp_extension = end(explode('.', strtolower($_FILES['files']['name']['solution_file'])));
- if (!in_array($temp_extension, $allowed_extensions))
- form_set_error('solution_file', t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
- if ($_FILES['files']['size']['solution_file'] <= 0)
- form_set_error('solution_file', t('File size cannot be zero.'));
-
- /* check if valid file name */
- if (!lab_migration_check_valid_filename($_FILES['files']['name']['solution_file']))
- form_set_error('solution_file', t('Invalid file name specified. Only alphabets, numbers and underscore is allowed as a valid filename.'));
-
- /* if file already exists */
- $file_exists_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filename = '%s'", $proposal_id, $_FILES['files']['name']['solution_file']);
- if (db_fetch_object($file_exists_q))
- form_set_error('solution_file', t('File with the same name already exists. Please rename the solution file and try again.'));
- }
- return;
-}
-
-function proposal_solution_form_submit($form, &$form_state)
-{
- global $user;
- $root_path = lab_migration_path();
-
- /* get current proposal */
- $proposal_id = (int)arg(3);
- $result = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id);
- if (!($row = db_fetch_object($result))) {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('lab_migration/manage_proposal');
- return;
- }
- if ($row->approval_status != 1) {
- drupal_set_message(t('Selected Proposal has not been approved yet.'), 'error');
- drupal_goto('lab_migration/manage_proposal/pending_solution');
- return;
- }
-
- if ($row->solution_status == 1) {
- $files_q = db_query("SELECT * FROM {lab_migration_files} WHERE link_id = %d AND filetype = 'A'", $proposal_id);
- while ($file_data = db_fetch_object($files_q)) {
- if (!file_exists($root_path . $file_data->filepath)) {
- drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $file_data->filepath)), 'error');
- return;
- }
- /* removing file */
- if (!unlink($root_path . $file_data->filepath)) {
- drupal_set_message(t('Error deleting !file', array('!file' => $file_data->filepath)), 'error');
- return;
- } else {
- /* deleting example files database entries */
- db_query("DELETE FROM {lab_migration_files} WHERE id = %d", $file_data->id);
- }
- }
- }
-
- /************** uploading file *******************/
- /* creating directories */
- $dest_path = $proposal_id . '/';
- if (!is_dir($root_path . $dest_path))
- mkdir($root_path . $dest_path);
-
- if (file_exists($root_path . $dest_path . $_FILES['files']['name']['solution_file']))
- {
- drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name']['solution_file'])), 'error');
- return;
- }
-
- /* uploading file */
- $filename = $_FILES['files']['name']['solution_file'];
- if (move_uploaded_file($_FILES['files']['tmp_name']['solution_file'], $root_path . $dest_path . $filename))
- {
- /* for uploaded files making an entry in the database */
- db_query("INSERT INTO {lab_migration_files} (link_id, filename, filepath, filemime, filesize, filetype, timestamp)
- VALUES (%d, '%s', '%s', '%s', %d, '%s', %d)",
- $proposal_id,
- $filename,
- $dest_path . $filename,
- $_FILES['files']['type']['solution_file'],
- $_FILES['files']['size']['solution_file'],
- 'A',
- time()
- );
-
- db_query("UPDATE {lab_migration_proposal} SET solution_status = 1, solver_uid = %d, solution_date = %d WHERE id = %d", $user->uid, time(), $proposal_id);
- } else {
- drupal_set_message('Error uploading file : ' . $dest_path . '/' . $filename, 'error');
- }
-
- /* sending email */
- $user_data = user_load($row->uid);
- $email_to = $user_data->mail;
- $param['solution_uploaded']['proposal_id'] = $proposal_id;
- $param['solution_uploaded']['user_id'] = $row->uid;
- if (!drupal_mail('lab_migration', 'solution_uploaded', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- $email_to = variable_get('textbook_companion_emails', '');;
- if (!drupal_mail('lab_migration', 'solution_uploaded', $email_to , language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_goto('lab_migration/manage_proposal/pending_solution');
-}
-