public function executeIndex(sfWebRequest $request) { $this->buildSubmenu($request); $id = $request->getParameter("id"); $conn = Propel::getConnection(); $this->courseObj = CoursePeer::retrieveByPK($id, $conn); if (!is_object($this->courseObj)) { $this->forward404(); } // courseDetail $detList = $this->courseObj->getCourseDetails(null, $conn); if (count($detList) > 0) { $this->courseDetail = $detList[0]; } // instructor $detList = CourseInstructorAssociationPeer::getLatestInstructorsForCourseId($this->courseObj->getId(), $conn); $newList = CourseInstructorAssociationPeer::getHistoricalInstructorsForCourseId($this->courseObj->getId(), $conn); if (count($detList) > 0) { $this->currentInstructorList = $detList; $this->pastInstructorList = $newList; } // program $detList = CourseDisciplineAssociationPeer::getRelatedDisciplinesForCourse($this->courseObj, $conn); if (count($detList) > 0) { $this->programList = $detList; } // full exam data $conn = Propel::getConnection(); $c = new Criteria(); $courseCrit = $c->getNewCriterion(ExamPeer::COURSE_ID, $this->courseObj->getId()); $c->addAnd($courseCrit); $c->addAscendingOrderByColumn(ExamPeer::YEAR); $c->addAscendingOrderByColumn(ExamPeer::TYPE); $c->addAscendingOrderByColumn(ExamPeer::DESCR); $examData = ExamPeer::doSelect($c, $conn); // now splice the data up and send it to the frontend $this->examData = array(); $year = ""; $type = ""; foreach ($examData as $exam) { if ($year != $exam->getYear()) { $year = $exam->getYear(); $this->examData[$year] = array(); $type = ""; } if ($type != $exam->getType()) { $type = $exam->getType(); $this->examData[$year][$type] = array(); } $this->examData[$year][$type][] = $exam; } }
public function executeIndex(sfWebRequest $request) { $this->buildSubmenu($request); $id = $request->getParameter("id"); $conn = Propel::getConnection(); $this->courseObj = CoursePeer::retrieveByPK($id, $conn); // courseDetail $detList = $this->courseObj->getCourseDetails(null, $conn); if (count($detList) > 0) { $this->courseDetail = $detList[0]; } // instructor $detList = CourseInstructorAssociationPeer::getLatestInstructorsForCourseId($this->courseObj->getId(), $conn); $newList = CourseInstructorAssociationPeer::getHistoricalInstructorsForCourseId($this->courseObj->getId(), $conn); if (count($detList) > 0) { $this->currentInstructorList = $detList; $this->pastInstructorList = $newList; } // program $detList = CourseDisciplineAssociationPeer::getRelatedDisciplinesForCourse($this->courseObj, $conn); if (count($detList) > 0) { $this->programList = $detList; } }