diff --git a/api/v1/entries/productplans.php b/api/v1/entries/productplans.php index f8313c1683..6fc0b0757e 100644 --- a/api/v1/entries/productplans.php +++ b/api/v1/entries/productplans.php @@ -24,7 +24,7 @@ class productplansEntry extends entry if(!$productID) return $this->sendError(400, 'No product id.'); $control = $this->loadController('productplan', 'browse'); - $control->browse($productID, $this->param('branch', 0), $this->param('status', 'all'), $this->param('order', 'begin_desc'), 0, $this->param('limit', 20), $this->param('page', 1)); + $control->browse($productID, $this->param('branch', 0), $this->param('status', 'all'), $this->param('query', 0), $this->param('order', 'begin_desc'), 0, $this->param('limit', 20), $this->param('page', 1)); /* Response */ $data = $this->getData(); diff --git a/framework/api/entry.class.php b/framework/api/entry.class.php index beadc3089a..5c89698e49 100644 --- a/framework/api/entry.class.php +++ b/framework/api/entry.class.php @@ -535,7 +535,7 @@ class baseEntry /* Format array. */ $value = array(); - if(is_array($object->$key)) + if(is_array($object->$key) or is_object($object->$key)) { foreach($object->$key as $v) $value[] = $this->cast($v, $type); } diff --git a/lib/scm/gitea.class.php b/lib/scm/gitea.class.php index b01638fa87..1585de2822 100644 --- a/lib/scm/gitea.class.php +++ b/lib/scm/gitea.class.php @@ -320,9 +320,8 @@ class gitea foreach($list as $node) if($node->path == $entry) $file = $node; - $commits = $this->getCommitsByPath($entry); - - if(!empty($commits)) $file->revision = zget($commits[0], 'id', ''); + $commits = $this->getCommitsByPath($entry, $revision, $revision); + if(!empty($commits)) $file->revision = zget($commits[0], 'sha', ''); $info->kind = (isset($file->type) and $file->type == 'tree') ? 'dir' : 'file'; } diff --git a/module/action/control.php b/module/action/control.php index 4be60a2303..6edd4aed0d 100755 --- a/module/action/control.php +++ b/module/action/control.php @@ -157,7 +157,7 @@ class action extends control $repeatObject = $this->dao->select('*')->from(TABLE_PRODUCT) ->where('id')->ne($oldAction->objectID) ->andWhere("(name = '{$product->name}' and program = {$programID})", true) - ->orWhere("code = '{$product->code}'") + ->beginIF($product->code)->orWhere("code = '{$product->code}'")->fi() ->markRight(1) ->andWhere('deleted')->eq('0') ->fetch(); @@ -182,13 +182,26 @@ class action extends control if($repeatObject) { - $result = preg_match('/_(\d+)$/', $repeatObject->name, $nameMatches); - $replaceName = $result ? preg_replace('/_(\d+)$/', '_' . ($nameMatches[1] + 1), $repeatObject->name) : $repeatObject->name . '_1'; - $result = preg_match('/_(\d+)$/', $repeatObject->code, $codeMatches); - $replaceCode = $result ? preg_replace('/_(\d+)$/', '_' . ($codeMatches[1] + 1), $repeatObject->code) : $repeatObject->code . '_1'; - $table = $oldAction->objectType == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; $object = $oldAction->objectType == 'product' ? $product : $project; + + $existNames = $this->dao->select('name')->from($table)->where('name')->like($repeatObject->name . '_%')->fetchPairs(); + for($i = 1; $i < 10000; $i ++) + { + $replaceName = $repeatObject->name . '_' . $i; + if(!in_array($replaceName, $existNames)) break; + } + $replaceCode = ''; + if($object->code) + { + $existCodes = $this->dao->select('code')->from($table)->where('code')->like($repeatObject->code . '_%')->fetchPairs(); + for($i = 1; $i < 10000; $i ++) + { + $replaceCode = $repeatObject->code . '_' . $i; + if(!in_array($replaceCode, $existCodes)) break; + } + } + if($repeatObject->name == $object->name and $repeatObject->code and $repeatObject->code == $object->code) { if($confirmChange == 'no') return print(js::confirm(sprintf($this->lang->action->repeatChange, $this->lang->{$oldAction->objectType}->common, $replaceName, $replaceCode), $this->createLink('action', 'undelete', "action={$actionID}&browseType={$browseType}&confirmChange=yes"))); diff --git a/module/action/model.php b/module/action/model.php index 8aec1a5db1..5e203ed3de 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1000,13 +1000,15 @@ class actionModel extends model elseif($productID == 'all' and is_numeric($projectID)) { $products = $this->loadModel('product')->getProductPairsByProject($projectID); - $executions = $this->loadModel('execution')->getPairs($projectID) + array(0 => 0); + $executions = $this->loadModel('execution')->getPairs($projectID); + + $authedExecutions = isset($authedExecutions) ? array_intersect(array_keys($executions), explode(',', $authedExecutions)) : array_keys($executions); $productCondition = ''; foreach(array_keys($products) as $product) $productCondition = empty($productCondition) ? "product LIKE '%,$product,%'" : "$productCondition OR product LIKE '%,$product,%'"; $projectCondition = "project = $projectID"; - $executionCondition = "execution " . helper::dbIN(array_keys($executions)); + $executionCondition = "execution " . helper::dbIN($authedExecutions); } elseif(is_numeric($productID) and $projectID == 'all') { @@ -1014,15 +1016,18 @@ class actionModel extends model $projects = $this->product->getProjectPairsByProduct($productID); $executions = $this->product->getExecutionPairsByProduct($productID); - $productCondition = "product = $productID"; - $projectCondition = "project " . helper::dbIN(array_keys($projects)); - $executionCondition = "execution " . helper::dbIN(array_keys($executions)); + $authedProjects = array_intersect(array_keys($projects), explode(',', $authedProjects)); + $authedExecutions = isset($authedExecutions) ? array_intersect(array_keys($executions), explode(',', $authedExecutions)) : array_keys($executions); + + $productCondition = "product like '%,$productID,%'"; + $projectCondition = 'project ' . helper::dbIN($authedProjects); + $executionCondition = 'execution ' . helper::dbIN($authedExecutions); } - $condition = "((product =',0,' or product = '0') AND project = '0' AND execution = '0')"; - if(!empty($productCondition)) $condition .= ' OR ' . $productCondition; - if(!empty($projectCondition)) $condition .= ' OR ' . $projectCondition; - if(!empty($executionCondition)) $condition .= ' OR ' . $executionCondition; + $condition = "((product =',0,' or product = '0' or product=',,') AND project = '0' AND execution = '0')"; + if(!empty($productCondition)) $condition .= " OR $productCondition"; + if(!empty($projectCondition)) $condition .= " OR $projectCondition"; + if(!empty($executionCondition)) $condition .= " OR $executionCondition"; } $actionCondition = $this->getActionCondition(); @@ -1092,7 +1097,8 @@ class actionModel extends model foreach($this->app->user->rights['acls']['actions'] as $moduleName => $actions) { if(isset($this->lang->mainNav->$moduleName) and !empty($this->app->user->rights['acls']['views']) and !isset($this->app->user->rights['acls']['views'][$moduleName])) continue; - $actionCondition .= "(`objectType` = '$moduleName' and `action` " . helper::dbIN($actions) . ") or "; + $canViewPrograms = $moduleName == 'program' ? "`objectID` in ({$this->app->user->view->programs}) and " : ''; + $actionCondition .= "($canViewPrograms `objectType` = '$moduleName' and `action` " . helper::dbIN($actions) . ") or "; } $actionCondition = trim($actionCondition, 'or '); } @@ -1214,8 +1220,17 @@ class actionModel extends model $relatedProjects = $relatedData['relatedProjects']; $requirements = $relatedData['requirements']; + $aclViews = isset($this->app->user->rights['acls']['views']) ? $this->app->user->rights['acls']['views'] : array(); + $authedProjects = (empty($aclViews) or (!empty($aclViews) and !empty($aclViews['project']))) ? ",{$this->app->user->view->projects}," : array(); + $authedExecutions = (empty($aclViews) or (!empty($aclViews) and !empty($aclViews['execution']))) ? ",{$this->app->user->view->sprints},": array(); + foreach($actions as $i => $action) { + if(($action->execution != '0' and strpos($authedExecutions, ",$action->execution,") === false) or ($action->execution == '0' and $action->project != '0' and strpos($authedProjects, ",$action->project,") === false)) + { + unset($actions[$i]); + continue; + } /* Add name field to the actions. */ $action->objectName = isset($objectNames[$action->objectType][$action->objectID]) ? $objectNames[$action->objectType][$action->objectID] : ''; diff --git a/module/api/control.php b/module/api/control.php index 2601e6e871..a854a71abc 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -353,7 +353,7 @@ class api extends control $this->view->type = $type; $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->users = $this->user->getPairs('nocode'); + $this->view->users = $this->user->getPairs('nocode|noclosed'); $this->display(); } @@ -388,7 +388,7 @@ class api extends control $this->view->doc = $doc; $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->users = $this->user->getPairs('nocode'); + $this->view->users = $this->user->getPairs('nocode|noclosed'); $this->display(); } @@ -636,7 +636,7 @@ class api extends control if(intval($libID) > 0 and common::hasPriv('api', 'create')) { $menu .= "