diff --git a/application/controllers/CourseadminController.php b/application/controllers/CourseadminController.php index 85026a3ce492509e05f3ce09bc2fb3fced34f156..2db404aff1db1181e5479ab990746acf2f603ddc 100644 --- a/application/controllers/CourseadminController.php +++ b/application/controllers/CourseadminController.php @@ -63,6 +63,7 @@ class CourseAdminController extends Nmc_Controller_Action $out->assign('nextCourseLink', $nextCourseLink); } + $creditsSingleValues = array(); foreach($course->credits as $credit) { if($credit->type == 1) { @@ -81,6 +82,8 @@ class CourseAdminController extends Nmc_Controller_Action $out->assign('page', 'edit_course'); $out->assign('course', $course); + $out->assign('parentGeneration', $course->getParentGeneration()); + $out->assign('childGenerations', $course->getChildGenerations()); $out->assign('uriParams', $uriParams); echo $out->render(); } diff --git a/application/models/rows/CourseGeneration.php b/application/models/rows/CourseGeneration.php index 117acb18dc40ce89c68bac4bb0e7cbb021fc6d03..04107f34779eb31cbebdfd95252e55784e4368c7 100644 --- a/application/models/rows/CourseGeneration.php +++ b/application/models/rows/CourseGeneration.php @@ -138,6 +138,21 @@ class CourseGeneration extends Asset return $this->assetId; } + public function getParentGeneration() + { + if(!$this->parent) { + return null; + } + + $parentGeneration = CourseGenerations::getInstance()->find($this->parent); + return $parentGeneration; + } + + public function getChildGenerations() + { + return CourseGenerations::getInstance()->fetchWithParentGeneration($this); + } + /** * Returns a reference to the home crosslist * diff --git a/application/models/rows/Request.php b/application/models/rows/Request.php index 5df0ce0bbd424419184d6a7d0eed1fc166062949..831ab20d2eaf3ace75a4943d92728b0ddc2261d0 100644 --- a/application/models/rows/Request.php +++ b/application/models/rows/Request.php @@ -18,8 +18,6 @@ class Request extends Nmc_Db_Table_Row public function getCourseGeneration() { $returnValue = null; - $primaryKey = $this->_table->getPrimaryKeyName(); - $primaryKey = Nmc_Db_Inflector::getInstance()->camelize($primaryKey); $select = $this->_db->select(); $select->from(CourseGenerations::getInstance()->getTableName(), @@ -29,8 +27,9 @@ class Request extends Nmc_Db_Table_Row . '.asset_id = ' . Assets::getInstance()->getTableName() . '.' . Assets::getInstance()->getPrimaryKeyName()); - $select->where($this->_db->quoteInto('request = ?', $this->$primaryKey)); + $select->where($this->_db->quoteInto('request = ?', $this->getPrimaryKey())); $select->order('creation_time'); + $generations = $this->_db->fetchCol($select); if(count($generations) > 0) { $returnValue = CourseGenerations::getInstance()->find($generations[0]); diff --git a/application/models/tables/CourseGenerations.php b/application/models/tables/CourseGenerations.php index 2a292428338f8696730c115d2e2d61bb02f81145..9410c3a9127d56c15e791dfa5cb5de0aa3b8e680 100644 --- a/application/models/tables/CourseGenerations.php +++ b/application/models/tables/CourseGenerations.php @@ -137,6 +137,13 @@ class CourseGenerations extends Nmc_Db_Table //print_r($newRecord->credits); return $newRecord; } + + public function fetchWithParentGeneration(CourseGeneration $parentGeneration) + { + $where = $this->_db->quoteInto('parent=?', $parentGeneration->getPrimaryKey()); + $childGenerations = $this->fetchAll($where); + return $childGenerations; + } } ?> \ No newline at end of file diff --git a/application/views/edit_course.xhtml b/application/views/edit_course.xhtml index becb35a2850571197f6056faae9a4948df6dc87b..ff0f2bf7164bd5ba34366dbef46610b420c8bf6e 100644 --- a/application/views/edit_course.xhtml +++ b/application/views/edit_course.xhtml @@ -1,6 +1,27 @@ -<a href="/courseadmin/index<?php echo $this->prevCourseLink; ?>">Previous</a> -<a href="/courseadmin/index<?php echo $this->nextCourseLink; ?>">Next</a> +<h1>Navigation</h1> +<div> + <b>Alphabetical: </b> + <a href="/courseadmin/index<?php echo $this->prevCourseLink; ?>">Previous</a> + <a href="/courseadmin/index<?php echo $this->nextCourseLink; ?>">Next</a> +</div> +<?php if ($this->parentGeneration || $this->childGenerations->count() > 0) { ?> +<div> + <b>Generational:</b> + <?php if ($this->parentGeneration) { ?> + <a href="/CourseAdmin/index/<?php echo $this->parentGeneration->getPrimaryKey();?>">Parent</a> + <?php } ?> + + <?php if ($this->childGenerations->count() > 0) { ?> + Children: + <?php $i = 0; foreach ($this->childGenerations as $childGeneration) { $i++; ?> + <a href="/CourseAdmin/index/<?php echo $childGeneration->getPrimaryKey();?>"><?php echo $i; ?></a> + <?php } ?> + <?php } ?> +</div> +<?php } ?> + +<h1>Edit Course</h1> <form action="/courseadmin/updatecourse/<?php echo implode('/', $this->uriParams); ?>" method="post"> <input type="hidden" name="courseId" value="<?php echo $this->course->getPrimaryKey(); ?>" />