add new method createDownloadLink()

This commit is contained in:
Uwe Steinmann 2016-12-19 14:18:50 +01:00
parent 93c67753d6
commit 960d5bc43c

View File

@ -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);
} /* }}} */
} /* }}} */