Merge branch '4.0'

Also updated dependencies
This commit is contained in:
Benoît Burnichon
2016-02-28 23:31:16 +01:00
22 changed files with 2537 additions and 2279 deletions

View File

@@ -27,7 +27,7 @@
"bootstrap-sass": "v2.3.2.2", "bootstrap-sass": "v2.3.2.2",
"jquery.lazyload": "~1.9.7", "jquery.lazyload": "~1.9.7",
"jquery-treeview": "~1.4.2", "jquery-treeview": "~1.4.2",
"alchemy-embed-medias": "~0.3.1" "alchemy-embed-medias": "~0.3.2"
}, },
"devDependencies": { "devDependencies": {
"mocha": "latest", "mocha": "latest",

View File

@@ -30,7 +30,7 @@
"require": { "require": {
"php": ">=5.5", "php": ">=5.5",
"alchemy-fr/tcpdf-clone": "~6.0", "alchemy-fr/tcpdf-clone": "~6.0",
"alchemy/embed-bundle": "^0.2.0", "alchemy/embed-bundle": "^0.3.2",
"alchemy/geonames-api-consumer": "~0.1.0", "alchemy/geonames-api-consumer": "~0.1.0",
"alchemy/google-plus-api-client": "~0.6.2", "alchemy/google-plus-api-client": "~0.6.2",
"alchemy/mediavorus": "^0.4.4", "alchemy/mediavorus": "^0.4.4",

168
composer.lock generated
View File

@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "d39892bd2597bbeda0205d0254b90dcd", "hash": "0b264e88dc633332244aa459e5bbe1f3",
"content-hash": "db752ae42fca6cbf8f9d67dfe5dc6639", "content-hash": "7f563052a82cf882eda37b48fde1d642",
"packages": [ "packages": [
{ {
"name": "alchemy-fr/tcpdf-clone", "name": "alchemy-fr/tcpdf-clone",
@@ -15,6 +15,12 @@
"url": "https://github.com/alchemy-fr/tcpdf-clone.git", "url": "https://github.com/alchemy-fr/tcpdf-clone.git",
"reference": "2ba0248a7187f1626df6c128750650416267f0e7" "reference": "2ba0248a7187f1626df6c128750650416267f0e7"
}, },
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/tcpdf-clone/zipball/2ba0248a7187f1626df6c128750650416267f0e7",
"reference": "2ba0248a7187f1626df6c128750650416267f0e7",
"shasum": ""
},
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
}, },
@@ -61,6 +67,10 @@
"qrcode", "qrcode",
"tcpdf" "tcpdf"
], ],
"support": {
"source": "https://github.com/alchemy-fr/tcpdf-clone/tree/6.0.039",
"issues": "https://github.com/alchemy-fr/tcpdf-clone/issues"
},
"time": "2013-10-13 16:11:17" "time": "2013-10-13 16:11:17"
}, },
{ {
@@ -103,14 +113,14 @@
"email": "imprec@gmail.com", "email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/" "homepage": "http://www.lickmychip.com/"
}, },
{
"name": "Nicolas Le Goff",
"email": "legoff.n@gmail.com"
},
{ {
"name": "Phraseanet Team", "name": "Phraseanet Team",
"email": "info@alchemy.fr", "email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/" "homepage": "http://www.phraseanet.com/"
},
{
"name": "Nicolas Le Goff",
"email": "legoff.n@gmail.com"
} }
], ],
"description": "A set of tools to build binary drivers", "description": "A set of tools to build binary drivers",
@@ -122,16 +132,16 @@
}, },
{ {
"name": "alchemy/embed-bundle", "name": "alchemy/embed-bundle",
"version": "v0.2.0", "version": "v0.3.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/alchemy-fr/embed-bundle.git", "url": "https://github.com/alchemy-fr/embed-bundle.git",
"reference": "37cc6ab627e4a770a60aad4ae4c60934e5de5cf5" "reference": "3db85da5eb56aa1ebeac4b0a3e224f127dfa7c1c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/embed-bundle/zipball/37cc6ab627e4a770a60aad4ae4c60934e5de5cf5", "url": "https://api.github.com/repos/alchemy-fr/embed-bundle/zipball/3db85da5eb56aa1ebeac4b0a3e224f127dfa7c1c",
"reference": "37cc6ab627e4a770a60aad4ae4c60934e5de5cf5", "reference": "3db85da5eb56aa1ebeac4b0a3e224f127dfa7c1c",
"shasum": "" "shasum": ""
}, },
"require-dev": { "require-dev": {
@@ -169,10 +179,10 @@
], ],
"description": "Embed resources bundle", "description": "Embed resources bundle",
"support": { "support": {
"source": "https://github.com/alchemy-fr/embed-bundle/tree/v0.2.0", "source": "https://github.com/alchemy-fr/embed-bundle/tree/v0.3.2",
"issues": "https://github.com/alchemy-fr/embed-bundle/issues" "issues": "https://github.com/alchemy-fr/embed-bundle/issues"
}, },
"time": "2016-01-15 12:49:06" "time": "2016-02-25 17:06:03"
}, },
{ {
"name": "alchemy/geonames-api-consumer", "name": "alchemy/geonames-api-consumer",
@@ -536,6 +546,12 @@
"url": "https://github.com/alchemy-fr/symfony-cors.git", "url": "https://github.com/alchemy-fr/symfony-cors.git",
"reference": "dbf7fcff1ce9fc1265db12955476ff169eab7375" "reference": "dbf7fcff1ce9fc1265db12955476ff169eab7375"
}, },
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/symfony-cors/zipball/dbf7fcff1ce9fc1265db12955476ff169eab7375",
"reference": "dbf7fcff1ce9fc1265db12955476ff169eab7375",
"shasum": ""
},
"require": { "require": {
"symfony/http-kernel": "^2.3.0|^3.0.0" "symfony/http-kernel": "^2.3.0|^3.0.0"
}, },
@@ -556,11 +572,7 @@
"Alchemy\\CorsBundle\\": "src/Bundle/" "Alchemy\\CorsBundle\\": "src/Bundle/"
} }
}, },
"autoload-dev": { "notification-url": "https://packagist.org/downloads/",
"psr-4": {
"Alchemy\\Cors\\Tests\\": "tests/unit/Component/"
}
},
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -1519,21 +1531,21 @@
}, },
{ {
"name": "doctrine/migrations", "name": "doctrine/migrations",
"version": "v1.3.0", "version": "v1.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/migrations.git", "url": "https://github.com/doctrine/migrations.git",
"reference": "2ce8d87d4247e4b87cc5905ea5f8446b12bd9b5b" "reference": "abc571dadd45df42f19baac7a0a1a371216dd93d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/migrations/zipball/2ce8d87d4247e4b87cc5905ea5f8446b12bd9b5b", "url": "https://api.github.com/repos/doctrine/migrations/zipball/abc571dadd45df42f19baac7a0a1a371216dd93d",
"reference": "2ce8d87d4247e4b87cc5905ea5f8446b12bd9b5b", "reference": "abc571dadd45df42f19baac7a0a1a371216dd93d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/dbal": "~2.2", "doctrine/dbal": "~2.2",
"ocramius/proxy-manager": "^1.0", "ocramius/proxy-manager": "^1.0|^2.0",
"php": "^5.5|^7.0", "php": "^5.5|^7.0",
"symfony/console": "~2.3|~3.0", "symfony/console": "~2.3|~3.0",
"symfony/yaml": "~2.3|~3.0" "symfony/yaml": "~2.3|~3.0"
@@ -1541,18 +1553,22 @@
"require-dev": { "require-dev": {
"doctrine/coding-standard": "dev-master", "doctrine/coding-standard": "dev-master",
"doctrine/orm": "2.*", "doctrine/orm": "2.*",
"jdorn/sql-formatter": "~1.1",
"johnkary/phpunit-speedtrap": "~1.0@dev", "johnkary/phpunit-speedtrap": "~1.0@dev",
"mockery/mockery": "^0.9.4", "mockery/mockery": "^0.9.4",
"phpunit/phpunit": "~4.7", "phpunit/phpunit": "~4.7",
"satooshi/php-coveralls": "0.6.*" "satooshi/php-coveralls": "0.6.*"
}, },
"suggest": {
"jdorn/sql-formatter": "Allows to generate formatted SQL with the diff command."
},
"bin": [ "bin": [
"bin/doctrine-migrations" "bin/doctrine-migrations"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "v1.4.x-dev" "dev-master": "v1.5.x-dev"
} }
}, },
"autoload": { "autoload": {
@@ -1584,7 +1600,7 @@
"database", "database",
"migrations" "migrations"
], ],
"time": "2016-01-23 09:49:17" "time": "2016-02-23 15:28:39"
}, },
{ {
"name": "doctrine/orm", "name": "doctrine/orm",
@@ -1725,12 +1741,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/igorw/evenement.git", "url": "https://github.com/igorw/evenement.git",
"reference": "v1.0.0" "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/igorw/evenement/zipball/fa966683e7df3e5dd5929d984a44abfbd6bafe8d", "url": "https://api.github.com/repos/igorw/evenement/zipball/fa966683e7df3e5dd5929d984a44abfbd6bafe8d",
"reference": "v1.0.0", "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1757,7 +1773,7 @@
"keywords": [ "keywords": [
"event-dispatcher" "event-dispatcher"
], ],
"time": "2012-05-30 08:01:08" "time": "2012-05-30 15:01:08"
}, },
{ {
"name": "facebook/php-sdk", "name": "facebook/php-sdk",
@@ -1803,6 +1819,7 @@
"facebook", "facebook",
"sdk" "sdk"
], ],
"abandoned": "facebook/php-sdk-v4",
"time": "2013-11-19 23:11:14" "time": "2013-11-19 23:11:14"
}, },
{ {
@@ -2644,12 +2661,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/hoaproject/Stream.git", "url": "https://github.com/hoaproject/Stream.git",
"reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3" "reference": "3bc446bc00849bf51166adc415d77aa375d48d8c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/hoaproject/Stream/zipball/3bc446bc00849bf51166adc415d77aa375d48d8c", "url": "https://api.github.com/repos/hoaproject/Stream/zipball/3bc446bc00849bf51166adc415d77aa375d48d8c",
"reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3", "reference": "3bc446bc00849bf51166adc415d77aa375d48d8c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2694,7 +2711,7 @@
"stream", "stream",
"wrapper" "wrapper"
], ],
"time": "2015-10-22 06:30:43" "time": "2015-10-26 12:21:43"
}, },
{ {
"name": "hoa/ustring", "name": "hoa/ustring",
@@ -3724,7 +3741,7 @@
], ],
"authors": [ "authors": [
{ {
"name": "Stephen Clay", "name": "Steve Clay",
"email": "steve@mrclay.org", "email": "steve@mrclay.org",
"homepage": "http://www.mrclay.org/", "homepage": "http://www.mrclay.org/",
"role": "Developer" "role": "Developer"
@@ -3910,21 +3927,21 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/romainneutron/Imagine-Silex-Service-Provider.git", "url": "https://github.com/romainneutron/Imagine-Silex-Service-Provider.git",
"reference": "0.1.2" "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/a8a7862ae90419f2b23746cd8436c2310e4eb084", "url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/a8a7862ae90419f2b23746cd8436c2310e4eb084",
"reference": "0.1.2", "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"imagine/imagine": "*", "imagine/imagine": "*",
"php": ">=5.3.3", "php": ">=5.3.3",
"silex/silex": ">=1.0,<2.0" "silex/silex": "~1.0"
}, },
"require-dev": { "require-dev": {
"symfony/browser-kit": ">=2.0,<3.0" "symfony/browser-kit": "~2.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@@ -5335,7 +5352,7 @@
}, },
{ {
"name": "Phraseanet Team", "name": "Phraseanet Team",
"email": "support@alchemy.fr", "email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/" "homepage": "http://www.phraseanet.com/"
} }
], ],
@@ -5399,6 +5416,62 @@
], ],
"time": "2014-12-05 14:17:14" "time": "2014-12-05 14:17:14"
}, },
{
"name": "symfony/polyfill-apcu",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-apcu.git",
"reference": "d1911e6caeb4b6a4c8e2d5c46b978a66b3745e4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/d1911e6caeb4b6a4c8e2d5c46b978a66b3745e4c",
"reference": "d1911e6caeb4b6a4c8e2d5c46b978a66b3745e4c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting apcu_* functions to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"apcu",
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2016-01-20 09:13:37"
},
{ {
"name": "symfony/polyfill-intl-icu", "name": "symfony/polyfill-intl-icu",
"version": "v1.1.0", "version": "v1.1.0",
@@ -5857,22 +5930,23 @@
}, },
{ {
"name": "symfony/symfony", "name": "symfony/symfony",
"version": "v2.8.2", "version": "v2.8.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/symfony.git", "url": "https://github.com/symfony/symfony.git",
"reference": "f3e6a82bcbea4db3b56df08e491e20a1faae82b5" "reference": "7a9a5fce7ce6e448e527f635463dda00761e12c2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/symfony/zipball/f3e6a82bcbea4db3b56df08e491e20a1faae82b5", "url": "https://api.github.com/repos/symfony/symfony/zipball/7a9a5fce7ce6e448e527f635463dda00761e12c2",
"reference": "f3e6a82bcbea4db3b56df08e491e20a1faae82b5", "reference": "7a9a5fce7ce6e448e527f635463dda00761e12c2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": "~2.4", "doctrine/common": "~2.4",
"php": ">=5.3.9", "php": ">=5.3.9",
"psr/log": "~1.0", "psr/log": "~1.0",
"symfony/polyfill-apcu": "~1.1",
"symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-intl-icu": "~1.0",
"symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php54": "~1.0", "symfony/polyfill-php54": "~1.0",
@@ -5941,7 +6015,7 @@
"doctrine/orm": "~2.4,>=2.4.5", "doctrine/orm": "~2.4,>=2.4.5",
"egulias/email-validator": "~1.2", "egulias/email-validator": "~1.2",
"monolog/monolog": "~1.11", "monolog/monolog": "~1.11",
"ocramius/proxy-manager": "~0.4|~1.0", "ocramius/proxy-manager": "~0.4|~1.0|~2.0",
"phpdocumentor/reflection": "^1.0.7" "phpdocumentor/reflection": "^1.0.7"
}, },
"type": "library", "type": "library",
@@ -5986,7 +6060,7 @@
"keywords": [ "keywords": [
"framework" "framework"
], ],
"time": "2016-01-14 12:01:11" "time": "2016-02-28 21:06:29"
}, },
{ {
"name": "themattharris/tmhoauth", "name": "themattharris/tmhoauth",
@@ -7176,16 +7250,16 @@
}, },
{ {
"name": "sebastian/environment", "name": "sebastian/environment",
"version": "1.3.3", "version": "1.3.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/environment.git", "url": "https://github.com/sebastianbergmann/environment.git",
"reference": "6e7133793a8e5a5714a551a8324337374be209df" "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df", "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
"reference": "6e7133793a8e5a5714a551a8324337374be209df", "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -7222,7 +7296,7 @@
"environment", "environment",
"hhvm" "hhvm"
], ],
"time": "2015-12-02 08:37:27" "time": "2016-02-26 18:40:46"
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",

