'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/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_proposal'] = array( 'title' => 'Pending Solution Proposals', 'description' => 'Pending Lab Migration Solution Proposals Queue', 'page callback' => 'solution_proposal_pending', 'access callback' => 'user_access', 'access arguments' => array('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' => '_proposal_pending_solution', 'access callback' => 'user_access', 'access arguments' => array('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' => '_proposal_all', 'access callback' => 'user_access', 'access arguments' => array('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' => '_category_all', 'access callback' => 'user_access', 'access arguments' => array('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('category_edit_form'), 'access arguments' => array('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('proposal_approval_form'), 'access arguments' => array('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('solution_proposal_approval_form'), 'access arguments' => array('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('proposal_edit_form'), 'access arguments' => array('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('proposal_status_form'), 'access arguments' => array('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('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('view proposal'), 'type' => MENU_CALLBACK, 'file' => 'solution_proposal.inc', ); /* CODE REVIEW */ $items['lab_migration/code_approval'] = array( 'title' => 'Manage Code Approval', 'description' => 'Manage Code Approval', 'page callback' => 'code_approval', 'access arguments' => array('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('code_approval_form'), 'access arguments' => array('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('bulk_approval_form'), 'access arguments' => array('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('dependency_approval_form'), 'access arguments' => array('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('bulk_upload_code_form'), 'access arguments' => array('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_notes_form'), 'access arguments' => array('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' => 'list_experiments', 'access callback' => 'user_access', 'access arguments' => array('upload code'), 'file' => 'upload_code.inc', ); $items['lab_migration/code/list_experiments'] = array( 'title' => 'List Experiments', 'description' => 'List Experiments', 'page callback' => 'list_experiments', 'access arguments' => array('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('upload_code_form'), 'access arguments' => array('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('upload_dependency_form'), 'access arguments' => array('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' => 'upload_code_delete', 'access arguments' => array('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('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('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('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('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('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('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('approve code'), 'type' => MENU_CALLBACK, 'file' => 'full_download.inc', ); /* DOWNLOAD FOR EVERYONE */ $items['lab_migration_run'] = array( 'title' => 'Download Codes', 'page callback' => 'drupal_get_form', 'page arguments' => array('lab_migration_run_form'), '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('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('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', ); return $items; } /** * Implementation of hook_perm(). */ function lab_migration_perm() { return array('create proposal', 'manage proposal', 'edit proposal', 'approve proposal', 'propose solution', 'view proposal', 'approve code', 'bulk manage code', 'bulk delete code', 'upload code', 'edit uploaded code', 'download code', 'access content', 'administer 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); if ($chapter_data = db_fetch_object($chapter_q)) { 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; $chapter_q = db_query("SELECT * FROM {lab_migration_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id); if (!$chapter_data = db_fetch_object($chapter_q)) { echo ''; return; } else { $chapter_id = $chapter_data->id; } $example_q = db_query("SELECT * FROM {lab_migration_example} WHERE chapter_id = %d AND number = '%s' LIMIT 1", $chapter_id, $example_number); if ($example_data = db_fetch_object($example_q)) { 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 check_name($name = '') { if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name)) return FALSE; else return TRUE; } function 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() . 'lab_migration_uploads/'; } /************************* USER VERIFICATION FUNCTIONS ************************/ function get_proposal() { global $user; $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = %d AND solution_status = 2 ORDER BY id DESC LIMIT 1", $user->uid); $proposal_data = db_fetch_object($proposal_q); 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 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; }