diff --git a/api/v1/entries/doclibs.php b/api/v1/entries/doclibs.php new file mode 100644 index 0000000000..6438a5abb2 --- /dev/null +++ b/api/v1/entries/doclibs.php @@ -0,0 +1,42 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class doclibsEntry extends Entry +{ + /** + * GET method. + * + * @access public + * @return void + */ + public function get() + { + $type = $this->param('type', 0); + $objectID = $this->param('objectID', 0); + + $libs = $this->loadModel('doc')->getLibs($type, $this->param('extra', ''), $this->param('appendLibs', ''), $objectID); + $result = array(); + foreach($libs as $libID => $libName) + { + $lib = new stdclass(); + $lib->id = $libID; + $lib->name = $libName; + $result[] = $lib; + } + + $lib = new stdclass(); + $lib->id = 'files'; + $lib->name = $this->lang->doclib->files; + $result[] = $lib; + + return $this->send(200, array('libs' => array_values($result))); + } +} diff --git a/api/v1/entries/docs.php b/api/v1/entries/docs.php new file mode 100644 index 0000000000..7eb899539e --- /dev/null +++ b/api/v1/entries/docs.php @@ -0,0 +1,38 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class docsEntry extends Entry +{ + /** + * GET method. + * + * @access public + * @return void + */ + public function get($libID = 0) + { + if(empty($libID)) $libID = $this->param('lib', 0); + if(empty($libID)) return $this->sendError(400, 'Need lib id.'); + + $docTree = $this->loadModel('doc')->getDocTree($libID); + + foreach($docTree as $i => $module) + { + if(empty($module->id)) + { + unset($docTree[$i]); + foreach($module->children as $doc) $docTree[] = $doc; + } + } + + return $this->send(200, array_values($docTree)); + } +} diff --git a/config/routes.php b/config/routes.php index 52acdeedc5..f0072833e6 100644 --- a/config/routes.php +++ b/config/routes.php @@ -97,6 +97,11 @@ $routes['/risks/:id'] = 'risk'; $routes['/departments'] = 'departments'; $routes['/departments/:id'] = 'department'; +$routes['/doclibs'] = 'doclibs'; +$routes['/doclibs/:id'] = 'docs'; +$routes['/docs'] = 'docs'; +$routes['/docs/:id'] = 'doc'; + $routes['/reports'] = 'reports'; $routes['/z/folders'] = 'zfolders'; diff --git a/module/bug/model.php b/module/bug/model.php index 87c7e7950d..22a539f85f 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1511,7 +1511,7 @@ class bugModel extends model ->beginIF(!empty($productID))->andWhere('product')->eq($productID)->fi() ->beginIF($type == 'unresolved')->andWhere('status')->eq('active')->fi() ->beginIF($type == 'noclosed')->andWhere('status')->ne('closed')->fi() - ->beginIF($type == 'assigntome')->andWhere('assignedTo')->eq($this->app->user->account)->fi() + ->beginIF($type == 'assignedtome')->andWhere('assignedTo')->eq($this->app->user->account)->fi() ->beginIF($type == 'openedbyme')->andWhere('openedBy')->eq($this->app->user->account)->fi() ->beginIF($build)->andWhere("CONCAT(',', openedBuild, ',') like '%,$build,%'")->fi() ->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi() diff --git a/module/common/view/kindeditor.html.php b/module/common/view/kindeditor.html.php index b155782660..19d2831692 100755 --- a/module/common/view/kindeditor.html.php +++ b/module/common/view/kindeditor.html.php @@ -52,7 +52,7 @@ $uid = uniqid(''); cssData: 'html,body {background: none}.article-content{overflow:visible}.article-content, .article-content table td, .article-content table th {line-height: 1.3846153846; font-size: 13px;}.article-content .table-auto {width: auto!important; max-width: 100%;}', placeholder: noticePasteImg);?>, placeholderStyle: {fontSize: '13px', color: '#888'}, - pasteImage: {postUrl: createLink('file', 'ajaxPasteImage', 'uid=' + kuid)}, + pasteImage: {postUrl: createLink('file', 'ajaxPasteImg', 'uid=' + kuid)}, syncAfterBlur: true, allowFileManager: false, spellcheck: false @@ -90,7 +90,7 @@ $uid = uniqid(''); { items: editorTool, placeholder: $editor.attr('placeholder') || options.placeholder || '', - pasteImage: {postUrl: createLink('file', 'ajaxPasteImage', 'uid=' + kuid), placeholder: $editor.attr('placeholder') || noticePasteImg);?>}, + pasteImage: {postUrl: createLink('file', 'ajaxPasteImg', 'uid=' + kuid), placeholder: $editor.attr('placeholder') || noticePasteImg);?>}, }); try diff --git a/module/doc/model.php b/module/doc/model.php index a49064b751..0e93e7039e 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -80,6 +80,7 @@ class docModel extends model ->where('deleted')->eq(0) ->beginIF($type)->andWhere('type')->eq($type)->fi() ->beginIF(!$type)->andWhere('type')->ne('api')->fi() + ->beginIF($objectID and strpos(',product,project,execution,', ",$type,"))->andWhere($type)->eq($objectID)->fi() ->orderBy('`order`, id desc')->query(); } @@ -88,7 +89,7 @@ class docModel extends model $executions = $this->loadModel('execution')->getPairs(); $libPairs = array(); - while ($lib = $stmt->fetch()) + while($lib = $stmt->fetch()) { if($lib->product != 0 and !isset($products[$lib->product])) continue; if($lib->execution != 0 and !isset($executions[$lib->execution])) continue; @@ -110,7 +111,7 @@ class docModel extends model if(!empty($appendLibs)) { $stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('id')->in($appendLibs)->orderBy('`order`, id desc')->query(); - while ($lib = $stmt->fetch()) + while($lib = $stmt->fetch()) { if(!isset($libPairs[$lib->id]) and $this->checkPrivLib($lib, $extra)) $libPairs[$lib->id] = $lib->name; } @@ -1623,10 +1624,7 @@ class docModel extends model static $docGroups; if(empty($docGroups)) { - $docs = $this->dao->select('*')->from(TABLE_DOC) - ->where('lib')->eq((int)$libID) - ->andWhere('deleted')->eq(0) - ->fetchAll(); + $docs = $this->dao->select('*')->from(TABLE_DOC)->where('lib')->eq((int)$libID)->andWhere('deleted')->eq(0)->fetchAll(); $docGroups = array(); foreach($docs as $doc) { diff --git a/module/file/control.php b/module/file/control.php index b36252c3c3..b25ccae783 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -333,7 +333,7 @@ class file extends control * @access public * @return void */ - public function ajaxPasteImage($uid = '') + public function ajaxPasteImg($uid = '') { if($_POST) die($this->file->pasteImage($this->post->editor, $uid)); }