View File

@@ -86,7 +86,7 @@ class SessionController extends Controller
} }
if ($this->getConf()->get(['registry', 'maintenance', 'enabled'], false)) { if ($this->getConf()->get(['registry', 'maintenance', 'enabled'], false)) {
$ret['message'] .= strip_tags($this->getConf()->get(['registry', 'maintenance', 'enabled'])); $ret['message'] .= strip_tags($this->getConf()->get(['registry', 'maintenance', 'message']));
} }
} }

View File

@@ -34,7 +34,7 @@ class UserPreferenceController extends Controller
$success = false; $success = false;
$msg = $this->app->trans('Error while saving preference'); $msg = $this->app->trans('Error while saving preference');
if ($prop && $value) { if (!is_null($prop) && !is_null($value)) {
$this->getSession()->set('phraseanet.' . $prop, $value); $this->getSession()->set('phraseanet.' . $prop, $value);
$success = true; $success = true;
$msg = $this->app->trans('Preference saved !'); $msg = $this->app->trans('Preference saved !');

View File

@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
@@ -53,7 +54,7 @@ class BasketRepository extends EntityRepository
/** /**
* Returns all basket for a given user that are not marked as archived * Returns all basket for a given user that are not marked as archived
* *
* @param User $user * @param User $user
* @return Basket[] * @return Basket[]
*/ */
public function findActiveByUser(User $user, $sort = null) public function findActiveByUser(User $user, $sort = null)
@@ -145,8 +146,8 @@ class BasketRepository extends EntityRepository
* *
* @throws NotFoundHttpException * @throws NotFoundHttpException
* @throws AccessDeniedHttpException * @throws AccessDeniedHttpException
* @param type $basket_id * @param int $basket_id
* @param User $user * @param User $user
* @return Basket * @return Basket
*/ */
public function findUserBasket($basket_id, User $user, $requireOwner) public function findUserBasket($basket_id, User $user, $requireOwner)
@@ -207,8 +208,6 @@ class BasketRepository extends EntityRepository
public function findWorkzoneBasket(User $user, $query, $year, $type, $offset, $perPage) public function findWorkzoneBasket(User $user, $query, $year, $type, $offset, $perPage)
{ {
$params = [];
switch ($type) { switch ($type) {
case self::RECEIVED: case self::RECEIVED:
$dql = 'SELECT b $dql = 'SELECT b
@@ -241,18 +240,6 @@ class BasketRepository extends EntityRepository
'usr_id' => $user->getId() 'usr_id' => $user->getId()
]; ];
break; break;
default:
$dql = 'SELECT b
FROM Phraseanet:Basket b
LEFT JOIN b.elements e
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE (b.user = :usr_id OR p.user = :validating_usr_id)';
$params = [
'usr_id' => $user->getId(),
'validating_usr_id' => $user->getId()
];
break;
case self::MYBASKETS: case self::MYBASKETS:
$dql = 'SELECT b $dql = 'SELECT b
FROM Phraseanet:Basket b FROM Phraseanet:Basket b
@@ -264,6 +251,17 @@ class BasketRepository extends EntityRepository
'usr_id' => $user->getId() 'usr_id' => $user->getId()
]; ];
break; break;
default:
$dql = 'SELECT b
FROM Phraseanet:Basket b
LEFT JOIN b.elements e
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE (b.user = :usr_id OR p.user = :validating_usr_id)';
$params = [
'usr_id' => $user->getId(),
'validating_usr_id' => $user->getId()
];
} }
if (ctype_digit($year) && strlen($year) == 4) { if (ctype_digit($year) && strlen($year) == 4) {
@@ -287,9 +285,7 @@ class BasketRepository extends EntityRepository
->setFirstResult($offset) ->setFirstResult($offset)
->setMaxResults($perPage); ->setMaxResults($perPage);
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true); return new Paginator($query, true);
return $paginator;
} }
/** /**

View File

@@ -565,14 +565,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
{ {
$name = strtolower($name); $name = strtolower($name);
if (!in_array($name, $this->get_available_subdefs())) {
throw new Exception_Media_SubdefNotFound(sprintf("subdef `%s` not found", $name));
}
if (isset($this->subdefs[$name])) { if (isset($this->subdefs[$name])) {
return $this->subdefs[$name]; return $this->subdefs[$name];
} }
if (!in_array($name, $this->get_available_subdefs())) {
throw new Exception_Media_SubdefNotFound(sprintf("subdef `%s` not found", $name));
}
if (!$this->subdefs) { if (!$this->subdefs) {
$this->subdefs = []; $this->subdefs = [];
} }
@@ -1583,7 +1583,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
} }
/** /**
* @return set_selection * @return set_selection|record_adapter[]
* @throws Exception * @throws Exception
* @throws \Doctrine\DBAL\DBALException * @throws \Doctrine\DBAL\DBALException
* @deprecated use {@link self::getChildren} instead. * @deprecated use {@link self::getChildren} instead.
@@ -1593,6 +1593,11 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
return $this->getChildren(); return $this->getChildren();
} }
/**
* @return set_selection|record_adapter[]
* @throws Exception
* @throws \Doctrine\DBAL\DBALException
*/
public function getChildren() public function getChildren()
{ {
if (!$this->isStory()) { if (!$this->isStory()) {

View File

@@ -12,36 +12,22 @@
abstract class set_abstract implements IteratorAggregate abstract class set_abstract implements IteratorAggregate
{ {
/** /**
* * @var \record_adapter[]
* @var Array
*/ */
protected $elements = []; protected $elements = [];
/** /**
*
* @return ArrayIterator * @return ArrayIterator
*/ */
public function getIterator() public function getIterator()
{ {
$this->load_elements();
return new ArrayIterator($this->elements); return new ArrayIterator($this->elements);
} }
/** /**
*
* @return set
*/
protected function load_elements()
{
return $this;
}
/**
*
* @param string $offset * @param string $offset
* @param string $value * @param record_adapter $value
* @return Void * @return void
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
@@ -53,9 +39,8 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
*
* @param string $offset * @param string $offset
* @return boolean * @return bool
*/ */
public function offsetExists($offset) public function offsetExists($offset)
{ {
@@ -63,9 +48,8 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
*
* @param string $offset * @param string $offset
* @return Void * @return void
*/ */
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
@@ -73,9 +57,8 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
*
* @param string $offset * @param string $offset
* @return record_adapter * @return record_adapter|null
*/ */
public function offsetGet($offset) public function offsetGet($offset)
{ {
@@ -83,8 +66,7 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
* * @return bool
* @return int
*/ */
public function is_empty() public function is_empty()
{ {
@@ -104,7 +86,7 @@ abstract class set_abstract implements IteratorAggregate
/** /**
* Get the number of element in the set * Get the number of element in the set
* *
* @return Int * @return int
*/ */
public function get_count() public function get_count()
{ {
@@ -112,7 +94,6 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
*
* @return int * @return int
*/ */
public function get_count_groupings() public function get_count_groupings()
@@ -127,20 +108,16 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
* * @return record_adapter[]
* @return Array
*/ */
public function get_elements() public function get_elements()
{ {
$this->load_elements();
return $this->elements; return $this->elements;
} }
/** /**
*
* @param record_adapter $record * @param record_adapter $record
* @return set * @return $this
*/ */
public function add_element(\record_adapter $record) public function add_element(\record_adapter $record)
{ {
@@ -150,9 +127,8 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
*
* @param record_adapter $record * @param record_adapter $record
* @return set * @return $this
*/ */
public function remove_element(\record_adapter $record) public function remove_element(\record_adapter $record)
{ {
@@ -164,7 +140,6 @@ abstract class set_abstract implements IteratorAggregate
} }
/** /**
*
* @return string * @return string
*/ */
public function serialize_list() public function serialize_list()

View File

@@ -12,10 +12,28 @@ use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Serializer\CaptionSerializer; use Alchemy\Phrasea\Model\Serializer\CaptionSerializer;
use Alchemy\Phrasea\Model\Entities\Token; use Alchemy\Phrasea\Model\Entities\Token;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Assert\Assertion;
use Doctrine\DBAL\Connection;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
class set_export extends set_abstract class set_export extends set_abstract
{ {
private static $maxFilenameLength = 256;
/**
* @param int $newLength
*/
public static function setMaxFilenameLength($newLength)
{
Assertion::integer($newLength);
Assertion::greaterThan($newLength, 0);
self::$maxFilenameLength = $newLength;
}
/**
* @var Application
*/
protected $app; protected $app;
protected $storage = []; protected $storage = [];
protected $total_download; protected $total_download;
@@ -30,19 +48,15 @@ class set_export extends set_abstract
protected $exportName; protected $exportName;
/** /**
*
* @param Application $app * @param Application $app
* @param string $lst * @param string $lst
* @param integer $sstid * @param int $sstid
* @param integer $storyWZid * @param int $storyWZid
* @return set_export
*/ */
public function __construct(Application $app, $lst, $sstid, $storyWZid = null) public function __construct(Application $app, $lst, $sstid, $storyWZid = null)
{ {
$this->app = $app; $this->app = $app;
$download_list = [];
$remain_hd = []; $remain_hd = [];
if ($storyWZid) { if ($storyWZid) {
@@ -60,8 +74,8 @@ class set_export extends set_abstract
$this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d"); $this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d");
foreach ($Basket->getElements() as $basket_element) { foreach ($Basket->getElements() as $basket_element) {
$base_id = $basket_element->getRecord($this->app)->get_base_id(); $base_id = $basket_element->getRecord($this->app)->getBaseId();
$record_id = $basket_element->getRecord($this->app)->get_record_id(); $record_id = $basket_element->getRecord($this->app)->getRecordId();
if (!isset($remain_hd[$base_id])) { if (!isset($remain_hd[$base_id])) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) { if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
@@ -71,14 +85,14 @@ class set_export extends set_abstract
} }
} }
$current_element = $download_list[] = $current_element = new record_exportElement(
new record_exportElement( $app,
$app, $basket_element->getRecord($this->app)->getDataboxId(),
$basket_element->getRecord($this->app)->get_sbas_id(), $record_id,
$record_id, $Basket->getName(),
$Basket->getName(), $remain_hd[$base_id]
$remain_hd[$base_id]
); );
$this->add_element($current_element);
$remain_hd[$base_id] = $current_element->get_remain_hd(); $remain_hd[$base_id] = $current_element->get_remain_hd();
} }
@@ -99,9 +113,9 @@ class set_export extends set_abstract
} }
if ($record->isStory()) { if ($record->isStory()) {
foreach ($record->get_children() as $child_basrec) { foreach ($record->getChildren() as $child_basrec) {
$base_id = $child_basrec->get_base_id(); $base_id = $child_basrec->getBaseId();
$record_id = $child_basrec->get_record_id(); $record_id = $child_basrec->getRecordId();
if (!isset($remain_hd[$base_id])) { if (!isset($remain_hd[$base_id])) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) { if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
@@ -111,20 +125,20 @@ class set_export extends set_abstract
} }
} }
$current_element = $download_list[] = $current_element = new record_exportElement(
new record_exportElement( $app,
$app, $child_basrec->getDataboxId(),
$child_basrec->get_sbas_id(), $record_id,
$record_id, $record->get_title(null, null, true) . '_' . $n,
$record->get_title(null, null, true) . '_' . $n, $remain_hd[$base_id]
$remain_hd[$base_id]
); );
$this->add_element($current_element);
$remain_hd[$base_id] = $current_element->get_remain_hd(); $remain_hd[$base_id] = $current_element->get_remain_hd();
} }
} else { } else {
$base_id = $record->get_base_id(); $base_id = $record->getBaseId();
$record_id = $record->get_record_id(); $record_id = $record->getRecordId();
if (!isset($remain_hd[$base_id])) { if (!isset($remain_hd[$base_id])) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) { if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
@@ -134,15 +148,14 @@ class set_export extends set_abstract
} }
} }
$current_element = $current_element = new record_exportElement(
$download_list[$basrec[0] . '_' . $basrec[1]] = $app,
new record_exportElement( $record->getDataboxId(),
$app, $record_id,
$record->get_sbas_id(), '',
$record_id, $remain_hd[$base_id]
'',
$remain_hd[$base_id]
); );
$this->add_element($current_element);
$remain_hd[$base_id] = $current_element->get_remain_hd(); $remain_hd[$base_id] = $current_element->get_remain_hd();
} }
@@ -150,8 +163,6 @@ class set_export extends set_abstract
} }
} }
$this->elements = $download_list;
$display_download = []; $display_download = [];
$display_orderable = []; $display_orderable = [];
@@ -161,18 +172,19 @@ class set_export extends set_abstract
$this->businessFieldsAccess = false; $this->businessFieldsAccess = false;
foreach ($this->elements as $download_element) { /** @var record_exportElement $download_element */
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) { foreach ($this->get_elements() as $download_element) {
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($download_element->getBaseId(), 'canmodifrecord')) {
$this->businessFieldsAccess = true; $this->businessFieldsAccess = true;
} }
foreach ($download_element->get_downloadable() as $name => $properties) { foreach ($download_element->get_downloadable() as $name => $properties) {
if (!isset($display_download[$name])) { if (!isset($display_download[$name])) {
$display_download[$name] = [ $display_download[$name] = [
'size' => 0, 'size' => 0,
'total' => 0, 'total' => 0,
'available' => 0, 'available' => 0,
'refused' => [] 'refused' => [],
]; ];
} }
@@ -191,9 +203,9 @@ class set_export extends set_abstract
foreach ($download_element->get_orderable() as $name => $properties) { foreach ($download_element->get_orderable() as $name => $properties) {
if (!isset($display_orderable[$name])) { if (!isset($display_orderable[$name])) {
$display_orderable[$name] = [ $display_orderable[$name] = [
'total' => 0, 'total' => 0,
'available' => 0, 'available' => 0,
'refused' => [] 'refused' => [],
]; ];
} }
@@ -209,7 +221,7 @@ class set_export extends set_abstract
} }
foreach ($display_download as $name => $values) { foreach ($display_download as $name => $values) {
$display_download[$name]['size'] = (int) $values['size']; $display_download[$name]['size'] = (int)$values['size'];
} }
$display_ftp = []; $display_ftp = [];
@@ -222,79 +234,73 @@ class set_export extends set_abstract
$this->ftp_datas = []; $this->ftp_datas = [];
if ($this->app['conf']->get(['registry', 'ftp', 'ftp-enabled']) && ($hasadminright || $this->app['conf']->get(['registry', 'ftp', 'ftp-user-access']))) { if ($this->app['conf']->get([
'registry',
'ftp',
'ftp-enabled',
]) && ($hasadminright || $this->app['conf']->get(['registry', 'ftp', 'ftp-user-access']))
) {
$display_ftp = $display_download; $display_ftp = $display_download;
$this->total_ftp = $this->total_download; $this->total_ftp = $this->total_download;
$lst_base_id = array_keys($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base()); $lst_base_id = array_keys($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base());
if ($hasadminright) { $userFilterSQL = '';
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.* $params = [];
FROM ( $types = [];
FtpCredential INNER JOIN Users ON (
FtpCredential.active = 1 AND FtpCredential.user_id = Users.id if (!$hasadminright) {
) INNER JOIN basusr ON ( $userFilterSQL = ' AND Users.id = :usr_id';
Users.id=basusr.usr_id $params['usr_id'] = $app->getAuthenticatedUser()->getId();
AND (basusr.base_id= $types['usr_id'] = PDO::PARAM_INT;
'" . implode("' OR basusr.base_id='", $lst_base_id) . "'
)
)
)
GROUP BY Users.id ";
$params = [];
} elseif ($this->app['conf']->get(['registry', 'ftp', 'ftp-user-access'])) {
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
FROM (
FtpCredential INNER JOIN Users ON (
FtpCredential.active = 1 AND FtpCredential.id = Users.id
) INNER JOIN basusr ON (
Users.id=basusr.usr_id
AND Users.id = :usr_id
AND (basusr.base_id=
'" . implode("' OR basusr.base_id='", $lst_base_id) . "'
)
)
)
GROUP BY Users.id ";
$params = [':usr_id' => $app->getAuthenticatedUser()->getId()];
} }
$sql = <<<SQL
SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
FROM (
FtpCredential INNER JOIN Users ON (FtpCredential.active = 1 AND FtpCredential.user_id = Users.id)
INNER JOIN basusr ON (
Users.id=basusr.usr_id
${userFilterSQL}
AND (basusr.base_id IN (:baseIds))
)
)
GROUP BY Users.id
SQL;
$params['baseIds'] = $lst_base_id;
$types['baseIds'] = Connection::PARAM_INT_ARRAY;
$datas[] = [ $datas[] = [
'name' => $app->trans('export::ftp: reglages manuels'), 'name' => $app->trans('export::ftp: reglages manuels'),
'usr_id' => '0', 'usr_id' => '0',
'address' => '', 'address' => '',
'login' => '', 'login' => '',
'password' => '', 'password' => '',
'ssl' => false, 'ssl' => false,
'dest_folder' => '', 'dest_folder' => '',
'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"), 'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"),
'passive' => false, 'passive' => false,
'max_retry' => 5, 'max_retry' => 5,
'sendermail' => $app->getAuthenticatedUser()->getEmail() 'sendermail' => $app->getAuthenticatedUser()->getEmail(),
]; ];
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql); foreach ($app->getApplicationBox()->get_connection()->fetchAll($sql, $params, $types) as $row) {
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
$datas[] = [ $datas[] = [
'name' => $row["usr_login"], 'name' => $row["usr_login"],
'usr_id' => $row['usr_id'], 'usr_id' => $row['usr_id'],
'address' => $row['address'], 'address' => $row['address'],
'login' => $row['login'], 'login' => $row['login'],
'password' => $row['password'], 'password' => $row['password'],
'ssl' => !! $row['tls'], 'ssl' => !!$row['tls'],
'dest_folder' => $row['reception_folder'], 'dest_folder' => $row['reception_folder'],
'prefix_folder' => 'prefix_folder' =>
(strlen(trim($row['repository_prefix_name'])) > 0 ? (strlen(trim($row['repository_prefix_name'])) > 0 ?
trim($row['repository_prefix_name']) : trim($row['repository_prefix_name']) :
'Export_' . date("Y-m-d_H.i.s")), 'Export_' . date("Y-m-d_H.i.s")),
'passive' => !! $row['passive'], 'passive' => !!$row['passive'],
'max_retry' => $row['max_retry'], 'max_retry' => $row['max_retry'],
'usr_mail' => $row['usr_mail'], 'usr_mail' => $row['usr_mail'],
'sender_mail' => $app->getAuthenticatedUser()->getEmail() 'sender_mail' => $app->getAuthenticatedUser()->getEmail(),
]; ];
} }
@@ -304,8 +310,6 @@ class set_export extends set_abstract
$this->display_orderable = $display_orderable; $this->display_orderable = $display_orderable;
$this->display_download = $display_download; $this->display_download = $display_download;
$this->display_ftp = $display_ftp; $this->display_ftp = $display_ftp;
return $this;
} }
/** /**
@@ -319,8 +323,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return array
* @return Array
*/ */
public function get_ftp_datas() public function get_ftp_datas()
{ {
@@ -333,8 +336,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return array
* @return Array
*/ */
public function get_display_orderable() public function get_display_orderable()
{ {
@@ -342,8 +344,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return array
* @return Array
*/ */
public function get_display_download() public function get_display_download()
{ {
@@ -351,8 +352,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return array
* @return Array
*/ */
public function get_display_ftp() public function get_display_ftp()
{ {
@@ -360,8 +360,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return int
* @return Int
*/ */
public function get_total_download() public function get_total_download()
{ {
@@ -369,8 +368,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return int
* @return Int
*/ */
public function get_total_order() public function get_total_order()
{ {
@@ -378,8 +376,7 @@ class set_export extends set_abstract
} }
/** /**
* * @return int
* @return Int
*/ */
public function get_total_ftp() public function get_total_ftp()
{ {
@@ -387,16 +384,15 @@ class set_export extends set_abstract
} }
/** /**
* * @param User $user
* @param User $user
* @param Filesystem $filesystem * @param Filesystem $filesystem
* @param Array $subdefs * @param array $subdefs
* @param boolean $rename_title * @param bool $rename_title
* @param boolean $includeBusinessFields * @param bool $includeBusinessFields
* * @return array
* @return Array * @throws Exception
*/ */
public function prepare_export(User $user, Filesystem $filesystem, Array $subdefs, $rename_title, $includeBusinessFields) public function prepare_export(User $user, Filesystem $filesystem, array $subdefs, $rename_title, $includeBusinessFields)
{ {
if (!is_array($subdefs)) { if (!is_array($subdefs)) {
throw new Exception('No subdefs given'); throw new Exception('No subdefs given');
@@ -414,32 +410,33 @@ class set_export extends set_abstract
$unicode = new \unicode(); $unicode = new \unicode();
foreach ($this->elements as $download_element) { /** @var record_exportElement $download_element */
foreach ($this->get_elements() as $download_element) {
$id = count($files); $id = count($files);
$files[$id] = [ $files[$id] = [
'base_id' => $download_element->get_base_id(), 'base_id' => $download_element->getBaseId(),
'record_id' => $download_element->get_record_id(), 'record_id' => $download_element->getRecordId(),
'original_name' => '', 'original_name' => '',
'export_name' => '', 'export_name' => '',
'subdefs' => [] 'subdefs' => [],
]; ];
$BF = false; $BF = false;
if ($includeBusinessFields && $this->app->getAclForUser($user)->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) { if ($includeBusinessFields && $this->app->getAclForUser($user)->has_right_on_base($download_element->getBaseId(), 'canmodifrecord')) {
$BF = true; $BF = true;
} }
$desc = $this->app['serializer.caption']->serialize($download_element->get_caption(), CaptionSerializer::SERIALIZE_XML, $BF); $desc = $this->app['serializer.caption']->serialize($download_element->get_caption(), CaptionSerializer::SERIALIZE_XML, $BF);
$files[$id]['original_name'] = $files[$id]['original_name'] =
$files[$id]['export_name'] = $files[$id]['export_name'] =
$download_element->get_original_name(true); $download_element->get_original_name(true);
$files[$id]['original_name'] = $files[$id]['original_name'] =
trim($files[$id]['original_name']) != '' ? trim($files[$id]['original_name']) != '' ?
$files[$id]['original_name'] : $id; $files[$id]['original_name'] : $id;
$infos = pathinfo($files[$id]['original_name']); $infos = pathinfo($files[$id]['original_name']);
@@ -456,13 +453,14 @@ class set_export extends set_abstract
$sizeMaxAjout = 0; $sizeMaxAjout = 0;
$sizeMaxExt = 0; $sizeMaxExt = 0;
$sd = $download_element->get_subdefs();
foreach ($download_element->get_downloadable() as $name => $properties) { foreach ($download_element->get_downloadable() as $name => $properties) {
if ($properties === false || !in_array($name, $subdefs)) { if ($properties === false || !in_array($name, $subdefs)) {
continue; continue;
} }
if (!in_array($name, ['caption', 'caption-yaml']) && !isset($sd[$name])) {
$subdef = $download_element->get_subdef($name);
if (!in_array($name, ['caption', 'caption-yaml']) && !isset($subdef)) {
continue; continue;
} }
@@ -481,23 +479,23 @@ class set_export extends set_abstract
break; break;
case 'thumbnail': case 'thumbnail':
$tmp_pathfile = [ $tmp_pathfile = [
'path' => $sd[$name]->get_path() 'path' => $subdef->get_path(),
, 'file' => $sd[$name]->get_file() 'file' => $subdef->get_file(),
]; ];
$subdef_export = true; $subdef_export = true;
$subdef_alive = true; $subdef_alive = true;
break; break;
case 'document': case 'document':
$subdef_export = true; $subdef_export = true;
$path = \recordutils_image::stamp($this->app , $sd[$name]); $path = \recordutils_image::stamp($this->app, $subdef);
$tmp_pathfile = [ $tmp_pathfile = [
'path' => $sd[$name]->get_path() 'path' => $subdef->get_path(),
, 'file' => $sd[$name]->get_file() 'file' => $subdef->get_file(),
]; ];
if (file_exists($path)) { if (file_exists($path)) {
$tmp_pathfile = [ $tmp_pathfile = [
'path' => dirname($path) 'path' => dirname($path),
, 'file' => basename($path) 'file' => basename($path),
]; ];
$subdef_alive = true; $subdef_alive = true;
} }
@@ -507,17 +505,18 @@ class set_export extends set_abstract
$subdef_export = true; $subdef_export = true;
$tmp_pathfile = [ $tmp_pathfile = [
'path' => $sd[$name]->get_path() 'path' => $subdef->get_path(),
, 'file' => $sd[$name]->get_file() 'file' => $subdef->get_file(),
]; ];
if (!$this->app->getAclForUser($user)->has_right_on_base($download_element->get_base_id(), "nowatermark") if (!$this->app->getAclForUser($user)->has_right_on_base($download_element->getBaseId(), "nowatermark")
&& !$this->app->getAclForUser($user)->has_preview_grant($download_element) && !$this->app->getAclForUser($user)->has_preview_grant($download_element)
&& $sd[$name]->get_type() == media_subdef::TYPE_IMAGE) { && $subdef->get_type() == media_subdef::TYPE_IMAGE
$path = recordutils_image::watermark($this->app, $sd[$name]); ) {
$path = recordutils_image::watermark($this->app, $subdef);
if (file_exists($path)) { if (file_exists($path)) {
$tmp_pathfile = [ $tmp_pathfile = [
'path' => dirname($path) 'path' => dirname($path),
, 'file' => basename($path) 'file' => basename($path),
]; ];
$subdef_alive = true; $subdef_alive = true;
} }
@@ -560,14 +559,12 @@ class set_export extends set_abstract
$files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"]; $files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"];
$files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"]; $files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"];
$files[$id]["subdefs"][$name]["label"] = $properties['label']; $files[$id]["subdefs"][$name]["label"] = $properties['label'];
$files[$id]["subdefs"][$name]["size"] = $sd[$name]->get_size(); $files[$id]["subdefs"][$name]["size"] = $subdef->get_size();
$files[$id]["subdefs"][$name]["mime"] = $sd[$name]->get_mime(); $files[$id]["subdefs"][$name]["mime"] = $subdef->get_mime();
$files[$id]["subdefs"][$name]["folder"] = $files[$id]["subdefs"][$name]["folder"] = $download_element->get_directory();
$download_element->get_directory(); $files[$id]["subdefs"][$name]["exportExt"] = isset($infos['extension']) ? $infos['extension'] : '';
$files[$id]["subdefs"][$name]["exportExt"] =
isset($infos['extension']) ? $infos['extension'] : '';
$size += $sd[$name]->get_size(); $size += $subdef->get_size();
break; break;
} }
@@ -582,7 +579,7 @@ class set_export extends set_abstract
} }
} }
$max_length = 31 - $sizeMaxExt - $sizeMaxAjout; $max_length = self::$maxFilenameLength - 1 - $sizeMaxExt - $sizeMaxAjout;
$name = $files[$id]["export_name"]; $name = $files[$id]["export_name"];
@@ -595,7 +592,7 @@ class set_export extends set_abstract
while (in_array(mb_strtolower($name), $file_names)) { while (in_array(mb_strtolower($name), $file_names)) {
$n++; $n++;
$suffix = "-" . $n; // pour diese si besoin $suffix = "-" . $n; // pour diese si besoin
$max_length = 31 - $sizeMaxExt - $sizeMaxAjout - mb_strlen($suffix); $max_length = self::$maxFilenameLength - 1 - $sizeMaxExt - $sizeMaxAjout - mb_strlen($suffix);
$name = mb_strtolower($files[$id]["export_name"]); $name = mb_strtolower($files[$id]["export_name"]);
if ($start_length > $max_length) if ($start_length > $max_length)
$name = mb_substr($name, 0, $max_length) . $suffix; $name = mb_substr($name, 0, $max_length) . $suffix;
@@ -611,10 +608,12 @@ class set_export extends set_abstract
$i = 0; $i = 0;
$name = utf8_decode($files[$id]["export_name"]); $name = utf8_decode($files[$id]["export_name"]);
$tmp_name = ""; $tmp_name = "";
$good_keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', $good_keys = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '-', '_', '.', '#']; '4', '5', '6', '7', '8', '9', '-', '_', '.', '#',
];
while (isset($name[$i])) { while (isset($name[$i])) {
if (!in_array(mb_strtolower($name[$i]), $good_keys)) if (!in_array(mb_strtolower($name[$i]), $good_keys))
@@ -629,7 +628,7 @@ class set_export extends set_abstract
$files[$id]["export_name"] = $tmp_name; $files[$id]["export_name"] = $tmp_name;
if (in_array('caption', $subdefs)) { if (in_array('caption', $subdefs)) {
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app->getAuthenticatedUser()->getId().'/'; $caption_dir = $this->app['tmp.caption.path'] . '/' . time() . $this->app->getAuthenticatedUser()->getId() . '/';
$filesystem->mkdir($caption_dir, 0750); $filesystem->mkdir($caption_dir, 0750);
@@ -650,7 +649,7 @@ class set_export extends set_abstract
} }
if (in_array('caption-yaml', $subdefs)) { if (in_array('caption-yaml', $subdefs)) {
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app->getAuthenticatedUser()->getId().'/'; $caption_dir = $this->app['tmp.caption.path'] . '/' . time() . $this->app->getAuthenticatedUser()->getId() . '/';
$filesystem->mkdir($caption_dir, 0750); $filesystem->mkdir($caption_dir, 0750);
@@ -674,23 +673,22 @@ class set_export extends set_abstract
$this->list = [ $this->list = [
'files' => $files, 'files' => $files,
'names' => $file_names, 'names' => $file_names,
'size' => $size, 'size' => $size,
'count' => $n_files 'count' => $n_files,
]; ];
return $this->list; return $this->list;
} }
/** /**
*
* @param Application $app * @param Application $app
* @param String $token * @param Token $token
* @param Array $list * @param array $list
* @param string $zipFile * @param string $zipFile
* *
* @return string * @return string
*/ */
public static function build_zip(Application $app, Token $token, Array $list, $zipFile) public static function build_zip(Application $app, Token $token, array $list, $zipFile)
{ {
if (isset($list['complete']) && $list['complete'] === true) { if (isset($list['complete']) && $list['complete'] === true) {
return; return;
@@ -745,19 +743,22 @@ class set_export extends set_abstract
* @todo a revoir le cas anonymous * @todo a revoir le cas anonymous
* *
* @param Application $app * @param Application $app
* @param Array $list * @param array $list
* @param String $type * @param String $type
* @param boolean $anonymous * @param boolean $anonymous
* @param string $comment * @param string $comment
* *
* @return Void * @return void
*/ */
public static function log_download(Application $app, Array $list, $type, $anonymous = false, $comment = '') public static function log_download(Application $app, array $list, $type, $anonymous = false, $comment = '')
{ {
$tmplog = []; $tmplog = [];
$files = $list['files']; $files = $list['files'];
$event_name = in_array($type, [Session_Logger::EVENT_EXPORTMAIL,Session_Logger::EVENT_EXPORTDOWNLOAD]) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD; $event_name = in_array($type, [
Session_Logger::EVENT_EXPORTMAIL,
Session_Logger::EVENT_EXPORTDOWNLOAD,
]) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD;
foreach ($files as $record) { foreach ($files as $record) {
foreach ($record["subdefs"] as $o => $obj) { foreach ($record["subdefs"] as $o => $obj) {
@@ -765,16 +766,16 @@ class set_export extends set_abstract
$record_object = new record_adapter($app, $sbas_id, $record['record_id']); $record_object = new record_adapter($app, $sbas_id, $record['record_id']);
$app['phraseanet.logger']($record_object->get_databox())->log($record_object, $event_name, $o, $comment); $app['phraseanet.logger']($record_object->getDatabox())->log($record_object, $event_name, $o, $comment);
if ($o != "caption") { if ($o != "caption") {
$log["rid"] = $record_object->get_record_id(); $log["rid"] = $record_object->getRecordId();
$log["subdef"] = $o; $log["subdef"] = $o;
$log["poids"] = $obj["size"]; $log["poids"] = $obj["size"];
$log["shortXml"] = $app['serializer.caption']->serialize($record_object->get_caption(), CaptionSerializer::SERIALIZE_XML); $log["shortXml"] = $app['serializer.caption']->serialize($record_object->get_caption(), CaptionSerializer::SERIALIZE_XML);
$tmplog[$record_object->get_base_id()][] = $log; $tmplog[$record_object->getBaseId()][] = $log;
if (!$anonymous && $o == 'document' && null !== $app->getAuthenticatedUser()) { if (!$anonymous && $o == 'document' && null !== $app->getAuthenticatedUser()) {
$app->getAclForUser($app->getAuthenticatedUser())->remove_remaining($record_object->get_base_id()); $app->getAclForUser($app->getAuthenticatedUser())->remove_remaining($record_object->getBaseId());
} }
} }
@@ -794,9 +795,9 @@ class set_export extends set_abstract
foreach ($list_base as $base_id) { foreach ($list_base as $base_id) {
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) { if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
$params = [ $params = [
':remain_dl' => $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id) ':remain_dl' => $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id),
, ':base_id' => $base_id ':base_id' => $base_id,
, ':usr_id' => $app->getAclForUser($app->getAuthenticatedUser())->getId() ':usr_id' => $app->getAuthenticatedUser()->getId(),
]; ];
$stmt->execute($params); $stmt->execute($params);
@@ -805,7 +806,5 @@ class set_export extends set_abstract
$stmt->closeCursor(); $stmt->closeCursor();
} }
return;
} }
} }

View File

@@ -14,21 +14,17 @@ use Alchemy\Phrasea\Model\Entities\Basket;
class set_selection extends set_abstract class set_selection extends set_abstract
{ {
protected $app;
/** /**
* * @var Application
* @return set_selection
*/ */
protected $app;
public function __construct(Application $app) public function __construct(Application $app)
{ {
$this->app = $app; $this->app = $app;
$this->elements = [];
return $this;
} }
/** /**
*
* @param Basket $Basket * @param Basket $Basket
* @return set_selection * @return set_selection
*/ */
@@ -42,20 +38,19 @@ class set_selection extends set_abstract
} }
/** /**
*
* @param array $rights * @param array $rights
* @param array $sbas_rights * @param array $sbas_rights
* *
* @return set_selection * @return set_selection
*/ */
public function grep_authorized(Array $rights = [], Array $sbas_rights = []) public function grep_authorized(array $rights = [], array $sbas_rights = [])
{ {
$to_remove = []; $to_remove = [];
foreach ($this->elements as $id => $record) { foreach ($this->get_elements() as $id => $record) {
$base_id = $record->get_base_id(); $base_id = $record->getBaseId();
$sbas_id = $record->get_sbas_id(); $sbas_id = $record->getDataboxId();
$record_id = $record->get_record_id(); $record_id = $record->getRecordId();
if (! $rights) { if (! $rights) {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($record)) { if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($record)) {
continue; continue;
@@ -84,7 +79,7 @@ class set_selection extends set_abstract
} }
try { try {
$connsbas = $record->get_databox()->get_connection(); $connsbas = $record->getDatabox()->get_connection();
$sql = 'SELECT record_id $sql = 'SELECT record_id
FROM record FROM record
@@ -105,31 +100,30 @@ class set_selection extends set_abstract
} }
} }
foreach ($to_remove as $id) { foreach ($to_remove as $id) {
unset($this->elements[$id]); $this->offsetUnset($id);
} }
return $this; return $this;
} }
/** /**
*
* @param array $lst * @param array $lst
* @param Boolean $flatten_groupings * @param Boolean $flatten_groupings
* *
* @return set_selection * @return set_selection
*/ */
public function load_list(Array $lst, $flatten_groupings = false) public function load_list(array $lst, $flatten_groupings = false)
{ {
foreach ($lst as $basrec) { foreach ($lst as $basrec) {
$basrec = explode('_', $basrec); $basrec = explode('_', $basrec);
if (count($basrec) == 2) { if (count($basrec) == 2) {
try { try {
$record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], count($this->elements)); $record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], $this->get_count());
} catch (\Exception $e) { } catch (\Exception $e) {
continue; continue;
} }
if ($record->isStory() && $flatten_groupings === true) { if ($record->isStory() && $flatten_groupings === true) {
foreach ($record->get_children() as $rec) { foreach ($record->getChildren() as $rec) {
$this->add_element($rec); $this->add_element($rec);
} }
} else { } else {
@@ -142,14 +136,13 @@ class set_selection extends set_abstract
} }
/** /**
* * @return array<int>
* @return array
*/ */
public function get_distinct_sbas_ids() public function get_distinct_sbas_ids()
{ {
$ret = []; $ret = [];
foreach ($this->elements as $record) { foreach ($this->get_elements() as $record) {
$sbas_id = phrasea::sbasFromBas($this->app, $record->get_base_id()); $sbas_id = $record->getDataboxId();
$ret[$sbas_id] = $sbas_id; $ret[$sbas_id] = $sbas_id;
} }

View File

@@ -384,7 +384,7 @@ function manageSession(data, showMessages) {
$('body').append('<div id="#MESSAGE"></div>'); $('body').append('<div id="#MESSAGE"></div>');
$('#MESSAGE') $('#MESSAGE')
.empty() .empty()
.append(data.message + '<div style="margin:20px;"><input type="checkbox" class="dialog_remove" />' + language.hideMessage + '</div>') .append('<div style="margin:30px 10px;"><h4><b>' + data.message + '</b></h4></div><div style="margin:20px 0px 10px;"><label class="checkbox"><input type="checkbox" class="dialog_remove" />' + language.hideMessage + '</label></div>')
.attr('title', 'Global Message') .attr('title', 'Global Message')
.dialog({ .dialog({
autoOpen: false, autoOpen: false,
@@ -393,8 +393,20 @@ function manageSession(data, showMessages) {
draggable: false, draggable: false,
modal: true, modal: true,
close: function () { close: function () {
if ($('.dialog_remove:checked', $(this)).length > 0) if ($('.dialog_remove:checked', $(this)).length > 0) {
setTemporaryPref('message', 0); // setTemporaryPref
$.ajax({
type: "POST",
url: "/user/preferences/temporary/",
data: {
prop: 'message',
value: 0
},
success: function (data) {
return;
}
});
}
} }
}) })
.dialog('open'); .dialog('open');

View File

@@ -413,13 +413,13 @@
this.list = null; this.list = null;
this.container = $container; this.container = $container;
$('.back_link', this.container).bind('click', function () { $container.on('click', '.back_link', function() {
$('#PushBox').show(); $('#PushBox').show();
$('#ListManager').hide(); $('#ListManager').hide();
return false; return false;
}); });
$('a.list_sharer', this.container).off('click').on('click', function () { $container.on('click', 'a.list_sharer', function() {
var $this = $(this), var $this = $(this),
options = { options = {
@@ -434,8 +434,7 @@
return false; return false;
}); });
$container.on('click', 'a.user_adder', function() {
$('a.user_adder', this.container).bind('click', function () {
var $this = $(this); var $this = $(this);

View File

@@ -751,18 +751,19 @@ function linearize() {
$('#answers .list').width(w); $('#answers .list').width(w);
} }
else { else {
var minMargin = 5;
var margin = 0; var margin = 0;
var el = $('#answers .diapo:first'); var el = $('#answers .diapo:first');
var brdrWidth = el.css('border-width'); var diapoWidth = el.outerWidth() + (minMargin * 2);
var stdWidth = el.outerWidth() + 10;
var fllWidth = $('#answers').innerWidth(); var fllWidth = $('#answers').innerWidth();
fllWidth -= 16; fllWidth -= 26;
var n = Math.floor(fllWidth / (stdWidth)); var n = Math.floor(fllWidth / (diapoWidth));
margin = Math.floor((fllWidth % stdWidth) / (2 * n)); margin = Math.floor((fllWidth % diapoWidth) / (2 * n));
$('#answers .diapo').css('margin', '5px ' + (5 + margin) + 'px'); margin = margin + minMargin;
$('#answers .diapo').css('margin', '5px ' + (margin) + 'px');
} }
} }
@@ -1209,7 +1210,7 @@ $(document).ready(function () {
$('#idFrameC .icon-menu li').last().find('a').trigger('click'); $('#idFrameC .icon-menu li').last().find('a').trigger('click');
$('#idFrameC .icon-menu li').first().find('a').trigger('click'); $('#idFrameC .icon-menu li').first().find('a').trigger('click');
$(previousTab).find('a').trigger('click'); $(previousTab).find('a').trigger('click');
} }
event.stopImmediatePropagation(); event.stopImmediatePropagation();
//p4.WorkZone.close(); //p4.WorkZone.close();

View File

@@ -87,6 +87,14 @@ function openPreview(env, pos, contId, reload) {
// update real absolute position with pagination: // update real absolute position with pagination:
var absolutePos = parseInt(navigation.perPage,10) * (parseInt(navigation.page, 10) - 1) + parseInt(pos,10); var absolutePos = parseInt(navigation.perPage,10) * (parseInt(navigation.page, 10) - 1) + parseInt(pos,10);
// if comes from story, work with relative positionning
if (env == 'REG') {
// @TODO - if event comes from workzone (basket|story),
// we can use the relative position in order to display the doubleclicked records
// except we can't know the original event in this implementation
absolutePos = 0;
}
prevAjax = $.ajax({ prevAjax = $.ajax({
type: "POST", type: "POST",
url: "../prod/records/", url: "../prod/records/",

View File

@@ -673,6 +673,11 @@ function edit_clk_editimg(evt, i) {
updateEditSelectedRecords(evt); updateEditSelectedRecords(evt);
} }
function toggleGroupSelection() {
var groupIndex = 0;
edit_clk_editimg(false, groupIndex);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// on a clique sur une checkbox de status // on a clique sur une checkbox de status
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1651,7 +1656,12 @@ function startThisEditing(sbas_id, what, regbasprid, ssel) {
if ($('#editcontextwrap').length == 0) if ($('#editcontextwrap').length == 0)
$('body').append('<div id="editcontextwrap"></div>'); $('body').append('<div id="editcontextwrap"></div>');
self.setTimeout("edit_select_all();", 100); // if is a group, only select the group
if (p4.edit.what === 'GRP') {
toggleGroupSelection();
} else {
self.setTimeout("edit_select_all();", 100);
}
$('.previewTips, .DCESTips, .fieldTips', p4.edit.editBox).tooltip({ $('.previewTips, .DCESTips, .fieldTips', p4.edit.editBox).tooltip({
fixable: true, fixable: true,

View File

@@ -88,10 +88,6 @@ a:hover {
TEXT-DECORATION: none TEXT-DECORATION: none
} }
#desktop {
min-width: 1100px;
}
EM { EM {
FONT-STYLE: normal; FONT-STYLE: normal;
BACKGROUND-COLOR: #D82400; BACKGROUND-COLOR: #D82400;
@@ -535,6 +531,7 @@ h4 {
@import 'ui-components/thumb-extractor'; @import 'ui-components/thumb-extractor';
@import 'ui-components/pagination'; @import 'ui-components/pagination';
@import 'ui-components/upload'; @import 'ui-components/upload';
@import 'ui-components/modal-basket-pref';
@import 'ui-components/modal-publish'; @import 'ui-components/modal-publish';
@import 'ui-components/modal-edit'; @import 'ui-components/modal-edit';
@import 'ui-components/modal-export'; @import 'ui-components/modal-export';
@@ -550,4 +547,4 @@ h4 {
@import 'ui-components/modal-preview'; @import 'ui-components/modal-preview';
@import 'ui-components/modal-push'; @import 'ui-components/modal-push';
@import 'ui-components/diapo'; @import 'ui-components/diapo';
@import 'ui-components/modal-preferences'; @import 'ui-components/modal-preferences';

View File

@@ -38,6 +38,7 @@ $answersInfoLabelColor: #949494 !default;
#answers { #answers {
box-sizing: border-box;
.status { .status {
img { img {
max-width: 16px; max-width: 16px;
@@ -54,14 +55,19 @@ $answersInfoLabelColor: #949494 !default;
cursor: pointer; cursor: pointer;
} }
.list { .list {
box-sizing: border-box;
position: relative; position: relative;
float: left; float: left;
margin: 10px; margin: 8px;
width: 600px; width: 600px;
overflow: hidden; overflow: hidden;
border: 3px solid $darkerBorderColor; border: 3px solid $darkerBorderColor;
.diapo {
margin: 5px;
}
.desc { .desc {
.dl-horizontal { .dl-horizontal {
margin-bottom: 0;
dt { dt {
width: 70px; //100 width: 70px; //100
} }
@@ -78,7 +84,7 @@ $answersInfoLabelColor: #949494 !default;
background-color: $darkerBackgroundColor; background-color: $darkerBackgroundColor;
top: 55px; top: 55px;
bottom: 0; bottom: 0;
margin-right: 8px; margin-right: 0;
//overflow-y: hidden; //overflow-y: hidden;
padding-left: 10px; padding-left: 10px;
overflow-y: auto; overflow-y: auto;

View File

@@ -0,0 +1,146 @@
#BasketBrowser {
h1 {
font-size: 14px;
line-height: 20px;
margin: 0;
padding: 0;
}
.Browser {
background-color: $mediumBackgroundColor;
}
.Basket {
background-color: $mediumBackgroundColor;
display: none;
.thumb_wrapper {
margin: 5px;
}
}
.result {
position: relative;
height: 100px;
.PNB10 {
overflow: hidden;
}
table {
height: 80px;
}
&.odd {
background-color: $darkBackgroundColor;
}
td.thumbnail {
display: table-cell;
width: 105px;
height: 80px;
padding: 0;
border: none;
border-radius: 0;
box-shadow: none;
line-height: 18px;
text-align: center;
vertical-align: top;
&.content {
width: 390px;
vertical-align: top;
}
.counter {
bottom: 18px;
font-size: 14px;
position: relative;
right: 5px;
text-align: right;
}
}
}
.results {
.datas {
top: 50px;
bottom: 50px;
overflow-y: auto;
overflow-x: hidden;
}
.header, .footer {
height: 50px;
}
.header {
bottom: auto;
}
.footer {
top: auto;
}
.result h1.title {
font-size: 14px;
}
}
form {
h1 {
margin: 10px 0;
}
ul li {
padding: 0;
border-top: 1px solid #9A9A9A;
&.first {
border-top: none;
}
label {
padding: 3px 0 2px 20px;
}
}
}
h1.title .loader {
display: none;
margin: 4px;
}
img {
vertical-align: middle;
}
table {
width: 100%;
border: none;
vertical-align: top;
td.paginator {
text-align: right;
}
}
input {
display: none;
&.Query {
padding: 3px;
display: block;
border-radius: 4px;
width: 155px;
padding-left: 25px;
}
}
label {
cursor: pointer;
color: #9a9a9a;
}
input:checked + label,
label.selected {
background-color: $highlightDarkerColor;
color: $highlightTextColor;
}
}

View File

@@ -31,7 +31,7 @@
{% set class_status = '' %} {% set class_status = '' %}
{% endif %} {% endif %}
<div pos="{{ i }}" id="idEditDiapo_{{ i }}" class="diapo selected {{ class_status }}" style="width:{{ cont_width }}px; height:{{ cont_height }}px;"> <div pos="{{ i }}" id="idEditDiapo_{{ i }}" class="diapo {{ class_status }}" style="width:{{ cont_width }}px; height:{{ cont_height }}px;">
<div class='titre'> <div class='titre'>
{{ record.get_original_name() }} {{ record.get_original_name() }}
</div> </div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
<?php <?php
namespace Alchemy\Tests\Phrasea\Controller\Prod; namespace Alchemy\Tests\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Model\Entities\User;
/** /**
* @group functional * @group functional
@@ -130,22 +131,28 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testExportFtp() public function testExportFtp()
{ {
if (!self::$DI['app']['conf']->get(['registry', 'ftp', 'ftp-enabled'])) { $app = $this->getApplication();
self::$DI['app']['conf']->set(['registry', 'ftp', 'ftp-enabled'], true);
if (!$app['conf']->get(['registry', 'ftp', 'ftp-enabled'])) {
$app['conf']->set(['registry', 'ftp', 'ftp-enabled'], true);
self::$GV_activeFTP = true; self::$GV_activeFTP = true;
} }
/** @var User $user */
$user = self::$DI['user'];
//inserted rows from this function are deleted in tearDownAfterClass //inserted rows from this function are deleted in tearDownAfterClass
self::$DI['client']->request('POST', '/prod/export/ftp/', [ $this->getClient()->request('POST', '/prod/export/ftp/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => $this->getRecord1()->get_serialize_key(),
'user_dest' => self::$DI['user']->getId(), 'user_dest' => $user->getId(),
'address' => 'local.phrasea.test', 'address' => 'local.phrasea.test',
'login' => self::$DI['user']->getEmail(), 'login' => $user->getEmail(),
'dest_folder' => '/home/test/', 'dest_folder' => '/home/test/',
'prefix_folder' => 'test2/', 'prefix_folder' => 'test2/',
'obj' => ['preview'] 'obj' => ['preview']
]); ]);
$response = self::$DI['client']->getResponse(); $response = $this->getClient()->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$datas = (array) json_decode($response->getContent()); $datas = (array) json_decode($response->getContent());
$this->assertArrayHasKey('success', $datas); $this->assertArrayHasKey('success', $datas);
@@ -161,13 +168,13 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport'); $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport');
self::$DI['client']->request('POST', '/prod/export/mail/', [ $this->getClient()->request('POST', '/prod/export/mail/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => $this->getRecord1()->get_serialize_key(),
'destmail' => 'user@example.com', 'destmail' => 'user@example.com',
'obj' => ['preview'], 'obj' => ['preview'],
]); ]);
$response = self::$DI['client']->getResponse(); $response = $this->getClient()->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
@@ -177,8 +184,8 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testRequireAuthentication() public function testRequireAuthentication()
{ {
$this->logout(self::$DI['app']); $this->logout($this->getApplication());
self::$DI['client']->request('POST', '/prod/export/multi-export/'); $this->getClient()->request('POST', '/prod/export/multi-export/');
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue($this->getClient()->getResponse()->isRedirect());
} }
} }