diff --git a/db/zentaopms299.sql b/db/zentaopms299.sql index a4b9a1fff9..db0c070e55 100644 --- a/db/zentaopms299.sql +++ b/db/zentaopms299.sql @@ -2,6 +2,8 @@ UPDATE `zt_doc` SET `type` = 'text' WHERE `type` = 'url'; UPDATE `zt_doclib` SET `acl` = 'private' WHERE `type` = 'custom' and `acl` = 'custom'; UPDATE `zt_doclib` SET `acl` = 'private' WHERE `type` = 'product' AND `acl` = 'custom'; +UPDATE `zt_doclib` SET `acl` = 'private' WHERE `type` = 'project' AND `acl` = 'custom'; +UPDATE `zt_doclib` SET `acl` = 'default' WHERE `type` = 'project' AND `acl` IN ('open', 'private'); ALTER TABLE `zt_doclib` ADD `addedBy` varchar(30) NOT NULL AFTER `order`; ALTER TABLE `zt_doclib` ADD `addedDate` datetime NOT NULL AFTER `addedBy`; diff --git a/module/doc/control.php b/module/doc/control.php index 4b4e0ae781..7a343f2507 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -150,36 +150,38 @@ class doc extends control if(in_array($type, array('product', 'project'))) $this->app->loadLang('api'); - $objects = array(); + $objects = array(); + $executionPairs = array(0 => ''); if($type == 'product') $objects = $this->product->getPairs(); - if($type == 'project') $objects = $this->project->getPairsByProgram(); + if($type == 'project') + { + $objects = $this->project->getPairsByProgram(); + $executions = $this->execution->getList($objectID); + } if($type == 'execution') { - $objects = $this->execution->getList(); - $projects = $this->project->getPairsByProgram('', 'all', true); + $executions = $this->execution->getList(); + $projects = $this->project->getPairsByProgram('', 'all', true); } /* Splice project name. */ - if($type == 'object') + if(!empty($executions)) { - foreach($objects as $id => $object) + foreach($executions as $id => $execution) { - if($object->multiple) + if($execution->multiple) { - if($object->type == 'stage' and $object->grade > 1) + if($execution->type == 'stage' and $execution->grade > 1) { - $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($object->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); - $object->name = implode('/', $parentExecutions); + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($execution->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $execution->name = implode('/', $parentExecutions); } - $objectPrefix = isset($projects[$object->project]) ? $projects[$object->project] . '/' : ''; - $objects[$id] = $objectPrefix . $object->name; - } - else - { - unset($objects[$id]); + $executionPrefix = isset($projects[$execution->project]) ? $projects[$execution->project] . '/' : ''; + $executionPairs[$id] = $executionPrefix . $execution->name; } } + if($type == 'executions') $objects = $executionPairs; } if($type == 'execution') @@ -196,11 +198,12 @@ class doc extends control unset($this->lang->doclib->aclList['open']); } - $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->users = $this->user->getPairs('nocode|noclosed'); - $this->view->objects = $objects; - $this->view->type = $type; - $this->view->objectID = $objectID; + $this->view->groups = $this->loadModel('group')->getPairs(); + $this->view->users = $this->user->getPairs('nocode|noclosed'); + $this->view->objects = $objects; + $this->view->executionPairs = $executionPairs; + $this->view->type = $type; + $this->view->objectID = $objectID; $this->display(); } @@ -266,8 +269,10 @@ class doc extends control if($lib->type != 'custom') { $this->lang->doclib->aclList['default'] = sprintf($this->lang->doclib->aclList['default'], $this->lang->{$lib->type}->common); + $this->lang->doclib->aclList['private'] = sprintf($this->lang->doclib->privateACL, $this->lang->{$lib->type}->common); unset($this->lang->doclib->aclList['open']); } + $this->view->lib = $lib; $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->users = $this->user->getPairs('noletter|noclosed', $lib->users); @@ -1414,4 +1419,34 @@ class doc extends control $this->display(); } + + /** + * Ajax Get the execution drop down by the projectID. + * + * @param int $projectID + * @access public + * @return void + */ + public function ajaxGetExecution($projectID) + { + $executions = $this->execution->getList($projectID); + $executionPairs = array(0 => ''); + if(!empty($executions)) + { + foreach($executions as $id => $execution) + { + if($execution->multiple) + { + if($execution->type == 'stage' and $execution->grade > 1) + { + $parentExecutions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in(trim($execution->path, ','))->andWhere('type')->in('stage,kanban,sprint')->orderBy('grade')->fetchPairs(); + $execution->name = implode('/', $parentExecutions); + } + + $executionPairs[$id] = $execution->name; + } + } + } + return print(html::select('execution', $executionPairs, 0, "class='form-control' data-placeholder='{$this->lang->doclib->tip->selectExecution}'")); + } } diff --git a/module/doc/js/createlib.js b/module/doc/js/createlib.js new file mode 100644 index 0000000000..62a2889d3f --- /dev/null +++ b/module/doc/js/createlib.js @@ -0,0 +1,12 @@ +$('#project').change(function() +{ + $.get(createLink('doc', 'ajaxGetExecution', 'projectID=' + $(this).val()), function(data) + { + if(data) + { + $('#execution').replaceWith(data); + $('#execution_chosen').remove(); + $('#execution').chosen(); + } + }); +}); diff --git a/module/doc/lang/de.php b/module/doc/lang/de.php index 4ae10e1857..ebd368afc6 100644 --- a/module/doc/lang/de.php +++ b/module/doc/lang/de.php @@ -22,6 +22,9 @@ $lang->doclib->product = $lang->productCommon . ' Bibliothek'; $lang->doclib->apiLibName = 'Api Library Name'; $lang->doclib->privateACL = "Private (Only creators and whitelisted users with %s permissions can access it)"; +$lang->doclib->tip = new stdclass(); +$lang->doclib->tip->selectExecution = "When execution is empty, the library created is the {$lang->projectCommon} library"; + $lang->doclib->type['wiki'] = 'WIKI'; $lang->doclib->type['api'] = 'API'; diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 33b6c28a56..9823ad66df 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -22,6 +22,9 @@ $lang->doclib->product = $lang->productCommon . ' Library'; $lang->doclib->apiLibName = 'Api Library Name'; $lang->doclib->privateACL = "Private (Only creators and whitelisted users with %s permissions can access it)"; +$lang->doclib->tip = new stdclass(); +$lang->doclib->tip->selectExecution = "When execution is empty, the library created is the {$lang->projectCommon} library"; + $lang->doclib->type['wiki'] = 'WIKI'; $lang->doclib->type['api'] = 'API'; diff --git a/module/doc/lang/fr.php b/module/doc/lang/fr.php index 530f89bd34..f8b94ada04 100644 --- a/module/doc/lang/fr.php +++ b/module/doc/lang/fr.php @@ -22,6 +22,9 @@ $lang->doclib->product = $lang->productCommon . ' Library'; $lang->doclib->apiLibName = 'Api Library Name'; $lang->doclib->privateACL = "Private (Only creators and whitelisted users with %s permissions can access it)"; +$lang->doclib->tip = new stdclass(); +$lang->doclib->tip->selectExecution = "When execution is empty, the library created is the {$lang->projectCommon} library"; + $lang->doclib->type['wiki'] = 'WIKI'; $lang->doclib->type['api'] = 'API'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index 2c15ad3e62..971b13111f 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -22,6 +22,9 @@ $lang->doclib->product = $lang->productCommon . '库'; $lang->doclib->apiLibName = '接口库名称'; $lang->doclib->privateACL = "私有 (仅创建者和有%s权限的白名单用户可访问)"; +$lang->doclib->tip = new stdclass(); +$lang->doclib->tip->selectExecution = "执行为空时,创建的库为{$lang->projectCommon}库"; + $lang->doclib->type['wiki'] = 'WIKI文档库'; $lang->doclib->type['api'] = '接口库'; diff --git a/module/doc/model.php b/module/doc/model.php index a879ad0434..024e56eca1 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1118,7 +1118,7 @@ class docModel extends model } } - if($object->project and $object->acl == 'private') + if($object->type == 'project' and $object->acl == 'default') { $stakeHolders = array(); $project = $this->loadModel('project')->getById($object->project); @@ -1137,7 +1137,7 @@ class docModel extends model if(isset($extraDocLibs[$object->id])) return true; } - if($object->acl == 'default' and (!empty($object->product) or !empty($object->execution))) + if($object->acl == 'default' and (in_array($object->type, array('product', 'execution')))) { $acls = $this->app->user->rights['acls']; if(!empty($object->product) and !empty($acls['products']) and !in_array($object->product, $acls['products'])) return false; @@ -1464,7 +1464,7 @@ class docModel extends model ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->andWhere($type)->eq($objectID) - ->beginIF(!empty($executionIDList))->orWhere('execution')->in($executionIDList)->fi() + ->beginIF(!empty($executionIDList))->orWhere('execution')->in(array_keys($executionIDList))->fi() ->beginIF(!empty($appendLib))->orWhere('id')->eq($appendLib)->fi() ->orderBy('`order` asc, id_asc') ->fetchAll('id'); diff --git a/module/doc/view/createlib.html.php b/module/doc/view/createlib.html.php index 31b2b88bd9..f4fff15496 100644 --- a/module/doc/view/createlib.html.php +++ b/module/doc/view/createlib.html.php @@ -27,6 +27,12 @@