getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } $documentid = $_POST["documentid"]; $document = $dms->getDocument($documentid); if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } if ($document->getAccessMode($user) < M_ALL) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } 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 = $_POST["version"]; $content = $document->getContentByVersion($version); if (!is_object($content)) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } if (!isset($_POST["overrideStatus"]) || !is_numeric($_POST["overrideStatus"]) || (intval($_POST["overrideStatus"])<-3 && intval($_POST["overrideStatus"])>2)) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_status")); } $overallStatus = $content->getStatus(); // status change control if ($overallStatus["status"] == S_REJECTED || $overallStatus["status"] == S_EXPIRED || $overallStatus["status"] == S_DRAFT_REV || $overallStatus["status"] == S_DRAFT_APP || $overallStatus["status"] == S_IN_WORKFLOW) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("cannot_change_final_states")); } $overrideStatus = $_POST["overrideStatus"]; $comment = $_POST["comment"]; if ($overrideStatus != $overallStatus["status"]) { if (!$content->setStatus($overrideStatus, $comment, $user)) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")); } else { // Send notification to subscribers. if($notifier) { $nl = $document->getNotifyList(); $folder = $document->getFolder(); $subject = "document_status_changed_email_subject"; $message = "document_status_changed_email_body"; $params = array(); $params['name'] = $document->getName(); $params['folder_path'] = $folder->getFolderPathPlain(); $params['status'] = getOverallStatusText($overrideStatus); $params['username'] = $user->getFullName(); $params['sitename'] = $settings->_siteName; $params['http_root'] = $settings->_httpRoot; $params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); $notifier->toList($user, $nl["users"], $subject, $message, $params); foreach ($nl["groups"] as $grp) { $notifier->toGroup($user, $grp, $subject, $message, $params); } $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params); } } } add_log_line("?documentid=".$documentid); header("Location:../out/out.DocumentVersionDetail.php?documentid=".$documentid."&version=".$version); ?>