diff --git a/module/doc/control.php b/module/doc/control.php
index e1c16906d9..19708b4cd9 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -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.
*
diff --git a/module/doc/js/view.js b/module/doc/js/view.js
index 2c353f2a50..34edfddc4f 100644
--- a/module/doc/js/view.js
+++ b/module/doc/js/view.js
@@ -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);
}
diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php
index 3b6b511d69..24f6e7741c 100644
--- a/module/doc/lang/zh-cn.php
+++ b/module/doc/lang/zh-cn.php
@@ -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 = '删除附件';
diff --git a/module/doc/model.php b/module/doc/model.php
index ad9d560288..e329e9b2e7 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -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();
diff --git a/module/doc/view/view.html.php b/module/doc/view/view.html.php
index 8f155c7506..0d1be15e9d 100644
--- a/module/doc/view/view.html.php
+++ b/module/doc/view/view.html.php
@@ -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);
?>
@@ -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)
{