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")); } $folder = $document->getFolder(); $docPathHTML = getFolderPathHTML($folder, true). " / ".$document->getName().""; if ($document->getAccessMode($user, 'editOnline') < M_READWRITE) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } if($document->isLocked()) { $lockingUser = $document->getLockingUser(); if (($lockingUser->getID() != $user->getID()) && ($document->getAccessMode($user, 'editOnline') != M_ALL)) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("lock_message", array("email" => $lockingUser->getEmail(), "username" => htmlspecialchars($lockingUser->getFullName())))); } } $tmpfname = tempnam(sys_get_temp_dir(), 'FOO'); file_put_contents($tmpfname, $_POST['data']); /* Check if the uploaded file is identical to last version */ $lc = $document->getLatestContent(); if($lc->getChecksum() == SeedDMS_Core_File::checksum($tmpfname)) { echo json_encode(array('success'=>false, 'message'=>getMLText('identical_version'))); } else { if($document->replaceContent(0, $user, $tmpfname, $lc->getOriginalFileName(), $lc->getFileType(), $lc->getMimeType())) { if($notifier) { $notifyList = $folder->getNotifyList(); $subject = "replace_content_email_subject"; $message = "replace_content_email_body"; $params = array(); $params['name'] = $document->getName(); $params['folder_name'] = $folder->getName(); $params['folder_path'] = $folder->getFolderPathPlain(); $params['username'] = $user->getFullName(); $params['comment'] = $document->getComment(); $params['version'] = $lc->getVersion(); $params['version_comment'] = $lc->getComment(); $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); $params['sitename'] = $settings->_siteName; $params['http_root'] = $settings->_httpRoot; $notifier->toList($user, $notifyList["users"], $subject, $message, $params); foreach ($notifyList["groups"] as $grp) { $notifier->toGroup($user, $grp, $subject, $message, $params); } } echo json_encode(array('success'=>true, 'message'=>getMLText('splash_saved_file'))); } else { echo json_encode(array('success'=>false, 'message'=>getMLText('splash_error_saving_file'))); } } unlink($tmpfname);