mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-11 16:35:38 +00:00
- these files are now for deleting a workflow from the database
This commit is contained in:
parent
baac03e298
commit
76d535a890
|
@ -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");
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()."<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.
|
||||
?>
|
||||
|
@ -74,8 +51,7 @@ class LetoDMS_View_RemoveWorkflow extends LetoDMS_Bootstrap_Style {
|
|||
<?php echo createHiddenFieldWithKey('removeworkflow'); ?>
|
||||
<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(); ?>'/>
|
||||
<input type='hidden' name='workflowid' value='<?php echo $workflow->getId(); ?>'/>
|
||||
<button type='submit' class="btn"><i class="icon-remove"></i> <?php printMLText("rm_workflow"); ?></button>
|
||||
</td></tr></table>
|
||||
</form>
|
||||
|
@ -87,24 +63,6 @@ class LetoDMS_View_RemoveWorkflow extends LetoDMS_Bootstrap_Style {
|
|||
<?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