public function delete() { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isProgramChair()) { redirect('Login/logout'); } if (!$this->uri->segment(3)) { redirect('Coursemanager/index'); } $course = new Course_model(); if (!$course->loadPropertiesFromPrimaryKey($this->uri->segment(3))) { redirect('Coursemanager/index'); } $course->delete(); redirect('Coursemanager/index/' . $course->getCourseName()); }
private function collectCourseData($curriculumID) { #get list of all curriculumcourseslots for names of courses $curriculum = new Curriculum_model(); $curriculum->loadPropertiesFromPrimaryKey($curriculumID); $currCourseList = $curriculum->getCurriculumCourseSlots(); #Courses list to grab courseIDs from courseName and course Number $course = new Course_model(); $courseList = $course->getAllCourses(); #Create a list of CourseIDs to reference courses $courseIDList = array(); #loop through each currCourseListName and grab the matching courseID's #with matching CourseNames and CourseNumbers foreach ($currCourseList as $currCourse) { $currCourseName = $currCourse->getName(); $nameLength = strlen($currCourseName); $cName = preg_split('%[0-9]%', $currCourseName); $cName = strtoupper($cName[0]); $cNumber = $currCourseName[$nameLength - 3] . $currCourseName[$nameLength - 2] . $currCourseName[$nameLength - 1]; foreach ($courseList as $course) { if ($course->getCourseName() . ' ' . $course->getCourseNumber() == $cName . $cNumber) { array_push($courseIDList, $course->getCourseID()); } } } #now that we have a list of all courseIDs we need to make a list of #courseSectionIDs #first make a list of all courseSections $courseSections = new Course_section_model(); $courseSectionList = $courseSections->getAllCourseSections(); #next make a list to store the courseSectionIDs we need $courseSectionIDList = array(); foreach ($courseIDList as $courseID) { foreach ($courseSectionList as $courseSection) { if ($courseSection->getCourse()->getCourseID() == $courseID) { array_push($courseSectionIDList, $courseSection->getCourseSectionID()); } } } $allCourseData = array(); foreach ($courseSectionIDList as $csID) { $courseData = array('sectionID' => null, 'courseName' => null, 'quarterID' => null, 'quarterName' => null, 'quarterYear' => null, 'sectionNum' => null); $cSection = new Course_section_model(); $cSection->loadPropertiesFromPrimaryKey($csID); $course = $cSection->getCourse(); $cName = $course->getCourseName(); $cNumber = $course->getCourseNumber(); $courseData['quarterID'] = $cSection->getAcademicQuarter()->getAcademicQuarterID(); $courseData['quarterName'] = $cSection->getAcademicQuarter()->getName(); $courseData['quarterYear'] = $cSection->getAcademicQuarter()->getYear(); $courseData['sectionNum'] = $cSection->getSectionName(); $courseData['sectionID'] = $csID; $courseData['courseName'] = $cName . $cNumber; array_push($allCourseData, $courseData); } return $allCourseData; }