+ add delete feature to release.

This commit is contained in:
wangchunsheng
2010-04-12 07:17:29 +00:00
parent 7eedbac23c
commit bbc483b777
4 changed files with 57 additions and 50 deletions

View File

@@ -36,6 +36,7 @@ class release extends control
public function browse($productID)
{
$this->commonAction($productID);
$this->session->set('releaseList', $this->app->getURI(true));
$this->view->header->title = $this->lang->release->browse;
$this->view->position[] = $this->lang->release->browse;
$this->view->releases = $this->release->getList($productID);
@@ -47,9 +48,10 @@ class release extends control
{
if(!empty($_POST))
{
$this->release->create($productID);
$releaseID = $this->release->create($productID);
if(dao::isError()) die(js::error(dao::getError()));
die(js::locate($this->createLink('release', 'browse', "productID=$productID"), 'parent'));
$this->loadModel('action')->create('release', $releaseID, 'opened');
die(js::locate(inlink('view', "releaseID=$releaseID"), 'parent'));
}
$this->commonAction($productID);
@@ -65,9 +67,11 @@ class release extends control
{
if(!empty($_POST))
{
$this->release->update($releaseID);
$changes = $this->release->update($releaseID);
if(dao::isError()) die(js::error(dao::getError()));
die(js::locate($this->createLink('release', 'browse', "productID={$this->post->product}"), 'parent'));
$actionID = $this->loadModel('action')->create('release', $releaseID, 'edited');
$this->action->logHistory($actionID, $changes);
die(js::locate(inlink('view', "releaseID=$releaseID"), 'parent'));
}
$release = $this->release->getById((int)$releaseID);
@@ -77,6 +81,7 @@ class release extends control
$this->view->position[] = $this->lang->release->edit;
$this->view->release = $release;
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product);
unset($this->view->builds['trunk']);
$this->display();
}
@@ -84,12 +89,16 @@ class release extends control
public function view($releaseID)
{
$release = $this->release->getById((int)$releaseID);
if(!$release) die(js::error($this->lang->notFound) . js::locate('back'));
$this->commonAction($release->product);
/* 赋值。*/
$this->view->header->title = $this->lang->release->view;
$this->view->position[] = $this->lang->release->view;
$this->view->release = $release;
$this->view->actions = $this->loadModel('action')->getList('release', $releaseID);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->display();
}
@@ -102,9 +111,8 @@ class release extends control
}
else
{
$release = $this->release->getById($releaseID);
$this->release->delete($releaseID);
die(js::locate($this->createLink('release', 'browse', "productID=$release->product"), 'parent'));
$this->release->delete(TABLE_RELEASE, $releaseID);
die(js::locate($this->session->releaseList, 'parent'));
}
}
}

View File

@@ -45,6 +45,7 @@ class releaseModel extends model
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_BUILD)->alias('t3')->on('t1.build = t3.id')
->where('t1.product')->eq((int)$productID)
->andWhere('t1.deleted')->eq(0)
->orderBy('t1.id DESC')
->fetchAll();
}
@@ -64,16 +65,12 @@ class releaseModel extends model
/* 编辑。*/
public function update($releaseID)
{
$oldRelease = $this->getByID($releaseID);
$release = fixer::input('post')
->stripTags('name')
->specialChars('desc')
->get();
$this->dao->update(TABLE_RELEASE)->data($release)->autoCheck()->batchCheck($this->config->release->edit->requiredFields, 'notempty')->where('id')->eq((int)$releaseID)->exec();
}
/* 删除release。*/
public function delete($releaseID)
{
return $this->dao->delete()->from(TABLE_RELEASE)->where('id')->eq((int)$releaseID)->exec();
if(!dao::isError()) return common::createChanges($oldRelease, $release);
}
}

View File

@@ -27,17 +27,17 @@
<div class='yui-d0'>
<div id='feature-bar'>
</div>
<table class='table-1 fixed tablesorter'>
<caption>
<table align='center' class='table-6 tablesorter'>
<caption class='caption-tl'>
<div class='f-left'><?php echo $lang->release->browse;?></div>
<div class='f-right'><?php common::printLink('release', 'create', "product=$product->id", $lang->release->create);?></div>
</caption>
<thead>
<tr>
<tr class='colhead'>
<th><?php echo $lang->release->name;?></th>
<th><?php echo $lang->release->build;?></th>
<th><?php echo $lang->release->date;?></th>
<th><?php echo $lang->actions;?></th>
<th class='w-100px'><?php echo $lang->release->date;?></th>
<th class='w-80px'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>

View File

@@ -24,38 +24,40 @@
?>
<?php include '../../common/view/header.html.php';?>
<div class='yui-d0'>
<form method='post' target='hiddenwin'>
<table class='table-1'>
<caption><?php echo $lang->release->view;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->release->product;?></th>
<td><?php echo $release->productName;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->name;?></th>
<td><?php echo $release->name;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->build;?></th>
<td><?php echo $release->buildName;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->date;?></th>
<td><?php echo $release->date;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->desc;?></th>
<td><?php echo nl2br($release->desc);?></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
<?php
<table class='table-1'>
<caption><?php echo $lang->release->view;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->release->product;?></th>
<td><?php echo $release->productName;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->name;?></th>
<td class='<?php if($release->deleted) echo 'deleted';?>'><?php echo $release->name;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->build;?></th>
<td><?php echo $release->buildName;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->date;?></th>
<td><?php echo $release->date;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->release->desc;?></th>
<td><?php echo nl2br($release->desc);?></td>
</tr>
</table>
<div class='a-center f-16px strong'>
<?php
$browseLink = $this->session->releaseList ? $this->session->releaseList : inlink('browse', "productID=$release->product");
if(!$release->deleted)
{
common::printLink('release', 'edit', "releaseID=$release->id", $lang->edit);
common::printLink('release', 'delete', "releaseID=$release->id", $lang->delete);
?>
</td>
</tr>
</table>
</form>
common::printLink('release', 'delete', "releaseID=$release->id", $lang->delete, 'hiddenwin');
}
echo html::a($browseLink, $lang->goback);
?>
</div>
<?php include '../../common/view/action.html.php';?>
</div>
<?php include '../../common/view/footer.html.php';?>