diff --git a/api/v1/entries/my.php b/api/v1/entries/my.php deleted file mode 100644 index 0031985771..0000000000 --- a/api/v1/entries/my.php +++ /dev/null @@ -1,22 +0,0 @@ -loadModel('my')->getInfo(); - $info->products = $this->loadModel('my')->getProducts(); - $info->projects = $this->loadModel('my')->getProjects(); - $info->joinProjectCount = count($info->projects); - $info->dynamic = $this->loadModel('my')->getDynamic(); - - if(!$info) return $this->sendError(400, $info->message); - $this->send(200, $info); - } -} diff --git a/api/v1/entries/product.php b/api/v1/entries/product.php index 524abf92d1..367e4594e2 100644 --- a/api/v1/entries/product.php +++ b/api/v1/entries/product.php @@ -14,7 +14,7 @@ class productEntry extends Entry $control->view($productID); $data = $this->getData(); - if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404(); + if(!$data or (isset($data->message) and $data->message == '404 Not found')) return $this->send404(); if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->product, 'createdDate:time')); if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); diff --git a/api/v1/entries/productissue.php b/api/v1/entries/productissue.php index 1546897052..eecc5704c4 100644 --- a/api/v1/entries/productissue.php +++ b/api/v1/entries/productissue.php @@ -33,9 +33,8 @@ class productIssueEntry extends entry $issue->title = $story->title; $issue->labels = array($this->app->lang->story->common, zget($this->app->lang->story->categoryList, $story->category)); $issue->pri = $story->pri; - $issue->assignedTo = $this->entry->getAssignees('story', $story); $issue->openedDate = $story->openedDate; - $issue->openedBy = $this->entry->getUser($story->openedBy); + $issue->openedBy = $story->openedBy; $issue->lastEditedDate = $story->lastEditedDate < '1970-01-01 01:01:01' ? $story->openedDate : $story->lastEditedDate; $issue->lastEditedBy = $story->lastEditedDate < '1970-01-01 01:01:01' ? $story->openedBy : $story->lastEditedBy; $issue->status = $storyStatus[$story->status]; @@ -43,6 +42,16 @@ class productIssueEntry extends entry $storySpec = $this->dao->select('*')->from(TABLE_STORYSPEC)->where('story')->eq($id)->andWhere('version')->eq($story->version)->fetch(); $issue->desc = $storySpec->spec; + + if($story->assignedTo == "") + { + $issue->assignedTo = array(); + } + else + { + $issue->assignedTo = array($story->assignedTo); + } + break; case 'bug': $this->app->loadLang('bug'); @@ -55,15 +64,25 @@ class productIssueEntry extends entry $issue->title = $bug->title; $issue->labels = array($this->app->lang->bug->common, zget($this->app->lang->bug->typeList, $bug->type)); $issue->pri = $bug->pri; - $issue->assignedTo = $this->entry->getAssignees('bug', $bug); $issue->openedDate = $bug->openedDate; - $issue->openedBy = $this->entry->getUser($bug->openedBy); + $issue->openedBy = $bug->openedBy; $issue->lastEditedDate = $bug->lastEditedDate < '1970-01-01 01:01:01' ? $bug->openedDate : $bug->lastEditedDate; $issue->lastEditedBy = $bug->lastEditedDate < '1970-01-01 01:01:01' ? $bug->openedBy : $bug->lastEditedBy; $issue->status = $bugStatus[$bug->status]; $issue->url = helper::createLink('bug', 'view', "bugID=$id"); $issue->desc = $bug->steps; + + if($bug->assignedTo == "") + { + $issue->assignedTo = array(); + } + else + { + $issue->assignedTo = array($bug->assignedTo); + } + break; + case 'task': $this->app->loadLang('task'); $taskStatus = array('' => '', 'wait' => 'opened', 'doing' => 'opened', 'done' => 'opened', 'pause' => 'opened', 'cancel' => 'opened', 'closed' => 'closed'); @@ -75,22 +94,69 @@ class productIssueEntry extends entry $issue->title = $task->name; $issue->labels = array($this->app->lang->task->common, zget($this->app->lang->task->typeList, $task->type)); $issue->pri = $task->pri; - $issue->assignedTo = $this->entry->getAssignees('task', $task); $issue->openedDate = $task->openedDate; - $issue->openedBy = $this->entry->getUser($task->openedBy); + $issue->openedBy = $task->openedBy; $issue->lastEditedDate = $task->lastEditedDate < '1970-01-01 01:01:01' ? $task->openedDate : $task->lastEditedDate; $issue->lastEditedBy = $task->lastEditedDate < '1970-01-01 01:01:01' ? $task->openedBy : $task->lastEditedBy; $issue->status = $taskStatus[$task->status]; $issue->url = helper::createLink('task', 'view', "taskID=$id"); $issue->desc = $task->desc; + /* Get assignees for task, the task object has the type of multiple assign only so far. */ + $users = $this->dao->select('account')->from(TABLE_TEAM) + ->where('type')->eq('task') + ->andWhere('root')->eq($task->id) + ->fetchAll(); + if($users) + { + foreach($users as $user) + { + $issue->assignedTo[] = $user->account; + } + } + else + { + if($task->assignedTo == "") + { + $issue->assignedTo = array(); + } + else + { + $issue->assignedTo = array($task->assignedTo); + } + } + break; + default: $this->send404(); } $actions = $this->loadModel('action')->getList($type, $issueID); + /** + * Get all users in issues so that we can bulk get user detail later. + * + */ + $userList = array(); + foreach($issue->assignedTo as $user) + { + $userList[] = $user; + } + $userList[] = $issue->openedBy; + $userList = array_unique($userList); + $userDetails = $this->loadModel('user')->getUserDetailsForAPI($userList); + + /** + * Set the user detail to assignedTo and openedBy. + * + */ + foreach($issue->assignedTo as $index => $user) + { + $issue->assignedTo[$index] = $userDetails[$user]; + } + $issue->openedBy = $userDetails[$issue->openedBy]; + $this->send(200, array('issue' => $this->format($issue, 'openedDate:time,lastEditedDate:time'))); } } diff --git a/api/v1/entries/productissues.php b/api/v1/entries/productissues.php index a8c24b65c5..7c2e8d1abb 100644 --- a/api/v1/entries/productissues.php +++ b/api/v1/entries/productissues.php @@ -124,7 +124,7 @@ class productIssuesEntry extends entry ->beginIF($storyFilter != 'all')->andWhere('category')->in($storyFilter)->fi() ->andWhere('deleted')->eq(0) ->fetchAll(); - foreach($stories as $story) $issues[] = array('id' => $story->id, 'type' => 'story', 'order' => $story->$order, 'status' => $this->getKey($story->status, $storyStatus)); + foreach($stories as $story) $issues[] = array('id' => $story->id, 'type' => 'story', 'order' => $story->$order, 'status' => $this->getKey($story->status, $storyStatus)); } if($bugFilter) @@ -136,7 +136,7 @@ class productIssuesEntry extends entry ->beginIF($bugFilter != 'all')->andWhere('type')->in($bugFilter)->fi() ->andWhere('deleted')->eq(0) ->fetchAll(); - foreach($bugs as $bug) $issues[] = array('id' => $bug->id, 'type' => 'bug', 'order' => $bug->$order, 'status' => $this->getKey($bug->status, $bugStatus)); + foreach($bugs as $bug) $issues[] = array('id' => $bug->id, 'type' => 'bug', 'order' => $bug->$order, 'status' => $this->getKey($bug->status, $bugStatus)); } array_multisort(array_column($issues, 'order'), $sort == 'asc' ? SORT_ASC : SORT_DESC, $issues); @@ -190,13 +190,38 @@ class productIssuesEntry extends entry $r->title = $task->name; $r->labels = array($this->app->lang->task->common, zget($this->app->lang->task->typeList, $task->type)); $r->pri = $task->pri; - $r->assignedTo = $this->entry->getAssignees('task', $task); $r->openedDate = $task->openedDate; - $r->openedBy = $this->entry->getUser($task->openedBy); + $r->openedBy = $task->openedBy; $r->lastEditedDate = $task->lastEditedDate < '1970-01-01 01:01:01' ? $task->openedDate : $task->lastEditedDate; $r->lastEditedBy = $task->lastEditedDate < '1970-01-01 01:01:01' ? $task->openedBy : $task->lastEditedBy; $r->status = $issue['status']; $r->url = helper::createLink('task', 'view', "taskID=$task->id"); + $r->assignedTo = array(); + + /* Get assignees for task, the task object has the type of multiple assign only so far. */ + $users = $this->dao->select('account')->from(TABLE_TEAM) + ->where('type')->eq('task') + ->andWhere('root')->eq($task->id) + ->fetchAll(); + if($users) + { + foreach($users as $user) + { + $r->assignedTo[] = $user->account; + } + } + else + { + if($task->assignedTo == "") + { + $r->assignedTo = array(); + } + else + { + $r->assignedTo = array($task->assignedTo); + } + } + } else if($issue['type'] == 'story') { @@ -206,13 +231,21 @@ class productIssuesEntry extends entry $r->title = $story->title; $r->labels = array($this->app->lang->story->common, zget($this->app->lang->story->categoryList, $story->category)); $r->pri = $story->pri; - $r->assignedTo = $this->entry->getAssignees('story', $story); $r->openedDate = $story->openedDate; - $r->openedBy = $this->entry->getUser($story->openedBy); + $r->openedBy = $story->openedBy; $r->lastEditedDate = $story->lastEditedDate < '1970-01-01 01:01:01' ? $story->openedDate : $story->lastEditedDate; $r->lastEditedBy = $story->lastEditedDate < '1970-01-01 01:01:01' ? $story->openedBy : $story->lastEditedBy; $r->status = $issue['status']; $r->url = helper::createLink('story', 'view', "storyID=$story->id"); + + if($story->assignedTo == "") + { + $r->assignedTo = array(); + } + else + { + $r->assignedTo = array($story->assignedTo); + } } else if($issue['type'] == 'bug') { @@ -222,18 +255,55 @@ class productIssuesEntry extends entry $r->title = $bug->title; $r->labels = array($this->app->lang->bug->common, zget($this->app->lang->bug->typeList, $bug->type)); $r->pri = $bug->pri; - $r->assignedTo = $this->entry->getAssignees('bug', $bug); $r->openedDate = $bug->openedDate; - $r->openedBy = $this->entry->getUser($bug->openedBy); + $r->openedBy = $bug->openedBy; $r->lastEditedDate = $bug->lastEditedDate < '1970-01-01 01:01:01' ? $bug->openedDate : $bug->lastEditedDate; $r->lastEditedBy = $bug->lastEditedDate < '1970-01-01 01:01:01' ? $bug->openedBy : $bug->lastEditedBy; $r->status = $issue['status']; $r->url = helper::createLink('bug', 'view', "bugID=$bug->id"); + + if($bug->assignedTo == "") + { + $r->assignedTo = array(); + } + else + { + $r->assignedTo = array($bug->assignedTo); + } } $result[] = $this->format($r, 'openedDate:time,lastEditedDate:time'); } + /** + * Get all users in issues so that we can bulk get user detail later. + * + */ + $userList = array(); + foreach($result as $issue) + { + foreach($issue->assignedTo as $user) + { + $userList[] = $user; + } + $userList[] = $issue->openedBy; + } + $userList = array_unique($userList); + $userDetails = $this->loadModel('user')->getUserDetailsForAPI($userList); + + /** + * Set the user detail to assignedTo and openedBy. + * + */ + foreach($result as $issue) + { + foreach($issue->assignedTo as $index => $user) + { + $issue->assignedTo[$index] = $userDetails[$user]; + } + $issue->openedBy = $userDetails[$issue->openedBy]; + } + return $result; } diff --git a/api/v1/entries/user.php b/api/v1/entries/user.php index ecc5faa910..b736b6d65a 100644 --- a/api/v1/entries/user.php +++ b/api/v1/entries/user.php @@ -10,6 +10,10 @@ class userEntry extends Entry { public function get($userID = 0) { + /* Get my info defaultly. */ + if(!$userID) return $this->getInfo(); + + /* Get user by id. */ $control = $this->loadController('user', 'profile'); $control->profile($userID); @@ -20,6 +24,25 @@ class userEntry extends Entry $this->send(200, $this->format($user, 'last:time,locked:time')); } + private function getInfo() + { + $info = $this->loadModel('my')->getInfo(); + + $products = $this->my->getProducts(); + $info->product = new stdclass(); + $info->product->total = count($products); + $info->product->products = $products; + + $projects = $this->my->getProjects(); + $info->project = new stdclass(); + $info->project->total = count($projects); + $info->project->projects = $projects; + + $info->actions = $this->my->getActions(); + + $this->send(200, $info); + } + public function put($userID) { $oldUser = $this->loadModel('user')->getByID($userID, 'id'); diff --git a/config/routes.php b/config/routes.php index a18c4c579f..bf01be4eaf 100644 --- a/config/routes.php +++ b/config/routes.php @@ -33,7 +33,7 @@ $routes['/tasks/:id/finish'] = 'taskFinish'; $routes['/users'] = 'users'; $routes['/users/:id'] = 'user'; -$routes['/my'] = 'my'; +$routes['/user'] = 'user'; $routes['/programs'] = 'programs'; $routes['/programs/:id'] = 'program'; diff --git a/db/update15.3.sql b/db/update15.3.sql index f0b147e39f..58685d2dd9 100644 --- a/db/update15.3.sql +++ b/db/update15.3.sql @@ -1,4 +1,4 @@ ALTER TABLE `zt_testtask` ADD `realFinishedDate` datetime NOT NULL AFTER `end`; -ALTER TABLE `zt_doc` ADD `tempContent` longtext NOT NULL AFTER `views`; +ALTER TABLE `zt_doc` ADD `draft` longtext NOT NULL AFTER `views`; ALTER TABLE `zt_release` ADD `mailto` text AFTER `desc`; ALTER TABLE `zt_release` ADD `notify` varchar(255) AFTER `mailto`; diff --git a/db/zentao.sql b/db/zentao.sql index bb9005b28e..1ffcfa5d74 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -310,7 +310,7 @@ CREATE TABLE IF NOT EXISTS `zt_doc` ( `keywords` varchar(255) NOT NULL, `type` varchar(30) NOT NULL, `views` smallint(5) unsigned NOT NULL, - `tempContent` longtext NOT NULL, + `draft` longtext NOT NULL, `collector` text NOT NULL, `addedBy` varchar(30) NOT NULL, `addedDate` datetime NOT NULL, @@ -1345,7 +1345,7 @@ INSERT INTO `zt_group` (`id`, `name`, `role`, `desc`) VALUES (10, 'OTHERS', 'others', 'for others.'), (11, 'guest', 'guest', 'For guest'), (12, 'LIMITED', 'limited', 'For limited user'), -(13, '项目管理员', 'projectAdmin', '项目管理员可以维护项目的权限'); +(13, 'Project Admin', 'projectAdmin', 'Project Admins manage project privileges'); INSERT INTO `zt_grouppriv` (`group`, `module`, `method`) VALUES (1,'action','editComment'), diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php index a5c472ed06..d360de0edb 100644 --- a/lib/scm/gitlab.class.php +++ b/lib/scm/gitlab.class.php @@ -151,30 +151,32 @@ class gitlab } /** - * Get branch + * Get branches. * * @access public * @return array */ public function branch() { - $branches = array(); - $api = "branches"; - + /* Max size of per_page in gitlab API is 100. */ $params = array(); $params['per_page'] = '100'; + + $branches = array(); for($page = 1; true; $page ++) { $params['page'] = $page; - $list = $this->fetch($api, $params); - if(empty($list)) break; + $branchList = $this->fetch("branches", $params); + if(empty($branchList)) break; - foreach($list as $branch) + foreach($branchList as $branch) { if(!isset($branch->name)) continue; $branches[$branch->name] = $branch->name; } - if(count($list) < $params['per_page']) break; + + /* Last page. */ + if(count($branchList) < $params['per_page']) break; } if(empty($branches)) $branches['master'] = 'master'; @@ -523,7 +525,6 @@ class gitlab if(!scm::checkRevision($version)) return array(); $api = "commits"; - /* TODO Put getCommits into cron job. And check best size of $count. */ if(empty($count)) $count = 10; $params = array(); diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 0c2e2b5dd7..2404362138 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -23,8 +23,7 @@ $lang->action->action = 'Action'; $lang->action->actionID = 'Action ID'; $lang->action->date = 'Date'; $lang->action->extra = 'Extra'; - -$lang->action->system = 'System'; +$lang->action->system = 'System'; $lang->action->trash = 'Recycle'; $lang->action->undelete = 'Restore'; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 4b02f6a749..0851e53781 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -23,8 +23,7 @@ $lang->action->action = '动作'; $lang->action->actionID = '记录ID'; $lang->action->date = '日期'; $lang->action->extra = '附加值'; - -$lang->action->system = '系统'; +$lang->action->system = '系统'; $lang->action->trash = '回收站'; $lang->action->undelete = '还原'; diff --git a/module/action/lang/zh-tw.php b/module/action/lang/zh-tw.php index 7c4f9a2d07..c587f8e284 100755 --- a/module/action/lang/zh-tw.php +++ b/module/action/lang/zh-tw.php @@ -23,8 +23,7 @@ $lang->action->action = '動作'; $lang->action->actionID = '記錄ID'; $lang->action->date = '日期'; $lang->action->extra = '附加值'; - -$lang->action->system = '系統'; +$lang->action->system = '系統'; $lang->action->trash = '資源回收筒'; $lang->action->undelete = '還原'; diff --git a/module/action/model.php b/module/action/model.php index f3fbe9325c..471854534c 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1006,7 +1006,8 @@ class actionModel extends model if($object->type == 'project') $objectProject[$object->id] = $object->id; } } - elseif($objectType == 'stakeholder'){ + elseif($objectType == 'stakeholder') + { $objectName = $this->dao->select("t1.id, t2.realname")->from($table)->alias('t1') ->leftJoin(TABLE_USER)->alias('t2')->on("t1.{$field} = t2.account") ->where('t1.id')->in($objectIds) @@ -1055,7 +1056,8 @@ class actionModel extends model $objectType = strtolower($action->objectType); $action->originalDate = $action->date; $action->date = date(DT_MONTHTIME2, strtotime($action->date)); - $action->actionLabel = isset($this->lang->action->label->$actionType) ? $this->lang->action->label->$actionType : (isset($this->lang->$objectType->$actionType) ? $this->lang->$objectType->$actionType : $action->action); + $action->actionLabel = isset($this->lang->$objectType->$actionType) ? $this->lang->$objectType->$actionType : $action->action; + $action->actionLabel = isset($this->lang->action->label->$actionType) ? $this->lang->action->label->$actionType : $action->actionLabel; $action->objectLabel = $objectType; if(isset($this->lang->action->label->$objectType)) { @@ -1108,25 +1110,24 @@ class actionModel extends model $method = $this->config->action->assetViewMethod[$action->objectType]; } - $action->objectLink = helper::createLink('assetlib', $method, sprintf($vars, $action->objectID), '', '', $projectID); + $action->objectLink = helper::createLink('assetlib', $method, sprintf($vars, $action->objectID)); } else { if($action->objectType == 'doclib') { $docLib = $this->dao->select('type,product,project,execution,deleted')->from(TABLE_DOCLIB)->where('id')->eq($action->objectID)->fetch(); - $docLib->type = $docLib->type == 'execution' ? 'project' : $docLib->type; - $docLib->objectID = strpos('product,project', $docLib->type) !== false ? $docLib->{$docLib->type} : 0; + $docLib->objectID = strpos('product,project,execution', $docLib->type) !== false ? $docLib->{$docLib->type} : 0; $appendLib = $docLib->deleted == '1' ? $action->objectID : 0; $action->objectLink = helper::createLink('doc', 'objectLibs', sprintf($vars, $docLib->type, $docLib->objectID, $action->objectID, $appendLib)); } elseif($action->objectType == 'user') { - $action->objectLink = !isset($deptUsers[$action->objectID]) ? 'javascript:void(0)' : helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID), '', '', $projectID); + $action->objectLink = !isset($deptUsers[$action->objectID]) ? 'javascript:void(0)' : helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID)); } else { - $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID), '', '', $projectID); + $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID)); } } $action->objectLabel = $objectLabel; diff --git a/module/bug/model.php b/module/bug/model.php index 4cef62c809..ee0a994d51 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -285,7 +285,7 @@ class bugModel extends model public function createBugFromGitlabIssue($bug, $executionID) { $bug->openedBy = $this->app->user->account; - $bug->openedDate = helper::now(); // TODO(dingguodong) use from issue->created_at ? + $bug->openedDate = helper::now(); $bug->assignedDate = isset($bug->assignedTo) ? helper::now() : 0; $bug->openedBuild = 'trunk'; $bug->story = 0; @@ -1817,7 +1817,7 @@ class bugModel extends model $bugSteps .= $this->lang->bug->tplResult; $bugSteps .= $this->lang->bug->tplExpect; } - + if(!empty($run->task)) $testtask = $this->loadModel('testtask')->getById($run->task); $executionID = isset($testtask->execution) ? $testtask->execution : 0; diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 36be812a37..c8e1d76b5a 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -36,8 +36,8 @@ $lang->help = 'Help'; $lang->aboutZenTao = 'About'; $lang->profile = 'Profile'; $lang->changePassword = 'Password'; -$lang->unfoldMenu = 'Unfold Menu'; -$lang->collapseMenu = 'Collapse Menu'; +$lang->unfoldMenu = 'Unfold'; +$lang->collapseMenu = 'Collapse'; $lang->preference = 'Preference'; $lang->runInfo = "