From baac03e298856239b35449b32245871bd72d3006 Mon Sep 17 00:00:00 2001 From: steinm Date: Thu, 24 Jan 2013 18:17:27 +0000 Subject: [PATCH] - new files to remove a workflow from a document (was RemoveWorkflow) --- op/op.RemoveWorkflowFromDocument.php | 83 +++++++++++++ out/out.RemoveWorkflowFromDocument.php | 66 +++++++++++ .../class.RemoveWorkflowFromDocument.php | 111 ++++++++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 op/op.RemoveWorkflowFromDocument.php create mode 100644 out/out.RemoveWorkflowFromDocument.php create mode 100644 views/bootstrap/class.RemoveWorkflowFromDocument.php diff --git a/op/op.RemoveWorkflowFromDocument.php b/op/op.RemoveWorkflowFromDocument.php new file mode 100644 index 000000000..be60955f9 --- /dev/null +++ b/op/op.RemoveWorkflowFromDocument.php @@ -0,0 +1,83 @@ +isAdmin()) { + UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); +} + +/* Check if the form data comes for a trusted request */ +if(!checkFormKey('removeworkflowfromdocument')) { + 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); +?> diff --git a/out/out.RemoveWorkflowFromDocument.php b/out/out.RemoveWorkflowFromDocument.php new file mode 100644 index 000000000..d34bc1bdd --- /dev/null +++ b/out/out.RemoveWorkflowFromDocument.php @@ -0,0 +1,66 @@ +isAdmin()) { + UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); +} + +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")); +} + +$document = $dms->getDocument(intval($_POST["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" => htmlspecialchars($document->getName()))),getMLText("invalid_version")); +} + +$version = $_POST["version"]; +$version = $document->getContentByVersion($version); + +if (!is_object($version)) { + UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($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")); +} + +$folder = $document->getFolder(); + +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'folder'=>$folder, 'document'=>$document, 'version'=>$version)); +if($view) { + $view->show(); + exit; +} + +?> diff --git a/views/bootstrap/class.RemoveWorkflowFromDocument.php b/views/bootstrap/class.RemoveWorkflowFromDocument.php new file mode 100644 index 000000000..21147d10e --- /dev/null +++ b/views/bootstrap/class.RemoveWorkflowFromDocument.php @@ -0,0 +1,111 @@ + + * @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 Removeorkflow view + * + * @category DMS + * @package LetoDMS + * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann + * @copyright Copyright (C) 2002-2005 Markus Westphal, + * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, + * 2010-2012 Uwe Steinmann + * @version Release: @package_version@ + */ +class LetoDMS_View_RemoveWorkflowFromDocument extends LetoDMS_Bootstrap_Style { + + function show() { /* {{{ */ + $dms = $this->params['dms']; + $user = $this->params['user']; + $folder = $this->params['folder']; + $document = $this->params['document']; + + $latestContent = $document->getLatestContent(); + + $this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName())))); + $this->globalNavigation($folder); + $this->contentStart(); + $this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document"); + $this->contentHeading(getMLText("rm_workflow")); + + $currentstate = $latestContent->getWorkflowState(); + $wkflog = $latestContent->getWorkflowLog(); + $workflow = $latestContent->getWorkflow(); + + $msg = "The document is currently in state: ".$currentstate->getName()."
"; + if($wkflog) { + foreach($wkflog as $entry) { + if($entry->getTransition()->getNextState()->getID() == $currentstate->getID()) { + $enterdate = $entry->getDate(); + $d = strptime($enterdate, '%Y-%m-%d %H:%M:%S'); + $enterts = mktime($d['tm_hour'], $d['tm_min'], $d['tm_sec'], $d['tm_mon']+1, $d['tm_mday'], $d['tm_year']+1900); + } + } + $msg .= "The state was entered at ".$enterdate." which was "; + $msg .= getReadableDuration((time()-$enterts))." ago.
"; + } + $msg .= "The document may stay in this state for ".$currentstate->getMaxTime()." sec."; + $this->infoMsg($msg); + + $this->contentContainerStart(); + // Display the Workflow form. +?> +
+
+

+
+ + +
+ + + +
+
+
+
+ +
+
+contentContainerEnd(); + + if($wkflog) { + $this->contentContainerStart(); + echo ""; + echo ""; + foreach($wkflog as $entry) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
".getMLText('action')."Start stateEnd state".getMLText('date')."".getMLText('user')."".getMLText('comment')."
".getMLText('action_'.$entry->getTransition()->getAction()->getName())."".$entry->getTransition()->getState()->getName()."".$entry->getTransition()->getNextState()->getName()."".$entry->getDate()."".$entry->getUser()->getFullname()."".$entry->getComment()."
\n"; + $this->contentContainerEnd(); + } + + $this->htmlEndPage(); + } /* }}} */ +} +?>