From 9421d900776755d5f45b6240a64de7ef7335cdb0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 24 Jan 2024 11:57:53 +0100 Subject: [PATCH] add management of link types --- op/op.LinkTypes.php | 121 +++++++++++++++++++ out/out.LinkTypes.php | 60 +++++++++ views/bootstrap/class.LinkTypes.php | 181 ++++++++++++++++++++++++++++ 3 files changed, 362 insertions(+) create mode 100644 op/op.LinkTypes.php create mode 100644 out/out.LinkTypes.php create mode 100644 views/bootstrap/class.LinkTypes.php diff --git a/op/op.LinkTypes.php b/op/op.LinkTypes.php new file mode 100644 index 000000000..a1015892b --- /dev/null +++ b/op/op.LinkTypes.php @@ -0,0 +1,121 @@ +isAdmin()) { + UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); +} + +if (isset($_POST["action"])) $action=$_POST["action"]; +else $action=NULL; + +//Neue Kategorie anlegen ----------------------------------------------------------------------------- +if ($action == "addlinktype") { + + /* Check if the form data comes from a trusted request */ + if(!checkFormKey('addlinktype')) { + UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); + } + + $name = trim($_POST["name"]); + if($name == '') { + UI::exitError(getMLText("admin_tools"),getMLText("linktype_noname")); + } + if (is_object($dms->getDocumentCategoryByName($name))) { + UI::exitError(getMLText("admin_tools"),getMLText("linktype_exists")); + } + $newCategory = $dms->addLinkType($name); + if (!$newCategory) { + UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); + } + $linktypeid=$newCategory->getID(); + + $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_linktype'))); + add_log_line(".php&action=addlinktype&linktypeid=".$linktypeid); +} + +//Kategorie löschen ---------------------------------------------------------------------------------- +else if ($action == "removelinktype") { + + /* Check if the form data comes from a trusted request */ + if(!checkFormKey('removelinktype')) { + UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); + } + + if (!isset($_POST["linktypeid"]) || !is_numeric($_POST["linktypeid"]) || intval($_POST["linktypeid"])<1) { + UI::exitError(getMLText("admin_tools"),getMLText("unknown_document_linktype")); + } + $linktypeid = $_POST["linktypeid"]; + $linktype = $dms->getDocumentCategory($linktypeid); + if (!is_object($linktype)) { + UI::exitError(getMLText("admin_tools"),getMLText("unknown_document_linktype")); + } + + if (!$linktype->remove()) { + UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); + } + + $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_linktype'))); + add_log_line(".php&action=removelinktype&linktypeid=".$linktypeid); + $linktypeid=-1; +} + +//Kategorie bearbeiten: Neuer Name -------------------------------------------------------------------- +else if ($action == "editlinktype") { + + /* Check if the form data comes from a trusted request */ + if(!checkFormKey('editlinktype')) { + UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token")); + } + + if (!isset($_POST["linktypeid"]) || !is_numeric($_POST["linktypeid"]) || intval($_POST["linktypeid"])<1) { + UI::exitError(getMLText("admin_tools"),getMLText("unknown_document_linktype")); + } + $linktypeid = $_POST["linktypeid"]; + $linktype = $dms->getLinkType($linktypeid); + if (!is_object($linktype)) { + UI::exitError(getMLText("admin_tools"),getMLText("unknown_document_linktype")); + } + + $name = $_POST["name"]; + if (!$linktype->setName($name)) { + UI::exitError(getMLText("admin_tools"),getMLText("error_occured")); + } + + $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_edit_linktype'))); + add_log_line(".php&action=editlinktype&linktypeid=".$linktypeid); +} + +else { + UI::exitError(getMLText("admin_tools"),getMLText("unknown_command")); +} + +header("Location:../out/out.LinkTypes.php?linktypeid=".$linktypeid); + +?> diff --git a/out/out.LinkTypes.php b/out/out.LinkTypes.php new file mode 100644 index 000000000..d0fc1f6fe --- /dev/null +++ b/out/out.LinkTypes.php @@ -0,0 +1,60 @@ +$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); +} + +$linktypes = $dms->getLinkTypes(); + +if(isset($_GET['linktypeid']) && $_GET['linktypeid']) { + $selcat = $dms->getLinkType($_GET['linktypeid']); +} else { + $selcat = null; +} + +if($view) { + $view->setParam('conversionmgr', $conversionmgr); + $view->setParam('linktypes', $linktypes); + $view->setParam('sellinktype', $selcat); + $view->setParam('accessobject', $accessop); + $view->setParam('showtree', showtree()); + $view->setParam('cachedir', $settings->_cacheDir); + $view->setParam('previewWidthList', $settings->_previewWidthList); + $view->setParam('timeout', $settings->_cmdTimeout); + $view->setParam('onepage', $settings->_onePageMode); // do most navigation by reloading areas of pages with ajax + $view->setParam('xsendfile', $settings->_enableXsendfile); + $view($_GET); +} diff --git a/views/bootstrap/class.LinkTypes.php b/views/bootstrap/class.LinkTypes.php new file mode 100644 index 000000000..bb315077a --- /dev/null +++ b/views/bootstrap/class.LinkTypes.php @@ -0,0 +1,181 @@ + + * @copyright Copyright (C) 2002-2005 Markus Westphal, + * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, + * 2010-2024 Uwe Steinmann + * @version Release: @package_version@ + */ + +/** + * Class which outputs the html page for LinkTypes view + * + * @category DMS + * @package SeedDMS + * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann + * @copyright Copyright (C) 2002-2005 Markus Westphal, + * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, + * 2010-2024 Uwe Steinmann + * @version Release: @package_version@ + */ +class SeedDMS_View_LinkTypes extends SeedDMS_Theme_Style { + + function js() { /* {{{ */ + $sellinktype = $this->params['sellinktype']; + header('Content-Type: application/javascript; charset=UTF-8'); + parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder')); +?> +$(document).ready( function() { + $( "#selector" ).change(function() { + $('div.ajax').trigger('update', {linktypeid: $(this).val()}); + window.history.pushState({"html":"","pageTitle":""},"", '../out/out.LinkTypes.php?linktypeid=' + $(this).val()); + }); +}); +printDeleteFolderButtonJs(); + $this->printDeleteDocumentButtonJs(); + $this->printClickDocumentJs(); + } /* }}} */ + + function info() { /* {{{ */ + $dms = $this->params['dms']; + $sellinktype = $this->params['sellinktype']; + $conversionmgr = $this->params['conversionmgr']; + $cachedir = $this->params['cachedir']; + $previewwidth = $this->params['previewWidthList']; + $timeout = $this->params['timeout']; + $xsendfile = $this->params['xsendfile']; + + if($sellinktype) { + $this->contentHeading(getMLText("link_type_info")); + /* + $c = $sellinktype->countDocumentLinksByType(); + echo "\n"; + echo "\n"; + echo "
".getMLText('document_count')."".($c)."
"; + + $documents = $sellinktype->getDocumentsByCategory(10); + if($documents) { + print $this->folderListHeader(); + print "\n"; + $previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile); + if($conversionmgr) + $previewer->setConversionMgr($conversionmgr); + foreach($documents as $doc) { + echo $this->documentListRow($doc, $previewer); + } + print ""; + } + */ + } + } /* }}} */ + + function actionmenu() { /* {{{ */ + $dms = $this->params['dms']; + $user = $this->params['user']; + $sellinktype = $this->params['sellinktype']; + + if($sellinktype && !$sellinktype->isUsed()) { +?> +
+ + + + formSubmit(' '.getMLText('rm_link_type'),'','','danger');?> +
+ +
+ + + + + + + + +contentContainerStart(); + $this->formField( + getMLText("name"), + array( + 'element'=>'input', + 'type'=>'text', + 'name'=>'name', + 'value'=>($linktype ? htmlspecialchars($linktype->getName()) : '') + ) + ); + $this->contentContainerEnd(); + $this->formSubmit(" ".getMLText('save')); +?> +
+ +params['sellinktype']; + + $this->showCategoryForm($sellinktype); + } /* }}} */ + + function show() { /* {{{ */ + $dms = $this->params['dms']; + $user = $this->params['user']; + $linktypes = $this->params['linktypes']; + $sellinktype = $this->params['sellinktype']; + + $this->htmlStartPage(getMLText("admin_tools")); + $this->globalNavigation(); + $this->contentStart(); + $this->pageNavigation(getMLText("admin_tools"), "admin_tools"); + + $this->contentHeading(getMLText("global_link_types")); + $this->rowStart(); + $this->columnStart(6); +?> +
+getID(), htmlspecialchars($linktype->getName()), $sellinktype && $linktype->getID()==$sellinktype->getID(), array(/*array('data-subtitle', $linktype->countDocumentLinksByType().' '.getMLText('documents'))*/)); + } + $this->formField( + null, //getMLText("selection"), + array( + 'element'=>'select', + 'id'=>'selector', + 'class'=>'chzn-select', + 'options'=>$options, + 'placeholder'=>getMLText('choose_link_type'), + ) + ); +?> +
+
getID()."\"" : "") ?>>
+ +columnEnd(); + $this->columnStart(6); +?> +
getID()."\"" : "") ?>>
+columnEnd(); + $this->rowEnd(); + + $this->contentEnd(); + $this->htmlEndPage(); + } /* }}} */ +}