From 76d535a890d61d870f19a1e7c275d941f06f91a2 Mon Sep 17 00:00:00 2001 From: steinm Date: Thu, 24 Jan 2013 18:18:29 +0000 Subject: [PATCH] - these files are now for deleting a workflow from the database --- op/op.RemoveWorkflow.php | 45 ++++---------------- out/out.RemoveWorkflow.php | 28 +++---------- views/bootstrap/class.RemoveWorkflow.php | 52 +++--------------------- 3 files changed, 17 insertions(+), 108 deletions(-) diff --git a/op/op.RemoveWorkflow.php b/op/op.RemoveWorkflow.php index cb55f1558..1cd47f7d7 100644 --- a/op/op.RemoveWorkflow.php +++ b/op/op.RemoveWorkflow.php @@ -34,50 +34,19 @@ 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["workflowid"]) || !is_numeric($_POST["workflowid"]) || intval($_POST["workflowid"])<1) { + UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_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(); +$workflow = $dms->getWorkflow(intval($_POST["workflowid"])); if (!is_object($workflow)) { - UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow")); + UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_id")); } -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); - } - } +if($workflow->remove()) { } -add_log_line("?documentid=".$documentid."&version".$version_num); +add_log_line(""); -header("Location:../out/out.ViewDocument.php?documentid=".$documentid); +header("Location:../out/out.WorkflowMgr.php"); ?> diff --git a/out/out.RemoveWorkflow.php b/out/out.RemoveWorkflow.php index d34bc1bdd..fb623d026 100644 --- a/out/out.RemoveWorkflow.php +++ b/out/out.RemoveWorkflow.php @@ -29,35 +29,17 @@ if (!$user->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")); +if (!isset($_GET["workflowid"]) || !is_numeric($_GET["workflowid"]) || intval($_GET["workflowid"])<1) { + UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_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(); +$workflow = $dms->getWorkflow(intval($_GET["workflowid"])); if (!is_object($workflow)) { - UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("document_has_no_workflow")); + UI::exitError(getMLText("workflow_title"),getMLText("invalid_workflow_id")); } -$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)); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'workflow'=>$workflow)); if($view) { $view->show(); exit; diff --git a/views/bootstrap/class.RemoveWorkflow.php b/views/bootstrap/class.RemoveWorkflow.php index 00bfd87d1..cb3d5addf 100644 --- a/views/bootstrap/class.RemoveWorkflow.php +++ b/views/bootstrap/class.RemoveWorkflow.php @@ -34,36 +34,13 @@ class LetoDMS_View_RemoveWorkflow extends LetoDMS_Bootstrap_Style { function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; - $folder = $this->params['folder']; - $document = $this->params['document']; + $workflow = $this->params['workflow']; - $latestContent = $document->getLatestContent(); - - $this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName())))); - $this->globalNavigation($folder); + $this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($workflow->getName())))); + $this->globalNavigation(); $this->contentStart(); - $this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document"); + $this->pageNavigation(getMLText("admin_tools"), "admin_tools"); $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. ?> @@ -74,8 +51,7 @@ class LetoDMS_View_RemoveWorkflow extends LetoDMS_Bootstrap_Style {
- - +
@@ -87,24 +63,6 @@ class LetoDMS_View_RemoveWorkflow extends LetoDMS_Bootstrap_Style { 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(); } /* }}} */ }