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.
*
+1 -1
View File
@@ -45,5 +45,5 @@ $(function()
function deleteFile(fileID)
{
if(!fileID) return;
hiddenwin.location.href =createLink('file', 'delete', 'fileID=' + fileID);
hiddenwin.location.href =createLink('doc', 'deleteFile', 'docID=' + docID + '&fileID=' + fileID);
}
-2
View File
@@ -78,8 +78,6 @@ $lang->doc->editType = '编辑分类';
$lang->doc->deleteType = '删除分类';
$lang->doc->addType = '增加分类';
$lang->doc->childType = '子分类';
$lang->doc->editType = '维护分类';
$lang->doc->deleteType = '删除分类';
$lang->doc->collect = '收藏';
$lang->doc->cancelCollection = '取消收藏';
$lang->doc->deleteFile = '删除附件';
+1
View File
@@ -71,6 +71,7 @@ class docModel extends model
{
$allLibGroups = $this->getAllLibGroups($libID);
$currentGroups = $allLibGroups[$type];
/* Append closed project. */
if(!isset($currentGroups[$currentLib]) and $type == 'project')
{
$project = $this->dao->select('id,name,status')->from(TABLE_PROJECT)->where('id')->eq($currentLib)->fetch();
+3 -2
View File
@@ -18,6 +18,7 @@
js::set('fullscreen', $lang->doc->fullscreen);
js::set('retrack', $lang->doc->retrack);
js::set('sysurl', common::getSysUrl());
js::set('docID', $doc->id);
?>
<div id="mainMenu" class="clearfix">
<div class="btn-toolbar pull-left">
@@ -34,12 +35,12 @@ js::set('sysurl', common::getSysUrl());
$i = 1;
foreach($actions as $action)
{
if($action->action == 'created')
if($action->action == 'created' or $action->action == 'deletedfile' or $action->action == 'commented')
{
$versions[$i] = "#$i " . zget($users, $action->actor) . ' ' . substr($action->date, 2, 14);
$i++;
}
if($action->action == 'edited')
elseif($action->action == 'edited')
{
foreach($action->history as $history)
{