diff --git a/module/execution/model.php b/module/execution/model.php index ee2c4fb8ce..a8e46e628e 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1178,6 +1178,10 @@ class executionModel extends model { $link = helper::createLink($module, $method, "productID=0&branch=0&extra=executionID=%s"); } + elseif($module == 'bug' and $method == 'view') + { + $link = helper::createLink('execution', 'bug', "executionID=%s"); + } else { $link = helper::createLink($module, $method, "executionID=%s"); diff --git a/module/file/control.php b/module/file/control.php index e9c08f9a49..ff5e46caa4 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -63,7 +63,7 @@ class file extends control die(json_encode(array('error' => 1, 'message' => $this->lang->file->errorFileUpload))); } } - if(@helper::saveFile($file['tmpname'], $this->file->savePath . $this->file->getSaveName($file['pathname']))) + if(@move_uploaded_file($file['tmpname'], $this->file->savePath . $this->file->getSaveName($file['pathname']))) { /* Compress image for jpg and bmp. */ $file = $this->file->compressImage($file); diff --git a/module/file/model.php b/module/file/model.php index c798587d83..1a2252c579 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -262,7 +262,7 @@ class fileModel extends model } else { - if(!helper::saveFile($file['tmpname'], $tmpFileChunkPath)) return false; + if(!move_uploaded_file($file['tmpname'], $tmpFileChunkPath)) return false; } if($file['chunk'] == ($file['chunks'] - 1)) @@ -278,7 +278,7 @@ class fileModel extends model } else { - if(!helper::saveFile($file['tmpname'], $file['realpath'])) return false; + if(!move_uploaded_file($file['tmpname'], $file['realpath'])) return false; $uploadFile['extension'] = $file['extension']; $uploadFile['pathname'] = $file['pathname']; @@ -471,7 +471,7 @@ class fileModel extends model $pathName = $filePath->pathname; $realPathName = $this->savePath . $this->getRealPathName($pathName); if(!is_dir(dirname($realPathName))) mkdir(dirname($realPathName)); - helper::saveFile($file['tmpname'], $realPathName); + move_uploaded_file($file['tmpname'], $realPathName); $file['pathname'] = $pathName; $file = $this->compressImage($file); @@ -966,4 +966,29 @@ class fileModel extends model die(); } } + + /** + * Get image size. + * + * @access public + * @param object $file + * @return array + */ + public function getImageSize($file) + { + if($this->config->file->storageType == 'fs') + { + return getimagesize($file->realPath); + } + else if($this->config->file->storageType == 's3') + { + $this->app->loadClass('ossclient', true); + + $config = $this->config->file; + $ossClient = new ossclient($config->accessKeyId, $config->accessKeySecret, $config->endpoint, $config->bucket); + $info = $ossClient->getImageInfo($file->pathname); + + return array($info->ImageWidth->value, $info->ImageHeight->value, 'img'); + } + } } diff --git a/module/file/view/printfiles.html.php b/module/file/view/printfiles.html.php index b7de5a98cf..e4c7c2a783 100644 --- a/module/file/view/printfiles.html.php +++ b/module/file/view/printfiles.html.php @@ -53,7 +53,7 @@ $sessionString .= session_name() . '=' . session_id(); $imageWidth = 0; if(stripos('jpg|jpeg|gif|png|bmp', $file->extension) !== false) { - $imageSize = getimagesize($file->realPath); + $imageSize = $this->file->getImageSize($file); $imageWidth = $imageSize ? $imageSize[0] : 0; } diff --git a/module/product/model.php b/module/product/model.php index 5f8bb17ca5..dc6149eb9a 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -1601,7 +1601,8 @@ class productModel extends model } elseif($module == 'testtask') { - $link = helper::createLink($module, 'browse', "productID=%s" . ($branch ? "&branch=%s" : '&branch=0') . "&extra=$extra"); + $extra = $method != 'browse' ? '' : "&extra=$extra"; + $link = helper::createLink($module, 'browse', "productID=%s" . ($branch ? "&branch=%s" : '&branch=0') . $extra); } elseif($module == 'bug' && $method == 'view') { diff --git a/module/project/model.php b/module/project/model.php index 3b5b3a0d57..2c27689277 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -815,6 +815,8 @@ class projectModel extends model $this->dao->replace(TABLE_USERGROUP)->data($groupPriv)->exec(); } + if($project->acl != 'open') $this->loadModel('user')->updateUserView($projectID, 'project'); + return $projectID; } } diff --git a/module/upgrade/control.php b/module/upgrade/control.php index 403469e06c..f51da2b2be 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -134,7 +134,7 @@ class upgrade extends control if(!$this->upgrade->isError()) { - if(!$this->config->systemMode && !isset($this->config->qcVersion)) $this->locate(inlink('to15Guide', "fromVersion=$fromVersion")); + if(!$this->config->systemMode && !isset($this->config->qcVersion) && strpos($fromVersion, 'max') === false) $this->locate(inlink('to15Guide', "fromVersion=$fromVersion")); $this->locate(inlink('afterExec', "fromVersion=$fromVersion")); } diff --git a/module/upgrade/model.php b/module/upgrade/model.php index cefc175566..5c8a6dbf4f 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -4199,6 +4199,7 @@ class upgradeModel extends model $program->openedDate = helper::now(); $program->openedVersion = $this->config->version; $program->acl = 'open'; + $program->days = $this->computeDaysDelta($program->begin, $program->end); $this->app->loadLang('program'); $this->app->loadLang('project'); @@ -4274,6 +4275,7 @@ class upgradeModel extends model $project->status = $data->projectStatus; $project->begin = $data->begin; $project->end = isset($data->end) ? $data->end : LONG_TIME; + $project->days = $this->computeDaysDelta($project->begin, $project->end); $project->PM = $data->PM; $project->auth = 'extend'; $project->openedBy = $account; @@ -4324,6 +4326,32 @@ class upgradeModel extends model return array($programID, $projectID, $lineID); } + /** + * Compute delta of two days. + * + * @param string begin + * @param string end + * @access public + * @return int + */ + public function computeDaysDelta($begin, $end) + { + if($end == LONG_TIME) return 0; + + $delta = helper::diffDate($end, $begin); + $week = date('w', strtotime($begin)); + $weekend = 0; + for($i = 0; $i < $delta; $i++) + { + $week = $week % 7; + if($week == 0 or $week == 6) $weekend ++; + + $week++; + } + + return $delta - $weekend; + } + /** * Replace program or project id for product and project linked objects. * @@ -4397,8 +4425,11 @@ class upgradeModel extends model $this->dao->replace(TABLE_PROJECTCASE)->data($projectCase)->exec(); } - /* Compute sprint path and grade. */ - $sprints = $this->dao->select('id, type, acl')->from(TABLE_PROJECT)->where('id')->in($sprintIdList)->fetchAll(); + /* Compute sprint path, grade and the minimum start date and end date of the project. */ + $project = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch(); + $sprints = $this->dao->select('id, type, acl, begin, end')->from(TABLE_PROJECT)->where('id')->in($sprintIdList)->fetchAll(); + $minBeginDate = $project->begin; + $maxEndData = $project->end; foreach($sprints as $sprint) { $data = new stdclass(); @@ -4411,6 +4442,9 @@ class upgradeModel extends model $data->lifetime = empty($sprint->lifetime) ? $sprint->type : $sprint->lifetime; $this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($sprint->id)->exec(); + + $minBeginDate = ($sprint->begin < $minBeginDate) ? $sprint->begin : $minBeginDate; + $maxEndData = $sprint->end > $maxEndData ? $sprint->end : $maxEndData; } /* Compute project date and status. */ @@ -4429,6 +4463,13 @@ class upgradeModel extends model $data->closedDate = $maxRealEnd; } + if($minBeginDate != $project->begin or $maxEndData != $project->end) + { + $data->begin = $minBeginDate; + $data->end = $maxEndData; + $data->days = $this->computeDaysDelta($data->begin, $data->end); + } + $this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($projectID)->exec(); /* Set product and project relation. */ @@ -4481,8 +4522,10 @@ class upgradeModel extends model $users = $this->dao->select('account')->from(TABLE_USER)->where('deleted')->eq('0')->fetchPairs('account', 'account'); /* Insert product and sprint team into project team. */ - $today = helper::today(); - foreach($teams as $account) + $today = helper::today(); + $project = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch(); + $projectMember = $this->dao->select('*')->from(TABLE_TEAM)->where('account')->in($teams)->fetchAll('account'); + foreach($projectMember as $account => $user) { if(empty($account)) continue; if(!isset($users[$account])) continue; @@ -4491,7 +4534,10 @@ class upgradeModel extends model $team->root = $projectID; $team->type = 'project'; $team->account = $account; + $team->role = $user->role; $team->join = $today; + $team->days = $project->days; + $team->hours = '7.0'; $this->dao->replace(TABLE_TEAM)->data($team)->exec(); }