Skip to content
Snippets Groups Projects
Commit fa594ac3 authored by Tim Steiner's avatar Tim Steiner
Browse files

Remove dependency on static college and major fields so that they can be...

Remove dependency on static college and major fields so that they can be removed from the BulletinSection and FourYearPlanGeneration tables. @1h00
parent 8ff30320
Branches use-colleges-majors-from-db
No related tags found
No related merge requests found
...@@ -105,7 +105,7 @@ class Bulletin_ApprovalActionBulletinCollegeRouterModel extends Requests_Approva ...@@ -105,7 +105,7 @@ class Bulletin_ApprovalActionBulletinCollegeRouterModel extends Requests_Approva
$requestSections = Bulletin_SectionModel::findWithRequest($requests); $requestSections = Bulletin_SectionModel::findWithRequest($requests);
foreach ($requests as $request) { foreach ($requests as $request) {
$section = $requestSections[$request->getId()]; $section = $requestSections[$request->getId()];
$college = $section->getCollege(); $college = $section->getCollegeLong();
$request->setState($college); $request->setState($college);
} }
Requests_RequestModel::save($requests); Requests_RequestModel::save($requests);
......
...@@ -205,7 +205,7 @@ class Bulletin_RepositoryModel ...@@ -205,7 +205,7 @@ class Bulletin_RepositoryModel
public function getFilePathForSection(Bulletin_SectionModel $section) public function getFilePathForSection(Bulletin_SectionModel $section)
{ {
return $this->getFilePathForCollegeMajorYear( return $this->getFilePathForCollegeMajorYear(
$section->getCollege(), $section->getCollegeLong(),
$section->getMajor(), $section->getMajor(),
$section->getYear() $section->getYear()
); );
......
...@@ -81,12 +81,14 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -81,12 +81,14 @@ class Bulletin_SectionModel extends Unl_Model
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db); $select = new Zend_Db_Select($db);
$select->from(array('b' => 'creqBulletinSections'), array()); $select->from(array('b' => 'creqBulletinSections'), array());
$select->join(array('c' => 'creqColleges'), 'b.collegeId = c.collegeId', array('college' => 'c.description'));
$select->join(array('r' => 'creqRequests'), 'b.request = r.requestId', array('requestId')); $select->join(array('r' => 'creqRequests'), 'b.request = r.requestId', array('requestId'));
$select->where('college = ?', $college); $select->where('c.description = ?', $college);
if ($major) { if ($major) {
$select->where('major = ?', $major); $select->join(array('m' => 'creqMajors'), 'b.majorId = m.majorId', array('major' => 'm.name'));
$select->where('m.name = ?', $major);
} else { } else {
$select->where('major IS NULL'); $select->where('majorId IS NULL');
} }
$select->where('r.complete = ?', 'no'); $select->where('r.complete = ?', 'no');
...@@ -110,9 +112,7 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -110,9 +112,7 @@ class Bulletin_SectionModel extends Unl_Model
'bulletinSectionId' => NULL, 'bulletinSectionId' => NULL,
'request' => NULL, 'request' => NULL,
'collegeId' => NULL, 'collegeId' => NULL,
'college' => NULL,
'majorId' => NULL, 'majorId' => NULL,
'major' => NULL,
'year' => NULL, 'year' => NULL,
); );
...@@ -188,9 +188,7 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -188,9 +188,7 @@ class Bulletin_SectionModel extends Unl_Model
$sqlParts[] = $db->quoteInto('(?, ', $model->_data['bulletinSectionId']) $sqlParts[] = $db->quoteInto('(?, ', $model->_data['bulletinSectionId'])
. $db->quoteInto('?, ' , $model->_data['request']) . $db->quoteInto('?, ' , $model->_data['request'])
. $db->quoteInto('?, ' , $model->_data['collegeId']) . $db->quoteInto('?, ' , $model->_data['collegeId'])
. $db->quoteInto('?, ' , $model->_data['college'])
. $db->quoteInto('?, ' , $model->_data['majorId']) . $db->quoteInto('?, ' , $model->_data['majorId'])
. $db->quoteInto('?, ' , $model->_data['major'])
. $db->quoteInto('?) ' , $model->_data['year']); . $db->quoteInto('?) ' , $model->_data['year']);
} }
$sql .= implode(', ', $sqlParts); $sql .= implode(', ', $sqlParts);
...@@ -200,9 +198,7 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -200,9 +198,7 @@ class Bulletin_SectionModel extends Unl_Model
. ' creqBulletinSectionsUpdate AS b ' . ' creqBulletinSectionsUpdate AS b '
. 'SET a.request = b.request, ' . 'SET a.request = b.request, '
. ' a.collegeId = b.collegeId, ' . ' a.collegeId = b.collegeId, '
. ' a.college = b.college, '
. ' a.majorId = b.majorId, ' . ' a.majorId = b.majorId, '
. ' a.major = b.major, '
. ' a.year = b.year ' . ' a.year = b.year '
. 'WHERE a.bulletinSectionId = b.bulletinSectionId '; . 'WHERE a.bulletinSectionId = b.bulletinSectionId ';
$db->query($sql); $db->query($sql);
...@@ -213,14 +209,12 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -213,14 +209,12 @@ class Bulletin_SectionModel extends Unl_Model
{ {
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
$sql = 'INSERT INTO creqBulletinSections (`request`, `collegeId`, `college`, `majorId`, `major`, `year`) VALUES '; $sql = 'INSERT INTO creqBulletinSections (`request`, `collegeId`, `majorId`, `year`) VALUES ';
$sqlParts = array(); $sqlParts = array();
foreach ($models as $model) { foreach ($models as $model) {
$sqlParts[] = $db->quoteInto('(?, ', $model->_data['request']) $sqlParts[] = $db->quoteInto('(?, ', $model->_data['request'])
. $db->quoteInto('?, ' , $model->_data['collegeId']) . $db->quoteInto('?, ' , $model->_data['collegeId'])
. $db->quoteInto('?, ' , $model->_data['college'])
. $db->quoteInto('?, ' , $model->_data['majorId']) . $db->quoteInto('?, ' , $model->_data['majorId'])
. $db->quoteInto('?, ' , $model->_data['major'])
. $db->quoteInto('?)' , $model->_data['year']); . $db->quoteInto('?)' , $model->_data['year']);
} }
$sql .= implode(', ', $sqlParts); $sql .= implode(', ', $sqlParts);
...@@ -290,6 +284,20 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -290,6 +284,20 @@ class Bulletin_SectionModel extends Unl_Model
return NULL; return NULL;
} }
public function getCollegeLong()
{
if (!$this->_data['collegeId'] && $this->_data['college']) {
return $this->_data['college'];
}
$colleges = Courses_CourseModel::getCollegeNames();
if (isset($colleges[$this->_data['collegeId']])) {
return $colleges[$this->_data['collegeId']];
}
return NULL;
}
public function setCollegeId($collegeId) public function setCollegeId($collegeId)
{ {
$colleges = Courses_CourseModel::getCollegeNames(); $colleges = Courses_CourseModel::getCollegeNames();
...@@ -297,7 +305,6 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -297,7 +305,6 @@ class Bulletin_SectionModel extends Unl_Model
throw new Exception('College not found.'); throw new Exception('College not found.');
} }
$this->_data['collegeId'] = $collegeId; $this->_data['collegeId'] = $collegeId;
$this->_data['college'] = $colleges[$collegeId];
} }
public function setCollege($college) public function setCollege($college)
...@@ -310,7 +317,6 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -310,7 +317,6 @@ class Bulletin_SectionModel extends Unl_Model
} }
$this->_data['collegeId'] = $collegeId; $this->_data['collegeId'] = $collegeId;
$this->_data['college'] = $college;
} }
public function getMajor() public function getMajor()
...@@ -467,11 +473,11 @@ class Bulletin_SectionModel extends Unl_Model ...@@ -467,11 +473,11 @@ class Bulletin_SectionModel extends Unl_Model
if ($section->getMajor()) { if ($section->getMajor()) {
$title = $section->getMajor() . ' ' . substr($section->getYear(), -2) . '-' . substr($section->getYear() + 1, -2); $title = $section->getMajor() . ' ' . substr($section->getYear(), -2) . '-' . substr($section->getYear() + 1, -2);
} else { } else {
$title = $section->getCollege() . ' Main Page ' . substr($section->getYear(), -2) . '-' . substr($section->getYear() + 1, -2); $title = $section->getCollegeLong() . ' Main Page ' . substr($section->getYear(), -2) . '-' . substr($section->getYear() + 1, -2);
} }
$hyphenatedTitle = preg_replace('/[^a-zA-Z0-9]+/', '-', strtolower($title)); $hyphenatedTitle = preg_replace('/[^a-zA-Z0-9]+/', '-', strtolower($title));
$majorName = $section->getMajor() ? $section->getMajor() : $section->getCollege(); $majorName = $section->getMajor() ? $section->getMajor() : $section->getCollegeLong();
$html = <<<EOF $html = <<<EOF
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
......
...@@ -13,7 +13,7 @@ class Bulletin_UtilityModel ...@@ -13,7 +13,7 @@ class Bulletin_UtilityModel
foreach ($data as $i => &$record) { foreach ($data as $i => &$record) {
$section = $requestSections[$record['request']->getId()]; $section = $requestSections[$record['request']->getId()];
$record['extra']['Section'] = $section->getMajor() ? $section->getMajor() : $section->getCollege(); $record['extra']['Section'] = $section->getMajor() ? $section->getMajor() : $section->getCollegeLong();
} }
unset($record); unset($record);
} }
......
...@@ -20,7 +20,7 @@ $this->headScript()->appendFile($this->baseUrl() . '/ice/src/plugins/IceSmartQuo ...@@ -20,7 +20,7 @@ $this->headScript()->appendFile($this->baseUrl() . '/ice/src/plugins/IceSmartQuo
$this->headScript()->appendFile($this->baseUrl() . '/tinymce/jscripts/tiny_mce/tiny_mce.js'); $this->headScript()->appendFile($this->baseUrl() . '/tinymce/jscripts/tiny_mce/tiny_mce.js');
$this->headScript()->appendFile($this->baseUrl() . '/javascript/bulletin/tinymce.js'); $this->headScript()->appendFile($this->baseUrl() . '/javascript/bulletin/tinymce.js');
$this->headScript()->appendFile($this->baseUrl() . '/javascript/bulletin/edit.js'); $this->headScript()->appendFile($this->baseUrl() . '/javascript/bulletin/edit.js');
$this->layout()->pageTitle = 'Editing: ' . ($this->section->getMajor() ? $this->section->getMajor() : $this->section->getCollege()) . ' (' . $this->request->getTypeDescription() . ')'; $this->layout()->pageTitle = 'Editing: ' . ($this->section->getMajor() ? $this->section->getMajor() : $this->section->getCollegeLong()) . ' (' . $this->request->getTypeDescription() . ')';
?> ?>
<form action="<?php echo $this->baseUrl('/bulletin/edit/edit.post'); ?>" method="post" enctype="multipart/form-data"> <form action="<?php echo $this->baseUrl('/bulletin/edit/edit.post'); ?>" method="post" enctype="multipart/form-data">
...@@ -83,7 +83,7 @@ $this->layout()->pageTitle = 'Editing: ' . ($this->section->getMajor() ? $this-> ...@@ -83,7 +83,7 @@ $this->layout()->pageTitle = 'Editing: ' . ($this->section->getMajor() ? $this->
<p>Only used by some Education & Human Sciences and Fine & Performing Arts programs. Please leave blank if there is no information already here for your program. Please contact Brooke Glenn (<a href="mailto:bglenn2@unl.edu">bglenn2@unl.edu</a>, 402-472-6023) if you think you need to add information to this section.</p> <p>Only used by some Education & Human Sciences and Fine & Performing Arts programs. Please leave blank if there is no information already here for your program. Please contact Brooke Glenn (<a href="mailto:bglenn2@unl.edu">bglenn2@unl.edu</a>, 402-472-6023) if you think you need to add information to this section.</p>
<textarea name="other" class="mceEditor"><?php echo $this->other; ?></textarea> <textarea name="other" class="mceEditor"><?php echo $this->other; ?></textarea>
<?php if ($this->section->getCollege() == 'Arts & Sciences') { ?> <?php if ($this->section->getCollegeLong() == 'Arts & Sciences') { ?>
<div> <div>
<h2><label for="justification">Justification</label></h2> <h2><label for="justification">Justification</label></h2>
<?php echo $this->formTextarea('justification', $this->request->getJustification()); ?> <?php echo $this->formTextarea('justification', $this->request->getJustification()); ?>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
$section = $data['section']; $section = $data['section'];
?> ?>
<tr> <tr>
<td><?php echo $this->escape($section->getMajor() ? $section->getMajor() : $section->getCollege()); ?></td> <td><?php echo $this->escape($section->getMajor() ? $section->getMajor() : $section->getCollegeLong()); ?></td>
<td><?php echo $this->escape($request->getTypeDescription()); ?></td> <td><?php echo $this->escape($request->getTypeDescription()); ?></td>
<td> <td>
<a href="<?php echo $this->baseUrl(); ?>/requests/edit/load/sessionId/<?php echo $savedId; ?>">Edit</a> <a href="<?php echo $this->baseUrl(); ?>/requests/edit/load/sessionId/<?php echo $savedId; ?>">Edit</a>
......
...@@ -7,7 +7,7 @@ if ($this->preview) { ...@@ -7,7 +7,7 @@ if ($this->preview) {
} else { } else {
$breadcrumb = 'Viewing'; $breadcrumb = 'Viewing';
} }
$this->layout()->pageTitle = $breadcrumb . ': ' . ($this->section->getMajor() ? $this->section->getMajor() : $this->section->getCollege()) . ' (' . $this->request->getTypeDescription() . ')'; $this->layout()->pageTitle = $breadcrumb . ': ' . ($this->section->getMajor() ? $this->section->getMajor() : $this->section->getCollegeLong()) . ' (' . $this->request->getTypeDescription() . ')';
$originalSection = Bulletin_SectionModel::parseHtml($this->originalFileContents); $originalSection = Bulletin_SectionModel::parseHtml($this->originalFileContents);
$proposedSection = Bulletin_SectionModel::parseHtml($this->proposedFileContents); $proposedSection = Bulletin_SectionModel::parseHtml($this->proposedFileContents);
?> ?>
...@@ -50,7 +50,7 @@ $proposedSection = Bulletin_SectionModel::parseHtml($this->proposedFileContents) ...@@ -50,7 +50,7 @@ $proposedSection = Bulletin_SectionModel::parseHtml($this->proposedFileContents)
</div> </div>
<?php if ($this->section->getCollege() == 'Arts & Sciences') { ?> <?php if ($this->section->getCollegeLong() == 'Arts & Sciences') { ?>
<div> <div>
<h2>Justification</h2> <h2>Justification</h2>
<?php echo $this->escape($this->request->getJustification()); ?> <?php echo $this->escape($this->request->getJustification()); ?>
......
...@@ -86,7 +86,6 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -86,7 +86,6 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
'type' => 'proposed', 'type' => 'proposed',
'removed' => 'no', 'removed' => 'no',
'majorId' => null, 'majorId' => null,
'major' => '',
'courses' => array(), 'courses' => array(),
'notes' => array(), 'notes' => array(),
); );
...@@ -285,8 +284,9 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -285,8 +284,9 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
$select = new Zend_Db_Select($db); $select = new Zend_Db_Select($db);
$select->from(array('g' => 'creqFourYearPlanGenerations'), array('fourYearPlanGenerationId')); $select->from(array('g' => 'creqFourYearPlanGenerations'), array('fourYearPlanGenerationId'));
$select->join(array('m' => 'creqMajors'), 'g.majorId = m.majorId', array('major' => 'name'));
$select->join(array('f' => 'creqFourYearPlans'), 'g.fourYearPlanGenerationId = f.currentGeneration', array()); $select->join(array('f' => 'creqFourYearPlans'), 'g.fourYearPlanGenerationId = f.currentGeneration', array());
$select->where('g.major = ?', $major); $select->where('m.name = ?', $major);
$records = $select->query()->fetchAll(); $records = $select->query()->fetchAll();
if (count($records) == 0) { if (count($records) == 0) {
...@@ -355,8 +355,9 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -355,8 +355,9 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
$select = new Zend_Db_Select($db); $select = new Zend_Db_Select($db);
$select->from(array('f' => 'creqFourYearPlanGenerations'), array()); $select->from(array('f' => 'creqFourYearPlanGenerations'), array());
$select->join(array('m' => 'creqMajors'), 'f.majorId = m.majorId', array('major' => 'name'));
$select->join(array('r' => 'creqRequests'), 'f.request = r.requestId', array('requestId')); $select->join(array('r' => 'creqRequests'), 'f.request = r.requestId', array('requestId'));
$select->where('f.major = ?', $major); $select->where('m.name = ?', $major);
$select->where('r.complete = ?', 'no'); $select->where('r.complete = ?', 'no');
$records = $select->query()->fetchAll(); $records = $select->query()->fetchAll();
...@@ -527,7 +528,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -527,7 +528,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
} }
} }
$sql = 'INSERT INTO creqFourYearPlanGenerations (assetId, parent, fourYearPlan, request, type, removed, majorId, major) VALUES '; $sql = 'INSERT INTO creqFourYearPlanGenerations (assetId, parent, fourYearPlan, request, type, removed, majorId) VALUES ';
$sqlParts = array(); $sqlParts = array();
foreach ($models as $model) { foreach ($models as $model) {
$sqlParts[] = $db->quoteInto('(?, ', $model->_data['assetId']) $sqlParts[] = $db->quoteInto('(?, ', $model->_data['assetId'])
...@@ -536,8 +537,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -536,8 +537,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
. $db->quoteInto('?, ' , $model->_data['request']) . $db->quoteInto('?, ' , $model->_data['request'])
. $db->quoteInto('?, ' , $model->_data['type']) . $db->quoteInto('?, ' , $model->_data['type'])
. $db->quoteInto('?, ' , $model->_data['removed']) . $db->quoteInto('?, ' , $model->_data['removed'])
. $db->quoteInto('?, ' , $model->_data['majorId']) . $db->quoteInto('?)' , $model->_data['majorId']);
. $db->quoteInto('?)' , $model->_data['major']);
} }
$sql .= implode(', ', $sqlParts); $sql .= implode(', ', $sqlParts);
$db->query($sql); $db->query($sql);
...@@ -619,8 +619,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -619,8 +619,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
. $db->quoteInto('?, ' , $model->_data['request']) . $db->quoteInto('?, ' , $model->_data['request'])
. $db->quoteInto('?, ' , $model->_data['type']) . $db->quoteInto('?, ' , $model->_data['type'])
. $db->quoteInto('?, ' , $model->_data['removed']) . $db->quoteInto('?, ' , $model->_data['removed'])
. $db->quoteInto('?, ' , $model->_data['majorId']) . $db->quoteInto('?)' , $model->_data['majorId']);
. $db->quoteInto('?)' , $model->_data['major']);
} }
$sql .= implode(', ', $sqlParts); $sql .= implode(', ', $sqlParts);
$db->query($sql); $db->query($sql);
...@@ -633,8 +632,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -633,8 +632,7 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
. ' a.request = b.request, ' . ' a.request = b.request, '
. ' a.type = b.type, ' . ' a.type = b.type, '
. ' a.removed = b.removed, ' . ' a.removed = b.removed, '
. ' a.majorId = b.majorId, ' . ' a.majorId = b.majorId '
. ' a.major = b.major '
. 'WHERE a.fourYearPlanGenerationId = b.fourYearPlanGenerationId '; . 'WHERE a.fourYearPlanGenerationId = b.fourYearPlanGenerationId ';
$db->query($sql); $db->query($sql);
$db->query('DROP TABLE creqFourYearPlanGenerationsUpdate'); $db->query('DROP TABLE creqFourYearPlanGenerationsUpdate');
...@@ -936,7 +934,6 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -936,7 +934,6 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
throw new Exception('Major not found.'); throw new Exception('Major not found.');
} }
$this->_data['majorId'] = $majorId; $this->_data['majorId'] = $majorId;
$this->_data['major'] = $majors[$majorId];
} }
public function setMajor($major) public function setMajor($major)
...@@ -949,7 +946,6 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model ...@@ -949,7 +946,6 @@ class FourYearPlans_FourYearPlanModel extends Unl_Model
} }
$this->_data['majorId'] = $majorId; $this->_data['majorId'] = $majorId;
$this->_data['major'] = $majors[$majorId];
} }
public function getConcentrations() public function getConcentrations()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment