function DatabaseHandler::duplicate_course_for_year
Search API
6.x DatabaseHandler.php | DatabaseHandler::duplicate_course_for_year($course = null, $catalog_year) |
File
- classes/
DatabaseHandler.php, line 599
Class
Code
function duplicate_course_for_year($course = null, $catalog_year)
{
// Duplicate the course for the given catalog_year.
// If it already exists for that catalog_year, delete it from the
// table.
// In other words, copy all course data from some valid year into this
// new year.
$c = $course;
$course_id = $c->course_id;
$min_hours = $c->min_hours;
$max_hours = $c->max_hours;
if (@$c->bool_ghost_min_hour) {
$min_hours = 0;
}
if (@$c->bool_ghost_hour) {
$max_hours = 0;
}
$res = $this->db_query("DELETE FROM draft_courses
WHERE
course_id = ?
AND catalog_year = ?
AND subject_id = ?
AND course_num = ?
AND school_id = ? ", $course_id, $catalog_year, $c->subject_id, $c->course_num, $c->school_id);
$res2 = $this->db_query("INSERT INTO draft_courses(course_id,
subject_id, course_num, catalog_year,
title, description, min_hours, max_hours,
repeat_hours, exclude, school_id) values (
?,?,?,?,?,?,?,?,?,?,?)
", $course_id, $c->subject_id, $c->course_num, $catalog_year, $c->title, $c->description, $min_hours, $max_hours, $c->repeat_hours, $c->db_exclude, $c->school_id);
}