From d8915782943f754c5aa2826e36c3bdf97daeb320 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Fri, 26 Feb 2010 03:26:14 +0000 Subject: [PATCH] + add the feature of attatch. --- module/task/control.php | 8 ++++++-- module/task/model.php | 11 ++++++++--- module/task/view/create.html.php | 8 ++++++-- module/task/view/edit.html.php | 6 +++++- module/task/view/view.html.php | 4 ++++ 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index c50b95dc5f..ae427c23f7 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -106,10 +106,14 @@ class task extends control $this->loadModel('action'); $changes = $this->task->update($taskID); if(dao::isError()) die(js::error(dao::getError())); - if($this->post->comment != '' or !empty($changes)) + $files = $this->loadModel('file')->saveUpload('task', $taskID); + + if($this->post->comment != '' or !empty($changes) or !empty($files)) { $action = !empty($changes) ? 'Edited' : 'Commented'; - $actionID = $this->action->create('task', $taskID, $action, $this->post->comment); + $fileAction = ''; + if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; + $actionID = $this->action->create('task', $taskID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); } die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); diff --git a/module/task/model.php b/module/task/model.php index e7e31bb842..bf62ccc1ee 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -39,7 +39,7 @@ class taskModel extends model ->setIF($this->post->estimate != false, 'left', $this->post->estimate) ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) ->setDefault('statusCustom', strpos(self::CUSTOM_STATUS_ORDER, $this->post->status) + 1) - ->remove('after') + ->remove('after,files,labels') ->get(); $this->dao->insert(TABLE_TASK)->data($task) @@ -49,6 +49,8 @@ class taskModel extends model ->exec(); if(!dao::isError()) $taskID = $this->dao->lastInsertID(); if($this->post->story) $this->loadModel('story')->setStage($this->post->story); + $this->loadModel('file')->saveUpload('task', $taskID); + return $taskID; } @@ -64,7 +66,7 @@ class taskModel extends model ->setIF($this->post->story != false and $this->post->story != $oldTask->story, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) ->setIF($this->post->status == 'done', 'left', 0) ->setDefault('statusCustom', strpos(self::CUSTOM_STATUS_ORDER, $this->post->status) + 1) - ->remove('comment') + ->remove('comment,fiels,labels') ->get(); $this->dao->update(TABLE_TASK)->data($task) ->autoCheck() @@ -89,7 +91,7 @@ class taskModel extends model /* 通过id获取一个任务信息。*/ public function getById($taskID) { - return $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t3.realname AS ownerRealName') + $task = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t3.realname AS ownerRealName') ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2') ->on('t1.story = t2.id') @@ -97,6 +99,9 @@ class taskModel extends model ->on('t1.owner = t3.account') ->where('t1.id')->eq((int)$taskID) ->fetch(); + if(!$task) return false; + $task->files = $this->loadModel('file')->getByObject('task', $taskID); + return $task; } /* 获得某一个项目的任务列表。*/ diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php index e46069a1db..8e634edfe7 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -24,7 +24,7 @@ ?>
-
+ @@ -33,7 +33,7 @@ - @@ -43,6 +43,10 @@ + + + +
task->create;?>
task->story;?> +
task->name;?>task->desc;?>
files;?>fetch('file', 'buildform');?>
task->owner;?> diff --git a/module/task/view/edit.html.php b/module/task/view/edit.html.php index 1ca5a145e9..c50d1306a0 100644 --- a/module/task/view/edit.html.php +++ b/module/task/view/edit.html.php @@ -24,7 +24,7 @@ ?>
- + @@ -43,6 +43,10 @@ + + + +
title;?>
task->desc;?>
files;?>fetch('file', 'buildform');?>
task->owner;?> owner, 'class=select-3');?> diff --git a/module/task/view/view.html.php b/module/task/view/view.html.php index f5c4544bab..088411643a 100644 --- a/module/task/view/view.html.php +++ b/module/task/view/view.html.php @@ -43,6 +43,10 @@ task->legendDesc;?>
desc);?>
+
+ files;?> +
files as $file) echo html::a($file->fullPath, $file->title, '_blank');?>
+