- added handling of categories

This commit is contained in:
steinm 2011-03-10 14:40:20 +00:00
parent c7a2869f0d
commit dd0deb7f34
2 changed files with 99 additions and 61 deletions

View File

@ -47,6 +47,7 @@ $comment = sanitizeString($_POST["comment"]);
$version_comment = sanitizeString($_POST["version_comment"]);
$keywords = sanitizeString($_POST["keywords"]);
$categories = sanitizeString($_POST["categoryidform1"]);
$reqversion = (int)$_POST["reqversion"];
if ($reqversion<1) $reqversion=1;
@ -150,16 +151,30 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
if ((count($_FILES["userfile"]["tmp_name"])==1)&&($_POST["name"]!=""))
$name = sanitizeString($_POST["name"]);
else $name = basename($userfilename);
$cats = array();
if($categories) {
$catids = explode(',', $categories);
foreach($catids as $catid) {
$cats[] = $dms->getDocumentCategory($catid);
}
}
$res = $folder->addDocument($name, $comment, $expires, $user, $keywords,
$userfiletmp, basename($userfilename),
$cats, $userfiletmp, basename($userfilename),
$fileType, $userfiletype, $sequence,
$reviewers, $approvers, $reqversion,$version_comment);
if (is_bool($res) && !$res) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("error_occured"));
} else {
$document = $res[0];
if(isset($GLOBALS['LETODMS_HOOKS']['postAddDocument'])) {
foreach($GLOBALS['LETODMS_HOOKS']['postAddDocument'] as $hookObj) {
if (method_exists($hookObj, 'postAddDocument')) {
$hookObj->postAddDocument($document);
}
}
}
// Send notification to subscribers.
if($notifier) {
$folder->getNotifyList();

View File

@ -1,55 +1,56 @@
<?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.Utils.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassEmail.php");
include("../inc/inc.Authentication.php");
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"));
}
$folder = $document->getFolder();
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
if ($document->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
}
<?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.
$name = sanitizeString($_POST["name"]);
$comment = sanitizeString($_POST["comment"]);
$keywords = sanitizeString($_POST["keywords"]);
$sequence = $_POST["sequence"];
if (!is_numeric($sequence)) {
$sequence="keep";
}
include("../inc/inc.Settings.php");
include("../inc/inc.Utils.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassEmail.php");
include("../inc/inc.Authentication.php");
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"));
}
$folder = $document->getFolder();
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
if ($document->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
}
$name = sanitizeString($_POST["name"]);
$comment = sanitizeString($_POST["comment"]);
$keywords = sanitizeString($_POST["keywords"]);
$categories = sanitizeString($_POST["categoryidform1"]);
$sequence = $_POST["sequence"];
if (!is_numeric($sequence)) {
$sequence="keep";
}
if (($oldname = $document->getName()) != $name) {
if($document->setName($name)) {
@ -81,7 +82,7 @@ if (($oldname = $document->getName()) != $name) {
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
@ -113,7 +114,7 @@ if (($oldcomment = $document->getComment()) != $comment) {
}
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
@ -121,7 +122,29 @@ if (($oldkeywords = $document->getKeywords()) != $keywords) {
if($document->setKeywords($keywords)) {
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
if($categories) {
$categoriesarr = array();
foreach(explode(',', $categories) as $catid) {
if($cat = $dms->getDocumentCategory($catid)) {
$categoriesarr[] = $cat;
}
}
$oldcategories = $document->getCategories();
$oldcatsids = array();
foreach($oldcategories as $oldcategory)
$oldcatsids[] = $oldcategory->getID();
if (count($categoriesarr) != count($oldcategories) ||
array_diff(explode(',', $categories), $oldcatsids)) {
if($document->setCategories($categoriesarr)) {
} else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
}
@ -129,12 +152,12 @@ if($sequence != "keep") {
if($document->setSequence($sequence)) {
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
add_log_line("?documentid=".$documentid);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>