mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-10 05:26:06 +00:00
- get rid of INSERT statements
This commit is contained in:
parent
acd9fa3fb3
commit
a2b791e7a2
|
@ -56,7 +56,7 @@ if (!is_object($content)) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// operation is only allowed for last the document version
|
// operation is only allowed for the last document version
|
||||||
$latestContent = $document->getLatestContent();
|
$latestContent = $document->getLatestContent();
|
||||||
if ($latestContent->getVersion()!=$version) {
|
if ($latestContent->getVersion()!=$version) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
|
@ -72,30 +72,10 @@ if (!isset($_POST["approvalStatus"]) || !is_numeric($_POST["approvalStatus"]) ||
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_approval_status"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_approval_status"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve the approve status for the current user.
|
|
||||||
$approvalStatus = $user->getApprovalStatus($documentid, $version);
|
|
||||||
if (count($approvalStatus["indstatus"]) == 0 && count($approvalStatus["grpstatus"]) == 0) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST["approvalType"] == "ind") {
|
if ($_POST["approvalType"] == "ind") {
|
||||||
|
|
||||||
$indApprover = true;
|
|
||||||
if (count($approvalStatus["indstatus"])==0) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
||||||
}
|
|
||||||
if ($approvalStatus["indstatus"][0]["status"]==-2) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// User is eligible to make this update.
|
|
||||||
|
|
||||||
$comment = sanitizeString($_POST["comment"]);
|
$comment = sanitizeString($_POST["comment"]);
|
||||||
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
|
if(0 > $latestContent->setApprovalByInd($user, $user, $_POST["approvalStatus"], $comment)) {
|
||||||
"VALUES ('". $approvalStatus["indstatus"][0]["approveID"] ."', '".
|
|
||||||
$_POST["approvalStatus"] ."', '". $comment ."', NOW(), '". $user->getID() ."')";
|
|
||||||
$res=$db->getResult($queryStr);
|
|
||||||
if (is_bool($res) && !res) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("approval_update_failed"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("approval_update_failed"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -126,35 +106,13 @@ if ($_POST["approvalType"] == "ind") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($_POST["approvalType"] == "grp") {
|
else if ($_POST["approvalType"] == "grp") {
|
||||||
|
|
||||||
$grpApprover=false;
|
|
||||||
foreach ($approvalStatus["grpstatus"] as $gs) {
|
|
||||||
if ($_POST["approvalGroup"] == $gs["required"]) {
|
|
||||||
if ($gs["status"]==-2) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
||||||
}
|
|
||||||
$grpStatus=$gs;
|
|
||||||
$grpApprover=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$grpApprover) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// User is eligible to make this update.
|
|
||||||
|
|
||||||
$comment = sanitizeString($_POST["comment"]);
|
$comment = sanitizeString($_POST["comment"]);
|
||||||
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
|
$group = $dms->getGroup($_POST['approvalGroup']);
|
||||||
"VALUES ('". $grpStatus["approveID"] ."', '".
|
if(0 > $latestContent->setApprovalByGrp($group, $user, $_POST["approvalStatus"], $comment)) {
|
||||||
$_POST["approvalStatus"] ."', '". $comment ."', NOW(), '". $user->getID() ."')";
|
|
||||||
$res=$db->getResult($queryStr);
|
|
||||||
if (is_bool($res) && !res) {
|
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("approval_update_failed"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("approval_update_failed"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Send an email notification to the document updater.
|
// Send an email notification to the document updater.
|
||||||
$grp = $dms->getGroup($grpStatus["required"]);
|
|
||||||
if($notifier) {
|
if($notifier) {
|
||||||
$subject = $settings->_siteName.": ".$document->getName().", v.".$version." - ".getMLText("approval_submit_email");
|
$subject = $settings->_siteName.": ".$document->getName().", v.".$version." - ".getMLText("approval_submit_email");
|
||||||
$message = getMLText("approval_submit_email")."\r\n";
|
$message = getMLText("approval_submit_email")."\r\n";
|
||||||
|
@ -243,7 +201,7 @@ if ($_POST["approvalStatus"]==-1){
|
||||||
$message = getMLText("document_status_changed_email")."\r\n";
|
$message = getMLText("document_status_changed_email")."\r\n";
|
||||||
$message .=
|
$message .=
|
||||||
getMLText("document").": ".$document->_name."\r\n".
|
getMLText("document").": ".$document->_name."\r\n".
|
||||||
getMLText("status").": ".getOverallStatusText($status)."\r\n".
|
getMLText("status").": ".getOverallStatusText($newStatus)."\r\n".
|
||||||
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
|
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
|
||||||
getMLText("comment").": ".$document->getComment()."\r\n".
|
getMLText("comment").": ".$document->getComment()."\r\n".
|
||||||
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
|
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user