mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-30 14:40:34 +02:00
* Add a preference so you can choose where merged documents are put
This commit is contained in:
@ -32,6 +32,9 @@ use ZipArchive;
|
||||
*/
|
||||
abstract class Merge
|
||||
{
|
||||
|
||||
const PREF_STORE_LOCATION = "merge_store_path";
|
||||
|
||||
/**
|
||||
* Instance of the addressbook_bo class
|
||||
*
|
||||
@ -2434,19 +2437,20 @@ abstract class Merge
|
||||
{
|
||||
throw new Api\Exception\AssertionFailed("Unable to generate merge file\n" . $result);
|
||||
}
|
||||
// Put it into the vfs using user's configured home dir if writable,
|
||||
// Put it into the vfs using user's preferred directory if writable,
|
||||
// or expected home dir (/home/username) if not
|
||||
$target = $_target = (Vfs::is_writable(Vfs::get_home_dir()) ?
|
||||
Vfs::get_home_dir() :
|
||||
"/home/{$GLOBALS['egw_info']['user']['account_lid']}"
|
||||
) . "/$filename";
|
||||
$target = $document_merge->get_save_path($filename);
|
||||
|
||||
// Make sure we won't overwrite something already there
|
||||
$target = Vfs::make_unique($target);
|
||||
|
||||
copy($result, Vfs::PREFIX . $target);
|
||||
unlink($result);
|
||||
|
||||
// Find out what to do with it
|
||||
$editable_mimes = array();
|
||||
try {
|
||||
try
|
||||
{
|
||||
if(class_exists('EGroupware\\collabora\\Bo') &&
|
||||
$GLOBALS['egw_info']['user']['apps']['collabora'] &&
|
||||
($discovery = \EGroupware\collabora\Bo::discover()) &&
|
||||
@ -2496,7 +2500,7 @@ abstract class Merge
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a filename for the merged file
|
||||
* Generate a filename for the merged file, without extension
|
||||
*
|
||||
* Default is just the name of the template
|
||||
* @return string
|
||||
@ -2506,6 +2510,30 @@ abstract class Merge
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a path where we can save the generated file
|
||||
* Takes into account user preference.
|
||||
*
|
||||
* @param string $filename The name of the generated file, including extension
|
||||
* @return string
|
||||
*/
|
||||
protected function get_save_path($filename) : string
|
||||
{
|
||||
// Default is home directory
|
||||
$target = (Vfs::is_writable(Vfs::get_home_dir()) ?
|
||||
Vfs::get_home_dir() :
|
||||
"/home/{$GLOBALS['egw_info']['user']['account_lid']}"
|
||||
);
|
||||
|
||||
// Check for a configured preferred directory
|
||||
if(($pref = $GLOBALS['egw_info']['user']['preferences']['filemanager'][Merge::PREF_STORE_LOCATION]) && Vfs::is_writable($pref))
|
||||
{
|
||||
$target = $pref;
|
||||
}
|
||||
|
||||
return $target . "/$filename";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all ids for when they try to do 'Select All', then merge into document
|
||||
*
|
||||
|
@ -171,6 +171,13 @@ class filemanager_hooks
|
||||
),
|
||||
);
|
||||
|
||||
$settings[Api\Storage\Merge::PREF_STORE_LOCATION] = array(
|
||||
'type' => 'vfs_dir',
|
||||
'size' => 60,
|
||||
'label' => 'Directory for storing merged documents',
|
||||
'name' => Api\Storage\Merge::PREF_STORE_LOCATION,
|
||||
'help' => lang('When you merge entries into documents, they will be stored here. If no directory is provided, they will be stored in %1', Vfs::get_home_dir())
|
||||
);
|
||||
$settings['default_document'] = array(
|
||||
'type' => 'vfs_file',
|
||||
'size' => 60,
|
||||
|
Reference in New Issue
Block a user