From 24465aaec2254a59f895fd7fb35deba6049b7c6e Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Tue, 16 Oct 2007 18:57:26 +0000
Subject: [PATCH] Fix editting of Essential Studies on Course Admin for new
 courses.

---
 application/models/rows/CourseGeneration.php  |  6 +--
 .../models/tables/CourseEsDesignations.php    | 39 +++++++++++--------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/application/models/rows/CourseGeneration.php b/application/models/rows/CourseGeneration.php
index 740ad469..c0ef6f4a 100644
--- a/application/models/rows/CourseGeneration.php
+++ b/application/models/rows/CourseGeneration.php
@@ -180,11 +180,7 @@ class CourseGeneration extends Asset
                                                                                $this->courseNumber,
                                                                                $this->courseLetter);
         if (is_null($courseCode)) {
-            if (is_null($college)) {
-                return array(array());
-            } else {
-                return array();
-            }
+            return CourseEsDesignations::getInstance()->getEmptyEssentialStudiesArray($college);
         }
 
         return CourseEsDesignations::getInstance()->getEssentialStudiesAreas($courseCode, $college);
diff --git a/application/models/tables/CourseEsDesignations.php b/application/models/tables/CourseEsDesignations.php
index c50bbf4f..a7724945 100644
--- a/application/models/tables/CourseEsDesignations.php
+++ b/application/models/tables/CourseEsDesignations.php
@@ -63,22 +63,7 @@ class CourseEsDesignations extends Nmc_Db_Table
         $where = implode(' AND ', $where);
 
         $results = $this->fetchAll($where);
-        $areaCodes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
-        $colleges = Colleges::getInstance()->fetchAll();
-
-        $areas = array();
-        if ($college) {
-            foreach ($areaCodes as $areaCode) {
-                $areas[$areaCode] = false;
-            }
-        } else {
-            foreach ($colleges as $collegeRow) {
-                $areas[$collegeRow->name] = array();
-                foreach ($areaCodes as $areaCode) {
-                    $areas[$collegeRow->name][$areaCode] = false;
-                }
-            }
-        }
+        $areas = $this->getEmptyEssentialStudiesArray($college);
 
         foreach ($results as $row) {
             if ($college) {
@@ -113,4 +98,26 @@ class CourseEsDesignations extends Nmc_Db_Table
             }
         }
     }
+
+    public function getEmptyEssentialStudiesArray(College $college = null)
+    {
+        $areaCodes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
+        $colleges = Colleges::getInstance()->fetchAll();
+
+        $areas = array();
+        if ($college) {
+            foreach ($areaCodes as $areaCode) {
+                $areas[$areaCode] = false;
+            }
+        } else {
+            foreach ($colleges as $collegeRow) {
+                $areas[$collegeRow->name] = array();
+                foreach ($areaCodes as $areaCode) {
+                    $areas[$collegeRow->name][$areaCode] = false;
+                }
+            }
+        }
+
+        return $areas;
+    }
 }
\ No newline at end of file
-- 
GitLab