#PHRAS-223 #time 6h

This commit is contained in:
Jean-Yves Gaulier
2015-01-28 18:44:18 +01:00
parent 0488091c4b
commit b149483d28
3 changed files with 123 additions and 109 deletions

View File

@@ -140,6 +140,8 @@ class Export implements ControllerProviderInterface
}
$success = false;
$msg = _('Error while connecting to FTP');
try {
$ftpClient = $app['phraseanet.ftp.client']($request->request->get('addr', ''), 21, 90, !!$request->request->get('ssl'));
$ftpClient->login($request->request->get('login', ''), $request->request->get('pwd', ''));
@@ -147,7 +149,6 @@ class Export implements ControllerProviderInterface
$msg = _('Connection to FTP succeed');
$success = true;
} catch (\Exception $e) {
$msg = sprintf(_('Error while connecting to FTP'));
}
return $app->json(array(

View File

@@ -34,15 +34,21 @@ class ftpclient
throw new Exception('Nom d\'hote incorrect ' . $host);
}
try {
if ($ssl === true) {
if (($this->connexion = ftp_ssl_connect($host, $port, $timeout)) === false) {
if (($this->connexion = @ftp_ssl_connect($host, $port, $timeout)) === false) {
throw new Exception('Impossible de se connecter au serveur FTP en SSL');
}
} else {
if (($this->connexion = ftp_connect($host, $port, $timeout)) === false) {
if (($this->connexion = @ftp_connect($host, $port, $timeout)) === false) {
throw new Exception('Impossible de se connecter au serveur FTP ' . $host . ":$port $timeout");
}
}
}
catch(\Exception $e) {
// any unknown pb
throw $e;
}
return $this;
}

View File

@@ -2,6 +2,7 @@
{% macro print_ftp_form(datas) %}
<div class="ftp_form ftp_form_{{datas.usr_id}}">
<form id="ftp_user_{{datas.usr_id}}" action="{{ path('export_ftp') }}" method="post" target="_blank" class="form-horizontal" style="text-align: left;">
<div class="control-group">
<label class="control-label" for="addrFTP_{{datas.usr_id}}">{% trans 'phraseanet:: adresse' %} ftp://</label>
<div class="controls">
@@ -57,6 +58,7 @@
<input type="checkbox" class=ftp_logfile_check" name="logfile" id="logfile_{{datas.usr_id}}" value="1" />
</div>
</div>
</form>
</div>
{% endmacro %}
@@ -415,9 +417,6 @@
<div id="ftp">
<div style="padding:10px; text-align: center;">
<h4>{% trans 'export:: FTP' %}</h4>
<form action="{{ path('export_ftp') }}" method="post" target="_blank" class="form-horizontal" style="text-align: left;">
<input type="hidden" name="lst" value="{{lst}}"/>
<input type="hidden" name="ssttid" value="{{ssttid}}"/>
<div class="control-group">
<label class="control-label" for="ftp_form_selector">
{% trans 'phraseanet:: prereglages'%}
@@ -437,6 +436,9 @@
{% endfor %}
</div>
</div>
<form id="ftp_joined" class="form-horizontal" style="text-align: left;">
<input type="hidden" name="lst" value="{{lst}}"/>
<input type="hidden" name="ssttid" value="{{ssttid}}"/>
<div>
<p>{% trans 'export::mail: fichiers joint' %}</p>
{% for name, values in download.get_display_ftp() %}
@@ -485,6 +487,7 @@
</label>
</div>
{% endif %}
</form>
<div class="buttons_line">
<button type="button" class="tryftp_button btn btn-inverse">{% trans 'boutton::essayer'%}</button>
<img class="tryftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
@@ -492,7 +495,7 @@
<img class="ftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
<button type="button" class="close_button btn btn-inverse">{% trans 'boutton::annuler'%}</button>
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
@@ -734,18 +737,21 @@
return false;
}
$('#ftp .ftp_button_loader').css('visibility','visible');
$('#ftp .ftp_button_loader').show();
$('#ftp .ftp_form:hidden').remove();
var $this = $(this);
var options = $('#ftp form').serialize();
var options_addr = $('#ftp_form_stock form:visible').serialize();
var options_join = $('#ftp_joined').serialize();
$this.attr('disabled','disabled');
$.post("../prod/export/ftp/"
, options
, options_addr + '&' + options_join
, function(data){
$this.removeAttr('disabled');
$('#ftp .ftp_button_loader').css('visibility','hidden');
$('#ftp .ftp_button_loader').hide();
if(data.success) {
humane.info(data.message);
@@ -770,9 +776,10 @@
$('#ftp .tryftp_button_loader').css('visibility','visible');
var $this = $(this);
$this.attr('disabled','disabled');
var options = $('#ftp form').serialize();
var options_addr = $('#ftp_form_stock form:visible').serialize();
$.post("../prod/export/ftp/test/"
, options
, options_addr // no need to include 'ftp_joined' checkboxes to test ftp
, function(data){
$('#ftp .tryftp_button_loader').css('visibility','hidden');
@@ -782,7 +789,7 @@
title : data.success ? '{% trans "Success !" %}' : '{% trans "Warning !" %}'
};
p4.Dialog.Create(options, 2).setContent(data.message);
p4.Dialog.Create(options, 3).setContent(data.message);
$this.removeAttr('disabled');