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.
File
- modules/
admin/ admin.courses.inc, line 9
Code
function admin_display_courses() {
$rtn = "";
$de_catalog_year = admin_get_de_catalog_year();
fp_add_css(fp_get_module_path("admin") . "/css/admin.css");
$cc = 1;
$show_hidden = 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 = trim($_GET ["ur"]);
$lr = 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)));
$rtn .= "<h2 class='title'>" . t("Courses for @year", array("@year" => $de_catalog_year)) . "</h2>";
$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"),
);
$rtn .= "<div class='admin-courses-select-letter-bar'>
";
foreach ($letter_ranges as $disp => $vals) {
$rtn .= l($disp, "admin/courses", "de_catalog_year=$de_catalog_year&ur=" . $vals [0] . "&lr=" . $vals [1], array("class" => "admin-courses-letter-link")) . " ";
}
$rtn .= "</div>
<div class='tenpt'>
<div style='padding: 5px;'>
" . l(t("Add a course for @year", array("@year" => $de_catalog_year)), "admin/courses/edit-course", "course_id=new&de_catalog_year=$de_catalog_year") . "
</div>
Legend: <br> [e] = Course has at least one add'l excluded name.
[v] = Course has at least one add'l valid name.
</div>
";
$exclude_line = "and exclude != 1";
if ($show_hidden == "yes") {
$rtn .= "<div class='tenpt'><b>" . t("Showing excluded courses.") . " ";
$rtn .= l(t("Hide?"), "admin/courses", "de_catalog_year=$de_catalog_year&show_hidden=no");
$rtn .= "</b></div>";
$exclude_line = "";
}
else {
$rtn .= "<div class='tenpt'><b>" . t("Hiding excluded courses.") . " ";
$rtn .= l(t("Show?"), "admin/courses", "de_catalog_year=$de_catalog_year&show_hidden=yes");
$rtn .= "</b></div>";
}
$rtn .= "<hr><br>
<table border='0' cellpadding='3' cellspacing='0'>";
$q = "SELECT * FROM draft_courses
WHERE
catalog_year = '?'
AND subject_id BETWEEN '?' AND '?'
AND delete_flag = '0'
$exclude_line
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);
$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 = " rep to $db_repeat_hours hrs.";
}
// remove special chars from subject_id...
$display_subject_id = $db_subject_id;
$db_subject_id = str_replace("&", "_A_", $db_subject_id);
$rtn .= "<tr style='$spanstyle'>
<td valign='top' width='90%'><a name='course_$db_course_id'></a>";
$rtn .= "<div style='$spanstyle padding:3px;'>";
//<a href='admin.php?performAction=editSpecificCourse&course_id=$db_course_id&subject_id=$db_subject_id&course_num=$db_course_num&de_catalog_year=$de_catalog_year'>$display_subject_id $db_course_num - $db_title</a> - $hrs$rep_hours</div>";
$rtn .= l("$display_subject_id $db_course_num - $db_title", "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") . " - $hrs$rep_hours</div>";
$rtn .= "</td>
<td valign='top' width='5%'>
$ex_names
</td>
<td valign='top' width='5%'>
$val_names
</td>
</tr>";
} // while
$rtn .= "</table>";
return $rtn;
}