mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-12 00:48:11 +00:00
perf: 共享的文件禁止移动到另一个共享文件夹内
This commit is contained in:
parent
529b4bec31
commit
092506e9ab
@ -363,6 +363,15 @@ class FileController extends AbstractController
|
||||
$file = File::permissionFind($id, 1000);
|
||||
//
|
||||
if ($pid > 0) {
|
||||
if ($toShareFile) {
|
||||
if ($file->share) {
|
||||
throw new ApiException("{$file->name} 当前正在共享,无法移动到另一个共享文件夹内");
|
||||
}
|
||||
if ($file->isSubShare()) {
|
||||
throw new ApiException("{$file->name} 内含有共享文件,无法移动到另一个共享文件夹内");
|
||||
}
|
||||
}
|
||||
//
|
||||
$tmpId = $pid;
|
||||
while ($tmpId > 0) {
|
||||
if ($id == $tmpId) {
|
||||
@ -370,11 +379,6 @@ class FileController extends AbstractController
|
||||
}
|
||||
$tmpId = intval(File::whereId($tmpId)->value('pid'));
|
||||
}
|
||||
if ($file->share && $toShareFile) {
|
||||
$file->share = 0;
|
||||
$file->save();
|
||||
FileUser::deleteFileAll($file->id, $file->userid);
|
||||
}
|
||||
}
|
||||
//
|
||||
$file->pid = $pid;
|
||||
@ -951,7 +955,7 @@ class FileController extends AbstractController
|
||||
// 设置共享
|
||||
$action = "update";
|
||||
if ($force === 0) {
|
||||
if (File::where("pids", "like", "%,{$file->id},%")->whereShare(1)->exists()) {
|
||||
if ($file->isSubShare()) {
|
||||
return Base::retError('此文件夹内已有共享文件夹', [], -3001);
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,6 +160,15 @@ class File extends AbstractModel
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录内是否存在共享文件或文件夹
|
||||
* @return bool
|
||||
*/
|
||||
public function isSubShare()
|
||||
{
|
||||
return $this->type == 'folder' && File::where("pids", "like", "%,{$this->id},%")->whereShare(1)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置/关闭 共享(同时遍历取消里面的共享)
|
||||
* @param $share
|
||||
|
||||
@ -1164,20 +1164,16 @@ export default {
|
||||
this.$refs.linkInput.focus({cursor:'all'});
|
||||
},
|
||||
|
||||
shearTo(force = false) {
|
||||
shearTo() {
|
||||
if (this.shearIds.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (force !== true
|
||||
&& this.isParentShare
|
||||
&& this.files.findIndex(({id, share}) => share && this.shearIds.includes(id)) > -1) {
|
||||
$A.modalConfirm({
|
||||
content: '剪切板含有共享文件,粘贴到共享文件夹中原共享属性将失效。',
|
||||
onOk: () => {
|
||||
this.shearTo(true)
|
||||
}
|
||||
});
|
||||
return;
|
||||
if (this.isParentShare) {
|
||||
const tmpFile = this.files.find(({id, share}) => share && this.shearIds.includes(id));
|
||||
if (tmpFile) {
|
||||
$A.modalError(`${tmpFile.name} 当前正在共享,无法移动到另一个共享文件夹内`)
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.$store.dispatch("call", {
|
||||
url: 'file/move',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user