'Lab Migration Proposal', 'description' => 'Lab Migration Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_proposal_form' ), 'access arguments' => array( 'lab migration create proposal' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'proposal.inc' ); $items['lab-migration/manage-proposal'] = array( 'title' => 'LM Manage Lab Proposals', 'description' => 'Manage Lab Migration Proposals', 'page callback' => 'lab_migration_proposal_pending', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration manage proposal' ), 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/pending'] = array( 'title' => 'Pending Proposals', 'description' => 'Pending Lab Migration Proposals Queue', 'page callback' => 'lab_migration_proposal_pending', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 1, 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/pending-solution-proposal'] = array( 'title' => 'Pending Solution Proposals', 'description' => 'Pending Lab Migration Solution Proposals Queue', 'page callback' => 'lab_migration_solution_proposal_pending', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'manage_solution_proposal.inc' ); $items['lab-migration/manage-proposal/pending-solution'] = array( 'title' => 'Pending Solution', 'description' => 'Pending Lab Migration Solution', 'page callback' => 'lab_migration_proposal_pending_solution', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_LOCAL_TASK, 'weight' => 3, 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/all'] = array( 'title' => 'All Proposals', 'description' => 'All Proposals', 'page callback' => 'lab_migration_proposal_all', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_LOCAL_TASK, 'weight' => 4, 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/category'] = array( 'title' => 'Category', 'description' => 'Category', 'page callback' => 'lab_migration_category_all', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_LOCAL_TASK, 'weight' => 5, 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/category/edit'] = array( 'title' => 'Edit Category', 'description' => 'Edit category', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_category_edit_form' ), 'access arguments' => array( 'lab migration edit proposal' ), 'type' => MENU_CALLBACK, '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( 'lab_migration_proposal_approval_form' ), 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/solution-proposal-approve'] = array( 'title' => 'Approve Solution Proposal', 'description' => 'Approve Solution Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_solution_proposal_approval_form' ), 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_solution_proposal.inc' ); $items['lab-migration/manage-proposal/edit'] = array( 'title' => 'Edit Proposal', 'description' => 'Edit Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_proposal_edit_form' ), 'access arguments' => array( 'lab migration manage proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); $items['lab-migration/manage-proposal/status'] = array( 'title' => 'Proposal Status', 'description' => 'Proposal Status', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_proposal_status_form' ), 'access arguments' => array( 'lab migration approve proposal' ), 'type' => MENU_CALLBACK, 'file' => 'manage_proposal.inc' ); /* SOLUTION PROPOSAL */ $items['lab-migration/open-proposal'] = array( 'title' => 'Lab Migration Solve', 'description' => 'Lab Migration Proposal Open For Solution', 'page callback' => 'lab_migration_proposal_open', 'access arguments' => array( 'lab migration propose solution' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'solution_proposal.inc' ); $items['lab-migration/show-proposal'] = array( 'title' => 'Lab Migration Solution Proposal', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_solution_proposal_form' ), 'access arguments' => array( 'lab migration propose solution' ), 'type' => MENU_CALLBACK, 'file' => 'solution_proposal.inc' ); /* CODE REVIEW */ $items['lab-migration/code-approval'] = array( 'title' => 'LM Manage Code Approval', 'description' => 'Manage Code Approval', 'page callback' => 'lab_migration_code_approval', 'access arguments' => array( 'lab migration approve code' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'code_approval.inc' ); $items['lab-migration/code-approval/approve'] = array( 'title' => 'Code Approval', 'description' => 'Code Approval', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_code_approval_form' ), 'access arguments' => array( 'lab migration approve code' ), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 1, 'file' => 'code_approval.inc' ); $items['lab-migration/code-approval/bulk'] = array( 'title' => 'Bulk Manage', 'description' => 'Bulk Mangage', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_bulk_approval_form' ), 'access arguments' => array( 'lab migration bulk manage code' ), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'bulk_approval.inc' ); $items['lab-migration/code-approval/bulk'] = array( 'title' => 'Bulk Manage', 'description' => 'Bulk Mangage', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_bulk_approval_form' ), 'access arguments' => array( 'lab migration bulk manage code' ), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'bulk_approval.inc' ); /*$items['lab_migration/code_approval/dependency'] = array( 'title' => 'Dependency', 'description' => 'Dependency Mangage', 'page callback' => 'drupal_get_form', 'page arguments' => array('lab_migration_dependency_approval_form'), 'access arguments' => array('lab migration bulk manage code'), 'type' => MENU_LOCAL_TASK, 'weight' => 3, 'file' => 'dependency_approval.inc', );*/ $items['lab-migration/code-approval/upload'] = array( 'title' => 'Upload Code', 'description' => 'Admin Upload', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_bulk_upload_code_form' ), 'access arguments' => array( 'lab migration bulk manage code' ), 'type' => MENU_CALLBACK, 'weight' => 4, 'file' => 'bulk_upload_code.inc' ); $items['lab-migration/code-approval/notes'] = array( 'title' => 'Notes for Reviewers', 'description' => 'Notes for Reviewers', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_lab_notes_form' ), 'access arguments' => array( 'lab migration bulk manage code' ), 'type' => MENU_CALLBACK, 'weight' => 4, 'file' => 'notes.inc' ); /* CODE UPLOAD */ $items['lab-migration/code'] = array( 'title' => 'Code Submission', 'description' => 'Code Submission', 'page callback' => 'lab_migration_list_experiments', 'access callback' => 'user_access', 'access arguments' => array( 'lab migration upload code' ), 'file' => 'upload_code.inc' ); $items['lab-migration/code/list-experiments'] = array( 'title' => 'List Experiments', 'description' => 'List Experiments', 'page callback' => 'lab_migration_list_experiments', 'access arguments' => array( 'lab migration upload code' ), 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'upload_code.inc', 'weight' => 1 ); $items['lab-migration/code/upload'] = array( 'title' => 'Code Submission', 'description' => 'Code Submission', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_upload_code_form' ), 'access arguments' => array( 'lab migration upload code' ), 'type' => MENU_LOCAL_TASK, 'file' => 'upload_code.inc', 'weight' => 2 ); /* $items['lab_migration/code/upload_dep'] = array( 'title' => 'Upload Dependency', 'description' => 'Upload Dependency Files', 'page callback' => 'drupal_get_form', 'page arguments' => array('lab_migration_upload_dependency_form'), 'access arguments' => array('lab migration upload code'), 'type' => MENU_LOCAL_TASK, 'file' => 'dependency.inc', 'weight' => 3, );*/ $items['lab-migration/code/delete'] = array( 'title' => 'Delete Solution', 'description' => 'Delete Solution', 'page callback' => 'lab_migration_upload_code_delete', 'access arguments' => array( 'lab migration upload code' ), 'type' => MENU_CALLBACK, 'file' => 'upload_code_delete.inc' ); /* CODE DOWNLOADS */ $items['lab-migration/download/file'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_solution_file', 'access arguments' => array( 'lab migration download code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); /*$items['lab_migration/download/dependency'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_dependency_file', 'access arguments' => array('lab migration download code'), 'type' => MENU_CALLBACK, 'file' => 'download.inc', );*/ $items['lab-migration/download/solution'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_solution', 'access arguments' => array( 'lab migration download code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['lab-migration/download/experiment'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_experiment', 'access arguments' => array( 'lab migration download code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['lab-migration/download/lab'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_lab', 'access arguments' => array( 'lab migration download code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); $items['lab-migration/full-download/experiment'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_full_experiment', 'access arguments' => array( 'lab migration approve code' ), 'type' => MENU_CALLBACK, 'file' => 'full_download.inc' ); $items['lab-migration/full-download/lab'] = array( 'title' => 'Code Download', 'description' => 'Code Download', 'page callback' => 'lab_migration_download_full_lab', 'access arguments' => array( 'lab migration approve code' ), 'type' => MENU_CALLBACK, 'file' => 'full_download.inc' ); /* COMPLETED LAB MIGRATIONS */ $items['lab-migration/completed-labs'] = array( 'title' => 'Completed Labs', 'page callback' => 'lab_migration_completed_labs_all', 'access arguments' => array( 'lab migration download code' ), 'file' => 'lab_details.inc' ); $items['lab-migration/experiments-list'] = array( 'title' => 'Download Codes', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_experiments_list' ), 'access arguments' => array( 'lab migration download code' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'experiments_list.inc' ); /* LABS IN PROGRESS */ $items['lab-migration/labs-progress'] = array( 'title' => 'Labs in Progress', 'page callback' => 'lab_migration_labs_progress_all', 'access arguments' => array( 'lab migration download code' ), 'file' => 'lab_details.inc' ); /* DOWNLOAD FOR EVERYONE */ $items['lab-migration/lab-migration-run'] = array( 'title' => 'Download Codes', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_run_form' ), 'access arguments' => array( 'lab migration download code' ), 'type' => MENU_NORMAL_ITEM, 'file' => 'run.inc' ); /*$items['lab_migration_run'] = array( 'title' => 'Download Codes', 'page callback' => 'drupal_get_form', 'page arguments' => array('lab_migration_run_form_ajax'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM, 'file' => 'run.inc', ); $items['lab_migration_run_ajax'] = array( 'page callback' => 'lab_migration_run_ajax', 'access callback' => TRUE, 'file' => 'run.inc', ); $items['download_codes'] = array( 'title' => 'Download Codes', 'page callback' => 'drupal_get_form', 'page arguments' => array('lab_migration_run_form_ajax'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM, 'file' => 'run.inc', );*/ /* LATEX SCRIPT */ $items['lab-migration/generate-lab'] = array( 'title' => 'Generate Lab', 'description' => 'Generate Lab From Latex Script', 'page callback' => 'lab_migration_download_lab_pdf', 'access arguments' => array( 'lab migration generate lab' ), 'type' => MENU_CALLBACK, 'file' => 'latex.inc' ); $items['lab-migration/delete-lab'] = array( 'title' => 'Delete Lab PDF', 'description' => 'Delete Lab PDF', 'page callback' => 'lab_migration_delete_lab_pdf', 'access arguments' => array( 'lab migration approve code' ), 'type' => MENU_CALLBACK, 'file' => 'latex.inc' ); /* ADMIN SETTINGS */ $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' ); /* AJAX REQUEST */ $items["lab-bulk-manage-exp/ajax"] = array( "title" => "Ajax callbacks", "page callback" => "lab_bulk_manage_exp_ajax", "access arguments" => array( "lab migration bulk manage code" ), "type" => MENU_CALLBACK, 'file' => 'bulk_approval.inc' ); /* $items["lab_migration/code_approval/dependency/ajax"] = array( "title" => "Ajax callbacks", "page callback" => "lab_migration_dependency_approval_ajax", "access arguments" => array("lab migration bulk manage code"), "type" => MENU_CALLBACK, 'file' => 'dependency_approval.inc', );*/ /*************** Lab Migration certificates ****************************/ $items['lab-migration/certificate'] = array( 'title' => 'List Of All Certificates LM', 'description' => 'List of all available lab migration certificates', 'page callback' => '_list_all_lm_certificates', 'access arguments' => array( 'Create custom Certificate' ) ); $items['lab-migration/certificate/lm-proposer/form'] = array( 'title' => 'Create Certificate', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_certificate_form' ), 'access arguments' => array( 'Create custom Certificate' ) ); $items['lab-migration/certificate/lm-proposer/form/edit'] = array( 'title' => 'Edit Proposer Certificate', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_certificate_edit_form' ), 'access arguments' => array( 'Create custom Certificate' ) ); $items['lab-migration/certificate/lm-participation/form'] = array( 'title' => 'Create Certificates for Participation', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_certificate_participation_form' ), 'access arguments' => array( 'Create custom Certificate' ) ); $items['lab-migration/certificate/lm-participation/form/edit'] = array( 'title' => 'Edit Certificates for Participation', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'lab_migration_certificate_participation_edit_form' ), 'access arguments' => array( 'Create custom Certificate' ) ); $items['lab-migration/certificate/generate-pdf'] = array( 'title' => 'Download Certificate', 'description' => 'Download Certificate', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'generate_lm_pdf' ), 'access arguments' => array( 'Create custom Certificate' ), 'file' => 'pdf/generate_pdf.inc' ); $items["lab-migration/certificates/verify"] = array( "title" => "Lab Migration Certificate Verification", "page callback" => "verify_lab_migration_certificates", "access arguments" => array( "Verify custom Certificate of lab" ), 'file' => 'pdf/verify_lab_migration_certificates.inc' ); $items['lab-migration/download/syllabus-copy-file'] = array( 'title' => 'Syllabus Copy Download', 'description' => 'Syllabus Copy Download', 'page callback' => 'lab_migration_download_syllabus_copy', 'access arguments' => array( 'lab migration bulk manage code' ), 'type' => MENU_CALLBACK, 'file' => 'download.inc' ); return $items; } /** * Implementation of hook_perm(). */ function lab_migration_permission() { return array( 'lab migration create proposal' => array( 'title' => t('lab migration create proposal'), 'restrict access' => TRUE ), 'lab migration manage proposal' => array( 'title' => t('lab migration manage proposal'), 'restrict access' => TRUE ), 'lab migration edit proposal' => array( 'title' => t('lab migration edit proposal'), 'restrict access' => TRUE ), 'lab migration approve proposal' => array( 'title' => t('lab migration approve proposal'), 'restrict access' => TRUE ), 'lab migration propose solution' => array( 'title' => t('lab migration propose solution'), 'restrict access' => TRUE ), 'lab migration approve code' => array( 'title' => t('lab migration approve code'), 'restrict access' => TRUE ), 'lab migration bulk manage code' => array( 'title' => t('lab migration bulk manage code'), 'restrict access' => TRUE ), 'lab migration bulk delete code' => array( 'title' => t('lab migration bulk delete code'), 'restrict access' => TRUE ), 'lab migration upload code' => array( 'title' => t('lab migration upload code'), 'restrict access' => TRUE ), 'lab migration download code' => array( 'title' => t('lab migration download code'), 'restrict access' => TRUE ), 'administer lab migration' => array( 'title' => t('administer lab migration'), 'restrict access' => TRUE ), 'lab migration generate lab' => array( 'title' => t('lab migration generate lab'), 'restrict access' => TRUE ), "Create custom Certificate" => array( "title" => t("create custom certificate "), "description" => t("Create custom Certificate") ), "Verify custom Certificate of lab" => array( "title" => t("Verify custom Certificate of lab"), "description" => t("Verify custom Certificate of lab") ) ); // return array('lab migration create proposal', 'lab migration manage proposal', 'lab migration edit proposal', 'lab migration approve proposal', 'lab migration propose solution', 'lab migration approve code', 'lab migration bulk manage code', 'lab migration bulk delete code', 'lab migration upload code', 'lab migration download code', 'administer lab migration', 'lab migration generate lab'); } /* AJAX CALLS */ function lab_migration_ajax() { $query_type = arg(2); if ($query_type == 'chapter_title') { $chapter_number = arg(3); $preference_id = arg(4); //$chapter_q = db_query("SELECT * FROM {lab_migration_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id); $query = db_select('lab_migration_chapter'); $query->fields('lab_migration_chapter'); $query->condition('number', $chapter_number); $query->condition('preference_id', $preference_id); $query->range(0, 1); $chapter_q = $query->execute(); if ($chapter_data = $chapter_q->fetchObject()) { echo $chapter_data->name; return; } } else if ($query_type == 'example_exists') { $chapter_number = arg(3); $preference_id = arg(4); $example_number = arg(5); $chapter_id = 0; $query = db_select('lab_migration_chapter'); $query->fields('lab_migration_chapter'); $query->condition('number', $chapter_number); $query->condition('preference_id', $preference_id); $query->range(0, 1); $chapter_q = $query->execute(); if (!$chapter_data = $chapter_q->fetchObject()) { echo ''; return; } else { $chapter_id = $chapter_data->id; } $query = db_select('lab_migration_example'); $query->fields('lab_migration_example'); $query->condition('chapter_id', $chapter_id); $query->condition('number', $example_number); $query->range(0, 1); $example_q = $query->execute(); if ($example_data = $example_q->fetchObject()) { if ($example_data->approval_status == 1) echo 'Warning! Solution already approved. You cannot upload the same solution again.'; else echo 'Warning! Solution already uploaded. Delete the solution and reupload it.'; return; } } echo ''; } /*************************** 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; } function lab_migration_check_name($name = '') { if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name)) return FALSE; else return TRUE; } function lab_migration_check_code_number($number = '') { if (!preg_match('/^[0-9]+$/', $number)) return FALSE; else return TRUE; } function lab_migration_path() { return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'cfd_uploads/lab_migration_uploads/'; } /************************* USER VERIFICATION FUNCTIONS ************************/ function lab_migration_get_proposal() { global $user; //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1"); $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('solution_provider_uid', $user->uid); $query->condition('solution_status', 2); $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 Lab migraion solution proposal. Please check the " . l('available', 'lab-migration/open-proposal') . " Lab migration proposal.", 'error'); drupal_goto(''); } 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; } return FALSE; } /***************************** GENERAL FUNCTIONS ******************************/ function lab_migration_get_category_name($category_id) { $category_data = ''; switch ($category_id) { case 0: $category_data = 'Not Selected'; break; case 1: $category_data = 'Fluid Mechanics'; break; case 2: $category_data = 'Control Theory & Control Systems'; break; case 3: $category_data = 'Chemical Engineering'; break; case 4: $category_data = 'Thermodynamics'; break; case 5: $category_data = 'Mechanical Engineering'; break; case 6: $category_data = 'Signal Processing'; break; case 7: $category_data = 'Digital Communications'; break; case 8: $category_data = 'Electrical Technology'; break; case 9: $category_data = 'Mathematics & Pure Science'; break; case 10: $category_data = 'Analog Electronics'; break; case 11: $category_data = 'Digital Electronics'; break; case 12: $category_data = 'Computer Programming'; break; case 13: $category_data = 'Others'; break; default: $category_data = 'Unknown'; break; } return $category_data; } /*function lab_migration_init() { drupal_add_js(drupal_get_path('module', 'lab_migration') . '/js/lab_migration_ajax.js', array ('scope' => 'footer')); }*/ /*************************************************************************/ /***** 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 _lm_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; } return $states; } function _lm_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; } return $city; } function _lm_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; } return $department; } function _lm_list_of_software_version() { $software_version = array(); $query = db_select('openfoam_software_version'); $query->fields('openfoam_software_version'); $query->orderBy('id', 'DESC'); $software_version_list = $query->execute(); while ($software_version_list_data = $software_version_list->fetchObject()) { $software_version[$software_version_list_data->openfoam_version] = $software_version_list_data->openfoam_version; } return $software_version; } function _lm_dir_name($lab, $name, $university) { $lab_title = ucname($lab); $proposar_name = ucname($name); $university_name = ucname($university); $dir_name = $lab_title . " " . "by". " " . $proposar_name . ' ' . $university_name; $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name)); return $directory_name; } function _list_all_lm_certificates() { $query = db_query("SELECT * FROM lab_migration_certificate"); $search_rows = array(); $output = ''; $details_list = $query->fetchAll(); foreach ($details_list as $details) { if ($details->type == "Proposer") { $search_rows[] = array( $details->lab_name, $details->institute_name, $details->name, $details->type, l('Download Certificate', 'lab-migration/certificate/generate-pdf/' . $details->proposal_id . '/' . $details->id), l('Edit Certificate', 'lab-migration/certificate/lm-proposer/form/edit/' . $details->proposal_id . '/' . $details->id) ); } //$details->type == "Proposer" else { $search_rows[] = array( $details->lab_name, $details->institute_name, $details->name, $details->type, l('Download Certificate', 'lab-migration/certificate/generate-pdf/' . $details->proposal_id . '/' . $details->id), l('Edit Certificate', 'lab-migration/certificate/lm-participation/form/edit/' . $details->proposal_id . '/' . $details->id) ); } } //$details_list as $details $search_header = array( 'Lab Name', 'Institute name', 'Name', 'Type', 'Download Certificates', 'Edit Certificates' ); $output .= theme('table', array( 'header' => $search_header, 'rows' => $search_rows )); return $output; } /********** Lab migration certificate form **************/ function lab_migration_certificate_form($form, $form_state) { $form['name_title'] = array( '#type' => 'select', '#title' => t('Title'), '#options' => array( 'Dr.' => 'Dr.', 'Prof.' => 'Prof.', 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.', 'Ms.' => 'Ms.' ), '#required' => TRUE ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Name of Proposer'), '#maxlength' => 50, '#required' => TRUE ); $form['email_id'] = array( '#type' => 'textfield', '#title' => t('Email'), '#size' => 50 ); $form['institute_name'] = array( '#type' => 'textfield', '#title' => t('college / Institue name'), '#required' => TRUE ); $form['institute_address'] = array( '#type' => 'textfield', '#title' => t('college / Institue address'), '#required' => TRUE ); $form['lab_name'] = array( '#type' => 'textfield', '#title' => t('Lab name'), '#required' => TRUE ); $form['department'] = array( '#type' => 'textfield', '#title' => t('Department'), '#required' => TRUE ); $form['semester_details'] = array( '#type' => 'textfield', '#title' => t('Semester details'), '#description' => 'Eg. 5th or 2nd', '#required' => TRUE ); $form['proposal_id'] = array( '#type' => 'textfield', '#title' => t('Lab Proposal Id'), '#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - cfd.fossee.in/lab-migration/lab-migration-run/64)', '#required' => TRUE ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') ); return $form; } function lab_migration_certificate_form_submit($form, &$form_state) { global $user; $v = $form_state["values"]; $result = "INSERT INTO {lab_migration_certificate} (uid, name_title, name, email_id, institute_name, institute_address, lab_name, department, semester_details,proposal_id,type,creation_date) VALUES (:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :semester_details,:proposal_id,:type,:creation_date)"; $args = array( ":uid" => $user->uid, ":name_title" => trim($v['name_title']), ":name" => trim($v['name']), ":email_id" => trim($v['email_id']), ":institute_name" => trim($v['institute_name']), ":institute_address" => trim($v['institute_address']), ":lab_name" => trim($v['lab_name']), ":department" => trim($v['department']), ":semester_details" => trim($v['semester_details']), ":proposal_id" => trim($v['proposal_id']), ":type" => "Proposer", ":creation_date" => time() ); $proposal_id = db_query($result, $args); drupal_goto('lab-migration/certificate'); } function lab_migration_certificate_edit_form($form, $form_state) { $type = arg(2); $action = arg(4); $proposal_id = arg(5); $certi_id = arg(6); //var_dump($type. "--".$action."--".$proposal_id."--".$certi_id); //die; if ($type == "lm-proposer" && $action == "edit") { $query = db_query("SELECT * FROM lab_migration_certificate WHERE proposal_id=:prop_id AND id=:certi_id", array( ":prop_id" => $proposal_id, ":certi_id" => $certi_id )); $details_list = $query->fetchobject(); if ($details_list->type == "Proposer") { $form['name_title'] = array( '#type' => 'select', '#title' => t('Title'), '#options' => array( 'Dr.' => 'Dr.', 'Prof.' => 'Prof.', 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.', 'Ms.' => 'Ms.' ), '#default_value' => $details_list->name_title ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Name of Proposer'), '#maxlength' => 50, '#default_value' => $details_list->name ); $form['email_id'] = array( '#type' => 'textfield', '#title' => t('Email'), '#size' => 50, '#default_value' => $details_list->email_id ); $form['institute_name'] = array( '#type' => 'textfield', '#title' => t('college / Institue Name'), '#default_value' => $details_list->institute_name ); $form['institute_address'] = array( '#type' => 'textfield', '#title' => t('college / Institue address'), '#default_value' => $details_list->institute_address ); $form['lab_name'] = array( '#type' => 'textfield', '#title' => t('Lab name'), '#default_value' => $details_list->lab_name ); $form['department'] = array( '#type' => 'textfield', '#title' => t('Department'), '#default_value' => $details_list->department ); $form['semester_details'] = array( '#type' => 'textfield', '#title' => t('Semester details '), '#description' => 'Eg. 5th or 2nd', '#default_value' => $details_list->semester_details ); $form['proposal_id'] = array( '#type' => 'textfield', '#title' => t('Lab Proposal Id'), '#description' => 'Note: You can find it in respective completed labs url -> cfd.fossee.in/lab-migration/lab-migration-run/64 <- this number is the proposal id for respective lab', '#default_value' => $details_list->proposal_id ); $form['certi_id'] = array( '#type' => 'hidden', '#default_value' => $details_list->id ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') ); } //$details_list->type == "Proposer" else { $form['err_message'] = array( '#type' => 'item', '#title' => t('Message'), '#markup' => 'Invalid information' ); } } //$type == "lm-proposer" && $action == "edit" else { $form['err_message'] = array( '#type' => 'item', '#title' => t('Message'), '#markup' => 'Invalid information' ); } return $form; } function lab_migration_certificate_edit_form_submit($form, &$form_state) { global $user; $v = $form_state["values"]; $result = "UPDATE lab_migration_certificate SET uid=:uid, name_title=:name_title, name=:name, email_id=:email_id, institute_name=:institute_name, institute_address=:institute_address, lab_name=:lab_name, department=:department, semester_details=:semester_details, proposal_id=:proposal_id, type=:type, creation_date=:creation_date WHERE id=:certi_id"; $args = array( ":uid" => $user->uid, ":name_title" => trim($v['name_title']), ":name" => trim($v['name']), ":email_id" => trim($v['email_id']), ":institute_name" => trim($v['institute_name']), ":institute_address" => trim($v['institute_address']), ":lab_name" => trim($v['lab_name']), ":department" => trim($v['department']), ":semester_details" => trim($v['semester_details']), ":proposal_id" => trim($v['proposal_id']), ":type" => "Proposer", ":creation_date" => time(), ":certi_id" => $v['certi_id'] ); $proposal_id = db_query($result, $args); drupal_goto('lab-migration/certificate'); } function lab_migration_certificate_participation_form($form, $form_state) { $form['name_title'] = array( '#type' => 'select', '#title' => t('Title'), '#options' => array( 'Dr.' => 'Dr.', 'Prof.' => 'Prof.', 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.', 'Ms.' => 'Ms.' ), '#required' => TRUE ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Name of Participant'), '#maxlength' => 50, '#required' => TRUE ); $form['email_id'] = array( '#type' => 'textfield', '#title' => t('Email'), '#size' => 50, '#default_value' => 'Not availbale' ); $form['institute_name'] = array( '#type' => 'textfield', '#title' => t('college / Institue Name'), '#required' => TRUE ); $form['institute_address'] = array( '#type' => 'textfield', '#title' => t('college / Institue address'), '#required' => TRUE ); $form['lab_name'] = array( '#type' => 'textfield', '#title' => t('Lab name'), '#required' => TRUE ); $form['department'] = array( '#type' => 'textfield', '#title' => t('Department'), '#required' => TRUE ); $form['semester_details'] = array( '#type' => 'textfield', '#title' => t('Semester details and department'), '#description' => 'Eg. 5th or 2nd', '#required' => TRUE ); $form['proposal_id'] = array( '#type' => 'textfield', '#title' => t('Lab Proposal Id'), '#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - cfd.fossee.in/lab-migration/lab-migration-run/64)', '#required' => TRUE ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') ); return $form; } function lab_migration_certificate_participation_form_submit($form, &$form_state) { global $user; $v = $form_state["values"]; $result = "INSERT INTO {lab_migration_certificate} (uid, name_title, name, email_id, institute_name, institute_address, lab_name, department, semester_details,proposal_id,type,creation_date) VALUES (:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :semester_details,:proposal_id,:type,:creation_date)"; $args = array( ":uid" => $user->uid, ":name_title" => trim($v['name_title']), ":name" => trim($v['name']), ":email_id" => trim($v['email_id']), ":institute_name" => trim($v['institute_name']), ":institute_address" => trim($v['institute_address']), ":lab_name" => trim($v['lab_name']), ":department" => trim($v['department']), ":semester_details" => trim($v['semester_details']), ":proposal_id" => $v['proposal_id'], ":type" => "Participant", ":creation_date" => time() ); $proposal_id = db_query($result, $args); drupal_goto('lab-migration/certificate'); } function lab_migration_certificate_participation_edit_form($form, $form_state) { $type = arg(2); $action = arg(4); $proposal_id = arg(5); $certi_id = arg(6); if ($type == "lm-participation" && $action == "edit") { $query = db_query("SELECT * FROM lab_migration_certificate WHERE proposal_id=:prop_id AND id=:certi_id", array( ":prop_id" => $proposal_id, ":certi_id" => $certi_id )); $details_list = $query->fetchobject(); if ($details_list->type == "Participant") { $form['name_title'] = array( '#type' => 'select', '#title' => t('Title'), '#options' => array( 'Dr.' => 'Dr.', 'Prof.' => 'Prof.', 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.', 'Ms.'=> 'Ms.' ), '#default_value' => $details_list->name_title ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Name of Participant'), '#maxlength' => 50, '#default_value' => $details_list->name ); $form['email_id'] = array( '#type' => 'textfield', '#title' => t('Email'), '#size' => 50, '#default_value' => $details_list->email_id ); $form['institute_name'] = array( '#type' => 'textfield', '#title' => t('college / Institue Name'), '#default_value' => $details_list->institute_name ); $form['institute_address'] = array( '#type' => 'textfield', '#title' => t('college / Institue address'), '#default_value' => $details_list->institute_address ); $form['lab_name'] = array( '#type' => 'textfield', '#title' => t('Lab name'), '#default_value' => $details_list->lab_name ); $form['department'] = array( '#type' => 'textfield', '#title' => t('Department'), '#default_value' => $details_list->department ); $form['semester_details'] = array( '#type' => 'textfield', '#title' => t('Semester details and department'), '#description' => 'Eg. 5th or 2nd', '#default_value' => $details_list->semester_details ); $form['proposal_id'] = array( '#type' => 'textfield', '#title' => t('Lab Proposal Id'), '#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - cfd.fossee.in/lab-migration/lab-migration-run/64)', '#default_value' => $details_list->proposal_id ); $form['certi_id'] = array( '#type' => 'hidden', '#default_value' => $details_list->id ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') ); } //$details_list->type == "Participant" else { $form['err_message'] = array( '#type' => 'item', '#title' => t('Message'), '#markup' => 'Invalid information' ); } } //$type == "lm_participation" && $action == "edit" else { $form['err_message'] = array( '#type' => 'item', '#title' => t('Message'), '#markup' => 'Invalid information' ); } return $form; } function lab_migration_certificate_participation_edit_form_submit($form, &$form_state) { global $user; $v = $form_state["values"]; $result = "UPDATE lab_migration_certificate SET uid=:uid, name_title=:name_title, name=:name, email_id=:email_id, institute_name=:institute_name, institute_address=:institute_address, lab_name=:lab_name, department=:department, semester_details=:semester_details, proposal_id=:proposal_id, type=:type, creation_date=:creation_date WHERE id=:certi_id"; $args = array( ":uid" => $user->uid, ":name_title" => trim($v['name_title']), ":name" => trim($v['name']), ":email_id" => trim($v['email_id']), ":institute_name" => trim($v['institute_name']), ":institute_address" => trim($v['institute_address']), ":lab_name" => trim($v['lab_name']), ":department" => trim($v['department']), ":semester_details" => trim($v['semester_details']), ":proposal_id" => trim($v['proposal_id']), ":type" => "Participant", ":creation_date" => time(), ":certi_id" => $v['certi_id'] ); $proposal_id = db_query($result, $args); drupal_goto('lab-migration/certificate'); }