Merge branch 'master_xieqiyu_66954' into 'master'
* Finish task#66954,#66960,#66959,#66958,#66956. See merge request easycorp/zentaopms!5206
This commit is contained in:
@@ -80,6 +80,14 @@
|
||||
<?php echo strpos('draft,changing', $story->status) !== false ? html::textarea('spec', htmlSpecialString($story->spec), "rows='5' class='form-control'") : $story->spec;?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='detail'>
|
||||
<div class='detail-title'><?php echo $lang->attatch;?></div>
|
||||
<div class='form-group'>
|
||||
<?php $canChangeFile = strpos('draft,changing', $story->status) !== false ? true : false;?>
|
||||
<?php echo $this->fetch('file', 'printFiles', array('files' => $files, 'fieldset' => 'false', 'object' => $story, 'method' => 'edit', 'showDelete' => $canChangeFile));?>
|
||||
<?php echo $canChangeFile ? $this->fetch('file', 'buildform') : '';?>
|
||||
</div>
|
||||
</div>
|
||||
<?php $this->printExtendFields($story, 'div', 'position=left');?>
|
||||
<div class='detail'>
|
||||
<div class='detail-title'><?php echo $lang->story->comment;?></div>
|
||||
|
||||
@@ -99,7 +99,8 @@ $lang->collapse = 'Zuklappen';
|
||||
$lang->saveSuccess = 'Gespeichert';
|
||||
$lang->importSuccess = 'Gespeichert';
|
||||
$lang->fail = 'Fehlgeschlagen';
|
||||
$lang->addFiles = 'Hinzufügen';
|
||||
$lang->addFiles = 'Hinzufügen ';
|
||||
$lang->deleteFiles = 'Anhang gelöscht ';
|
||||
$lang->files = 'Datei ';
|
||||
$lang->pasteText = 'Einfügen';
|
||||
$lang->uploadImages = 'Hochladen';
|
||||
|
||||
@@ -99,7 +99,8 @@ $lang->collapse = 'Collapse';
|
||||
$lang->saveSuccess = 'Saved';
|
||||
$lang->importSuccess = 'Saved';
|
||||
$lang->fail = 'Fail';
|
||||
$lang->addFiles = 'Added Files';
|
||||
$lang->addFiles = 'Added Files ';
|
||||
$lang->deleteFiles = 'Deleted Files ';
|
||||
$lang->files = 'Files ';
|
||||
$lang->pasteText = 'Multi-line Paste';
|
||||
$lang->uploadImages = 'Multi-image Upload';
|
||||
|
||||
@@ -100,6 +100,7 @@ $lang->saveSuccess = 'Sauvegardé';
|
||||
$lang->importSuccess = 'Sauvé';
|
||||
$lang->fail = 'Echec';
|
||||
$lang->addFiles = 'Fichiers ajoutés ';
|
||||
$lang->deleteFiles = 'Pièce jointe supprimée ';
|
||||
$lang->files = 'Fichiers ';
|
||||
$lang->pasteText = 'Collage Multi-lignes';
|
||||
$lang->uploadImages = 'Upload Multi-images';
|
||||
|
||||
@@ -78,7 +78,8 @@ $lang->collapse = 'Co lại';
|
||||
$lang->saveSuccess = 'Đã lưu';
|
||||
$lang->importSuccess = 'Đã lưu';
|
||||
$lang->fail = 'Thất bại';
|
||||
$lang->addFiles = 'Tập tin đã thêm';
|
||||
$lang->addFiles = 'Tập tin đã thêm ';
|
||||
$lang->deleteFiles = 'Tháo ảnh ';
|
||||
$lang->files = 'Files ';
|
||||
$lang->pasteText = 'Dán nhiều dòng';
|
||||
$lang->uploadImages = 'Tải lên nhiều ảnh';
|
||||
|
||||
@@ -100,6 +100,7 @@ $lang->saveSuccess = '保存成功';
|
||||
$lang->importSuccess = '导入成功';
|
||||
$lang->fail = '失败';
|
||||
$lang->addFiles = '上传了附件 ';
|
||||
$lang->deleteFiles = '删除了附件 ';
|
||||
$lang->files = '附件 ';
|
||||
$lang->pasteText = '多项录入';
|
||||
$lang->uploadImages = '多图上传 ';
|
||||
|
||||
@@ -306,17 +306,19 @@ class file extends control
|
||||
* @param string $fieldset
|
||||
* @param object $object
|
||||
* @param string $method
|
||||
* @param bool $showDelete
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function printFiles($files, $fieldset, $object = null, $method = 'view')
|
||||
public function printFiles($files, $fieldset, $object = null, $method = 'view', $showDelete = true)
|
||||
{
|
||||
$this->view->files = $files;
|
||||
$this->view->fieldset = $fieldset;
|
||||
$this->view->object = $object;
|
||||
$this->view->method = $method;
|
||||
$this->view->files = $files;
|
||||
$this->view->fieldset = $fieldset;
|
||||
$this->view->object = $object;
|
||||
$this->view->method = $method;
|
||||
$this->view->showDelete = $showDelete;
|
||||
|
||||
if($method == 'view') return $this->display('file', 'viewfiles');
|
||||
if(strpos('view,edit', $method) !== false) return $this->display('file', 'viewfiles');
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
+60
-2
@@ -46,8 +46,9 @@ class fileModel extends model
|
||||
->where('objectType')->eq($objectType)
|
||||
->andWhere('objectID')->eq((int)$objectID)
|
||||
->andWhere('extra')->ne('editor')
|
||||
->beginIF($objectType == 'story' and $extra)->andWhere('extra')->like("%,$extra,%")->fi()
|
||||
->beginIF($objectType != 'story' and $extra)->andWhere('extra')->eq($extra)->fi()
|
||||
->andWhere('deleted')->eq('0')
|
||||
->beginIF($extra)->andWhere('extra')->eq($extra)
|
||||
->orderBy('id')
|
||||
->fetchAll('id');
|
||||
|
||||
@@ -1097,7 +1098,6 @@ class fileModel extends model
|
||||
{
|
||||
return $this->dao->select("id,$value")->from(TABLE_FILE)
|
||||
->where('id')->in($IDs)
|
||||
->andWhere('deleted')->eq('0')
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
@@ -1119,4 +1119,62 @@ class fileModel extends model
|
||||
$this->dao->update(TABLE_CASE)->set('`fromCaseVersion`')->eq($fromcaseVersion)->where('`fromCaseID`')->eq($file->objectID)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update version of story files.
|
||||
*
|
||||
* @param int $storyID
|
||||
* @param int $storyVersion
|
||||
* @param array $deleteFiles
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateStoryFileVersion($storyID, $storyVersion, $deleteFiles = array())
|
||||
{
|
||||
$oldStoryVersion = $storyVersion - 1;
|
||||
$this->dao->dbh($this->dbh)->update(TABLE_FILE)->set("extra = CONCAT(extra, '$storyVersion,')")
|
||||
->where('objectType')->eq('story')
|
||||
->andWhere('objectID')->eq($storyID)
|
||||
->andWhere('extra')->like("%,$oldStoryVersion,%")
|
||||
->beginIF(!empty($deleteFiles))->andWhere('id')->notin($deleteFiles)->fi()
|
||||
->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete story file.
|
||||
*
|
||||
* @param int $storyID
|
||||
* @param int $storyVersion
|
||||
* @param array $deleteFiles
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteStoryFile($storyID, $storyVersion, $deleteFiles = array())
|
||||
{
|
||||
$deleteFileList = $this->dao->select('*')->from(TABLE_FILE)
|
||||
->where('objectType')->eq('story')
|
||||
->andWhere('objectID')->eq($storyID)
|
||||
->andWhere('extra')->eq(",$storyVersion,")
|
||||
->beginIF(!empty($deleteFiles))->andWhere('id')->in($deleteFiles)->fi()
|
||||
->fetchAll('id');
|
||||
|
||||
if(!empty($deleteFileList))
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_FILE)->where('id')->in(array_keys($deleteFileList))->exec();
|
||||
|
||||
foreach($deleteFileList as $file)
|
||||
{
|
||||
$realPathName = $this->getRealPathName($file->pathname);
|
||||
@unlink($realPathName);
|
||||
}
|
||||
}
|
||||
|
||||
/* When the file is in multiple story versions, 'extra' need delete the version to be deleted. */
|
||||
$this->dao->update(TABLE_FILE)->set("extra = REPLACE(extra, '$storyVersion,', '')")
|
||||
->where('objectType')->eq('story')
|
||||
->andWhere('objectID')->eq($storyID)
|
||||
->andWhere('extra')->like("%,$storyVersion,%")
|
||||
->beginIF(!empty($deleteFiles))->andWhere('id')->in($deleteFiles)->fi()
|
||||
->exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
if(common::hasPriv($objectType, 'edit', $object))
|
||||
{
|
||||
echo "<span class='right-icon'> ";
|
||||
if($method != 'storyChange') common::printLink('file', 'edit', "fileID=$file->id", $lang->file->edit, '', "data-width='400' class='fileAction btn btn-link edit iframe text-primary' title='{$lang->file->edit}'");
|
||||
common::printLink('file', 'edit', "fileID=$file->id", $lang->file->edit, '', "data-width='400' class='fileAction btn btn-link edit iframe text-primary' title='{$lang->file->edit}'");
|
||||
if(common::hasPriv('file', 'delete')) echo html::a('###', $lang->delete, '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id)' title='$lang->delete'");
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<?php endif;?>
|
||||
<style>
|
||||
.file {padding-top: 2px;}
|
||||
ul.files-list {margin-bottom: unset}
|
||||
.files-list>li>a {display: inline; word-wrap: break-word;}
|
||||
.files-list>li>.right-icon {opacity: 1;}
|
||||
.fileAction {color: #0c64eb !important;}
|
||||
@@ -15,7 +16,7 @@
|
||||
.renameFile .icon {margin-top: 8px;}
|
||||
.renameFile .input-group-addon {width: 60px;}
|
||||
.backgroundColor {background: #eff5ff; }
|
||||
.icon.icon-file-text {margin-left: 4px;}
|
||||
.icon.icon-file-text {padding-left: 7px}
|
||||
.right-icon .btn {padding: 0 6px;}
|
||||
</style>
|
||||
<script>
|
||||
@@ -38,13 +39,20 @@ $(document).ready(function()
|
||||
* Delete a file.
|
||||
*
|
||||
* @param int $fileID
|
||||
* @param object $obj
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function deleteFile(fileID)
|
||||
function deleteFile(fileID, obj)
|
||||
{
|
||||
if(!fileID) return;
|
||||
|
||||
<?php if($showDelete and $method == 'edit'):?>
|
||||
$('<input />').attr('type', 'hidden').attr('name', 'deleteFiles[' + fileID + ']').attr('value', fileID).appendTo('ul.files-list');
|
||||
$(obj).closest('li.file').addClass('hidden');
|
||||
<?php else:?>
|
||||
hiddenwin.location.href = createLink('file', 'delete', 'fileID=' + fileID);
|
||||
<?php endif;?>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +103,7 @@ function downloadFile(fileID, extension, imageWidth, fileTitle)
|
||||
function showRenameBox(fileID)
|
||||
{
|
||||
$('#renameFile' + fileID).closest('li').addClass('hidden');
|
||||
$('#renameBox' + fileID).removeClass('hidden');
|
||||
$('#renameBox' + fileID).closest('li').removeClass('hidden');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +115,7 @@ function showRenameBox(fileID)
|
||||
*/
|
||||
function showFile(fileID)
|
||||
{
|
||||
$('#renameBox' + fileID).addClass('hidden');
|
||||
$('#renameBox' + fileID).closest('li').addClass('hidden');
|
||||
$('#renameFile' + fileID).closest('li').removeClass('hidden');
|
||||
}
|
||||
|
||||
@@ -123,7 +131,6 @@ function setFileName(fileID)
|
||||
var fileName = $('#fileName' + fileID).val();
|
||||
var extension = $('#extension' + fileID).val();
|
||||
var postData = {'fileName' : fileName, 'extension' : extension};
|
||||
$('#renameBox' + fileID ).addClass('hidden');
|
||||
$.ajax(
|
||||
{
|
||||
url:createLink('file', 'edit', 'fileID=' + fileID),
|
||||
@@ -134,7 +141,7 @@ function setFileName(fileID)
|
||||
{
|
||||
$('#fileTitle' + fileID).html("<i class='icon icon-file-text'></i> " + data['title']);
|
||||
$('#renameFile' + fileID).closest('li').removeClass('hidden');
|
||||
$('#renameBox' + fileID).addClass('hidden');
|
||||
$('#renameBox' + fileID).closest('li').addClass('hidden');
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -212,12 +219,12 @@ function setFileName(fileID)
|
||||
|
||||
common::printLink('file', 'download', "fileID=$file->id", "<i class='icon icon-download'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->downloadFile}'");
|
||||
if(common::hasPriv('file', 'edit')) echo html::a('###', "<i class='icon icon-pencil-alt'></i>", '', "id='renameFile$file->id' class='fileAction btn btn-link edit text-primary' onclick='showRenameBox($file->id)' title='{$lang->file->edit}'");
|
||||
if(common::hasPriv('file', 'delete')) echo html::a('###', "<i class='icon icon-trash'></i>", '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id)' title='$lang->delete'");
|
||||
if($showDelete and common::hasPriv('file', 'delete')) echo html::a('###', "<i class='icon icon-trash'></i>", '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id, this)' title='$lang->delete'");
|
||||
echo '</span>';
|
||||
}
|
||||
echo '</li>';?>
|
||||
|
||||
<li class='file'>
|
||||
<li class='file hidden'>
|
||||
<div>
|
||||
<?php
|
||||
if(strrpos($file->title, '.') !== false)
|
||||
@@ -230,11 +237,11 @@ function setFileName(fileID)
|
||||
$file->title = join('.', $title);
|
||||
}
|
||||
?>
|
||||
<div class='hidden renameFile w-300px' id='renameBox<?php echo $file->id;?>'>
|
||||
<div class='renameFile w-300px' id='renameBox<?php echo $file->id;?>'>
|
||||
<i class='icon icon-file-text'></i>
|
||||
<div class='input-group'>
|
||||
<?php echo html::input('fileName' . $file->id, $file->title, "class='form-control' size='40'");?>
|
||||
<input type="hidden" name="extension" id="extension<?php echo $file->id?>" value="<?php echo $file->extension;?>"/>
|
||||
<input type="text" id="<?php echo 'fileName' . $file->id?>" value="<?php echo $file->title;?>" class='form-control'/>
|
||||
<input type="hidden" id="extension<?php echo $file->id?>" value="<?php echo $file->extension;?>"/>
|
||||
<strong class='input-group-addon'>.<?php echo $file->extension;?></strong>
|
||||
</div>
|
||||
<div class="input-group-btn">
|
||||
|
||||
+27
-15
@@ -747,17 +747,25 @@ class story extends control
|
||||
*/
|
||||
public function edit($storyID, $kanbanGroup = 'default', $storyType = 'story')
|
||||
{
|
||||
$this->loadModel('file');
|
||||
$this->app->loadLang('bug');
|
||||
$story = $this->story->getById($storyID, 0, true);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = $this->story->update($storyID);
|
||||
$deleteFiles = isset($_POST['deleteFiles']) ? $this->file->getPairs($_POST['deleteFiles'], 'title') : array();
|
||||
$changes = $this->story->update($storyID);
|
||||
if(dao::isError()) return print(js::error(dao::getError()));
|
||||
if($this->post->comment != '' or !empty($changes))
|
||||
|
||||
$files = $this->file->saveUpload($story->type, $storyID, ",$story->version,");
|
||||
if(empty($files) and $this->post->uid != '' and isset($_SESSION['album']['used'][$this->post->uid])) $files = $this->file->getPairs($_SESSION['album']['used'][$this->post->uid]);
|
||||
|
||||
if($this->post->comment != '' or !empty($changes) or !empty($files) or !empty($deleteFiles))
|
||||
{
|
||||
$action = !empty($changes) ? 'Edited' : 'Commented';
|
||||
$actionID = $this->action->create('story', $storyID, $action, $this->post->comment);
|
||||
$action = (!empty($changes) or !empty($files)) ? 'Edited' : 'Commented';
|
||||
$fileAction = empty($files) ? '' : $this->lang->addFiles . join(',', $files) . "\n" ;
|
||||
$fileAction .= empty($deleteFiles) ? '' : $this->lang->deleteFiles . join(',', $deleteFiles) . "\n";
|
||||
$actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
|
||||
$editedStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
|
||||
@@ -871,6 +879,7 @@ class story extends control
|
||||
$this->view->reviewers = array_keys($reviewerList);
|
||||
$this->view->reviewedReviewer = $reviewedReviewer;
|
||||
$this->view->productReviewers = $this->user->getPairs('noclosed|nodeleted', array_keys($reviewerList), 0, $productReviewers);
|
||||
$this->view->files = $this->file->getByObject($story->type, $storyID, $story->version);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -1084,26 +1093,28 @@ class story extends control
|
||||
*/
|
||||
public function change($storyID, $from = '', $storyType = 'story')
|
||||
{
|
||||
$this->loadModel('file');
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = $this->story->change($storyID);
|
||||
$deleteFiles = isset($_POST['deleteFiles']) ? $this->file->getPairs($_POST['deleteFiles'], 'title') : array();
|
||||
$changes = $this->story->change($storyID);
|
||||
if(dao::isError())
|
||||
{
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => dao::getError()));
|
||||
return print(js::error(dao::getError()));
|
||||
}
|
||||
|
||||
$story = $this->story->getByID($storyID);
|
||||
$version = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch('version');
|
||||
$files = $this->loadModel('file')->saveUpload($story->type, $storyID, $version);
|
||||
|
||||
$files = $this->file->saveUpload($story->type, $storyID, ",$version,");
|
||||
if(empty($files) and $this->post->uid != '' and isset($_SESSION['album']['used'][$this->post->uid])) $files = $this->file->getPairs($_SESSION['album']['used'][$this->post->uid]);
|
||||
|
||||
if($this->post->comment != '' or !empty($changes) or !empty($files))
|
||||
if($this->post->comment != '' or !empty($changes) or !empty($files) or !empty($deleteFiles))
|
||||
{
|
||||
$action = (!empty($changes) or !empty($files)) ? 'Changed' : 'Commented';
|
||||
$fileAction = '';
|
||||
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ;
|
||||
$actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment);
|
||||
$action = (!empty($changes) or !empty($files)) ? 'Changed' : 'Commented';
|
||||
$fileAction = empty($files) ? '' : $this->lang->addFiles . join(',', $files) . "\n" ;
|
||||
$fileAction .= empty($deleteFiles) ? '' : $this->lang->deleteFiles . join(',', $deleteFiles) . "\n";
|
||||
$actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
|
||||
@@ -1168,7 +1179,7 @@ class story extends control
|
||||
$this->view->needReview = (($this->app->user->account == $this->view->product->PO or $this->config->story->needReview == 0) and empty($reviewer)) ? "checked='checked'" : "";
|
||||
$this->view->reviewer = implode(',', array_keys($reviewer));
|
||||
$this->view->productReviewers = $this->user->getPairs('noclosed|nodeleted', $reviewer, 0, $productReviewers);
|
||||
$this->view->files = $this->loadModel('file')->getByObject($story->type, $storyID);
|
||||
$this->view->files = $this->file->getByObject($story->type, $storyID, $story->version);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -1247,6 +1258,7 @@ class story extends control
|
||||
|
||||
$storyID = (int)$storyID;
|
||||
$story = $this->story->getById($storyID, $version, true);
|
||||
$version = empty($version) ? $story->version : $version;
|
||||
$linkModuleName = $this->config->vision == 'lite' ? 'project' : 'product';
|
||||
if(!$story) return print(js::error($this->lang->notFound) . js::locate($this->createLink($linkModuleName, 'index')));
|
||||
|
||||
@@ -1254,7 +1266,7 @@ class story extends control
|
||||
|
||||
$this->story->replaceURLang($story->type);
|
||||
|
||||
$story->files = $this->loadModel('file')->getByObject($story->type, $storyID);
|
||||
$story->files = $this->loadModel('file')->getByObject($story->type, $storyID, $version);
|
||||
$product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fields('name, id, type, status')->fetch();
|
||||
$plan = $this->dao->findById($story->plan)->from(TABLE_PRODUCTPLAN)->fetch('title');
|
||||
$bugs = $this->dao->select('id,title,status,pri,severity')->from(TABLE_BUG)->where('story')->eq($storyID)->andWhere('deleted')->eq(0)->fetchAll();
|
||||
@@ -1318,7 +1330,7 @@ class story extends control
|
||||
$this->view->storyModule = $storyModule;
|
||||
$this->view->modulePath = $modulePath;
|
||||
$this->view->storyProducts = $storyProducts;
|
||||
$this->view->version = $version == 0 ? $story->version : $version;
|
||||
$this->view->version = $version;
|
||||
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('story', $storyID);
|
||||
$this->view->from = $from;
|
||||
$this->view->param = $param;
|
||||
|
||||
+15
-8
@@ -265,7 +265,7 @@ class storyModel extends model
|
||||
}
|
||||
|
||||
$this->file->updateObjectID($this->post->uid, $storyID, $story->type);
|
||||
$this->file->saveUpload($story->type, $storyID, $extra = 1);
|
||||
$this->file->saveUpload($story->type, $storyID, ',1,');
|
||||
|
||||
if(!empty($story->plan))
|
||||
{
|
||||
@@ -685,7 +685,7 @@ class storyModel extends model
|
||||
$oldStoryReviewers = $this->getReviewerPairs($storyID, $oldStory->version);
|
||||
$_POST['reviewer'] = isset($_POST['reviewer']) ? $_POST['reviewer'] : array();
|
||||
$reviewerHasChanged = (array_diff(array_keys($oldStoryReviewers), $_POST['reviewer']) or array_diff($_POST['reviewer'], array_keys($oldStoryReviewers)));
|
||||
if($story->spec != $oldStory->spec or $story->verify != $oldStory->verify or $story->title != $oldStory->title or $this->loadModel('file')->getCount() or $reviewerHasChanged) $specChanged = true;
|
||||
if($story->spec != $oldStory->spec or $story->verify != $oldStory->verify or $story->title != $oldStory->title or $this->loadModel('file')->getCount() or $reviewerHasChanged or isset($_POST['deleteFiles'])) $specChanged = true;
|
||||
|
||||
$now = helper::now();
|
||||
$story = fixer::input('post')
|
||||
@@ -703,7 +703,7 @@ class storyModel extends model
|
||||
->setIF($specChanged and $oldStory->closedBy, 'closedDate', '0000-00-00')
|
||||
->setIF(!$specChanged, 'status', $oldStory->status)
|
||||
->stripTags($this->config->story->editor->change['id'], $this->config->allowedTags)
|
||||
->remove('files,labels,reviewer,comment,needNotReview,uid')
|
||||
->remove('files,labels,reviewer,comment,needNotReview,uid,deleteFiles')
|
||||
->get();
|
||||
|
||||
$story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->change['id'], $this->post->uid);
|
||||
@@ -760,6 +760,10 @@ class storyModel extends model
|
||||
$oldStory->reviewers = implode(',', array_keys($oldStoryReviewers));
|
||||
$story->reviewers = implode(',', $_POST['reviewer']);
|
||||
}
|
||||
|
||||
$deleteFiles = isset($_POST['deleteFiles']) ? $_POST['deleteFiles'] : array();
|
||||
if(!empty($deleteFiles)) $this->file->deleteStoryFile($story->id, $story->version, $deleteFiles);
|
||||
$this->file->updateStoryFileVersion($story->id, $story->version, $deleteFiles);
|
||||
}
|
||||
|
||||
$this->file->updateObjectID($this->post->uid, $storyID, 'story');
|
||||
@@ -824,7 +828,7 @@ class storyModel extends model
|
||||
->join('linkStories', ',')
|
||||
->join('linkRequirements', ',')
|
||||
->join('childStories', ',')
|
||||
->remove('files,labels,comment,contactListMenu,stages,reviewer,needNotReview')
|
||||
->remove('files,labels,comment,contactListMenu,stages,reviewer,needNotReview,deleteFiles')
|
||||
->get();
|
||||
|
||||
if($oldStory->type == 'story' and !isset($story->linkStories)) $story->linkStories = '';
|
||||
@@ -1031,6 +1035,9 @@ class storyModel extends model
|
||||
$this->dao->update(TABLE_STORY)->set($linkStoryField)->eq(implode(',', $linkStories))->where('id')->eq((int)$changeStoryID)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['deleteFiles'])) $this->file->deleteStoryFile($storyID, $oldStory->version, $_POST['deleteFiles']);
|
||||
$this->file->updateObjectID($this->post->uid, $storyID, 'story');
|
||||
return common::createChanges($oldStory, $story);
|
||||
}
|
||||
}
|
||||
@@ -1478,7 +1485,7 @@ class storyModel extends model
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->in($deleteVersion)->exec();
|
||||
}
|
||||
|
||||
$this->dao->delete()->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('objectID')->eq($storyID)->andWhere('extra')->eq($oldStory->version)->exec();
|
||||
$this->file->deleteStoryFile($storyID, $oldStory->version);
|
||||
}
|
||||
if($this->post->result != 'reject') $this->setStage($storyID);
|
||||
|
||||
@@ -1585,10 +1592,10 @@ class storyModel extends model
|
||||
*/
|
||||
public function recallChange($storyID)
|
||||
{
|
||||
$story = $this->getById($storyID);
|
||||
$preVersion = $story->version - 1;
|
||||
$story = $this->getById($storyID);
|
||||
|
||||
/* Update story title and version and status. */
|
||||
$preVersion = $story->version - 1;
|
||||
$preTitle = $this->dao->select('title')->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->eq($preVersion)->fetch('title');
|
||||
$this->dao->update(TABLE_STORY)->set('title')->eq($preTitle)->set('version')->eq($preVersion)->set('status')->eq('active')->where('id')->eq($storyID)->exec();
|
||||
|
||||
@@ -1596,7 +1603,7 @@ class storyModel extends model
|
||||
$this->dao->delete()->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->eq($story->version)->exec();
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($story->version)->exec();
|
||||
|
||||
$this->dao->delete()->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('objectID')->eq($storyID)->andWhere('extra')->eq($story->version)->exec();
|
||||
$this->loadModel('file')->deleteStoryFile($storyID, $story->version);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<tr>
|
||||
<th><?php echo $lang->attatch;?></th>
|
||||
<td>
|
||||
<?php echo $this->fetch('file', 'printFiles', array('files' => $files, 'fieldset' => 'true', 'object' => $story, 'method' => 'storyChange'));?>
|
||||
<?php echo $this->fetch('file', 'printFiles', array('files' => $files, 'fieldset' => 'false', 'object' => $story, 'method' => 'edit'));?>
|
||||
<?php echo $this->fetch('file', 'buildform');?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -85,6 +85,14 @@
|
||||
<?php echo strpos('draft,changing', $story->status) !== false ? html::textarea('verify', htmlSpecialString($story->verify), "rows='5' class='form-control'") : $story->verify;?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='detail'>
|
||||
<div class='detail-title'><?php echo $lang->attatch;?></div>
|
||||
<div class='form-group'>
|
||||
<?php $canChangeFile = strpos('draft,changing', $story->status) !== false ? true : false;?>
|
||||
<?php echo $this->fetch('file', 'printFiles', array('files' => $files, 'fieldset' => 'false', 'object' => $story, 'method' => 'edit', 'showDelete' => $canChangeFile));?>
|
||||
<?php echo $canChangeFile ? $this->fetch('file', 'buildform') : '';?>
|
||||
</div>
|
||||
</div>
|
||||
<?php $this->printExtendFields($story, 'div', 'position=left');?>
|
||||
<div class='detail'>
|
||||
<div class='detail-title'><?php echo $lang->story->comment;?></div>
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
-->
|
||||
<?php echo $this->fetch('file', 'printFiles', array('files' => $story->files, 'fieldset' => 'true', 'object' => $story));?>
|
||||
<?php echo $this->fetch('file', 'printFiles', array('files' => $story->files, 'fieldset' => 'true', 'object' => $story, 'method' => 'view', 'showDelete' => false));?>
|
||||
<?php
|
||||
$canBeChanged = common::canBeChanged('story', $story);
|
||||
if($canBeChanged) $actionFormLink = $this->createLink('action', 'comment', "objectType=story&objectID=$story->id");
|
||||
|
||||
@@ -549,6 +549,9 @@ class upgradeModel extends model
|
||||
$this->updateStoryStatus();
|
||||
if(strpos($fromVersion, 'max') !== false) $this->syncCase2Project();
|
||||
break;
|
||||
case '17_6':
|
||||
$this->updateStoryFile();
|
||||
break;
|
||||
}
|
||||
|
||||
$this->deletePatch();
|
||||
@@ -7204,4 +7207,38 @@ class upgradeModel extends model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update story file version.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateStoryFile()
|
||||
{
|
||||
$storyFileList = $this->dao->select('*')->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('extra')->ne('editor')->fetchAll('id');
|
||||
|
||||
/* Get story version. */
|
||||
$storyIDList = array();
|
||||
foreach($storyFileList as $file) $storyIDList[$file->objectID] = $file->objectID;
|
||||
$storyVersionList = $this->dao->select('id,version')->from(TABLE_STORY)->where('id')->in($storyIDList)->fetchPairs();
|
||||
|
||||
foreach($storyFileList as $file)
|
||||
{
|
||||
if(!is_numeric($file->extra)) continue;
|
||||
|
||||
$fileExtra = '';
|
||||
$storyVersion = $storyVersionList[$file->objectID];
|
||||
if($file->extra != $storyVersion)
|
||||
{
|
||||
for($i = $file->extra; $i <= $storyVersion; $i ++) $fileExtra .= ",$i";
|
||||
$fileExtra .= ',';
|
||||
}
|
||||
if(empty($fileExtra)) $fileExtra = ",$file->extra,";
|
||||
|
||||
$this->dao->update(TABLE_FILE)->set('extra')->eq($fileExtra)->where('id')->eq($file->id)->exec();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user