forked from extern/egroupware
* New feature: cross-application document merge in filemanager GUI
This commit is contained in:
parent
f7cc51ad18
commit
3e72371fd7
@ -34,6 +34,12 @@ class filemanager_ui
|
||||
'filemanager_ui::listview' => 'Listview',
|
||||
);
|
||||
public static $views_init = false;
|
||||
|
||||
/**
|
||||
* vfs namespace for document merge properties
|
||||
*
|
||||
*/
|
||||
public static $merge_prop_namespace = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -53,6 +59,7 @@ class filemanager_ui
|
||||
}
|
||||
|
||||
self::init_views();
|
||||
self::$merge_prop_namespace = egw_vfs::DEFAULT_PROP_NAMESPACE.$GLOBALS['egw_info']['flags']['currentapp'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,6 +176,44 @@ class filemanager_ui
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mergeapp property for given path
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $scope='self' (default) or 'parents'
|
||||
* $scope == 'self' query only the given path
|
||||
* $scope == 'parents' query only path parents for property (first parent in hierarchy upwards wins)
|
||||
*
|
||||
* @return string merge application or NULL if no property found
|
||||
*/
|
||||
private static function get_mergeapp($path, $scope='self')
|
||||
{
|
||||
$app = null;
|
||||
switch($scope)
|
||||
{
|
||||
case 'self':
|
||||
$props = egw_vfs::propfind($path, self::$merge_prop_namespace);
|
||||
$app = empty($props) ? null : $props[0]['val'];
|
||||
break;
|
||||
case 'parents':
|
||||
// search for props in parent directories
|
||||
$currentpath = $path;
|
||||
while($dir = egw_vfs::dirname($currentpath))
|
||||
{
|
||||
$props = egw_vfs::propfind($dir, self::$merge_prop_namespace);
|
||||
if(!empty($props))
|
||||
{
|
||||
// found prop in parent directory
|
||||
return $app = $props[0]['val'];
|
||||
}
|
||||
$currentpath = $dir;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main filemanager page
|
||||
@ -1060,6 +1105,25 @@ function force_download(_action, _senders)
|
||||
{
|
||||
$props[] = array('name' => $name, 'val' => $content[$name] ? $content[$name] : null);
|
||||
}
|
||||
elseif ($name == 'mergeapp')
|
||||
{
|
||||
$mergeprop = array(
|
||||
array(
|
||||
'ns' => self::$merge_prop_namespace,
|
||||
'name' => 'mergeapp',
|
||||
'val' => (!empty($content[$name]) ? $content[$name] : null),
|
||||
),
|
||||
);
|
||||
if (egw_vfs::proppatch($path,$mergeprop))
|
||||
{
|
||||
$content['old'][$name] = $content[$name];
|
||||
$msg .= lang('Setting for document merge saved.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg .= lang('Saving setting for document merge failed!');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
|
||||
@ -1223,7 +1287,31 @@ function force_download(_action, _senders)
|
||||
0 => lang('No access'),
|
||||
);
|
||||
}
|
||||
$sel_options['mergeapp']= egw_link::app_list('merge');
|
||||
|
||||
// mergeapp
|
||||
$content['mergeapp'] = self::get_mergeapp($path, 'self');
|
||||
$content['mergeapp_parent'] = self::get_mergeapp($path, 'parents');
|
||||
if(!empty($content['mergeapp']))
|
||||
{
|
||||
$content['mergeapp_effective'] = $content['mergeapp'];
|
||||
}
|
||||
elseif(!empty($content['mergeapp_parent']))
|
||||
{
|
||||
$content['mergeapp_effective'] = $content['mergeapp_parent'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['mergeapp_effective'] = null;
|
||||
}
|
||||
// mergeapp select options
|
||||
$mergeapp_list = egw_link::app_list('merge');
|
||||
$mergeapp_empty = !empty($content['mergeapp_parent'])
|
||||
? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
|
||||
$sel_options['mergeapp'] = array('' => $mergeapp_empty);
|
||||
$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
|
||||
// mergeapp other gui options
|
||||
$content['mergeapp_itempicker_disabled'] = $content['is_dir'] || empty($content['mergeapp_effective']);
|
||||
|
||||
$preserve = $content;
|
||||
if (!isset($preserve['old']))
|
||||
{
|
||||
@ -1233,6 +1321,7 @@ function force_download(_action, _senders)
|
||||
'uid' => $content['uid'],
|
||||
'gid' => $content['gid'],
|
||||
'comment' => (string)$content['comment'],
|
||||
'mergeapp' => $content['mergeapp']
|
||||
);
|
||||
if ($cfs) foreach($cfs as $name => $data)
|
||||
{
|
||||
|
@ -209,9 +209,9 @@
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<row disabled="@mergeapp_itempicker_disabled">
|
||||
<hbox>
|
||||
<itempicker id="itempicker_merge" application="calendar,infolog,projectmanager" action="itempickerDocumentAction" action_label="Merge"/>
|
||||
<itempicker id="itempicker_merge" application="@mergeapp_effective" action="itempickerDocumentAction" action_label="Merge"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
@ -226,13 +226,13 @@
|
||||
<row disabled="@is_dir">
|
||||
<description value="Items of the selected application can be inserted into this document"/>
|
||||
<menulist>
|
||||
<menupopup id="merge[mergeapp]"/>
|
||||
<menupopup id="mergeapp"/>
|
||||
</menulist>
|
||||
</row>
|
||||
<row disabled="!@is_dir">
|
||||
<description value="Items of the selected application can be inserted into files of this directory"/>
|
||||
<menulist>
|
||||
<menupopup id="merge[mergeapp]"/>
|
||||
<menupopup id="mergeapp"/>
|
||||
</menulist>
|
||||
</row>
|
||||
</rows>
|
||||
|
Loading…
Reference in New Issue
Block a user