* Fix the bug of upload images when batch create bug.
This commit is contained in:
@@ -765,15 +765,13 @@ class bug extends control
|
||||
|
||||
$message = '';
|
||||
$bugIdList = array();
|
||||
foreach($bugs as $index => $bug)
|
||||
foreach($bugs as $bug)
|
||||
{
|
||||
$bug->id = $this->bug->create($bug);
|
||||
|
||||
/* 批量创建后的一些其他操作。*/
|
||||
/* Processing other operations after batch creation. */
|
||||
$uploadImage = !empty($this->post->uploadImage[$index]) ? $this->post->uploadImage[$index] : '';
|
||||
$file = $this->bugZen->processImageForBatchCreate($bug, $uploadImage, $bugImagesFile);
|
||||
$this->bugZen->afterBatchCreate($bug, $output, $uploadImage, $file);
|
||||
$this->bugZen->afterBatchCreate($bug, $output);
|
||||
|
||||
$message = $this->executeHooks($bug->id);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class bugModel extends model
|
||||
*/
|
||||
public function create(object $bug, string $from = ''): int|false
|
||||
{
|
||||
$this->dao->insert(TABLE_BUG)->data($bug, 'laneID')
|
||||
$this->dao->insert(TABLE_BUG)->data($bug, 'laneID,uploadImage,imageFile')
|
||||
->autoCheck()
|
||||
->checkIF(!empty($bug->notifyEmail), 'notifyEmail', 'email')
|
||||
->batchCheck($this->config->bug->create->requiredFields, 'notempty')
|
||||
|
||||
+20
-14
@@ -1269,10 +1269,11 @@ class bugZen extends bug
|
||||
*
|
||||
* @param int $productID
|
||||
* @param string $branch
|
||||
* @param array $bugImagesFile
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function buildBugsForBatchCreate(int $productID, string $branch): array
|
||||
protected function buildBugsForBatchCreate(int $productID, string $branch, array $bugImagesFile): array
|
||||
{
|
||||
$bugs = form::batchData($this->config->bug->form->batchCreate)->get();
|
||||
|
||||
@@ -1282,7 +1283,7 @@ class bugZen extends bug
|
||||
while($module = $stmt->fetch()) $moduleOwners[$module->id] = $module->owner;
|
||||
|
||||
/* Construct data. */
|
||||
foreach($bugs as $bug)
|
||||
foreach($bugs as $index => $bug)
|
||||
{
|
||||
$bug->openedBy = $this->app->user->account;
|
||||
$bug->openedDate = helper::now();
|
||||
@@ -1295,6 +1296,11 @@ class bugZen extends bug
|
||||
$bug->assignedTo = $moduleOwners[$bug->module];
|
||||
$bug->assignedDate = helper::now();
|
||||
}
|
||||
|
||||
$uploadImage = !empty($this->post->uploadImage[$index]) ? $this->post->uploadImage[$index] : '';
|
||||
$imageFile = $this->processImageForBatchCreate($bug, $uploadImage, $bugImagesFile);
|
||||
$bug->uploadImage = $uploadImage;
|
||||
$bug->imageFile = $imageFile;
|
||||
}
|
||||
|
||||
return $bugs;
|
||||
@@ -1782,7 +1788,7 @@ class bugZen extends bug
|
||||
$this->loadModel('file')->saveFile($file, 'realpath');
|
||||
|
||||
$fileID = $this->dao->lastInsertID();
|
||||
$bug->steps .= '<img src="{' . $fileID . '.' . $file['extension'] . '}" alt="" />';
|
||||
$bug->steps .= '<br><img src="{' . $fileID . '.' . $file['extension'] . '}" alt="" />';
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1976,12 +1982,10 @@ class bugZen extends bug
|
||||
*
|
||||
* @param object $bug
|
||||
* @param array $output
|
||||
* @param string $uploadImage
|
||||
* @param array $file
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
protected function afterBatchCreate(object $bug, array $output, string|null $uploadImage, array $file): bool
|
||||
protected function afterBatchCreate(object $bug, array $output): bool
|
||||
{
|
||||
/* If bug has the execution, update kanban data. */
|
||||
if($bug->execution)
|
||||
@@ -1998,14 +2002,16 @@ class bugZen extends bug
|
||||
}
|
||||
|
||||
/* When the bug is created by uploading the image, add the image to the file of the bug. */
|
||||
if(!empty($uploadImage) and !empty($file))
|
||||
if(!empty($bug->uploadImage) and !empty($bug->imageFile))
|
||||
{
|
||||
$file['objectType'] = 'bug';
|
||||
$file['objectID'] = $bug->id;
|
||||
$file['addedBy'] = $this->app->user->account;
|
||||
$file['addedDate'] = helper::now();
|
||||
$this->dao->insert(TABLE_FILE)->data($file, 'realpath')->exec();
|
||||
unset($file);
|
||||
$bug->imageFile['objectType'] = 'bug';
|
||||
$bug->imageFile['objectID'] = $bug->id;
|
||||
$bug->imageFile['addedBy'] = $this->app->user->account;
|
||||
$bug->imageFile['addedDate'] = helper::now();
|
||||
$this->dao->insert(TABLE_FILE)->data($bug->imageFile, 'realpath')->exec();
|
||||
|
||||
unset($bug->imageFile);
|
||||
unset($bug->uploadImage);
|
||||
}
|
||||
|
||||
return !dao::isError();
|
||||
@@ -2172,7 +2178,7 @@ class bugZen extends bug
|
||||
helper::setcookie('bugModule', '0', 0);
|
||||
|
||||
/* Remove upload image file and session. */
|
||||
if(!empty($this->post->uploadImage) and !empty($this->session->bugImagesFile))
|
||||
if(!empty($_POST['uploadImage']) and !empty($_SESSION['bugImagesFile']))
|
||||
{
|
||||
$classFile = $this->app->loadClass('zfile');
|
||||
$file = current($_SESSION['bugImagesFile']);
|
||||
|
||||
Reference in New Issue
Block a user