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; } }
} 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:
* @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";
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; }