forked from extern/egroupware
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 $action
|
||||
* @param string $file_path
|
||||
*/
|
||||
function ajax_actions ($es_id, $action)
|
||||
function ajax_actions ($es_id, $action, $file_path)
|
||||
{
|
||||
switch ($action)
|
||||
{
|
||||
case 'save':
|
||||
$this->SESSION_Save($es_id);
|
||||
//update genesis file after save happened
|
||||
if ($file_path) self::generateGenesis ($file_path, $es_id);
|
||||
break;
|
||||
case 'delete':
|
||||
$this->SESSION_cleanup($es_id);
|
||||
@ -324,13 +327,8 @@ class filemanager_collab extends filemanager_collab_bo {
|
||||
*/
|
||||
function ajax_getGenesisUrl ($file_path, $_isNew)
|
||||
{
|
||||
|
||||
$result = array();
|
||||
$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();
|
||||
// handle new empty file
|
||||
if ($_isNew)
|
||||
@ -345,6 +343,8 @@ class filemanager_collab extends filemanager_collab_bo {
|
||||
|
||||
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 (
|
||||
'es_id' => $session['es_id'],
|
||||
'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))
|
||||
{
|
||||
$genesis_file = $dir.'/.'.$es_id.'.webodf.odt';
|
||||
$genesis_url = $paths[0].'/webdav.php'.$genesis_file;
|
||||
$result = array (
|
||||
'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, $genesis_url);
|
||||
$this->SESSION_add2Db($es_id, $result['genesis_url']);
|
||||
}
|
||||
$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__,
|
||||
__FILE__,
|
||||
'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;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ app.classes.filemanager = app.classes.filemanager.extend({
|
||||
success: function(data) {
|
||||
egw(window).message(egw.lang('Document %1 successfully has been saved.', file_path));
|
||||
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 () {},
|
||||
data: blob,
|
||||
@ -268,7 +268,6 @@ app.classes.filemanager = app.classes.filemanager.extend({
|
||||
*/
|
||||
editor_delete: function (_egwAction) {
|
||||
var fullpath = this.et2.getWidgetById('file_path').value;
|
||||
fullpath = fullpath.split('/webdav.php')[1];
|
||||
var selected = fullpath.split('/');
|
||||
selected.pop();
|
||||
var path = selected.join('/');
|
||||
@ -359,7 +358,7 @@ app.classes.filemanager = app.classes.filemanager.extend({
|
||||
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',
|
||||
null,
|
||||
buttons,
|
||||
|
Loading…
Reference in New Issue
Block a user