function get_mspr_entity($type, $entity_id) { switch ($type) { case 'studentships': $entity = Studentship::get($entity_id); break; case 'clineval': $entity = ClinicalPerformanceEvaluation::get($entity_id); break; case 'internal_awards': $entity = InternalAwardReceipt::get($entity_id); break; case 'external_awards': $entity = ExternalAwardReceipt::get($entity_id); break; case 'contributions': $entity = Contribution::get($entity_id); break; case 'student_run_electives': $entity = StudentRunElective::get($entity_id); break; case 'observerships': $entity = Observership::get($entity_id); break; case 'int_acts': $entity = InternationalActivity::get($entity_id); break; case 'critical_enquiry': $entity = CriticalEnquiry::get($entity_id); break; case 'community_based_project': $entity = CommunityBasedProject::get($entity_id); break; case 'research_citations': $entity = ResearchCitation::get($entity_id); break; } return $entity; }
/** * Processes the various sections of the MSPR module */ function process_manage_award_details() { if (isset($_POST['action'])) { $action = $_POST['action']; switch ($action) { case "add_award_recipient": $award_id = isset($_POST['award_id']) ? $_POST['award_id'] : 0; $user_id = isset($_POST['internal_award_user_id']) ? $_POST['internal_award_user_id'] : 0; if ($user_id && $award_id) { $year = $_POST['internal_award_year']; $info = array("award_id" => $award_id, "user_id" => $user_id, "year" => $year); InternalAwardReceipt::create($info); } break; case "remove_award_recipient": $id = isset($_POST['internal_award_id']) ? $_POST['internal_award_id'] : 0; if ($id) { $recipient = InternalAwardReceipt::get($id); if ($recipient) { $recipient->delete(); } } break; case "edit_award_details": $award_id = isset($_POST['award_id']) ? $_POST['award_id'] : 0; $disabled = (bool) $_POST['award_disabled']; $title = clean_input($_POST['award_title'], array("notags", "specialchars")); $terms = clean_input($_POST['award_terms'], array("notags", "specialchars", "nl2br")); if (!$title || !$terms) { add_error("Insufficient information please check the fields and try again"); } else { if ($award_id) { $award = InternalAward::get($award_id); if ($award) { edit_award_details($award, $title, $terms, $disabled); } } else { add_error("Award not found"); } } break; case "new_award": $title = clean_input($_POST['award_title'], array("notags", "specialchars")); $terms = clean_input($_POST['award_terms'], array("notags", "specialchars", "nl2br")); if (!$title || !$terms) { add_error("Insufficient information please check the fields and try again"); } else { InternalAward::create($title, $terms); } break; case "remove_award": $award_id = isset($_POST['award_id']) ? $_POST['award_id'] : 0; if ($award_id) { $award = InternalAward::get($award_id); $award->delete(); } break; } } }