function fp_render_student_profile_header
Search API
6.x theme.inc | fp_render_student_profile_header($bool_mini = TRUE, $extra_profile_items = array()) |
Returns the HTML for the "profile" header html for a student
2 calls to fp_render_student_profile_header()
- AdvisingScreen::output_to_browser in classes/
AdvisingScreen.php - This method outputs the screen to the browser by performing an include(path-to-theme-file.php). All necessary information must be placed into certain variables before the include happens.
- student_profile_display_student_profile_page in modules/
student_profile/ student_profile.module
File
- includes/
theme.inc, line 814
Code
function fp_render_student_profile_header($bool_mini = TRUE, $extra_profile_items = array()) {
global $current_student_id, $screen, $user, $student;
$csid = $current_student_id;
$school_id = db_get_school_id_for_student_id($current_student_id);
$degree_plan = NULL;
$rtn = "";
if (!isset($extra_profile_items ['left_side'])) {
$extra_profile_items ['left_side'] = array();
}
if (!isset($extra_profile_items ['right_side'])) {
$extra_profile_items ['right_side'] = array();
}
// Call a hook to possibly add more items to our profile items.
invoke_hook("alter_student_profile_items", array($bool_mini, &$extra_profile_items));
if (is_object($screen) && is_object($screen->degree_plan)) {
$degree_plan = $screen->degree_plan;
}
if (!isset($student) || $student == NULL || !is_object($student)) {
$student = new Student($current_student_id);
}
if ($degree_plan == NULL) {
// Degree plan is still null. This probably means we are NOT on an advising screen, so, let's
// use a FlightPath object to init our degree plan, which might actually be a combination of degrees.
// First, we can cheat by seeing if we have anything cached for this student the last time their degree plan
// was loaded. Using this,
// its much faster & memory-friendly than trying to re-init a whole new FlightPath object and DegreePlan object(s).
$bool_got_from_simple_cache = FALSE;
// TODO: Check for _what_if if we are in what if mode?
if (isset($_SESSION ["fp_simple_degree_plan_cache_for_student"])) {
if ($_SESSION ["fp_simple_degree_plan_cache_for_student"]["cwid"] == $csid) {
// Yes, it's for this student. Load her up.
$degree_plan = new DegreePlan();
$degree_plan->degree_id = $_SESSION ["fp_simple_degree_plan_cache_for_student"]["degree_id"];
$degree_plan->combined_degree_ids_array = $_SESSION ["fp_simple_degree_plan_cache_for_student"]["combined_degree_ids_array"];
$degree_plan->is_combined_dynamic_degree_plan = $_SESSION ["fp_simple_degree_plan_cache_for_student"]["is_combined_dynamic_degree_plan"];
$bool_got_from_simple_cache = TRUE;
}
}
if (!$bool_got_from_simple_cache) {
// didn't get it from the simple cache, so load it all fresh.
$fp = new FlightPath($student);
$fp->init(TRUE);
$degree_plan = $fp->degree_plan;
}
}
$cat_year = $student->catalog_year . "-" . ($student->catalog_year + 1);
$rank = $student->rank;
// Should we display a catalog year warning? This is
// something that can be part of a settings table.
if ($student->catalog_year < intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id))) {
$alert_msg = "";
$alert_msg .= "<b>" . t("Important Notice:") . "</b> " . t("FlightPath cannot display degree plans from catalogs earlier than %earliest.
The student's catalog year is %current, which means that the degree plan displayed may not accurately
represent this student's degree requirements.", array("%earliest" => intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id)) . "-" . (intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id)) + 1), "%current" => $cat_year));
$cat_year = "<span class='catalog-year-alert-early'>$cat_year<a href='javascript:fp_alert(\"$alert_msg\");' title='" . t("Important Notice") . "'><i class='fa fa-exclamation-triangle'></i></a></span>";
$bool_catalog_warning = true;
}
if (variable_get_for_school("current_catalog_year", '', $school_id) > intval(variable_get_for_school("earliest_catalog_year", 2006, $school_id))) {
// Is the student's catalog set beyond the range that
// FP has data for? If so, show a warning.
if ($student->catalog_year > variable_get_for_school("current_catalog_year", '', $school_id))
{
$alert_msg = t("This student's catalog year is @cat_year,
and specific curriculum requirements are not yet
available for this year.
To advise this student according to @new_cat
requirements, select the student's major using What If.", array("@cat_year" => $cat_year, "@new_cat" => variable_get_for_school("current_catalog_year", '', $school_id) . "-" . (variable_get_for_school("current_catalog_year", '', $school_id) + 1)));
$cat_year = "<span class='catalog-year-alert-too-far'>$cat_year<a href='javascript:fp_alert(\"$alert_msg\");' title='" . t("Important Notice") . "'><i class='fa fa-exclamation-triangle'></i></a></span>";
$bool_future_catalog_warning = true;
}
}
$db = get_global_database_handler();
///////////////////////////
$degree_title_div = "";
$s = ""; // plural degrees?
$bool_show_track_selection_link = FALSE;
// We are trying to figure out what to display for the Degree field. If there is only ONE degree plan
// to worry about, then we will display it.
if ($degree_plan == null || $degree_plan->is_combined_dynamic_degree_plan != TRUE) {
// This is an ordinary degree plan.
$use_degree_plan = $degree_plan;
$degree_title = "";
if ($degree_plan != NULL) {
$degree_title = $degree_plan->get_title2(TRUE);
}
/**
* This degree is in fact a track.
*/
if (strstr($degree_plan->major_code, "_")) {
$degree_title = $degree_plan->get_title2(TRUE, TRUE);
if ($degree_plan->db_allow_dynamic == 0) {
// This degree is NON-dynamic. Meaning, if we change tracks, we should do it from the perspective
// of the original major code, and how FP 4.x did things.
$temp = explode("_", $degree_plan->major_code);
$m = trim($temp [0]);
// Remove trailing | if its there.
$m = rtrim($m, "|");
$use_degree_plan = $db->get_degree_plan($m, $degree_plan->catalog_year, TRUE); // the original degree plan!
}
}
if ($screen->screen_mode == "detailed") {
$degree_title .= " ($degree_plan->major_code)";
}
if ($use_degree_plan != null && $use_degree_plan->get_available_tracks()) {
$bool_show_track_selection_link = TRUE;
}
$degree_title_div = "<div class='degree-title'>$degree_title</div>";
//array_push($display_array, t("Degree:") . " ~~ " . $degree_title);
}
else {
// This degree plan is made from combining several other degrees. let's trot them out and display them as well.
$t_degree_plan_titles = "";
$dc = 0;
foreach ($degree_plan->combined_degree_ids_array as $t_degree_id) {
$t_degree_plan = new DegreePlan();
$t_degree_plan->degree_id = $t_degree_id;
$t_degree_plan->load_descriptive_data();
if ($t_degree_plan->get_available_tracks()) {
$bool_show_track_selection_link = TRUE;
}
// Add it to our box...
// If more than one major/minor, etc, combine them into one div
$t_title = $t_degree_plan->get_title2(TRUE);
$t_class = $t_degree_plan->degree_class;
$t_class_details = fp_get_degree_classification_details($t_class);
// If this is actually a track, let's get the track's title instead.
if ($x = $t_degree_plan->get_track_title(TRUE)) {
$t_title = $x;
}
if ($t_class_details ["level_num"] == 3) {
$t_title = "<span class='level-3-raquo'>»</span>" . $t_title;
}
$machine_major_code = fp_get_machine_readable($t_degree_plan->major_code);
if ($t_degree_plan->track_code != "") {
$machine_major_code .= "-" . fp_get_machine_readable($t_degree_plan->track_code);
}
$t_degree_plan_titles .= "<span class='multi-degree-title multi-degree-class-" . $t_class . "
multi-degree-class-level-" . $t_class_details ["level_num"] . "
multi-degree-code-$machine_major_code multi-degree-num-$dc'>
" . $t_title . "</span><span class='multi-degree-comma'>,</span>";
$dc++;
$s = "s";
}
// Trim the last comma off the end of t_degree_plan_titles
$t_degree_plan_titles = rtrim($t_degree_plan_titles, "<span class='multi-degree-comma'>,</span>");
$degree_title_div = $t_degree_plan_titles;
}
// Now, do we want to add an option to select a track to the degree_title_div?
if ($bool_show_track_selection_link) {
// Are we in what_if mode?
$advising_what_if = @$GLOBALS ["fp_advising"]["advising_what_if"];
// We want to add a link to the popup to let the user select other degree tracks.
$op_link = "<a class='degree-op-link-change-degree-options' href='javascript: popupSmallIframeDialog(\"" . fp_url("advise/popup-change-track", "advising_what_if=$advising_what_if") . "\",\"" . t("Select a Degree Option") . "\");'
title='" . t("Change degree options") . "'><i class='fa fa-cog'></i></a>";
if (!$screen || $screen->screen_mode == "not_advising" || $screen->screen_mode == "detailed") {
$op_link = "";
}
if (!user_has_permission("can_advise_students")) {
if (@$GLOBALS ["fp_advising"]["advising_what_if"] != "yes")
{
// In other words, we do not have permission to advise,
// and we are not in whatIf, so take out the link.
$op_link = "";
}
}
if ($op_link) {
$degree_title_div .= "<span class='degree-op-link'>$op_link</span>";
}
}
$right_side_top = "<h2> </h2>"; // need spacers on purpose
$whatifclass = "";
if (@$GLOBALS ["fp_advising"]["advising_what_if"] == "yes") {
$whatifclass = "student-mini-profile-what-if-mode";
// Set the cat year to whatever our What If cat year was, current if we can't find it.
$what_if_catalog_year = @$GLOBALS ["fp_advising"]["what_if_catalog_year"];
if ($what_if_catalog_year != 0 && $what_if_catalog_year != "") {
$student->catalog_year = $what_if_catalog_year;
}
else {
// Only change to current if that is how our settings are set...
if (variable_get_for_school("what_if_catalog_year_mode", "current", $school_id) == "current") {
$student->catalog_year = variable_get_for_school("current_catalog_year", '', $school_id);
}
}
//$what_if_select = "<span class='what-if-change-settings'>" . l("<i class='fa fa-cog'></i> " . t("Change Settings"), "what-if", "advising_what_if=yes&what_if_major_code=none&what_if_track_code=none&what_if_track_degree_ids=none¤t_student_id=$current_student_id") . "</span>";
//$right_side_top = "<h2 class='what-if-notice'>" . t("What If Mode") . "</h2>";
}
// Figure out what the user's image is based on their account.
$image_url = "";
$student_account_user_id = db_get_user_id_from_cwid($student->student_id, 'student');
if ($student_account_user_id) {
$student_account = fp_load_user($student_account_user_id);
if ($student_account) {
$image_url = @$student_account->settings ['image_url'];
}
}
$rtn .= "<div class='student-mini-profile $whatifclass'>
";
if ($image_url) {
$rtn .= "<div class='header-profile-image'>
<img src='$image_url' class='student-profile-image' />
</div> <!-- profile-image -->
";
}
$school_html = $school_name = "";
if (module_enabled("schools")) {
// If we have schools module enabled, let's find out what school this student belongs to and display it
$defs = schools_get_school_definitions(TRUE);
$temp = @$defs [$student->school_id];
if ($temp) {
$school_html .= "
<div class='profile-detail-line profile-inline-line profile-detail-line-school profile-line-detail-school-$student->school_id'>
<label>" . t("School:") . "</label> <span class='profile-line-content'>" . $temp ['name'] . "</span>
</div>
";
}
}
$rtn .= " <div class='profile-top-details-wrapper profile-top-wrapper-left-side'>
<div class='profile-detail-line profile-detail-line-student-name-cwid'>
<h2>$student->name ($student->student_id)</h2>
</div>
$school_html
<div class='profile-detail-line profile-inline-line profile-detail-line-degree'>
<label>" . t("Degree$s:") . "</label> <span class='profile-line-content'>$degree_title_div</span>
</div>
<div class='profile-detail-line profile-inline-line profile-detail-line-cat-year'>
<label>" . t("Catalog Year:") . "</label> <span class='profile-line-content'>$cat_year</span>
</div>
";
if (isset($extra_profile_items ['left_side'])) {
foreach ($extra_profile_items ['left_side'] as $details) {
$label = @$details ['label'];
$content = @$details ['content'];
$extra_class = @$details ['extra_class'];
$mobile_content = @$details ['mobile_content']; // displayed in an initially-hidden span, if provided.
if ($mobile_content) {
$mobile_content = "<span style='display:none;' class='mobile-profile-line-content'>$mobile_content</span>";
$extra_class .= " has-mobile-content";
}
$rtn .= "<div class='profile-detail-line profile-inline-line $extra_class'>
<label>$label</label> <span class='profile-line-content'>$content</span>$mobile_content
</div>";
}
}
$rtn .= "</div>
<div class='profile-top-details-wrapper profile-top-wrapper-right-side'>
<div class='profile-detail-line profile-detail-line-empty'>
$right_side_top <!-- need something here so it lines up correctly -->
</div>
<div class='profile-detail-line profile-inline-line profile-detail-line-rank'>
<label>" . t("Classification:") . "</label> <span class='profile-line-content'>$rank</span>
</div>
<div class='profile-detail-line profile-inline-line profile-detail-line-cumu'>
<label>" . t("Cumulative:") . "</label> <span class='profile-line-content'>{$student->cumulative_hours} " . t("hrs") . " / " . fp_truncate_decimals($student->gpa, 3) . " " . t("GPA") . "</span>
</div>
";
if (isset($extra_profile_items ['right_side'])) {
foreach ($extra_profile_items ['right_side'] as $details) {
$label = @$details ['label'];
$content = @$details ['content'];
$extra_class = @$details ['extra_class'];
$mobile_content = @$details ['mobile_content']; // displayed in an initially-hidden span, if provided.
if ($mobile_content) {
$mobile_content = "<span style='display:none;' class='mobile-profile-line-content'>$mobile_content</span>";
$extra_class .= " has-mobile-content";
}
$rtn .= "<div class='profile-detail-line profile-inline-line $extra_class'>
<label>$label</label> <span class='profile-line-content'>$content</span>$mobile_content
</div>";
}
}
$rtn .= "
</div>
<div class='clear'></div>
</div>
";
return $rtn;
}