mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-28 18:40:39 +00:00
124 lines
3.1 KiB
PHP
124 lines
3.1 KiB
PHP
<?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;
|
|
} /* }}} */
|
|
|
|
} /* }}} */
|