mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-24 15:49:06 +01:00
Move VFS widget file handling from Etemplate/Widget/Customfields to Storage/Customfields, to avoid errors with CalDAV/CardDAV not being able to find Etemplate/Widget/Customfields
This commit is contained in:
parent
944718daaa
commit
8d7a9b7284
@ -417,58 +417,4 @@ class Customfields extends Transformer
|
||||
//error_log(__METHOD__."() $form_name $field: ".array2string($value).' --> '.array2string($value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any uploaded files that weren't dealt with immediately when uploaded.
|
||||
* This usually happens for new entries, where we don't have the entry's ID
|
||||
* to properly file it in the VFS. Files are stored temporarily until we
|
||||
* have the ID, then here we move the files to their proper location.
|
||||
*
|
||||
* @staticvar array $_customfields List of custom field data, kept to avoid
|
||||
* loading it multiple times if called again.
|
||||
*
|
||||
* @param string $app Current application
|
||||
* @param string $entry_id Application ID of the new entry
|
||||
* @param Array $values Array of entry data, including custom fields.
|
||||
* File information from the VFS widget (via self::validate()) will be found &
|
||||
* dealt with. Successful or not, the value is cleared to avoid trying to insert it into
|
||||
* the database, which would generate errors.
|
||||
* @param Array $customfields Pass the custom field list if you have it to avoid loading it again
|
||||
*/
|
||||
public static function handle_files($app, $entry_id, &$values, &$customfields = array())
|
||||
{
|
||||
if(!is_array($values) || !$entry_id) return;
|
||||
|
||||
if(!$customfields)
|
||||
{
|
||||
static $_customfields = array();
|
||||
if(!$_customfields[$app])
|
||||
{
|
||||
$_customfields[$app] = Api\Storage\Customfields::get($app);
|
||||
}
|
||||
$customfields = $_customfields[$app];
|
||||
}
|
||||
foreach ($customfields as $field_name => $field)
|
||||
{
|
||||
if($field['type'] == 'filemanager')
|
||||
{
|
||||
$value =& $values[static::$prefix.$field_name];
|
||||
static::handle_file($entry_id, $field, $value);
|
||||
unset($values[static::$prefix.$field_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function handle_file($entry_id, $field, $value)
|
||||
{
|
||||
$path = Vfs::get_vfs_path($field['app'].":$entry_id:".$field['label']);
|
||||
if($path)
|
||||
{
|
||||
foreach($value as $file)
|
||||
{
|
||||
$file['tmp_name'] = Api\Vfs::PREFIX.$file['path'];
|
||||
Vfs::store_file($path, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ class Storage extends Storage\Base
|
||||
{
|
||||
$id = isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]];
|
||||
|
||||
\EGroupware\Api\Etemplate\Widget\Customfields::handle_files($this->app, $id, $data, $this->customfields);
|
||||
\EGroupware\Api\Storage\Customfields::handle_files($this->app, $id, $data, $this->customfields);
|
||||
|
||||
foreach (array_keys((array)$this->customfields) as $name)
|
||||
{
|
||||
|
@ -544,6 +544,59 @@ class Customfields implements \IteratorAggregate
|
||||
self::$db = $GLOBALS['egw_setup']->db;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any uploaded files that weren't dealt with immediately when uploaded.
|
||||
* This usually happens for new entries, where we don't have the entry's ID
|
||||
* to properly file it in the VFS. Files are stored temporarily until we
|
||||
* have the ID, then here we move the files to their proper location.
|
||||
*
|
||||
* @staticvar array $_customfields List of custom field data, kept to avoid
|
||||
* loading it multiple times if called again.
|
||||
*
|
||||
* @param string $app Current application
|
||||
* @param string $entry_id Application ID of the new entry
|
||||
* @param Array $values Array of entry data, including custom fields.
|
||||
* File information from the VFS widget (via self::validate()) will be found &
|
||||
* dealt with. Successful or not, the value is cleared to avoid trying to insert it into
|
||||
* the database, which would generate errors.
|
||||
* @param Array $customfields Pass the custom field list if you have it to avoid loading it again
|
||||
*/
|
||||
public static function handle_files($app, $entry_id, &$values, &$customfields = array())
|
||||
{
|
||||
if(!is_array($values) || !$entry_id) return;
|
||||
|
||||
if(!$customfields)
|
||||
{
|
||||
static $_customfields = array();
|
||||
if(!$_customfields[$app])
|
||||
{
|
||||
$_customfields[$app] = Api\Storage\Customfields::get($app);
|
||||
}
|
||||
$customfields = $_customfields[$app];
|
||||
}
|
||||
foreach ($customfields as $field_name => $field)
|
||||
{
|
||||
if($field['type'] == 'filemanager' && $value =& $values[Api\Storage::CF_PREFIX.$field_name])
|
||||
{
|
||||
static::handle_file($entry_id, $field, $value);
|
||||
unset($values[Api\Storage::CF_PREFIX.$field_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function handle_file($entry_id, $field, $value)
|
||||
{
|
||||
$path = Api\Etemplate\Widget\Vfs::get_vfs_path($field['app'].":$entry_id:".$field['label']);
|
||||
if($path)
|
||||
{
|
||||
foreach($value as $file)
|
||||
{
|
||||
$file['tmp_name'] = Api\Vfs::PREFIX.$file['path'];
|
||||
Api\Etemplate\Widget\Vfs::store_file($path, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Customfields::init_static();
|
||||
|
@ -1632,7 +1632,7 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
$this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since);
|
||||
}
|
||||
// Custom fields
|
||||
Api\Etemplate\Widget\Customfields::handle_files('calendar', $cal_id, $event);
|
||||
Api\Storage\Customfields::handle_files('calendar', $cal_id, $event);
|
||||
|
||||
foreach($event as $name => $value)
|
||||
{
|
||||
|
@ -632,7 +632,7 @@ class infolog_so
|
||||
$to_delete = array();
|
||||
|
||||
// Deal with files in new entries
|
||||
Api\Etemplate\Widget\Customfields::handle_files('infolog',$info_id,$values);
|
||||
Api\Storage\Customfields::handle_files('infolog',$info_id,$values);
|
||||
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user