+ add the feature of attatchment.

This commit is contained in:
wangchunsheng
2010-01-13 07:54:18 +00:00
parent 59dda856db
commit 1c5e521b5d
5 changed files with 40 additions and 19 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -31,7 +31,7 @@ function loadModuleMenu(productID)
}
</script>
<div id='doc3'>
<form method='post' target='hiddenwin'>
<form method='post' enctype='multipart/form-data' target='hiddenwin'>
<table align='center' class='table-1'>
<caption><?php echo $lang->story->create;?></caption>
<tr>
@@ -77,6 +77,11 @@ function loadModuleMenu(productID)
<th class='rowhead'><?php echo $lang->story->spec;?></th>
<td class='a-left'><textarea name='spec' rows='8' class='text-1'></textarea></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->story->legendAttatch;?></th>
<td class='a-left'><?php echo $this->fetch('file', 'buildform');?></td>
</tr>
<tr>
<td colspan='2'>
<input type='submit' value='<?php echo $lang->save;?>' class='button-s' />

View File

@@ -31,7 +31,7 @@ function loadModuleMenu(productID)
}
</script>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<form method='post' enctype='multipart/form-data' target='hiddenwin'>
<table class='table-1'>
<caption><?php echo $lang->story->edit;?></caption>
<tr>
@@ -81,11 +81,15 @@ function loadModuleMenu(productID)
</tr>
<tr>
<th class='rowhead'><?php echo $lang->story->spec;?></th>
<td class='a-left'><textarea name='spec' rows='8' class='text-1'><?php echo $story->spec;?></textarea></td>
<td class='a-left'><textarea name='spec' rows='5' class='text-1'><?php echo $story->spec;?></textarea></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->comment;?></th>
<td class='a-left'><textarea name='comment' rows='5' class='text-1'></textarea></td>
<td class='a-left'><textarea name='comment' rows='4' class='text-1'></textarea></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->story->legendAttatch;?></th>
<td class='a-left'><?php echo $this->fetch('file', 'buildform');?></td>
</tr>
<tr>
<td colspan='2' class='a-center'><?php echo html::submitButton() . html::resetButton();?></td>

View File

@@ -45,7 +45,11 @@
<div class='yui-b'>
<fieldset>
<legend><?php echo $lang->story->legendSpec;?></legend>
<div><?php echo nl2br($story->spec);?></div>
<div class='content'><?php echo nl2br($story->spec);?></div>
</fieldset>
<fieldset>
<legend><?php echo $lang->story->legendAttatch;?></legend>
<div><?php foreach($story->files as $file) echo html::a($file->fullPath, $file->title, '_blank');?></div>
</fieldset>
<?php include '../../common/action.html.php';?>
<fieldset>
@@ -120,11 +124,7 @@
<div></div>
</fieldset>
<fieldset>
<legend><?php echo $lang->story->legendAttatch;?></legend>
<div>&nbsp;</div>
</fieldset>
<fieldset>
<fieldset>
<legend><?php echo $lang->story->legendOpenInfo;?></legend>
<table class='table-1 a-left'>
<tr>