*[misc] add method.

This commit is contained in:
songchenxuan
2024-10-16 08:37:36 +08:00
committed by sunhao
parent 7908bb3d8b
commit 943d026f10
4 changed files with 60 additions and 15 deletions
+1 -1
View File
@@ -807,7 +807,7 @@ class doc extends control
* 产品/项目/执行/团队空间。
* ProductSpace/ProjectSpace/ExecutionSpace/TeamSpace.
*
* @param string $type custom|product|project|execution
* @param string $type custom|product|project|execution|doctemplate
* @param int $objectID
* @param int $libID
* @param int $moduleID
+21 -14
View File
@@ -965,20 +965,25 @@ class docModel extends model
{
if(common::isTutorialMode()) return $this->loadModel('tutorial')->getSubSpaces('custom');
$objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)
->where('type')->eq('custom')
->andWhere('deleted')->eq(0)
->andWhere('parent')->eq(0)
->andWhere('vision')->eq($this->config->vision)
->fetchAll();
return $this->getSpacePairs('custom');
}
$pairs = array();
foreach($objectLibs as $lib)
{
if($this->checkPrivLib($lib)) $pairs[$lib->id] = $lib->name;
}
/**
* 获取团队空间下的空间。
* Get team spaces.
*
* @access public
* @return array
*/
public function getDocTemplateSpaces()
{
if(common::isTutorialMode()) return $this->loadModel('tutorial')->getTeamSpaces();
return $pairs;
return $this->getSpacePairs('doctemplate');
}
public function initDocTemplateSpaces()
{
}
/**
@@ -2299,12 +2304,14 @@ class docModel extends model
}
else
{
if($type == 'custom')
if($type == 'custom' || $type == 'doctemplate')
{
$spaces = $this->getTeamSpaces();
$spaces = $type == 'custom' ? $this->getTeamSpaces() : $this->getDocTemplateSpaces();
if(empty($objectID)) $objectID = (int)key($spaces);
if(!isset($spaces[$objectID])) $objectID = (int)key($spaces);
}
$libs = $this->getLibsByObject($type, $objectID, $appendLib);
if(($libID == 0 || !isset($libs[$libID])) && !empty($libs)) $libID = reset($libs)->id;
if(isset($libs[$libID])) $objectDropdown['text'] = zget($libs[$libID], 'name', '');
+26
View File
@@ -220,6 +220,32 @@ class docTao extends docModel
->fetchAll('id');
}
/**
* 获取空间。
* Get space pairs.
*
* @param string $type
* @access protected
* @return array
*/
protected function getSpacePairs(string $type): array
{
$objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)
->where('type')->eq($type)
->andWhere('deleted')->eq(0)
->andWhere('parent')->eq(0)
->andWhere('vision')->eq($this->config->vision)
->fetchAll();
$pairs = array();
foreach($objectLibs as $lib)
{
if($this->checkPrivLib($lib)) $pairs[$lib->id] = $lib->name;
}
return $pairs;
}
/**
* 更新文档。
* Update document.
+12
View File
@@ -2109,6 +2109,18 @@ class tutorialModel extends model
if($type == 'mine') return array(1 => 'Test My Space');
}
/**
* 获取新手模式团队空间。
* Get team spaces.
*
* @access public
* @return array
*/
public function getDocTemplateSpaces(): array
{
return array(1 => 'Doc Template Space');
}
/**
* 获取新手模式文档库。
* Get doc lib.