diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php index ecf9871531..aad2bbb639 100644 --- a/lib/scm/gitlab.class.php +++ b/lib/scm/gitlab.class.php @@ -501,7 +501,8 @@ class gitlab if($version) { $lastCommit = $this->getSingleCommit($version); - if(empty($lastCommit)) return array(); + if(!isset($lastCommit->committed_date)) return array('commits' => array(), 'files' => array()); + $params['until'] = $lastCommit->committed_date; } @@ -644,7 +645,13 @@ class gitlab $api = ltrim($api, '/'); $api = $this->root . $api . '?' . http_build_query($params); - $response = file_get_contents($api); + $response = commonModel::http($api); + if(!empty(commonModel::$requestErrors)) + { + commonModel::$requestErrors = array(); + return array(); + } + return json_decode($response); } diff --git a/module/bug/control.php b/module/bug/control.php index aa08869665..9bf56305b2 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -546,7 +546,7 @@ class bug extends control } /* Get executions. */ - $executions = array('' => ''); + $executions = array(0 => ''); if(isset($projects[$projectID]) or $this->config->systemMode == 'classic') $executions += $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, 'id_desc', $projectID); /* Set custom. */ @@ -877,7 +877,7 @@ class bug extends control $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $bug->branch); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); $this->view->currentModuleID = $currentModuleID; - $this->view->executions = $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $projectID); + $this->view->executions = array(0 => '') + $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $projectID); $this->view->stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch); $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product); $this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution); 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/project/model.php b/module/project/model.php index a078124118..2c27689277 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -748,7 +748,7 @@ class projectModel extends model $lib->name = $this->lang->doclib->main['project']; $lib->type = 'project'; $lib->main = '1'; - $lib->acl = $project->acl; + $lib->acl = $project->acl != 'program' ? $project->acl : 'custom'; $this->dao->insert(TABLE_DOCLIB)->data($lib)->exec(); $this->updateProducts($projectID); @@ -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/repo/control.php b/module/repo/control.php index 9580fd9d4f..411c1b0bc5 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -867,7 +867,7 @@ class repo extends control set_time_limit(0); $repo = $this->repo->getRepoByID($repoID); if(empty($repo)) die(); - //if($repo->synced) die('finish'); + if($repo->synced) die('finish'); $this->commonAction($repoID); $this->scm->setEngine($repo); diff --git a/module/repo/model.php b/module/repo/model.php index fd22ec2338..03ec69715a 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -281,15 +281,18 @@ class repoModel extends model $repo = $this->getRepoByID($id); $data = fixer::input('post') + ->setIf($this->post->SCM == 'Gitlab', 'password', $this->post->gitlabToken) + ->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost) + ->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject) ->setDefault('client', 'svn') ->setDefault('prefix', $repo->prefix) ->setDefault('product', '') - ->setIF($this->post->path != $repo->path, 'synced', 0) ->skipSpecial('path,client,account,password') ->join('product', ',') ->get(); if($this->post->SCM == 'Gitlab') $data->path = sprintf($this->config->repo->gitlab->apiPath, $data->gitlabHost, $this->post->gitlabProject); + if($data->path != $repo->path) $data->synced = 0; $data->acl = empty($data->acl) ? '' : json_encode($data->acl); @@ -313,7 +316,7 @@ class repoModel extends model $this->dao->update(TABLE_REPO)->data($data, $skip = 'gitlabHost,gitlabToken,gitlabProject') ->batchCheck($this->config->repo->edit->requiredFields, 'notempty') ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') - ->checkIF($data->SCM == 'GitLab', 'gitlabProject', 'notempty') + ->checkIF($data->SCM == 'GitLab', 'extra', 'notempty') ->autoCheck() ->where('id')->eq($id)->exec(); 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 4d66019fca..5c8a6dbf4f 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -647,6 +647,10 @@ class upgradeModel extends model $this->saveLogs('Execute 15_0_rc2'); $this->execSQL($this->getUpgradeFile('15.0.rc2')); $this->appendExec('15_0_rc2'); + case '15_0_rc3': + $this->saveLogs('Execute 15_0_rc3'); + $this->updateLibType(); + $this->appendExec('15_0_rc3'); } $this->deletePatch(); @@ -4306,7 +4310,7 @@ class upgradeModel extends model $lib->name = $this->lang->doclib->main['project']; $lib->type = 'project'; $lib->main = '1'; - $lib->acl = $project->acl; + $lib->acl = $project->acl != 'program' ? $project->acl : 'custom'; $this->dao->insert(TABLE_DOCLIB)->data($lib)->exec(); $this->loadModel('action')->create('project', $projectID, 'openedbysystem'); @@ -4909,4 +4913,18 @@ class upgradeModel extends model return true; } + + /** + * Update execution main doclib type. + * + * @access public + * @return bool + */ + public function updateLibType() + { + $executionList = $this->dao->select('id')->from(TABLE_EXECUTION)->where('type')->eq('sprint')->fetchAll('id'); + $this->dao->update(TABLE_DOCLIB)->set('type')->eq('execution')->where('execution')->in(array_keys($executionList))->exec(); + + return true; + } } diff --git a/module/user/model.php b/module/user/model.php index 3b68f42bee..b21d70430b 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -192,6 +192,7 @@ class userModel extends model * Get user info by ID. * * @param mix $userID + * @param string $field id|account * @access public * @return object|bool */ diff --git a/test/init.php b/test/init.php index 7fbea75295..5b362be7c9 100644 --- a/test/init.php +++ b/test/init.php @@ -29,6 +29,13 @@ $tester = $app->loadCommon(); $config->zendataRoot = dirname(__FILE__) . DS . 'zendata'; $config->zdPath = "/usr/local/zd/zd"; +/** + * Save variable to $_result. + * + * @param mix $result + * @access public + * @return bool true + */ function run($result) { global $_result; @@ -36,6 +43,14 @@ function run($result) return true; } +/** + * Print expect data. + * + * @param string $key + * @param string $delimiter + * @access public + * @return void + */ function expect($key, $delimiter = ',') { global $_result; @@ -66,12 +81,21 @@ function expect($key, $delimiter = ',') echo "\n"; } +/** + * Import data create by zendata to one table. + * + * @param string $table + * @param string $yaml + * @param int $count + * @access public + * @return void + */ function zdImport($table, $yaml, $count = 10) { chdir(dirname(__FILE__)); global $app, $config; $dns = "mysql://{$config->db->user}:{$config->db->password}@{$config->db->host}:{$config->db->port}/{$config->db->name}#utf8"; $table = trim($table, '`'); - $commad = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count"; - system($commad); + $command = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count"; + system($command); }