This commit is contained in:
wangyidong
2020-01-02 08:52:11 +08:00
parent e8d6811056
commit 3e938c780f
5 changed files with 40 additions and 6 deletions
+35 -1
View File
@@ -100,7 +100,7 @@ class doc extends control
$productID = $lib->product;
$projectID = $lib->project;
if(($from == 'product' or $from == 'project') and $type != $from) $from = 'doc';
if($type != 'product' and $type != 'project') $from = 'doc';
}
$this->libs = $this->doc->getLibs($type, '', $libID);
@@ -507,6 +507,40 @@ class doc extends control
}
}
/**
* Delete file for doc.
*
* @param int $docID
* @param int $fileID
* @param string $confirm
* @access public
* @return void
*/
public function deleteFile($docID, $fileID, $confirm = 'no')
{
$this->loadModel('file');
if($confirm == 'no')
{
die(js::confirm($this->lang->file->confirmDelete, inlink('deleteFile', "docID=$docID&fileID=$fileID&confirm=yes")));
}
else
{
$docContent = $this->dao->select('t1.*')->from(TABLE_DOCCONTENT)->alias('t1')
->leftJoin(TABLE_DOC)->alias('t2')->on('t1.doc=t2.id and t1.version=t2.version')
->where('t2.id')->eq($docID)
->fetch();
unset($docContent->id);
$docContent->files = trim(str_replace(",{$fileID},", ',', ",{$docContent->files},"), ',');
$docContent->version += 1;
$this->dao->insert(TABLE_DOCCONTENT)->data($docContent)->exec();
$this->dao->update(TABLE_DOC)->set('version')->eq($docContent->version)->where('id')->eq($docID)->exec();
$file = $this->file->getById($fileID);
$this->loadModel('action')->create($file->objectType, $file->objectID, 'deletedFile', '', $extra=$file->title);
die(js::locate($this->createLink('doc', 'view', "docID=$docID"), 'parent'));
}
}
/**
* Collect doc, doclib or module of doclib.
*