mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
add scripts for modifying attachments
This commit is contained in:
parent
ecda021289
commit
795b6c52e2
68
controllers/class.EditDocumentFile.php
Normal file
68
controllers/class.EditDocumentFile.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of EditDocumentFile controller
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class which does the busines logic for editing a document
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_Controller_EditDocumentFile extends SeedDMS_Controller_Common {
|
||||||
|
|
||||||
|
public function run() {
|
||||||
|
$dms = $this->params['dms'];
|
||||||
|
$user = $this->params['user'];
|
||||||
|
$settings = $this->params['settings'];
|
||||||
|
$document = $this->params['document'];
|
||||||
|
$file = $this->params['file'];
|
||||||
|
|
||||||
|
if(false === $this->callHook('preEditDocumentFile')) {
|
||||||
|
if(empty($this->errormsg))
|
||||||
|
$this->errormsg = 'hook_preEditDocumentFile_failed';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->callHook('editDocumentFile', $document);
|
||||||
|
if($result === null) {
|
||||||
|
$name = $this->params['name'];
|
||||||
|
$oldname = $file->getName();
|
||||||
|
if($oldname != $name)
|
||||||
|
if(!$file->setName($name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$comment = $this->params['comment'];
|
||||||
|
if(($oldcomment = $file->getComment()) != $comment)
|
||||||
|
if(!$file->setComment($comment))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$version = $this->params["version"];
|
||||||
|
$oldversion = $file->getVersion();
|
||||||
|
if ($oldversion != $version)
|
||||||
|
if(!$file->setVersion($version))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$public = $this->params["public"];
|
||||||
|
$file->setPublic($public == 'true' ? 1 : 0);
|
||||||
|
|
||||||
|
if(!$this->callHook('postEditDocumentFile')) {
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
82
op/op.EditDocumentFile.php
Normal file
82
op/op.EditDocumentFile.php
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?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-2016 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.LogInit.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.ClassController.php");
|
||||||
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
$controller = Controller::factory($tmp[1]);
|
||||||
|
|
||||||
|
/* Check if the form data comes from a trusted request */
|
||||||
|
if(!checkFormKey('editdocumentfile')) {
|
||||||
|
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 (!isset($_POST["fileid"]) || !is_numeric($_POST["fileid"]) || intval($_POST["fileid"])<1) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_file_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $document->getDocumentFile($_POST["fileid"]);
|
||||||
|
|
||||||
|
if (!is_object($file)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_file_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($document->getAccessMode($user) < M_ALL)&&($user->getID()!=$file->getUserID())) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$controller->setParam('document', $document);
|
||||||
|
$controller->setParam('file', $file);
|
||||||
|
$controller->setParam('name', isset($_POST['name']) ? $_POST['name'] : '');
|
||||||
|
$controller->setParam('comment', isset($_POST['comment']) ? $_POST['comment'] : '');
|
||||||
|
$controller->setParam('version', isset($_POST['version']) ? $_POST['version'] : '');
|
||||||
|
$controller->setParam('public', isset($_POST['public']) ? $_POST['public'] : '');
|
||||||
|
if(!$controller->run()) {
|
||||||
|
if($controller->getErrorNo()) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $controller->getErrorMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add_log_line("?documentid=".$documentid);
|
||||||
|
|
||||||
|
header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=attachments");
|
||||||
|
|
||||||
|
|
71
out/out.EditDocumentFile.php
Normal file
71
out/out.EditDocumentFile.php
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
// MyDMS. Document Management System
|
||||||
|
// Copyright (C) 2010 Matteo Lucarelli
|
||||||
|
// Copyright (C) 2010-2016 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.LogInit.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");
|
||||||
|
|
||||||
|
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 (!isset($_GET["fileid"]) || !is_numeric($_GET["fileid"]) || intval($_GET["fileid"])<1) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_file_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $document->getDocumentFile($_GET["fileid"]);
|
||||||
|
|
||||||
|
if (!is_object($file)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_file_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($document->getAccessMode($user) < M_ALL)&&($user->getID()!=$file->getUserID())) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$folder = $document->getFolder();
|
||||||
|
|
||||||
|
/* Create object for checking access to certain operations */
|
||||||
|
$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings);
|
||||||
|
|
||||||
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||||
|
if($view) {
|
||||||
|
$view->setParam('folder', $folder);
|
||||||
|
$view->setParam('document', $document);
|
||||||
|
$view->setParam('file', $file);
|
||||||
|
$view->setParam('accessobject', $accessop);
|
||||||
|
$view($_GET);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
92
views/bootstrap/class.EditDocumentFile.php
Normal file
92
views/bootstrap/class.EditDocumentFile.php
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of EditDocumentFile 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 EditDocumentFile 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_EditDocumentFile extends SeedDMS_Bootstrap_Style {
|
||||||
|
|
||||||
|
function show() { /* {{{ */
|
||||||
|
$dms = $this->params['dms'];
|
||||||
|
$user = $this->params['user'];
|
||||||
|
$folder = $this->params['folder'];
|
||||||
|
$document = $this->params['document'];
|
||||||
|
$file = $this->params['file'];
|
||||||
|
|
||||||
|
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||||
|
$this->globalNavigation($folder);
|
||||||
|
$this->contentStart();
|
||||||
|
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
|
||||||
|
$this->contentHeading(getMLText("edit"));
|
||||||
|
$this->contentContainerStart();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<form action="../op/op.EditDocumentFile.php" class="form-horizontal" name="form1" method="post">
|
||||||
|
<?php echo createHiddenFieldWithKey('editdocumentfile'); ?>
|
||||||
|
<input type="hidden" name="documentid" value="<?php echo $document->getID()?>">
|
||||||
|
<input type="hidden" name="fileid" value="<?php echo $file->getID()?>">
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label"><?php printMLText("version");?>:</label>
|
||||||
|
<div class="controls"><select name="version" id="version">
|
||||||
|
<option value=""><?= getMLText('document') ?></option>
|
||||||
|
<?php
|
||||||
|
$versions = $document->getContent();
|
||||||
|
foreach($versions as $version)
|
||||||
|
echo "<option value=\"".$version->getVersion()."\"".($version->getVersion() == $file->getVersion() ? " selected" : "").">".getMLText('version')." ".$version->getVersion()."</option>";
|
||||||
|
?>
|
||||||
|
</select></div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label"><?php printMLText("name");?>:</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input name="name" type="text" value="<?php print htmlspecialchars($file->getName());?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label"><?php printMLText("comment");?>:</label>
|
||||||
|
<div class="controls">
|
||||||
|
<textarea name="comment" rows="4" cols="80"><?php print htmlspecialchars($file->getComment());?></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label"><?php printMLText("document_link_public");?>:</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="checkbox" name="public" value="true"<?php echo ($file->isPublic() ? " checked" : "");?> />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="controls">
|
||||||
|
<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