mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-12-24 05:48:29 +00:00
add new class SeedDMS_Core_DownloadLink
This commit is contained in:
parent
2155e5b09f
commit
bd53565ee3
|
|
@ -96,4 +96,9 @@ require_once('Core/inc.FileUtils.php');
|
|||
*/
|
||||
require_once('Core/inc.ClassTransmittal.php');
|
||||
|
||||
/**
|
||||
* @uses SeedDMS_DownloadLink
|
||||
*/
|
||||
require_once('Core/inc.ClassDownloadLink.php');
|
||||
|
||||
?>
|
||||
|
|
|
|||
123
SeedDMS_Core/Core/inc.ClassDownloadLink.php
Normal file
123
SeedDMS_Core/Core/inc.ClassDownloadLink.php
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of a document in the document management system
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS_Core
|
||||
* @license GPL2
|
||||
* @author Markus Westphal, Malcolm Cowe, Matteo Lucarelli,
|
||||
* Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal, 2006-2008 Malcolm Cowe,
|
||||
* 2010 Matteo Lucarelli, 2010 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to represent a download link in the document management system
|
||||
*
|
||||
* Download links are access rights to a particular document version.
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS_Core
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2016 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Core_DownloadLink { /* {{{ */
|
||||
/**
|
||||
* @var integer unique id of object
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* @var object document belonging to link
|
||||
*/
|
||||
protected $_document;
|
||||
|
||||
/**
|
||||
* @var integer version of document
|
||||
*/
|
||||
protected $_version;
|
||||
|
||||
/**
|
||||
* @var object user owning the document link
|
||||
*/
|
||||
protected $_user;
|
||||
|
||||
/**
|
||||
* @var string hash of document link
|
||||
*/
|
||||
protected $_hash;
|
||||
|
||||
/**
|
||||
* @var date date till links valid
|
||||
*/
|
||||
protected $_valid;
|
||||
|
||||
/**
|
||||
* @var object back reference to document management system
|
||||
*/
|
||||
public $_dms;
|
||||
|
||||
function __construct($id, $document, $version, $user, $hash, $valid) { /* {{{ */
|
||||
$this->_id = $id;
|
||||
$this->_dms = null;
|
||||
$this->_document = $document;
|
||||
$this->_version = $version;
|
||||
$this->_user = $user;
|
||||
$this->_hash = $hash;
|
||||
$this->_valid = $valid;
|
||||
} /* }}} */
|
||||
|
||||
private static function __getInstance($queryStr, $dms) { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
if (count($resArr) != 1)
|
||||
return false;
|
||||
$resArr = $resArr[0];
|
||||
|
||||
$document = $dms->getDocument($resArr['document']);
|
||||
$user = $dms->getUser($resArr['user']);
|
||||
|
||||
$classname = $dms->getClassname('downloadlink');
|
||||
$downloadlink = new $classname($resArr["id"], $document, $resArr["version"], $user, $resArr["hash"], $resArr["valid"]);
|
||||
$downloadlink->setDMS($dms);
|
||||
return $downloadlink;
|
||||
} /* }}} */
|
||||
|
||||
public static function getInstance($id, $dms) { /* {{{ */
|
||||
$queryStr = "SELECT * FROM tblDownloadLinks WHERE id = " . (int) $id;
|
||||
return self::__getInstance($queryStr, $dms);
|
||||
} /* }}} */
|
||||
|
||||
public static function getInstanceByHash($hash, $dms) { /* {{{ */
|
||||
$queryStr = "SELECT * FROM tblDownloadLinks WHERE hash = " . $db->qstr($hash);
|
||||
return self::__getInstance($queryStr, $dms);
|
||||
} /* }}} */
|
||||
|
||||
/*
|
||||
* Set dms this object belongs to.
|
||||
*
|
||||
* Each object needs a reference to the dms it belongs to. It will be
|
||||
* set when the object is created.
|
||||
* The dms has a references to the currently logged in user
|
||||
* and the database connection.
|
||||
*
|
||||
* @param object $dms reference to dms
|
||||
*/
|
||||
function setDMS($dms) { /* {{{ */
|
||||
$this->_dms = $dms;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return owner of document link
|
||||
*
|
||||
* @return object owner of document link as an instance of {@link SeedDMS_Core_User}
|
||||
*/
|
||||
function getUser() { /* {{{ */
|
||||
return $this->_user;
|
||||
} /* }}} */
|
||||
|
||||
} /* }}} */
|
||||
Loading…
Reference in New Issue
Block a user