Merge branch 'master' into elastic-indexer

Conflicts:
	.gitignore
This commit is contained in:
Damien Alexandre
2014-09-08 11:39:02 +02:00
2224 changed files with 1709 additions and 14016 deletions

73
.gitignore vendored
View File

@@ -1,20 +1,61 @@
# Exclude common IDE project files
/nbproject
/config/custom_files
/config/templates
/config/topics
/config/wm
/config/minilogos
/config/status
/config/stamp
/config/configuration.yml
/vendor
/plugins
/node_modules
composer.phar
behat.yml
/datas
/.idea
# Exclude javascript dependencies folder
/www/assets
/tmp-assets
# Exclude node.js dependencies folder
/node_modules
# Exclude compiled LESS folder
/www/skins/build
# Exclude compiled javascript test fixture folder
/www/scripts/tests/fixtures
/.vagrant/
/bin/
# Exclude configuration folder exception the configuration sample file
/config
!/config/configuration.sample.yml
# Exclude generated proxies from doctrine2
/resources/proxies
# Exclude temporaries resources (zip files, quarantine documents etc ..) folder
/tmp
# Exclude cache folder
/cache
# Exclude log folder
/logs
# Exclude plugin folder
/plugins
# Excluse assets plugin folder
/www/plugins
# Exclude folder for storing documents (images, videos, PDF) and their sub-definitions
/datas
# Exclude dependencies folder
/vendor
# Exclude package's binaries folder except the Phraseanet's ones
/bin
!/bin/console
!/bin/developer
!/bin/setup
# Exclude composer
composer.phar
# Exclude behat configuration file
behat.yml
# Exclude vagrant configuration file
.vagrant
# Exclude crossdomain.xml file it's generated
/www/crossdomain.xml

View File

@@ -25,11 +25,6 @@ before_script:
- echo 'extension="memcached.so"' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/memcached.ini
- echo "extension=zmq.so" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/zmq.ini
- yes | pecl install imagick
- wget http://sphinxsearch.com/files/sphinx-2.0.6-release.tar.gz
- tar xzf sphinx-2.0.6-release.tar.gz
- sh -c "cd sphinx-2.0.6-release && wget http://snowball.tartarus.org/dist/libstemmer_c.tgz && tar xzf libstemmer_c.tgz && ./configure --with-libstemmer --with-iconv --with-mysql --enable-id64 --quiet && make -j --quiet && sudo make install"
- sudo mkdir -p /var/sphinx/datas
- sudo chmod -R 0777 /var/sphinx
- mysql -e 'create database update39_test;create database ab_test;create database db_test; create database ab_unitTests; create database db_unitTests;'
- sudo mysql -e "GRANT ALL PRIVILEGES ON ab_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
- sudo mysql -e "GRANT ALL PRIVILEGES ON db_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
@@ -66,7 +61,7 @@ script:
bin/setup system:install --email=test@phraseanet.com --password=test --db-user=root --db-template=fr --db-password= --databox=db_test --appbox=ab_test --server-name=http://127.0.0.1 -y -v;
bin/developer ini:setup-tests-dbs -v;
fi"
- php hudson/cleanupSubdefs.php
- php resources/hudson/cleanupSubdefs.php
#sqlite db generation should occur once Phraseanet is up to date :
- bin/developer phraseanet:regenerate-sqlite
- ./node_modules/.bin/grunt test

View File

