mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
W.I.P. collab editor:
- Try to update genesis file after save happens
This commit is contained in:
parent
a5b31c62ab
commit
11ab760dc8
@ -249,13 +249,16 @@ class filemanager_collab extends filemanager_collab_bo {
|
|||||||
*
|
*
|
||||||
* @param type $es_id
|
* @param type $es_id
|
||||||
* @param type $action
|
* @param type $action
|
||||||
|
* @param string $file_path
|
||||||
*/
|
*/
|
||||||
function ajax_actions ($es_id, $action)
|
function ajax_actions ($es_id, $action, $file_path)
|
||||||
{
|
{
|
||||||
switch ($action)
|
switch ($action)
|
||||||
{
|
{
|
||||||
case 'save':
|
case 'save':
|
||||||
$this->SESSION_Save($es_id);
|
$this->SESSION_Save($es_id);
|
||||||
|
//update genesis file after save happened
|
||||||
|
if ($file_path) self::generateGenesis ($file_path, $es_id);
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$this->SESSION_cleanup($es_id);
|
$this->SESSION_cleanup($es_id);
|
||||||
@ -324,13 +327,8 @@ class filemanager_collab extends filemanager_collab_bo {
|
|||||||
*/
|
*/
|
||||||
function ajax_getGenesisUrl ($file_path, $_isNew)
|
function ajax_getGenesisUrl ($file_path, $_isNew)
|
||||||
{
|
{
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$es_id = md5($file_path);
|
$es_id = md5($file_path);
|
||||||
$paths = explode('/webdav.php', $file_path);
|
|
||||||
$dir_parts = explode('/',$paths[1]);
|
|
||||||
array_pop($dir_parts);
|
|
||||||
$dir = join('/', $dir_parts);
|
|
||||||
$response = Api\Json\Response::get();
|
$response = Api\Json\Response::get();
|
||||||
// handle new empty file
|
// handle new empty file
|
||||||
if ($_isNew)
|
if ($_isNew)
|
||||||
@ -345,6 +343,8 @@ class filemanager_collab extends filemanager_collab_bo {
|
|||||||
|
|
||||||
if ($session && $session['genesis_url'] !== '')
|
if ($session && $session['genesis_url'] !== '')
|
||||||
{
|
{
|
||||||
|
$gen_file = explode('/webdav.php',$session['genesis_url']);
|
||||||
|
if (!Api\Vfs::file_exists($gen_file[1])) self::generateGenesis ($file_path, $es_id);
|
||||||
$result = array (
|
$result = array (
|
||||||
'es_id' => $session['es_id'],
|
'es_id' => $session['es_id'],
|
||||||
'genesis_url' => $session['genesis_url']
|
'genesis_url' => $session['genesis_url']
|
||||||
@ -352,15 +352,32 @@ class filemanager_collab extends filemanager_collab_bo {
|
|||||||
}
|
}
|
||||||
else if ($this->is_collabAllowed($file_path, Api\Vfs::WRITABLE))
|
else if ($this->is_collabAllowed($file_path, Api\Vfs::WRITABLE))
|
||||||
{
|
{
|
||||||
$genesis_file = $dir.'/.'.$es_id.'.webodf.odt';
|
|
||||||
$genesis_url = $paths[0].'/webdav.php'.$genesis_file;
|
|
||||||
$result = array (
|
$result = array (
|
||||||
'es_id' => $es_id,
|
'es_id' => $es_id,
|
||||||
'genesis_url' => $genesis_url
|
'genesis_url' => self::generateGenesis($file_path, $es_id)
|
||||||
);
|
);
|
||||||
Api\Vfs::copy($paths[1], $genesis_file);
|
$this->SESSION_add2Db($es_id, $result['genesis_url']);
|
||||||
$this->SESSION_add2Db($es_id, $genesis_url);
|
|
||||||
}
|
}
|
||||||
$response->data($result);
|
$response->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a genesis file out of given file path and session id
|
||||||
|
*
|
||||||
|
* @param type $file_path file path in webdav format example: egroupware/webdav.php/home/sysop/test.odt
|
||||||
|
* @param type $es_id session id
|
||||||
|
*
|
||||||
|
* @return string returns genesis url
|
||||||
|
*/
|
||||||
|
static function generateGenesis ($file_path, $es_id)
|
||||||
|
{
|
||||||
|
$paths = explode('/webdav.php', $file_path);
|
||||||
|
$dir_parts = explode('/',$paths[1]);
|
||||||
|
array_pop($dir_parts);
|
||||||
|
$dir = join('/', $dir_parts);
|
||||||
|
$genesis_file = $dir.'/.'.$es_id.'.webodf.odt';
|
||||||
|
$genesis_url = $paths[0].'/webdav.php'.$genesis_file;
|
||||||
|
Api\Vfs::copy($paths[1], $genesis_file);
|
||||||
|
return $genesis_url;
|
||||||
|
}
|
||||||
}
|
}
|
@ -162,6 +162,17 @@ class filemanager_collab_bo
|
|||||||
__LINE__,
|
__LINE__,
|
||||||
__FILE__,
|
__FILE__,
|
||||||
'filemanager');
|
'filemanager');
|
||||||
|
$where_query = 'collab_es_id ="'.$es_id.'" AND collab_optype != "AddMember" AND'.
|
||||||
|
' collab_optype != "RemoveMember" AND collab_optype !="AddCursor" AND'.
|
||||||
|
' collab_optype !="RemoveCursor"';
|
||||||
|
// cleanup the op table
|
||||||
|
$this->db->delete(
|
||||||
|
self::OP_TABLE,
|
||||||
|
$where_query,
|
||||||
|
__LINE__,
|
||||||
|
__FILE__,
|
||||||
|
'filemanager'
|
||||||
|
);
|
||||||
return !$query? false: true;
|
return !$query? false: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ app.classes.filemanager = app.classes.filemanager.extend({
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
egw(window).message(egw.lang('Document %1 successfully has been saved.', file_path));
|
egw(window).message(egw.lang('Document %1 successfully has been saved.', file_path));
|
||||||
self.editor.setDocumentModified(false);
|
self.editor.setDocumentModified(false);
|
||||||
egw.json('filemanager.filemanager_collab.ajax_actions',[self.collab_server.es_id, 'save']).sendRequest();
|
egw.json('filemanager.filemanager_collab.ajax_actions',[self.collab_server.es_id, 'save',egw.webserverUrl+'/webdav.php'+file_path]).sendRequest();
|
||||||
},
|
},
|
||||||
error: function () {},
|
error: function () {},
|
||||||
data: blob,
|
data: blob,
|
||||||
@ -268,7 +268,6 @@ app.classes.filemanager = app.classes.filemanager.extend({
|
|||||||
*/
|
*/
|
||||||
editor_delete: function (_egwAction) {
|
editor_delete: function (_egwAction) {
|
||||||
var fullpath = this.et2.getWidgetById('file_path').value;
|
var fullpath = this.et2.getWidgetById('file_path').value;
|
||||||
fullpath = fullpath.split('/webdav.php')[1];
|
|
||||||
var selected = fullpath.split('/');
|
var selected = fullpath.split('/');
|
||||||
selected.pop();
|
selected.pop();
|
||||||
var path = selected.join('/');
|
var path = selected.join('/');
|
||||||
@ -359,7 +358,7 @@ app.classes.filemanager = app.classes.filemanager.extend({
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
egw.lang('All the changes has been discarded and new session created! Save as your local changes if you need them or reload to join new session.'),
|
egw.lang('This session is not valid anymore! Save as your local changes if you need them or reload to join new session.'),
|
||||||
'Delete file',
|
'Delete file',
|
||||||
null,
|
null,
|
||||||
buttons,
|
buttons,
|
||||||
|
Loading…
Reference in New Issue
Block a user