mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
Add FtpCredentials entity
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Alchemy\Phrasea\Command\Developer;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Core\Provider\ORMServiceProvider;
|
||||
use Doctrine\ORM\Tools\Setup;
|
||||
use Doctrine\ORM\Configuration as ORMConfiguration;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
@@ -33,34 +34,19 @@ class RegenerateSqliteDb extends Command
|
||||
$source = __DIR__ . '/../../../../../tests/db-ref.sqlite';
|
||||
$target = __DIR__ . '/../../../../../tests/db-ref.sqlite.bkp';
|
||||
|
||||
if (is_file($source)) {
|
||||
$fs->rename($source, $target);
|
||||
}
|
||||
|
||||
try {
|
||||
$dbParams = $this->container['phraseanet.configuration']->getTestConnectionParameters();
|
||||
$dbParams['path'] = $source;
|
||||
|
||||
$config = new ORMConfiguration();
|
||||
AnnotationRegistry::registerFile(
|
||||
$this->container['root.path'].'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
|
||||
);
|
||||
$this->container->register(new ORMServiceProvider());
|
||||
$this->container['EM.dbal-conf'] = $dbParams;
|
||||
|
||||
$annotationReader = new AnnotationReader();
|
||||
$driverChain = new DriverChain();
|
||||
$annotationDriver = new AnnotationDriver(
|
||||
$annotationReader,
|
||||
array($this->container['root.path'].'/lib/Doctrine/Entities')
|
||||
);
|
||||
$driverChain->addDriver($annotationDriver, 'Entities');
|
||||
|
||||
$config->setAutoGenerateProxyClasses(true);
|
||||
$config->setMetadataDriverImpl($driverChain);
|
||||
$config->setProxyDir($this->container['root.path'] . '/lib/Doctrine/Proxies');
|
||||
$config->setProxyNamespace('Proxies');
|
||||
|
||||
$em = EntityManager::create($dbParams, $config, new EventManager());
|
||||
|
||||
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$metadatas = $this->container['EM']->getMetadataFactory()->getAllMetadata();
|
||||
$schemaTool = new SchemaTool($this->container['EM']);
|
||||
$schemaTool->createSchema($metadatas);
|
||||
} catch (\Exception $e) {
|
||||
$fs->rename($target, $source);
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Helper\User as UserHelper;
|
||||
use Entities\FtpCredential;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -797,23 +798,23 @@ class Users implements ControllerProviderInterface
|
||||
&& false === \User_Adapter::get_usr_id_from_email($app, $curUser['usr_mail'])) {
|
||||
$NewUser = \User_Adapter::create($app, $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false);
|
||||
|
||||
if (isset($curUser['defaultftpdatasent'])) {
|
||||
$NewUser->set_defaultftpdatas($curUser['defaultftpdatasent']);
|
||||
}
|
||||
$ftpCredential = new FtpCredential();
|
||||
$ftpCredential->setUsrId($NewUser->get_id());
|
||||
|
||||
if (isset($curUser['activeFTP'])) {
|
||||
$NewUser->set_activeftp((int) ($curUser['activeFTP']));
|
||||
$ftpCredential->setActive((int) $curUser['activeFTP']);
|
||||
}
|
||||
if (isset($curUser['addrFTP'])) {
|
||||
$NewUser->set_ftp_address($curUser['addrFTP']);
|
||||
$ftpCredential->setAddress((string) $curUser['addrFTP']);
|
||||
}
|
||||
if (isset($curUser['passifFTP'])) {
|
||||
$NewUser->set_ftp_passif((int) ($curUser['passifFTP']));
|
||||
$ftpCredential->setPassive((int) $curUser['passifFTP']);
|
||||
}
|
||||
if (isset($curUser['destFTP'])) {
|
||||
$NewUser->set_ftp_dir($curUser['destFTP']);
|
||||
$ftpCredential->setReceptionFolder($curUser['destFTP']);
|
||||
}
|
||||
if (isset($curUser['prefixFTPfolder'])) {
|
||||
$NewUser->set_ftp_dir_prefix($curUser['prefixFTPfolder']);
|
||||
$ftpCredential->setRepositoryPrefixName($curUser['prefixFTPfolder']);
|
||||
}
|
||||
if (isset($curUser['usr_prenom'])) {
|
||||
$NewUser->set_firstname($curUser['usr_prenom']);
|
||||
|
@@ -168,7 +168,7 @@ class Export implements ControllerProviderInterface
|
||||
{
|
||||
$download = new \set_exportftp($app, $request->request->get('lst'), $request->request->get('ssttid'));
|
||||
|
||||
$mandatoryParameters = array('addr', 'login', 'destfolder', 'NAMMKDFOLD', 'obj');
|
||||
$mandatoryParameters = array('address', 'login', 'dest_folder', 'prefix_folder', 'obj');
|
||||
|
||||
foreach ($mandatoryParameters as $parameter) {
|
||||
if (!$request->request->get($parameter)) {
|
||||
@@ -194,14 +194,14 @@ class Export implements ControllerProviderInterface
|
||||
|
||||
$download->export_ftp(
|
||||
$request->request->get('user_dest'),
|
||||
$request->request->get('addr'),
|
||||
$request->request->get('address'),
|
||||
$request->request->get('login'),
|
||||
$request->request->get('pwd', ''),
|
||||
$request->request->get('password', ''),
|
||||
$request->request->get('ssl'),
|
||||
$request->request->get('nbretry'),
|
||||
$request->request->get('passif'),
|
||||
$request->request->get('destfolder'),
|
||||
$request->request->get('NAMMKDFOLD'),
|
||||
$request->request->get('max_retry'),
|
||||
$request->request->get('passive'),
|
||||
$request->request->get('dest_folder'),
|
||||
$request->request->get('prefix_folder'),
|
||||
$request->request->get('logfile')
|
||||
);
|
||||
|
||||
|
@@ -17,6 +17,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Alchemy\Phrasea\Notification\Receiver;
|
||||
use Alchemy\Phrasea\Notification\Mail\MailRequestEmailUpdate;
|
||||
use Alchemy\Phrasea\Form\Login\PhraseaRenewPasswordForm;
|
||||
use Entities\FtpCredential;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
@@ -363,7 +364,7 @@ class Account implements ControllerProviderInterface
|
||||
'form_company',
|
||||
'form_activity',
|
||||
'form_geonameid',
|
||||
'form_addrFTP',
|
||||
'form_addressFTP',
|
||||
'form_loginFTP',
|
||||
'form_pwdFTP',
|
||||
'form_destFTP',
|
||||
@@ -372,26 +373,11 @@ class Account implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
if (0 === count(array_diff($accountFields, array_keys($request->request->all())))) {
|
||||
$defaultDatas = 0;
|
||||
|
||||
if ($datas = (array) $request->request->get("form_defaultdataFTP", array())) {
|
||||
if (in_array('document', $datas)) {
|
||||
$defaultDatas += 4;
|
||||
}
|
||||
|
||||
if (in_array('preview', $datas)) {
|
||||
$defaultDatas += 2;
|
||||
}
|
||||
|
||||
if (in_array('caption', $datas)) {
|
||||
$defaultDatas += 1;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$app['phraseanet.appbox']->get_connection()->beginTransaction();
|
||||
|
||||
$app['authentication']->getUser()->set_gender($request->request->get("form_gender"))
|
||||
$app['authentication']->getUser()
|
||||
->set_gender($request->request->get("form_gender"))
|
||||
->set_firstname($request->request->get("form_firstname"))
|
||||
->set_lastname($request->request->get("form_lastname"))
|
||||
->set_address($request->request->get("form_address"))
|
||||
@@ -402,18 +388,30 @@ class Account implements ControllerProviderInterface
|
||||
->set_company($request->request->get("form_company"))
|
||||
->set_position($request->request->get("form_function"))
|
||||
->set_geonameid($request->request->get("form_geonameid"))
|
||||
->set_mail_notifications((bool) $request->request->get("mail_notifications"))
|
||||
->set_activeftp($request->request->get("form_activeFTP"))
|
||||
->set_ftp_address($request->request->get("form_addrFTP"))
|
||||
->set_ftp_login($request->request->get("form_loginFTP"))
|
||||
->set_ftp_password($request->request->get("form_pwdFTP"))
|
||||
->set_ftp_passif($request->request->get("form_passifFTP"))
|
||||
->set_ftp_dir($request->request->get("form_destFTP"))
|
||||
->set_ftp_dir_prefix($request->request->get("form_prefixFTPfolder"))
|
||||
->set_defaultftpdatas($defaultDatas);
|
||||
->set_mail_notifications((bool) $request->request->get("mail_notifications"));
|
||||
|
||||
/* @var $ftpCredential \Entities\FtpCredential */
|
||||
$ftpCredential = $app['EM']->getRepository('Entities\FtpCredential')->findOneBy(array(
|
||||
'usrId' => $app['authentication']->getUser()->get_id()
|
||||
));
|
||||
|
||||
if (null === $ftpCredential) {
|
||||
$ftpCredential = new \Entities\FtpCredential();
|
||||
$ftpCredential->setUsrId($app['authentication']->getUser()->get_id());
|
||||
}
|
||||
|
||||
$ftpCredential->setActive($request->request->get("form_activeFTP"));
|
||||
$ftpCredential->setAddress($request->request->get("form_addressFTP"));
|
||||
$ftpCredential->setLogin($request->request->get("form_loginFTP"));
|
||||
$ftpCredential->setPassword($request->request->get("form_pwdFTP"));
|
||||
$ftpCredential->setPassive($request->request->get("form_passifFTP"));
|
||||
$ftpCredential->setReceptionFolder($request->request->get("form_destFTP"));
|
||||
$ftpCredential->setRepositoryPrefixName($request->request->get("form_prefixFTPfolder"));
|
||||
|
||||
$app->addFlash('success', _('login::notification: Changements enregistres'));
|
||||
$app['phraseanet.appbox']->get_connection()->commit();
|
||||
$app['EM']->persist($ftpCredential);
|
||||
$app['EM']->flush();
|
||||
$app->addFlash('success', _('login::notification: Changements enregistres'));
|
||||
} catch (Exception $e) {
|
||||
$app->addFlash('error', _('forms::erreurs lors de l\'enregistrement des modifications'));
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
|
@@ -44,24 +44,11 @@ class ORMServiceProvider implements ServiceProviderInterface
|
||||
return new MonologSQLLogger($logger, 'yaml');
|
||||
});
|
||||
|
||||
$app['EM'] = $app->share(function(Application $app) {
|
||||
|
||||
$config = new ORMConfiguration();
|
||||
|
||||
if ($app['debug']) {
|
||||
$config->setSQLLogger($app['EM.sql-logger']);
|
||||
}
|
||||
|
||||
$app['EM.driver'] = $app->share(function(Application $app) {
|
||||
AnnotationRegistry::registerFile(
|
||||
$app['root.path'].'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
|
||||
);
|
||||
|
||||
$opCodeCacheType = $app['phraseanet.configuration']['main']['opcodecache']['type'];
|
||||
$opCodeCacheOptions = $app['phraseanet.configuration']['main']['opcodecache']['options'];
|
||||
|
||||
$cacheType = $app['phraseanet.configuration']['main']['cache']['type'];
|
||||
$cacheOptions = $app['phraseanet.configuration']['main']['cache']['options'];
|
||||
|
||||
$annotationReader = new AnnotationReader();
|
||||
$fileCacheReader = new FileCacheReader(
|
||||
$annotationReader,
|
||||
@@ -82,35 +69,68 @@ class ORMServiceProvider implements ServiceProviderInterface
|
||||
|
||||
$driverChain->addDriver($annotationDriver, 'Entities');
|
||||
|
||||
return $driverChain;
|
||||
});
|
||||
|
||||
$app['EM.config'] = $app->share(function(Application $app) {
|
||||
$config = new ORMConfiguration();
|
||||
|
||||
if ($app['debug']) {
|
||||
$config->setSQLLogger($app['EM.sql-logger']);
|
||||
}
|
||||
|
||||
$config->setMetadataCacheImpl($app['phraseanet.cache-service']->factory(
|
||||
'ORMmetadata', $opCodeCacheType, $opCodeCacheOptions
|
||||
'ORMmetadata', $app['EM.opcode-cache-type'], $app['EM.opcode-cache-options']
|
||||
));
|
||||
|
||||
$config->setQueryCacheImpl($app['phraseanet.cache-service']->factory(
|
||||
'ORMquery', $opCodeCacheType, $opCodeCacheOptions
|
||||
'ORMquery', $app['EM.opcode-cache-type'], $app['EM.opcode-cache-options']
|
||||
));
|
||||
$config->setResultCacheImpl($app['phraseanet.cache-service']->factory(
|
||||
'ORMresult', $cacheType, $cacheOptions
|
||||
'ORMresult', $app['EM.cache-type'], $app['EM.cache-options']
|
||||
));
|
||||
|
||||
$config->setAutoGenerateProxyClasses($app['debug']);
|
||||
|
||||
$config->setMetadataDriverImpl($driverChain);
|
||||
$config->setMetadataDriverImpl($app['EM.driver']);
|
||||
|
||||
$config->setProxyDir($app['root.path'] . '/lib/Doctrine/Proxies');
|
||||
$config->setProxyNamespace('Proxies');
|
||||
|
||||
if ('test' === $app->getEnvironment()) {
|
||||
$dbalConf = $app['phraseanet.configuration']['main']['database-test'];
|
||||
} else {
|
||||
$dbalConf = $app['phraseanet.configuration']['main']['database'];
|
||||
}
|
||||
return $config;
|
||||
});
|
||||
|
||||
$app['EM.opcode-cache-type'] = $app->share(function(Application $app) {
|
||||
return $app['phraseanet.configuration']['main']['opcodecache']['type'];
|
||||
});
|
||||
$app['EM.opcode-cache-options'] = $app->share(function(Application $app) {
|
||||
return $app['phraseanet.configuration']['main']['opcodecache']['options'];
|
||||
});
|
||||
|
||||
$app['EM.cache-type'] = $app->share(function(Application $app) {
|
||||
return $app['phraseanet.configuration']['main']['cache']['type'];
|
||||
});
|
||||
$app['EM.cache-options'] = $app->share(function(Application $app) {
|
||||
return $app['phraseanet.configuration']['main']['cache']['options'];
|
||||
});
|
||||
$app['EM.events-manager'] = $app->share(function(Application $app) {
|
||||
$evm = new EventManager();
|
||||
$evm->addEventSubscriber(new TimestampableListener());
|
||||
|
||||
return $evm;
|
||||
});
|
||||
|
||||
$app['EM.dbal-conf'] = $app->share(function(Application $app) {
|
||||
if ('test' === $app->getEnvironment()) {
|
||||
return $app['phraseanet.configuration']['main']['database-test'];
|
||||
}
|
||||
|
||||
return $app['phraseanet.configuration']['main']['database'];
|
||||
});
|
||||
|
||||
$app['EM'] = $app->share(function(Application $app) {
|
||||
try {
|
||||
$em = EntityManager::create($dbalConf, $config, $evm);
|
||||
$em = EntityManager::create($app['EM.dbal-conf'], $app['EM.config'], $app['EM.events-manager']);
|
||||
} catch (\Exception $e) {
|
||||
throw new RuntimeException("Unable to create database connection", $e->getCode(), $e);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
protected static $number = '3.9.0.a0';
|
||||
protected static $number = '3.9.0.a1';
|
||||
protected static $name = 'Diplodocus';
|
||||
|
||||
public static function getNumber()
|
||||
|
270
lib/Doctrine/Entities/FtpCredential.php
Normal file
270
lib/Doctrine/Entities/FtpCredential.php
Normal file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Entities;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="FtpCredential")
|
||||
* @ORM\Entity(repositoryClass="Repositories\FtpCredentialRepository")
|
||||
*/
|
||||
class FtpCredential
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $usrId;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $active = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $address = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $login = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128)
|
||||
*/
|
||||
private $password = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128, name="reception_folder")
|
||||
*/
|
||||
private $receptionFolder = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128, name="repository_prefix_name")
|
||||
*/
|
||||
private $repositoryPrefixName = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $passive = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="tls")
|
||||
*/
|
||||
private $ssl = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", name="max_retry")
|
||||
*/
|
||||
private $maxRetry = 5;
|
||||
|
||||
/**
|
||||
* @Gedmo\Timestampable(on="update")
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $updated;
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \User_Adapter
|
||||
*/
|
||||
public function getUser(Application $app)
|
||||
{
|
||||
return \User_Adapter::getInstance($this->usrId, $app);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \User_Adapter
|
||||
*/
|
||||
public function getUsrId()
|
||||
{
|
||||
return $this->usrId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $usrId
|
||||
*/
|
||||
public function setUsrId($usrId)
|
||||
{
|
||||
$this->usrId = $usrId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
*/
|
||||
public function setActive($active)
|
||||
{
|
||||
$this->active = (Boolean) $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
public function setAddress($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $login
|
||||
*/
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReceptionFolder()
|
||||
{
|
||||
return $this->receptionFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $receptionFolder
|
||||
*/
|
||||
public function setReceptionFolder($receptionFolder)
|
||||
{
|
||||
$this->receptionFolder = $receptionFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRepositoryPrefixName()
|
||||
{
|
||||
return $this->repositoryPrefixName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $repositoryPrefixName
|
||||
*/
|
||||
public function setRepositoryPrefixName($repositoryPrefixName)
|
||||
{
|
||||
$this->repositoryPrefixName = $repositoryPrefixName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPassive()
|
||||
{
|
||||
return $this->passive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $passive
|
||||
*/
|
||||
public function setPassive($passive)
|
||||
{
|
||||
$this->passive = (Boolean) $passive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSsl()
|
||||
{
|
||||
return $this->ssl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ssl
|
||||
*/
|
||||
public function setSsl($ssl)
|
||||
{
|
||||
$this->ssl = (Boolean) $ssl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getMaxRetry()
|
||||
{
|
||||
return $this->maxRetry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $maxRetry
|
||||
*/
|
||||
public function setMaxRetry($maxRetry)
|
||||
{
|
||||
$this->maxRetry = $maxRetry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Datetime
|
||||
*/
|
||||
public function getUpdated()
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
}
|
18
lib/Doctrine/Repositories/FtpCredentialRepository.php
Normal file
18
lib/Doctrine/Repositories/FtpCredentialRepository.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class FtpCredentialRepository extends EntityRepository
|
||||
{
|
||||
}
|
@@ -13,6 +13,7 @@ use Alchemy\Phrasea\Application;
|
||||
|
||||
use Alchemy\Phrasea\Exception\SessionNotFound;
|
||||
use Alchemy\Geonames\Exception\ExceptionInterface as GeonamesExceptionInterface;
|
||||
use Entities\FtpCredential;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -246,58 +247,15 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @var FtpCredential
|
||||
*/
|
||||
protected $defaultftpdatas;
|
||||
|
||||
protected $ftpCredential;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mail_notifications;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $activeftp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ftp_address;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ftp_login;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ftp_password;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ftp_passif;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ftp_dir;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ftp_dir_prefix;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
@@ -559,22 +517,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
return $usr_id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $datas
|
||||
* @return User_Adapter
|
||||
*/
|
||||
public function set_defaultftpdatas($datas)
|
||||
{
|
||||
$sql = 'UPDATE usr SET defaultftpdatasent = :defaultftpdatas WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':defaultftpdatas' => $datas, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->defaultftpdatas = $datas;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bollean $boolean
|
||||
@@ -593,23 +535,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return User_Adapter
|
||||
*/
|
||||
public function set_activeftp($boolean)
|
||||
{
|
||||
$value = $boolean ? '1' : '0';
|
||||
$sql = 'UPDATE usr SET activeftp = :activeftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':activeftp' => $value, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->activeftp = $boolean;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
@@ -627,91 +552,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $address
|
||||
* @return User_Adapter
|
||||
*/
|
||||
public function set_ftp_address($address)
|
||||
{
|
||||
$sql = 'UPDATE usr SET addrftp = :addrftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':addrftp' => $address, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->ftp_address = $address;
|
||||
$this->delete_data_from_cache();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $login
|
||||
* @return User_Adapter
|
||||
*/
|
||||
public function set_ftp_login($login)
|
||||
{
|
||||
$sql = 'UPDATE usr SET loginftp = :loginftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':loginftp' => $login, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->ftp_login = $login;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $password
|
||||
* @return User_Adapter
|
||||
*/
|
||||
public function set_ftp_password($password)
|
||||
{
|
||||
$sql = 'UPDATE usr SET pwdFTP = :passwordftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':passwordftp' => $password, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->ftp_password = $password;
|
||||
$this->delete_data_from_cache();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_ftp_passif($boolean)
|
||||
{
|
||||
$value = $boolean ? '1' : '0';
|
||||
$sql = 'UPDATE usr SET passifftp = :passifftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':passifftp' => $value, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->ftp_passif = !!$boolean;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_ftp_dir($ftp_dir)
|
||||
{
|
||||
$sql = 'UPDATE usr SET destftp = :destftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':destftp' => $ftp_dir, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->ftp_dir = $ftp_dir;
|
||||
$this->delete_data_from_cache();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_ftp_dir_prefix($ftp_dir_prefix)
|
||||
{
|
||||
$sql = 'UPDATE usr SET prefixFTPfolder = :prefixftp WHERE usr_id = :usr_id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':prefixftp' => $ftp_dir_prefix, ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
$this->ftp_dir_prefix = $ftp_dir_prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_firstname($firstname)
|
||||
{
|
||||
$sql = 'UPDATE usr SET usr_prenom = :usr_prenom WHERE usr_id = :usr_id';
|
||||
@@ -891,18 +731,12 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
$stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()));
|
||||
$stmt->closeCursor();
|
||||
|
||||
$this->set_ftp_address('')
|
||||
->set_activeftp(false)
|
||||
$this
|
||||
->set_city('')
|
||||
->set_company('')
|
||||
->set_email(null)
|
||||
->set_fax('')
|
||||
->set_firstname('')
|
||||
->set_ftp_dir('')
|
||||
->set_ftp_dir_prefix('')
|
||||
->set_ftp_login('')
|
||||
->set_ftp_passif('')
|
||||
->set_ftp_password('')
|
||||
->set_gender('')
|
||||
->set_geonameid('')
|
||||
->set_job('')
|
||||
@@ -913,11 +747,28 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
->set_zip('')
|
||||
->set_tel('');
|
||||
|
||||
$this->ftpCredential = new FtpCredential();
|
||||
$this->ftpCredential->setUsrId($this->get_id());
|
||||
$this->app['EM']->persist($this->ftpCredential);
|
||||
$this->app['EM']->flush();
|
||||
|
||||
$this->delete_data_from_cache();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFtpCredential()
|
||||
{
|
||||
if (null === $this->ftpCredential) {
|
||||
/* @var $ftpCredential \Entities\FtpCredential */
|
||||
$this->ftpCredential = $this->app['EM']->getRepository('Entities\FtpCredential')->findOneBy(array(
|
||||
'usrId' => $this->get_id()
|
||||
));
|
||||
}
|
||||
|
||||
return $this->ftpCredential;
|
||||
}
|
||||
|
||||
public function is_template()
|
||||
{
|
||||
return $this->is_template;
|
||||
@@ -1023,52 +874,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function get_defaultftpdatas()
|
||||
{
|
||||
return $this->defaultftpdatas;
|
||||
}
|
||||
|
||||
public function get_mail_notifications()
|
||||
{
|
||||
return $this->mail_notifications;
|
||||
}
|
||||
|
||||
public function get_activeftp()
|
||||
{
|
||||
return $this->activeftp;
|
||||
}
|
||||
|
||||
public function get_ftp_address()
|
||||
{
|
||||
return $this->ftp_address;
|
||||
}
|
||||
|
||||
public function get_ftp_login()
|
||||
{
|
||||
return $this->ftp_login;
|
||||
}
|
||||
|
||||
public function get_ftp_password()
|
||||
{
|
||||
return $this->ftp_password;
|
||||
}
|
||||
|
||||
public function get_ftp_passif()
|
||||
{
|
||||
return $this->ftp_passif;
|
||||
}
|
||||
|
||||
public function get_ftp_dir()
|
||||
{
|
||||
return $this->ftp_dir;
|
||||
}
|
||||
|
||||
public function get_ftp_dir_prefix()
|
||||
{
|
||||
return $this->ftp_dir_prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <type> $id
|
||||
@@ -1079,8 +889,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
$sql = 'SELECT usr_id, ldap_created, create_db, usr_login, usr_password, usr_nom, activite,
|
||||
usr_prenom, usr_sexe as gender, usr_mail, adresse, usr_creationdate, usr_modificationdate,
|
||||
ville, cpostal, tel, fax, fonction, societe, geonameid, lastModel, invite,
|
||||
defaultftpdatasent, mail_notifications, activeftp, addrftp, loginftp,
|
||||
pwdFTP, passifftp, destftp, prefixFTPfolder, mail_locked, model_of, locale
|
||||
mail_notifications, mail_locked, model_of, locale
|
||||
FROM usr WHERE usr_id= :id ';
|
||||
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
@@ -1100,15 +909,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
|
||||
$this->ldap_created = $row['ldap_created'];
|
||||
|
||||
$this->defaultftpdatas = $row['defaultftpdatasent'];
|
||||
$this->mail_notifications = $row['mail_notifications'];
|
||||
$this->activeftp = $row['activeftp'];
|
||||
$this->ftp_address = $row['addrftp'];
|
||||
$this->ftp_login = $row['loginftp'];
|
||||
$this->ftp_password = $row['pwdFTP'];
|
||||
$this->ftp_passif = $row['passifftp'];
|
||||
$this->ftp_dir = $row['destftp'];
|
||||
$this->ftp_dir_prefix = $row['prefixFTPfolder'];
|
||||
|
||||
$this->mail_locked = !!$row['mail_locked'];
|
||||
|
||||
@@ -1725,6 +1526,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
|
||||
$usr_id = $conn->lastInsertId();
|
||||
|
||||
$ftpCredential = new FtpCredential();
|
||||
$ftpCredential->setUsrId($usr_id);
|
||||
$app['EM']->persist($ftpCredential);
|
||||
$app['EM']->flush();
|
||||
|
||||
if ($invite) {
|
||||
$sql = 'UPDATE usr SET usr_login = "invite' . $usr_id . '" WHERE usr_id="' . $usr_id . '"';
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
@@ -34,24 +34,8 @@ interface User_Interface
|
||||
|
||||
public function get_country();
|
||||
|
||||
public function set_defaultftpdatas($datas);
|
||||
|
||||
public function set_mail_notifications($boolean);
|
||||
|
||||
public function set_activeftp($boolean);
|
||||
|
||||
public function set_ftp_address($address);
|
||||
|
||||
public function set_ftp_login($login);
|
||||
|
||||
public function set_ftp_password($password);
|
||||
|
||||
public function set_ftp_passif($boolean);
|
||||
|
||||
public function set_ftp_dir($ftp_dir);
|
||||
|
||||
public function set_ftp_dir_prefix($ftp_dir_prefix);
|
||||
|
||||
public function set_firstname($firstname);
|
||||
|
||||
public function set_lastname($lastname);
|
||||
@@ -78,24 +62,8 @@ interface User_Interface
|
||||
|
||||
public function delete();
|
||||
|
||||
public function get_defaultftpdatas();
|
||||
|
||||
public function get_mail_notifications();
|
||||
|
||||
public function get_activeftp();
|
||||
|
||||
public function get_ftp_address();
|
||||
|
||||
public function get_ftp_login();
|
||||
|
||||
public function get_ftp_password();
|
||||
|
||||
public function get_ftp_passif();
|
||||
|
||||
public function get_ftp_dir();
|
||||
|
||||
public function get_ftp_dir_prefix();
|
||||
|
||||
public function load($id);
|
||||
|
||||
public function set_last_template(User_Interface $template);
|
||||
|
89
lib/classes/patch/390.php
Normal file
89
lib/classes/patch/390.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Entities\FtpCredential;
|
||||
|
||||
class patch_390 implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0.a1';
|
||||
|
||||
/** @var array */
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$sql = 'SELECT usr_id, activeFTP, addrFTP, loginFTP,
|
||||
retryFTP, passifFTP, pwdFTP, destFTP, prefixFTPfolder
|
||||
FROM usr';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$n = 0;
|
||||
$em = $app['EM'];
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$credential = new FtpCredential();
|
||||
$credential->setActive($row['activeFTP']);
|
||||
$credential->setAddress($row['addrFTP']);
|
||||
$credential->setLogin($row['loginFTP']);
|
||||
$credential->setMaxRetry((Integer) $row['retryFTP']);
|
||||
$credential->setPassive($row['passifFTP']);
|
||||
$credential->setPassword($row['pwdFTP']);
|
||||
$credential->setReceptionFolder($row['destFTP']);
|
||||
$credential->setRepositoryPrefixName($row['prefixFTPfolder']);
|
||||
$credential->setUsrId($row['usr_id']);
|
||||
|
||||
$em->persist($credential);
|
||||
|
||||
$n++;
|
||||
|
||||
if ($n % 100 === 0) {
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
@@ -235,12 +235,12 @@ class set_export extends set_abstract
|
||||
$lst_base_id = array_keys($app['authentication']->getUser()->ACL()->get_granted_base());
|
||||
|
||||
if ($hasadminright) {
|
||||
$sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
|
||||
usr.pwdFTP,usr.destFTP,prefixFTPfolder,usr.passifFTP,
|
||||
usr.retryFTP,usr.usr_mail
|
||||
FROM (usr INNER JOIN basusr
|
||||
ON ( activeFTP=1
|
||||
AND usr.usr_id=basusr.usr_id
|
||||
$sql = "SELECT usr.usr_id,usr_login,usr.usr_mail, FtpCredential.*
|
||||
FROM (
|
||||
FtpCredential INNER JOIN usr ON (
|
||||
FtpCredential.active = 1 AND FtpCredential.usrId = usr.usr_id
|
||||
) INNER JOIN basusr ON (
|
||||
usr.usr_id=basusr.usr_id
|
||||
AND (basusr.base_id=
|
||||
'" . implode("' OR basusr.base_id='", $lst_base_id) . "'
|
||||
)
|
||||
@@ -249,11 +249,12 @@ class set_export extends set_abstract
|
||||
GROUP BY usr_id ";
|
||||
$params = array();
|
||||
} elseif ($this->app['phraseanet.registry']->get('GV_ftp_for_user')) {
|
||||
$sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
|
||||
usr.pwdFTP,usr.destFTP,prefixFTPfolder,
|
||||
usr.passifFTP,usr.retryFTP,usr.usr_mail
|
||||
FROM (usr INNER JOIN basusr
|
||||
ON ( activeFTP=1 AND usr.usr_id=basusr.usr_id
|
||||
$sql = "SELECT usr.usr_id,usr_login,usr.usr_mail, FtpCredential.*
|
||||
FROM (
|
||||
FtpCredential INNER JOIN usr ON (
|
||||
FtpCredential.active = 1 AND FtpCredential.usrId = usr.usr_id
|
||||
) INNER JOIN basusr ON (
|
||||
usr.usr_id=basusr.usr_id
|
||||
AND usr.usr_id = :usr_id
|
||||
AND (basusr.base_id=
|
||||
'" . implode("' OR basusr.base_id='", $lst_base_id) . "'
|
||||
@@ -267,15 +268,14 @@ class set_export extends set_abstract
|
||||
$datas[] = array(
|
||||
'name' => _('export::ftp: reglages manuels'),
|
||||
'usr_id' => '0',
|
||||
'addrFTP' => '',
|
||||
'loginFTP' => '',
|
||||
'pwdFTP' => '',
|
||||
'ssl' => '0',
|
||||
'destFTP' => '',
|
||||
'prefixFTPfolder' => 'Export_' . date("Y-m-d_H.i.s"),
|
||||
'passifFTP' => false,
|
||||
'retryFTP' => 5,
|
||||
'mailFTP' => '',
|
||||
'address' => '',
|
||||
'login' => '',
|
||||
'password' => '',
|
||||
'ssl' => false,
|
||||
'dest_folder' => '',
|
||||
'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"),
|
||||
'passive' => false,
|
||||
'max_retry' => 5,
|
||||
'sendermail' => $app['authentication']->getUser()->get_email()
|
||||
);
|
||||
|
||||
@@ -288,19 +288,19 @@ class set_export extends set_abstract
|
||||
$datas[] = array(
|
||||
'name' => $row["usr_login"],
|
||||
'usr_id' => $row['usr_id'],
|
||||
'addrFTP' => $row['addrFTP'],
|
||||
'loginFTP' => $row['loginFTP'],
|
||||
'pwdFTP' => $row['pwdFTP'],
|
||||
'ssl' => $row['sslFTP'],
|
||||
'destFTP' => $row['destFTP'],
|
||||
'prefixFTPfolder' =>
|
||||
(strlen(trim($row['prefixFTPfolder'])) > 0 ?
|
||||
trim($row['prefixFTPfolder']) :
|
||||
'address' => $row['address'],
|
||||
'login' => $row['login'],
|
||||
'password' => $row['password'],
|
||||
'ssl' => !! $row['tls'],
|
||||
'dest_folder' => $row['reception_folder'],
|
||||
'prefix_folder' =>
|
||||
(strlen(trim($row['repository_prefix_name'])) > 0 ?
|
||||
trim($row['repository_prefix_name']) :
|
||||
'Export_' . date("Y-m-d_H.i.s")),
|
||||
'passifFTP' => ($row['passifFTP'] > 0),
|
||||
'retryFTP' => $row['retryFTP'],
|
||||
'mailFTP' => $row['usr_mail'],
|
||||
'sendermail' => $app['authentication']->getUser()->get_email()
|
||||
'passive' => !! $row['passive'],
|
||||
'max_retry' => $row['max_retry'],
|
||||
'usr_mail' => $row['usr_mail'],
|
||||
'sender_mail' => $app['authentication']->getUser()->get_email()
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -3729,107 +3729,6 @@
|
||||
<default>0</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>activeFTP</name>
|
||||
<type>tinyint(1)</type>
|
||||
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default>0</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>addrFTP</name>
|
||||
|
||||
<type>varchar(128)</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default></default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>sslFTP</name>
|
||||
|
||||
<type>tinyint(1) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default>0</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
|
||||
<name>loginFTP</name>
|
||||
<type>varchar(128)</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default></default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>pwdFTP</name>
|
||||
<type>varchar(128)</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default></default>
|
||||
<comment></comment>
|
||||
|
||||
</field>
|
||||
<field>
|
||||
<name>destFTP</name>
|
||||
<type>varchar(128)</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default></default>
|
||||
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>passifFTP</name>
|
||||
<type>tinyint(1) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
|
||||
<default>0</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>retryFTP</name>
|
||||
<type>tinyint(1) unsigned</type>
|
||||
<null></null>
|
||||
|
||||
<extra></extra>
|
||||
|
||||
<default>5</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>defaultftpdatasent</name>
|
||||
<type>int(11) unsigned</type>
|
||||
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default>0</default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>prefixFTPfolder</name>
|
||||
|
||||
<type>varchar(100)</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
<default></default>
|
||||
<comment></comment>
|
||||
</field>
|
||||
<field>
|
||||
<name>lastModel</name>
|
||||
<type>varchar(50)</type>
|
||||
@@ -4019,10 +3918,6 @@
|
||||
<data key="last_conn">0000-00-00 00:00:00</data>
|
||||
<data key="model_of">0</data>
|
||||
<data key="create_db">0</data>
|
||||
<data key="activeFTP">0</data>
|
||||
<data key="passifFTP">0</data>
|
||||
<data key="retryFTP">5</data>
|
||||
<data key="defaultftpdatasent">5</data>
|
||||
<data key="canchgprofil">0</data>
|
||||
<data key="canchgftpprofil">0</data>
|
||||
<data key="nonce"></data>
|
||||
@@ -4038,10 +3933,6 @@
|
||||
<data key="last_conn">0000-00-00 00:00:00</data>
|
||||
<data key="model_of">0</data>
|
||||
<data key="create_db">0</data>
|
||||
<data key="activeFTP">0</data>
|
||||
<data key="passifFTP">0</data>
|
||||
<data key="retryFTP">5</data>
|
||||
<data key="defaultftpdatasent">5</data>
|
||||
<data key="canchgprofil">0</data>
|
||||
<data key="canchgftpprofil">0</data>
|
||||
<data key="nonce"></data>
|
||||
|
@@ -167,48 +167,49 @@
|
||||
|
||||
<legend>{% trans "FTP" %}</legend>
|
||||
|
||||
{% set ftpCredential = app["authentication"].getUser().getFtpCredential() %}
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="form_label checkbox" for="form_activeFTP">{% trans "admin::compte-utilisateur:ftp: Activer le compte FTP" %}
|
||||
<input class="input_element input-xlarge" type="checkbox" name="form_activeFTP" id="form_activeFTP" {% if app["authentication"].getUser().get_activeftp() %}checked{% endif %} onchange="if(this.checked){$('#ftpinfos').slideDown();}else{$('#ftpinfos').slideUp();}" />
|
||||
<input class="input_element input-xlarge" type="checkbox" name="form_activeFTP" id="form_activeFTP" {% if ftpCredential.isActive() %}checked{% endif %} onchange="if(this.checked){$('#ftpinfos').slideDown();}else{$('#ftpinfos').slideUp();}" />
|
||||
</label>
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ftpinfos" style="display:{% if app["authentication"].getUser().get_activeftp() %}block{% else %}none{% endif %}">
|
||||
<div id="ftpinfos" style="display:{% if ftpCredential.isActive() %}block{% else %}none{% endif %}">
|
||||
<div class="control-group">
|
||||
<label class="form_label control-label" for="form_addrFTP"><strong>{% trans "phraseanet:: adresse" %}</strong></label>
|
||||
<label class="form_label control-label" for="form_addressFTP"><strong>{% trans "phraseanet:: adresse" %}</strong></label>
|
||||
<div class="controls">
|
||||
<input class="input_element input-xlarge" type="text" name="form_addrFTP" id="form_addrFTP" value="{{ app["authentication"].getUser().get_ftp_address() }}" />
|
||||
<input class="input_element input-xlarge" type="text" name="form_addressFTP" id="form_addressFTP" value="{{ ftpCredential.getAddress() }}" />
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="form_label control-label" for="form_loginFTP"><strong>{% trans "admin::compte-utilisateur identifiant" %}</strong></label>
|
||||
<div class="controls">
|
||||
<input class="input_element input-xlarge" type="text" name="form_loginFTP" id="form_loginFTP" value="{{ app["authentication"].getUser().get_ftp_login() }}" />
|
||||
<input class="input_element input-xlarge" type="text" name="form_loginFTP" id="form_loginFTP" value="{{ ftpCredential.getLogin() }}" />
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="form_label control-label" for="form_pwdFTP"><strong>{% trans "admin::compte-utilisateur mot de passe" %}</strong></label>
|
||||
<div class="controls">
|
||||
<input class="input_element input-xlarge" type="text" name="form_pwdFTP" id="form_pwdFTP" value="{{ app["authentication"].getUser().get_ftp_password() }}" />
|
||||
<input class="input_element input-xlarge" type="text" name="form_pwdFTP" id="form_pwdFTP" value="{{ ftpCredential.getPassword() }}" />
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="form_label control-label" for="form_destFTP"><strong>{% trans "admin::compte-utilisateur:ftp: repertoire de destination ftp" %}</strong></label>
|
||||
<div class="controls">
|
||||
<input class="input_element input-xlarge" type="text" name="form_destFTP" id="form_destFTP" value="{{ app["authentication"].getUser().get_ftp_dir() }}" />
|
||||
<input class="input_element input-xlarge" type="text" name="form_destFTP" id="form_destFTP" value="{{ ftpCredential.getReceptionFolder() }}" />
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="form_label control-label" for="form_prefixFTPfolder"><strong>{% trans "admin::compte-utilisateur:ftp: prefixe des noms de dossier ftp" %}</strong></label>
|
||||
<div class="controls">
|
||||
<input class="input_element input-xlarge" type="text" name="form_prefixFTPfolder" id="form_prefixFTPfolder" value="{{ app["authentication"].getUser().get_ftp_dir_prefix() }}" />
|
||||
<input class="input_element input-xlarge" type="text" name="form_prefixFTPfolder" id="form_prefixFTPfolder" value="{{ ftpCredential.getRepositoryPrefixName() }}" />
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +217,7 @@
|
||||
<div class="controls">
|
||||
<label class="form_label checkbox" for="form_passifFTP">
|
||||
{% trans "admin::compte-utilisateur:ftp: Utiliser le mode passif" %}
|
||||
<input class="input_element input-xlarge" type="checkbox" name="form_passifFTP" id="form_passifFTP" {% if app["authentication"].getUser().get_ftp_passif() == "1" %}checked{% endif %} />
|
||||
<input class="input_element input-xlarge" type="checkbox" name="form_passifFTP" id="form_passifFTP" {% if ftpCredential.isPassive() %}checked{% endif %} />
|
||||
</label>
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
@@ -224,7 +225,7 @@
|
||||
<div class="control-group">
|
||||
<label class="form_label control-label" for="form_retryFTP"><strong>{% trans "admin::compte-utilisateur:ftp: Nombre d\'essais max" %}</strong></label>
|
||||
<div class="controls">
|
||||
<input class="input_element input-xlarge" type="text" name="form_retryFTP" id="form_retryFTP" value="5" />
|
||||
<input class="input_element input-xlarge" type="text" name="form_retryFTP" id="form_retryFTP" value="{{ ftpCredential.getMaxRetry() }}" />
|
||||
<p class="form_alert help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -3,52 +3,52 @@
|
||||
{% macro print_ftp_form(datas) %}
|
||||
<div class="ftp_form ftp_form_{{datas.usr_id}}">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="addrFTP_{{datas.usr_id}}">{% trans 'phraseanet:: adresse' %} ftp://</label>
|
||||
<label class="control-label" for="ftp-address-{{datas.usr_id}}">{% trans 'phraseanet:: adresse' %} ftp://</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="addr" id="addrFTP_{{datas.usr_id}}" value="{{datas.addrFTP}}" />
|
||||
<input type="text" name="address" id="ftp-address-{{datas.usr_id}}" value="{{datas.address}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="ftpssl_{{datas.usr_id}}">{% trans 'phraseanet:: utiliser SSL' %}</label>
|
||||
<label class="control-label" for="ftp-ssl-{{datas.usr_id}}">{% trans 'phraseanet:: utiliser SSL' %}</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" name="ssl" id="ftpssl_{{datas.usr_id}}" value="1" />
|
||||
<input type="checkbox" name="ssl" id="ftp-ssl-{{datas.usr_id}}" {% if datas.ssl %}checked{% endif %} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="loginFTP_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur identifiant' %}</label>
|
||||
<label class="control-label" for="ftp-login-{{datas.usr_id}}">{% trans 'admin::compte-utilisateur identifiant' %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="login" id="loginFTP_{{datas.usr_id}}" value="{{datas.loginFTP}}" />
|
||||
<input type="text" name="login" id="ftp-login-{{datas.usr_id}}" value="{{datas.login}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="pwdFTP_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur mot de passe' %}</label>
|
||||
<label class="control-label" for="ftp-password-{{datas.usr_id}}">{% trans 'admin::compte-utilisateur mot de passe' %}</label>
|
||||
<div class="controls">
|
||||
<input type="password" name="pwd" id="pwdFTP_{{datas.usr_id}}" value="{{datas.pwdFTP}}" />
|
||||
<input type="password" name="password" id="ftp-password-{{datas.usr_id}}" value="{{datas.password}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="passifFTP_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: Utiliser le mode passif' %}</label>
|
||||
<label class="control-label" for="ftp-passive-{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: Utiliser le mode passif' %}</label>
|
||||
<div class="controls">
|
||||
<input value="1" type="checkbox" name="passif" id="passifFTP_{{datas.usr_id}}" {% if datas.passifFTP %}checked="checked"{% endif %} />
|
||||
<input value="1" type="checkbox" name="passive" id="ftp-passive-{{datas.usr_id}}" {% if datas.passive %}checked{% endif %} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="retryFTP_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: Nombre d\'essais max' %}</label>
|
||||
<label class="control-label" for="ftp-max-retry-{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: Nombre d\'essais max' %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="nbretry" id="retryFTP_{{datas.usr_id}}" value="{{datas.retryFTP}}" />
|
||||
<input type="text" name="max_retry" id="ftp-max-retry-{{datas.usr_id}}" value="{{datas.max_retry}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="destFTP_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: repertoire de destination ftp' %}</label>
|
||||
<label class="control-label" for="ftp-dest-folder-{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: repertoire de destination ftp' %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="destfolder" id="destFTP_{{datas.usr_id}}" value="{{datas.destFTP}}" />
|
||||
<input type="text" name="dest_folder" id="ftp-dest-folder-{{datas.usr_id}}" value="{{datas.dest_folder}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="idMKDFOLD_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: creer un dossier' %}</label>
|
||||
<label class="control-label" for="ftp-prefix-folder-{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: creer un dossier' %}</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" class="ftp_folder_check" {% if datas.prefixFTPfolder != '' %}checked="checked"{% endif %} name="MKDFOLD" id="idMKDFOLD_{{datas.usr_id}}" value="MKDFOLD" />
|
||||
<input type="text" name="NAMMKDFOLD" id="prefixFTPfolder_{{datas.usr_id}}" value="{{datas.prefixFTPfolder}}" {% if datas.prefixFTPfolder == '' %}disabled="disabled"{% endif %} />
|
||||
<input type="checkbox" class="ftp_folder_check" {% if datas.prefix_folder != '' %}checked{% endif %} name="prefix_folder_check" id="ftp-prefix-folder-check-{{datas.usr_id}}" />
|
||||
<input type="text" name="prefix_folder" id="ftp-prefix-folder-{{datas.usr_id}}" value="{{datas.prefix_folder}}" {% if datas.prefix_folder == '' %}disabled{% endif %} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
@@ -107,10 +107,10 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testExportFtpNoDocs()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/export/ftp/', array(
|
||||
'addr' => 'test.ftp',
|
||||
'address' => 'test.ftp',
|
||||
'login' => 'login',
|
||||
'destfolder' => 'documents',
|
||||
'NAMMKDFOLD' => 'documents',
|
||||
'dest_folder' => 'documents',
|
||||
'prefix_folder' => 'documents',
|
||||
'obj' => array('preview')
|
||||
));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
@@ -137,10 +137,10 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
return array(
|
||||
array(array()),
|
||||
array(array('addr' => '')),
|
||||
array(array('addr' => '', 'login' => '')),
|
||||
array(array('addr' => '', 'login' => '', 'destfolder' => '')),
|
||||
array(array('addr' => '', 'login' => '', 'destfolder' => '', 'NAMMKDFOLD' => '')),
|
||||
array(array('address' => '')),
|
||||
array(array('address' => '', 'login' => '')),
|
||||
array(array('address' => '', 'login' => '', 'dest_folder' => '')),
|
||||
array(array('address' => '', 'login' => '', 'dest_folder' => '', 'prefix_folder' => '')),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
self::$DI['client']->request('POST', '/prod/export/ftp/', array(
|
||||
'lst' => self::$DI['record_1']->get_serialize_key(),
|
||||
'user_dest' => self::$DI['user']->get_id(),
|
||||
'addr' => 'local.phrasea.test',
|
||||
'address' => 'local.phrasea.test',
|
||||
'login' => self::$DI['user']->get_email(),
|
||||
'destfolder' => '/home/test/',
|
||||
'NAMMKDFOLD' => 'test2/',
|
||||
'dest_folder' => '/home/test/',
|
||||
'prefix_folder' => 'test2/',
|
||||
'obj' => array('preview')
|
||||
));
|
||||
|
||||
|
@@ -305,7 +305,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
'form_company' => 'NASA',
|
||||
'form_activity' => 'Space',
|
||||
'form_geonameid' => '',
|
||||
'form_addrFTP' => '',
|
||||
'form_addressFTP' => '',
|
||||
'form_loginFTP' => '',
|
||||
'form_pwdFTP' => '',
|
||||
'form_destFTP' => '',
|
||||
|
@@ -60,6 +60,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
self::$time_start = microtime(true);
|
||||
|
||||
self::$DI = new \Pimple();
|
||||
self::initializeSqliteDB();
|
||||
|
||||
$application = new Application('test');
|
||||
|
||||
@@ -68,10 +69,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
exit(1);
|
||||
}
|
||||
|
||||
self::createSetOfUserTests($application);
|
||||
|
||||
self::updateTablesSchema($application);
|
||||
|
||||
self::createSetOfUserTests($application);
|
||||
|
||||
self::setCollection($application);
|
||||
|
||||
self::generateRecords($application);
|
||||
@@ -82,6 +83,14 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public static function initializeSqliteDB($path = '/tmp/db.sqlite')
|
||||
{
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
copy(__DIR__ . '/../db-ref.sqlite', $path);
|
||||
}
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
|
||||
@@ -129,9 +138,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
$app['debug'] = true;
|
||||
|
||||
$app['EM'] = $app->share($app->extend('EM', function($em) {
|
||||
@unlink('/tmp/db.sqlite');
|
||||
copy(__DIR__ . '/../db-ref.sqlite', '/tmp/db.sqlite');
|
||||
$app['EM'] = $app->share($app->extend('EM', function($em) use ($phpunit) {
|
||||
$phpunit::initializeSqliteDB();
|
||||
|
||||
return $em;
|
||||
}));
|
||||
@@ -171,9 +179,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
$app['debug'] = true;
|
||||
|
||||
$app['EM'] = $app->share($app->extend('EM', function($em) {
|
||||
@unlink('/tmp/db.sqlite');
|
||||
copy(__DIR__ . '/../db-ref.sqlite', '/tmp/db.sqlite');
|
||||
$app['EM'] = $app->share($app->extend('EM', function ($em) use ($phpunit) {
|
||||
$phpunit::initializeSqliteDb();
|
||||
|
||||
return $em;
|
||||
}));
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user