* Add api priv and switch api doc release locate.

This commit is contained in:
caoyanyi
2023-04-07 09:30:02 +08:00
parent 4260e92cdd
commit ea55ca8c33
10 changed files with 88 additions and 19 deletions
+14 -4
View File
@@ -2787,9 +2787,9 @@ class docModel extends model
* @access public
* @return array
*/
public function getModuleTree($rootID, $moduleID = 0, $type = 'doc', $parent = 0, &$modules = array())
public function getModuleTree($rootID, $moduleID = 0, $type = 'doc', $parent = 0, $modules = array())
{
if(empty($modules))
if(is_array($modules) and empty($modules))
{
$modules = $this->dao->select('*')->from(TABLE_MODULE)
->where('root')->eq((int)$rootID)
@@ -2843,10 +2843,11 @@ class docModel extends model
* @param int $objectID
* @param int $executionID
* @param string $browseType bySearch
* @param int $param
* @access public
* @return array
*/
public function getLibTree($libID, $libs, $type, $moduleID, $objectID = 0, $browseType = '')
public function getLibTree($libID, $libs, $type, $moduleID, $objectID = 0, $browseType = '', $param = 0)
{
if($type == 'project')
{
@@ -2862,11 +2863,20 @@ class docModel extends model
->fetchPairs();
}
$release = null;
if($browseType == 'byrelease' and $param) $release = $this->loadModel('api')->getRelease(0, 'byId', $param);
$libTree = array($type => array());
$apiLibs = array();
$apiLibIDList = array();
foreach($libs as $lib)
{
$releaseModule = array();
if($release and $release->lib == $lib->id)
{
foreach($release->snap['modules'] as $module) $releaseModule[$module['id']] = (object)$module;
}
$item = new stdclass();
$item->id = $lib->id;
$item->type = $lib->type == 'api' ? 'api' : 'lib';
@@ -2874,7 +2884,7 @@ class docModel extends model
$item->objectType = $type;
$item->objectID = $objectID;
$item->active = $lib->id == $libID && $browseType != 'bySearch' ? 1 : 0;
$item->children = $this->getModuleTree($lib->id, $moduleID, $lib->type == 'api' ? 'api' : 'doc');
$item->children = $this->getModuleTree($lib->id, $moduleID, $lib->type == 'api' ? 'api' : 'doc', 0, $releaseModule);
$showDoc = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=doc&key=showDoc');
$showDoc = $showDoc === '0' ? 0 : 1;
if($this->app->rawMethod == 'view' and $lib->type != 'api' and $showDoc)