@@ -20,7 +20,8 @@ module.exports = function(grunt) {
all: ['www/include/js/tests/*.html']
},
clean: {
"assets": ["<%= path.bower %>", "<%= path.asset %>"]
"assets": ["<%= path.asset %>"],
"bower": ["<%= path.bower %>"]
},
bower: {
install: {
@@ -253,6 +254,32 @@ module.exports = function(grunt) {
"dest": "<%= path.asset %>/normalize-css/",
"flatten": true
},
"sinon-chai": {
"expand": true,
"src": [
"<%= path.bower %>/sinon-chai/lib/sinon-chai.js",
"<%= path.bower %>/sinon-chai/LICENCE.txt",
],
"dest": "<%= path.asset %>/sinon-chai/",
"flatten": true
},
"sinonjs": {
"expand": true,
"src": [
"<%= path.bower %>/sinonjs/sinon.js"
],
"dest": "<%= path.asset %>/sinonjs/",
"flatten": true
},
"squire": {
"expand": true,
"src": [
"<%= path.bower %>/squire/src/Squire.js",
"<%= path.bower %>/squire/LICENCE"
],
"dest": "<%= path.asset %>/squire/",
"flatten": true
},
"qunit": {
"expand": true,
"src": [
@@ -390,6 +417,7 @@ module.exports = function(grunt) {
"copy:blueimp",
"copy:bootstrap",
"copy:bootstrap-multiselect",
"copy:chai",
"copy:font-awesome",
"copy:geonames-server-jquery-plugin",
"copy:humane-js",
@@ -402,9 +430,16 @@ module.exports = function(grunt) {
"copy:jquery-ui",
"copy:jquery.treeview",
"copy:json2",
"copy:js-fixtures",
"copy:modernizr",
"copy:normalize",
"copy:normalize",
"copy:qunit",
"copy:mocha",
"copy:requirejs",
"copy:sinon-chai",
"copy:sinonjs",
"copy:squire",
"copy:swfobject",
"copy:tinymce",
"copy:underscore",
@@ -416,7 +451,8 @@ module.exports = function(grunt) {
"bower",
"copy-deps",
"bower_postinst",
"copy-assets"
"copy-assets",
"clean:bower"
]);
grunt.registerTask('test', ["shell:generate_js_fixtures", "qunit", "mocha_phantomjs"]);
};

12
Vagrantfile vendored
View File

@@ -1,11 +1,15 @@
require 'yaml'
unless Vagrant.has_plugin?("vagrant-hostsupdater")
raise 'vagrant-hostmanager is not installed! please run "vagrant plugin install vagrant-hostsupdater'
end
root = File.dirname(File.expand_path(__FILE__))
Vagrant.configure("2") do |config|
Dir.glob(root+"/vagrant/vms/**/puphpet/config.yaml").each do|f|
dir = File.dirname(File.expand_path(f)+"/..")
base_path = dir[0..-21]
Dir.glob(root+"/resources/vagrant/vms/**/puphpet/config.yaml").each do|f|
dir = File.dirname(File.expand_path(f+"/.."))
base_path = dir
configValues = YAML.load_file(f)
data = configValues['vagrantfile-local']
@@ -167,7 +171,7 @@ Vagrant.configure("2") do |config|
node.vm.provision "shell" do |s|
s.path = "#{base_path}/puphpet/shell/initial-setup.sh"
s.args = "/vagrant/vagrant/vms/#{data['name']}/puphpet"
s.args = "/vagrant/resources/vagrant/vms/#{data['name']}/puphpet"
end
node.vm.provision "shell" do |kg|

View File

@@ -12,6 +12,7 @@
namespace KonsoleKommander;
use Alchemy\Phrasea\Command\Plugin\ListPlugin;
use Alchemy\Phrasea\Command\Setup\CrossDomainGenerator;
use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper;
use Alchemy\Phrasea\Command\Setup\H264MappingGenerator;
use Alchemy\Phrasea\Command\SearchEngine\IndexCreateCommand;
@@ -116,6 +117,7 @@ $cli->command(new H264ConfigurationDumper());
$cli->command(new H264MappingGenerator());
$cli->command(new XSendFileConfigurationDumper());
$cli->command(new XSendFileMappingGenerator());
$cli->command(new CrossDomainGenerator());
if ($cli['phraseanet.SE']->getName() === 'ElasticSearch') {
$cli->command(new IndexCreateCommand());

View File

@@ -79,8 +79,12 @@ main:
host: 127.0.0.1
port: 6700
storage:
subdefs:
default-dir: null
subdefs:null
cache: null
log : null
download: null
lazaret: null
caption: null
bridge:
youtube:
enabled: false
@@ -202,3 +206,29 @@ api_cors:
session:
idle: 0
lifetime: 604800 # 1 week
crossdomain:
site-control: 'master-only'
allow-access-from:
-
domain: '*.example.com'
secure: 'false'
-
domain: 'www.example.com'
secure: 'true'
to-ports: '507,516-523'
allow-access-from-identity:
-
fingerprint-algorithm: 'sha-1'
fingerprint: '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67'
-
fingerprint-algorithm: 'sha256'
fingerprint: '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67'
allow-http-request-headers-from:
-
domain: '*.bar.com'
secure: 'true'
headers: 'SOAPAction, X-Foo*'
-
domain: 'foo.example.com'
secure: 'false'
headers: 'Authorization,X-Foo*'

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

View File

@@ -1,2 +0,0 @@
*
!.gitignore

0
config/topics/.gitkeep Normal file
View File

View File

@@ -1,2 +0,0 @@
*
!.gitignore

0
config/wm/.gitkeep Normal file
View File

0
datas/.gitkeep Normal file
View File

View File

@@ -1,4 +0,0 @@
dailymotion:
public_key:
secret_key:
dev_token:

View File

@@ -1,74 +0,0 @@
<?php
require_once __DIR__ . '/../../vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
$console = new Application('Functionnal tests for dailymotion API');
$console
->register('upload:dailymotion')
->setDescription('Test upload on dailymotion API')
->setCode(function (InputInterface $input, OutputInterface $output) use ($core) {
try {
$configuration = Yaml::parse(__DIR__. '/config/keys.conf.yml');
} catch(\Exception $e) {
$output->writeln('<error>could not parse configuration file</error>');
return;
}
$appbox = \appbox::get_instance($core);
$found = false;
foreach ($appbox->get_databoxes() as $databox) {
/* @var $databox \databox */
$sql = 'SELECT record_id FROM record WHERE type="video" AND (
mime="video/mp4" OR mime="video/quicktime" OR mime="video/x-msvideo" OR mime="video/x-msvideo"
) LIMIT 1';
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute();
$rows = $stmt->fetch(\PDO::FETCH_ASSOC);
if(1 === count($rows)) {
$found = true;
$record = $databox->get_record($rows['record_id']);
break;
}
unset($stmt);
}
if (!$found) {
$output->writeln('<error>No video found, </error>');
return;
}
$bridge = new \Bridge_Api_Dailymotion($core['Registry'], new \Bridge_Api_Auth_OAuth2());
$bridge->set_oauth_token($configuration['dailymotion']['dev_token']);
$options = [];
$samples = [
'title' => $record->get_title(),
'description' => 'Upload functionnal test',
'tags' => 'phraseanet upload test dm api',
'private' => true,
];
foreach($bridge->get_fields() as $field) {
$options[$field['name']] = isset($samples[$field['name']]) ? $samples[$field['name']] : uniqid('test_upload');
}
try {
$idVideo = $bridge->upload($record, $options);
$output->writeln(sprintf('<info>video id is %s</info>', $idVideo));
} catch(\Bridge_Exception_ActionAuthNeedReconnect $e) {
$output->writeln(sprintf('<error>Invalid token %s</error>', $configuration['dailymotion']['dev_token']));
} catch(\Exception $e) {
$output->writeln(sprintf('<error>%s : %s -> %s</error>',get_class($e), $e->getMessage(), $e->getTraceAsString()));
}
});
$console->run();

View File

@@ -188,18 +188,18 @@ class Application extends SilexApplication
error_reporting(-1);
$this['root.path'] = realpath(__DIR__ . '/../../..');
$this->environment = $environment;
mb_internal_encoding("UTF-8");
$this->setupApplicationPaths($this);
$this['charset'] = 'UTF-8';
mb_internal_encoding($this['charset']);
!defined('JETON_MAKE_SUBDEF') ? define('JETON_MAKE_SUBDEF', 0x01) : '';
!defined('JETON_WRITE_META_DOC') ? define('JETON_WRITE_META_DOC', 0x02) : '';
!defined('JETON_WRITE_META_SUBDEF') ? define('JETON_WRITE_META_SUBDEF', 0x04) : '';
!defined('JETON_WRITE_META') ? define('JETON_WRITE_META', 0x06) : '';
$this['charset'] = 'UTF-8';
$this['debug'] = $this->share(function (Application $app) {
return Application::ENV_PROD !== $app->getEnvironment();
});
@@ -218,6 +218,7 @@ class Application extends SilexApplication
$this->register(new AuthenticationManagerServiceProvider());
$this->register(new BorderManagerServiceProvider());
$this->register(new BrowserServiceProvider());
$this->register(new FilesystemServiceProvider());
$this->register(new ConfigurationServiceProvider());
$this->register(new ConfigurationTesterServiceProvider);
$this->register(new ConvertersServiceProvider());
@@ -229,7 +230,6 @@ class Application extends SilexApplication
$this->register(new JMSSerializerServiceProvider());
$this->register(new FFMpegServiceProvider());
$this->register(new FeedServiceProvider());
$this->register(new FilesystemServiceProvider());
$this->register(new FtpServiceProvider());
$this->register(new GeonamesServiceProvider());
$this['geonames.server-uri'] = $this->share(function (Application $app) {
@@ -333,7 +333,7 @@ class Application extends SilexApplication
$this->register(new TokensServiceProvider());
$this->register(new TwigServiceProvider(), [
'twig.options' => [
'cache' => $this['root.path'].'/tmp/cache_twig/',
'cache' => $this->share(function($app) {return $app['cache.path'].'/twig';}),
],
]);
@@ -341,7 +341,7 @@ class Application extends SilexApplication
'locale_fallbacks' => ['fr'],
'translator.cache-options' => [
'debug' => $this['debug'],
'cache_dir' => $this['root.path'].'/tmp/translations'
'cache_dir' => $this->share(function($app) {return $app['cache.path'].'/translations';}),
],
]);
@@ -589,6 +589,8 @@ class Application extends SilexApplication
{
$this['twig'] = $this->share(
$this->extend('twig', function ($twig, $app) {
$twig->setCache($app['cache.path'].'/twig');
$paths = require $app['plugins.directory'] . '/twig-paths.php';
if ($app['browser']->isTablet() || $app['browser']->isMobile()) {
@@ -899,4 +901,92 @@ class Application extends SilexApplication
{
return static::$flashTypes;
}
private function setupApplicationPaths(Application $app)
{
// app root path
$this['root.path'] = realpath(__DIR__ . '/../../..');
// temporary resources default path such as download zip, quarantined documents etc ..
$this['tmp.path'] = $this['root.path'].'/tmp';
// cache path for dev env
$this['cache.dev.path'] = $app->share(function() use ($app) {
$path = sys_get_temp_dir().'/'.md5($app['root.path']);
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// cache path (twig, minify, translations, configuration, doctrine metas serializer metas, profiler etc ...)
$this['cache.path'] = $app->share(function() use ($app) {
// if ($app->getEnvironment() !== Application::ENV_PROD) {
// return $this['cache.dev.path'];
// }
$path = $this['root.path'].'/cache';
if ($app['phraseanet.configuration']->isSetup()) {
$path = $app['conf']->get(['main', 'storage', 'cache'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
$app['cache.paths'] = $app->share(function() use ($app) {
return array(
self::ENV_DEV => $this['cache.path'],
self::ENV_TEST => $this['cache.path'],
self::ENV_PROD => $this['cache.path']
);
});
// log path
$this['log.path'] = $app->share(function() use ($app) {
$path = $this['root.path'].'/logs';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'log'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// temporary download file path (zip file)
$this['tmp.download.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/download';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'download'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// quarantined file path
$this['tmp.lazaret.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/lazaret';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'quarantine'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
// document caption file path
$this['tmp.caption.path'] = $app->share(function() use ($app) {
$path = $this['tmp.path'].'/caption';
if ($app['phraseanet.configuration']->isSetup()) {
return $app['conf']->get(['main', 'storage', 'caption'], $path);
}
// ensure path is created
$app['filesystem']->mkdir($path);
return $path;
});
}
}

View File

@@ -61,7 +61,7 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) {
$app->register($p = new WebProfilerServiceProvider(), [
'profiler.cache_dir' => $app['root.path'].'/tmp/cache/profiler',
'profiler.cache_dir' => $app['cache.path'].'/profiler',
]);
$app->mount('/_profiler', $p);

View File

@@ -196,11 +196,11 @@ class Manager
*/
protected function bookLazaretPathfile($filename, $suffix = '')
{
$output = $this->app['root.path'] . '/tmp/lazaret/lzrt_' . substr($filename, 0, 3) . '_' . $suffix . '.' . pathinfo($filename, PATHINFO_EXTENSION);
$output = $this->app['tmp.path'].'/lazaret/lzrt_' . substr($filename, 0, 3) . '_' . $suffix . '.' . pathinfo($filename, PATHINFO_EXTENSION);
$infos = pathinfo($output);
$n = 0;
$this->app['filesystem']->mkdir($this->app['root.path'] . '/tmp/lazaret');
$this->app['filesystem']->mkdir($this->app['tmp.lazaret.path']);
while (true) {
$output = sprintf('%s/%s-%d%s', $infos['dirname'], $infos['filename'], ++ $n, (isset($infos['extension']) ? '.' . $infos['extension'] : ''));

View File

@@ -100,12 +100,12 @@ class IniReset extends Command
// inject v3.1 fixtures
if ($input->getOption('v3.1')) {
$this->container['filesystem']->copy($this->container['root.path'].'/hudson/connexion.inc', $this->container['root.path'].'/config/connexion.inc');
$this->container['filesystem']->copy($this->container['root.path'].'/hudson/_GV.php', $this->container['root.path'].'/config/_GV.php');
$this->container['filesystem']->copy($this->container['root.path'].'/resources/hudson/connexion.inc', $this->container['root.path'].'/config/connexion.inc');
$this->container['filesystem']->copy($this->container['root.path'].'/resources//hudson/_GV.php', $this->container['root.path'].'/config/_GV.php');
$command = $this->getApplication()->find('dbal:import');
$content = file_get_contents($this->container['root.path'] . '/hudson/fixtures.sql');
$content = file_get_contents($this->container['root.path'] . '/resources//hudson/fixtures.sql');
$content = str_replace('ab_test', $dbs['ab'], $content);
$content = str_replace('db_test', $dbName, $content);

View File

@@ -30,12 +30,12 @@ class JsFixtures extends Command
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$dbRefPath = __DIR__ . '/../../../../../tests/db-ref.sqlite';
$dbRefPath = sys_get_temp_dir() . '/db-ref.sqlite';
if (!file_exists($dbRefPath)) {
throw new RuntimeException('You must generate sqlite db first, run "bin/console phraseanet:regenerate-sqlite" command.');
}
copy($dbRefPath, '/tmp/db.sqlite');
copy($dbRefPath, sys_get_temp_dir().'/db.sqlite');
$sbasId = current($this->container['phraseanet.appbox']->get_databoxes())->get_sbas_id();
$this->writeResponse($output, 'GET', '/login/', '/home/login/index.html');

View File

@@ -54,16 +54,16 @@ class RegenerateSqliteDb extends Command
{
parent::__construct('phraseanet:regenerate-sqlite');
$this->setDescription("Updates the sqlite 'tests/db-ref.sqlite' database with current database definition.");
$this->setDescription("Updates the sqlite 'db-ref.sqlite' database with current database definition.");
}
public function doExecute(InputInterface $input, OutputInterface $output)
{
$fs = new Filesystem();
$source = __DIR__ . '/../../../../../tests/db-ref.sqlite';
$target = __DIR__ . '/../../../../../tests/db-ref.sqlite.bkp';
$json = __DIR__ . '/../../../../../tests/fixtures.json';
$source = sys_get_temp_dir().'/db-ref.sqlite';
$target = sys_get_temp_dir().'/db-ref.sqlite.bkp';
$json = sys_get_temp_dir().'/fixtures.json';
$renamed = false;
if (is_file($source)) {

View File

@@ -37,7 +37,7 @@ class SetupTestsDbs extends Command
));
}
$settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../hudson/InstallDBs.yml'));
$settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../resources/hudson/InstallDBs.yml'));
$dbs = array();

View File

@@ -33,7 +33,6 @@ class Uninstaller extends Command
$root = $this->container['root.path'];
foreach ([
$root.'/tmp/configuration-compiled.php',
$root.'/config/configuration.yml',
$root.'/config/services.yml',
$root.'/config/connexions.yml',
@@ -42,27 +41,48 @@ class Uninstaller extends Command
$root.'/config/connexion.inc',
$root.'/config/_GV.php',
$root.'/config/_GV.php.old',
$root.'/tmp/cache_registry.php',
$root.'/tmp/cache_registry.yml',
$root.'/config/configuration-compiled.php',
] as $file) {
if (is_file($file)) {
if ($this->container['filesystem']->exists($file)) {
unlink($file);
}
}
foreach ([
$root.'/tmp/serializer',
$root.'/tmp/cache_twig',
$root.'/tmp/translations',
$root.'/tmp/cache_minify',
$root.'/tmp/download',
$root.'/tmp/locks',
$root.'/tmp/cache',
] as $dir) {
if (is_dir($dir)) {
$this->container['tmp.download.path'],
$this->container['tmp.lazaret.path'],
$this->container['tmp.caption.path'],
$this->container['tmp.path'].'/sessions',
$this->container['tmp.path'].'/locks',
] as $resource) {
if (is_dir($resource)) {
$finder = new Finder();
foreach ($finder->files()->in($dir) as $file) {
unlink($file);
foreach ($finder->files()->in($resource) as $file) {
$this->container['filesystem']->remove($file);
}
} elseif (is_file($resource)) {
$this->container['filesystem']->remove($resource);
}
}
foreach ($this->container['cache.paths'] as $path) {
foreach ([
$path.'/cache_registry.php',
$path.'/cache_registry.yml',
$path.'/serializer',
$path.'/doctrine',
$path.'/twig',
$path.'/translations',
$path.'/minify',
$path.'/profiler',
] as $resource) {
if (is_dir($resource)) {
$finder = new Finder();
foreach ($finder->files()->in($resource) as $file) {
$this->container['filesystem']->remove($file);
}
} elseif (is_file($resource)) {
$this->container['filesystem']->remove($resource);
}
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Command\Setup;
use Alchemy\Phrasea\Command\Command;
use Alchemy\Phrasea\Utilities\CrossDomainDumper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CrossDomainGenerator extends Command
{
public function __construct($name = null)
{
parent::__construct('crossdomain:generate');
$this->setDescription('Generate crossdomain.xml file according to configuration');
}
/**
* {@inheritdoc}
*/
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$configuration = $this->container['phraseanet.configuration']['crossdomain'];
$dumper = new CrossDomainDumper();
$xml = $dumper->dump($configuration);
$output->writeln($xml);
$this->container['filesystem']->dumpFile($this->container['root.path'].'/www/crossdomain.xml', $xml);
return ;
}
}

View File

@@ -72,8 +72,8 @@ class XSendFileMappingGenerator extends Command
private function computeMapping($paths)
{
return array_merge([
['mount-point' => 'protected_lazaret', 'directory' => $this->container['root.path'] . '/tmp/lazaret'],
['mount-point' => 'protected_download', 'directory' => $this->container['root.path'] . '/tmp/download'],
['mount-point' => 'protected_lazaret', 'directory' => $this->container['tmp.lazaret.path']],
['mount-point' => 'protected_download', 'directory' => $this->container['tmp.download.path']],
], array_map([$this, 'pathsToConf'], array_unique($paths)));
}

View File

@@ -52,7 +52,7 @@ class SchedulerRun extends Command
}
$this->container['signal-handler']->register([SIGINT, SIGTERM], [$this, 'signalHandler']);
$this->container['task-manager']->addSubscriber(new LockFileSubscriber($this->container['task-manager.logger'], $this->container['root.path'].'/tmp/locks'));
$this->container['task-manager']->addSubscriber(new LockFileSubscriber($this->container['task-manager.logger'], $this->container['tmp.path'].'/locks'));
$this->container['task-manager']->start();
}
}

View File

@@ -61,7 +61,7 @@ class TaskRun extends Command
$logger->pushHandler(new RotatingFileHandler($file->getPath(), $this->container['task-manager.logger.configuration']['max-files'], $this->container['task-manager.logger.configuration']['level']));
}
$job->addSubscriber(new LockFileSubscriber('task-'.$task->getId(), $logger, $this->container['root.path'].'/tmp/locks'));
$job->addSubscriber(new LockFileSubscriber('task-'.$task->getId(), $logger, $this->container['tmp.path'].'/locks'));
$job->addSubscriber(new StopSignalSubscriber($this->container['signal-handler'], $logger));
if ($input->getOption('listen-signal')) {

View File

@@ -699,7 +699,7 @@ class Databox implements ControllerProviderInterface
$ret['sbas_id'] = $databox_id;
$ret['xml_indexed'] = $datas['xml_indexed'];
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
$ret['jeton_subdef'] = $datas['jeton_subdef'];
if ($app['filesystem']->exists($app['root.path'] . '/config/minilogos/logopdf_' . $databox_id . '.jpg')) {
$ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg';
}

View File

@@ -795,7 +795,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/import/example/csv/', function (Application $app) {
$file = new \SplFileInfo($app['root.path'] . '/lib/Fixtures/exampleImportUsers.csv');
$file = new \SplFileInfo($app['root.path'] . '/resources/examples/example_import_users.csv');
if (!$file->isFile()) {
$app->abort(400);
@@ -814,7 +814,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/import/example/rtf/', function (Application $app) {
$file = new \SplFileInfo($app['root.path'] . '/lib/Fixtures/Fields.rtf');
$file = new \SplFileInfo($app['root.path'] . '/resources/examples/fields.rtf');
if (!$file->isFile()) {
$app->abort(400);

View File

@@ -519,8 +519,8 @@ class V1 implements ControllerProviderInterface
'report' => [
'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']),
],
'filesystem' => [
'noWeb' => $app['conf']->get(['main', 'storage', 'subdefs', 'default-dir']),
'storage' => [
'documents' => $app['conf']->get(['main', 'storage', 'subdefs']),
],
'searchEngine' => [
'configuration' => [

View File

@@ -26,9 +26,10 @@ class Minifier implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->get('/', function (Application $app, Request $request) {
// cache directory path
$min_cachePath = $app['root.path'] . '/tmp/cache_minify';
$min_cachePath = $app['cache.path'].'/minify';
// ensure path is created
$app['filesystem']->mkdir($min_cachePath);
/**
* Cache file locking. Set to false if filesystem is NFS. On at least one

View File

@@ -136,7 +136,7 @@ class DoDownload implements ControllerProviderInterface
$mime = $subdef['mime'];
$list['complete'] = true;
} else {
$exportFile = $app['root.path'] . '/tmp/download/' . $token->getValue() . '.zip';
$exportFile = $app['tmp.download.path'].'/'.$token->getValue() . '.zip';
$mime = 'application/zip';
}
@@ -184,7 +184,7 @@ class DoDownload implements ControllerProviderInterface
$app,
$token,
$list,
sprintf($app['root.path'] . '/tmp/download/%s.zip', $token->getValue()) // Dest file
sprintf($app['tmp.download.path'].'/%s.zip', $token->getValue()) // Dest file
);
return $app->json([

View File

@@ -223,7 +223,7 @@ class Export implements ControllerProviderInterface
$app,
$token,
$list,
$app['root.path'] . '/tmp/download/' . $token->getValue() . '.zip'
$app['tmp.download.path'].'/'. $token->getValue() . '.zip'
);
$remaingEmails = $destMails;

View File

@@ -126,7 +126,7 @@ class Lazaret implements ControllerProviderInterface
'base_id' => $lazaretFile->getBaseId(),
'created' => $lazaretFile->getCreated()->format(\DateTime::ATOM),
'updated' => $lazaretFile->getUpdated()->format(\DateTime::ATOM),
'pathname' => $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(),
'pathname' => $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename(),
'sha256' => $lazaretFile->getSha256(),
'uuid' => $lazaretFile->getUuid(),
];
@@ -174,8 +174,8 @@ class Lazaret implements ControllerProviderInterface
return $app->json($ret);
}
$lazaretFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename();
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename();
$lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
try {
$borderFile = Border\File::buildFromPathfile(
@@ -294,8 +294,8 @@ class Lazaret implements ControllerProviderInterface
protected function denyLazaretFile(Application $app, LazaretFile $lazaretFile)
{
$lazaretFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename();
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename();
$lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
$app['EM']->remove($lazaretFile);
$app['EM']->flush();
@@ -386,8 +386,8 @@ class Lazaret implements ControllerProviderInterface
return $app->json($ret);
}
$lazaretFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename();
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename();
$lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
try {
$media = $app['mediavorus']->guess($lazaretFileName);
@@ -437,7 +437,7 @@ class Lazaret implements ControllerProviderInterface
return new Response(null, 404);
}
$lazaretThumbFileName = $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getThumbFilename();
$lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
return $app['phraseanet.file-serve']->deliverFile($lazaretThumbFileName, $lazaretFile->getOriginalName(), DeliverDataInterface::DISPOSITION_INLINE, 'image/jpeg', 3600);
}

View File

@@ -252,11 +252,9 @@ class Tools implements ControllerProviderInterface
$dataUri = DataURI\Parser::parse($request->request->get('image', ''));
$path = $app['root.path'] . '/tmp';
$name = sprintf('extractor_thumb_%s', $record->get_serialize_key());
$fileName = sprintf('%s/%s.png', $path, $name);
$fileName = sprintf('%s/%s.png', sys_get_temp_dir(), $name);
file_put_contents($fileName, $dataUri->getData());

View File

@@ -1138,7 +1138,7 @@ class Thesaurus implements ControllerProviderInterface
{
list($term, $context) = $this->splitTermAndContext($request->get("t"));
$dom = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $request->get('term'), $request->get('context'), $request->get('piv'));
$dom = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $term, $context, $request->get('piv'));
$xpath = new \DOMXPath($dom);
@@ -1158,10 +1158,10 @@ class Thesaurus implements ControllerProviderInterface
$candidates_list = [];
for ($i = 0; $i < $candidates->length; $i ++) {
if ($candidates->item($i)->getAttribute("sourceok") == "1") {
$candidates_list = [
$candidates_list[] = array(
'id' => $candidates->item($i)->getAttribute("id"),
'field' => $candidates->item($i)->getAttribute("field"),
];
);
}
}
@@ -2948,8 +2948,8 @@ class Thesaurus implements ControllerProviderInterface
$xpathth = new \DOMXPath($domth);
$xpathct = new \DOMXPath($domct);
// on cherche les champs d'oe peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme
$fields = [];
// on cherche les champs d'ou peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme
$fields = array();
$xpathstruct = new \DOMXPath($domstruct);
$nodes = $xpathstruct->query("/record/description/*[@tbranch]");
for ($i = 0; $i < $nodes->length; $i ++) {
@@ -2992,7 +2992,7 @@ class Thesaurus implements ControllerProviderInterface
];
if (count($fields) > 0) {
$q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";
$q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t)) . "'";
if ($k) {
if ($k != "*") {
$q .= " and @k='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";

View File

@@ -44,6 +44,7 @@ class Xmlhttp implements ControllerProviderInterface
$controllers->match('openbranch_prod.j.php', 'controller.thesaurus.xmlhttp:OpenBranchJson');
$controllers->match('openbranches_prod.h.php', 'controller.thesaurus.xmlhttp:OpenBranchesHtml');
$controllers->match('openbranches_prod.x.php', 'controller.thesaurus.xmlhttp:OpenBranchesXml');
$controllers->match('openbranches_prod.j.php', 'controller.thesaurus.xmlhttp:OpenBranchesJson');
$controllers->match('replacecandidate.j.php', 'controller.thesaurus.xmlhttp:ReplaceCandidateJson')
->before(function () use ($app) {
$app['firewall']->requireAccessToModule('thesaurus');
@@ -772,72 +773,19 @@ class Xmlhttp implements ControllerProviderInterface
$lthid = strlen($thid);
// count occurences
if ($lthid == 1) {
if ($lthid > 1) {
$dthid = str_replace('.', 'd', $thid);
$sql = 'SELECT COUNT(DISTINCT r.record_id) AS n
FROM (thit AS t INNER JOIN record AS r USING(record_id))
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0';
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$sql = "SELECT"
. " 0+SUBSTR(t.value, " . ($lthid + 2) . ") AS k, COUNT(DISTINCT(`record_id`)) AS n"
. " FROM (thit AS t INNER JOIN record AS r USING(record_id))"
. " INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id"
. " WHERE t.value LIKE :like AND r.coll_id IN(".$lcoll.") AND (r.status^c.mask_xor)&c.mask_and=0"
. " GROUP BY k ORDER BY NULL";
$sqlparm = array(':like' => $dthid . 'd%', ':site'=>$site, ':usr_id'=>$usr_id);
$stmt = $connbas->prepare($sql);
$stmt->execute($sqlparm);
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $rowbas) {
$t_nrec[$thid] = $rowbas;
}
$sql = 'SELECT
SUBSTRING_INDEX(SUBSTR(t.value, ' . ($lthid + 1) . '), "d", 1) AS k ,
COUNT(DISTINCT t.record_id) AS n
FROM (thit AS t INNER JOIN record AS r USING(record_id))
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
GROUP BY k';
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql);
$stmt->execute([':like' => $dthid . '%']);
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $rowbas) {
$t_nrec[$thid . $rowbas['k']] = $rowbas;
}
} elseif (strlen($thid) > 1) {
$dthid = str_replace('.', 'd', $thid);
$sql = 'SELECT
SUBSTRING_INDEX(SUBSTR(t.value, ' . ($lthid) . '), \'d\', 1) AS k ,
COUNT(DISTINCT t.record_id) AS n
FROM (thit AS t INNER JOIN record AS r USING(record_id))
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
GROUP BY k';
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql);
$stmt->execute($sqlparm);
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $rowbas) {
$t_nrec[$thid] = $rowbas;
}
$sql = 'SELECT
SUBSTRING_INDEX(SUBSTR(t.value, ' . ($lthid + 2) . '), \'d\', 1) AS k ,
COUNT(DISTINCT t.record_id) AS n
FROM (thit AS t INNER JOIN record AS r USING(record_id))
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
GROUP BY k';
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql);
$stmt->execute($sqlparm);
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -879,17 +827,6 @@ class Xmlhttp implements ControllerProviderInterface
if ($request->get('last')) {
$class .= ( $class == '' ? '' : ' ') . 'last';
}
$html .= '<LI id="' . $request->get('type') . 'X_P.' . $sbid . '.' . $thid . '" class="' . $class . '" loaded="1">' . "\n";
$html .= ' <div class="hitarea expandable-hitarea"></div>' . "\n";
$html .= ' <span>' . $label . '</span>';
if (isset($t_nrec[$thid])) {
$html .= ' <I>' . $t_nrec[$thid]['n'] . '</I>';
}
$html .= "\n";
// on dresse la liste des termes specifiques avec comme cle le synonyme dans la langue pivot
$nts = 0;
$tts = [];
@@ -1165,6 +1102,92 @@ class Xmlhttp implements ControllerProviderInterface
}
}
public function OpenBranchesJson(Application $app, Request $request)
{
if ('' === ($mod = strtoupper($request->get('mod')))) {
$mod = 'TREE';
}
$ret = array(
'parms'=> array(
'bid' => $request->get('bid'),
't' => $request->get('t'),
'mod' => $request->get('mod'),
'debug' => $request->get('debug')
),
'result'=>NULL,
'error'=>'',
'error_code'=>0,
);
if (null === ($bid = $request->get('bid'))) {
$ret['error'] = 'Missing bid parameter';
$ret['error_code'] = 400;
return json_encode($ret);
}
if ($mod != 'TREE' && $mod != "LIST") {
$ret['error'] = 'bad mod, TREE|LIST';
$ret['error_code'] = 400;
return json_encode($ret);
}
$databox = $app['phraseanet.appbox']->get_databox((int) $bid);
$dom = $databox->get_dom_thesaurus();
if (!$dom) {
$ret['error'] = 'Unable to load thesaurus';
$ret['error_code'] = 500;
return json_encode($ret);
}
$xpath = $databox->get_xpath_thesaurus();
$q = '/thesaurus';
if (($znode = $xpath->query($q)->item(0))) {
$q2 = '//sy';
if ($request->get('t')) {
$t = $this->splitTermAndContext($request->get('t'));
$q2 = 'starts-with(@w, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[0])) . '\')';
if ($t[1])
$q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
$q2 = '//sy[' . $q2 . ']';
}
$nodes = $xpath->query($q2, $znode);
if ($mod == 'TREE') {
for ($i = 0; $i < $nodes->length; $i++) {
$nodes->item($i)->setAttribute('bold', '1');
for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
$n->setAttribute('open', '1');
}
}
$ret['result'] = $this->getBrancheJson($bid, $znode, $ret['result'], 0);
} else {
$ret['result'] = array();
for ($i = 0; $i < $nodes->length; $i++) {
$n = $nodes->item($i);
$t = $n->getAttribute('v');
$tid = $n->getAttribute('id');
$ret['result'][] = array(
'id' => $n->getAttribute('id'),
't' => $n->getAttribute('v'),
);
}
}
}
if($request->get('debug')) {
printf("<pre>%s</pre>", var_export($ret, true));
// printf("<pre>%s</pre>", json_encode($ret, JSON_PRETTY_PRINT));
die;
}
return json_encode($ret, JSON_PRETTY_PRINT);
}
public function OpenBranchesXml(Application $app, Request $request)
{
if (null === $mod = $request->get('mod')) {
@@ -1233,7 +1256,44 @@ class Xmlhttp implements ControllerProviderInterface
$html->appendChild($ret->createTextNode($zhtml));
}
return new Response($zhtml, 200, ['Content-Type' => 'text/xml']);
return new Response($zhtml, 200, array('Content-Type' => 'text/xml'));
}
private function getBrancheJson($bid, $srcnode, &$ret, $depth)
{
$tid = $srcnode->getAttribute('id');
$nts = 0;
$allsy = array();
for ($n = $srcnode->firstChild; $n; $n = $n->nextSibling) {
if ($n->nodeName == 'sy') {
$t = $n->getAttribute('v');
$allsy[] = array(
'id' => $n->getAttribute('id'),
't' => $t,
'lng' => $n->getAttribute('lng'),
'bold' => (bool)$n->getAttribute('bold'),
);
} elseif ($n->nodeName == 'te') {
$nts++;
}
}
$nret = array(
'id' => $tid,
'nts' => $nts,
'synonyms' => $allsy,
'children' => array(),
);
for ($n = $srcnode->firstChild; $n; $n = $n->nextSibling) {
if ($n->nodeName == 'te') {
if ($n->getAttribute('open')) {
$nret['children'][] = $this->getBrancheJson($bid, $n, $ret['children'], $depth + 1);
}
}
}
return $nret;
}
private function getBrancheXML($bid, $srcnode, &$html, $depth)

View File

@@ -22,12 +22,10 @@ use Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHa
class SessionHandlerFactory
{
private $connectionFactory;
private $root;
public function __construct(ConnectionFactory $connectionFactory, $root = null)
public function __construct(ConnectionFactory $connectionFactory)
{
$this->connectionFactory = $connectionFactory;
$this->root = __DIR__ . '/../../../../..';
}
/**
@@ -62,7 +60,7 @@ class SessionHandlerFactory
)
);
case 'file':
return new NativeFileSessionHandler($this->root.'/tmp/sessions');
return new NativeFileSessionHandler(isset($options['save-path']) ? $options['save-path'] : null);
case 'redis':
return new WriteCheckSessionHandler(
new RedisSessionHandler(

View File

@@ -61,7 +61,9 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface
$msg = json_encode(['msg' => $msg, 'code' => $code]);
$event->setResponse(new Response($msg, $code, $headers));
} else {
$event->setResponse($this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException()));
$response = $this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException());
$response->headers->set('Content-Type', 'text/html');
$event->setResponse($response);
}
}
}

View File

@@ -21,7 +21,9 @@ class CacheServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['phraseanet.cache-registry'] = $app['root.path'] . '/tmp/cache_registry.php';
$app['phraseanet.cache-registry'] = $app->share(function () use ($app) {
return $app['cache.path'].'/cache_registry.php';
});
$app['phraseanet.cache-compiler'] = $app->share(function () {
return new Compiler();

View File

@@ -35,7 +35,7 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
return new Compiler();
});
$app['phraseanet.configuration.config-path'] = $app['root.path'].'/config/configuration.yml';
$app['phraseanet.configuration.config-compiled-path'] = $app['root.path'] . '/tmp/configuration-compiled.php';
$app['phraseanet.configuration.config-compiled-path'] = $app['root.path'].'/config/configuration-compiled.php';
$app['configuration.store'] = $app->share(function (SilexApplication $app) {
return new HostConfiguration(new Configuration(

View File

@@ -21,7 +21,10 @@ class JMSSerializerServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['serializer.cache-directory'] = $app['root.path'] . '/tmp/serializer/';
$app['serializer.cache-directory'] = $app->share(function () use ($app) {
return $app['cache.path'].'/serializer/';
});
$app['serializer.src_directory'] = $app['root.path'] . '/vendor/jms/serializer/src/';
$app['serializer.metadata.annotation_reader'] = $app->share(function () use ($app) {

View File

@@ -37,7 +37,9 @@ class ORMServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['EM.sql-logger.file'] = $app['root.path'] . '/logs/doctrine-log.log';
$app['EM.sql-logger.file'] = $app->share(function (Application $app) {
return $app['log.path'].'/doctrine-log.log';
});
$app['EM.sql-logger.max-files'] = 5;
$app['EM.sql-logger'] = $app->share(function (Application $app) {
@@ -55,7 +57,7 @@ class ORMServiceProvider implements ServiceProviderInterface
$annotationReader = new AnnotationReader();
$fileCacheReader = new FileCacheReader(
$annotationReader,
$app['root.path']."/tmp/doctrine",
$app['cache.path'].'/doctrine',
$app['debug']
);
@@ -97,7 +99,7 @@ class ORMServiceProvider implements ServiceProviderInterface
$config->setMetadataDriverImpl($app['EM.driver']);
$config->setProxyDir($app['root.path'] . '/tmp/doctrine-proxies');
$config->setProxyDir($app['root.path'].'/resources/proxies');
$config->setProxyNamespace('Alchemy\Phrasea\Model\Proxies');
$config->setAutoGenerateProxyClasses($app['debug']);
$config->addEntityNamespace('Phraseanet', 'Alchemy\Phrasea\Model\Entities');

View File

@@ -23,7 +23,7 @@ class SessionHandlerServiceProvider implements ServiceProviderInterface
public function register(Application $app)
{
$app['session.storage.handler.factory'] = $app->share(function (Application $app) {
return new SessionHandlerFactory($app['cache.connection-factory'], $app['root.path']);
return new SessionHandlerFactory($app['cache.connection-factory']);
});
}

View File

@@ -58,7 +58,7 @@ class TasksServiceProvider implements ServiceProviderInterface
});
$app['task-manager.log-file.root'] = $app->share(function (Application $app) {
return $app['root.path'].'/logs';
return $app['log.path'];
});
$app['task-manager.log-file.factory'] = $app->share(function (Application $app) {

View File

@@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Core;
class Version
{
protected static $number = '3.9.0-alpha.18';
protected static $number = '3.9.0-alpha.19';
protected static $name = 'Gorgosaurus';
public static function getNumber()

View File

@@ -205,7 +205,7 @@ class TokenManipulator implements ManipulatorInterface
switch ($token->getType()) {
case 'download':
case 'email':
$file = $this->app['root.path'] . '/tmp/download/' . $token->getValue() . '.zip';
$file = $this->app['tmp.download.path'].'/' . $token->getValue() . '.zip';
if (is_file($file)) {
unlink($file);
}

View File

@@ -34,7 +34,6 @@ class Installer
$this->rollbackInstall($abConn, $dbConn);
try {
$this->createConfigFile($abConn, $serverName, $binaryData);
$this->createAB();
$this->populateRegistryData($serverName, $dataPath, $binaryData);
@@ -60,13 +59,16 @@ class Installer
private function populateRegistryData($serverName, $dataPath)
{
if (null === realpath($dataPath)) {
if (null === $dataPath = realpath($dataPath)) {
throw new \InvalidArgumentException(sprintf('Path %s does not exist.', $dataPath));
}
$dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
$this->app['conf']->set(['main', 'storage', 'subdefs', 'default-dir'], $dataPath);
$this->app['conf']->set(['main', 'storage', 'subdefs'], $dataPath);
$this->app['conf']->set(['main', 'storage', 'cache'], realpath(__DIR__ . '/../../../../cache'));
$this->app['conf']->set(['main', 'storage', 'log'], realpath(__DIR__ . '/../../../../logs'));
$this->app['conf']->set(['main', 'storage', 'download'], realpath(__DIR__ . '/../../../../tmp/download'));
$this->app['conf']->set(['main', 'storage', 'lazaret'], realpath(__DIR__ . '/../../../../tmp/lazaret'));
$this->app['conf']->set(['main', 'storage', 'caption'], realpath(__DIR__ . '/../../../../tmp/caption'));
$this->app['conf']->set('servername', $serverName);
$this->app['conf']->set('registry', $this->app['registry.manipulator']->getRegistryData());
}
@@ -134,7 +136,7 @@ class Installer
foreach ($appbox->tables->table as $table) {
try {
$sql = 'DROP TABLE `' . $table['name'] . '`';
$sql = 'DROP TABLE IF EXISTS `' . $table['name'] . '`';
$stmt = $abConn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
@@ -145,7 +147,7 @@ class Installer
if (null !== $dbConn) {
foreach ($databox->tables->table as $table) {
try {
$sql = 'DROP TABLE `' . $table['name'] . '`';
$sql = 'DROP TABLE IF EXISTS `' . $table['name'] . '`';
$stmt = $dbConn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();

View File

@@ -35,8 +35,8 @@ class FilesystemProbe extends FilesystemRequirements implements ProbeInterface
);
}
if ($conf->has(['main', 'storage', 'subdefs', 'default-dir'])) {
$paths[] = $conf->get(['main', 'storage', 'subdefs', 'default-dir']);
if ($conf->has(['main', 'storage', 'subdefs'])) {
$paths[] = $conf->get(['main', 'storage', 'subdefs']);
}
foreach ($paths as $path) {

View File

@@ -31,16 +31,12 @@ class FilesystemRequirements extends RequirementCollection implements Requiremen
$baseDir . '/config/wm',
$baseDir . '/logs',
$baseDir . '/tmp',
$baseDir . '/www/custom',
$baseDir . '/tmp/locks',
$baseDir . '/tmp/cache_twig',
$baseDir . '/tmp/serializer',
$baseDir . '/tmp/doctrine',
$baseDir . '/tmp/cache_minify',
$baseDir . '/tmp/caption',
$baseDir . '/tmp/lazaret',
$baseDir . '/tmp/desc_tmp',
$baseDir . '/tmp/download',
$baseDir . '/tmp/batches'
$baseDir . '/cache',
$baseDir . '/www/custom',
];
foreach ($paths as $path) {

View File

@@ -190,14 +190,14 @@ class FtpJob extends AbstractJob
if ($subdef == 'caption') {
$desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_XML, $exportElement->isBusinessfields());
$localfile = $app['root.path'] . '/tmp/' . md5($desc . time() . mt_rand());
$localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) {
throw new \Exception('Impossible de creer un fichier temporaire');
}
} elseif ($subdef == 'caption-yaml') {
$desc = $app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_YAML, $exportElement->isBusinessfields());
$localfile = $app['root.path'] . '/tmp/' . md5($desc . time() . mt_rand());
$localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) {
throw new \Exception('Impossible de creer un fichier temporaire');
}
@@ -272,7 +272,7 @@ class FtpJob extends AbstractJob
$buffer .= $root . '/' . $folder . $filename . "\n";
}
$tmpfile = $app['root.path'] . '/tmp/tmpftpbuffer' . $date->format('U') . '.txt';
$tmpfile = sys_get_temp_dir().'/tmpftpbuffer' . $date->format('U') . '.txt';
file_put_contents($tmpfile, $buffer);

View File

@@ -45,11 +45,17 @@ class CachedTranslator extends Translator
return;
}
if (null === $this->options['cache_dir']) {
if (is_callable($this->options['cache_dir'])) {
$cache_dir = call_user_func($this->options['cache_dir'], $this->app);
} else {
$cache_dir = $this->options['cache_dir'];
}
if (null === $cache_dir) {
return parent::loadCatalogue($locale);
}
$cache = new ConfigCache($this->options['cache_dir'].'/catalogue.'.$locale.'.php', $this->options['debug']);
$cache = new ConfigCache($cache_dir.'/catalogue.'.$locale.'.php', $this->options['debug']);
if (!$cache->isFresh()) {
parent::loadCatalogue($locale);

View File

@@ -0,0 +1,107 @@
<?php
namespace Alchemy\Phrasea\Utilities;
/** Build crossdomain.xml file according to configuration */
class CrossDomainDumper
{
public function dump(array $configuration)
{
$xml = '<?xml version="1.0"?>'.PHP_EOL;
$xml .= '<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">'.PHP_EOL;
$xml .= '<cross-domain-policy>' . PHP_EOL;
$xml .= $this->getSiteControl($configuration);
$xml .= $this->getAllowAccess($configuration);
$xml .= $this->getAllowIdentity($configuration);
$xml .= $this->getAllowHeader($configuration);
$xml .= "</cross-domain-policy>";
return $xml;
}
private function getSiteControl(array $conf)
{
$xml = '';
if (isset($conf['site-control'])) {
$xml = "\t".'<site-control permitted-cross-domain-policies="'.$conf['site-control'].'"/>'.PHP_EOL;
}
return $xml;
}
private function getAllowAccess(array $conf)
{
$xml = '';
if (!isset($conf['allow-access-from'])) {
return $xml;
}
$allowAccess = $conf['allow-access-from'];
if (!is_array($allowAccess)) {
return $xml;
}
foreach ($allowAccess as $access) {
// domain is mandatory
if (!isset($access['domain'])) {
continue;
}
$domain = $access['domain'];
$secure = isset($access['secure']) ? $access['secure'] : false;
$ports = isset($access['to-ports']) ? $access['to-ports'] : false;
$xml .= "\t".'<allow-access-from domain="'.$domain.'"'. ($ports ? ' to-ports="'.$ports.'"' : '') . ($secure ? ' secure="'.$secure.'"': ''). '/>'.PHP_EOL;
}
return $xml;
}
private function getAllowIdentity(array $conf)
{
$xml = '';
if (!isset($conf['allow-access-from-identity'])) {
return $xml;
}
$allowAccess = $conf['allow-access-from-identity'];
if (!is_array($allowAccess)) {
return $xml;
}
foreach ($allowAccess as $access) {
$algorithm = isset($access['fingerprint-algorithm']) ? $access['fingerprint-algorithm'] : false;
$fingerprint = isset($access['fingerprint']) ? $access['fingerprint'] : false;
// both are mandatory
if (!$algorithm || !$fingerprint) {
continue;
}
$xml .= "\t".'<signatory><certificate fingerprint="'.$fingerprint.'" fingerprint-algorithm="'.$algorithm.'"/></signatory>'.PHP_EOL;
}
return $xml;
}
private function getAllowHeader(array $conf)
{
$xml = '';
if (!isset($conf['allow-http-request-headers-from'])) {
return $xml;
}
$allowHeaders = $conf['allow-http-request-headers-from'];
if (!is_array($allowHeaders)) {
return $xml;
}
foreach ($allowHeaders as $access) {
// domain & headers are mandatory
if (!isset($access['domain']) && !isset($access['headers'])) {
continue;
}
$secure = isset($access['secure']) ? $access['secure'] : false;
$xml .= "\t".'<allow-http-request-headers-from domain="'.$access['domain'].'" headers="'.$access['headers'].'"'. ($secure ? ' secure="'.$secure.'"': '') . '/>'.PHP_EOL;
}
return $xml;
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Alchemy\Phrasea\Utilities;
use Alchemy\Phrasea\Exception\RuntimeException;
/** Parse crossdomain.xml file */
class CrossDomainParser
{
public function parse($file)
{
if (!file_exists($file)) {
throw new RuntimeException(sprintf('File "%s" does not exist.', $file));
}
$xml = simplexml_load_file($file);
if (!$xml) {
throw new RuntimeException(sprintf('File "%s" could not be parsed.', $file));
}
$conf = array();
if (isset($xml->{"site-control"})) {
$sc = $xml->{"site-control"};
foreach ($sc->attributes() as $k => $v) {
if ($k === 'permitted-cross-domain-policies') {
$conf['site-control'] = (string) $v;
}
}
}
if (isset($xml->{"allow-access-from"})) {
if (count($xml->{"allow-access-from"}) > 0) {
$conf['allow-access-from'] = array();
foreach ($xml->{"allow-access-from"} as $el) {
$opt = array();
foreach ($el->attributes() as $k => $v) {
$opt[$k] = (string) $v;
}
$conf['allow-access-from'][] = $opt;
}
}
}
if (isset($xml->{"signatory"})) {
if (count($xml->{"signatory"}) > 0) {
$conf['allow-access-from-identity'] = array();
foreach ($xml->{"signatory"} as $el) {
if (isset($el->{"certificate"})) {
$c = array();
foreach ($el->{"certificate"}->attributes() as $k => $v) {
$c[$k] = (string) $v;
}
$conf['allow-access-from-identity'][] = $c;
}
}
}
}
if (isset($xml->{"allow-http-request-headers-from"})) {
if (count($xml->{"allow-http-request-headers-from"}) > 0) {
$conf['allow-http-request-headers-from'] = array();
foreach ($xml->{"allow-http-request-headers-from"} as $el) {
$opt = array();
foreach ($el->attributes() as $k => $v) {
$opt[$k] = (string) $v;
}
$conf['allow-http-request-headers-from'][] = $opt;
}
}
}
return $conf;
}
}

View File

@@ -17,9 +17,9 @@ class Setup_Upgrade
{
/**
*
* @var appbox
* @var Applications
*/
private $appbox;
private $app;
/**
*
@@ -30,16 +30,16 @@ class Setup_Upgrade
public function __construct(Application $app, $force = false)
{
if ($force) {
self::remove_lock_file();
$this->remove_lock_file();
}
if (self::lock_exists()) {
if ($this->lock_exists()) {
throw new Exception_Setup_UpgradeAlreadyStarted('The upgrade is already started');
}
$this->appbox = $app['phraseanet.appbox'];
$this->app = $app;
if (version_compare($this->appbox->get_version(), '3.9', '<')
if (version_compare($this->app['phraseanet.appbox']->get_version(), '3.9', '<')
&& count(MailChecker::getWrongEmailUsers($app)) > 0) {
throw new \Exception_Setup_FixBadEmailAddresses('Please fix the database before starting');
}
@@ -55,7 +55,7 @@ class Setup_Upgrade
*/
public function __destruct()
{
self::remove_lock_file();
$this->remove_lock_file();
return;
}
@@ -93,9 +93,9 @@ class Setup_Upgrade
'last_update' => $date_obj->format(DATE_ATOM),
], 1);
if (!file_put_contents(self::get_lock_file(), $datas))
if (!file_put_contents($this->get_lock_file(), $datas))
throw new Exception_Setup_CannotWriteLockFile(
sprintf('Cannot write lock file to %s', self::get_lock_file())
sprintf('Cannot write lock file to %s', $this->get_lock_file())
);
return $this;
@@ -106,11 +106,11 @@ class Setup_Upgrade
*
* @return boolean
*/
private static function lock_exists()
private function lock_exists()
{
clearstatcache();
return file_exists(self::get_lock_file());
return file_exists($this->get_lock_file());
}
/**
@@ -118,19 +118,19 @@ class Setup_Upgrade
*
* @return string
*/
private static function get_lock_file()
private function get_lock_file()
{
return __DIR__ . '/../../../tmp/upgrade.lock';
return $this->app['tmp.path'].'/locks/upgrade.lock';
}
/**
*
* @return Void
*/
private static function remove_lock_file()
private function remove_lock_file()
{
if (self::lock_exists()) {
unlink(self::get_lock_file());
if ($this->lock_exists()) {
unlink($this->get_lock_file());
}
return;

View File

@@ -288,21 +288,24 @@ class appbox extends base
$app['phraseanet.pre-schema-upgrader']->apply($app);
$finder = new Finder();
$finder->in([
$this->app['root.path'] . '/tmp/cache_minify/',
$this->app['root.path'] . '/tmp/cache_twig/',
$this->app['root.path'] . '/tmp/translations/',
$this->app['root.path'] . '/tmp/cache/profiler/',
$this->app['root.path'] . '/tmp/doctrine/',
$this->app['root.path'] . '/tmp/serializer/',
])
$in = [];
foreach ($app['cache.paths'] as $path) {
$in[] = $path.'/minify/';
$in[] = $path.'/twig/';
$in[] = $path.'/translations/';
$in[] = $path.'/profiler/';
$in[] = $path.'/doctrine/';
$in[] = $path.'/serializer/';
};
$finder->in(array_filter($in, function($path) {
return is_dir($path);
}))
->depth(0)
->ignoreVCS(true)
->ignoreDotFiles(true);
foreach ($finder as $file) {
$app['filesystem']->remove($file);
}
$app['filesystem']->remove($finder);
foreach ([
'config/custom_files/' => 'www/custom/',
@@ -311,7 +314,7 @@ class appbox extends base
'config/status/' => 'www/custom/status/',
'config/wm/' => 'www/custom/wm/',
] as $source => $target) {
$app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target);
$app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target, null, array('override' => true));
}
$advices = $this->upgradeDB(true, $app);

View File

@@ -412,7 +412,7 @@ abstract class base implements cache_cacheableInterface
{
$field_stmt = $defaults_stmt = [];
$create_stmt = "CREATE TABLE `" . $table['name'] . "` (";
$create_stmt = "CREATE TABLE IF NOT EXISTS `" . $table['name'] . "` (";
foreach ($table->fields->field as $field) {
$isnull = trim($field->null) == "" ? "NOT NULL" : "NULL";

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class connection_pdoStatement implements \connection_statement
{
protected $statement;
public function __construct(\PDOStatement $statement)
{
$this->statement = $statement;
return $this;
}
public function getQueryString()
{
return $this->statement->queryString;
}
public function execute($params = array())
{
return $this->statement->execute($params);
}
public function __call($function_name, $parameters)
{
return call_user_func_array(array($this->statement, $function_name), $parameters);
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class connection_pdoStatementReconnectable implements \connection_statement
{
protected $queryString;
protected $statement;
protected $conn;
public function __construct(\connection_statement $statement, \connection_pdo $conn)
{
$this->statement = $statement;
$this->conn = $conn;
return $this;
}
public function getQueryString()
{
return $this->statement->getQueryString();
}
public function execute($params = array())
{
try {
return $this->statement->execute($params);
} catch (\Exception $e) {
$unreachable = ($e->getCode() === 2006) || (false !== strpos($e->getMessage(), 'MySQL server has gone away')) || (false !== strpos($e->getMessage(), 'errno=32 Broken pipe'));
if (!$unreachable) {
throw $e;
}
$this->conn->connect();
}
// retry query with update statement
$this->statement = $this->conn->prepare($this->getQueryString());
return $this->statement->execute($params);
}
public function __call($function_name, $parameters)
{
return call_user_func_array(array($this->statement, $function_name), $parameters);
}
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
interface connection_statement
{
public function execute($params = array());
public function getQueryString();
}

View File

@@ -419,14 +419,18 @@ class databox extends base
public function get_indexed_record_amount()
{
$sql = "SELECT status & 3 AS status, SUM(1) AS n FROM record GROUP BY(status & 3)";
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$ret = ['xml_indexed' => 0, 'thesaurus_indexed' => 0];
$ret = array(
'xml_indexed' => 0,
'thesaurus_indexed' => 0,
'jeton_subdef' => array()
);
foreach ($rs as $row) {
$status = $row['status'];
if ($status & 1)
@@ -435,6 +439,21 @@ class databox extends base
$ret['thesaurus_indexed'] += $row['n'];
}
$sql = "SELECT type, jeton, COUNT(record_id) AS n FROM record WHERE jeton & ".JETON_MAKE_SUBDEF." GROUP BY type, jeton";
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
if(!array_key_exists($row['type'], $ret['jeton_subdef'])) {
$ret['jeton_subdef'][$row['type']] = 0;
}
if((int)$row['jeton'] & JETON_MAKE_SUBDEF) {
$ret['jeton_subdef'][$row['type']] += (int)$row['n'];
}
}
return $ret;
}
@@ -575,7 +594,7 @@ class databox extends base
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
$databox->insert_datas();
$databox->setNewStructure(
$data_template, $app['conf']->get(['main', 'storage', 'subdefs', 'default-dir'])
$data_template, $app['conf']->get(['main', 'storage', 'subdefs'])
);
return $databox;
@@ -915,7 +934,7 @@ class databox extends base
$contents = str_replace(
["{{basename}}", "{{datapathnoweb}}"]
, [$this->dbname, $path_doc]
, [$this->dbname, rtrim($path_doc, '/').'/']
, $contents
);

View File

@@ -42,7 +42,7 @@ class module_console_sphinxGenerateSuggestion extends Command
)
));
$tmp_file = $this->container['root.path'] . '/tmp/dict' . $index . '.txt';
$tmp_file = sys_get_temp_dir().'/dict' . $index . '.txt';
$databox = $this->getService('phraseanet.appbox')->get_databox($sbas_id);

View File

@@ -31,21 +31,16 @@ class module_console_systemClearCache extends Command
{
$finder = new Finder();
$in = [];
foreach ($this->container['cache.paths'] as $path) {
$in[] = $path;
};
$finder
->exclude('.git')
->exclude('.svn')
->in([
$this->container['root.path'] . '/tmp/cache_minify/',
$this->container['root.path'] . '/tmp/cache_twig/',
$this->container['root.path'] . '/tmp/translations/',
$this->container['root.path'] . '/tmp/cache/profiler/',
$this->container['root.path'] . '/tmp/doctrine/',
$this->container['root.path'] . '/tmp/serializer/',
]);
->in($in);
$filesystem = new Filesystem();
$filesystem->remove($finder);
$this->container['filesystem']->remove($finder);
if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
$this->getService('phraseanet.cache-service')->flushAll();

View File

@@ -641,8 +641,9 @@ class module_report_activity extends module_report
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE log.site = :site_id
AND log_date.action = 'download'
AND (" . $datefilter['sql'] . ")
AND (" . $collfilter['sql'] . ")
AND (" . $datefilter['sql'] . ")" .
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
. "
) AS tt
LEFT JOIN subdef AS s ON (s.record_id = tt.record_id)
WHERE s.name = tt.final
@@ -715,9 +716,9 @@ class module_report_activity extends module_report
SELECT DISTINCT(log_date.id), log_date.date AS heures
FROM log AS log_date FORCE INDEX (date_site)
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . "
AND " . $collfilter['sql'] . "
AND log_date.site = :site_id
WHERE " . $datefilter['sql'] . "" .
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
. " AND log_date.site = :site_id
) AS tt";
$stmt = $conn->prepare($sql);
@@ -747,12 +748,10 @@ class module_report_activity extends module_report
{
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
$conn = $databox->get_connection();
$result = [];
$res = [];
$datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter =
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$result = array();
$res = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -763,9 +762,9 @@ class module_report_activity extends module_report
SELECT DISTINCT(log_date.id), DATE_FORMAT( log_date.date, '%Y-%m-%d' ) AS ddate
FROM log AS log_date FORCE INDEX (date_site) INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . "
AND log_date.site = :site_id
AND (" . $collfilter['sql'] . ")
) AS tt
AND log_date.site = :site_id" .
(('' !== $collfilter['sql']) ? (" AND (" . $collfilter['sql'] . ")") : '')
. ") AS tt
GROUP by tt.ddate
ORDER BY tt.ddate ASC";
@@ -807,9 +806,9 @@ class module_report_activity extends module_report
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_search.log_id = log_date.id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . "
AND log_date.site = :site_id
AND (" . $collfilter['sql'] . ")
) AS tt
AND log_date.site = :site_id" .
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
. ") AS tt
GROUP BY tt.usrid
ORDER BY nb DESC";
@@ -848,9 +847,9 @@ class module_report_activity extends module_report
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_search.log_id = log_date.id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . "
AND log_date.site = :site_id
AND (" . $collfilter['sql'] . ")
) AS tt
AND log_date.site = :site_id" .
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
. ") AS tt
GROUP BY tt.search
ORDER BY nb DESC";
@@ -889,9 +888,9 @@ class module_report_activity extends module_report
FROM (log_view)
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_view.log_id = log_date.id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . "
AND (" . $collfilter['sql'] . ")
) AS tt
WHERE " . $datefilter['sql'] . "" .
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
. ") AS tt
GROUP BY referrer
ORDER BY nb_view DESC ";
@@ -933,8 +932,9 @@ class module_report_activity extends module_report
FROM (log_docs AS log_date)
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'
AND (" . $collfilter['sql'] . ")
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add' " .
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
. "
) AS tt
GROUP BY tt.ddate
ORDER BY activity ASC ";
@@ -969,9 +969,9 @@ class module_report_activity extends module_report
FROM (log_docs AS log_date)
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . " AND log_date.action = 'edit'
AND (" . $collfilter['sql'] . ")
) AS tt
WHERE " . $datefilter['sql'] . " AND log_date.action = 'edit'" .
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
. ") AS tt
GROUP BY tt.ddate
ORDER BY activity ASC ";
@@ -1006,9 +1006,9 @@ class module_report_activity extends module_report
FROM (log_docs AS log_date)
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'
AND (" . $collfilter['sql'] . ")
) AS tt
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'" .
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
. ") AS tt
GROUP BY tt.usrid
ORDER BY nb ASC ";

View File

@@ -50,7 +50,11 @@ class module_report_sqlfilter
$coll_filter[] = 'log_colls.coll_id = ' . $val;
}
}
$ret['sql'] = ' (' . implode(' OR ', array_unique($coll_filter)) . ') ';
$collections = array_unique($coll_filter);
if (count($collections) > 0) {
$ret['sql'] = ' (' . implode(' OR ', $collections) . ') ';
}
return $ret;
}
@@ -66,15 +70,15 @@ class module_report_sqlfilter
$params = [':log_site' => $this->app['conf']->get(['main', 'key'])];
if ($this->filter['date']) {
if ($this->filter['date'] && $this->filter['date']['sql'] !== '') {
$finalfilter .= $this->filter['date']['sql'] . ' AND ';
$params = array_merge($params, $this->filter['date']['params']);
}
if ($this->filter['user']) {
if ($this->filter['user'] && $this->filter['user']['sql'] !== '') {
$finalfilter .= $this->filter['user']['sql'] . ' AND ';
$params = array_merge($params, $this->filter['user']['params']);
}
if ($this->filter['collection']) {
if ($this->filter['collection'] && $this->filter['collection']['sql'] !== '') {
$finalfilter .= $this->filter['collection']['sql'] . ' AND ';
$params = array_merge($params, $this->filter['collection']['params']);
}
@@ -174,11 +178,14 @@ class module_report_sqlfilter
$n ++;
}
$filter_user = ['sql' => implode(' AND ', $filter), 'params' => $params];
if (count($filter) > 0) {
$filter_user = array('sql' => implode(' AND ', $filter), 'params' => $params);
$this->filter['user'] = $filter_user;
}
}
return;
}
@@ -201,7 +208,11 @@ class module_report_sqlfilter
}
}
$this->filter['collection'] = ['sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => []];
$collections = array_unique($coll_filter);
if (count($collections) > 0) {
$this->filter['collection'] = array('sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => array());
}
}
return;
@@ -219,7 +230,9 @@ class module_report_sqlfilter
$params[":record_fil" . $n] = phrasea::collFromBas($this->app, $val);
$n ++;
}
$this->filter['record'] = ['sql' => implode(' OR ', $dl_coll_filter), 'params' => $params];
if (count($dl_coll_filter) > 0) {
$this->filter['record'] = array('sql' => implode(' OR ', $dl_coll_filter), 'params' => $params);
}
}
return;

View File

@@ -89,7 +89,7 @@ class patch_370alpha7a extends patchAbstract
$i = 0;
foreach ($rs as $row) {
$filePath = $app['root.path'] . '/tmp/lazaret/' . $row['filepath'];
$filePath = $app['tmp.lazaret.path'].'/'.$row['filepath'];
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
continue;
}
@@ -100,7 +100,7 @@ class patch_370alpha7a extends patchAbstract
$spec->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO);
$spec->setDimensions(375, 275);
$thumbPath = $app['root.path'] . '/tmp/lazaret/' . sprintf("thumb_%s", $row['filepath']);
$thumbPath = $app['tmp.lazaret.path'].'/'.sprintf("thumb_%s", $row['filepath']);
try {
$app['media-alchemyst']->turnInto($filePath, $thumbPath, $spec);

View File

@@ -63,11 +63,11 @@ class patch_380alpha16a extends patchAbstract
}
$xsendfile['mapping'][] = [
'directory' => $app['root.path'] . '/tmp/lazaret/',
'directory' => $app['tmp.lazaret.path'],
'mount-point' => '/lazaret/',
];
$xsendfile['mapping'][] = [
'directory' => $app['root.path'] . '/tmp/download/',
'directory' => $app['tmp.download.path'],
'mount-point' => '/download/',
];

View File

@@ -0,0 +1,85 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 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 Alchemy\Phrasea\Utilities\CrossDomainParser;
use Alchemy\Phrasea\Exception\RuntimeException;
class patch_386alpha2a implements patchInterface
{
/** @var string */
private $release = '3.8.6-alpha.2';
/** @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;
}
/**
* Returns doctrine migrations needed for the patch.
*
* @return array
*/
public function getDoctrineMigrations()
{
return array();
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$config = $app['phraseanet.configuration']->getConfig();
$parser = new CrossDomainParser();
try {
$crossDomainConfig = $parser->parse($app['root.path'].'/www/crossdomain.xml');
} catch (RuntimeException $e) {
$crossDomainConfig = array(
'allow-access-from' => array(
array(
'domain' => '*.cooliris.com',
'secure' => 'false',
)
)
);
}
$config['crossdomain'] = $crossDomainConfig;
$app['phraseanet.configuration']->setConfig($config);
return true;
}
}

View File

@@ -0,0 +1,100 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_390alpha19a extends patchAbstract
{
/** @var string */
private $release = '3.9.0-alpha.19';
/** @var array */
private $concern = [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 getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$storage = $app['conf']->get(['main', 'storage']);
$storage['cache'] = $app['root.path'].'/cache';
$storage['log'] = $app['root.path'].'/logs';
$storage['download'] = $app['root.path'].'/tmp/download';
$storage['lazaret'] = $app['root.path'].'/tmp/lazaret';
$storage['caption'] = $app['root.path'].'/tmp/caption';
$app['conf']->set(['main', 'storage'], $storage);
// update file structure
$this->removeDirectory($app, $app['root.path'].'/tmp/cache_twig');
$this->removeDirectory($app, $app['root.path'].'/tmp/doctrine');
$this->removeDirectory($app, $app['root.path'].'/tmp/profiler');
$this->removeDirectory($app, $app['root.path'].'/tmp/serializer');
$this->removeDirectory($app, $app['root.path'].'/tmp/translations');
$this->removeDirectory($app, $app['root.path'].'/tmp/cache_minify');
$this->removeDirectory($app, $app['root.path'].'/features');
$this->removeDirectory($app, $app['root.path'].'/hudson');
$this->removeDirectory($app, $app['root.path'].'/locales');
$this->removeDirectory($app, $app['root.path'].'/vagrant');
$this->removeDirectory($app, $app['root.path'].'/tmp/doctrine-proxies');
$this->copyFile($app, $app['root.path'].'/tmp/cache_registry.php', $app['cache.path'].'/cache_registry.php');
$this->copyFile($app, $app['root.path'].'/tmp/configuration-compiled.php', $app['root.path'].'/config/configuration-compiled.php');
return true;
}
private function removeDirectory(Application $app, $originDir)
{
if (is_dir($originDir)) {
$app['filesystem']->remove($originDir);
}
}
private function copyFile(Application $app, $originFile, $targetFile)
{
if ($app['filesystem']->exists($originFile)) {
$app['filesystem']->copy($originFile, $targetFile);
}
}
}

View File

@@ -165,7 +165,7 @@ class patch_390alpha9b extends patchAbstract
'GV_smtp_secure' => ['registry', 'email', 'smtp-secure-mode'],
'GV_smtp_user' => ['registry', 'email', 'smtp-user'],
'GV_smtp_password' => ['registry', 'email', 'smtp-password'],
'GV_base_datapath_noweb' => ['main', 'storage', 'subdefs', 'default-dir'],
'GV_base_datapath_noweb' => ['main', 'storage', 'subdefs'],
'GV_youtube_api' => ['main', 'bridge', 'youtube', 'enabled'],
'GV_youtube_client_id' => ['main', 'bridge', 'youtube', 'client_id'],
'GV_youtube_client_secret' => ['main', 'bridge', 'youtube', 'client_secret'],

View File

@@ -41,7 +41,7 @@ class random
switch ($row['type']) {
case 'download':
case 'email':
$file = $this->app['root.path'] . '/tmp/download/' . $row['value'] . '.zip';
$file = $this->app['tmp.download.path'].'/'.$row['value'].'.zip';
if (is_file($file))
unlink($file);
break;

View File

@@ -631,8 +631,7 @@ class set_export extends set_abstract
$files[$id]["export_name"] = $tmp_name;
if (in_array('caption', $subdefs)) {
$caption_dir = $this->app['root.path'] . '/tmp/desc_tmp/'
. time() . $this->app['authentication']->getUser()->getId() . '/';
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app['authentication']->getUser()->getId().'/';
$filesystem->mkdir($caption_dir, 0750);
@@ -653,8 +652,7 @@ class set_export extends set_abstract
}
if (in_array('caption-yaml', $subdefs)) {
$caption_dir = $this->app['root.path'] . '/tmp/desc_tmp/'
. time() . $this->app['authentication']->getUser()->getId() . '/';
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app['authentication']->getUser()->getId().'/';
$filesystem->mkdir($caption_dir, 0750);

View File

@@ -2351,11 +2351,19 @@
<comment></comment>
</field>
<field>
<name>completed</name>
<type>tinyint(4)</type>
<name>todo</name>
<type>int(11)</type>
<null></null>
<extra></extra>
<default>-1</default>
<default>0</default>
<comment></comment>
</field>
<field>
<name>done</name>
<type>int(11)</type>
<null></null>
<extra></extra>
<default>0</default>
<comment></comment>
</field>
<field>

View File

@@ -72,8 +72,12 @@ main:
swftools_timeout: 60
unoconv_timeout: 60
storage:
subdefs:
default-dir: null
subdefs: null
cache: null
log : null
download: null
lazaret: null
caption: null
bridge:
youtube:
enabled: false
@@ -199,3 +203,8 @@ session:
idle: 0
# 1 week
lifetime: 604800
crossdomain:
allow-access-from:
-
domain: '*.cooliris.com'
secure: 'false'

2
logs/.gitignore vendored
View File

@@ -1,2 +0,0 @@
*
!.gitignore

0
logs/.gitkeep Normal file
View File

Some files were not shown because too many files have changed in this diff Show More