From 960d5bc43ce53d03888b59252e40dcfa4087e918 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 19 Dec 2016 14:18:50 +0100 Subject: [PATCH] add new method createDownloadLink() --- SeedDMS_Core/Core/inc.ClassDocument.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index b7fd88c0d..ff61ec81c 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -5556,6 +5556,25 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return $needwkflaction; } /* }}} */ + /** + * Create a new download link + * + * @param SeedDMS_Core_User $user + * @param string $expirationdate + * @return boolean true if link could be created, otherwise false + */ + function createDownloadLink($user, $expirationdate) { /* {{{ */ + $db = $this->_document->_dms->getDB(); + $hash = md5(uniqid()); + $queryStr = "INSERT INTO tblDownloadLinks (document, version, userID, hash) VALUES (".$this->_document->getID().", ".$this->_version.", ".$user->getID().", '".$hash."')"; + if (!$db->getResult($queryStr)) { + return false; + } + $id = $db->getInsertID(); + + return SeedDMS_Core_DownloadLink::getInstance($id, $this->_document->_dms); + } /* }}} */ + } /* }}} */