mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 09:35:00 +00:00
place business login into controller class
This commit is contained in:
parent
34bd22f40e
commit
45d3ebab3d
67
controllers/class.ReceiptDocument.php
Normal file
67
controllers/class.ReceiptDocument.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of ReceiptDocument controller
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class which does the busines logic for downloading a document
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Controller_ReceiptDocument extends SeedDMS_Controller_Common {
|
||||
|
||||
public function run() {
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$settings = $this->params['settings'];
|
||||
$document = $this->params['document'];
|
||||
$content = $this->params['content'];
|
||||
$receiptstatus = $this->params['receiptstatus'];
|
||||
$receipttype = $this->params['receipttype'];
|
||||
$group = $this->params['group'];
|
||||
$comment = $this->params['comment'];
|
||||
|
||||
/* Get the document id and name before removing the document */
|
||||
$docname = $document->getName();
|
||||
$documentid = $document->getID();
|
||||
|
||||
if(!$this->callHook('preReceiptDocument', $document)) {
|
||||
}
|
||||
|
||||
$result = $this->callHook('receiptDocument', $document);
|
||||
if($result === null) {
|
||||
|
||||
if ($receipttype == "ind") {
|
||||
if(0 > $content->setReceiptByInd($user, $user, $receiptstatus, $comment)) {
|
||||
$this->error = 1;
|
||||
$this->errormsg = "receipt_update_failed";
|
||||
return false;
|
||||
}
|
||||
} elseif ($receipttype == "grp") {
|
||||
if(0 > $content->setReceiptByGrp($group, $user, $receiptstatus, $comment)) {
|
||||
$this->error = 1;
|
||||
$this->errormsg = "receipt_update_failed";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->callHook('postReceiptDocument', $document)) {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,10 @@ include("../inc/inc.ClassEmail.php");
|
|||
include("../inc/inc.DBInit.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
include("../inc/inc.ClassUI.php");
|
||||
include("../inc/inc.ClassController.php");
|
||||
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$controller = Controller::factory($tmp[1]);
|
||||
|
||||
/* Check if the form data comes for a trusted request */
|
||||
if(!checkFormKey('receiptdocument')) {
|
||||
|
@ -45,6 +49,8 @@ if (!is_object($document)) {
|
|||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
|
||||
$folder = $document->getFolder();
|
||||
|
||||
if ($document->getAccessMode($user) < M_READ) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||
}
|
||||
|
@ -76,20 +82,19 @@ if (!isset($_POST["receiptStatus"]) || !is_numeric($_POST["receiptStatus"]) ||
|
|||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_receipt_status"));
|
||||
}
|
||||
|
||||
if ($_POST["receiptType"] == "ind") {
|
||||
|
||||
$comment = $_POST["comment"];
|
||||
$receiptLogID = $latestContent->setReceiptByInd($user, $user, $_POST["receiptStatus"], $comment);
|
||||
if(0 > $receiptLogID) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("receipt_update_failed"));
|
||||
}
|
||||
} elseif ($_POST["receiptType"] == "grp") {
|
||||
$comment = $_POST["comment"];
|
||||
$controller->setParam('document', $document);
|
||||
$controller->setParam('content', $latestContent);
|
||||
$controller->setParam('receiptstatus', $_POST["receiptStatus"]);
|
||||
$controller->setParam('receipttype', $_POST["receiptType"]);
|
||||
if ($_POST["receiptType"] == "grp") {
|
||||
$group = $dms->getGroup($_POST['receiptGroup']);
|
||||
$receiptLogID = $latestContent->setReceiptByGrp($group, $user, $_POST["receiptStatus"], $comment);
|
||||
if(0 > $receiptLogID) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("receipt_update_failed"));
|
||||
}
|
||||
} else {
|
||||
$group = null;
|
||||
}
|
||||
$controller->setParam('group', $group);
|
||||
$controller->setParam('comment', $_POST["comment"]);
|
||||
if(!$controller->run()) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText($controller->getErrorMsg()));
|
||||
}
|
||||
|
||||
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
|
||||
|
|
Loading…
Reference in New Issue
Block a user