forked from extern/egroupware
* All apps: symlink files to not yet saved entries were not working
This commit is contained in:
parent
41c89e0f7e
commit
366a940030
@ -178,11 +178,15 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
|
|
||||||
// Filemanager select
|
// Filemanager select
|
||||||
var select_attrs = {
|
var select_attrs = {
|
||||||
method: 'EGroupware\\Api\\Etemplate\\Widget\\Link::link_existing',
|
|
||||||
method_id: function() { return self.options.value.to_app + ':' + self.options.value.to_id;},
|
|
||||||
button_label: egw.lang('Link'),
|
button_label: egw.lang('Link'),
|
||||||
button_caption: ''
|
button_caption: ''
|
||||||
};
|
};
|
||||||
|
// only set server-side callback, if we have a real application-id (not null or array)
|
||||||
|
// otherwise it only gives an error on server-side
|
||||||
|
if (self.options.value.to_id && typeof self.options.value.to_id != 'object') {
|
||||||
|
select_attrs.method = 'EGroupware\\Api\\Etemplate\\Widget\\Link::link_existing';
|
||||||
|
select_attrs.method_id = self.options.value.to_app + ':' + self.options.value.to_id;
|
||||||
|
}
|
||||||
this.vfs_select = et2_createWidget("vfs-select", select_attrs,this);
|
this.vfs_select = et2_createWidget("vfs-select", select_attrs,this);
|
||||||
jQuery(this.vfs_select.getDOMNode()).change( function() {
|
jQuery(this.vfs_select.getDOMNode()).change( function() {
|
||||||
var values = true;
|
var values = true;
|
||||||
|
@ -248,6 +248,11 @@ class Link extends Etemplate\Widget
|
|||||||
public static function link_existing($app_id, $files)
|
public static function link_existing($app_id, $files)
|
||||||
{
|
{
|
||||||
list($app, $id, $dest_file) = explode(':', $app_id);
|
list($app, $id, $dest_file) = explode(':', $app_id);
|
||||||
|
|
||||||
|
if (empty($app_id) || empty($id))
|
||||||
|
{
|
||||||
|
return; // cant do anything
|
||||||
|
}
|
||||||
if($id && $dest_file && trim($dest_file) !== '')
|
if($id && $dest_file && trim($dest_file) !== '')
|
||||||
{
|
{
|
||||||
$id .= "/$dest_file";
|
$id .= "/$dest_file";
|
||||||
|
@ -1197,26 +1197,27 @@ class Link extends Link\Storage
|
|||||||
* @param string $app appname to link the file to
|
* @param string $app appname to link the file to
|
||||||
* @param string $id id in $app
|
* @param string $id id in $app
|
||||||
* @param string $file VFS path to link to
|
* @param string $file VFS path to link to
|
||||||
* @param string $comment ='' comment to add to the link
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
static function link_file($app,$id,$file)//,$comment='')
|
static function link_file($app,$id,$file)
|
||||||
{
|
{
|
||||||
// Don't try to link into app dir if there is no id
|
// Don't try to link into app dir if there is no id
|
||||||
if(!$id) return;
|
if(!$id) return;
|
||||||
|
|
||||||
$app_path = self::vfs_path($app,$id);
|
if (!Vfs::stat($file))
|
||||||
$ok = true;
|
|
||||||
if (Vfs::file_exists($app_path) || ($ok = Vfs::mkdir($app_path,0,true)))
|
|
||||||
{
|
{
|
||||||
if (!Vfs::stat($file))
|
error_log(__METHOD__. ' (Link target ' . Vfs::decodePath($file) . ' not found!');
|
||||||
{
|
return false;
|
||||||
error_log(__METHOD__. ' (Link target ' . Vfs::decodePath($file) . ' not found!');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = Vfs::concat($app_path,Vfs::basename($file));
|
$entry_dir = self::vfs_path($app, $id);
|
||||||
return Vfs::symlink($file,$link);
|
if (!file_exists($entry_dir) && !mkdir($entry_dir, 0, true))
|
||||||
|
{
|
||||||
|
error_log(__METHOD__."($app,$id,".array2string($file).") Can't mkdir $entry_dir!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Vfs::symlink($file, Vfs::concat($entry_dir, Vfs::basename($file)));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* deletes a single or all attached files of an entry (for all there's no acl check, as the entry probably not exists any more!)
|
* deletes a single or all attached files of an entry (for all there's no acl check, as the entry probably not exists any more!)
|
||||||
|
@ -1817,8 +1817,9 @@ class infolog_ui
|
|||||||
{
|
{
|
||||||
//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
|
//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
|
||||||
Link::link('infolog',$info_id,$content['link_to']['to_id']);
|
Link::link('infolog',$info_id,$content['link_to']['to_id']);
|
||||||
$content['link_to']['to_id'] = $info_id;
|
|
||||||
}
|
}
|
||||||
|
$content['link_to']['to_id'] = $info_id;
|
||||||
|
|
||||||
if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary
|
if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary
|
||||||
{
|
{
|
||||||
list($app,$id) = explode(':',$info_link_id);
|
list($app,$id) = explode(':',$info_link_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user