Saturday 20 February 2010

KnowledgeTree and Versioning of documents uploaded by WebDAV

The advantage of KnowledgeTree is that it keeps versions of each document that you upload. Unfortunately, this does not seem to work in version 3.7.0.2, when uploading a new version of an existing file via WebDAV. The file is overwritten with the new version, but there is no version history.

There might be good reasons for that behaviour, which are explained in this issue?

Here is a solution that works for me, but of course, I do not know the interna of Knowledge Tree, therefore please use it at your own risk...

In file ktwebdav/lib/KTWebDAVServer.inc.php, find the lines:
// Modified - 25/10/07 - changed add to overwrite
// $oDocument =& KTDocumentUtil::add($oParentFolder, $name, $oUser, $aOptions);
$oDocument =& KTDocumentUtil::overwrite($oDocument, $name, $sTempFilename, $oUser, $aOptions);
It seems, with the add method a new file would be created, with a unique filename. So uploading a new version of test.txt would result in two files, test.txt would stay, and the new file would be test(1).txt. This is not really what you want.

To get real versioning, comment that line with "overwrite", and add these lines:
$aOptions['newfilename'] = $name;
$oDocument =& KTDocumentUtil::checkin($oDocument, $sTempFilename, 'WebDAV upload', $oUser, $aOptions);
This should do the trick. You will only have one file in your folder, and when you click on "Version History" in your webinterface, you will see the old versions and the current version. The file you download via WebDAV is always the latest version. This makes sense to me...

3 comments:

Plinio said...

Hi, this post was very useful for me. Can i translate your post and publish in my brazilian website (http://pliniopavin.com.br), about ECM and KnowledgeTree ?

Timotheus Pokorra said...

Hi Plinio, thanks for the comment. Yes, you are welcome to translate and publish on your website.

Unknown said...

Hello,

Thanks, your post was very helpful for me. Versioning now works ok via BitKinex, but I have 1 more question. Do you know how to automatically lock the document after download a file via webdav (function check out) ? Now, if someone download document via webdav knowledgetree save Action only as "View", but it should save Action as "Check out (it means lock)". Check in probably works ok, because knowledgetree save action after upload the same file via webdav as "Check in". My email: endabliu(at)gmail.com