function admin_display_courses
Search API
7.x admin.courses.inc | admin_display_courses() |
6.x admin.courses.inc | admin_display_courses() |
4.x admin.courses.inc | admin_display_courses() |
5.x admin.courses.inc | admin_display_courses() |
This function displays all of our courses for us to edit.
1 string reference to 'admin_display_courses'
- schools_content_alter in modules/
schools/ schools.module
File
- modules/
admin/ admin.courses.inc, line 9
Code
function admin_display_courses() {
$rtn = "";
// Do this using $render array, so it can be altered
// by hook_content_alter
$render = array();
$render ['#id'] = 'admin_display_courses';
$de_catalog_year = admin_get_de_catalog_year();
fp_add_css(fp_get_module_path("admin") . "/css/admin.css");
$cc = 1;
$show_hidden = fp_trim(@$_GET ["show_hidden"]);
if ($show_hidden != "") {
$_SESSION ["dehidden"] = $show_hidden;
}
else {
$show_hidden = @$_SESSION ["dehidden"];
}
// Get the "upper range" (UR) and
// lower range (LR) of the courses in question...
$ur = fp_trim(@$_GET ["ur"]);
$lr = fp_trim(@$_GET ["lr"]);
if ($ur == "") {
// meaning, no range was set. Use A - AZZZZZ, so, all of the A's.
$ur = @$_SESSION ["dec_ur"];
$lr = @$_SESSION ["dec_lr"];
if ($ur == "") {
// if still blank, assign it..
$ur = "A";
$lr = "AZZZZ";
}
}
$_SESSION ["dec_ur"] = $ur;
$_SESSION ["dec_lr"] = $lr;
fp_set_title(t("Courses for @year", array("@year" => $de_catalog_year)));
$html = "";
$letter_ranges = array(
"A" => array("A", "AZZZZ"),
"B" => array("B", "BZZZZ"),
"C-CN" => array("C", "CNZZZ"),
"CO-CZ" => array("CO", "CZZZZ"),
"D" => array("D", "DZZZZ"),
"E" => array("E", "EZZZZ"),
"F" => array("F", "FZZZZ"),
"G" => array("G", "GZZZZ"),
"H" => array("H", "HZZZZ"),
"I-L" => array("I", "LZZZZ"),
"M-MR" => array("M", "MRZZZ"),
"MS-MZ" => array("MS", "MZZZZ"),
"N-O" => array("N", "OZZZZ"),
"P" => array("P", "PZZZZ"),
"Q-R" => array("Q", "RZZZZ"),
"S-SO" => array("S", "SOZZZ"),
"SP-SZ" => array("SP", "SZZZZ"),
"T-Z" => array("T", "ZZZZZ"),
);
$html .= "<div class='admin-courses-select-letter-bar'>
";
foreach ($letter_ranges as $disp => $vals) {
$html .= l($disp, "admin/courses", "de_catalog_year=$de_catalog_year&ur=" . $vals [0] . "&lr=" . $vals [1], array("class" => "admin-courses-letter-link")) . " ";
}
$html .= "</div>
<div >
<div style='padding: 5px;'>
" . l("<i class='fa fa-plus'></i> " . t("Add a course for @year", array("@year" => $de_catalog_year)), "admin/courses/edit-course", "course_id=new&de_catalog_year=$de_catalog_year") . "
" . t("Legend: [e] = Course has at least one add'l excluded name. [v] = Course has at least one add'l valid name.") . "
</div>
</div>
";
$render ['upper_links'] = array(
'value' => $html,
);
$mark = "";
$mark .= "<div class='degrees-filter'>";
$mark .= fp_render_form("admin_courses_list_filter_form");
$mark .= "</div>";
$render ['courses_filter'] = array(
'value' => $mark,
);
$render ['courses_table_top'] = array(
'value' => "<table border='0' cellpadding='5' cellspacing='5' class='disp-courses-table'>
<tr>
<th>" . t("Course") . "</th>
<th>" . t("Hours") . "</th>
<th width='10%'>" . t("Extra") . "</th>
</tr>",
);
$on_mouse_over = "
onmouseover='$(this).addClass(\"selection_highlight\");'
onmouseout='$(this).removeClass(\"selection_highlight\");'
";
$extra_where_conditions = "";
$extra_where_conditions .= " AND exclude != 1 ";
$filter_exclude = @trim($_SESSION ['courses_filter_exclude']);
if ($filter_exclude == 'yes') {
$extra_where_conditions = "";
}
$filter_school = @intval(trim($_SESSION ['courses_filter_school']));
if (module_enabled('schools')) {
if ($filter_school) {
$extra_where_conditions .= " AND school_id = $filter_school ";
}
}
else {
// schools not enabled, so only search for school = 0
$extra_where_conditions .= " AND school_id = 0 ";
}
watchdog("admin", "Viewed admin courses list. Exclude option: $filter_exclude, Range: $ur - $lr, ($de_catalog_year), School id: $filter_school", array(), WATCHDOG_DEBUG);
$q = "SELECT * FROM draft_courses
WHERE
catalog_year = ?
AND subject_id BETWEEN ? AND ?
AND delete_flag = 0
$extra_where_conditions
ORDER BY subject_id, course_num";
$result = db_query($q, $de_catalog_year, $ur, $lr);
while ($cur = db_fetch_array($result)) {
extract($cur, 3, "db");
$ex_names = "";
$val_names = "";
// Check to see if this course has more than one name...
// removed AND `catalog_year`='$de_catalog_year' from query,
// because we don't care what other cat year it came from.
$res2 = db_query("SELECT * FROM draft_courses
WHERE course_id = ?
", $db_course_id);
while ($cur2 = db_fetch_array($res2)) {
if ($cur2 ["subject_id"] == $db_subject_id && $cur2 ["course_num"] == $db_course_num) {
continue;
}
if ($cur2 ["exclude"] == "1") {
$ex_names = "[e]";
}
else {
$val_names = "[v]";
}
}
$spanstyle = "";
if ($db_exclude == "1") {
$spanstyle = "background-color: #ddd;";
}
$temp_course = new Course();
$db_title = $temp_course->fix_title($db_title);
$db_min_hours = $db_min_hours * 1;
$db_max_hours = $db_max_hours * 1;
$db_repeat_hours = $db_repeat_hours * 1;
$hrs = $db_min_hours;
if (trim($db_min_hours) != trim($db_max_hours)) {
$hrs .= " - $db_max_hours";
}
//$hrs .= " hrs";
$rep_hours = "";
if ($db_repeat_hours > $db_min_hours) {
$rep_hours = "<div class='rep-msg'>rep to $db_repeat_hours</div>";
}
// remove special chars from subject_id...
$display_subject_id = $db_subject_id;
$db_subject_id = str_replace("&", "_A_", $db_subject_id);
$url = fp_url("admin/courses/edit-course", "course_id=$db_course_id&subject_id=$db_subject_id&course_num=$db_course_num&de_catalog_year=$de_catalog_year");
$render ['course_row_' . $db_course_id] = array(
'value' => "
<tr style='$spanstyle; cursor:pointer;' $on_mouse_over
onClick='window.location=\"$url\"'
>
<td valign='top' width=''>
<a name='course_$db_course_id'></a>
<div>$display_subject_id $db_course_num - $db_title</div>
</td>
<td>
$hrs$rep_hours
</td>
<td valign='top' >
$ex_names
$val_names
</tr>",
'data' => array(
'course_id' => $db_course_id,
'school_id' => $db_school_id,
'catalog_year' => $de_catalog_year,
'db_row' => $cur,
'subject_id' => $db_subject_id,
'course_num' => $db_course_num,
),
);
} // while
$render ['courses_table_bottom'] = array(
'value' => "</table>",
);
$rtn .= fp_render_content($render);
return $rtn;
}