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

@ -176,8 +176,16 @@ 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);
$right = $_right ? $_right : Api\Vfs::WRITABLE;
@ -186,11 +194,18 @@ class filemanager_collab extends filemanager_collab_bo {
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)
{
$result = array();
$es_id = md5($file_path);
$paths = explode('/webdav.php', $file_path);
$dir_parts = explode('/',$paths[1]);
array_pop($dir_parts);
@ -205,7 +220,7 @@ class filemanager_collab extends filemanager_collab_bo {
'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_url = $paths[0].'/webdav.php'.$genesis_file;

View File

@ -1481,7 +1481,7 @@ class filemanager_ui
*
* @param array $content
*/
function editor(array $content=null)
function editor($content=null)
{
$tmpl = new Etemplate('filemanager.editor');
$file_path = $_GET['path'];
@ -1500,7 +1500,7 @@ class filemanager_ui
$content['file_path'] = $file_path;
}
}
$actions = self::getActions_edit();
if (!Api\Vfs::check_access($paths[1], Api\Vfs::WRITABLE))
{

View File

@ -233,7 +233,7 @@ app.classes.filemanager = app.classes.filemanager.extend({
success: function(data) {
egw(window).message(egw.lang('Document %1 successfully has been saved.', filename[1]));
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 () {},
data: blob,