mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-12-17 09:33:13 +00:00
remove code for creating download links. It is now an extension
This commit is contained in:
parent
b608eff555
commit
64fca16d40
|
|
@ -1,183 +0,0 @@
|
|||
<?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['userID']);
|
||||
|
||||
$classname = $dms->getClassname('downloadlink');
|
||||
$downloadlink = new $classname($resArr["id"], $document, $resArr["version"], $user, $resArr["hash"], $resArr["valid"]);
|
||||
$downloadlink->setDMS($dms);
|
||||
return $downloadlink;
|
||||
} /* }}} */
|
||||
|
||||
private static function __getAllInstances($queryStr, $dms) { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$downloadlinks = array();
|
||||
foreach($resArr as $rec) {
|
||||
$document = $dms->getDocument($rec['document']);
|
||||
$user = $dms->getUser($rec['userID']);
|
||||
|
||||
$classname = $dms->getClassname('downloadlink');
|
||||
$downloadlink = new $classname($rec["id"], $document, $rec["version"], $user, $rec["hash"], $rec["valid"]);
|
||||
$downloadlink->setDMS($dms);
|
||||
$downloadlinks[] = $downloadlink;
|
||||
}
|
||||
return $downloadlinks;
|
||||
} /* }}} */
|
||||
|
||||
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);
|
||||
} /* }}} */
|
||||
|
||||
public static function getAllInstances($user, $version, $dms) { /* {{{ */
|
||||
$queryStr = "SELECT * FROM `tblDownloadLinks`";
|
||||
if($user || $version) {
|
||||
$queryStr .= " WHERE";
|
||||
if($user) {
|
||||
$queryStr .= " `userID` = " . (int) $user->getID();
|
||||
if($version) {
|
||||
$queryStr .= " AND `version` = " . (int) $version;
|
||||
}
|
||||
} else {
|
||||
$queryStr .= " `version` = " . (int) $version;
|
||||
}
|
||||
}
|
||||
return self::__getAllInstances($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;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return hash of document link
|
||||
*
|
||||
* @return string hash of link
|
||||
*/
|
||||
function getHash() { /* {{{ */
|
||||
return $this->_hash;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Remove a download link
|
||||
*
|
||||
* @return boolean true on success, otherwise false
|
||||
*/
|
||||
function remove() { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$queryStr = "DELETE FROM `tblDownloadLinks` WHERE `id` = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
} /* }}} */
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
// MyDMS. Document Management System
|
||||
// Copyright (C) 2002-2005 Markus Westphal
|
||||
// Copyright (C) 2006-2008 Malcolm Cowe
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
include("../inc/inc.Settings.php");
|
||||
include("../inc/inc.LogInit.php");
|
||||
include("../inc/inc.Language.php");
|
||||
include("../inc/inc.Init.php");
|
||||
include("../inc/inc.Extension.php");
|
||||
include("../inc/inc.DBInit.php");
|
||||
include("../inc/inc.ClassUI.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
|
||||
/* Check if the form data comes for a trusted request */
|
||||
if(!checkFormKey('createdownloadlink')) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
|
||||
}
|
||||
|
||||
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
$documentid = $_POST["documentid"];
|
||||
$document = $dms->getDocument($documentid);
|
||||
|
||||
if (!is_object($document)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
|
||||
if ($document->getAccessMode($user) < M_READ) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
if (!isset($_POST["version"]) || !is_numeric($_POST["version"]) || intval($_POST["version"])<1) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
$version_num = $_POST["version"];
|
||||
$version = $document->getContentByVersion($version_num);
|
||||
|
||||
if (!is_object($version)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
if (isset($_POST["expdate"]))
|
||||
$expiration = $_POST["expdate"];
|
||||
else
|
||||
$expiration = null;
|
||||
|
||||
if($version->createDownloadLink($user, $expiration)) {
|
||||
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_create_download_link')));
|
||||
} else {
|
||||
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_error_create_download+link')));
|
||||
}
|
||||
|
||||
add_log_line("?documentid=".$documentid."&version".$version_num);
|
||||
|
||||
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
|
||||
|
||||
?>
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
// MyDMS. Document Management System
|
||||
// Copyright (C) 2002-2005 Markus Westphal
|
||||
// Copyright (C) 2006-2008 Malcolm Cowe
|
||||
// Copyright (C) 2010 Matteo Lucarelli
|
||||
// Copyright (C) 2010-2015 Uwe Steinmann
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
include("../inc/inc.Settings.php");
|
||||
include("../inc/inc.Utils.php");
|
||||
include("../inc/inc.Language.php");
|
||||
include("../inc/inc.Init.php");
|
||||
include("../inc/inc.Extension.php");
|
||||
include("../inc/inc.DBInit.php");
|
||||
include("../inc/inc.ClassUI.php");
|
||||
include("../inc/inc.ClassAccessOperation.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
|
||||
if (!$accessop->check_view_access($view, $_GET)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => '')),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
$document = $dms->getDocument($_GET["documentid"]);
|
||||
|
||||
if (!is_object($document)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
|
||||
if ($document->getAccessMode($user) < M_ALL) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
if (!isset($_GET["version"]) || !is_numeric($_GET["version"]) || intval($_GET["version"]<1)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
$content = $document->getContentByVersion($_GET["version"]);
|
||||
if (!is_object($content)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
$folder = $document->getFolder();
|
||||
|
||||
if($view) {
|
||||
$view->setParam('folder', $folder);
|
||||
$view->setParam('document', $document);
|
||||
$view->setParam('version', $content);
|
||||
$view->setParam('accessobject', $accessop);
|
||||
$view($_GET);
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of CreateDownloadLink view
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
||||
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
||||
* 2010-2012 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include parent class
|
||||
*/
|
||||
require_once("class.Bootstrap.php");
|
||||
|
||||
/**
|
||||
* Class which outputs the html page for CreateDownloadLink view
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
||||
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
||||
* 2010-2012 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_View_CreateDownloadLink extends SeedDMS_Bootstrap_Style {
|
||||
|
||||
function show() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$folder = $this->params['folder'];
|
||||
$transmittals = $this->params['transmittals'];
|
||||
$content = $this->params['version'];
|
||||
|
||||
$document = $content->getDocument();
|
||||
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||
$this->globalNavigation();
|
||||
$this->contentStart();
|
||||
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
|
||||
$this->contentHeading(getMLText("create_download_link"));
|
||||
$this->contentContainerStart();
|
||||
|
||||
?>
|
||||
<form action="../op/op.CreateDownloadLink.php" name="form1" class="form-horizontal" method="post">
|
||||
<input type="hidden" name="documentid" value="<?php print $content->getDocument()->getID();?>">
|
||||
<input type="hidden" name="version" value="<?php print $content->getVersion();?>">
|
||||
<input type="hidden" name="action" value="createdownloadlink">
|
||||
<?php echo createHiddenFieldWithKey('createdownloadlink'); ?>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="login"><?php printMLText("expires");?>:</label>
|
||||
<div class="controls">
|
||||
<span class="input-append date span12" id="expirationdate" data-date="<?php echo $expdate; ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>" data-checkbox="#expires">
|
||||
<input class="span3" size="16" name="expdate" type="text" value="<?php echo $expdate; ?>">
|
||||
<span class="add-on"><i class="icon-calendar"></i></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn"><i class="icon-save"></i> <?php printMLText("save");?></button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<?php
|
||||
$this->contentContainerEnd();
|
||||
$this->contentEnd();
|
||||
$this->htmlEndPage();
|
||||
} /* }}} */
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user