function display_observerships(Observerships $observerships, $type, $hide_controls = false) { global $ENTRADA_TEMPLATE; $content_file = $ENTRADA_TEMPLATE->absolute() . "/modules/common/mspr/observership.xml"; $content_template = new Template($content_file); $contents = ""; if ($observerships && $observerships->count() > 0) { foreach ($observerships as $entity) { $preceptor = $entity->getPreceptor(); if ($preceptor) { $preceptor_proxy_id = $preceptor->getID(); $preceptor_firstname = ""; $preceptor_lastname = ""; $preceptor_prefix = $entity->getPreceptorPrefix(); $preceptor_email = $entity->getPreceptorEmail(); $preceptor_status = $entity->getStatus(); } else { $preceptor_proxy_id = 0; $preceptor_firstname = $entity->getPreceptorFirstname(); $preceptor_lastname = $entity->getPreceptorLastname(); $preceptor_prefix = $entity->getPreceptorPrefix(); $preceptor_email = $entity->getPreceptorEmail(); $preceptor_status = $entity->getStatus(); } $preceptor_name = (!empty($preceptor_prefix) ? $preceptor_prefix . " " : "") . trim($entity->getPreceptorFirstname() . " " . $entity->getPreceptorLastname()); $start = $entity->getStartDate(); $end = $entity->getEndDate(); $start = $start['y'] . "-" . $start['m'] . "-" . $start['d']; $end = $end['y'] . "-" . $end['m'] . "-" . $end['d']; $content_bind = array("title" => clean_input($entity->getTitle(), array("notags", "specialchars")), "site" => clean_input($entity->getSite(), array("notags", "specialchars")), "location" => clean_input($entity->getLocation(), array("notags", "specialchars")), "preceptor" => clean_input($preceptor_name, array("notags", "specialchars")), "period" => clean_input($entity->getPeriod(), array("notags", "specialchars")), "preceptor_proxy_id" => $preceptor_proxy_id, "preceptor_firstname" => $preceptor_firstname, "preceptor_lastname" => $preceptor_lastname, "preceptor_prefix" => $preceptor_prefix, "preceptor_email" => $preceptor_email, "status" => $preceptor_status, "start" => $start, "end" => $end); $content = $content_template->getResult($content_bind, array("lang" => DEFAULT_LANGUAGE)); $contents .= item_wrap_content($type, $entity, $content, $hide_controls); } } else { $contents = "<li>None</li>"; } return list_wrap_content($contents); }
public function process() { $user = $this->_user; $translator = $this->_translator; $type = $this->type; static $valid = array("external_awards" => array("add", "remove", "edit"), "contributions" => array("add", "remove", "edit"), "critical_enquiry" => array("add", "remove", "edit"), "community_based_project" => array("add", "remove", "edit"), "research_citations" => array("add", "remove", "edit", "resequence"), "observerships" => array("add", "remove", "edit", "resequence")); $section = filter_input(INPUT_GET, 'mspr-section', FILTER_CALLBACK, array('options' => 'strtolower')); if ($section) { $params = array('entity_id' => FILTER_VALIDATE_INT, 'action' => array('filter' => FILTER_CALLBACK, 'options' => 'strtolower'), 'user_id' => FILTER_VALIDATE_INT); $inputs = filter_input_array(INPUT_POST, $params); extract($inputs); if (!$action) { add_error($translator->translate("mspr_no_action")); } if (!array_key_exists($section, $valid)) { add_error($translator->translate("mspr_invalid_section")); } else { if (!in_array($action, $valid[$section])) { add_error($translator->translate("mspr_invalid_action")); } } if (!has_error() && in_array($action, array("add", "edit", "resequence"))) { $inputs = get_mspr_inputs($section); process_mspr_inputs($section, $inputs, $translator); //modifies inputs/adds errors } if (!has_error()) { $inputs['user_id'] = $user_id; if ($action == "add") { switch ($section) { case 'external_awards': ExternalAwardReceipt::create($inputs); break; case 'contributions': Contribution::create($inputs); break; case 'critical_enquiry': if (CriticalEnquiry::get($user_id)) { add_error($translator->translate("mspr_too_many_critical_enquiry")); } else { CriticalEnquiry::create($inputs); } break; case 'community_based_project': if (CommunityBasedProject::get($user_id)) { add_error($translator->translate("mspr_too_many_community_based_project")); } else { CommunityBasedProject::create($inputs); } break; case 'research_citations': ResearchCitation::create($inputs); break; case 'observerships': $observership = Observership::create($inputs); break; } } elseif ($action == "resequence") { switch ($section) { case 'research_citations': ResearchCitations::setSequence($user_id, $inputs['research_citations']); break; } } else { //everything else requires an entity if ($entity_id) { $entity = get_mspr_entity($section, $entity_id); if ($entity) { switch ($action) { case "remove": $entity->delete(); break; case "edit": if ($entity instanceof Approvable) { $inputs['comment'] = ""; $inputs['status'] = 0; //set to unapproved. } $entity->update($inputs); //inputs processed above break; } } else { add_error($translator->translate("mspr_invalid_entity")); } } else { add_error($translator->translate("mspr_no_entity")); } } } switch ($section) { case 'external_awards': $external_awards = ExternalAwardReceipts::get($user); display_status_messages(); echo display_external_awards($external_awards, $type); break; case 'contributions': $contributions = Contributions::get($user); display_status_messages(); echo display_contributions($contributions, $type); break; case 'critical_enquiry': $critical_enquiry = CriticalEnquiry::get($user); display_status_messages(); echo display_critical_enquiry($critical_enquiry, $type); break; case 'community_based_project': $community_based_project = CommunityBasedProject::get($user); display_status_messages(); echo display_community_based_project($community_based_project, $type); break; case 'research_citations': $research_citations = ResearchCitations::get($user); display_status_messages(); echo display_research_citations($research_citations, $type); break; case 'observerships': $observerships = Observerships::get($user); display_status_messages(); echo display_observerships($observerships, "public"); break; } } }
$ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/" . $MODULE . "\\'', 15000)"; add_error("Your account does not have the permissions required to use this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance."); echo display_error(); application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] do not have access to this module [" . $MODULE . "]"); } else { // require_once(dirname(__FILE__)."/includes/functions.inc.php"); // require_once "Models/mspr/Observership.class.php"; require_once "Models/mspr/Observerships.class.php"; $PROXY_ID = $user_record["id"]; $user = User::get($PROXY_ID); $pending_observerships = Observerships::get(array("student_id" => $user->getID(), "status" => "pending")); $approved_observerships = Observerships::get(array("student_id" => $user->getID(), "status" => "approved")); $rejected_observerships = Observerships::get(array("student_id" => $user->getID(), "status" => "rejected")); $confirmed_observerships = Observerships::get(array("student_id" => $user->getID(), "status" => "confirmed")); $denied_observerships = Observerships::get(array("student_id" => $user->getID(), "status" => "denied")); echo "<h1>Observerships for " . $user->getFullname(false) . "</h1>"; $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/users/manage/students?section=observerships&id=" . $user->getID(), "title" => "Observerships"); switch ($STEP) { case 2: if ($_POST["status"] && is_array($_POST["status"])) { foreach ($_POST["status"] as $observership_id => $status) { $observership = Observership::get($observership_id); if ($observership->getStudentID() == $PROXY_ID && ($status == "rejected" || $status == "approved")) { $query = "UPDATE `student_observerships` SET `status` = " . $db->qstr($status) . " WHERE `id` = " . $observership_id; if (!$db->Execute($query)) { application_log("error", "Error while updating `student_observerships`, DB said: " . $db->ErrorMsg()); add_error("An error ocurred while trying to update observership status. An administrator has been informed, please try again later."); } } else { application_log("error", "Attempt to update observership with id [" . $observership_id . "] for proxy id [" . $PROXY_ID . "] where status was invalid or different student_id.");
*/ if (!defined("PARENT_INCLUDED") || !defined("IN_OBSERVERSHIPS_ADMIN")) { exit; } elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) { header("Location: " . ENTRADA_URL); exit; } elseif (!$ENTRADA_ACL->amIAllowed("user", "update", false)) { $ERROR++; $ERRORSTR[] = "Your account does not have the permissions required to use this feature of this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance."; echo display_error(); application_log("error", "Group [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["group"] . "] and role [" . $_SESSION["permissions"][$ENTRADA_USER->getAccessId()]["role"] . "] does not have access to this module [" . $MODULE . "]"); } else { require_once "Models/mspr/Observership.class.php"; require_once "Models/mspr/Observerships.class.php"; echo "<h1>Pending Observerships</h1>"; $observerships = Observerships::get(array("status" => "pending")); $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/observerships", "title" => "Pending Observerships"); switch ($STEP) { case 2: if ($_POST["action"] == "Reject" || $_POST["action"] == "Approve") { $set_status = $_POST["action"] == "Reject" ? "rejected" : "approved"; if ($_POST["status"] && is_array($_POST["status"])) { foreach ($_POST["status"] as $id => $status) { if ($status == "on") { $id = (int) $id; $query = "UPDATE `student_observerships` SET `status` = " . $db->qstr($set_status) . " WHERE `id` = " . $db->qstr($id); if (!$db->Execute($query)) { add_error("Failed to update observership. A system administrator has been informed, please try again later."); application_log("error", "Failed to updated observership, DB said: " . $db->ErrorMsg()); } } else {
$i++; } } ?> </tbody> </table> <div class="row-fluid"> <input class="btn btn-primary pull-right" type="button" value="Reorder" id="reorder_observership" /> <input class="btn" type="button" value="Cancel Reorder" id="cancel_order" style="display:none;" /> </div> <?php } $other_observerships["pending"] = Observerships::get(array("student_id" => $ENTRADA_USER->getID(), "status" => "pending")); $other_observerships["approved"] = Observerships::get(array("student_id" => $ENTRADA_USER->getID(), "status" => "approved")); $other_observerships["rejected"] = Observerships::get(array("student_id" => $ENTRADA_USER->getID(), "status" => "rejected")); $other_observerships["denied"] = Observerships::get(array("student_id" => $ENTRADA_USER->getID(), "status" => "denied")); if ($other_observerships) { $total_observerships += count($other_observerships); ?> <h2>Unconfirmed Observerships</h2> <div class="display-generic"> <strong>Please note:</strong> Unconfirmed observerships will not appear in your MSPR. Approved observerships require a reflection to be entered after they have been completed, which will notify the preceptor for confirmation. </div> <form action="<?php echo ENTRADA_URL; ?> /profile/observerships?section=delete" method="post"> <table class="table table-striped" id="unconfirmed-observership-list" cellspacing="0" cellpadding="1" summary="List of Observerships"> <thead> <tr> <th width="20"> </th>
public function process() { global $ENTRADA_USER; $user = $this->_user; $translator = $this->_translator; $type = $this->type; static $valid = array("studentships" => array("add", "remove", "edit"), "clineval" => array("add", "remove", "edit"), "internal_awards" => array("add", "remove", "edit"), "student_run_electives" => array("add", "remove", "edit"), "observerships" => array("add", "remove", "edit"), "int_acts" => array("add", "remove", "edit"), "external_awards" => array("approve", "unapprove", "reject", "add", "edit"), "contributions" => array("approve", "unapprove", "reject", "add", "edit"), "critical_enquiry" => array("approve", "unapprove", "reject", "add", "edit"), "community_based_project" => array("approve", "unapprove", "reject", "add", "edit"), "research_citations" => array("approve", "unapprove", "reject", "add", "edit", "resequence")); $section = filter_input(INPUT_GET, 'mspr-section', FILTER_CALLBACK, array('options' => 'strtolower')); if ($section) { $params = array('entity_id' => FILTER_VALIDATE_INT, 'action' => array('filter' => FILTER_CALLBACK, 'options' => 'strtolower'), 'comment' => FILTER_SANITIZE_STRING, 'user_id' => FILTER_VALIDATE_INT); $inputs = filter_input_array(INPUT_POST, $params); extract($inputs); if (!$action) { add_error($translator->translate("mspr_no_action")); } if (!array_key_exists($section, $valid)) { add_error($translator->translate("mspr_invalid_section")); } else { if (!in_array($action, $valid[$section])) { add_error($translator->translate("mspr_invalid_action")); } } if ($action == "reject" && MSPR_REJECTION_REASON_REQUIRED) { if (!$comment) { add_error($translator->translate("mspr_no_reject_reason")); } } if (!has_error() && in_array($action, array("add", "edit", "resequence"))) { $inputs = get_mspr_inputs($section); process_mspr_inputs($section, $inputs, $translator); //modifies inputs/adds errors } if (!has_error()) { $inputs['user_id'] = $user_id; if ($action == "add") { if (AUTO_APPROVE_ADMIN_MSPR_SUBMISSIONS) { $inputs['status'] = 1; } switch ($section) { case "clineval": ClinicalPerformanceEvaluation::create($inputs); break; case "observerships": Observership::create($inputs); break; case 'studentships': Studentship::create($inputs); break; case 'internal_awards': InternalAwardReceipt::create($inputs); break; case 'external_awards': ExternalAwardReceipt::create($inputs); break; case 'contributions': Contribution::create($inputs); break; case 'student_run_electives': StudentRunElective::create($inputs); break; case 'int_acts': InternationalActivity::create($inputs); break; case 'critical_enquiry': if (CriticalEnquiry::get($user_id)) { add_error($translator->translate("mspr_too_many_critical_enquiry")); } else { CriticalEnquiry::create($inputs); } break; case 'community_based_project': if (CommunityBasedProject::get($user_id)) { add_error($translator->translate("mspr_too_many_community_based_project")); } else { CommunityBasedProject::create($inputs); } break; case 'research_citations': ResearchCitation::create($inputs); break; } } elseif ($action == "resequence") { switch ($section) { case 'research_citations': ResearchCitations::setSequence($user_id, $inputs['research_citations']); break; } } else { //everything else requires an entity if ($entity_id) { $entity = get_mspr_entity($section, $entity_id); if ($entity) { switch ($action) { case "approve": $entity->approve(); break; case "unapprove": $entity->unapprove(); break; case "remove": $entity->delete(); break; case "edit": if ($entity instanceof Approvable) { if (AUTO_APPROVE_ADMIN_MSPR_EDITS) { $inputs['comment'] = ""; $inputs['status'] = 1; } else { $inputs['comment'] = $entity->getComment(); $inputs['status'] = $entity->getStatus(); } } $entity->update($inputs); //inputs processed above break; case "reject": if (MSPR_REJECTION_SEND_EMAIL) { $sub_info = get_submission_information($entity); $reason_type = !$comment ? "noreason" : "reason"; $active_user = User::get($ENTRADA_USER->getID()); if ($active_user && $type) { submission_rejection_notification($reason_type, array("firstname" => $user->getFirstname(), "lastname" => $user->getLastname(), "email" => $user->getEmail()), array("to_fullname" => $user->getFirstname() . " " . $user->getLastname(), "from_firstname" => $active_user->getFirstname(), "from_lastname" => $active_user->getLastname(), "reason" => clean_input($comment, array("notags", "specialchars")), "submission_details" => $sub_info, "application_name" => APPLICATION_NAME . " MSPR System")); } else { add_error($translator->translate("mspr_email_failed")); } } $entity->reject($comment); break; } } else { add_error($translator->translate("mspr_invalid_entity")); } } else { add_error($translator->translate("mspr_no_entity")); } } } switch ($section) { case 'studentships': $studentships = Studentships::get($user); display_status_messages(); echo display_studentships($studentships, $type); break; case 'clineval': $clinical_evaluation_comments = ClinicalPerformanceEvaluations::get($user); display_status_messages(); echo display_clineval($clinical_evaluation_comments, $type); break; case 'internal_awards': $internal_awards = InternalAwardReceipts::get($user); display_status_messages(); echo display_internal_awards($internal_awards, $type); break; case 'external_awards': $external_awards = ExternalAwardReceipts::get($user); display_status_messages(); echo display_external_awards($external_awards, $type); break; case 'contributions': $contributions = Contributions::get($user); display_status_messages(); echo display_contributions($contributions, $type); break; case 'student_run_electives': $student_run_electives = StudentRunElectives::get($user); display_status_messages(); echo display_student_run_electives($student_run_electives, $type); break; case 'observerships': $observerships = Observerships::get($user); display_status_messages(); echo display_observerships($observerships, $type); break; case 'int_acts': $int_acts = InternationalActivities::get($user); display_status_messages(); echo display_international_activities($int_acts, $type); break; case 'critical_enquiry': $critical_enquiry = CriticalEnquiry::get($user); display_status_messages(); echo display_critical_enquiry($critical_enquiry, $type); break; case 'community_based_project': $community_based_project = CommunityBasedProject::get($user); display_status_messages(); echo display_community_based_project($community_based_project, $type); break; case 'research_citations': $research_citations = ResearchCitations::get($user); display_status_messages(); echo display_research_citations($research_citations, $type); break; } } }