mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-28 10:30:42 +00:00
download links can be created
This commit is contained in:
parent
244ae9066b
commit
4e8dc17b32
|
|
@ -344,6 +344,25 @@ class SeedDMS_AccessOperation {
|
|||
return false;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Check if download link to document version may be created
|
||||
*
|
||||
* Creating a download link to a document content is only allowed if the document was not
|
||||
* obsoleted. There may be other requirements which are not taken into
|
||||
* account here.
|
||||
*/
|
||||
function mayCreateDownloadLink($document) { /* {{{ */
|
||||
if(get_class($document) == $this->dms->getClassname('document')) {
|
||||
if($latestContent = $document->getLatestContent()) {
|
||||
$status = $latestContent->getStatus();
|
||||
if ($status["status"]!=S_OBSOLETE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Check for access permission on view
|
||||
*
|
||||
|
|
|
|||
70
op/op.CreateDownloadLink.php
Normal file
70
op/op.CreateDownloadLink.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?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"));
|
||||
}
|
||||
$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);
|
||||
|
||||
?>
|
||||
72
out/out.CreateDownloadLink.php
Normal file
72
out/out.CreateDownloadLink.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
?>
|
||||
76
views/bootstrap/class.CreateDownloadLink.php
Normal file
76
views/bootstrap/class.CreateDownloadLink.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?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();
|
||||
} /* }}} */
|
||||
}
|
||||
?>
|
||||
|
|
@ -647,6 +647,10 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
if($this->check_access('AddToTransmittal'))
|
||||
print "<li>".$this->html_link('AddToTransmittal', array('documentid'=>$documentid, 'version'=>$latestContent->getVersion()), array(), "<i class=\"icon-list\"></i>".getMLText("add_to_transmittal"), false, true)."</li>";
|
||||
}
|
||||
if($this->check_access('CreateDownloadLink'))
|
||||
if($accessop->mayCreateDownloadLink($document)) {
|
||||
print "<li>".$this->html_link('CreateDownloadLink', array('documentid'=>$documentid, 'version'=>$latestContent->getVersion()), array(), "<i class=\"icon-download-alt\"></i>".getMLText("create_download_link"), false, true)."</li>";
|
||||
}
|
||||
if($this->check_access('EditComment'))
|
||||
if($accessop->mayEditComment($document)) {
|
||||
print "<li>".$this->html_link('EditComment', array('documentid'=>$documentid, 'version'=>$latestContent->getVersion()), array(), "<i class=\"icon-comment\"></i>".getMLText("edit_comment"), false, true)."</li>";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user