function course_node_delete in Course 7
Same name and namespace in other branches
- 7.2 course.module \course_node_delete()
Implements hook_node_delete().
File
- ./
course.module, line 819 - course.module Core functionality for Courses.
Code
function course_node_delete($node) {
if (course_node_is_course($node)) {
// Clean up course specific settings and enrollments when a course is
// deleted.
db_delete('course_node')
->condition('nid', $node->nid)
->execute();
db_delete('course_enrollment')
->condition('nid', $node->nid)
->execute();
db_delete('course_report')
->condition('nid', $node->nid)
->execute();
$query = db_select('course_outline', 'co');
$query
->join('course_outline_fulfillment', 'cof', 'co.coid = cof.coid');
$result = $query
->fields('co')
->condition('co.nid', $node->nid)
->execute();
while ($row = $result
->fetch()) {
db_delete('course_outline_fulfillment')
->condition('coid', $row->coid)
->execute();
}
db_delete('course_outline')
->condition('nid', $node->nid)
->execute();
}
}