Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/9.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/9.0
  • Loading branch information
metaventis-build committed Nov 14, 2024
2 parents d599d42 + 12dc617 commit e166167
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion service/src/main/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sed -i -r "s|memory_limit.*|memory_limit = ${memory_limit}|" "${php_ini}"

sed -i "s|define('ONLYOFFICE_DOCUMENT_SERVER', '.*')|define('ONLYOFFICE_DOCUMENT_SERVER', '${only_office_document_server}')|g" "${conf}"
sed -i "s|define('ONLYOFFICE_PLUGIN_URL', '.*')|define('ONLYOFFICE_PLUGIN_URL', '${only_office_plugin_url}')|g" "${conf}"
sed -i "s|define('ONLYOFFICE_EDUSHARING_PLUGIN', .*)|define('ONLYOFFICE_EDUSHARING_PLUGIN', ${only_office_edusharing_plugin})|g" "${conf}"
sed -i "s|define('ONLYOFFICE_EDUSHARING_PLUGIN', '.*')|define('ONLYOFFICE_EDUSHARING_PLUGIN', '${only_office_edusharing_plugin}')|g" "${conf}"
sed -i "s|define('ONLYOFFICE_EDUSHARING_PLUGIN_LABEL', '.*')|define('ONLYOFFICE_EDUSHARING_PLUGIN_LABEL', '${only_office_edusharing_plugin_label}')|g" "${conf}"
sed -i "s|define('ONLYOFFICE_EDUSHARING_PLUGIN_ICON', '.*')|define('ONLYOFFICE_EDUSHARING_PLUGIN_ICON', '${only_office_edusharing_plugin_icon}')|g" "${conf}"
sed -i "s|define('ONLYOFFICE_JWT_SECRET', '.*')|define('ONLYOFFICE_JWT_SECRET', '${only_office_jwt_secret}')|g" "${conf}"
Expand Down
6 changes: 5 additions & 1 deletion service/src/main/php/src/lib/EduRestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ public function createContentNodeEnhanced($nodeId, $contentpath, $mimetype, $ver
}

public function createContentNode($nodeId, $contentpath, $mimetype, $versionComment = '') {
$ch = curl_init($this->getApiUrl() . 'node/v1/nodes/-home-/' . $nodeId . '/content?versionComment=' . $versionComment . '&mimetype=' . $mimetype);
$url = $this->getApiUrl() . 'node/v1/nodes/-home-/' . $nodeId . '/content?mimetype=' . $mimetype;
if (!empty($versionComment)) {
$url .= '&versionComment=' . $versionComment;
}
$ch = curl_init($url);
$headers = $this->getHeaders();
$headers[] = 'Content-Type: multipart/form-data';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
Expand Down
56 changes: 38 additions & 18 deletions service/src/main/php/src/tools/onlyoffice/doceditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
ini_set('display_errors', 0);

$id = $_GET['id'];
$lang = 'de';
$lang = $_SESSION[$id]['language'] ?? 'de';



/*
*
Expand Down Expand Up @@ -127,7 +129,9 @@ function getCallbackUrl($id) {
<script src="<?php echo $_SESSION[$id]['WWWURL']?>/js/materialize.min.js"></script>
<script type="text/javascript">

var docEditor;
var lang = '<?php echo ($_SESSION[$id]['language'] ?? 'de') ?>';

var docEditor;

var innerAlert = function (message) {
if (console && console.log)
Expand All @@ -144,9 +148,22 @@ function getCallbackUrl($id) {
};

var onRequestEditRights = function () {
return;
const queryData = new URLSearchParams(window.location.search.slice(1));
queryData.set("requestEdit", "true");
const newUrl = new URL(window.location.href);
newUrl.search = queryData;
window.location.href = newUrl;
};

var onOutdatedVersion = function () {
const messages = {
en: 'The session expired or the document is now longer up to date. Please reload it from the repository.',
de: 'Die Session ist abgelaufen oder das Dokument ist veraltet. Bitte laden Sie es aus dem Repositorium neu.'
}
alert(lang === 'de' ? messages.de : messages.en);
window.close();
}

var onError = function (event) {
if (event)
innerAlert(event.data);
Expand All @@ -161,10 +178,11 @@ function getCallbackUrl($id) {
$payload_download = false;
//$payload_print = $get_array["embed"] == "true" ? "false" : "true";
$payload_edit = $_SESSION[$id]['edit'] ? true : false;
$switchToEditMode = $payload_edit && isset($_GET['requestEdit']) && (bool)$_GET['requestEdit'] === true;
//$payload_comment = $get_array["comment"] == "true" ? "true" : "false";
//$payload_review = $get_array["review"] == "true" ? "true" : "false";
$payload_form = false;
$payload_mode = 'edit';
$payload_mode = $switchToEditMode ? 'edit' : 'view';
$detector = new Mobile_Detect();
$type = $detector->isMobile() ? 'mobile' : 'desktop';
$payload_callback = getCallbackUrl($id);
Expand All @@ -187,8 +205,9 @@ function getCallbackUrl($id) {
"created" => $payload_created,
],
"permissions" => [
"download" => false,
"edit" => $payload_edit
"download" => true,
"edit" => $payload_edit,
"chat" => true
]
],
"editorConfig" => [
Expand All @@ -211,8 +230,7 @@ function getCallbackUrl($id) {
"about" => false,
"feedback" => false,
"comments" => true,
"forcesave" => false, //check concept, some integrity issues with versions
"chat" => true
"forcesave" => true, //check concept, some integrity issues with versions
// goback: {
/* url: "<?php echo serverPath() ?>/index.php",*/
// },
Expand All @@ -230,33 +248,35 @@ function getCallbackUrl($id) {
];
}
echo json_encode(json_encode($payload));

