diff --git a/application/modules/courses/controllers/PublicViewController.php b/application/modules/courses/controllers/PublicViewController.php index f19cb3b337a011c221ec7aabaa88e4fb875d0406..e874200f47bd9b8925275b02b547fbd0b1fca0fa 100644 --- a/application/modules/courses/controllers/PublicViewController.php +++ b/application/modules/courses/controllers/PublicViewController.php @@ -20,6 +20,9 @@ class Courses_PublicViewController extends App_Controller_Action { if ($subject) { $criteria = array('subject' => $subject); $courses = Courses_CourseModel::findWithCriteria($criteria); + foreach ($courses as $course) { + $course->setEffectiveHomeSubject($subject); + } } else { $courses = Courses_CourseModel::findAllActive(); } diff --git a/application/modules/courses/models/CourseModel.php b/application/modules/courses/models/CourseModel.php index 6b949ad70588485dc12dec8de1e197a088057f26..f34d01edc604cf1922c75cdddb773829e1ba56f2 100644 --- a/application/modules/courses/models/CourseModel.php +++ b/application/modules/courses/models/CourseModel.php @@ -1743,7 +1743,20 @@ class Courses_CourseModel extends Unl_Model { $this->_data['title'] = $title; } + + /** + * Used when displaying the course code as if the home subject were something else + * ie: MATH 340 (CSCE 340) instead of CSCE 340 (MATH 340) + * @var unknown_type + */ + protected $_effectiveHomeSubject = ''; + + public function setEffectiveHomeSubject($subject) + { + $this->_effectiveHomeSubject = $subject; + } + public function getCourseCode() { $courseCode = ''; @@ -1752,14 +1765,14 @@ class Courses_CourseModel extends Unl_Model $courseNumbers = array(); foreach ($this->_data['crosslistings'] as $crosslisting) { - if ($crosslisting['type'] != 'home listing') { + if (!$this->_isEffectiveHomeCrosslisting($crosslisting)) { continue; } $homeSubject = $crosslisting['subject']; $courseNumbers[] = str_pad($crosslisting['courseNumber'], 3, '0', STR_PAD_LEFT) . $crosslisting['courseLetter']; } foreach ($this->_data['crosslistings'] as $crosslisting) { - if ($crosslisting['type'] == 'home listing') { + if ($this->_isEffectiveHomeCrosslisting($crosslisting)) { continue; } if ($crosslisting['subject'] != $homeSubject) { @@ -1777,14 +1790,14 @@ class Courses_CourseModel extends Unl_Model if (in_array('Correspondence', $this->getDeliveryMethods())) { $courseNumbers = array(); foreach ($this->_data['crosslistings'] as $crosslisting) { - if ($crosslisting['type'] != 'home listing') { + if (!$this->_isEffectiveHomeCrosslisting($crosslisting)) { continue; } $homeSubject = $crosslisting['subject']; $courseNumbers[] = str_pad($crosslisting['courseNumber'], 3, '0', STR_PAD_LEFT) . $crosslisting['courseLetter']; } foreach ($this->_data['crosslistings'] as $crosslisting) { - if ($crosslisting['type'] == 'home listing') { + if ($this->_isEffectiveHomeCrosslisting($crosslisting)) { continue; } if ($crosslisting['subject'] != $homeSubject) { @@ -1802,7 +1815,15 @@ class Courses_CourseModel extends Unl_Model return $homeSubject . ' ' . $courseCode; } - + + protected function _isEffectiveHomeCrosslisting($crosslisting) + { + if (!$this->_effectiveHomeSubject && $crosslisting['type'] == 'home listing' || $this->_effectiveHomeSubject == $crosslisting['subject']) { + return true; + } + return false; + } + public function setCourseCode($subject, $courseNumber, $courseLetter = null) { if (!self::isSubjectValid($subject)) {