diff --git a/module/doc/control.php b/module/doc/control.php index 89e44fa514..3241019627 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -1288,7 +1288,6 @@ class doc extends control $pager = new pager($recTotal, $recPerPage, $pageID); $this->app->rawMethod = $rawMethod; - $this->view->libID = $libID; if($libType == 'api') { $this->loadModel('api'); @@ -1306,12 +1305,16 @@ class doc extends control $this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $orderBy, $pager) : $this->doc->getDocs($libID, $moduleID, $orderBy, $pager); } + $apiObjectType = $type == 'product' || $type == 'project' ? $type : ''; + $apiObjectID = $apiObjectType ? $objectID : 0; + $this->view->title = $title; $this->view->type = $type; $this->view->browseType = $browseType; $this->view->param = $queryID; $this->view->users = $this->user->getPairs('noletter'); $this->view->libTree = $libTree; + $this->view->libID = $libID; $this->view->moduleID = $moduleID; $this->view->objectDropdown = $objectDropdown; $this->view->libType = $libType; @@ -1320,6 +1323,7 @@ class doc extends control $this->view->orderBy = $orderBy; $this->view->exportMethod = $type . '2export'; $this->view->canExport = common::hasPriv('doc', $type . '2export'); + $this->view->apiLibs = $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID); $this->display(); } diff --git a/module/doc/model.php b/module/doc/model.php index e74a8003d9..6dc40bc25b 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -39,17 +39,20 @@ class docModel extends model * Get api Libraries. * * @param int $appendLib + * @param string $appendLib + * @param int $objectID * @return array - * @author thanatos thanatos915@163.com */ - public function getApiLibs($appendLib = 0) + public function getApiLibs($appendLib = 0, $objectType = '', $objectID = 0) { $libs = $this->dao->select('*')->from(TABLE_DOCLIB) ->where('deleted')->eq(0) ->andWhere('type')->eq('api') ->beginIF(!empty($appendLib))->orWhere('id')->eq($appendLib)->fi() + ->beginIF(!empty($objectType))->andWhere($objectType)->eq($objectID)->fi() ->orderBy('`order`_asc, id_desc') ->fetchAll('id'); + $libs = array_filter($libs, array($this, 'checkPrivLib')); return $libs; } diff --git a/module/doc/view/doclist.html.php b/module/doc/view/doclist.html.php index faa592a799..e650454e39 100644 --- a/module/doc/view/doclist.html.php +++ b/module/doc/view/doclist.html.php @@ -27,7 +27,7 @@

doc->noDoc;?> "; $html .= "

'; diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index 252e6a811a..8789f41f4a 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -33,7 +33,7 @@ echo html::a(helper::createLink('doc', 'createLib', "type=$type&objectID=$objectID"), ' ' . $this->lang->doc->createLib, '', 'class="btn btn-secondary iframe"'); } - if(common::hasPriv('doc', 'create')) + if(common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs))) { if($libID) { @@ -42,22 +42,30 @@ $html .= ""; $html .= "';