?>
);

config.events = {
'onReady': onReady,
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onError': onError,
'onInfo': function ( data ) {
if ( data && data.data && data.data.getConfig ) {
docEditor.serviceCommand ( 'getConfig', '<?php echo $_SESSION[$id]['ticket']; ?>' );
'onReady': onReady,
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
'onInfo': function ( data ) {
if ( data && data.data && data.data.getConfig ) {
docEditor.serviceCommand ( 'getConfig', '<?php echo $_SESSION[$id]['ticket']; ?>' );
}
}
};
<?php if (defined('ONLYOFFICE_JWT_SECRET') && !empty(ONLYOFFICE_JWT_SECRET)): ?>
config.token = "<?php echo JWT::encode($payload, ONLYOFFICE_JWT_SECRET);?>"
<?php endif; ?>;
var сonnectEditor = function () {
var connectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
}
if(window.addEventListener)
{
window.addEventListener("load", сonnectEditor);
window.addEventListener("load", connectEditor);
}
else
if (window.attachEvent) {
window.attachEvent("load", сonnectEditor);
window.attachEvent("load", connectEditor);
}
function getXmlHttp() {
var xmlhttp;
Expand Down
6 changes: 1 addition & 5 deletions service/src/main/php/src/tools/onlyoffice/webeditor-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ function track($log)
$downloadUri = $data["url"];
$saved = 1;
$tmpSavePath = DATA . DIRECTORY_SEPARATOR . 'tools' . DIRECTORY_SEPARATOR . 'onlyoffice' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . date("Y-m-d_H-i-s") . '_' . $_SESSION[$id]['node']->node->ref->id . '.' . $_SESSION[$id]['filetype'];
if ($status == 'ForcedSave') {
$comment = 'EDITOR_UPLOAD_USER,ONLY_OFFICE';
} else {
$comment = 'EDITOR_UPLOAD,ONLY_OFFICE';
}
$comment = $status == 'ForcedSave' ? '' : 'EDITOR_UPLOAD,ONLY_OFFICE';

$arrContextOptions = array(
"ssl" => array(
Expand Down

0 comments on commit e166167

Please sign in to comment.