diff --git a/trunk/module/story/control.php b/trunk/module/story/control.php index 814f98d845..4610ba6f67 100644 --- a/trunk/module/story/control.php +++ b/trunk/module/story/control.php @@ -74,10 +74,13 @@ class story extends control $this->loadModel('action'); $changes = $this->story->update($storyID); if(dao::isError()) die(js::error(dao::getError())); - if($this->post->comment != '' or !empty($changes)) + $files = $this->loadModel('file')->saveUpload('story', $storyID); + if($this->post->comment != '' or !empty($changes) or !empty($files)) { $action = !empty($changes) ? 'Edited' : 'Commented'; - $actionID = $this->action->create('story', $storyID, $action, $this->post->comment); + $fileAction = ''; + if(!empty($files)) $fileAction = "Add Files " . join(',', $files) . "\n" ; + $actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); } die(js::locate($this->createLink('story', 'view', "storyID=$storyID"), 'parent')); @@ -110,12 +113,13 @@ class story extends control public function view($storyID) { $this->loadModel('action'); - $storyID = (int)$storyID; - $story = $this->dao->findByID((int)$storyID)->from(TABLE_STORY)->fetch(); - $product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fields('name, id')->fetch(); - $plan = $this->dao->findById($story->plan)->from(TABLE_PRODUCTPLAN)->fetch('title'); - $modulePath = $this->tree->getParents($story->module); - $users = $this->user->getPairs(); + $storyID = (int)$storyID; + $story = $this->dao->findByID((int)$storyID)->from(TABLE_STORY)->fetch(); + $story->files = $this->loadModel('file')->getByObject('story', $storyID); + $product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fields('name, id')->fetch(); + $plan = $this->dao->findById($story->plan)->from(TABLE_PRODUCTPLAN)->fetch('title'); + $modulePath = $this->tree->getParents($story->module); + $users = $this->user->getPairs(); /* 设置菜单。*/ $this->product->setMenu($this->product->getPairs(), $product->id); diff --git a/trunk/module/story/model.php b/trunk/module/story/model.php index efd073e8a1..d35199c347 100644 --- a/trunk/module/story/model.php +++ b/trunk/module/story/model.php @@ -45,9 +45,16 @@ class storyModel extends model ->add('openedDate', $now) ->add('assignedDate', 0) ->setIF($this->post->assignedTo != '', 'assignedDate', $now) + ->remove('files,labels') ->get(); $this->dao->insert(TABLE_STORY)->data($story)->autoCheck()->check('title', 'notempty')->exec(); - if(!dao::isError()) return $this->dao->lastInsertID(); + if(!dao::isError()) + { + $storyID = $this->dao->lastInsertID(); + $this->loadModel('file')->saveUpload('story', $storyID); + return $storyID; + } + return false; } /* 更新需求。*/ @@ -65,6 +72,7 @@ class storyModel extends model ->add('lastEditedDate', $now) ->setDefault('plan', 0) ->setIF($this->post->assignedTo != $oldStory->assignedTo, 'assignedDate', $now) + ->remove('files,labels') ->get(); $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->check('title', 'notempty')->where('id')->eq((int)$storyID)->exec(); if(!dao::isError()) return common::createChanges($oldStory, $story); diff --git a/trunk/module/story/view/create.html.php b/trunk/module/story/view/create.html.php index da45b09d02..93e7d7ab4c 100644 --- a/trunk/module/story/view/create.html.php +++ b/trunk/module/story/view/create.html.php @@ -31,7 +31,7 @@ function loadModuleMenu(productID) }