WIP of background & logo image upload into instance dir:

- Generate url for anon_images.php
This commit is contained in:
Hadi Nategh 2017-04-28 12:40:33 +02:00
parent 47df7828ce
commit c55e0bdae3
2 changed files with 9 additions and 9 deletions

View File

@ -20,28 +20,28 @@ class admin_config
var $public_functions = array('index' => True);
/**
* Upload function to store files into instance files_dir
* Upload function to store anonymous images into instance files_dir/anon_images
*
* @param type $file file info array
* @param type $dir directory to store file
*
*/
function ajax_upload ($file, $dir = null)
function ajax_upload_anon_images ($file)
{
$files_dir = $dir ? $dir : $GLOBALS['egw_info']['server']['files_dir'].'/unknown_images';
$path = $GLOBALS['egw_info']['server']['files_dir'].'/anon-images';
$success = false;
$response = Api\Json\Response::get();
if (is_array($file) && is_writable(dirname($files_dir)))
if (is_array($file) && is_writable(dirname($path)))
{
if (!is_dir($files_dir)) mkdir ($files_dir);
if (!is_dir($path)) mkdir ($path);
$tmp_file = array_keys($file);
$destination = $files_dir.'/'.$file[$tmp_file[0]]['name'];
$destination = $path.'/'.$file[$tmp_file[0]]['name'];
$success = rename($GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp_file[0],$destination);
}
if ($success)
{
$response->data(array(
'path' => $destination
'path' => $GLOBALS['egw_info']['server']['webserver_url'].'/api/anon_images.php?src='.$file[$tmp_file[0]]['name']
));
}
else

View File

@ -54,7 +54,7 @@
<description value="Enter the URL or filename (in api/templates/default/images) of your logo" label="%s:"/>
<hbox>
<textbox id="newsettings[login_logo_file]" width="70%"/>
<file onchange="egw.json('admin.admin_config.ajax_upload',[widget.get_value()], function(_data){widget._parent._children[0].set_value(_data.path)}).sendRequest()" width="30%" label="upload"/>
<file onchange="egw.json('admin.admin_config.ajax_upload_anon_images',[widget.get_value()], function(_data){widget._parent._children[0].set_value(_data.path)}).sendRequest()" width="30%" label="upload"/>
</hbox>
</row>
<row>
@ -69,7 +69,7 @@
<description value="Enter the URL or filename (in api/templates/default/images) of your background image" label="%s:"/>
<hbox>
<textbox id="newsettings[login_background_file]" width="70%"/>
<file width="30%" label="upload" onchange="egw.json('admin.admin_config.ajax_upload',[widget.get_value()], function(_data){widget._parent._children[0].set_value(_data.path)}).sendRequest()"/>
<file width="30%" label="upload" onchange="egw.json('admin.admin_config.ajax_upload_anon_images',[widget.get_value()], function(_data){widget._parent._children[0].set_value(_data.path)}).sendRequest()"/>
</hbox>
</row>
<row>