mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	- new files to remove a workflow from a document (was RemoveWorkflow)
This commit is contained in:
		
							parent
							
								
									bb74e11b40
								
							
						
					
					
						commit
						baac03e298
					
				
							
								
								
									
										83
									
								
								op/op.RemoveWorkflowFromDocument.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								op/op.RemoveWorkflowFromDocument.php
									
									
									
									
									
										Normal 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('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); | ||||
| ?>
 | ||||
							
								
								
									
										66
									
								
								out/out.RemoveWorkflowFromDocument.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								out/out.RemoveWorkflowFromDocument.php
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,66 @@ | |||
| <?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.Utils.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")); | ||||
| } | ||||
| 
 | ||||
| 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; | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
							
								
								
									
										111
									
								
								views/bootstrap/class.RemoveWorkflowFromDocument.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								views/bootstrap/class.RemoveWorkflowFromDocument.php
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,111 @@ | |||
| <?php | ||||
| /** | ||||
|  * Implementation of RemoveWorkflowFromDocument view | ||||
|  * | ||||
|  * @category   DMS | ||||
|  * @package    LetoDMS | ||||
|  * @license    GPL 2 | ||||
|  * @version    @version@ | ||||
|  * @author     Uwe Steinmann <uwe@steinmann.cx> | ||||
|  * @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 <uwe@steinmann.cx> | ||||
|  * @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()."<br />"; | ||||
| 		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.<br />"; | ||||
| 		} | ||||
| 		$msg .= "The document may stay in this state for ".$currentstate->getMaxTime()." sec."; | ||||
| 		$this->infoMsg($msg); | ||||
| 
 | ||||
| 		$this->contentContainerStart(); | ||||
| 		// Display the Workflow form.
 | ||||
| ?>
 | ||||
| 	<div class="row-fluid"> | ||||
| 	<div class="span4"> | ||||
| 	<p><?php printMLText("rm_workflow_warning"); ?></p>
 | ||||
| 	<form method="post" action="../op/op.RemoveWorkflowFromDocument.php" name="form1" onsubmit="return checkForm();"> | ||||
| 	<?php echo createHiddenFieldWithKey('removeworkflowfromdocument'); ?>
 | ||||
| 	<table> | ||||
| 	<tr><td></td><td> | ||||
| 	<input type='hidden' name='documentid' value='<?php echo $document->getId(); ?>'/> | ||||
| 	<input type='hidden' name='version' value='<?php echo $latestContent->getVersion(); ?>'/> | ||||
| 	<button type='submit' class="btn"><i class="icon-remove"></i> <?php printMLText("rm_workflow"); ?></button>
 | ||||
| 	</td></tr></table> | ||||
| 	</form> | ||||
| 	</div> | ||||
| 	<div id="workflowgraph" class="span8"> | ||||
| 	<iframe src="out.WorkflowGraph.php?workflow=<?php echo $workflow->getID(); ?>" width="100%" height="500" style="border: 1px solid #AAA;"></iframe> | ||||
| 	</div> | ||||
| 	</div> | ||||
| <?php | ||||
| 		$this->contentContainerEnd(); | ||||
| 
 | ||||
| 		if($wkflog) { | ||||
| 			$this->contentContainerStart(); | ||||
| 			echo "<table class=\"table-condensed\">"; | ||||
| 			echo "<tr><th>".getMLText('action')."</th><th>Start state</th><th>End state</th><th>".getMLText('date')."</th><th>".getMLText('user')."</th><th>".getMLText('comment')."</th></tr>"; | ||||
| 			foreach($wkflog as $entry) { | ||||
| 				echo "<tr>"; | ||||
| 				echo "<td>".getMLText('action_'.$entry->getTransition()->getAction()->getName())."</td>"; | ||||
| 				echo "<td>".$entry->getTransition()->getState()->getName()."</td>"; | ||||
| 				echo "<td>".$entry->getTransition()->getNextState()->getName()."</td>"; | ||||
| 				echo "<td>".$entry->getDate()."</td>"; | ||||
| 				echo "<td>".$entry->getUser()->getFullname()."</td>"; | ||||
| 				echo "<td>".$entry->getComment()."</td>"; | ||||
| 				echo "</tr>"; | ||||
| 			} | ||||
| 			echo "</table>\n"; | ||||
| 			$this->contentContainerEnd(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->htmlEndPage(); | ||||
| 	} /* }}} */ | ||||
| } | ||||
| ?>
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 steinm
						steinm