* Merge code.

This commit is contained in:
sunguangming
2024-08-09 17:24:36 +08:00
committed by 王怡栋
parent ffbdb1e5a6
commit c0644bc7f1
10 changed files with 132 additions and 8 deletions
+7 -6
View File
@@ -1181,12 +1181,13 @@ class doc extends control
$this->docZen->setAclForCreateLib(is_numeric($targetSpace) ? 'custom' : 'mine');
$this->view->title = $this->lang->doc->moveLibAction;
$this->view->spaces = $this->docZen->getAllSpaces();
$this->view->lib = $lib;
$this->view->targetSpace = $targetSpace;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs('nocode|noclosed');
$this->view->title = $this->lang->doc->moveLibAction;
$this->view->spaces = $this->docZen->getAllSpaces();
$this->view->lib = $lib;
$this->view->targetSpace = $targetSpace;
$this->view->hasOthersDoc = $this->doc->hasOthersDoc($lib);
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs('nocode|noclosed');
$this->display();
}
+15
View File
@@ -12,3 +12,18 @@ window.toggleLibAcl = function(e)
$this = $(e.target);
$this.closest('form').find('#whiteListBox').toggleClass('hidden', $(e.target).val() != 'private');
};
window.clickSubmit = function(e)
{
zui.Modal.confirm({message: errorOthersCreated}).then((res) =>
{
if(res)
{
const formUrl = $('form').attr('action');
const formData = new FormData($("form")[0]);
$.ajaxSubmit({url: formUrl, data: formData});
}
});
return false;
}
+1
View File
@@ -357,6 +357,7 @@ $lang->doc->confirmUpdateContent = 'You have a document that is not saved from l
$lang->doc->selectLibType = 'Please select a type of doc library.';
$lang->doc->noLibreOffice = 'You does not have access to office conversion settings!';
$lang->doc->errorParentChapter = 'The parent chapter cannot be its own chapter or sub chapter!';
$lang->doc->errorOthersCreated = 'There are documents created by others in this library. You cannot move it.';
$lang->doc->noticeAcl['lib']['product']['default'] = "Users who can access the selected {$lang->productCommon} can access it.";
$lang->doc->noticeAcl['lib']['product']['custom'] = "Users who can access the selected {$lang->productCommon} or users in the whiltelist can access it.";
+1
View File
@@ -357,6 +357,7 @@ $lang->doc->confirmUpdateContent = 'You have a document that is not saved from l
$lang->doc->selectLibType = 'Please select a type of doc library.';
$lang->doc->noLibreOffice = 'You does not have access to office conversion settings!';
$lang->doc->errorParentChapter = 'The parent chapter cannot be its own chapter or sub chapter!';
$lang->doc->errorOthersCreated = 'There are documents created by others in this library. You cannot move it.';
$lang->doc->noticeAcl['lib']['product']['default'] = "Users who can access the selected {$lang->productCommon} can access it.";
$lang->doc->noticeAcl['lib']['product']['custom'] = "Users who can access the selected {$lang->productCommon} or users in the whiltelist can access it.";
+1
View File
@@ -357,6 +357,7 @@ $lang->doc->confirmUpdateContent = 'You have a document that is not saved from l
$lang->doc->selectLibType = 'Please select a type of doc library.';
$lang->doc->noLibreOffice = 'You does not have access to office conversion settings!';
$lang->doc->errorParentChapter = 'The parent chapter cannot be its own chapter or sub chapter!';
$lang->doc->errorOthersCreated = 'There are documents created by others in this library. You cannot move it.';
$lang->doc->noticeAcl['lib']['product']['default'] = "Users who can access the selected {$lang->productCommon} can access it.";
$lang->doc->noticeAcl['lib']['product']['custom'] = "Users who can access the selected {$lang->productCommon} or users in the whiltelist can access it.";
+1
View File
@@ -357,6 +357,7 @@ $lang->doc->confirmUpdateContent = '检查到您有未保存的文档内容,
$lang->doc->selectLibType = '请选择文档库类型';
$lang->doc->noLibreOffice = '您还没有office转换设置访问权限!';
$lang->doc->errorParentChapter = '父章节不能是自身章节及子章节!';
$lang->doc->errorOthersCreated = '该库下其他人创建的文档暂不支持移动,是否确认移动?';
$lang->doc->noticeAcl['lib']['product']['default'] = "有所选{$lang->productCommon}访问权限的用户可以访问。";
$lang->doc->noticeAcl['lib']['product']['custom'] = "有所选{$lang->productCommon}访问权限或白名单里的用户可以访问。";
+99 -2
View File
@@ -2432,6 +2432,7 @@ class docModel extends model
$item->main = zget($lib, 'main', 0);
$item->objectType = $type;
$item->objectID = $objectID;
$item->addedBy = $lib->addedBy;
$item->active = $lib->id == $libID && $browseType != 'bysearch' ? 1 : 0;
$item->children = $this->getModuleTree($lib->id, $moduleID, $lib->type == 'api' ? 'api' : 'doc', 0, $releaseModule, $docID);
@@ -3002,8 +3003,9 @@ class docModel extends model
}
elseif($data->space == 'mine')
{
$data->type = 'mine';
$data->parent = 0;
$data->type = 'mine';
$data->parent = 0;
$data->addedBy = $this->app->user->account;
}
else
{
@@ -3019,6 +3021,101 @@ class docModel extends model
$actionID = $this->loadModel('action')->create('docLib', $libID, 'Moved', '', json_encode(array('from' => $lib->type == 'mine' ? 'mine' : $lib->parent, 'to' => $data->type == 'mine' ? 'mine' : $data->parent)));
$this->action->logHistory($actionID, $changes);
/* 从团队空间移动到我的空间,需要保留其他人创建的文档在团队空间。 */
if($data->type == 'mine') $this->reserveOthersDoc($lib);
return true;
}
/**
* 迁移文档库时保留其他人创建的文档。
* Reserve other people's documents when migrating document libraries.
*
* @param object $lib
* @access public
* @return void
*/
public function reserveOthersDoc(object $lib)
{
$othersDocList = $this->dao->select('id, module')->from(TABLE_DOC)
->where('lib')->eq($lib->id)
->andWhere('addedBy')->ne($this->app->user->account)
->andWhere('deleted')->eq('0')
->fetchPairs();
if($othersDocList)
{
unset($lib->id);
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
$newLibID = $this->dao->lastInsertID();
$this->dao->update(TABLE_DOC)->set('lib')->eq($newLibID)->where('id')->in(array_keys($othersDocList))->exec();
$modulePairs = $this->dao->select('id, path')->from(TABLE_MODULE)->where('id')->in($othersDocList)->andWhere('deleted')->eq('0')->fetchPairs();
$moduleIdList = array();
foreach($modulePairs as $path)
{
$paths = explode(',', trim($path, ','));
foreach($paths as $id)
{
if($id > 0) $moduleIdList[$id] = $id;
}
}
$mapList = array();
$idMap = array();
$modules = $this->dao->select('*')->from(TABLE_MODULE)->where('id')->in($moduleIdList)->andWhere('deleted')->eq('0')->fetchAll('id');
foreach($modules as $module)
{
$oldID = $module->id;
unset($module->id);
$module->root = $newLibID;
$this->dao->insert(TABLE_MODULE)->data($module)->exec();
$newID = $this->dao->lastInsertID();
$module->id = $newID;
$mapList[] = $module;
$idMap[$oldID] = $newID;
$this->dao->update(TABLE_DOC)->set('module')->eq($newID)->where('module')->eq($oldID)->andWhere('lib')->eq($newLibID)->exec();
}
foreach($mapList as $module)
{
$parent = $module->parent ? $idMap[$module->parent] : 0;
$paths = explode(',', trim($module->path, ','));
foreach($paths as $key => $path)
{
if($path) $paths[$key] = $idMap[$path];
}
$path = implode(',', $paths);
$this->dao->update(TABLE_MODULE)->set('parent')->eq($parent)->set('path')->eq($path)->where('id')->eq($module->id)->exec();
}
}
}
/**
* 判断文档库下是否有其他人创建的文档。
* Check if there are other documents created under the document library.
*
* @param object $lib
* @access public
* @return bool
*/
public function hasOthersDoc(object $lib): bool
{
if($lib->type != 'custom') return false;
$docID = $this->dao->select('id')->from(TABLE_DOC)
->where('vision')->eq($this->config->vision)
->andWhere('templateType')->eq('')
->andWhere('deleted')->eq(0)
->andWhere('lib')->eq($lib->id)
->andWhere('addedBy')->ne($this->app->user->account)
->fetch('id');
return !empty($docID);
}
}
+2
View File
@@ -21,9 +21,11 @@ if($libType == 'custom' && ($lib->type == 'mine' || $lib->parent != $targetSpace
jsVar('targetSpace', $targetSpace);
jsVar('libID', $lib->id);
jsVar('errorOthersCreated', $lang->doc->errorOthersCreated);
formPanel
(
on::change('[name=space]', 'changeSpace'),
$hasOthersDoc ? set::ajax(array('beforeSubmit' => jsRaw("clickSubmit"))) : null,
formGroup
(
set::width('5/6'),
+1
View File
@@ -92,6 +92,7 @@ div
zui::kanbanList
(
set::key('kanban'),
set('$replace', false),
set::items($kanbanList),
set::height('calc(100vh - 120px)')
)
+4
View File
@@ -1778,6 +1778,10 @@ class storyModel extends model
$story->parent = $parentID;
$this->doChangeParent($story->id, $story, $oldStory);
if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent, false);
if($story->parent > 0) $this->updateParentStatus($storyID, $story->parent, false);
$this->setStage($story->id);
}