public static function get($where = null, $limit = null) { global $db; $allowed_fields = array("student_id", "preceptor_proxy_id", "preceptor_email", "status"); $where_clause = ""; if ($where && (is_array($where) || get_class($where) == "User")) { $where_clause = "WHERE "; if (is_array($where)) { $i = 0; foreach ($where as $key => $value) { if (in_array($key, $allowed_fields)) { $where_clause .= ($i > 0 ? " AND " : "") . "`" . $key . "` = " . $db->qstr($value) . " "; $i++; } } } else { if (get_class($where) == "User") { $where_clause .= "`student_id` = " . $db->qstr($where->getID()) . " AND `status` = 'confirmed'"; $limit = 8; } } $limit_clause = ""; if (is_int($limit)) { $limit = (int) $limit; $limit_clause = " LIMIT " . $limit; } $query = "SELECT * FROM `student_observerships` " . $where_clause . " ORDER BY `order` ASC, `start` ASC " . $limit_clause; $results = $db->getAll($query); $obss = array(); if ($results) { foreach ($results as $result) { $obs = Observership::fromArray($result, "fetch"); $obss[] = $obs; } } return new self($obss); } else { return false; } }
if (!defined("PARENT_INCLUDED") || !defined("IN_PUBLIC_OBSERVERSHIPS")) { exit; } elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) { header("Location: " . ENTRADA_URL); exit; } else { $BREADCRUMB[] = array("url" => ENTRADA_URL . "/profile/observerships?section=delete", "title" => "Delete Observerships"); require_once "Models/mspr/Observership.class.php"; require_once "Models/mspr/Observerships.class.php"; ?> <h1>My Observerships</h1> <?php if ($_POST["delete"]) { if (is_array($_POST["delete"])) { foreach ($_POST["delete"] as $observership_id) { $observership = Observership::get($observership_id); if ($observership->getStatus() == "pending" || $observership->getStatus() == "approved" || $observership->getStatus() == "rejected") { $valid_observerships[] = $observership; } } } switch ($STEP) { case 2: foreach ($valid_observerships as $observership) { $title = $observership->getTitle(); if ($observership->getStatus() == "pending" || $observership->getStatus() == "approved" || $observership->getStatus() == "rejected") { if ($observership->delete()) { $deleted[] = $title; } else { add_error("An error ocurred while attempting to delete the observership <strong>" . $title . "</strong>. An administrator has been informed, please try again later.\n\t\t\t\t\t\t\t\t\t\t<br />You will be automatically redirected to the My Observerships page in 5 seconds, or you can <a href=\"" . ENTRADA_URL . "/profile/observerships\">click here</a>."); }
} 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 { $student_id = clean_input($_GET["id"], "numeric"); $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/observerships?section=add", "title" => "Add Observership"); switch ($STEP) { case 2: $observership_array = $_POST; $observership_array["student_id"] = $student_id; /* * Admins adding observerships are approved automatically. */ $OBSERVERSHIP = Observership::fromArray($observership_array, "add", $student_id); if (!$OBSERVERSHIP->isValid()) { add_error("<strong>Invalid data entered</strong>. Please confirm everything and try again."); } else { if ($OBSERVERSHIP->create()) { $url = ENTRADA_URL . "/admin/users/manage/students?section=observerships&id=" . $student_id; echo display_success("Successfully created Observership. You will be redirected to your Observership index in <strong>5 seconds</strong> or <a href=\"" . $url . "\">click here</a> to go there now."); $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; return; } else { add_error("<strong>Error occurred creating Observership</strong>. Please confirm everything and try again."); } } break; case 1: default:
public function getObservership() { return Observership::get($this->observership_id); }
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; }
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; } } }
require_once 'core/library/Models/mspr/Observership.class.php'; if (!defined("PARENT_INCLUDED") || !defined("IN_PUBLIC_OBSERVERSHIPS")) { exit; } elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) { header("Location: " . ENTRADA_URL); exit; } if (isset($_GET["id"]) && ($tmp = clean_input($_GET["id"], array("int")))) { $OBSERVERSHIP_ID = $tmp; } else { echo display_error("Invalid observership ID provided. Returning to your Observerships index."); $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/profile/observerships\\'', 5000)"; return; } $BREADCRUMB[] = array("url" => ENTRADA_URL . "/profile/observerships?section=edit&id=" . $OBSERVERSHIP_ID, "title" => "Update Observership"); $OBSERVERSHIP = Observership::get($OBSERVERSHIP_ID); if (!$OBSERVERSHIP) { echo display_error("Invalid observership ID provided. Returning to your Observerships index."); $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/profile/observerships\\'', 5000)"; return; } if ($OBSERVERSHIP->getStudentId() !== $ENTRADA_USER->getActiveId() || !in_array(strtolower($OBSERVERSHIP->getStatus()), array('pending', 'rejected'))) { echo display_error("You are not authorized to update the selected Observership. Returning to your Observerships index."); $ONLOAD[] = "setTimeout('window.location=\\'" . ENTRADA_URL . "/profile/observerships\\'', 5000)"; return; } switch ($STEP) { case 2: echo "<h1>Update Observership</h1>"; $observership_array = $_POST; if ($OBSERVERSHIP->getStatus() == "rejected") {
* * @author Organisation: Queen's University * @author Unit: School of Medicine * @author Developer: Ryan Warner <*****@*****.**> * @copyright Copyright 2012 Queen's University. All Rights Reserved. * */ if (!defined("PARENT_INCLUDED")) { exit; } $unique_id = isset($_GET["unique_id"]) ? clean_input($_GET["unique_id"], "alphanumeric") : NULL; echo "<h1>Observership Confirmation</h1>"; if ($unique_id) { require_once ENTRADA_CORE . "/library/Models/mspr/Observership.class.php"; $step = isset($_POST["step"]) ? (int) $_POST["step"] : '1'; $observership = Observership::getByUniqueID($unique_id); if ($observership && $observership->getStatus() == "approved") { switch ($step) { case 2: if ($_POST["action"] == "Confirm" || $_POST["action"] == "Deny") { $PROCESSED["status"] = $_POST["action"] == "Confirm" ? "confirmed" : "denied"; } if ($PROCESSED["status"]) { $query = "UPDATE `student_observerships` SET `status` = " . $db->qstr($PROCESSED["status"]) . " WHERE `id` = " . $db->qstr($observership->getID()); if ($db->Execute($query)) { add_success("Thank you for updating this observership."); } else { application_log("error", "Error occurred when attempting to update `student_observershisp` [" . $observership->getID() . "], DB said: " . $db->ErrorMsg()); add_error("An error ocurred, we were unable to update the observership. A system administrator has been informed, please try again later."); } } else {
* @author Unit: School of Medicine * @author Developer: Matt Simpson <*****@*****.**> * @copyright Copyright 2010 Queen's University. All Rights Reserved. * */ require_once 'core/library/Models/mspr/Observership.class.php'; if (!defined("PARENT_INCLUDED") || !defined("IN_PUBLIC_OBSERVERSHIPS")) { exit; } elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) { header("Location: " . ENTRADA_URL); exit; } $BREADCRUMB[] = array("url" => ENTRADA_URL . "/profile/observerships?section=add", "title" => "Create Observerships"); switch ($STEP) { case 2: $OBSERVERSHIP = Observership::fromArray($_POST, "add"); if (!$OBSERVERSHIP->isValid()) { add_error("<strong>Invalid data entered</strong>. Please confirm everything and try again."); } else { if ($OBSERVERSHIP->create()) { if (isset($AGENT_CONTACTS["observership"])) { $message = ""; $message .= "The following observership request has been submitted:\n"; $message .= "======================================================\n"; $message .= "\n"; $message .= "Submitted at: " . date("Y-m-d H:i", time()) . "\n"; $message .= "Submitted by: " . $ENTRADA_USER->getFullname(false) . "\n"; $message .= "E-Mail Address: " . $ENTRADA_USER->getEmail() . "\n"; $message .= "\n"; $message .= "Observership details:\n"; $message .= "---------------------\n";
} if ($NOTICE) { echo display_notice(); } if ($SUCCESS) { echo display_success(); } $HEAD[] = "<script type=\"text/javascript\"> var SITE_URL = '" . ENTRADA_URL . "';</script>"; $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/users.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>"; $HEAD[] = "<link href=\"" . ENTRADA_URL . "/javascript/calendar/css/xc2_default.css?release=" . html_encode(APPLICATION_VERSION) . "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />"; $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/calendar/config/xc2_default.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>"; $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/calendar/script/xc2_inpage.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>"; $HEAD[] = "<script type=\"text/javascript\">\n\t\t\tfunction provStateFunction(countries_id) {\t\n\t\t\t\tvar url='" . webservice_url("clerkship_prov") . "';\n\t\t\t\turl=url+'?countries_id='+countries_id+'&prov_state=" . rawurlencode($OBSERVERSHIP->getProv() ? clean_input($OBSERVERSHIP->getProv(), array("notags", "trim")) : $PROCESSED["prov_state"]) . "';\n\t\t\t\tnew Ajax.Updater(\$('prov_state_div'), url, \n\t\t\t\t\t{ \n\t\t\t\t\t\tmethod:'get',\n\t\t\t\t\t\tonComplete: function () {\n\t\t\t\t\t\t\tgenerateAutocomplete();\n\t\t\t\t\t\t\tif (\$('prov_state').selectedIndex || \$('prov_state').selectedIndex === 0) {\n\t\t\t\t\t\t\t\t\$('prov_state_label').removeClassName('form-nrequired');\n\t\t\t\t\t\t\t\t\$('prov_state_label').addClassName('form-required');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\$('prov_state_label').removeClassName('form-required');\n\t\t\t\t\t\t\t\t\$('prov_state_label').addClassName('form-nrequired');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t}\n\t\t\t</script>\n"; $ONLOAD[] = "provStateFunction(\$F(\$('observership_form')['countries_id']))"; if (!$OBSERVERSHIP) { $OBSERVERSHIP = new Observership(); } ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#activity_type').change(function(){ var type = jQuery(this).val(); if (type == 'ipobservership') { jQuery('#observership_details').slideDown(); } else { jQuery('#observership_details').slideUp(); } }); jQuery('#observership_details').hide();
public function next($id) { global $db; $query = "\tSELECT * FROM `student_observerships` \n\t\t\t\t\tWHERE `status` = 'pending' \n\t\t\t\t\tAND `id` > " . $db->qstr($id) . " LIMIT 1"; error_log($query); $response = $db->GetRow($query); if (!$response) { return false; } $next = Observership::fromArray($response); foreach ($next as $field => $value) { $this->{$field} = $value; } return $this; }
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; } } }