From 8fb6670c99f82c93de7204d79ffaa500c5c3dcec Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 25 Jan 2007 18:03:29 +0000
Subject: [PATCH] Editing a course creates a new generation of the course.

This should solve the problem of stale data in "View/Edit" from the home page.
---
 application/controllers/NewrequestController.php | 2 ++
 application/models/rows/Asset.php                | 8 ++++++++
 application/models/rows/Request.php              | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/application/controllers/NewrequestController.php b/application/controllers/NewrequestController.php
index ce076054..ebe5495d 100644
--- a/application/controllers/NewrequestController.php
+++ b/application/controllers/NewrequestController.php
@@ -108,6 +108,8 @@ class NewRequestController extends Nmc_Controller_Action
         $request = Requests::getInstance()->find($requestId);
         $course = $request->getCourseGeneration();
 
+        $course = clone $course;
+
         Nmc_Registry_Session::getInstance()->course = $course;
         Nmc_Registry_Session::getInstance()->request = $request;
 
diff --git a/application/models/rows/Asset.php b/application/models/rows/Asset.php
index ea3aabdf..295caa7a 100644
--- a/application/models/rows/Asset.php
+++ b/application/models/rows/Asset.php
@@ -21,6 +21,14 @@ class Asset extends Nmc_Db_Table_Row
         parent::_save();
     }
 
+    protected function _clone()
+    {
+        parent::_clone();
+
+        $this->creationTime = time();
+        $this->modifiedTime = time();
+    }
+
     public function getAssetId()
     {
         return $this->getPrimaryKey();
diff --git a/application/models/rows/Request.php b/application/models/rows/Request.php
index 4a8c5852..9c6d55cc 100644
--- a/application/models/rows/Request.php
+++ b/application/models/rows/Request.php
@@ -50,7 +50,7 @@ class Request extends Nmc_Db_Table_Row
                       . Assets::getInstance()->getTableName() . '.'
                       . Assets::getInstance()->getPrimaryKeyName());
         $select->where($this->_db->quoteInto('request = ?', $this->getPrimaryKey()));
-        $select->order('creation_time');
+        $select->order('creation_time DESC');
 
         $generations = $this->_db->fetchCol($select);
         if(count($generations) > 0) {
-- 
GitLab