added operations for new workflow functions

This commit is contained in:
steinm 2013-01-24 10:48:37 +00:00
parent 7582c2bd11
commit 24dee8545f
11 changed files with 1020 additions and 0 deletions

View File

@ -0,0 +1,60 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removetransitionfromworkflow')) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
}
if (!isset($_POST["workflow"]) || !is_numeric($_POST["workflow"])) {
UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_id"));
}
$workflow = $dms->getWorkflow($_POST["workflow"]);
if (!is_object($workflow)) {
UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_id"));
}
if (!isset($_POST["transition"]) || !is_numeric($_POST["transition"])) {
UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_id"));
}
$transition = $workflow->getTransition($_POST['transition']);
if (!is_object($transition)) {
UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_id"));
}
if($workflow->removeTransition($transition)) {
}
add_log_line("?workflow=".$workflow->getID()."&transition".$transition->getID());
header("Location:../out/out.WorkflowMgr.php?workflow=".$workflow->getID());
?>

83
op/op.RemoveWorkflow.php Normal file
View File

@ -0,0 +1,83 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removeworkflow')) {
UI::exitError(getMLText("workflow_editor"), getMLText("invalid_request_token"));
}
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
UI::exitError(getMLText("workflow_editor"), getMLText("invalid_doc_id"));
}
$documentid = $_POST["documentid"];
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
UI::exitError(getMLText("workflow_editor"), getMLText("invalid_doc_id"));
}
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"));
}
$workflow = $version->getWorkflow();
if (!is_object($workflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
if($version->removeWorkflow($user)) {
if ($notifier) {
$nl = $document->getNotifyList();
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("remove_workflow_email");
$message = getMLText("remove_workflow_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("workflow").": ".$workflow->getName()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
// Send notification to subscribers.
$notifier->toList($user, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid."&version".$version_num);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>

View File

@ -0,0 +1,52 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removeworkflowstate')) {
UI::exitError(getMLText("workflow_editor"), getMLText("invalid_request_token"));
}
if (!isset($_POST["workflowstateid"]) || !is_numeric($_POST["workflowstateid"]) || intval($_POST["workflowstateid"])<1) {
UI::exitError(getMLText("workflow_editor"), getMLText("invalid_version"));
}
$workflowstate = $dms->getWorkflowState($_POST["workflowstateid"]);
if (!is_object($workflowstate)) {
UI::exitError(getMLText("workflow_editor"), getMLText("invalid_workflow_state"));
}
if($workflowstate->remove()) {
}
add_log_line("?workflowstateid=".$_POST["workflowstateid"]);
header("Location:../out/out.WorkflowStatesMgr.php");
?>

View File

@ -0,0 +1,96 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
/* Check if the form data comes for a trusted request */
if(!checkFormKey('returnfromsubworkflow')) {
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["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"));
}
$parentworkflow = $version->getParentWorkflow();
if (!is_object($parentworkflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
$workflow = $version->getWorkflow();
if (!is_object($workflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
if(isset($_POST["transition"]) && $_POST["transition"]) {
$transition = $dms->getWorkflowTransition($_POST["transition"]);
if (!is_object($transition)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_workflow_transition"));
}
} else {
$transition = null;
}
if($version->returnFromSubWorkflow($user, $transition, $_POST["comment"])) {
if ($notifier) {
$nl = $document->getNotifyList();
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("return_from_subworkflow_email");
$message = getMLText("return_from_subwork_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("workflow").": ".$workflow->getName()."\r\n".
getMLText("workflow").": ".$parentworkflow->getName()."\r\n".
getMLText("current_state").": ".$version->getWorkflowState()->getName()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
// Send notification to subscribers.
$notifier->toList($user, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid."&version".$version_num);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>

83
op/op.RewindWorkflow.php Normal file
View File

@ -0,0 +1,83 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
/* Check if the form data comes for a trusted request */
if(!checkFormKey('rewindworkflow')) {
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["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"));
}
$workflow = $version->getWorkflow();
if (!is_object($workflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
if($version->rewindWorkflow()) {
if ($notifier) {
$nl = $document->getNotifyList();
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("rewind_workflow_email");
$message = getMLText("rewind_workflow_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("workflow").": ".$workflow->getName()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
// Send notification to subscribers.
$notifier->toList($user, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid."&version".$version_num);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>

90
op/op.RunSubWorkflow.php Normal file
View File

@ -0,0 +1,90 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
/* Check if the form data comes for a trusted request */
if(!checkFormKey('runsubworkflow')) {
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["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"));
}
$workflow = $version->getWorkflow();
if (!is_object($workflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
$subworkflow = $dms->getWorkflow($_POST["subworkflow"]);
if (!is_object($subworkflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
if($version->getWorkflowState()->getID() != $subworkflow->getInitState()->getID()) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
if($version->runSubWorkflow($subworkflow)) {
if ($notifier) {
$nl = $document->getNotifyList();
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("run_subworkflow_email");
$message = getMLText("run_subwork_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("workflow").": ".$subworkflow->getName()."\r\n".
getMLText("current_state").": ".$version->getWorkflowState()->getName()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
// Send notification to subscribers.
$notifier->toList($user, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid."&version".$version_num);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>

76
op/op.SetWorkflow.php Normal file
View File

@ -0,0 +1,76 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
//
// 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.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassEmail.php");
include("../inc/inc.Authentication.php");
/* Check if the form data comes for a trusted request */
if(!checkFormKey('setworkflow')) {
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_READWRITE) {
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["workflow"]) || !is_numeric($_POST["workflow"]) || intval($_POST["workflow"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_workflow"));
}
$workflow = $dms->getWorkflow($_POST["workflow"]);
if (!is_object($workflow)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_workflow"));
}
if (!$version->setWorkflow($workflow, $user)){
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);
?>

95
op/op.TriggerWorkflow.php Normal file
View File

@ -0,0 +1,95 @@
<?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.ClassEmail.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
/* Check if the form data comes for a trusted request */
if(!checkFormKey('triggerworkflow')) {
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["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"));
}
$workflow = $version->getWorkflow();
if (!is_object($workflow)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow"));
}
$transition = $dms->getWorkflowTransition($_POST["transition"]);
if (!is_object($transition)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_workflow_transition"));
}
if(!$version->triggerWorkflowTransitionIsAllowed($user, $transition)) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
}
$workflow = $transition->getWorkflow();
if($version->triggerWorkflowTransition($user, $transition, $_POST["comment"])) {
if ($notifier) {
$nl = $document->getNotifyList();
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("transition_triggered_email");
$message = getMLText("transition_triggered_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("workflow").": ".$workflow->getName()."\r\n".
getMLText("action").": ".$transition->getAction()->getName()."\r\n".
getMLText("comment").": ".$_POST["comment"]."\r\n".
getMLText("previous_state").": ".$transition->getState()->getName()."\r\n".
getMLText("current_state").": ".$transition->getNextState()->getName()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
// Send notification to subscribers.
$notifier->toList($user, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid."&version".$version_num);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>

View File

@ -0,0 +1,124 @@
<?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-2013 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.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
include("../inc/inc.ClassPasswordStrength.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (isset($_POST["action"])) $action=$_POST["action"];
else $action=NULL;
// add new workflow ---------------------------------------------------------
if ($action == "addworkflowaction") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('addworkflowaction')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
$name = $_POST["name"];
$docstatus = $_POST["docstatus"];
if (is_object($dms->getWorkflowActionByName($name))) {
UI::exitError(getMLText("admin_tools"),getMLText("workflow_action_exists"));
}
$newWorkflowaction = $dms->addWorkflowAction($name, $docstatus);
if (!$newWorkflowaction) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$workflowactionid = $newWorkflowaction->getID();
add_log_line(".php&action=addworkflowaction&name=".$name);
}
// delete user ------------------------------------------------------------
else if ($action == "removeworkflowaction") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removeworkflowaction')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (isset($_POST["workflowactionid"])) {
$workflowactionid = $_POST["workflowactionid"];
}
if (!isset($workflowactionid) || !is_numeric($workflowactionid) || intval($workflowactionid)<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$workflowActionToRemove = $dms->getWorkflowAction($workflowactionid);
if (!is_object($workflowActionToRemove)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
if (!$workflowActionToRemove->remove()) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
add_log_line(".php&action=removeworkflowaction&workflowactionid=".$workflowactionid);
$workflowactionid=-1;
}
// modify workflow ---------------------------------------------------------
else if ($action == "editworkflowaction") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('editworkflowaction')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["workflowactionid"]) || !is_numeric($_POST["workflowactionid"]) || intval($_POST["workflowactionid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$workflowactionid=$_POST["workflowactionid"];
$editedWorkflowAction = $dms->getWorkflowAction($workflowactionid);
if (!is_object($editedWorkflowAction)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$name = $_POST["name"];
$docstatus = $_POST["docstatus"];
if ($editedWorkflowAction->getName() != $name)
$editedWorkflowAction->setName($name);
add_log_line(".php&action=editworkflowaction&workflowactionid=".$workflow);
}
else UI::exitError(getMLText("admin_tools"),getMLText("unknown_command"));
header("Location:../out/out.WorkflowActionsMgr.php?workflowactionid=".$workflowactionid);
?>

135
op/op.WorkflowMgr.php Normal file
View File

@ -0,0 +1,135 @@
<?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-2013 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.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
include("../inc/inc.ClassPasswordStrength.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (isset($_POST["action"])) $action=$_POST["action"];
else $action=NULL;
// add new workflow ---------------------------------------------------------
if ($action == "addworkflow") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('addworkflow')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
$name = $_POST["name"];
$initstate = $_POST["initstate"];
if (is_object($dms->getWorkflowByName($name))) {
UI::exitError(getMLText("admin_tools"),getMLText("workflow_exists"));
}
$state = $dms->getWorkflowState($initstate);
if (!$state) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$newWorkflow = $dms->addWorkflow($name, $state);
if (!$newWorkflow) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
add_log_line(".php&action=addworkflow&name=".$name);
}
// delete user ------------------------------------------------------------
else if ($action == "removeworkflow") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removeworkflow')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (isset($_POST["workflowid"])) {
$workflowid = $_POST["workflowid"];
}
if (!isset($workflowid) || !is_numeric($workflowid) || intval($workflowid)<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$workflowToRemove = $dms->getWorkflow($workflowid);
if (!is_object($workflowToRemove)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
if (!$workflowToRemove->remove()) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
add_log_line(".php&action=removeworkflow&workflowid=".$workflowid);
$workflowid=-1;
}
// modify workflow ---------------------------------------------------------
else if ($action == "editworkflow") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('editworkflow')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["workflowid"]) || !is_numeric($_POST["workflowid"]) || intval($_POST["workflowid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$workflowid=$_POST["workflowid"];
$editedWorkflow = $dms->getWorkflow($workflowid);
if (!is_object($editedWorkflow)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$name = $_POST["name"];
$initstate = $_POST["initstate"];
$state = $dms->getWorkflowState($initstate);
if (!$state) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
if ($editedWorkflow->getName() != $name)
$editedWorkflow->setName($name);
if ($editedWorkflow->getInitState()->getID() != $state->getID())
$editedWorkflow->setInitState($state);
add_log_line(".php&action=editworkflow&workflowid=".$workflow);
}
else UI::exitError(getMLText("admin_tools"),getMLText("unknown_command"));
header("Location:../out/out.WorkflowMgr.php?workflowid=".$workflowid);
?>

126
op/op.WorkflowStatesMgr.php Normal file
View File

@ -0,0 +1,126 @@
<?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-2013 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.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
include("../inc/inc.ClassPasswordStrength.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (isset($_POST["action"])) $action=$_POST["action"];
else $action=NULL;
// add new workflow ---------------------------------------------------------
if ($action == "addworkflowstate") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('addworkflowstate')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
$name = $_POST["name"];
$docstatus = $_POST["docstatus"];
if (is_object($dms->getWorkflowStateByName($name))) {
UI::exitError(getMLText("admin_tools"),getMLText("workflow_state_exists"));
}
$newWorkflowstate = $dms->addWorkflowState($name, $docstatus);
if (!$newWorkflowstate) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$workflowstateid = $newWorkflowstate->getID();
add_log_line(".php&action=addworkflowstate&name=".$name);
}
// delete user ------------------------------------------------------------
else if ($action == "removeworkflowstate") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removeworkflowstate')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (isset($_POST["workflowstateid"])) {
$workflowstateid = $_POST["workflowstateid"];
}
if (!isset($workflowstateid) || !is_numeric($workflowstateid) || intval($workflowstateid)<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$workflowStateToRemove = $dms->getWorkflowState($workflowstateid);
if (!is_object($workflowStateToRemove)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
if (!$workflowStateToRemove->remove()) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
add_log_line(".php&action=removeworkflowstate&workflowstateid=".$workflowstateid);
$workflowstateid=-1;
}
// modify workflow ---------------------------------------------------------
else if ($action == "editworkflowstate") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('editworkflowstate')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["workflowstateid"]) || !is_numeric($_POST["workflowstateid"]) || intval($_POST["workflowstateid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$workflowstateid=$_POST["workflowstateid"];
$editedWorkflowState = $dms->getWorkflowState($workflowstateid);
if (!is_object($editedWorkflowState)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_workflow_id"));
}
$name = $_POST["name"];
$docstatus = $_POST["docstatus"];
if ($editedWorkflowState->getName() != $name)
$editedWorkflowState->setName($name);
if ($editedWorkflowState->getDocumentStatus() != $docstatus)
$editedWorkflowState->setDocumentStatus($docstatus);
add_log_line(".php&action=editworkflowstate&workflowstateid=".$workflow);
}
else UI::exitError(getMLText("admin_tools"),getMLText("unknown_command"));
header("Location:../out/out.WorkflowStatesMgr.php?workflowstateid=".$workflowstateid);
?>