W.I.P. collab editor:

- Fix minor bugs caught by scrutinizer
This commit is contained in:
Hadi Nategh 2016-08-19 17:59:44 +02:00
parent a8268adfb5
commit fcff069f45
3 changed files with 22 additions and 7 deletions

View File

@ -177,7 +177,15 @@ class filemanager_collab extends filemanager_collab_bo {
} }
function is_collabAllowed ($file_path, $_right) /**
* Check if the collaboration is allowed for given file path
*
* @param string $file_path file path
* @param int $_right VFS file access right
*
* @return boolean returns true if allowed
*/
function is_collabAllowed ($file_path, $_right=null)
{ {
$paths = explode('/webdav.php', $file_path); $paths = explode('/webdav.php', $file_path);
$right = $_right ? $_right : Api\Vfs::WRITABLE; $right = $_right ? $_right : Api\Vfs::WRITABLE;
@ -186,11 +194,18 @@ class filemanager_collab extends filemanager_collab_bo {
return $allowed; return $allowed;
} }
/**
* Function to get genesis url by generating a temp genesis temp file
* out of given path, and returnig es_id md5 hash and genesis url to
* client.
*
* @param type $file_path file path
*
*/
function ajax_getGenesisUrl ($file_path) function ajax_getGenesisUrl ($file_path)
{ {
$result = array(); $result = array();
$es_id = md5($file_path); $es_id = md5($file_path);
$paths = explode('/webdav.php', $file_path); $paths = explode('/webdav.php', $file_path);
$dir_parts = explode('/',$paths[1]); $dir_parts = explode('/',$paths[1]);
array_pop($dir_parts); array_pop($dir_parts);
@ -205,7 +220,7 @@ class filemanager_collab extends filemanager_collab_bo {
'genesis_url' => $session['genesis_url'] 'genesis_url' => $session['genesis_url']
); );
} }
else if ($this->is_collabAllowed($file_path)) else if ($this->is_collabAllowed($file_path, Api\Vfs::WRITABLE))
{ {
$genesis_file = $dir.'/.'.$es_id.'.webodf.odt'; $genesis_file = $dir.'/.'.$es_id.'.webodf.odt';
$genesis_url = $paths[0].'/webdav.php'.$genesis_file; $genesis_url = $paths[0].'/webdav.php'.$genesis_file;

View File

@ -1481,7 +1481,7 @@ class filemanager_ui
* *
* @param array $content * @param array $content
*/ */
function editor(array $content=null) function editor($content=null)
{ {
$tmpl = new Etemplate('filemanager.editor'); $tmpl = new Etemplate('filemanager.editor');
$file_path = $_GET['path']; $file_path = $_GET['path'];

View File

@ -233,7 +233,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.', filename[1])); egw(window).message(egw.lang('Document %1 successfully has been saved.', filename[1]));
self.editor.setDocumentModified(false); self.editor.setDocumentModified(false);
egw.json('filemanager.filemanager_collab.ajax_actions',[self.editor_getFilePath(), 'save']).sendRequest(); egw.json('filemanager.filemanager_collab.ajax_actions',[self.collab_server.es_id, 'save']).sendRequest();
}, },
error: function () {}, error: function () {},
data: blob, data: blob,