mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Merge branch '3.6' of github.com:alchemy-fr/Phraseanet into 3.6
This commit is contained in:
@@ -5,12 +5,12 @@ Phraseanet 3.5 - Digital Asset Management application
|
|||||||
|
|
||||||
Metadatas Management (include Thesaurus and DublinCore Mapping)
|
Metadatas Management (include Thesaurus and DublinCore Mapping)
|
||||||
Search Engine (Sphinx Search Integration)
|
Search Engine (Sphinx Search Integration)
|
||||||
RestFull APIS (See Developer Documentation http://docs.phraseanet.com/Devel)
|
RestFull APIS (See Developer Documentation https://docs.phraseanet.com/3.6/Devel)
|
||||||
Bridge to Youtube/Dailymotion/Flickr
|
Bridge to Youtube/Dailymotion/Flickr
|
||||||
|
|
||||||
#Documentation :
|
#Documentation :
|
||||||
|
|
||||||
http://docs.phraseanet.com
|
https://docs.phraseanet.com/3.6/
|
||||||
|
|
||||||
#Easy Installation
|
#Easy Installation
|
||||||
|
|
||||||
|
@@ -64,6 +64,7 @@ try
|
|||||||
$app->add(new module_console_schedulerStart('scheduler:start'));
|
$app->add(new module_console_schedulerStart('scheduler:start'));
|
||||||
$app->add(new module_console_fileConfigCheck('check:config'));
|
$app->add(new module_console_fileConfigCheck('check:config'));
|
||||||
$app->add(new module_console_fileEnsureProductionSetting('check:ensureProductionSettings'));
|
$app->add(new module_console_fileEnsureProductionSetting('check:ensureProductionSettings'));
|
||||||
|
$app->add(new module_console_fileEnsureDevSetting('check:ensureDevSettings'));
|
||||||
$app->add(new module_console_systemConfigCheck('check:system'));
|
$app->add(new module_console_systemConfigCheck('check:system'));
|
||||||
$result_code = $app->run();
|
$result_code = $app->run();
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,7 @@ bootstrap::register_autoloads();
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
||||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
|
||||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
|
||||||
);
|
|
||||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
|
||||||
|
|
||||||
$serviceName = $configuration->getOrm();
|
$serviceName = $configuration->getOrm();
|
||||||
$confService = $configuration->getService($serviceName);
|
$confService = $configuration->getService($serviceName);
|
||||||
|
@@ -41,8 +41,8 @@ prod:
|
|||||||
|
|
||||||
template_engine: twig
|
template_engine: twig
|
||||||
orm: doctrine_prod
|
orm: doctrine_prod
|
||||||
cache: memcache_cache
|
cache: array_cache
|
||||||
opcodecache: apc_cache
|
opcodecache: array_cache
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# TEST #
|
# TEST #
|
||||||
|
@@ -52,11 +52,11 @@ Orm:
|
|||||||
dbal: main_connexion
|
dbal: main_connexion
|
||||||
cache:
|
cache:
|
||||||
query:
|
query:
|
||||||
service: Cache\apc_cache
|
service: Cache\array_cache
|
||||||
result:
|
result:
|
||||||
service: Cache\memcache_cache
|
service: Cache\array_cache
|
||||||
metadata:
|
metadata:
|
||||||
service: Cache\apc_cache
|
service: Cache\array_cache
|
||||||
|
|
||||||
TemplateEngine:
|
TemplateEngine:
|
||||||
#Define a template engine service
|
#Define a template engine service
|
||||||
|
@@ -38,7 +38,7 @@ echo "ok !";
|
|||||||
# Valid link ?
|
# Valid link ?
|
||||||
|
|
||||||
echo -n "Check link validity : ";
|
echo -n "Check link validity : ";
|
||||||
wget --no-check-certificate $instance -o /dev/null
|
wget --no-check-certificate $instance --output-document=/dev/null
|
||||||
if [ ! $? -eq 0 ]
|
if [ ! $? -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "Link does not exists.";
|
echo "Link does not exists.";
|
||||||
@@ -60,10 +60,11 @@ do
|
|||||||
echo "nok !";
|
echo "nok !";
|
||||||
cat /tmp/jsunitphantom;
|
cat /tmp/jsunitphantom;
|
||||||
testOK=1;
|
testOK=1;
|
||||||
|
else
|
||||||
|
echo "ok !";
|
||||||
fi
|
fi
|
||||||
echo "";
|
echo "";
|
||||||
echo "";
|
echo "";
|
||||||
echo "";
|
|
||||||
done
|
done
|
||||||
|
|
||||||
exit $testOK;
|
exit $testOK;
|
||||||
|
@@ -317,6 +317,19 @@ return call_user_func(function()
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$route = '/records/{databox_id}/{record_id}/caption/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->caption_records($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/caption/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
|
* Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
|
||||||
*
|
*
|
||||||
|
@@ -232,7 +232,7 @@ return call_user_func(
|
|||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
/* @var $repository \Repositories\BasketRepository */
|
/* @var $repository \Repositories\BasketRepository */
|
||||||
$basket_collection = $repository->findActiveByUser(
|
$basket_collection = $repository->findActiveValidationAndBasketByUser(
|
||||||
$app['Core']->getAuthenticatedUser()
|
$app['Core']->getAuthenticatedUser()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ return call_user_func(
|
|||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
/* @var $repository \Repositories\BasketRepository */
|
/* @var $repository \Repositories\BasketRepository */
|
||||||
$basket_collection = $repository->findActiveByUser(
|
$basket_collection = $repository->findActiveValidationAndBasketByUser(
|
||||||
$app['Core']->getAuthenticatedUser()
|
$app['Core']->getAuthenticatedUser()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -52,4 +52,9 @@ class ApcCache extends DoctrineApc implements Cache
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
return apc_clear_cache() && apc_clear_cache('user');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -53,4 +53,11 @@ class ArrayCache extends DoctrineArray implements Cache
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
$this->deleteAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -26,6 +26,8 @@ interface Cache extends DoctrineCache
|
|||||||
|
|
||||||
public function getStats();
|
public function getStats();
|
||||||
|
|
||||||
|
public function flush();
|
||||||
|
|
||||||
public function get($key);
|
public function get($key);
|
||||||
|
|
||||||
public function deleteMulti(array $array_keys);
|
public function deleteMulti(array $array_keys);
|
||||||
|
@@ -60,7 +60,7 @@ class Manager
|
|||||||
{
|
{
|
||||||
foreach ($this->registry as $cacheKey => $service_name)
|
foreach ($this->registry as $cacheKey => $service_name)
|
||||||
{
|
{
|
||||||
$this->get($cacheKey, $service_name)->getDriver()->deleteAll();
|
$this->get($cacheKey, $service_name)->getDriver()->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -71,22 +71,25 @@ class Manager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$configuration = $this->core->getConfiguration()->getService($service_name);
|
$configuration = $this->core->getConfiguration()->getService($service_name);
|
||||||
|
$service = Builder::create($this->core, $service_name, $configuration);
|
||||||
|
$driver = $service->getDriver();
|
||||||
$write = true;
|
$write = true;
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||||
array('type' => 'Cache\\ArrayCache')
|
array('type' => 'Cache\\ArrayCache')
|
||||||
);
|
);
|
||||||
|
$service = Builder::create($this->core, $service_name, $configuration);
|
||||||
|
$driver = $service->getDriver();
|
||||||
$write = false;
|
$write = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$service = Builder::create($this->core, $service_name, $configuration);
|
|
||||||
|
|
||||||
if ($this->hasChange($cacheKey, $service_name))
|
if ($this->hasChange($cacheKey, $service_name))
|
||||||
{
|
{
|
||||||
$service->getDriver()->deleteAll();
|
$driver->flush();
|
||||||
if($write)
|
|
||||||
|
if ($write)
|
||||||
{
|
{
|
||||||
$this->registry[$cacheKey] = $service_name;
|
$this->registry[$cacheKey] = $service_name;
|
||||||
$this->save($cacheKey, $service_name);
|
$this->save($cacheKey, $service_name);
|
||||||
@@ -108,7 +111,7 @@ class Manager
|
|||||||
$this->registry[$name] = $driver;
|
$this->registry[$name] = $driver;
|
||||||
|
|
||||||
$datas = sprintf("#LastUpdate: %s\n", $date->format(DATE_ISO8601))
|
$datas = sprintf("#LastUpdate: %s\n", $date->format(DATE_ISO8601))
|
||||||
. $this->parser->dump($this->registry);
|
. $this->parser->dump($this->registry);
|
||||||
|
|
||||||
file_put_contents($this->cacheFile->getPathname(), $datas);
|
file_put_contents($this->cacheFile->getPathname(), $datas);
|
||||||
}
|
}
|
||||||
|
@@ -52,4 +52,9 @@ class MemcacheCache extends DoctrineMemcache implements Cache
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
return $this->getMemcache()->flush();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -23,7 +23,7 @@ class RedisCache extends AbstractCache implements Cache
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Memcache
|
* @var \Redis
|
||||||
*/
|
*/
|
||||||
private $_redis;
|
private $_redis;
|
||||||
|
|
||||||
@@ -124,4 +124,9 @@ class RedisCache extends AbstractCache implements Cache
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
return $this->_redis->flushAll();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -52,4 +52,9 @@ class XcacheCache extends DoctrineXcache implements Cache
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
return xcache_clear_cache(XC_TYPE_VAR, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -99,18 +99,6 @@ class Description implements ControllerProviderInterface
|
|||||||
$field->set_dces_element($dces_element);
|
$field->set_dces_element($dces_element);
|
||||||
$field->save();
|
$field->save();
|
||||||
|
|
||||||
if ($request->get('regname') == $field->get_id())
|
|
||||||
{
|
|
||||||
$field->set_regname();
|
|
||||||
}
|
|
||||||
if ($request->get('regdate') == $field->get_id())
|
|
||||||
{
|
|
||||||
$field->set_regdate();
|
|
||||||
}
|
|
||||||
if ($request->get('regdesc') == $field->get_id())
|
|
||||||
{
|
|
||||||
$field->set_regdesc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
@@ -413,10 +413,28 @@ class Basket implements ControllerProviderInterface
|
|||||||
|
|
||||||
$basket->addBasketElement($basket_element);
|
$basket->addBasketElement($basket_element);
|
||||||
|
|
||||||
|
if(null !== $validationSession = $basket->getValidation())
|
||||||
|
{
|
||||||
|
if(false !== $validationSession->isFinished())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$participants = $validationSession->getParticipants();
|
||||||
|
|
||||||
|
foreach($participants as $participant)
|
||||||
|
{
|
||||||
|
$validationData = new \Entities\ValidationData();
|
||||||
|
$validationData->setParticipant($participant);
|
||||||
|
$validationData->setBasketElement($basket_element);
|
||||||
|
|
||||||
|
$em->persist($validationData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->merge($basket);
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@@ -183,10 +183,12 @@ class Push implements ControllerProviderInterface
|
|||||||
|
|
||||||
$appbox = \appbox::get_instance($app['Core']);
|
$appbox = \appbox::get_instance($app['Core']);
|
||||||
|
|
||||||
$push_name = $request->get(
|
$push_name = $request->get('name');
|
||||||
'name'
|
|
||||||
, sprintf(_('Push from %s'), $user->get_display_name())
|
if (trim($push_name) === '')
|
||||||
);
|
{
|
||||||
|
$push_name = sprintf(_('Push from %s'), $user->get_display_name());
|
||||||
|
}
|
||||||
|
|
||||||
$push_description = $request->get('push_description');
|
$push_description = $request->get('push_description');
|
||||||
|
|
||||||
@@ -322,10 +324,12 @@ class Push implements ControllerProviderInterface
|
|||||||
|
|
||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
$validation_name = $request->get(
|
$validation_name = $request->get('name');
|
||||||
'name'
|
|
||||||
, sprintf(_('Validation from %s'), $user->get_display_name())
|
if (trim($validation_name) === '')
|
||||||
);
|
{
|
||||||
|
$validation_name = sprintf(_('Validation from %s'), $user->get_display_name());
|
||||||
|
}
|
||||||
|
|
||||||
$validation_description = $request->get('validation_description');
|
$validation_description = $request->get('validation_description');
|
||||||
|
|
||||||
|
@@ -205,11 +205,9 @@ class Query implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$json['results'] = $twig->render($template, array(
|
$json['results'] = $twig->render($template, array(
|
||||||
'results' => $result,
|
'results' => $result,
|
||||||
'GV_social_tools' => $registry->get('GV_social_tools'),
|
'GV_social_tools' => $registry->get('GV_social_tools'),
|
||||||
'array_selected' => explode(';', $request->get('sel')),
|
|
||||||
'highlight' => $search_engine->get_query(),
|
'highlight' => $search_engine->get_query(),
|
||||||
'searchEngine' => $search_engine,
|
'searchEngine' => $search_engine,
|
||||||
'suggestions' => $prop
|
'suggestions' => $prop
|
||||||
|
@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request,
|
|||||||
Symfony\Component\HttpFoundation\Response,
|
Symfony\Component\HttpFoundation\Response,
|
||||||
Symfony\Component\HttpFoundation\RedirectResponse,
|
Symfony\Component\HttpFoundation\RedirectResponse,
|
||||||
Symfony\Component\HttpKernel\Exception\HttpException,
|
Symfony\Component\HttpKernel\Exception\HttpException,
|
||||||
|
Symfony\Component\Finder\Finder,
|
||||||
Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Alchemy\Phrasea\Helper;
|
use Alchemy\Phrasea\Helper;
|
||||||
|
|
||||||
@@ -40,49 +41,56 @@ class Root implements ControllerProviderInterface
|
|||||||
\User_Adapter::updateClientInfos(1);
|
\User_Adapter::updateClientInfos(1);
|
||||||
|
|
||||||
$appbox = \appbox::get_instance($app['Core']);
|
$appbox = \appbox::get_instance($app['Core']);
|
||||||
$css = array();
|
|
||||||
$cssfile = false;
|
|
||||||
$registry = $app['Core']->getRegistry();
|
$registry = $app['Core']->getRegistry();
|
||||||
|
|
||||||
$session = $appbox->get_session();
|
|
||||||
$user = $app['Core']->getAuthenticatedUser();
|
$user = $app['Core']->getAuthenticatedUser();
|
||||||
|
|
||||||
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
|
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
|
||||||
|
|
||||||
if ($hdir = opendir($cssPath))
|
$css = array();
|
||||||
|
$cssfile = false;
|
||||||
|
|
||||||
|
$finder = new Finder();
|
||||||
|
|
||||||
|
$iterator = $finder
|
||||||
|
->directories()
|
||||||
|
->depth(0)
|
||||||
|
->filter(function(\SplFileInfo $fileinfo)
|
||||||
|
{
|
||||||
|
return ctype_xdigit($fileinfo->getBasename());
|
||||||
|
})
|
||||||
|
->in($cssPath);
|
||||||
|
|
||||||
|
foreach ($iterator as $dir)
|
||||||
{
|
{
|
||||||
while (false !== ($file = readdir($hdir)))
|
$baseName = $dir->getBaseName();
|
||||||
{
|
$css[$baseName] = $baseName;
|
||||||
if (substr($file, 0, 1) == "." || mb_strtolower($file) == "cvs")
|
|
||||||
continue;
|
|
||||||
if (is_dir($cssPath . $file))
|
|
||||||
{
|
|
||||||
$css[$file] = $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir($hdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cssfile = $user->getPrefs('css');
|
$cssfile = $user->getPrefs('css');
|
||||||
|
|
||||||
if (!$cssfile && isset($css['000000']))
|
if (!$cssfile && isset($css['000000']))
|
||||||
|
{
|
||||||
$cssfile = '000000';
|
$cssfile = '000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$user_feeds = \Feed_Collection::load_all($appbox, $user);
|
$user_feeds = \Feed_Collection::load_all($appbox, $user);
|
||||||
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
||||||
|
|
||||||
$srt = 'name asc';
|
|
||||||
|
|
||||||
|
|
||||||
$thjslist = "";
|
$thjslist = "";
|
||||||
|
|
||||||
$queries_topics = '';
|
$queries_topics = '';
|
||||||
|
|
||||||
if ($registry->get('GV_client_render_topics') == 'popups')
|
if ($registry->get('GV_client_render_topics') == 'popups')
|
||||||
$queries_topics = queries::dropdown_topics();
|
{
|
||||||
|
$queries_topics = \queries::dropdown_topics();
|
||||||
|
}
|
||||||
elseif ($registry->get('GV_client_render_topics') == 'tree')
|
elseif ($registry->get('GV_client_render_topics') == 'tree')
|
||||||
|
{
|
||||||
$queries_topics = \queries::tree_topics();
|
$queries_topics = \queries::tree_topics();
|
||||||
|
}
|
||||||
|
|
||||||
$sbas = $bas2sbas = array();
|
$sbas = $bas2sbas = array();
|
||||||
|
|
||||||
foreach ($appbox->get_databoxes() as $databox)
|
foreach ($appbox->get_databoxes() as $databox)
|
||||||
{
|
{
|
||||||
$sbas_id = $databox->get_sbas_id();
|
$sbas_id = $databox->get_sbas_id();
|
||||||
@@ -131,8 +139,6 @@ class Root implements ControllerProviderInterface
|
|||||||
'GV_bitly_key' => $registry->get('GV_bitly_key')
|
'GV_bitly_key' => $registry->get('GV_bitly_key')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new Response($out);
|
return new Response($out);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -38,282 +38,311 @@ class Story implements ControllerProviderInterface
|
|||||||
|
|
||||||
|
|
||||||
$controllers->get('/create/', function(Application $app)
|
$controllers->get('/create/', function(Application $app)
|
||||||
{
|
{
|
||||||
/* @var $twig \Twig_Environment */
|
/* @var $twig \Twig_Environment */
|
||||||
$twig = $app['Core']->getTwig();
|
$twig = $app['Core']->getTwig();
|
||||||
|
|
||||||
return new Response($twig->render('prod/Story/Create.html.twig', array()));
|
return new Response($twig->render('prod/Story/Create.html.twig', array()));
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/', function(Application $app, Request $request)
|
$controllers->post('/', function(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
||||||
$em = $app['Core']->getEntityManager();
|
$em = $app['Core']->getEntityManager();
|
||||||
|
|
||||||
$user = $app['Core']->getAuthenticatedUser();
|
$user = $app['Core']->getAuthenticatedUser();
|
||||||
|
|
||||||
$collection = \collection::get_from_base_id($request->get('base_id'));
|
$collection = \collection::get_from_base_id($request->get('base_id'));
|
||||||
|
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord'))
|
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord'))
|
||||||
throw new \Exception_Forbidden('You can not create a story on this collection');
|
{
|
||||||
|
throw new \Exception_Forbidden('You can not create a story on this collection');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$system_file = new \system_file(
|
$system_file = new \system_file(
|
||||||
$app['Core']->getRegistry()
|
$app['Core']->getRegistry()
|
||||||
->get('GV_RootPath') . 'www/skins/icons/substitution/regroup_doc.png'
|
->get('GV_RootPath') . 'www/skins/icons/substitution/regroup_doc.png'
|
||||||
);
|
);
|
||||||
|
|
||||||
$Story = \record_adapter::create($collection, $system_file, false, true);
|
$Story = \record_adapter::create($collection, $system_file, false, true);
|
||||||
|
|
||||||
$metadatas = array();
|
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||||
|
{
|
||||||
|
$sbas_rec = explode('_', $sbas_rec);
|
||||||
|
|
||||||
foreach ($collection->get_databox()->get_meta_structure() as $meta)
|
if (count($sbas_rec) !== 2)
|
||||||
{
|
{
|
||||||
if ($meta->is_regname())
|
continue;
|
||||||
$value = $request->get('name');
|
}
|
||||||
elseif ($meta->is_regdesc())
|
|
||||||
$value = $request->get('description');
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$metadatas[] = array(
|
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||||
'meta_struct_id' => $meta->get_id()
|
|
||||||
, 'meta_id' => null
|
|
||||||
, 'value' => $value
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$Story->set_metadatas($metadatas)
|
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||||
->rebuild_subdefs();
|
&& !$user->ACL()->has_hd_grant($record)
|
||||||
|
&& !$user->ACL()->has_preview_grant($record))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$StoryWZ = new \Entities\StoryWZ();
|
if ($Story->hasChild($record))
|
||||||
$StoryWZ->setUser($user);
|
continue;
|
||||||
$StoryWZ->setRecord($Story);
|
|
||||||
|
|
||||||
$em->persist($StoryWZ);
|
$Story->appendChild($record);
|
||||||
|
}
|
||||||
|
|
||||||
$em->flush();
|
$metadatas = array();
|
||||||
|
|
||||||
if ($request->getRequestFormat() == 'json')
|
foreach ($collection->get_databox()->get_meta_structure() as $meta)
|
||||||
{
|
{
|
||||||
$data = array(
|
if ($meta->get_thumbtitle())
|
||||||
'success' => true
|
{
|
||||||
, 'message' => _('Story created')
|
$value = $request->get('name');
|
||||||
, 'WorkZone' => $StoryWZ->getId()
|
}
|
||||||
, 'story' => array(
|
else
|
||||||
'sbas_id' => $Story->get_sbas_id(),
|
{
|
||||||
'record_id' => $Story->get_record_id(),
|
continue;
|
||||||
)
|
}
|
||||||
);
|
|
||||||
|
|
||||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
$metadatas[] = array(
|
||||||
|
'meta_struct_id' => $meta->get_id()
|
||||||
|
, 'meta_id' => null
|
||||||
|
, 'value' => $value
|
||||||
|
);
|
||||||
|
|
||||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
||||||
return new RedirectResponse(sprintf('/%d/', $StoryWZ->getId()));
|
|
||||||
}
|
$StoryWZ = new \Entities\StoryWZ();
|
||||||
});
|
$StoryWZ->setUser($user);
|
||||||
|
$StoryWZ->setRecord($Story);
|
||||||
|
|
||||||
|
$em->persist($StoryWZ);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
if ($request->getRequestFormat() == 'json')
|
||||||
|
{
|
||||||
|
$data = array(
|
||||||
|
'success' => true
|
||||||
|
, 'message' => _('Story created')
|
||||||
|
, 'WorkZone' => $StoryWZ->getId()
|
||||||
|
, 'story' => array(
|
||||||
|
'sbas_id' => $Story->get_sbas_id(),
|
||||||
|
'record_id' => $Story->get_record_id(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||||
|
|
||||||
|
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new RedirectResponse(sprintf('/%d/', $StoryWZ->getId()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$controllers->get('/{sbas_id}/{record_id}/', function(Application $app, $sbas_id, $record_id)
|
$controllers->get('/{sbas_id}/{record_id}/', function(Application $app, $sbas_id, $record_id)
|
||||||
{
|
{
|
||||||
$Story = new \record_adapter($sbas_id, $record_id);
|
$Story = new \record_adapter($sbas_id, $record_id);
|
||||||
|
|
||||||
/* @var $twig \Twig_Environment */
|
/* @var $twig \Twig_Environment */
|
||||||
$twig = $app['Core']->getTwig();
|
$twig = $app['Core']->getTwig();
|
||||||
|
|
||||||
$html = $twig->render('prod/WorkZone/Story.html.twig', array('Story' => $Story));
|
$html = $twig->render('prod/WorkZone/Story.html.twig', array('Story' => $Story));
|
||||||
|
|
||||||
return new Response($html);
|
return new Response($html);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
$controllers->post(
|
$controllers->post(
|
||||||
'/{sbas_id}/{record_id}/addElements/'
|
'/{sbas_id}/{record_id}/addElements/'
|
||||||
, function(Application $app, Request $request, $sbas_id, $record_id)
|
, function(Application $app, Request $request, $sbas_id, $record_id)
|
||||||
{
|
{
|
||||||
$Story = new \record_adapter($sbas_id, $record_id);
|
$Story = new \record_adapter($sbas_id, $record_id);
|
||||||
|
|
||||||
$user = $app['Core']->getAuthenticatedUser();
|
$user = $app['Core']->getAuthenticatedUser();
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||||
|
|
||||||
/* @var $user \User_Adapter */
|
/* @var $user \User_Adapter */
|
||||||
|
|
||||||
$n = 0;
|
$n = 0;
|
||||||
|
|
||||||
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||||
{
|
{
|
||||||
$sbas_rec = explode('_', $sbas_rec);
|
$sbas_rec = explode('_', $sbas_rec);
|
||||||
|
|
||||||
if (count($sbas_rec) !== 2)
|
if (count($sbas_rec) !== 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||||
|
|
||||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||||
&& !$user->ACL()->has_hd_grant($record)
|
&& !$user->ACL()->has_hd_grant($record)
|
||||||
&& !$user->ACL()->has_preview_grant($record))
|
&& !$user->ACL()->has_preview_grant($record))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Story->hasChild($record))
|
if ($Story->hasChild($record))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$Story->appendChild($record);
|
$Story->appendChild($record);
|
||||||
|
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'success' => true
|
'success' => true
|
||||||
, 'message' => sprintf(_('%d records added'), $n)
|
, 'message' => sprintf(_('%d records added'), $n)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($request->getRequestFormat() == 'json')
|
if ($request->getRequestFormat() == 'json')
|
||||||
{
|
{
|
||||||
|
|
||||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||||
|
|
||||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new RedirectResponse('/');
|
return new RedirectResponse('/');
|
||||||
}
|
}
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->post(
|
$controllers->post(
|
||||||
'/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/'
|
'/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/'
|
||||||
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id)
|
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id)
|
||||||
{
|
{
|
||||||
$Story = new \record_adapter($sbas_id, $record_id);
|
$Story = new \record_adapter($sbas_id, $record_id);
|
||||||
|
|
||||||
$record = new \record_adapter($child_sbas_id, $child_record_id);
|
$record = new \record_adapter($child_sbas_id, $child_record_id);
|
||||||
|
|
||||||
$user = $app['Core']->getAuthenticatedUser();
|
$user = $app['Core']->getAuthenticatedUser();
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||||
|
|
||||||
/* @var $user \User_Adapter */
|
/* @var $user \User_Adapter */
|
||||||
|
|
||||||
$Story->removeChild($record);
|
$Story->removeChild($record);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'success' => true
|
'success' => true
|
||||||
, 'message' => _('Record removed from story')
|
, 'message' => _('Record removed from story')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($request->getRequestFormat() == 'json')
|
if ($request->getRequestFormat() == 'json')
|
||||||
{
|
{
|
||||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||||
|
|
||||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new RedirectResponse('/');
|
return new RedirectResponse('/');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->assert('sbas_id', '\d+')
|
->assert('sbas_id', '\d+')
|
||||||
->assert('record_id', '\d+')
|
->assert('record_id', '\d+')
|
||||||
->assert('child_sbas_id', '\d+')
|
->assert('child_sbas_id', '\d+')
|
||||||
->assert('child_record_id', '\d+');
|
->assert('child_record_id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Basket reorder form
|
* Get the Basket reorder form
|
||||||
*/
|
*/
|
||||||
$controllers->get(
|
$controllers->get(
|
||||||
'/{sbas_id}/{record_id}/reorder/'
|
'/{sbas_id}/{record_id}/reorder/'
|
||||||
, function(Application $app, $sbas_id, $record_id)
|
, function(Application $app, $sbas_id, $record_id)
|
||||||
{
|
{
|
||||||
/* @var $em \Doctrine\ORM\EntityManager */
|
/* @var $em \Doctrine\ORM\EntityManager */
|
||||||
$em = $app['Core']->getEntityManager();
|
$em = $app['Core']->getEntityManager();
|
||||||
|
|
||||||
$story = new \record_adapter($sbas_id, $record_id);
|
$story = new \record_adapter($sbas_id, $record_id);
|
||||||
|
|
||||||
if (!$story->is_grouping())
|
if (!$story->is_grouping())
|
||||||
{
|
{
|
||||||
throw new \Exception('This is not a story');
|
throw new \Exception('This is not a story');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @var $twig \Twig_Environment */
|
/* @var $twig \Twig_Environment */
|
||||||
$twig = $app['Core']->getTwig();
|
$twig = $app['Core']->getTwig();
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
$twig->render(
|
$twig->render(
|
||||||
'prod/Story/Reorder.html.twig'
|
'prod/Story/Reorder.html.twig'
|
||||||
, array('story' => $story)
|
, array('story' => $story)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
->assert('sbas_id', '\d+')
|
->assert('sbas_id', '\d+')
|
||||||
->assert('record_id', '\d+');
|
->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
$controllers->post(
|
$controllers->post(
|
||||||
'/{sbas_id}/{record_id}/reorder/'
|
'/{sbas_id}/{record_id}/reorder/'
|
||||||
, function(Application $app, $sbas_id, $record_id)
|
, function(Application $app, $sbas_id, $record_id)
|
||||||
{
|
{
|
||||||
$ret = array('success' => false, 'message' => _('An error occured'));
|
$ret = array('success' => false, 'message' => _('An error occured'));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$user = $app['Core']->getAuthenticatedUser();
|
$user = $app['Core']->getAuthenticatedUser();
|
||||||
/* @var $user \User_Adapter */
|
/* @var $user \User_Adapter */
|
||||||
|
|
||||||
$story = new \record_adapter($sbas_id, $record_id);
|
$story = new \record_adapter($sbas_id, $record_id);
|
||||||
|
|
||||||
if (!$story->is_grouping())
|
if (!$story->is_grouping())
|
||||||
{
|
{
|
||||||
throw new \Exception('This is not a story');
|
throw new \Exception('This is not a story');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord'))
|
if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord'))
|
||||||
{
|
{
|
||||||
throw new ControllerException(_('You can not edit this story'));
|
throw new ControllerException(_('You can not edit this story'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE regroup SET ord = :ord
|
$sql = 'UPDATE regroup SET ord = :ord
|
||||||
WHERE rid_parent = :parent_id AND rid_child = :children_id';
|
WHERE rid_parent = :parent_id AND rid_child = :children_id';
|
||||||
$stmt = $story->get_databox()->get_connection()->prepare($sql);
|
$stmt = $story->get_databox()->get_connection()->prepare($sql);
|
||||||
|
|
||||||
foreach ($app['request']->get('element') as $record_id => $ord)
|
foreach ($app['request']->get('element') as $record_id => $ord)
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = array(
|
||||||
':ord' => $ord,
|
':ord' => $ord,
|
||||||
':parent_id' => $story->get_record_id(),
|
':parent_id' => $story->get_record_id(),
|
||||||
':children_id' => $record_id
|
':children_id' => $record_id
|
||||||
);
|
);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$ret = array('success' => true, 'message' => _('Story updated'));
|
$ret = array('success' => true, 'message' => _('Story updated'));
|
||||||
}
|
}
|
||||||
catch (ControllerException $e)
|
catch (ControllerException $e)
|
||||||
{
|
{
|
||||||
$ret = array('success' => false, 'message' => $e->getMessage());
|
$ret = array('success' => false, 'message' => $e->getMessage());
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$Serializer = $app['Core']['Serializer'];
|
$Serializer = $app['Core']['Serializer'];
|
||||||
|
|
||||||
return new Response($Serializer->serialize($ret, 'json'), 200, array('Content-type' => 'application/json'));
|
return new Response($Serializer->serialize($ret, 'json'), 200, array('Content-type' => 'application/json'));
|
||||||
})
|
})
|
||||||
->assert('sbas_id', '\d+')
|
->assert('sbas_id', '\d+')
|
||||||
->assert('record_id', '\d+');
|
->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
|
@@ -286,7 +286,6 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
|
|
||||||
$list->setName($list_name);
|
$list->setName($list_name);
|
||||||
|
|
||||||
$em->merge($list);
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
@@ -459,7 +458,7 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
$list->addUsrListEntry($entry);
|
$list->addUsrListEntry($entry);
|
||||||
|
|
||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
$em->merge($list);
|
|
||||||
$inserted_usr_ids[] = $user_entry->get_id();
|
$inserted_usr_ids[] = $user_entry->get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,14 +584,12 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
$list->addUsrListOwner($owner);
|
$list->addUsrListOwner($owner);
|
||||||
|
|
||||||
$em->persist($owner);
|
$em->persist($owner);
|
||||||
$em->merge($list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$role = $app['request']->get('role');
|
$role = $app['request']->get('role');
|
||||||
|
|
||||||
$owner->setRole($role);
|
$owner->setRole($role);
|
||||||
|
|
||||||
$em->merge($owner);
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
|
@@ -33,293 +33,323 @@ class Installer implements ControllerProviderInterface
|
|||||||
$controllers = new ControllerCollection();
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
$controllers->get('/', function() use ($app)
|
$controllers->get('/', function() use ($app)
|
||||||
{
|
|
||||||
$request = $app['request'];
|
|
||||||
|
|
||||||
$php_constraint = \setup::check_php_version();
|
|
||||||
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
|
||||||
$extension_constraints = \setup::check_php_extension();
|
|
||||||
$opcode_constraints = \setup::check_cache_opcode();
|
|
||||||
$php_conf_constraints = \setup::check_php_configuration();
|
|
||||||
$locales_constraints = \setup::check_system_locales();
|
|
||||||
|
|
||||||
$constraints_coll = array(
|
|
||||||
'php_constraint' => $php_constraint
|
|
||||||
, 'writability_constraints' => $writability_constraints
|
|
||||||
, 'extension_constraints' => $extension_constraints
|
|
||||||
, 'opcode_constraints' => $opcode_constraints
|
|
||||||
, 'php_conf_constraints' => $php_conf_constraints
|
|
||||||
, 'locales_constraints' => $locales_constraints
|
|
||||||
);
|
|
||||||
$redirect = true;
|
|
||||||
|
|
||||||
foreach ($constraints_coll as $key => $constraints)
|
|
||||||
{
|
|
||||||
$unset = true;
|
|
||||||
foreach ($constraints as $constraint)
|
|
||||||
{
|
|
||||||
if (!$constraint->is_ok() && $constraint->is_blocker())
|
|
||||||
$redirect = $unset = false;
|
|
||||||
}
|
|
||||||
if ($unset === true)
|
|
||||||
{
|
|
||||||
unset($constraints_coll[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($redirect)
|
|
||||||
{
|
|
||||||
return $app->redirect('/setup/installer/step2/');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
|
||||||
$loader = new \Twig_Loader_Filesystem($ld_path);
|
|
||||||
$twig = new \Twig_Environment($loader);
|
|
||||||
|
|
||||||
$html = $twig->render(
|
|
||||||
'/setup/index.html.twig'
|
|
||||||
, array_merge($constraints_coll, array(
|
|
||||||
'locale' => \Session_Handler::get_locale()
|
|
||||||
, 'available_locales' => $app['Core']::getAvailableLanguages()
|
|
||||||
, 'version_number' => $app['Core']['Version']->getNumber()
|
|
||||||
, 'version_name' => $app['Core']['Version']->getName()
|
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
|
||||||
))
|
|
||||||
);
|
|
||||||
|
|
||||||
return new Response($html);
|
|
||||||
});
|
|
||||||
|
|
||||||
$controllers->get('/step2/', function() use ($app)
|
|
||||||
{
|
|
||||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
|
||||||
|
|
||||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
|
||||||
$loader = new \Twig_Loader_Filesystem($ld_path);
|
|
||||||
|
|
||||||
$twig = new \Twig_Environment($loader);
|
|
||||||
$twig->addExtension(new \Twig_Extensions_Extension_I18n());
|
|
||||||
|
|
||||||
$request = $app['request'];
|
|
||||||
|
|
||||||
$warnings = array();
|
|
||||||
if ($request->getScheme() == 'http')
|
|
||||||
{
|
|
||||||
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = $twig->render(
|
|
||||||
'/setup/step2.html.twig'
|
|
||||||
, array(
|
|
||||||
'locale' => \Session_Handler::get_locale()
|
|
||||||
, 'available_locales' => $app['Core']::getAvailableLanguages()
|
|
||||||
, 'available_templates' => \appbox::list_databox_templates()
|
|
||||||
, 'version_number' => $app['Core']['Version']->getNumber()
|
|
||||||
, 'version_name' => $app['Core']['Version']->getName()
|
|
||||||
, 'warnings' => $warnings
|
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
|
||||||
, 'discovered_binaries' => \setup::discover_binaries()
|
|
||||||
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new Response($html);
|
|
||||||
});
|
|
||||||
|
|
||||||
$controllers->post('/install/', function() use ($app)
|
|
||||||
{
|
|
||||||
set_time_limit(360);
|
|
||||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
|
||||||
$request = $app['request'];
|
|
||||||
|
|
||||||
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
|
||||||
|
|
||||||
$setupRegistry = new \Setup_Registry();
|
|
||||||
$setupRegistry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
|
||||||
|
|
||||||
$conn = $connbas = null;
|
|
||||||
|
|
||||||
$hostname = $request->get('ab_hostname');
|
|
||||||
$port = $request->get('ab_port');
|
|
||||||
$user_ab = $request->get('ab_user');
|
|
||||||
$password = $request->get('ab_password');
|
|
||||||
|
|
||||||
$appbox_name = $request->get('ab_name');
|
|
||||||
$databox_name = $request->get('db_name');
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name, array(), $setupRegistry);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return $app->redirect('/setup/installer/step2/?error=' . _('Appbox is unreachable'));
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ($databox_name)
|
|
||||||
{
|
|
||||||
$connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name, array(), $setupRegistry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
|
|
||||||
}
|
|
||||||
|
|
||||||
\setup::rollback($conn, $connbas);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$setupRegistry = new \Setup_Registry();
|
|
||||||
$setupRegistry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
|
||||||
|
|
||||||
$appbox = \appbox::create($app['Core'], $setupRegistry, $conn, $appbox_name, true);
|
|
||||||
|
|
||||||
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
|
||||||
|
|
||||||
if ($configuration->isInstalled())
|
|
||||||
{
|
|
||||||
$serviceName = $configuration->getOrm();
|
|
||||||
$confService = $configuration->getService($serviceName);
|
|
||||||
|
|
||||||
$ormService = \Alchemy\Phrasea\Core\Service\Builder::create(
|
|
||||||
$app['Core']
|
|
||||||
, $serviceName
|
|
||||||
, $confService
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($ormService->getType() === 'doctrine')
|
|
||||||
{
|
{
|
||||||
/* @var $em \Doctrine\ORM\EntityManager */
|
$request = $app['request'];
|
||||||
|
|
||||||
$em = $ormService->getDriver();
|
$php_constraint = \setup::check_php_version();
|
||||||
|
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||||
|
$extension_constraints = \setup::check_php_extension();
|
||||||
|
$opcode_constraints = \setup::check_cache_opcode();
|
||||||
|
$php_conf_constraints = \setup::check_php_configuration();
|
||||||
|
$locales_constraints = \setup::check_system_locales();
|
||||||
|
|
||||||
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
$constraints_coll = array(
|
||||||
|
'php_constraint' => $php_constraint
|
||||||
if (!empty($metadatas))
|
, 'writability_constraints' => $writability_constraints
|
||||||
{
|
, 'extension_constraints' => $extension_constraints
|
||||||
// Create SchemaTool
|
, 'opcode_constraints' => $opcode_constraints
|
||||||
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
|
, 'php_conf_constraints' => $php_conf_constraints
|
||||||
// Create schema
|
, 'locales_constraints' => $locales_constraints
|
||||||
$tool->dropSchema($metadatas);
|
|
||||||
$tool->createSchema($metadatas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$registry = \registry::get_instance();
|
|
||||||
\setup::create_global_values($registry);
|
|
||||||
|
|
||||||
$appbox->set_registry($registry);
|
|
||||||
|
|
||||||
$registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->get('datapath_noweb')), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_base_datapath_web', \p4string::addEndSlash($request->get('datapath_web')), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_base_dataurl', \p4string::addEndSlash($request->get('mount_point_web')), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_cli', $request->get('binary_php'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_imagick', $request->get('binary_convert'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_pathcomposite', $request->get('binary_composite'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_exiftool', $request->get('binary_exiftool'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_swf_extract', $request->get('binary_swfextract'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_pdf2swf', $request->get('binary_pdf2swf'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_swf_render', $request->get('binary_swfrender'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_unoconv', $request->get('binary_unoconv'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_ffmpeg', $request->get('binary_ffmpeg'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_mp4box', $request->get('binary_MP4Box'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_mplayer', $request->get('binary_mplayer'), \registry::TYPE_STRING);
|
|
||||||
$registry->set('GV_pdftotext', $request->get('binary_xpdf'), \registry::TYPE_STRING);
|
|
||||||
|
|
||||||
$user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);
|
|
||||||
|
|
||||||
if (!\p4string::hasAccent($databox_name))
|
|
||||||
{
|
|
||||||
if ($databox_name)
|
|
||||||
{
|
|
||||||
$template = new \system_file(__DIR__ . '/../../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
|
||||||
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
|
||||||
$user->ACL()
|
|
||||||
->give_access_to_sbas(array($databox->get_sbas_id()))
|
|
||||||
->update_rights_to_sbas(
|
|
||||||
$databox->get_sbas_id(), array(
|
|
||||||
'bas_manage' => 1, 'bas_modify_struct' => 1,
|
|
||||||
'bas_modif_th' => 1, 'bas_chupub' => 1
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
$redirect = true;
|
||||||
|
|
||||||
$a = \collection::create($databox, $appbox, 'test', $user);
|
foreach ($constraints_coll as $key => $constraints)
|
||||||
|
|
||||||
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
|
||||||
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
|
||||||
'canpush' => 1, 'cancmd' => 1
|
|
||||||
, 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1
|
|
||||||
, 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1
|
|
||||||
, 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1
|
|
||||||
, 'modify_struct' => 1, 'nowatermark' => 1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$tasks = $request->get('create_task', array());
|
|
||||||
foreach ($tasks as $task)
|
|
||||||
{
|
{
|
||||||
switch ($task)
|
$unset = true;
|
||||||
|
foreach ($constraints as $constraint)
|
||||||
{
|
{
|
||||||
case 'cindexer';
|
if (!$constraint->is_ok() && $constraint->is_blocker())
|
||||||
case 'subdef';
|
$redirect = $unset = false;
|
||||||
case 'writemeta';
|
}
|
||||||
$class_name = sprintf('task_period_%s', $task);
|
if ($unset === true)
|
||||||
if ($task === 'cindexer')
|
{
|
||||||
{
|
unset($constraints_coll[$key]);
|
||||||
$credentials = $databox->get_connection()->get_credentials();
|
|
||||||
|
|
||||||
$host = $credentials['hostname'];
|
|
||||||
$port = $credentials['port'];
|
|
||||||
$user_ab = $credentials['user'];
|
|
||||||
$password = $credentials['password'];
|
|
||||||
|
|
||||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<binpath>"
|
|
||||||
. str_replace('/phraseanet_indexer', '', $request->get('binary_phraseanet_indexer'))
|
|
||||||
. "</binpath><host>" . $host . "</host><port>"
|
|
||||||
. $port . "</port><base>"
|
|
||||||
. $appbox_name . "</base><user>"
|
|
||||||
. $user_ab . "</user><password>"
|
|
||||||
. $password . "</password><socket>25200</socket>"
|
|
||||||
. "<use_sbas>1</use_sbas><nolog>0</nolog><clng></clng>"
|
|
||||||
. "<winsvc_run>0</winsvc_run><charset>utf8</charset></tasksettings>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$settings = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
\task_abstract::create($appbox, $class_name, $settings);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
\phrasea::start($app['Core']);
|
if ($redirect)
|
||||||
|
{
|
||||||
|
return $app->redirect('/setup/installer/step2/');
|
||||||
|
}
|
||||||
|
|
||||||
$auth = new \Session_Authentication_None($user);
|
|
||||||
|
|
||||||
$appbox->get_session()->authenticate($auth);
|
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
||||||
|
$loader = new \Twig_Loader_Filesystem($ld_path);
|
||||||
|
$twig = new \Twig_Environment($loader);
|
||||||
|
|
||||||
$redirection = '/admin/?section=taskmanager¬ice=install_success';
|
$html = $twig->render(
|
||||||
|
'/setup/index.html.twig'
|
||||||
|
, array_merge($constraints_coll, array(
|
||||||
|
'locale' => \Session_Handler::get_locale()
|
||||||
|
, 'available_locales' => $app['Core']::getAvailableLanguages()
|
||||||
|
, 'version_number' => $app['Core']['Version']->getNumber()
|
||||||
|
, 'version_name' => $app['Core']['Version']->getName()
|
||||||
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
return $app->redirect($redirection);
|
return new Response($html);
|
||||||
}
|
});
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
\setup::rollback($conn, $connbas);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));
|
$controllers->get('/step2/', function() use ($app)
|
||||||
});
|
{
|
||||||
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
|
||||||
|
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
||||||
|
$loader = new \Twig_Loader_Filesystem($ld_path);
|
||||||
|
|
||||||
|
$twig = new \Twig_Environment($loader);
|
||||||
|
$twig->addExtension(new \Twig_Extensions_Extension_I18n());
|
||||||
|
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$warnings = array();
|
||||||
|
|
||||||
|
$php_constraint = \setup::check_php_version();
|
||||||
|
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||||
|
$extension_constraints = \setup::check_php_extension();
|
||||||
|
$opcode_constraints = \setup::check_cache_opcode();
|
||||||
|
$php_conf_constraints = \setup::check_php_configuration();
|
||||||
|
$locales_constraints = \setup::check_system_locales();
|
||||||
|
|
||||||
|
$constraints_coll = array(
|
||||||
|
'php_constraint' => $php_constraint
|
||||||
|
, 'writability_constraints' => $writability_constraints
|
||||||
|
, 'extension_constraints' => $extension_constraints
|
||||||
|
, 'opcode_constraints' => $opcode_constraints
|
||||||
|
, 'php_conf_constraints' => $php_conf_constraints
|
||||||
|
, 'locales_constraints' => $locales_constraints
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($constraints_coll as $key => $constraints)
|
||||||
|
{
|
||||||
|
$unset = true;
|
||||||
|
foreach ($constraints as $constraint)
|
||||||
|
{
|
||||||
|
if (!$constraint->is_ok() && !$constraint->is_blocker())
|
||||||
|
{
|
||||||
|
$warnings[] = $constraint->get_message();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->getScheme() == 'http')
|
||||||
|
{
|
||||||
|
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = $twig->render(
|
||||||
|
'/setup/step2.html.twig'
|
||||||
|
, array(
|
||||||
|
'locale' => \Session_Handler::get_locale()
|
||||||
|
, 'available_locales' => $app['Core']::getAvailableLanguages()
|
||||||
|
, 'available_templates' => \appbox::list_databox_templates()
|
||||||
|
, 'version_number' => $app['Core']['Version']->getNumber()
|
||||||
|
, 'version_name' => $app['Core']['Version']->getName()
|
||||||
|
, 'warnings' => $warnings
|
||||||
|
, 'error' => $request->get('error')
|
||||||
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
|
, 'discovered_binaries' => \setup::discover_binaries()
|
||||||
|
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Response($html);
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->post('/install/', function() use ($app)
|
||||||
|
{
|
||||||
|
set_time_limit(360);
|
||||||
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
$request = $app['request'];
|
||||||
|
|
||||||
|
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
||||||
|
|
||||||
|
$setupRegistry = new \Setup_Registry();
|
||||||
|
$setupRegistry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
||||||
|
|
||||||
|
$conn = $connbas = null;
|
||||||
|
|
||||||
|
$hostname = $request->get('ab_hostname');
|
||||||
|
$port = $request->get('ab_port');
|
||||||
|
$user_ab = $request->get('ab_user');
|
||||||
|
$password = $request->get('ab_password');
|
||||||
|
|
||||||
|
$appbox_name = $request->get('ab_name');
|
||||||
|
$databox_name = $request->get('db_name');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name, array(), $setupRegistry);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return $app->redirect('/setup/installer/step2/?error=' . _('Appbox is unreachable'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ($databox_name)
|
||||||
|
{
|
||||||
|
$connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name, array(), $setupRegistry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
|
||||||
|
}
|
||||||
|
|
||||||
|
\setup::rollback($conn, $connbas);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$setupRegistry = new \Setup_Registry();
|
||||||
|
$setupRegistry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
||||||
|
|
||||||
|
$appbox = \appbox::create($app['Core'], $setupRegistry, $conn, $appbox_name, true);
|
||||||
|
|
||||||
|
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
||||||
|
|
||||||
|
if ($configuration->isInstalled())
|
||||||
|
{
|
||||||
|
$serviceName = $configuration->getOrm();
|
||||||
|
$confService = $configuration->getService($serviceName);
|
||||||
|
|
||||||
|
$ormService = \Alchemy\Phrasea\Core\Service\Builder::create(
|
||||||
|
$app['Core']
|
||||||
|
, $serviceName
|
||||||
|
, $confService
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($ormService->getType() === 'doctrine')
|
||||||
|
{
|
||||||
|
/* @var $em \Doctrine\ORM\EntityManager */
|
||||||
|
|
||||||
|
$em = $ormService->getDriver();
|
||||||
|
|
||||||
|
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
||||||
|
|
||||||
|
if (!empty($metadatas))
|
||||||
|
{
|
||||||
|
// Create SchemaTool
|
||||||
|
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
|
||||||
|
// Create schema
|
||||||
|
$tool->dropSchema($metadatas);
|
||||||
|
$tool->createSchema($metadatas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$registry = \registry::get_instance();
|
||||||
|
\setup::create_global_values($registry);
|
||||||
|
|
||||||
|
$appbox->set_registry($registry);
|
||||||
|
|
||||||
|
$registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->get('datapath_noweb')), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_base_datapath_web', \p4string::addEndSlash($request->get('datapath_web')), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_base_dataurl', \p4string::addEndSlash($request->get('mount_point_web')), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_cli', $request->get('binary_php'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_imagick', $request->get('binary_convert'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_pathcomposite', $request->get('binary_composite'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_exiftool', $request->get('binary_exiftool'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_swf_extract', $request->get('binary_swfextract'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_pdf2swf', $request->get('binary_pdf2swf'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_swf_render', $request->get('binary_swfrender'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_unoconv', $request->get('binary_unoconv'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_ffmpeg', $request->get('binary_ffmpeg'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_mp4box', $request->get('binary_MP4Box'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_mplayer', $request->get('binary_mplayer'), \registry::TYPE_STRING);
|
||||||
|
$registry->set('GV_pdftotext', $request->get('binary_xpdf'), \registry::TYPE_STRING);
|
||||||
|
|
||||||
|
$user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);
|
||||||
|
|
||||||
|
if (!\p4string::hasAccent($databox_name))
|
||||||
|
{
|
||||||
|
if ($databox_name)
|
||||||
|
{
|
||||||
|
$template = new \system_file(__DIR__ . '/../../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
||||||
|
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
||||||
|
$user->ACL()
|
||||||
|
->give_access_to_sbas(array($databox->get_sbas_id()))
|
||||||
|
->update_rights_to_sbas(
|
||||||
|
$databox->get_sbas_id(), array(
|
||||||
|
'bas_manage' => 1, 'bas_modify_struct' => 1,
|
||||||
|
'bas_modif_th' => 1, 'bas_chupub' => 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$a = \collection::create($databox, $appbox, 'test', $user);
|
||||||
|
|
||||||
|
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
||||||
|
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
||||||
|
'canpush' => 1, 'cancmd' => 1
|
||||||
|
, 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1
|
||||||
|
, 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1
|
||||||
|
, 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1
|
||||||
|
, 'modify_struct' => 1, 'nowatermark' => 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$tasks = $request->get('create_task', array());
|
||||||
|
foreach ($tasks as $task)
|
||||||
|
{
|
||||||
|
switch ($task)
|
||||||
|
{
|
||||||
|
case 'cindexer';
|
||||||
|
case 'subdef';
|
||||||
|
case 'writemeta';
|
||||||
|
$class_name = sprintf('task_period_%s', $task);
|
||||||
|
if ($task === 'cindexer')
|
||||||
|
{
|
||||||
|
$credentials = $databox->get_connection()->get_credentials();
|
||||||
|
|
||||||
|
$host = $credentials['hostname'];
|
||||||
|
$port = $credentials['port'];
|
||||||
|
$user_ab = $credentials['user'];
|
||||||
|
$password = $credentials['password'];
|
||||||
|
|
||||||
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<binpath>"
|
||||||
|
. str_replace('/phraseanet_indexer', '', $request->get('binary_phraseanet_indexer'))
|
||||||
|
. "</binpath><host>" . $host . "</host><port>"
|
||||||
|
. $port . "</port><base>"
|
||||||
|
. $appbox_name . "</base><user>"
|
||||||
|
. $user_ab . "</user><password>"
|
||||||
|
. $password . "</password><socket>25200</socket>"
|
||||||
|
. "<use_sbas>1</use_sbas><nolog>0</nolog><clng></clng>"
|
||||||
|
. "<winsvc_run>0</winsvc_run><charset>utf8</charset></tasksettings>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$settings = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
\task_abstract::create($appbox, $class_name, $settings);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
\phrasea::start($app['Core']);
|
||||||
|
|
||||||
|
$auth = new \Session_Authentication_None($user);
|
||||||
|
|
||||||
|
$appbox->get_session()->authenticate($auth);
|
||||||
|
|
||||||
|
$redirection = '/admin/?section=taskmanager¬ice=install_success';
|
||||||
|
|
||||||
|
return $app->redirect($redirection);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
\setup::rollback($conn, $connbas);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage()));
|
||||||
|
});
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -275,7 +275,12 @@ class Core extends \Pimple
|
|||||||
$appbox = \appbox::get_instance($this);
|
$appbox = \appbox::get_instance($this);
|
||||||
$session = \Session_Handler::getInstance($appbox);
|
$session = \Session_Handler::getInstance($appbox);
|
||||||
|
|
||||||
return \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
if($session->get_usr_id())
|
||||||
|
{
|
||||||
|
return \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core,
|
|||||||
class ApcCache extends ServiceAbstract implements ServiceInterface
|
class ApcCache extends ServiceAbstract implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
public function getScope()
|
public function getScope()
|
||||||
{
|
{
|
||||||
return 'cache';
|
return 'cache';
|
||||||
@@ -38,11 +40,14 @@ class ApcCache extends ServiceAbstract implements ServiceInterface
|
|||||||
throw new \Exception('The APC cache requires the APC extension.');
|
throw new \Exception('The APC cache requires the APC extension.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$service = new CacheDriver\ApcCache();
|
if (!$this->cache)
|
||||||
|
{
|
||||||
|
$this->cache = new CacheDriver\ApcCache();
|
||||||
|
|
||||||
$service->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||||
|
}
|
||||||
|
|
||||||
return $service;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
|
@@ -27,6 +27,8 @@ use Alchemy\Phrasea\Core,
|
|||||||
class ArrayCache extends ServiceAbstract implements ServiceInterface
|
class ArrayCache extends ServiceAbstract implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
public function getScope()
|
public function getScope()
|
||||||
{
|
{
|
||||||
return 'cache';
|
return 'cache';
|
||||||
@@ -34,11 +36,14 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface
|
|||||||
|
|
||||||
public function getDriver()
|
public function getDriver()
|
||||||
{
|
{
|
||||||
$service = new CacheDriver\ArrayCache();
|
if (!$this->cache)
|
||||||
|
{
|
||||||
|
$this->cache = new CacheDriver\ArrayCache();
|
||||||
|
|
||||||
$service->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||||
|
}
|
||||||
|
|
||||||
return $service;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
|
@@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core,
|
|||||||
class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
const DEFAULT_HOST = "localhost";
|
const DEFAULT_HOST = "localhost";
|
||||||
const DEFAULT_PORT = "11211";
|
const DEFAULT_PORT = "11211";
|
||||||
|
|
||||||
@@ -53,27 +55,30 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
|||||||
throw new \Exception('The Memcache cache requires the Memcache extension.');
|
throw new \Exception('The Memcache cache requires the Memcache extension.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$memcache = new \Memcache();
|
if(!$this->cache)
|
||||||
|
|
||||||
$memcache->addServer($this->host, $this->port);
|
|
||||||
|
|
||||||
$key = sprintf("%s:%s", $this->host, $this->port);
|
|
||||||
|
|
||||||
$stats = @$memcache->getExtendedStats();
|
|
||||||
|
|
||||||
if (isset($stats[$key]))
|
|
||||||
{
|
{
|
||||||
$service = new CacheDriver\MemcacheCache();
|
$memcache = new \Memcache();
|
||||||
$service->setMemcache($memcache);
|
|
||||||
}
|
$memcache->addServer($this->host, $this->port);
|
||||||
else
|
|
||||||
{
|
$key = sprintf("%s:%s", $this->host, $this->port);
|
||||||
throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
|
||||||
|
$stats = @$memcache->getExtendedStats();
|
||||||
|
|
||||||
|
if (isset($stats[$key]))
|
||||||
|
{
|
||||||
|
$this->cache = new CacheDriver\MemcacheCache();
|
||||||
|
$this->cache->setMemcache($memcache);
|
||||||
|
|
||||||
|
$this->cache->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$service->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
return $this->cache;
|
||||||
|
|
||||||
return $service;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
|
@@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core,
|
|||||||
class RedisCache extends ServiceAbstract implements ServiceInterface
|
class RedisCache extends ServiceAbstract implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
const DEFAULT_HOST = "localhost";
|
const DEFAULT_HOST = "localhost";
|
||||||
const DEFAULT_PORT = "6379";
|
const DEFAULT_PORT = "6379";
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ class RedisCache extends ServiceAbstract implements ServiceInterface
|
|||||||
|
|
||||||
public function __construct(Core $core, $name, Array $options)
|
public function __construct(Core $core, $name, Array $options)
|
||||||
{
|
{
|
||||||
parent::__construct( $core, $name, $options);
|
parent::__construct($core, $name, $options);
|
||||||
|
|
||||||
$this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST;
|
$this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST;
|
||||||
|
|
||||||
@@ -57,26 +59,30 @@ class RedisCache extends ServiceAbstract implements ServiceInterface
|
|||||||
throw new \Exception('The Redis cache requires the Redis extension.');
|
throw new \Exception('The Redis cache requires the Redis extension.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$redis = new \Redis();
|
|
||||||
|
|
||||||
if (!$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY))
|
if (!$this->cache)
|
||||||
{
|
{
|
||||||
$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
|
$redis = new \Redis();
|
||||||
|
|
||||||
|
if (!$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY))
|
||||||
|
{
|
||||||
|
$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($redis->connect($this->host, $this->port))
|
||||||
|
{
|
||||||
|
$this->cache = new CacheDriver\RedisCache();
|
||||||
|
$this->cache->setRedis($redis);
|
||||||
|
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($redis->connect($this->host, $this->port))
|
return $this->cache;
|
||||||
{
|
|
||||||
$service = new CacheDriver\RedisCache();
|
|
||||||
$service->setRedis($redis);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
|
||||||
}
|
|
||||||
|
|
||||||
$service->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
|
||||||
|
|
||||||
return $service;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
|
@@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core,
|
|||||||
class XcacheCache extends ServiceAbstract implements ServiceInterface
|
class XcacheCache extends ServiceAbstract implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
public function getScope()
|
public function getScope()
|
||||||
{
|
{
|
||||||
return 'cache';
|
return 'cache';
|
||||||
@@ -38,11 +40,14 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
|
|||||||
throw new \Exception('The XCache cache requires the XCache extension.');
|
throw new \Exception('The XCache cache requires the XCache extension.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$service = new CacheDriver\XcacheCache();
|
if (!$this->cache)
|
||||||
|
{
|
||||||
|
$this->cache = new CacheDriver\XcacheCache();
|
||||||
|
|
||||||
$service->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||||
|
}
|
||||||
|
|
||||||
return $service;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
@@ -55,5 +60,4 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
63
lib/Alchemy/Phrasea/Core/Service/Log/FirePHP.php
Normal file
63
lib/Alchemy/Phrasea/Core/Service/Log/FirePHP.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2012 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Core\Service\Log;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core,
|
||||||
|
Alchemy\Phrasea\Core\Service,
|
||||||
|
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||||
|
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||||
|
use Monolog\Logger;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Handler\FirePHPHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class FirePHP extends ServiceAbstract implements ServiceInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
public function __construct(\Alchemy\Phrasea\Core $core, $name, Array $options)
|
||||||
|
{
|
||||||
|
parent::__construct($core, $name, $options);
|
||||||
|
|
||||||
|
$this->logger = new Logger('FirePHP');
|
||||||
|
|
||||||
|
$this->logger->pushHandler(new FirePHPHandler());
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDriver()
|
||||||
|
{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return 'FirePHP Monolog';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getScope()
|
||||||
|
{
|
||||||
|
return 'log';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMandatoryOptions()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -66,7 +66,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
|||||||
, $handler
|
, $handler
|
||||||
, $this->name
|
, $this->name
|
||||||
, $this->getScope()
|
, $this->getScope()
|
||||||
, implode(", ", $this->handler)
|
, implode(", ", $this->handlers)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,6 @@ use Alchemy\Phrasea\Core,
|
|||||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
use Events\Listener\Cache\Action\Clear as ClearCacheListener;
|
|
||||||
use Doctrine\ORM\Events as DoctrineEvents;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -54,33 +52,33 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
|||||||
$config->setSQLLogger($this->getLog($logServiceName));
|
$config->setSQLLogger($this->getLog($logServiceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//get cache
|
|
||||||
$cache = isset($options["cache"]) ? $options["cache"] : false;
|
$cache = isset($options["cache"]) ? $options["cache"] : false;
|
||||||
|
|
||||||
if (!$cache || $this->debug)
|
if (!$cache || $this->debug)
|
||||||
{
|
{
|
||||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache');
|
$metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache');
|
||||||
$queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache');
|
$queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache');
|
||||||
$resultCache = $this->core['CacheService']->get('ORMresult', 'Cache\\ArrayCache');
|
// $resultCache = $this->core['CacheService']->get('ORMresult', 'Cache\\ArrayCache');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache';
|
$query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache';
|
||||||
$meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache';
|
$meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache';
|
||||||
$results = isset($cache["result"]['service']) ? $cache["result"]['service'] : 'Cache\\ArrayCache';
|
// $results = isset($cache["result"]['service']) ? $cache["result"]['service'] : 'Cache\\ArrayCache';
|
||||||
|
|
||||||
$queryCache = $this->core['CacheService']->get('ORMquery', $query);
|
$queryCache = $this->core['CacheService']->get('ORMquery', $query);
|
||||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', $meta);
|
$metaCache = $this->core['CacheService']->get('ORMmetadata', $meta);
|
||||||
$resultCache = $this->core['CacheService']->get('ORMresult', $results);
|
// $resultCache = $this->core['CacheService']->get('ORMresult', 'Cache\\ArrayCache');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$resultCache = $this->core['CacheService']->get('ORMresult', 'Cache\\ArrayCache');
|
||||||
|
|
||||||
$config->setMetadataCacheImpl($metaCache->getDriver());
|
$config->setMetadataCacheImpl($metaCache->getDriver());
|
||||||
|
|
||||||
$config->setQueryCacheImpl($queryCache->getDriver());
|
$config->setQueryCacheImpl($queryCache->getDriver());
|
||||||
|
|
||||||
$config->setResultCacheImpl($resultCache->getDriver());
|
$config->setResultCacheImpl($resultCache->getDriver());
|
||||||
|
|
||||||
|
|
||||||
//define autoregeneration of proxies base on debug mode
|
//define autoregeneration of proxies base on debug mode
|
||||||
$config->setAutoGenerateProxyClasses($this->debug);
|
$config->setAutoGenerateProxyClasses($this->debug);
|
||||||
|
|
||||||
@@ -124,11 +122,6 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
|||||||
|
|
||||||
$evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
|
$evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
|
||||||
|
|
||||||
$evm->addEventListener(DoctrineEvents::postUpdate, new ClearCacheListener());
|
|
||||||
$evm->addEventListener(DoctrineEvents::postRemove, new ClearCacheListener());
|
|
||||||
$evm->addEventListener(DoctrineEvents::postPersist, new ClearCacheListener());
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->entityManager = \Doctrine\ORM\EntityManager::create($dbalConf, $config, $evm);
|
$this->entityManager = \Doctrine\ORM\EntityManager::create($dbalConf, $config, $evm);
|
||||||
|
@@ -32,10 +32,13 @@ class Prod extends Helper
|
|||||||
);
|
);
|
||||||
|
|
||||||
$bases = $fields = $dates = array();
|
$bases = $fields = $dates = array();
|
||||||
$appbox = \appbox::get_instance($this->core);
|
|
||||||
$session = $appbox->get_session();
|
|
||||||
$user = $this->getCore()->getAuthenticatedUser();
|
$user = $this->getCore()->getAuthenticatedUser();
|
||||||
|
|
||||||
|
if(!$user instanceof \User_Adapter)
|
||||||
|
{
|
||||||
|
return $search_datas;
|
||||||
|
}
|
||||||
|
|
||||||
$searchSet = $user->getPrefs('search');
|
$searchSet = $user->getPrefs('search');
|
||||||
|
|
||||||
foreach ($user->ACL()->get_granted_sbas() as $databox)
|
foreach ($user->ACL()->get_granted_sbas() as $databox)
|
||||||
|
@@ -422,27 +422,6 @@ class Edit extends RecordHelper
|
|||||||
{
|
{
|
||||||
$i = count($this->javascript_fields);
|
$i = count($this->javascript_fields);
|
||||||
|
|
||||||
switch ($meta->get_type())
|
|
||||||
{
|
|
||||||
case 'datetime':
|
|
||||||
$format = _('phraseanet::technique::datetime-edit-format');
|
|
||||||
$explain = _('phraseanet::technique::datetime-edit-explain');
|
|
||||||
break;
|
|
||||||
case 'date':
|
|
||||||
$format = _('phraseanet::technique::date-edit-format');
|
|
||||||
$explain = _('phraseanet::technique::date-edit-explain');
|
|
||||||
break;
|
|
||||||
case 'time':
|
|
||||||
$format = _('phraseanet::technique::time-edit-format');
|
|
||||||
$explain = _('phraseanet::technique::time-edit-explain');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$format = $explain = "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$regfield = ($meta->is_regname() || $meta->is_regdesc() || $meta->is_regdate());
|
|
||||||
|
|
||||||
$source = $meta->get_source();
|
$source = $meta->get_source();
|
||||||
$separator = $meta->get_separator();
|
$separator = $meta->get_separator();
|
||||||
|
|
||||||
@@ -455,12 +434,11 @@ class Edit extends RecordHelper
|
|||||||
, 'required' => $meta->is_required()
|
, 'required' => $meta->is_required()
|
||||||
, 'readonly' => $meta->is_readonly()
|
, 'readonly' => $meta->is_readonly()
|
||||||
, 'type' => $meta->get_type()
|
, 'type' => $meta->get_type()
|
||||||
, 'format' => $format
|
, 'format' => ''
|
||||||
, 'explain' => $explain
|
, 'explain' => ''
|
||||||
, 'tbranch' => $meta->get_tbranch()
|
, 'tbranch' => $meta->get_tbranch()
|
||||||
, 'maxLength' => $source ? $source->maxlength() : 0
|
, 'maxLength' => $source ? $source->maxlength() : 0
|
||||||
, 'minLength' => $source ? $source->minLength() : 0
|
, 'minLength' => $source ? $source->minLength() : 0
|
||||||
, 'regfield' => $regfield
|
|
||||||
, 'multi' => $meta->is_multi()
|
, 'multi' => $meta->is_multi()
|
||||||
, 'separator' => $separator
|
, 'separator' => $separator
|
||||||
, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null
|
, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null
|
||||||
@@ -615,55 +593,6 @@ class Edit extends RecordHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
// foreach ($trecchanges as $fname => $fchange)
|
|
||||||
// {
|
|
||||||
// $bool = false;
|
|
||||||
// if ($regfields && $parm['act_option'] == 'SAVEGRP'
|
|
||||||
// && $fname == $regfields['regname'])
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// $basket = basket_adapter::getInstance($parm['ssel']);
|
|
||||||
// $basket->name = implode(' ', $fchange['values']);
|
|
||||||
// $basket->save();
|
|
||||||
// $bool = true;
|
|
||||||
// }
|
|
||||||
// catch (Exception $e)
|
|
||||||
// {
|
|
||||||
// echo $e->getMessage();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if ($regfields && $parm['act_option'] == 'SAVEGRP'
|
|
||||||
// && $fname == $regfields['regdesc'])
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// $basket = basket_adapter::getInstance($parm['ssel']);
|
|
||||||
// $basket->desc = implode(' ', $fchange['values']);
|
|
||||||
// $basket->save();
|
|
||||||
// $bool = true;
|
|
||||||
// }
|
|
||||||
// catch (Exception $e)
|
|
||||||
// {
|
|
||||||
// echo $e->getMessage();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if ($bool)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// $basket = basket_adapter::getInstance($parm['ssel']);
|
|
||||||
// $basket->delete_cache();
|
|
||||||
// }
|
|
||||||
// catch (Exception $e)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -131,10 +131,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
|||||||
sum(remain_dwnld) as remain_dwnld,
|
sum(remain_dwnld) as remain_dwnld,
|
||||||
sum(month_dwnld_max) as month_dwnld_max,
|
sum(month_dwnld_max) as month_dwnld_max,
|
||||||
|
|
||||||
mask_xor as maskxordec,
|
sum(mask_and + mask_xor) as masks
|
||||||
bin(mask_xor) as maskxorbin,
|
|
||||||
mask_and as maskanddec,
|
|
||||||
bin(mask_and) as maskandbin
|
|
||||||
|
|
||||||
FROM (usr u, bas b, sbas s)
|
FROM (usr u, bas b, sbas s)
|
||||||
LEFT JOIN (basusr bu)
|
LEFT JOIN (basusr bu)
|
||||||
@@ -206,8 +203,6 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
|||||||
{
|
{
|
||||||
$this->base_id = (int) $this->request->get('base_id');
|
$this->base_id = (int) $this->request->get('base_id');
|
||||||
|
|
||||||
// $this->base_id = (int) $parm['base_id'];
|
|
||||||
|
|
||||||
$sql = "SELECT u.usr_id, restrict_dwnld, remain_dwnld, month_dwnld_max
|
$sql = "SELECT u.usr_id, restrict_dwnld, remain_dwnld, month_dwnld_max
|
||||||
FROM (usr u INNER JOIN basusr bu ON u.usr_id = bu.usr_id)
|
FROM (usr u INNER JOIN basusr bu ON u.usr_id = bu.usr_id)
|
||||||
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
||||||
|
@@ -184,8 +184,10 @@ class PDF
|
|||||||
$fimg = $subdef->get_pathfile();
|
$fimg = $subdef->get_pathfile();
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
||||||
&& $subdef->get_type() == media_subdef::TYPE_IMAGE)
|
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE)
|
||||||
$fimg = recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
{
|
||||||
|
$fimg = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
||||||
|
}
|
||||||
|
|
||||||
$wimg = $himg = $ImgSize;
|
$wimg = $himg = $ImgSize;
|
||||||
if ($subdef->get_height() > 0 && $subdef->get_width() > 0)
|
if ($subdef->get_height() > 0 && $subdef->get_width() > 0)
|
||||||
@@ -479,8 +481,8 @@ class PDF
|
|||||||
$f = $subdef->get_pathfile();
|
$f = $subdef->get_pathfile();
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
||||||
&& $subdef->get_type() == media_subdef::TYPE_IMAGE)
|
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE)
|
||||||
$f = recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
$f = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
||||||
|
|
||||||
$wimg = $himg = 150; // preview dans un carre de 150 mm
|
$wimg = $himg = 150; // preview dans un carre de 150 mm
|
||||||
if ($subdef->get_width() > 0 && $subdef->get_height() > 0)
|
if ($subdef->get_width() > 0 && $subdef->get_height() > 0)
|
||||||
|
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Listener\Cache\Action;
|
|
||||||
|
|
||||||
use Entities;
|
|
||||||
use Doctrine\ORM\Event\LifecycleEventArgs, Doctrine\Common\Cache\Cache;
|
|
||||||
use Events\Processor\Factory, Events\Processor\Factory\Exception as ProcessorNotFound;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear event used to delete entries in cache
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
class Clear
|
|
||||||
{
|
|
||||||
|
|
||||||
public function postUpdate(LifecycleEventArgs $eventArgs)
|
|
||||||
{
|
|
||||||
$this->clear($eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postRemove(LifecycleEventArgs $eventArgs)
|
|
||||||
{
|
|
||||||
$this->clear($eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postPersist(LifecycleEventArgs $eventArgs)
|
|
||||||
{
|
|
||||||
$this->clear($eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function clear(LifecycleEventArgs $eventArgs)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//get proper cache action processor for the processed entity
|
|
||||||
$factory = new Factory\CacheAction(get_class($eventArgs->getEntity()));
|
|
||||||
$factory->getProcessor()->process($eventArgs);
|
|
||||||
}
|
|
||||||
catch (ProcessorNotFound $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Processor\Cache\Action;
|
|
||||||
|
|
||||||
use Doctrine\Common\Cache;
|
|
||||||
use Events\Processor\Processor;
|
|
||||||
use Doctrine\Common\EventArgs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
abstract class AbstractClear implements Processor
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the current used result cache adapter
|
|
||||||
* @param EventArgs $args
|
|
||||||
* @return \Doctrine\Common\Cache
|
|
||||||
*/
|
|
||||||
protected function getCacheAdapter(EventArgs $args)
|
|
||||||
{
|
|
||||||
$em = $args->getEntityManager();
|
|
||||||
|
|
||||||
return $em->getConfiguration()->getResultCacheImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the processed entity cache suffix
|
|
||||||
* @param EventArgs $args
|
|
||||||
* @return string
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
protected function getEntityCacheSuffix(EventArgs $args)
|
|
||||||
{
|
|
||||||
$entity = new \ReflectionClass(get_class($args->getEntity()));
|
|
||||||
|
|
||||||
if (!$entity->hasConstant("CACHE_SUFFIX"))
|
|
||||||
{
|
|
||||||
throw new \Exception(sprintf("Missing cache suffix for %s entity", $entity->getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $entity->getConstant("CACHE_SUFFIX");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Processor\Cache\Action\Clear;
|
|
||||||
|
|
||||||
use Doctrine\Common\EventArgs;
|
|
||||||
use Events\Processor\Cache\Action\AbstractClear;
|
|
||||||
use Repositories\BasketRepository;
|
|
||||||
use Entities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
class Basket extends AbstractClear
|
|
||||||
{
|
|
||||||
|
|
||||||
public function process(EventArgs $args)
|
|
||||||
{
|
|
||||||
$cache = $this->getCacheAdapter($args);
|
|
||||||
$cache->deleteBySuffix(Entities\Basket::CACHE_SUFFIX);
|
|
||||||
$cache->deleteBySuffix(Entities\BasketElement::CACHE_SUFFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Processor\Cache\Action\Clear;
|
|
||||||
|
|
||||||
use Doctrine\Common\EventArgs;
|
|
||||||
use Events\Processor\Cache\Action\AbstractClear;
|
|
||||||
use Entities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
class BasketElement extends AbstractClear
|
|
||||||
{
|
|
||||||
|
|
||||||
public function process(EventArgs $args)
|
|
||||||
{
|
|
||||||
$cache = $this->getCacheAdapter($args);
|
|
||||||
$cache->deleteBySuffix(Entities\Basket::CACHE_SUFFIX);
|
|
||||||
$cache->deleteBySuffix(Entities\BasketElement::CACHE_SUFFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Processor\Factory;
|
|
||||||
|
|
||||||
use Doctrine\Common\ClassLoader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
class CacheAction extends FactoryAbstract
|
|
||||||
{
|
|
||||||
public static function create($processor)
|
|
||||||
{
|
|
||||||
$entity = ucfirst(array_pop(explode("\\", $processor)));
|
|
||||||
$className = sprintf("Events\Processor\Cache\Action\Clear\%s", $entity);
|
|
||||||
|
|
||||||
if(!class_exists($className))
|
|
||||||
{
|
|
||||||
throw new Exception(sprintf("Unknow processor %s", $processor));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new $className();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Processor\Factory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
abstract class FactoryAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Events\Processor\Processor
|
|
||||||
*/
|
|
||||||
private $processor;
|
|
||||||
|
|
||||||
public function __construct($processor)
|
|
||||||
{
|
|
||||||
$this->processor = static::create($processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Events\Processor\Processor
|
|
||||||
*/
|
|
||||||
public function getProcessor()
|
|
||||||
{
|
|
||||||
return $this->processor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static function which create the proper processor
|
|
||||||
* @param type $element
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
abstract public static function create($processor);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Events\Processor;
|
|
||||||
|
|
||||||
use Doctrine\Common\EventArgs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
interface Processor
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The executed process for clearing cache
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(EventArgs $args);
|
|
||||||
}
|
|
@@ -35,8 +35,8 @@ class BasketElementRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
$cacheId = "_user_basket_element_" . $element_id . "_" . $user->get_id() . Entities\BasketElement::CACHE_SUFFIX;
|
// $cacheId = "_user_basket_element_" . $element_id . "_" . $user->get_id() . Entities\BasketElement::CACHE_SUFFIX;
|
||||||
$query->useResultCache(true, 1800, $cacheId);
|
// $query->useResultCache(true, 1800, $cacheId);
|
||||||
|
|
||||||
$element = $query->getOneOrNullResult();
|
$element = $query->getOneOrNullResult();
|
||||||
|
|
||||||
@@ -66,8 +66,9 @@ class BasketElementRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
$cacheId = "_basket_element_by_record_" . $record->get_serialize_key() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
$query->useResultCache(true, 1800, $cacheId);
|
// $cacheId = "_basket_element_by_record_" . $record->get_serialize_key() . Entities\BasketElement::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $cacheId);
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@@ -98,8 +99,9 @@ class BasketElementRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
$cacheId = "_receveid_element_by_record_" . $record->get_serialize_key() . "_" . $user->getId() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
$query->useResultCache(true, 1800, $cacheId);
|
// $cacheId = "_receveid_element_by_record_" . $record->get_serialize_key() . "_" . $user->getId() . Entities\BasketElement::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $cacheId);
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@@ -123,8 +125,9 @@ class BasketElementRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
$cacheId = "_receveid_validation_element_by_record" . $record->get_serialize_key() . "_" . $user->getId() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
$query->useResultCache(true, 1800, $cacheId);
|
// $cacheId = "_receveid_validation_element_by_record" . $record->get_serialize_key() . "_" . $user->getId() . Entities\BasketElement::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $cacheId);
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
@@ -56,9 +56,9 @@ class BasketRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters(array('usr_id' => $user->get_id()));
|
$query->setParameters(array('usr_id' => $user->get_id()));
|
||||||
$idCache = "_active_by_user_" . ($sort === null ? "" : $sort ) . "_" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
|
|
||||||
$query->useResultCache(true, 1800, $idCache);
|
// $idCache = "_active_by_user_" . ($sort === null ? "" : $sort. "_" ) . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $idCache);
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@@ -79,9 +79,11 @@ class BasketRepository extends EntityRepository
|
|||||||
WHERE b.archived = false
|
WHERE b.archived = false
|
||||||
AND (
|
AND (
|
||||||
(b.usr_id = :usr_id_owner AND b.is_read = false)
|
(b.usr_id = :usr_id_owner AND b.is_read = false)
|
||||||
OR (b.usr_id != :usr_id_ownertwo AND p.usr_id = :usr_id_participant
|
OR (b.usr_id != :usr_id_ownertwo
|
||||||
AND p.is_aware = false)
|
AND p.usr_id = :usr_id_participant
|
||||||
|
AND p.is_aware = false)
|
||||||
)
|
)
|
||||||
|
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())
|
||||||
ORDER BY e.ord ASC';
|
ORDER BY e.ord ASC';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
@@ -93,9 +95,8 @@ class BasketRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
$idCache = "findUnreadActiveByUser" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
// $idCache = "findUnreadActiveByUser" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $idCache);
|
||||||
$query->useResultCache(true, 1800, $idCache);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@@ -129,8 +130,9 @@ class BasketRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id()));
|
$query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id()));
|
||||||
$idCache = "_active_validation_by_user_" . $user->get_id() . "_" . $sort . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
$query->useResultCache(true, 1800, $idCache);
|
// $idCache = "_active_validation_by_user_" . $user->get_id() . "_" . $sort . Entities\Basket::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $idCache);
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@@ -157,8 +159,9 @@ class BasketRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters(array('basket_id' => $basket_id));
|
$query->setParameters(array('basket_id' => $basket_id));
|
||||||
$cacheId = "_find_user_" . $basket_id . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
$query->useResultCache(true, 1800, $cacheId);
|
// $cacheId = "_find_user_" . $basket_id . Entities\Basket::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $cacheId);
|
||||||
|
|
||||||
$basket = $query->getOneOrNullResult();
|
$basket = $query->getOneOrNullResult();
|
||||||
|
|
||||||
@@ -211,8 +214,9 @@ class BasketRepository extends EntityRepository
|
|||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
$idCache = "_containing_record_" . $record->get_serialize_key() . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
$query->useResultCache(true, 1800, $idCache);
|
// $idCache = "_containing_record_" . $record->get_serialize_key() . Entities\Basket::CACHE_SUFFIX;
|
||||||
|
// $query->useResultCache(true, 1800, $idCache);
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@@ -255,10 +259,9 @@ class BasketRepository extends EntityRepository
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$type = 'default';
|
|
||||||
$dql = 'SELECT b, e, s, p
|
$dql = 'SELECT b, e, s, p
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
JOIN b.elements e
|
LEFT JOIN b.elements e
|
||||||
LEFT JOIN b.validation s
|
LEFT JOIN b.validation s
|
||||||
LEFT JOIN s.participants p
|
LEFT JOIN s.participants p
|
||||||
WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)';
|
WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)';
|
||||||
@@ -267,6 +270,17 @@ class BasketRepository extends EntityRepository
|
|||||||
'validating_usr_id' => $user->get_id()
|
'validating_usr_id' => $user->get_id()
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case self::MYBASKETS:
|
||||||
|
$dql = 'SELECT b, e, s, p
|
||||||
|
FROM Entities\Basket b
|
||||||
|
LEFT JOIN b.elements e
|
||||||
|
LEFT JOIN b.validation s
|
||||||
|
LEFT JOIN s.participants p
|
||||||
|
WHERE (b.usr_id = :usr_id)';
|
||||||
|
$params = array(
|
||||||
|
'usr_id' => $user->get_id()
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctype_digit($year) && strlen($year) == 4)
|
if (ctype_digit($year) && strlen($year) == 4)
|
||||||
@@ -285,7 +299,7 @@ class BasketRepository extends EntityRepository
|
|||||||
$params['description'] = '%' . $query . '%';
|
$params['description'] = '%' . $query . '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
$dql .= ' ORDER BY e.ord ASC';
|
$dql .= ' ORDER BY b.id DESC, e.ord ASC';
|
||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
@@ -293,12 +307,44 @@ class BasketRepository extends EntityRepository
|
|||||||
$count = Paginate::getTotalQueryResults($query);
|
$count = Paginate::getTotalQueryResults($query);
|
||||||
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $perPage);
|
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $perPage);
|
||||||
|
|
||||||
$idCache = "_" . $type . "_workzone_basket_" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
// $idCache = "_" . $type . "_workzone_basket_" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
||||||
|
// $paginateQuery->useResultCache(true, 1800, $idCache);
|
||||||
|
|
||||||
$paginateQuery->useResultCache(true, 1800, $idCache);
|
|
||||||
$result = $paginateQuery->getResult();
|
$result = $paginateQuery->getResult();
|
||||||
|
|
||||||
return array('count' => $count, 'result' => $result);
|
return array('count' => $count, 'result' => $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all actives validation where current user is involved and user basket
|
||||||
|
* @param \User_Adapter $user
|
||||||
|
* @param type $sort
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function findActiveValidationAndBasketByUser(\User_Adapter $user, $sort = null)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT b, e, s, p
|
||||||
|
FROM Entities\Basket b
|
||||||
|
LEFT JOIN b.elements e
|
||||||
|
LEFT JOIN b.validation s
|
||||||
|
LEFT JOIN s.participants p
|
||||||
|
WHERE (b.usr_id = :usr_id
|
||||||
|
AND b.archived = false) OR (b.usr_id != :usr_id AND p.usr_id = :usr_id
|
||||||
|
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP()))';
|
||||||
|
|
||||||
|
if ($sort == 'date')
|
||||||
|
{
|
||||||
|
$dql .= ' ORDER BY b.created DESC, e.ord ASC';
|
||||||
|
}
|
||||||
|
elseif ($sort == 'name')
|
||||||
|
{
|
||||||
|
$dql .= ' ORDER BY b.name ASC, e.ord ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
$query->setParameters(array('usr_id' => $user->get_id()));
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,25 @@ class StoryWZRepository extends EntityRepository
|
|||||||
|
|
||||||
if ($sort == 'name')
|
if ($sort == 'name')
|
||||||
{
|
{
|
||||||
uasort($stories, array('\\Repositories\\StoryWZRepository', 'title_compare'));
|
$sortedStories = array();
|
||||||
|
foreach ($stories as $story)
|
||||||
|
{
|
||||||
|
$sortedStories[] = $story->getRecord()->get_title();
|
||||||
|
}
|
||||||
|
|
||||||
|
uasort($sortedStories, function($a, $b)
|
||||||
|
{
|
||||||
|
if ($a == $b)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($a < $b) ? -1 : 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($sortedStories as $idStory => $titleStory)
|
||||||
|
{
|
||||||
|
$sortedStories[$idStory] = $stories[$idStory];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stories;
|
return $stories;
|
||||||
@@ -54,7 +72,7 @@ class StoryWZRepository extends EntityRepository
|
|||||||
{
|
{
|
||||||
$story = $this->find($id);
|
$story = $this->find($id);
|
||||||
|
|
||||||
if($story)
|
if ($story)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -66,7 +84,7 @@ class StoryWZRepository extends EntityRepository
|
|||||||
throw new \Exception_NotFound('Story not found');
|
throw new \Exception_NotFound('Story not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($story->getUser()->get_id() !== $user->get_id())
|
if ($story->getUser()->get_id() !== $user->get_id())
|
||||||
{
|
{
|
||||||
throw new \Exception_Forbidden('You have not access to ths story');
|
throw new \Exception_Forbidden('You have not access to ths story');
|
||||||
}
|
}
|
||||||
@@ -79,16 +97,6 @@ class StoryWZRepository extends EntityRepository
|
|||||||
return $story;
|
return $story;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function title_compare(\Entities\StoryWZ $a, \Entities\StoryWZ $b)
|
|
||||||
{
|
|
||||||
if ($a->getRecord()->get_title() == $b->getRecord()->get_title())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ($a->getRecord()->get_title() < $b->getRecord()->get_title()) ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findUserStory(\User_Adapter $user, \record_adapter $Story)
|
public function findUserStory(\User_Adapter $user, \record_adapter $Story)
|
||||||
{
|
{
|
||||||
$story = $this->findOneBy(
|
$story = $this->findOneBy(
|
||||||
|
@@ -204,6 +204,25 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function caption_records(Request $request, $databox_id, $record_id)
|
||||||
|
{
|
||||||
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
|
$record = $this->appbox->get_databox($databox_id)->get_record($record_id);
|
||||||
|
$fields = $record->get_caption()->get_fields();
|
||||||
|
$ret = array();
|
||||||
|
foreach ($fields as $field)
|
||||||
|
{
|
||||||
|
$ret[$field->get_meta_struct_id()] = array(
|
||||||
|
'meta_structure_id' => $field->get_meta_struct_id()
|
||||||
|
, 'name' => $field->get_name()
|
||||||
|
, 'value' => $field->get_serialized_values(";")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$result->set_datas($ret);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an API_V1_result containing the results of a records search
|
* Get an API_V1_result containing the results of a records search
|
||||||
*
|
*
|
||||||
|
@@ -131,4 +131,18 @@ class Bridge_Api_Dailymotion_Container implements Bridge_Api_ContainerInterface
|
|||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_duration()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_category()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_private()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -138,4 +138,19 @@ class Bridge_Api_Flickr_Container implements Bridge_Api_ContainerInterface
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_duration()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_category()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_private()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -210,7 +210,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
*/
|
*/
|
||||||
public function get_category()
|
public function get_category()
|
||||||
{
|
{
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,7 +219,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
*/
|
*/
|
||||||
public function get_duration()
|
public function get_duration()
|
||||||
{
|
{
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,5 +279,4 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
{
|
{
|
||||||
return $this->entry["tags"];
|
return $this->entry["tags"];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -117,4 +117,20 @@ class Bridge_Api_Youtube_Container implements Bridge_Api_ContainerInterface
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_duration()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_category()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function is_private()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -558,7 +558,7 @@ class Session_Handler
|
|||||||
$browser = Browser::getInstance();
|
$browser = Browser::getInstance();
|
||||||
|
|
||||||
if($this->is_authenticated())
|
if($this->is_authenticated())
|
||||||
$user = User_Adapter::getInstance ($this->get_usr_id (), appbox::get_instance ());
|
$user = User_Adapter::getInstance ($this->get_usr_id (), appbox::get_instance (\bootstrap::getCore()));
|
||||||
|
|
||||||
return Session_Logger::create($databox, $browser, $this, $user);
|
return Session_Logger::create($databox, $browser, $this, $user);
|
||||||
}
|
}
|
||||||
|
@@ -456,15 +456,6 @@ class appbox extends base
|
|||||||
|
|
||||||
$cacheService = "array_cache";
|
$cacheService = "array_cache";
|
||||||
|
|
||||||
if (extension_loaded('apc'))
|
|
||||||
{
|
|
||||||
$cacheService = "apc_cache";
|
|
||||||
}
|
|
||||||
elseif (extension_loaded('xcache'))
|
|
||||||
{
|
|
||||||
$cacheService = "xcache_cache";
|
|
||||||
}
|
|
||||||
|
|
||||||
$Core->getConfiguration()->setConnexions($connexion);
|
$Core->getConfiguration()->setConnexions($connexion);
|
||||||
|
|
||||||
$services = $Core->getConfiguration()->getConfigurations();
|
$services = $Core->getConfiguration()->getConfigurations();
|
||||||
@@ -474,7 +465,7 @@ class appbox extends base
|
|||||||
if ($serviceName === "doctrine_prod")
|
if ($serviceName === "doctrine_prod")
|
||||||
{
|
{
|
||||||
|
|
||||||
$services["doctrine_prod"]["options"]["orm"]["cache"] = array(
|
$services["doctrine_prod"]["options"]["cache"] = array(
|
||||||
"query" => $cacheService,
|
"query" => $cacheService,
|
||||||
"result" => $cacheService,
|
"result" => $cacheService,
|
||||||
"metadata" => $cacheService
|
"metadata" => $cacheService
|
||||||
|
@@ -60,11 +60,12 @@ abstract class base implements cache_cacheableInterface
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const APPLICATION_BOX = 'APPLICATION_BOX';
|
const APPLICATION_BOX = 'APPLICATION_BOX';
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const DATA_BOX = 'DATA_BOX';
|
const DATA_BOX = 'DATA_BOX';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -78,7 +79,6 @@ abstract class base implements cache_cacheableInterface
|
|||||||
public function get_schema()
|
public function get_schema()
|
||||||
{
|
{
|
||||||
if ($this->schema)
|
if ($this->schema)
|
||||||
|
|
||||||
return $this->schema;
|
return $this->schema;
|
||||||
|
|
||||||
$this->load_schema();
|
$this->load_schema();
|
||||||
@@ -178,7 +178,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
public function get_data_from_cache($option = null)
|
public function get_data_from_cache($option = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($this->get_base_type() == self::DATA_BOX)
|
if ($this->get_base_type() == self::DATA_BOX)
|
||||||
{
|
{
|
||||||
\cache_databox::refresh($this->id);
|
\cache_databox::refresh($this->id);
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,6 @@ abstract class base implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
if ($this->version)
|
if ($this->version)
|
||||||
|
|
||||||
return $this->version;
|
return $this->version;
|
||||||
|
|
||||||
$version = '0.0.0';
|
$version = '0.0.0';
|
||||||
@@ -245,9 +244,9 @@ abstract class base implements cache_cacheableInterface
|
|||||||
|
|
||||||
if ($sql !== '')
|
if ($sql !== '')
|
||||||
{
|
{
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ($row)
|
if ($row)
|
||||||
$version = $row['version'];
|
$version = $row['version'];
|
||||||
@@ -261,10 +260,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
public function upgradeavailable()
|
public function upgradeavailable()
|
||||||
{
|
{
|
||||||
if ($this->get_version())
|
if ($this->get_version())
|
||||||
|
|
||||||
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
|
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
|
||||||
else
|
else
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,13 +278,25 @@ abstract class base implements cache_cacheableInterface
|
|||||||
|
|
||||||
$upgrader->add_steps(count($allTables) + 1);
|
$upgrader->add_steps(count($allTables) + 1);
|
||||||
|
|
||||||
$sql = "SHOW TABLE STATUS";
|
$sql = "SHOW TABLE STATUS";
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
|
||||||
|
$ORMTables = array(
|
||||||
|
'BasketElements',
|
||||||
|
'Baskets',
|
||||||
|
'StoryWZ',
|
||||||
|
'UsrListOwners',
|
||||||
|
'UsrLists',
|
||||||
|
'UsrListsContent',
|
||||||
|
'ValidationDatas',
|
||||||
|
'ValidationParticipants',
|
||||||
|
'ValidationSessions',
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
$tname = $row["Name"];
|
$tname = $row["Name"];
|
||||||
@@ -296,7 +305,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$upgrader->set_current_message(sprintf(_('Updating table %s'), $tname));
|
$upgrader->set_current_message(sprintf(_('Updating table %s'), $tname));
|
||||||
|
|
||||||
$engine = strtolower(trim($allTables[$tname]->engine));
|
$engine = strtolower(trim($allTables[$tname]->engine));
|
||||||
$ref_engine = strtolower($row['Engine']);
|
$ref_engine = strtolower($row['Engine']);
|
||||||
|
|
||||||
if ($engine != $ref_engine && in_array($engine, array('innodb', 'myisam')))
|
if ($engine != $ref_engine && in_array($engine, array('innodb', 'myisam')))
|
||||||
@@ -311,22 +320,22 @@ abstract class base implements cache_cacheableInterface
|
|||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$recommends[] = array(
|
$recommends[] = array(
|
||||||
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
||||||
'sql' => $sql
|
'sql' => $sql
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = self::upgradeTable($allTables[$tname]);
|
$ret = self::upgradeTable($allTables[$tname]);
|
||||||
$recommends = array_merge($recommends, $ret);
|
$recommends = array_merge($recommends, $ret);
|
||||||
unset($allTables[$tname]);
|
unset($allTables[$tname]);
|
||||||
$upgrader->add_steps_complete(1);
|
$upgrader->add_steps_complete(1);
|
||||||
}
|
}
|
||||||
else
|
elseif (!in_array($tname, $ORMTables))
|
||||||
{
|
{
|
||||||
$recommends[] = array(
|
$recommends[] = array(
|
||||||
'message' => 'Une table pourrait etre supprime',
|
'message' => 'Une table pourrait etre supprime',
|
||||||
'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;'
|
'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,7 +399,6 @@ abstract class base implements cache_cacheableInterface
|
|||||||
protected function load_schema()
|
protected function load_schema()
|
||||||
{
|
{
|
||||||
if ($this->schema)
|
if ($this->schema)
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
|
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");
|
||||||
@@ -434,7 +442,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected function createTable(SimpleXMLElement $table)
|
protected function createTable(SimpleXMLElement $table)
|
||||||
{
|
{
|
||||||
$field_stmt = $defaults_stmt = array();
|
$field_stmt = $defaults_stmt = array();
|
||||||
|
|
||||||
$create_stmt = "CREATE TABLE `" . $table['name'] . "` (";
|
$create_stmt = "CREATE TABLE `" . $table['name'] . "` (";
|
||||||
|
|
||||||
@@ -451,8 +459,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
|
|
||||||
$character_set = '';
|
$character_set = '';
|
||||||
if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext'))
|
if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext'))
|
||||||
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|
||||||
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
|
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
|
||||||
{
|
{
|
||||||
|
|
||||||
$collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci';
|
$collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci';
|
||||||
@@ -463,8 +471,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$field_stmt[] = " `" . $field->name . "` " . $field->type . " "
|
$field_stmt[] = " `" . $field->name . "` " . $field->type . " "
|
||||||
. $field->extra . " " . $character_set . " "
|
. $field->extra . " " . $character_set . " "
|
||||||
. $is_default . " " . $isnull . "";
|
. $is_default . " " . $isnull . "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -482,7 +490,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
$primary_fields[] = "`" . $field . "`";
|
$primary_fields[] = "`" . $field . "`";
|
||||||
}
|
}
|
||||||
|
|
||||||
$field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')';
|
$field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')';
|
||||||
break;
|
break;
|
||||||
case "UNIQUE":
|
case "UNIQUE":
|
||||||
$unique_fields = array();
|
$unique_fields = array();
|
||||||
@@ -511,32 +519,32 @@ abstract class base implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
foreach ($table->defaults->default as $default)
|
foreach ($table->defaults->default as $default)
|
||||||
{
|
{
|
||||||
$k = $v = $params = $dates_values = array();
|
$k = $v = $params = $dates_values = array();
|
||||||
$nonce = random::generatePassword(16);
|
$nonce = random::generatePassword(16);
|
||||||
foreach ($default->data as $data)
|
foreach ($default->data as $data)
|
||||||
{
|
{
|
||||||
$k = trim($data['key']);
|
$k = trim($data['key']);
|
||||||
if ($k === 'usr_password')
|
if ($k === 'usr_password')
|
||||||
$data = User_Adapter::salt_password($data, $nonce);
|
$data = User_Adapter::salt_password($data, $nonce);
|
||||||
if ($k === 'nonce')
|
if ($k === 'nonce')
|
||||||
$data = $nonce;
|
$data = $nonce;
|
||||||
$v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data));
|
$v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data));
|
||||||
|
|
||||||
if (trim(mb_strtolower($v)) == 'now()')
|
if (trim(mb_strtolower($v)) == 'now()')
|
||||||
$dates_values [$k] = 'NOW()';
|
$dates_values [$k] = 'NOW()';
|
||||||
else
|
else
|
||||||
$params[$k] = (trim(mb_strtolower($v)) == 'null' ? null : $v);
|
$params[$k] = (trim(mb_strtolower($v)) == 'null' ? null : $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
$separator = ((count($params) > 0 && count($dates_values) > 0) ? ', ' : '');
|
$separator = ((count($params) > 0 && count($dates_values) > 0) ? ', ' : '');
|
||||||
|
|
||||||
$defaults_stmt[] = array(
|
$defaults_stmt[] = array(
|
||||||
'sql' =>
|
'sql' =>
|
||||||
'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params))
|
'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params))
|
||||||
. $separator . implode(', ', array_keys($dates_values)) . ')
|
. $separator . implode(', ', array_keys($dates_values)) . ')
|
||||||
VALUES (:' . implode(', :', array_keys($params))
|
VALUES (:' . implode(', :', array_keys($params))
|
||||||
. $separator . implode(', ', array_values($dates_values)) . ') '
|
. $separator . implode(', ', array_values($dates_values)) . ') '
|
||||||
, 'params' => $params
|
, 'params' => $params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,8 +570,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$recommends[] = array(
|
$recommends[] = array(
|
||||||
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
||||||
'sql' => $def['sql']
|
'sql' => $def['sql']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -574,7 +582,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
protected function upgradeTable(SimpleXMLElement $table)
|
protected function upgradeTable(SimpleXMLElement $table)
|
||||||
{
|
{
|
||||||
$correct_table = array('fields' => array(), 'indexes' => array(), 'collation' => array());
|
$correct_table = array('fields' => array(), 'indexes' => array(), 'collation' => array());
|
||||||
$alter = $alter_pre = $return = array();
|
$alter = $alter_pre = $return = array();
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
@@ -589,8 +597,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
$collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci';
|
$collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci';
|
||||||
|
|
||||||
if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext'))
|
if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext'))
|
||||||
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|
|| substr(strtolower((string) $field->type), 0, 7) == 'varchar'
|
||||||
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
|
|| in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum')))
|
||||||
{
|
{
|
||||||
$code = array_pop(array_reverse(explode('_', $collation)));
|
$code = array_pop(array_reverse(explode('_', $collation)));
|
||||||
|
|
||||||
@@ -618,7 +626,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
foreach ($table->indexes->index as $index)
|
foreach ($table->indexes->index as $index)
|
||||||
{
|
{
|
||||||
$i_name = (string) $index->name;
|
$i_name = (string) $index->name;
|
||||||
$expr = array();
|
$expr = array();
|
||||||
foreach ($index->fields->field as $field)
|
foreach ($index->fields->field as $field)
|
||||||
$expr[] = '`' . trim((string) $field) . '`';
|
$expr[] = '`' . trim((string) $field) . '`';
|
||||||
|
|
||||||
@@ -630,25 +638,25 @@ abstract class base implements cache_cacheableInterface
|
|||||||
$correct_table['indexes']['PRIMARY'] = 'PRIMARY KEY (' . $expr . ')';
|
$correct_table['indexes']['PRIMARY'] = 'PRIMARY KEY (' . $expr . ')';
|
||||||
break;
|
break;
|
||||||
case "UNIQUE":
|
case "UNIQUE":
|
||||||
$correct_table['indexes'][$i_name] = 'UNIQUE KEY `' . $i_name . '` (' . $expr . ')';
|
$correct_table['indexes'][$i_name] = 'UNIQUE KEY `' . $i_name . '` (' . $expr . ')';
|
||||||
break;
|
break;
|
||||||
case "INDEX":
|
case "INDEX":
|
||||||
$correct_table['indexes'][$i_name] = 'KEY `' . $i_name . '` (' . $expr . ')';
|
$correct_table['indexes'][$i_name] = 'KEY `' . $i_name . '` (' . $expr . ')';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = "SHOW FULL FIELDS FROM `" . $table['name'] . "`";
|
$sql = "SHOW FULL FIELDS FROM `" . $table['name'] . "`";
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs2 as $row2)
|
foreach ($rs2 as $row2)
|
||||||
{
|
{
|
||||||
$f_name = $row2['Field'];
|
$f_name = $row2['Field'];
|
||||||
$expr_found = trim($row2['Type']);
|
$expr_found = trim($row2['Type']);
|
||||||
|
|
||||||
$_extra = $row2['Extra'];
|
$_extra = $row2['Extra'];
|
||||||
@@ -727,8 +735,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
'message' => 'Un champ pourrait etre supprime',
|
'message' => 'Un champ pourrait etre supprime',
|
||||||
'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;"
|
'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,16 +747,16 @@ abstract class base implements cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tIndex = array();
|
$tIndex = array();
|
||||||
$sql = "SHOW INDEXES FROM `" . $table['name'] . "`";
|
$sql = "SHOW INDEXES FROM `" . $table['name'] . "`";
|
||||||
$stmt = $this->get_connection()->prepare($sql);
|
$stmt = $this->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs2 as $row2)
|
foreach ($rs2 as $row2)
|
||||||
{
|
{
|
||||||
if (!isset($tIndex[$row2['Key_name']]))
|
if (!isset($tIndex[$row2['Key_name']]))
|
||||||
$tIndex[$row2['Key_name']] = array('unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => array());
|
$tIndex[$row2['Key_name']] = array('unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => array());
|
||||||
$tIndex[$row2['Key_name']]['columns'][(int) ($row2['Seq_in_index'])] = $row2['Column_name'];
|
$tIndex[$row2['Key_name']]['columns'][(int) ($row2['Seq_in_index'])] = $row2['Column_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,8 +794,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
'message' => 'Un index pourrait etre supprime',
|
'message' => 'Un index pourrait etre supprime',
|
||||||
'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';'
|
'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -806,8 +814,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
||||||
'sql' => $a
|
'sql' => $a
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -823,8 +831,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()),
|
||||||
'sql' => $a
|
'sql' => $a
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -882,8 +890,8 @@ abstract class base implements cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$upgrader->add_steps_complete(1)
|
$upgrader->add_steps_complete(1)
|
||||||
->add_steps(count($list_patches))
|
->add_steps(count($list_patches))
|
||||||
->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname()));
|
->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname()));
|
||||||
ksort($list_patches);
|
ksort($list_patches);
|
||||||
|
|
||||||
$success = true;
|
$success = true;
|
||||||
|
@@ -50,10 +50,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
|
|||||||
$this->record = $record;
|
$this->record = $record;
|
||||||
$this->databox = $databox;
|
$this->databox = $databox;
|
||||||
|
|
||||||
|
|
||||||
$this->retrieve_fields();
|
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +178,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
|
|||||||
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
|
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
|
||||||
{
|
{
|
||||||
$fields = array();
|
$fields = array();
|
||||||
foreach ($this->fields as $meta_struct_id => $field)
|
foreach ($this->retrieve_fields() as $meta_struct_id => $field)
|
||||||
{
|
{
|
||||||
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
|
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
|
||||||
continue;
|
continue;
|
||||||
|
@@ -991,13 +991,6 @@ class databox extends base
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['regname']))
|
|
||||||
$meta_struct_field->set_regname();
|
|
||||||
if (isset($field['regdate']))
|
|
||||||
$meta_struct_field->set_regdate();
|
|
||||||
if (isset($field['regdesc']))
|
|
||||||
$meta_struct_field->set_regdesc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -98,24 +98,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected $thumbtitle;
|
protected $thumbtitle;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var <type>
|
|
||||||
*/
|
|
||||||
protected $regdate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var <type>
|
|
||||||
*/
|
|
||||||
protected $regdesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var <type>
|
|
||||||
*/
|
|
||||||
protected $regname;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
@@ -163,7 +145,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
$connbas = $this->get_connection();
|
$connbas = $this->get_connection();
|
||||||
|
|
||||||
$sql = "SELECT `regdate`, `regdesc`, `regname`, `thumbtitle`, `separator`
|
$sql = "SELECT `thumbtitle`, `separator`
|
||||||
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
|
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
|
||||||
, `readonly`, `indexable`, `name`, `src`
|
, `readonly`, `indexable`, `name`, `src`
|
||||||
, `VocabularyControlType`, `RestrictToVocabularyControl`
|
, `VocabularyControlType`, `RestrictToVocabularyControl`
|
||||||
@@ -216,10 +198,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$this->separator = $separator;
|
$this->separator = $separator;
|
||||||
$this->thumbtitle = $row['thumbtitle'];
|
$this->thumbtitle = $row['thumbtitle'];
|
||||||
|
|
||||||
$this->regdesc = !!$row['regdesc'];
|
|
||||||
$this->regname = !!$row['regname'];
|
|
||||||
$this->regdate = !!$row['regdate'];
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,39 +599,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return databox_field
|
|
||||||
*/
|
|
||||||
public function set_regdate()
|
|
||||||
{
|
|
||||||
$this->set_reg_attr('date');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return databox_field
|
|
||||||
*/
|
|
||||||
public function set_regdesc()
|
|
||||||
{
|
|
||||||
$this->set_reg_attr('desc');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return databox_field
|
|
||||||
*/
|
|
||||||
public function set_regname()
|
|
||||||
{
|
|
||||||
$this->set_reg_attr('name');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $attr
|
* @param string $attr
|
||||||
@@ -683,33 +628,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function is_regname()
|
|
||||||
{
|
|
||||||
return $this->regname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function is_regdesc()
|
|
||||||
{
|
|
||||||
return $this->regdesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function is_regdate()
|
|
||||||
{
|
|
||||||
return $this->regdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
@@ -870,10 +788,10 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
$sql = "INSERT INTO metadatas_structure
|
$sql = "INSERT INTO metadatas_structure
|
||||||
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
|
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
|
||||||
`thumbtitle`, `multi`, `regname`, `regdesc`, `regdate` ,
|
`thumbtitle`, `multi`,
|
||||||
`report`, `sorter`)
|
`report`, `sorter`)
|
||||||
VALUES (null, :name, '', 0, 1, 'text', '',
|
VALUES (null, :name, '', 0, 1, 'text', '',
|
||||||
null, 0, null, null, null,
|
null, 0,
|
||||||
1, :sorter)";
|
1, :sorter)";
|
||||||
|
|
||||||
$stmt = $databox->get_connection()->prepare($sql);
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
177
lib/classes/eventsmanager/notify/downloadmailfail.class.php
Normal file
177
lib/classes/eventsmanager/notify/downloadmailfail.class.php
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
const MAIL_NO_VALID = 1;
|
||||||
|
const MAIL_FAIL = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $events = array('__EXPORT_MAIL_FAIL__');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function icon_url()
|
||||||
|
{
|
||||||
|
return '/skins/icons/user.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $event
|
||||||
|
* @param Array $params
|
||||||
|
* @param mixed content $object
|
||||||
|
* @return Void
|
||||||
|
*/
|
||||||
|
public function fire($event, $params, &$object)
|
||||||
|
{
|
||||||
|
$default = array(
|
||||||
|
'usr_id' => null
|
||||||
|
, 'lst' => ''
|
||||||
|
, 'ssttid' => ''
|
||||||
|
, 'dest' => ''
|
||||||
|
, 'reason' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
$params = array_merge($default, $params);
|
||||||
|
|
||||||
|
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
$dom_xml->preserveWhiteSpace = false;
|
||||||
|
$dom_xml->formatOutput = true;
|
||||||
|
|
||||||
|
$root = $dom_xml->createElement('datas');
|
||||||
|
|
||||||
|
$lst = $dom_xml->createElement('lst');
|
||||||
|
$ssttid = $dom_xml->createElement('ssttid');
|
||||||
|
$dest = $dom_xml->createElement('dest');
|
||||||
|
$reason = $dom_xml->createElement('reason');
|
||||||
|
|
||||||
|
$lst->appendChild($dom_xml->createTextNode($params['lst']));
|
||||||
|
$ssttid->appendChild($dom_xml->createTextNode($params['ssttid']));
|
||||||
|
$dest->appendChild($dom_xml->createTextNode($params['dest']));
|
||||||
|
$reason->appendChild($dom_xml->createTextNode($params['reason']));
|
||||||
|
|
||||||
|
$root->appendChild($lst);
|
||||||
|
$root->appendChild($ssttid);
|
||||||
|
$root->appendChild($dest);
|
||||||
|
$root->appendChild($reason);
|
||||||
|
|
||||||
|
$dom_xml->appendChild($root);
|
||||||
|
|
||||||
|
$datas = $dom_xml->saveXml();
|
||||||
|
|
||||||
|
$mailed = false;
|
||||||
|
|
||||||
|
$send_notif = ($this->get_prefs(__CLASS__, $params['usr_id']) != '0');
|
||||||
|
|
||||||
|
if ($send_notif)
|
||||||
|
{
|
||||||
|
$user = User_Adapter::getInstance($params['usr_id'], $this->appbox);
|
||||||
|
$name = $user->get_display_name();
|
||||||
|
|
||||||
|
$to = array('email' => $user->get_email(), 'name' => $name);
|
||||||
|
|
||||||
|
$from = array(
|
||||||
|
'email' => $this->registry->get('GV_defaulmailsenderaddr'),
|
||||||
|
'name' => $this->registry->get('GV_homeTitle')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (parent::email())
|
||||||
|
$mailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Array $datas
|
||||||
|
* @param boolean $unread
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function datas($datas, $unread)
|
||||||
|
{
|
||||||
|
$sx = simplexml_load_string($datas);
|
||||||
|
$usr_id = (int) $sx->usr_id;
|
||||||
|
$reason = (int) $sx->reason;
|
||||||
|
$lst = (string) $sx->lst;
|
||||||
|
$ssttid = (int) $sx->ssttid;
|
||||||
|
$dest = (string) $sx->dest;
|
||||||
|
|
||||||
|
if ($reason == self::MAIL_NO_VALID)
|
||||||
|
{
|
||||||
|
$reason = _('email is not valid');
|
||||||
|
}
|
||||||
|
elseif ($reason == self::MAIL_FAIL)
|
||||||
|
{
|
||||||
|
$reason = _('failed to send mail');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$reason = _('an error occured while exporting records');
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = sprintf(
|
||||||
|
_("The delivery to %s failed for the following reason : %s")
|
||||||
|
, $dest
|
||||||
|
, $reason
|
||||||
|
);
|
||||||
|
|
||||||
|
$ret = array(
|
||||||
|
'text' => $text
|
||||||
|
, 'class' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_name()
|
||||||
|
{
|
||||||
|
return _('Email export fails');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_description()
|
||||||
|
{
|
||||||
|
return _('Get a notification when a mail export fails');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function is_available()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -208,8 +208,9 @@ class mail
|
|||||||
|
|
||||||
$body = eregi_replace("[\]", '', $body);
|
$body = eregi_replace("[\]", '', $body);
|
||||||
|
|
||||||
$body .= "<br/>\n"._('Si le lien n\'est pas cliquable, copiez-collez le dans votre navigateur.')."<br/>\n";
|
|
||||||
$body .= "<br/><br/><br/><br/>\n\n\n\n";
|
$body .= "<br/><br/><br/><br/>\n\n\n\n";
|
||||||
|
$body .= '<div style="font-style:italic;">'._('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.').'</div>';
|
||||||
|
$body .= "<br/>\n";
|
||||||
$body .= '<div style="font-style:italic;">' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "</div>\n";
|
$body .= '<div style="font-style:italic;">' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "</div>\n";
|
||||||
$body .= '<div><a href="' . $registry->get('GV_ServerName') . '">' . $registry->get('GV_ServerName') . "</a></div>\n";
|
$body .= '<div><a href="' . $registry->get('GV_ServerName') . '">' . $registry->get('GV_ServerName') . "</a></div>\n";
|
||||||
$body = '<body>' . $body . '</body>';
|
$body = '<body>' . $body . '</body>';
|
||||||
@@ -258,7 +259,7 @@ class mail
|
|||||||
$mail->ConfirmReadingTo = $reading_confirm_to;
|
$mail->ConfirmReadingTo = $reading_confirm_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li>'));
|
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li><em><strong><span><br>'));
|
||||||
|
|
||||||
foreach ($files as $f)
|
foreach ($files as $f)
|
||||||
{
|
{
|
||||||
|
@@ -143,7 +143,7 @@ class module_console_fileConfigCheck extends Command
|
|||||||
private function checkParse(OutputInterface $output)
|
private function checkParse(OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$this->configuration->getConfigurations())
|
if (!$this->configuration)
|
||||||
{
|
{
|
||||||
throw new \Exception("Unable to load configurations\n");
|
throw new \Exception("Unable to load configurations\n");
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ class module_console_fileConfigCheck extends Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->configuration->getConfiguration();
|
$this->configuration;
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
@@ -178,15 +178,8 @@ class module_console_fileConfigCheck extends Command
|
|||||||
{
|
{
|
||||||
$configuration = Core\Configuration::build();
|
$configuration = Core\Configuration::build();
|
||||||
|
|
||||||
try
|
$env = $configuration->getEnvironnement();
|
||||||
{
|
$output->writeln("<info>Get Selected Environment from file : ".$env."</info>");
|
||||||
$configuration->getConfiguration();
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
throw new \Exception(sprintf("Check get selected environment from file\n"), null, $e);
|
|
||||||
}
|
|
||||||
$output->writeln("<info>Get Selected Environment from file OK</info>");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
920
lib/classes/module/console/fileEnsureDevSetting.class.php
Normal file
920
lib/classes/module/console/fileEnsureDevSetting.class.php
Normal file
@@ -0,0 +1,920 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputArgument,
|
||||||
|
Symfony\Component\Console\Input\InputInterface,
|
||||||
|
Symfony\Component\Console\Input\InputOption,
|
||||||
|
Symfony\Component\Console\Output\OutputInterface,
|
||||||
|
Symfony\Component\Console\Command\Command;
|
||||||
|
use Alchemy\Phrasea\Core;
|
||||||
|
use Symfony\Component\Yaml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write tests
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class module_console_fileEnsureDevSetting extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
const ALERT = 1;
|
||||||
|
const ERROR = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Alchemy\Phrasea\Core\Configuration
|
||||||
|
*/
|
||||||
|
protected $configuration;
|
||||||
|
protected $testSuite = array(
|
||||||
|
'checkPhraseanetScope'
|
||||||
|
, 'checkDatabaseScope'
|
||||||
|
, 'checkTeamplateEngineService'
|
||||||
|
, 'checkOrmService'
|
||||||
|
, 'checkCacheService'
|
||||||
|
, 'checkOpcodeCacheService'
|
||||||
|
);
|
||||||
|
protected $errors = 0;
|
||||||
|
protected $alerts = 0;
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Ensure development settings');
|
||||||
|
|
||||||
|
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
|
||||||
|
$this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
|
||||||
|
|
||||||
|
$environnement = $input->getArgument('conf');
|
||||||
|
|
||||||
|
$this->configuration = \Alchemy\Phrasea\Core\Configuration::build($specifications, $environnement);
|
||||||
|
|
||||||
|
if (!$this->configuration->isInstalled())
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("\nPhraseanet is not installed\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->checkParse($output);
|
||||||
|
$output->writeln(sprintf("Will Ensure Production Settings on <info>%s</info>", $this->configuration->getEnvironnement()));
|
||||||
|
|
||||||
|
$this->runTests($output);
|
||||||
|
|
||||||
|
$retval = $this->errors;
|
||||||
|
if ($input->getOption('strict'))
|
||||||
|
{
|
||||||
|
$retval += $this->alerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($retval > 0)
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Some errors found in your conf</error>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<info>Your dev settings are setted correctly ! Enjoy</info>");
|
||||||
|
}
|
||||||
|
$output->writeln('End');
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function runTests(OutputInterface $output)
|
||||||
|
{
|
||||||
|
foreach ($this->testSuite as $test)
|
||||||
|
{
|
||||||
|
$display = "";
|
||||||
|
switch ($test)
|
||||||
|
{
|
||||||
|
case 'checkPhraseanetScope' :
|
||||||
|
$display = "Phraseanet Configuration";
|
||||||
|
break;
|
||||||
|
case 'checkDatabaseScope' :
|
||||||
|
$display = "Database";
|
||||||
|
break;
|
||||||
|
case 'checkTeamplateEngineService' :
|
||||||
|
$display = "Template Engine";
|
||||||
|
break;
|
||||||
|
case 'checkOrmService' :
|
||||||
|
$display = "ORM";
|
||||||
|
break;
|
||||||
|
case 'checkCacheService' :
|
||||||
|
$display = "Cache";
|
||||||
|
break;
|
||||||
|
case 'checkOpcodeCacheService' :
|
||||||
|
$display = "Opcode";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception('Unknown test');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\n||| %s", mb_strtoupper($display)));
|
||||||
|
|
||||||
|
call_user_func(array($this, $test), $output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkParse(OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$this->configuration->getConfigurations())
|
||||||
|
{
|
||||||
|
throw new \Exception("Unable to load configurations\n");
|
||||||
|
}
|
||||||
|
if (!$this->configuration->getConnexions())
|
||||||
|
{
|
||||||
|
throw new \Exception("Unable to load connexions\n");
|
||||||
|
}
|
||||||
|
if (!$this->configuration->getServices())
|
||||||
|
{
|
||||||
|
throw new \Exception("Unable to load services\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkCacheService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$cache = $this->configuration->getCache();
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->probeCacheService($output, $cache))
|
||||||
|
{
|
||||||
|
if ($this->recommendedCacheService($output, $cache, true))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<comment>Cache server recommended</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verification = sprintf("\t--> Verify <info>%s</info> : %s", 'MainCache', $work_message);
|
||||||
|
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . 'service', $cache, false, $verification);
|
||||||
|
$this->verifyCacheOptions($output, $cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkOpcodeCacheService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$cache = $this->configuration->getOpcodeCache();
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->probeCacheService($output, $cache))
|
||||||
|
{
|
||||||
|
if ($this->recommendedCacheService($output, $cache, false))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>No cache required</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verification = sprintf("\t--> Verify <info>%s</info> : %s", 'OpcodeCache', $work_message);
|
||||||
|
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . 'service', $cache, false, $verification);
|
||||||
|
$this->verifyCacheOptions($output, $cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkPhraseanetScope(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$required = array('servername', 'maintenance', 'debug', 'display_errors', 'database');
|
||||||
|
|
||||||
|
$phraseanet = $this->configuration->getPhraseanet();
|
||||||
|
|
||||||
|
foreach ($phraseanet->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
case 'servername':
|
||||||
|
$url = $value;
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
|
||||||
|
$parseUrl = parse_url($url);
|
||||||
|
|
||||||
|
if (empty($url))
|
||||||
|
{
|
||||||
|
$message = "<error>should not be empty</error>";
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($url == 'http://sub.domain.tld/')
|
||||||
|
{
|
||||||
|
$this->alerts++;
|
||||||
|
$message = "<comment>may be wrong</comment>";
|
||||||
|
}
|
||||||
|
elseif (!filter_var($url, FILTER_VALIDATE_URL))
|
||||||
|
{
|
||||||
|
$message = "<error>not valid</error>";
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message = "<info>OK</info>";
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'maintenance':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'debug':
|
||||||
|
case 'display_errors':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'database':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$service = $this->configuration->getConnexion($value);
|
||||||
|
if ($this->verifyDatabaseConnexion($service))
|
||||||
|
{
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message = '<error>Connection not available</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$message = '<error>Unknown connection</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkDatabaseScope(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$connexionName = $this->configuration->getPhraseanet()->get('database');
|
||||||
|
$connexion = $this->configuration->getConnexion($connexionName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ($this->verifyDatabaseConnexion($connexion))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\t--> Verify connection <info>%s</info> : %s", $connexionName, $work_message));
|
||||||
|
|
||||||
|
$required = array('driver');
|
||||||
|
|
||||||
|
if (!$connexion->has('driver'))
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Connection has no driver</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($connexion->get('driver') == 'pdo_mysql')
|
||||||
|
{
|
||||||
|
$required = array('driver', 'dbname', 'charset', 'password', 'user', 'port', 'host');
|
||||||
|
}
|
||||||
|
elseif ($connexion->get('driver') == 'pdo_sqlite')
|
||||||
|
{
|
||||||
|
$required = array('driver', 'path', 'charset');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Your driver is not managed</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($connexion->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
case 'charset':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
if ($value !== 'UTF8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'path':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = is_writable(dirname($value)) ? '<info>OK</info>' : '<error>Not writeable</error>';
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'dbname':
|
||||||
|
case 'user':
|
||||||
|
case 'host':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'port':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be ctype_digit</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'password':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = '***********';
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'driver':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'pdo_mysql')
|
||||||
|
{
|
||||||
|
$message = '<error>MySQL recommended</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function verifyDatabaseConnexion(\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $connexion)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$config = new \Doctrine\DBAL\Configuration();
|
||||||
|
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkTeamplateEngineService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$templateEngineName = $this->configuration->getTemplating();
|
||||||
|
$configuration = $this->configuration->getService($templateEngineName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration);
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not load template engine !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\t--> Verify Template engine <info>%s</info> : %s", $templateEngineName, $work_message));
|
||||||
|
|
||||||
|
if (!$configuration->has('type'))
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Configuration has no type</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($configuration->get('type') == 'TemplateEngine\\Twig')
|
||||||
|
{
|
||||||
|
$required = array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Your type is not managed</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($configuration->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'type':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'TemplateEngine\\Twig')
|
||||||
|
{
|
||||||
|
$message = '<error>Not recognized</error>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'options':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($configuration->get('options') as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'debug';
|
||||||
|
case 'strict_variables';
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'autoescape';
|
||||||
|
case 'optimizer';
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'charset';
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'utf-8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkOrmService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$ormName = $this->configuration->getOrm();
|
||||||
|
$configuration = $this->configuration->getService($ormName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration);
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\t--> Verify ORM engine <info>%s</info> : %s", $ormName, $work_message));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!$configuration->has('type'))
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Configuration has no type</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($configuration->get('type') == 'Orm\\Doctrine')
|
||||||
|
{
|
||||||
|
$required = array('debug', 'dbal', 'cache');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Your type is not managed</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($configuration->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'type':
|
||||||
|
$message = $value == 'Orm\\Doctrine' ? '<info>OK</info>' : '<error>Not recognized</error>';
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'options':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($configuration->get('options') as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'log':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'cache':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be Array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
|
||||||
|
$required_caches = array('query', 'result', 'metadata');
|
||||||
|
foreach ($value as $name => $cache_type)
|
||||||
|
{
|
||||||
|
$required_caches = array_diff($required_caches, array($name));
|
||||||
|
|
||||||
|
foreach ($cache_type as $key_cache => $value_cache)
|
||||||
|
{
|
||||||
|
switch ($key_cache)
|
||||||
|
{
|
||||||
|
case 'service':
|
||||||
|
if ($this->probeCacheService($output, $value_cache))
|
||||||
|
{
|
||||||
|
$server = $name === 'result';
|
||||||
|
if ($this->recommendedCacheService($output, $value_cache, $server))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors++;
|
||||||
|
$work_message = '<error>No cache required</error>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verification = sprintf("\t--> Verify <info>%s</info> : %s", $name, $work_message);
|
||||||
|
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $key_cache, $value_cache, false, $verification);
|
||||||
|
$this->verifyCacheOptions($output, $value_cache);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!isset($cache_type['service']))
|
||||||
|
{
|
||||||
|
$output->writeln('<error>Miss service for %s</error>', $cache_type);
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required_caches) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required caches %s</error>', implode(', ', $required_caches)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'debug':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'dbal':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$connexion = $this->configuration->getConnexion($value);
|
||||||
|
$this->verifyDatabaseConnexion($connexion);
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$message = '<error>Failed</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function verifyCacheOptions(OutputInterface $output, $ServiceName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conf = $this->configuration->getService($ServiceName);
|
||||||
|
|
||||||
|
$Service = Core\Service\Builder::create(
|
||||||
|
\bootstrap::getCore(), $ServiceName, $conf
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$required_options = array();
|
||||||
|
|
||||||
|
switch ($Service->getType())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case 'memcache':
|
||||||
|
$required_options = array('host', 'port');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($required_options)
|
||||||
|
{
|
||||||
|
foreach ($conf->get('options') as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'host';
|
||||||
|
$required_options = array_diff($required_options, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'port';
|
||||||
|
$required_options = array_diff($required_options, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required_options) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required_options)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function probeCacheService(OutputInterface $output, $ServiceName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||||
|
|
||||||
|
$Service = Core\Service\Builder::create(
|
||||||
|
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Service->getDriver()->isServer())
|
||||||
|
{
|
||||||
|
switch ($Service->getType())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 'memcache':
|
||||||
|
if (!@memcache_connect($Service->getHost(), $Service->getPort()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recommendedCacheService(OutputInterface $output, $ServiceName, $server)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||||
|
|
||||||
|
$Service = Core\Service\Builder::create(
|
||||||
|
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Service->getType() === 'array';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function printConf($output, $scope, $value, $scopage = false, $message = '')
|
||||||
|
{
|
||||||
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
foreach ($value as $key => $val)
|
||||||
|
{
|
||||||
|
if ($scopage)
|
||||||
|
$key = $scope . ":" . $key;
|
||||||
|
$this->printConf($output, $key, $val, $scopage, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (is_bool($value))
|
||||||
|
{
|
||||||
|
if ($value === false)
|
||||||
|
{
|
||||||
|
$value = 'false';
|
||||||
|
}
|
||||||
|
elseif ($value === true)
|
||||||
|
{
|
||||||
|
$value = 'true';
|
||||||
|
}
|
||||||
|
$output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
|
||||||
|
}
|
||||||
|
elseif (!empty($value))
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -44,6 +44,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
, 'checkOpcodeCacheService'
|
, 'checkOpcodeCacheService'
|
||||||
);
|
);
|
||||||
protected $errors = 0;
|
protected $errors = 0;
|
||||||
|
protected $alerts = 0;
|
||||||
|
|
||||||
public function __construct($name = null)
|
public function __construct($name = null)
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->setDescription('Ensure production settings');
|
$this->setDescription('Ensure production settings');
|
||||||
|
|
||||||
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
|
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
|
||||||
|
$this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -74,8 +76,23 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
|
|
||||||
$this->runTests($output);
|
$this->runTests($output);
|
||||||
|
|
||||||
|
$retval = $this->errors;
|
||||||
|
if ($input->getOption('strict'))
|
||||||
|
{
|
||||||
|
$retval += $this->alerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($retval > 0)
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Some errors found in your conf</error>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<info>Your production settings are setted correctly ! Enjoy</info>");
|
||||||
|
}
|
||||||
$output->writeln('End');
|
$output->writeln('End');
|
||||||
return 0;
|
|
||||||
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function runTests(OutputInterface $output)
|
private function runTests(OutputInterface $output)
|
||||||
@@ -112,15 +129,6 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
|
|
||||||
call_user_func(array($this, $test), $output);
|
call_user_func(array($this, $test), $output);
|
||||||
}
|
}
|
||||||
if ($this->errors)
|
|
||||||
{
|
|
||||||
$output->writeln("\n<error>Some errors found in your conf</error>");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$output->writeln("\n<info>Your production settings are setted correctly ! Enjoy</info>");
|
|
||||||
}
|
|
||||||
return $this->errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkParse(OutputInterface $output)
|
private function checkParse(OutputInterface $output)
|
||||||
@@ -156,6 +164,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$work_message = '<comment>Cache server recommended</comment>';
|
$work_message = '<comment>Cache server recommended</comment>';
|
||||||
|
$this->alerts++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -185,6 +194,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$work_message = '<comment>Opcode recommended</comment>';
|
$work_message = '<comment>Opcode recommended</comment>';
|
||||||
|
$this->alerts++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,6 +221,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
case 'servername':
|
case 'servername':
|
||||||
@@ -226,6 +237,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
elseif ($url == 'http://sub.domain.tld/')
|
elseif ($url == 'http://sub.domain.tld/')
|
||||||
{
|
{
|
||||||
|
$this->alerts++;
|
||||||
$message = "<comment>may be wrong</comment>";
|
$message = "<comment>may be wrong</comment>";
|
||||||
}
|
}
|
||||||
elseif (!filter_var($url, FILTER_VALIDATE_URL))
|
elseif (!filter_var($url, FILTER_VALIDATE_URL))
|
||||||
@@ -235,6 +247,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
elseif ($parseUrl["scheme"] !== "https")
|
elseif ($parseUrl["scheme"] !== "https")
|
||||||
{
|
{
|
||||||
|
$this->alerts++;
|
||||||
$message = "<comment>should be https</comment>";
|
$message = "<comment>should be https</comment>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -247,7 +260,14 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
case 'debug':
|
case 'debug':
|
||||||
case 'display_errors':
|
case 'display_errors':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value ? '<error>Should be false</error>' : '<info>OK</info>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'database':
|
case 'database':
|
||||||
@@ -335,11 +355,17 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
case 'charset':
|
case 'charset':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == 'UTF8' ? '<info>OK</info>' : '<comment>Not recognized</comment>';
|
$message = '<info>OK</info>';
|
||||||
|
if ($value !== 'UTF8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'path':
|
case 'path':
|
||||||
@@ -351,23 +377,50 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
case 'user':
|
case 'user':
|
||||||
case 'host':
|
case 'host':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'port':
|
case 'port':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = ctype_digit($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be ctype_digit</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'password':
|
case 'password':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$value = '***********';
|
$value = '***********';
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'driver':
|
case 'driver':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value === 'pdo_mysql' ? '<info>OK</info>' : '<error>MySQL recommended</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'pdo_mysql')
|
||||||
|
{
|
||||||
|
$message = '<error>MySQL recommended</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -410,7 +463,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$work_message = '<error>Failed - could not connect !</error>';
|
$work_message = '<error>Failed - could not load template engine !</error>';
|
||||||
$this->errors++;
|
$this->errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,14 +491,29 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
case 'type':
|
case 'type':
|
||||||
$message = $value == 'TemplateEngine\\Twig' ? '<info>OK</info>' : '<error>Not recognized</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if($value !== 'TemplateEngine\\Twig')
|
||||||
|
{
|
||||||
|
$message = '<error>Not recognized</error>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'options':
|
case 'options':
|
||||||
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be array</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, 'array()', false, $message);
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -458,21 +526,43 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
case 'debug';
|
case 'debug';
|
||||||
case 'strict_variables';
|
case 'strict_variables';
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == false ? '<info>OK</info>' : '<error>Should be false</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'autoescape';
|
case 'autoescape';
|
||||||
case 'optimizer';
|
case 'optimizer';
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == true ? '<info>OK</info>' : '<error>Should be true</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'charset';
|
case 'charset';
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == 'utf-8' ? '<info>OK</info>' : '<comment>Not recognized</comment>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'utf-8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -533,10 +623,18 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'options':
|
case 'options':
|
||||||
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be array</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, 'array()', false, $message);
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -548,12 +646,26 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
case 'log':
|
case 'log':
|
||||||
$message = $value == false ? '<info>OK</info>' : '<error>Should be deactivated</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be deactivated</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'cache':
|
case 'cache':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be Array</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be Array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, 'array()', false, $message);
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
|
||||||
$required_caches = array('query', 'result', 'metadata');
|
$required_caches = array('query', 'result', 'metadata');
|
||||||
@@ -575,6 +687,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->alerts++;
|
||||||
if ($server)
|
if ($server)
|
||||||
{
|
{
|
||||||
$work_message = '<comment>Cache server recommended</comment>';
|
$work_message = '<comment>Cache server recommended</comment>';
|
||||||
@@ -598,6 +711,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->verifyCacheOptions($output, $value_cache);
|
$this->verifyCacheOptions($output, $value_cache);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -617,7 +731,14 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
break;
|
break;
|
||||||
case 'debug':
|
case 'debug':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == false ? '<info>OK</info>' : '<error>Should be false</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'dbal':
|
case 'dbal':
|
||||||
@@ -636,6 +757,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -684,15 +806,30 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
{
|
{
|
||||||
case 'host';
|
case 'host';
|
||||||
$required_options = array_diff($required_options, array($conf));
|
$required_options = array_diff($required_options, array($conf));
|
||||||
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'port';
|
case 'port';
|
||||||
$required_options = array_diff($required_options, array($conf));
|
$required_options = array_diff($required_options, array($conf));
|
||||||
$message = ctype_digit($value) ? '<info>OK</info>' : '<comment>Not recognized</comment>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -729,7 +866,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'memcache':
|
case 'memcache':
|
||||||
if (!memcache_connect($Service->getHost(), $Service->getPort()))
|
if (!@memcache_connect($Service->getHost(), $Service->getPort()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -453,7 +453,6 @@ class module_report_activity extends module_report
|
|||||||
$this->result[$i]['total'] += 1;
|
$this->result[$i]['total'] += 1;
|
||||||
|
|
||||||
$total['tot_dl'] += 1;
|
$total['tot_dl'] += 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nb_row = $i + 1;
|
$nb_row = $i + 1;
|
||||||
@@ -479,7 +478,7 @@ class module_report_activity extends module_report
|
|||||||
* @param string $on choose the field on what you want the result
|
* @param string $on choose the field on what you want the result
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getConnexionBase($tab = false, $on= "")
|
public function getConnexionBase($tab = false, $on = "")
|
||||||
{
|
{
|
||||||
//default group on user column
|
//default group on user column
|
||||||
if (empty($on))
|
if (empty($on))
|
||||||
@@ -577,7 +576,7 @@ class module_report_activity extends module_report
|
|||||||
* @param array $tab config for the html table
|
* @param array $tab config for the html table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getDetailDownload($tab = false, $on="")
|
public function getDetailDownload($tab = false, $on = "")
|
||||||
{
|
{
|
||||||
empty($on) ? $on = "user" : ""; //by default always report on user
|
empty($on) ? $on = "user" : ""; //by default always report on user
|
||||||
|
|
||||||
@@ -638,19 +637,37 @@ class module_report_activity extends module_report
|
|||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
$user = $row[$on];
|
$user = $row[$on];
|
||||||
if (($save_user != $user) && !is_null($user))
|
if (($save_user != $user) && !is_null($user) && !empty($user))
|
||||||
|
{
|
||||||
|
if ($i >= 0)
|
||||||
|
{
|
||||||
|
if (($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc']) == 0 || ($this->result[$i]['poiddoc'] + $this->result[$i]['poidprev']) == 0)
|
||||||
|
{
|
||||||
|
unset($this->result[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->result[$i]['poiddoc']) && isset($this->result[$i]['poidprev']))
|
||||||
|
{
|
||||||
|
$this->result[$i]['poiddoc'] = p4string::format_octets($this->result[$i]['poiddoc']);
|
||||||
|
$this->result[$i]['poidprev'] = p4string::format_octets($this->result[$i]['poidprev']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
$this->result[$i]['nbprev'] = 0;
|
||||||
|
$this->result[$i]['poidprev'] = 0;
|
||||||
|
$this->result[$i]['nbdoc'] = 0;
|
||||||
|
$this->result[$i]['poiddoc'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//doc info
|
//doc info
|
||||||
if ($row['final'] == 'document' &&
|
if ($row['final'] == 'document' &&
|
||||||
!is_null($user) && !is_null($row['usrid']))
|
!is_null($user) && !is_null($row['usrid']))
|
||||||
{
|
{
|
||||||
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
|
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
|
||||||
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ?
|
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0);
|
||||||
p4string::format_octets($row['poid']) : 0);
|
|
||||||
if (!isset($this->result[$i]['nbprev']))
|
|
||||||
$this->result[$i]['nbprev'] = 0;
|
|
||||||
if (!isset($this->result[$i]['poidprev']))
|
|
||||||
$this->result[$i]['poidprev'] = 0;
|
|
||||||
$this->result[$i]['user'] = empty($row[$on]) ?
|
$this->result[$i]['user'] = empty($row[$on]) ?
|
||||||
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
||||||
$total['nbdoc'] += $this->result[$i]['nbdoc'];
|
$total['nbdoc'] += $this->result[$i]['nbdoc'];
|
||||||
@@ -658,26 +675,25 @@ class module_report_activity extends module_report
|
|||||||
$this->result[$i]['usrid'] = $row['usrid'];
|
$this->result[$i]['usrid'] = $row['usrid'];
|
||||||
}
|
}
|
||||||
//preview info
|
//preview info
|
||||||
if ($row['final'] == 'preview' &&
|
if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') &&
|
||||||
!is_null($user) &&
|
!is_null($user) &&
|
||||||
!is_null($row['usrid']))
|
!is_null($row['usrid']))
|
||||||
{
|
{
|
||||||
if (!isset($this->result[$i]['nbdoc']))
|
|
||||||
$this->result[$i]['nbdoc'] = 0;
|
$this->result[$i]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
|
||||||
if (!isset($this->result[$i]['poiddoc']))
|
$this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
|
||||||
$this->result[$i]['poiddoc'] = 0;
|
|
||||||
$this->result[$i]['nbprev'] = (!is_null($row['nb']) ? $row['nb'] : 0);
|
|
||||||
$this->result[$i]['poidprev'] = (!is_null($row['poid']) ?
|
|
||||||
p4string::format_octets($row['poid']) : 0);
|
|
||||||
$this->result[$i]['user'] = empty($row[$on]) ?
|
$this->result[$i]['user'] = empty($row[$on]) ?
|
||||||
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
||||||
$total['nbprev'] += $this->result[$i]['nbprev'];
|
$total['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
|
||||||
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
|
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
|
||||||
$this->result[$i]['usrid'] = $row['usrid'];
|
$this->result[$i]['usrid'] = $row['usrid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$save_user = $user;
|
$save_user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($this->result[$i]);
|
||||||
$nb_row = $i + 1;
|
$nb_row = $i + 1;
|
||||||
$this->total = $nb_row;
|
$this->total = $nb_row;
|
||||||
|
|
||||||
|
66
lib/classes/patch/320h.class.php
Normal file
66
lib/classes/patch/320h.class.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class patch_320h implements patchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $release = '3.2.0.0.a8';
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Array
|
||||||
|
*/
|
||||||
|
private $concern = array(base::APPLICATION_BOX);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply(base &$appbox)
|
||||||
|
{
|
||||||
|
$sql = 'DELETE FROM basusr WHERE actif = "0"';
|
||||||
|
|
||||||
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -59,7 +59,7 @@ class patch_360 implements patchInterface
|
|||||||
|
|
||||||
foreach ($tables as $table)
|
foreach ($tables as $table)
|
||||||
{
|
{
|
||||||
$sql = 'TRUNCATE ' . $table;
|
$sql = 'DELETE FROM ' . $table;
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
@@ -54,12 +54,18 @@ class patch_3602 implements patchInterface
|
|||||||
|
|
||||||
function apply(base &$databox)
|
function apply(base &$databox)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
|
||||||
|
|
||||||
$sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
catch(\PDOException $e)
|
||||||
|
{
|
||||||
|
|
||||||
$stmt = $databox->get_connection()->prepare($sql);
|
}
|
||||||
$stmt->execute();
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -95,8 +95,6 @@ interface record_Interface
|
|||||||
|
|
||||||
public function set_binary_status($status);
|
public function set_binary_status($status);
|
||||||
|
|
||||||
public function get_reg_name();
|
|
||||||
|
|
||||||
public function get_hd_file();
|
public function get_hd_file();
|
||||||
|
|
||||||
public function delete();
|
public function delete();
|
||||||
|
@@ -140,8 +140,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
const CACHE_GROUPING = 'grouping';
|
const CACHE_GROUPING = 'grouping';
|
||||||
const CACHE_STATUS = 'status';
|
const CACHE_STATUS = 'status';
|
||||||
|
|
||||||
protected static $_regfields;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param <int> $base_id
|
* @param <int> $base_id
|
||||||
@@ -895,16 +893,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
|
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
|
||||||
{
|
{
|
||||||
$sbas_id = $this->get_sbas_id();
|
|
||||||
$record_id = $this->get_record_id();
|
|
||||||
|
|
||||||
if ($this->is_grouping())
|
|
||||||
{
|
|
||||||
$regfield = self::getRegFields($sbas_id, $this->get_caption());
|
|
||||||
|
|
||||||
return $regfield['regname'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
@@ -944,98 +932,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_description()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!$this->is_grouping())
|
|
||||||
throw new \Exception('This record is not a story');
|
|
||||||
|
|
||||||
$regfield = self::getRegFields($this->get_sbas_id(), $this->get_caption());
|
|
||||||
|
|
||||||
return $regfield['regdesc'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param <type> $sbas_id
|
|
||||||
* @param caption_record $desc
|
|
||||||
* @return <type>
|
|
||||||
*/
|
|
||||||
protected static function getRegFields($sbas_id, caption_record $desc)
|
|
||||||
{
|
|
||||||
if (!self::$_regfields)
|
|
||||||
self::load_regfields();
|
|
||||||
|
|
||||||
$arrayRegFields = self::$_regfields[$sbas_id];
|
|
||||||
|
|
||||||
$array = array();
|
|
||||||
|
|
||||||
foreach ($arrayRegFields as $k => $f)
|
|
||||||
{
|
|
||||||
$array[$f] = $k;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields = array();
|
|
||||||
$fields["regname"] = "";
|
|
||||||
$fields["regdesc"] = "";
|
|
||||||
$fields["regdate"] = "";
|
|
||||||
|
|
||||||
foreach ($desc->get_fields() as $caption_field)
|
|
||||||
{
|
|
||||||
/* @var $caption_field caption_field */
|
|
||||||
$meta_struct_id = $caption_field->get_meta_struct_id();
|
|
||||||
if (array_key_exists($meta_struct_id, $array))
|
|
||||||
{
|
|
||||||
$fields[$array[$meta_struct_id]] = $caption_field->get_serialized_values();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get databox reg fields
|
|
||||||
*
|
|
||||||
* @todo change this shit
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected static function load_regfields()
|
|
||||||
{
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
|
||||||
self::$_regfields = array();
|
|
||||||
foreach ($appbox->get_databoxes() as $databox)
|
|
||||||
{
|
|
||||||
self::$_regfields[$databox->get_sbas_id()] = self::searchRegFields($databox->get_meta_structure());
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$_regfields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param databox_descriptionStructure $meta_struct
|
|
||||||
* @return <type>
|
|
||||||
*/
|
|
||||||
protected function searchRegFields(databox_descriptionStructure $meta_struct)
|
|
||||||
{
|
|
||||||
$fields = null;
|
|
||||||
$fields["regname"] = "";
|
|
||||||
$fields["regdesc"] = "";
|
|
||||||
$fields["regdate"] = "";
|
|
||||||
|
|
||||||
foreach ($meta_struct as $meta)
|
|
||||||
{
|
|
||||||
if ($meta->is_regname())
|
|
||||||
$fields["regname"] = $meta->get_id();
|
|
||||||
elseif ($meta->is_regdesc())
|
|
||||||
$fields["regdesc"] = $meta->get_id();
|
|
||||||
elseif ($meta->is_regdate())
|
|
||||||
$fields['regdate'] = $meta->get_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return media_subdef
|
* @return media_subdef
|
||||||
@@ -1487,42 +1383,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_reg_name()
|
|
||||||
{
|
|
||||||
if (!$this->is_grouping())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$balisename = '';
|
|
||||||
|
|
||||||
$struct = $this->databox->get_structure();
|
|
||||||
|
|
||||||
if ($sxe = simplexml_load_string($struct))
|
|
||||||
{
|
|
||||||
$z = $sxe->xpath('/record/description');
|
|
||||||
if ($z && is_array($z))
|
|
||||||
{
|
|
||||||
foreach ($z[0] as $ki => $vi)
|
|
||||||
{
|
|
||||||
if ($vi['regname'] == '1')
|
|
||||||
{
|
|
||||||
$balisename = $ki;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$regname = '';
|
|
||||||
if ($sxe = simplexml_load_string($this->get_xml()))
|
|
||||||
$regname = (string) $sxe->description->$balisename;
|
|
||||||
|
|
||||||
return $regname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@@ -631,7 +631,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
|
|||||||
return array();
|
return array();
|
||||||
$rs = $res['results'];
|
$rs = $res['results'];
|
||||||
$res = array_shift($rs);
|
$res = array_shift($rs);
|
||||||
if (!$res['xml'])
|
if (! isset($res['xml']))
|
||||||
|
|
||||||
return array();
|
return array();
|
||||||
$sxe = simplexml_load_string($res['xml']);
|
$sxe = simplexml_load_string($res['xml']);
|
||||||
@@ -645,7 +645,8 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
|
|||||||
{
|
{
|
||||||
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
|
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
|
||||||
}
|
}
|
||||||
$val = implode(' '.$field['separator'].' ', $val);
|
$separator = $field['separator'] ? $field['separator'][0] : '';
|
||||||
|
$val = implode(' '.$separator.' ', $val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -222,14 +222,26 @@ class set_order extends set_abstract
|
|||||||
$core = \bootstrap::getCore();
|
$core = \bootstrap::getCore();
|
||||||
|
|
||||||
$em = $core->getEntityManager();
|
$em = $core->getEntityManager();
|
||||||
$repository = $em->getRepository('\Entities\Basket');
|
|
||||||
|
|
||||||
|
$Basket = null;
|
||||||
/* @var $repository \Repositories\BasketRepository */
|
/* @var $repository \Repositories\BasketRepository */
|
||||||
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
|
if($this->ssel_id)
|
||||||
|
{
|
||||||
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
|
||||||
|
}
|
||||||
|
catch(\Exception $e)
|
||||||
|
{
|
||||||
|
$Basket = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!$Basket)
|
if(!$Basket)
|
||||||
{
|
{
|
||||||
$Basket = new Basket();
|
$Basket = new \Entities\Basket();
|
||||||
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
|
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
|
||||||
$Basket->setOwner($this->user);
|
$Basket->setOwner($this->user);
|
||||||
$Basket->setPusher($core->getAuthenticatedUser());
|
$Basket->setPusher($core->getAuthenticatedUser());
|
||||||
@@ -265,7 +277,7 @@ class set_order extends set_abstract
|
|||||||
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
|
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
|
||||||
$record = new record_adapter($sbas_id, $basrec['record_id']);
|
$record = new record_adapter($sbas_id, $basrec['record_id']);
|
||||||
|
|
||||||
$BasketElement = new BasketElement();
|
$BasketElement = new \Entities\BasketElement();
|
||||||
$BasketElement->setRecord($record);
|
$BasketElement->setRecord($record);
|
||||||
$BasketElement->setBasket($Basket);
|
$BasketElement->setBasket($Basket);
|
||||||
|
|
||||||
@@ -273,7 +285,6 @@ class set_order extends set_abstract
|
|||||||
|
|
||||||
$em->persist($BasketElement);
|
$em->persist($BasketElement);
|
||||||
|
|
||||||
$em->merge($Basket);
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':usr_id' => $session->get_usr_id()
|
':usr_id' => $session->get_usr_id()
|
||||||
|
@@ -608,17 +608,15 @@ class setup
|
|||||||
{
|
{
|
||||||
$stats = $Core->getCache()->getStats();
|
$stats = $Core->getCache()->getStats();
|
||||||
|
|
||||||
|
echo '<li>' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '</li>';
|
||||||
|
echo "<table>";
|
||||||
|
|
||||||
foreach ($stats as $name => $stat)
|
foreach ($stats as $name => $stat)
|
||||||
{
|
{
|
||||||
echo '<li>Statistics given by `' . $name . '`</li>';
|
echo "<tr class='even'><td>" . $name . "</td><td> " . $stat . "</td></tr>";
|
||||||
echo '<li>' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '</li>';
|
|
||||||
echo "<table>";
|
|
||||||
foreach ($stat as $key => $value)
|
|
||||||
{
|
|
||||||
echo "<tr class='even'><td>" . $key . "</td><td> " . $value . "</td></tr>";
|
|
||||||
}
|
|
||||||
echo "</table>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "</table>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -643,9 +641,9 @@ class setup
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($found > 1)
|
if ($found > 1)
|
||||||
$constraints[] = new Setup_Constraint('Multiple opcode caches', false, 'Many opcode cache load is forbidden', true);
|
$constraints[] = new Setup_Constraint('Multiple opcode caches', false, _('Many opcode cache load is forbidden'), true);
|
||||||
if ($found === 0)
|
if ($found === 0)
|
||||||
$constraints[] = new Setup_Constraint('No opcode cache', false, 'No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.', false);
|
$constraints[] = new Setup_Constraint('No opcode cache', false, _('No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.'), false);
|
||||||
|
|
||||||
return new Setup_ConstraintsIterator($constraints);
|
return new Setup_ConstraintsIterator($constraints);
|
||||||
}
|
}
|
||||||
|
@@ -67,15 +67,17 @@ class sphinx_configuration
|
|||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'sbas' => self::OPT_ALL_SBAS
|
'sbas' => self::OPT_ALL_SBAS
|
||||||
, 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
|
, 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
|
||||||
, 'enable_star' => self::OPT_ENABLE_STAR_ON
|
, 'enable_star' => self::OPT_ENABLE_STAR_ON
|
||||||
, 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
|
, 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
|
||||||
, 'min_infix_len' => self::OPT_MIN_INFIX_LEN
|
, 'min_infix_len' => self::OPT_MIN_INFIX_LEN
|
||||||
, 'charset_tables' => array()
|
, 'charset_tables' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
$options = array_merge($defaults, $options);
|
$options = array_merge($defaults, $options);
|
||||||
|
|
||||||
|
$options['charset_tables'] = array_unique($options['charset_tables']);
|
||||||
|
|
||||||
$lb = phrasea::sbas_params();
|
$lb = phrasea::sbas_params();
|
||||||
|
|
||||||
$conf = '';
|
$conf = '';
|
||||||
@@ -439,7 +441,7 @@ class sphinx_configuration
|
|||||||
path = /var/sphinx/datas/docs_realtime_' . $serialized . '
|
path = /var/sphinx/datas/docs_realtime_' . $serialized . '
|
||||||
|
|
||||||
|
|
||||||
' . $charset_abstract . '
|
' . $charset_abstract . '
|
||||||
|
|
||||||
rt_field = value
|
rt_field = value
|
||||||
# rt_field = meta_struct_id
|
# rt_field = meta_struct_id
|
||||||
@@ -593,6 +595,9 @@ searchd
|
|||||||
# optional, default is 256
|
# optional, default is 256
|
||||||
#
|
#
|
||||||
max_filters = 512
|
max_filters = 512
|
||||||
|
|
||||||
|
compat_sphinxql_magics = 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
';
|
';
|
||||||
|
@@ -81,7 +81,7 @@ class sphinxrt
|
|||||||
if ($rt_id)
|
if ($rt_id)
|
||||||
{
|
{
|
||||||
$this->connection->beginTransaction();
|
$this->connection->beginTransaction();
|
||||||
$sql = "DELETE FROM " . $rt_id . " WHERE id = " . (int) $id . "";
|
$sql = "DELETE FROM " . $rt_id . " WHERE id = " . (int) $id . "";
|
||||||
$stmt = $this->connection->prepare($sql);
|
$stmt = $this->connection->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -99,14 +99,13 @@ class sphinxrt
|
|||||||
$cl = new SphinxClient();
|
$cl = new SphinxClient();
|
||||||
|
|
||||||
if ($cl->Status() === false)
|
if ($cl->Status() === false)
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
|
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
|
||||||
$cl->SetConnectTimeout(1);
|
$cl->SetConnectTimeout(1);
|
||||||
|
|
||||||
|
|
||||||
$status = strrev($status);
|
$status = strrev($status);
|
||||||
$new_stat = array();
|
$new_stat = array();
|
||||||
for ($i = 4; $i < strlen($status); $i++)
|
for ($i = 4; $i < strlen($status); $i++)
|
||||||
{
|
{
|
||||||
@@ -122,20 +121,18 @@ class sphinxrt
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, Array $content, DateTime $created)
|
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, DateTime $created)
|
||||||
{
|
{
|
||||||
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
|
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
|
||||||
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
|
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
|
||||||
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
|
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
|
||||||
$crc_type = crc32($type);
|
$crc_type = crc32($type);
|
||||||
|
|
||||||
$this->connection->beginTransaction();
|
$this->connection->beginTransaction();
|
||||||
|
|
||||||
// foreach ($content as $value)
|
$sql = "REPLACE INTO " . $rt_id . " VALUES (
|
||||||
// {
|
|
||||||
$sql = "REPLACE INTO " . $rt_id . " VALUES (
|
|
||||||
'" . (int) $meta_id . "'
|
'" . (int) $meta_id . "'
|
||||||
,'" . str_replace("'", "\'", implode(' ', $content)) . "'
|
,'" . str_replace("'", "\'", $content) . "'
|
||||||
,'" . (int) $tag_id . "'
|
,'" . (int) $tag_id . "'
|
||||||
," . (int) $record_id . "
|
," . (int) $record_id . "
|
||||||
," . (int) $sbas_id . "
|
," . (int) $sbas_id . "
|
||||||
@@ -149,7 +146,6 @@ class sphinxrt
|
|||||||
," . (int) $created->format('U') . " )";
|
," . (int) $created->format('U') . " )";
|
||||||
$stmt = $this->connection->prepare($sql);
|
$stmt = $this->connection->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
// }
|
|
||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
@@ -160,9 +156,9 @@ class sphinxrt
|
|||||||
|
|
||||||
public function replace_in_documents($rt_id, $record_id, $value, $sbas_id, $coll_id, $grouping, $type, DateTime $created)
|
public function replace_in_documents($rt_id, $record_id, $value, $sbas_id, $coll_id, $grouping, $type, DateTime $created)
|
||||||
{
|
{
|
||||||
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
|
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
|
||||||
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
|
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
|
||||||
$crc_type = crc32($type);
|
$crc_type = crc32($type);
|
||||||
|
|
||||||
$this->connection->beginTransaction();
|
$this->connection->beginTransaction();
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -5160,30 +5160,6 @@
|
|||||||
<default></default>
|
<default></default>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
|
||||||
<name>regdate</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>regname</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>regdesc</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
<field>
|
||||||
<name>report</name>
|
<name>report</name>
|
||||||
<type>tinyint(1) unsigned</type>
|
<type>tinyint(1) unsigned</type>
|
||||||
@@ -5261,27 +5237,6 @@
|
|||||||
<field>required</field>
|
<field>required</field>
|
||||||
</fields>
|
</fields>
|
||||||
</index>
|
</index>
|
||||||
<index>
|
|
||||||
<name>regname</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>regname</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
<index>
|
|
||||||
<name>regdate</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>regdate</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
<index>
|
|
||||||
<name>regdesc</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>regdesc</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
<index>
|
<index>
|
||||||
<name>sorter</name>
|
<name>sorter</name>
|
||||||
<type>UNIQUE</type>
|
<type>UNIQUE</type>
|
||||||
@@ -5826,7 +5781,7 @@
|
|||||||
<field>
|
<field>
|
||||||
<name>results</name>
|
<name>results</name>
|
||||||
<type>int(11) unsigned</type>
|
<type>int(11) unsigned</type>
|
||||||
<null></null>
|
<null>YES</null>
|
||||||
<extra></extra>
|
<extra></extra>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
|
@@ -149,7 +149,7 @@
|
|||||||
<SpecialInstruct src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
<SpecialInstruct src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
||||||
|
|
||||||
<!-- 2:55 -->
|
<!-- 2:55 -->
|
||||||
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" regdate="1" />
|
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" />
|
||||||
|
|
||||||
<!-- 2:80 -->
|
<!-- 2:80 -->
|
||||||
<Byline src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
<Byline src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
||||||
@@ -170,7 +170,7 @@
|
|||||||
<OriginalRef src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
<OriginalRef src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
||||||
|
|
||||||
<!-- 2:105 -->
|
<!-- 2:105 -->
|
||||||
<Headline src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" regname="1" />
|
<Headline src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" />
|
||||||
|
|
||||||
<!-- 2:110 -->
|
<!-- 2:110 -->
|
||||||
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
||||||
|
|
||||||
<!-- 2:120 -->
|
<!-- 2:120 -->
|
||||||
<Caption src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" regdesc="1" />
|
<Caption src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" />
|
||||||
|
|
||||||
<!-- 2:122 -->
|
<!-- 2:122 -->
|
||||||
<CaptionWriter src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
<CaptionWriter src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
||||||
|
@@ -149,7 +149,7 @@
|
|||||||
<Observations src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
<Observations src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
||||||
|
|
||||||
<!-- 2:55 -->
|
<!-- 2:55 -->
|
||||||
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" regdate="1" />
|
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" />
|
||||||
|
|
||||||
<!-- 2:80 -->
|
<!-- 2:80 -->
|
||||||
<Signature src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
<Signature src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
||||||
@@ -170,7 +170,7 @@
|
|||||||
<ReferencesOriginales src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
<ReferencesOriginales src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
||||||
|
|
||||||
<!-- 2:105 -->
|
<!-- 2:105 -->
|
||||||
<Titre src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" regname="1" />
|
<Titre src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" />
|
||||||
|
|
||||||
<!-- 2:110 -->
|
<!-- 2:110 -->
|
||||||
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
||||||
|
|
||||||
<!-- 2:120 -->
|
<!-- 2:120 -->
|
||||||
<Legende src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" regdesc="1" />
|
<Legende src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" />
|
||||||
|
|
||||||
<!-- 2:122 -->
|
<!-- 2:122 -->
|
||||||
<Redacteur src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
<Redacteur src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
syntaxCheck="true"
|
syntaxCheck="true"
|
||||||
verbose="false"
|
verbose="false"
|
||||||
|
bootstrap="unitTest/bootstrap.inc"
|
||||||
>
|
>
|
||||||
<!--
|
<!--
|
||||||
<logging>
|
<logging>
|
||||||
@@ -31,6 +32,13 @@
|
|||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<blacklist>
|
||||||
|
<directory>./vendor</directory>
|
||||||
|
<directory>./unitTest</directory>
|
||||||
|
</blacklist>
|
||||||
|
</filter>
|
||||||
|
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class="SimpleTestListener" file="unitTest/PHPUNITListener.inc"></listener>
|
<listener class="SimpleTestListener" file="unitTest/PHPUNITListener.inc"></listener>
|
||||||
</listeners>
|
</listeners>
|
||||||
|
@@ -363,6 +363,39 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRecordsCaptionRoute()
|
||||||
|
{
|
||||||
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
|
{
|
||||||
|
$databox = databox::get_instance($databox_id);
|
||||||
|
|
||||||
|
$collection = array_shift($databox->get_collections());
|
||||||
|
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
|
||||||
|
|
||||||
|
$record = record_adapter::create($collection, $system_file);
|
||||||
|
|
||||||
|
$record_id = $record->get_record_id();
|
||||||
|
|
||||||
|
$route = '/records/' . $databox_id . '/' . $record_id . '/caption/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
|
||||||
|
$crawler = $this->client->request('GET', $route);
|
||||||
|
$content = json_decode($this->client->getResponse()->getContent());
|
||||||
|
|
||||||
|
$this->evaluateResponse200($this->client->getResponse());
|
||||||
|
$this->evaluateMetaJson200($content);
|
||||||
|
|
||||||
|
$this->evaluateRecordsCaptionResponse($content);
|
||||||
|
$record->delete();
|
||||||
|
}
|
||||||
|
$route = '/records/24892534/51654651553/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateNotFoundRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
$route = '/records/any_bad_id/sfsd5qfsd5/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateBadRequestRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testRecordsMetadatasRoute()
|
public function testRecordsMetadatasRoute()
|
||||||
{
|
{
|
||||||
foreach (static::$databoxe_ids as $databox_id)
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
@@ -654,7 +687,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
{
|
{
|
||||||
if (!in_array($metadata->meta_id, array_keys($toupdate)))
|
if (!in_array($metadata->meta_id, array_keys($toupdate)))
|
||||||
continue;
|
continue;
|
||||||
$saved_value = $toupdate[$metadata->meta_id]['value'][0];
|
$saved_value = $toupdate[$metadata->meta_id]['value'];
|
||||||
$this->assertEquals($saved_value, $metadata->value);
|
$this->assertEquals($saved_value, $metadata->value);
|
||||||
}
|
}
|
||||||
$record->delete();
|
$record->delete();
|
||||||
@@ -1160,6 +1193,20 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function evaluateRecordsCaptionResponse($content)
|
||||||
|
{
|
||||||
|
foreach ($content->response as $field)
|
||||||
|
{
|
||||||
|
$this->assertTrue(is_object($field), 'Un bloc field est un objet');
|
||||||
|
$this->assertObjectHasAttribute('meta_structure_id', $meta);
|
||||||
|
$this->assertTrue(is_int($field->meta_structure_id));
|
||||||
|
$this->assertObjectHasAttribute('name', $field);
|
||||||
|
$this->assertTrue(is_string($meta->name));
|
||||||
|
$this->assertObjectHasAttribute('value', $field);
|
||||||
|
$this->assertTrue(is_string($meta->value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function evaluateRecordsMetadataResponse($content)
|
protected function evaluateRecordsMetadataResponse($content)
|
||||||
{
|
{
|
||||||
$this->assertObjectHasAttribute("metadatas", $content->response);
|
$this->assertObjectHasAttribute("metadatas", $content->response);
|
||||||
|
@@ -369,6 +369,39 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRecordsCaptionRoute()
|
||||||
|
{
|
||||||
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
|
{
|
||||||
|
$databox = databox::get_instance($databox_id);
|
||||||
|
|
||||||
|
$collection = array_shift($databox->get_collections());
|
||||||
|
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
|
||||||
|
|
||||||
|
$record = record_adapter::create($collection, $system_file);
|
||||||
|
|
||||||
|
$record_id = $record->get_record_id();
|
||||||
|
|
||||||
|
$route = '/records/' . $databox_id . '/' . $record_id . '/caption/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
|
||||||
|
$crawler = $this->client->request('GET', $route , array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
|
||||||
|
$content = self::$yaml->parse($this->client->getResponse()->getContent());
|
||||||
|
|
||||||
|
$this->evaluateResponse200($this->client->getResponse());
|
||||||
|
$this->evaluateMetaYaml200($content);
|
||||||
|
|
||||||
|
$this->evaluateRecordsCaptionResponse($content);
|
||||||
|
$record->delete();
|
||||||
|
}
|
||||||
|
$route = '/records/24892534/51654651553/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateNotFoundRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
$route = '/records/any_bad_id/sfsd5qfsd5/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateBadRequestRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testRecordsMetadatasRoute()
|
public function testRecordsMetadatasRoute()
|
||||||
{
|
{
|
||||||
foreach (static::$databoxe_ids as $databox_id)
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
@@ -681,7 +714,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
{
|
{
|
||||||
if (!in_array($metadata["meta_id"], array_keys($toupdate)))
|
if (!in_array($metadata["meta_id"], array_keys($toupdate)))
|
||||||
continue;
|
continue;
|
||||||
$saved_value = $toupdate[$metadata["meta_id"]]['value'][0];
|
$saved_value = $toupdate[$metadata["meta_id"]]['value'];
|
||||||
$this->assertEquals($saved_value, $metadata["value"]);
|
$this->assertEquals($saved_value, $metadata["value"]);
|
||||||
}
|
}
|
||||||
$record->delete();
|
$record->delete();
|
||||||
@@ -1197,6 +1230,20 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function evaluateRecordsCaptionResponse($content)
|
||||||
|
{
|
||||||
|
foreach ($content["response"] as $field)
|
||||||
|
{
|
||||||
|
$this->assertTrue(is_array($field), 'Un bloc field est un objet');
|
||||||
|
$this->assertArrayHasKey('meta_structure_id', $meta);
|
||||||
|
$this->assertTrue(is_int($field["meta_structure_id"]));
|
||||||
|
$this->assertArrayHasKey('name', $field);
|
||||||
|
$this->assertTrue(is_string($meta["name"]));
|
||||||
|
$this->assertArrayHasKey('value', $field);
|
||||||
|
$this->assertTrue(is_string($meta["value"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function evaluateRecordsMetadataResponse($content)
|
protected function evaluateRecordsMetadataResponse($content)
|
||||||
{
|
{
|
||||||
$this->assertArrayHasKey("metadatas", $content["response"]);
|
$this->assertArrayHasKey("metadatas", $content["response"]);
|
||||||
|
@@ -59,9 +59,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'User'
|
, 'vocabulary_' . $id => 'User'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -149,9 +146,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -169,9 +163,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -194,9 +185,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -220,9 +208,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -251,9 +236,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'User'
|
, 'vocabulary_' . $id => 'User'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
$this->assertTrue($this->client->getResponse()->isOk());
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
$this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
|
$this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
|
||||||
|
@@ -461,6 +461,74 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->assertEquals(2, $basket->getElements()->count());
|
$this->assertEquals(2, $basket->getElements()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testAddElementToValidationPost()
|
||||||
|
{
|
||||||
|
|
||||||
|
$em = self::$core->getEntityManager();
|
||||||
|
|
||||||
|
$datas = $em->getRepository('Entities\ValidationData')->findAll();
|
||||||
|
$countDatas = count($datas);
|
||||||
|
|
||||||
|
$validationSession = new \Entities\ValidationSession();
|
||||||
|
|
||||||
|
$validationSession->setDescription('Une description au hasard');
|
||||||
|
$validationSession->setName('Un nom de validation');
|
||||||
|
$expires = new \DateTime();
|
||||||
|
$expires->modify('+1 week');
|
||||||
|
$validationSession->setExpires($expires);
|
||||||
|
$validationSession->setInitiator(self::$user);
|
||||||
|
|
||||||
|
$basket = new \Entities\Basket();
|
||||||
|
$basket->setName('test');
|
||||||
|
$basket->setDescription('description');
|
||||||
|
$basket->setOwner(self::$user);
|
||||||
|
$basket->setValidation($validationSession);
|
||||||
|
$validationSession->setBasket($basket);
|
||||||
|
|
||||||
|
|
||||||
|
$validationParticipant = new \Entities\ValidationParticipant();
|
||||||
|
$validationParticipant->setSession($validationSession);
|
||||||
|
$validationParticipant->setUser(self::$user_alt1);
|
||||||
|
$validationSession->addValidationParticipant($validationParticipant);
|
||||||
|
|
||||||
|
$em->persist($validationParticipant);
|
||||||
|
$em->persist($basket);
|
||||||
|
$em->persist($validationSession);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$route = sprintf('/baskets/%s/addElements/', $basket->getId());
|
||||||
|
|
||||||
|
$records = array(
|
||||||
|
self::$record_1->get_serialize_key(),
|
||||||
|
self::$record_2->get_serialize_key(),
|
||||||
|
' ',
|
||||||
|
'42',
|
||||||
|
'abhak',
|
||||||
|
self::$record_no_access->get_serialize_key(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$lst = implode(';', $records);
|
||||||
|
|
||||||
|
$this->client->request('POST', $route, array('lst' => $lst));
|
||||||
|
|
||||||
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
|
$this->assertEquals(302, $response->getStatusCode());
|
||||||
|
|
||||||
|
$em = self::$core->getEntityManager();
|
||||||
|
/* @var $em \Doctrine\ORM\EntityManager */
|
||||||
|
$basket = $em->getRepository('Entities\Basket')->find($basket->getId());
|
||||||
|
|
||||||
|
$this->assertEquals(2, $basket->getElements()->count());
|
||||||
|
|
||||||
|
$datas = $em->getRepository('Entities\ValidationData')->findAll();
|
||||||
|
|
||||||
|
$this->assertTrue($countDatas < count($datas), 'assert that '.count($datas).' > '.$countDatas );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testAddElementPostJSON()
|
public function testAddElementPostJSON()
|
||||||
{
|
{
|
||||||
$basket = $this->insertOneBasket();
|
$basket = $this->insertOneBasket();
|
||||||
|
@@ -50,7 +50,7 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
if(self::$api instanceof Bridge_Api)
|
if (self::$api instanceof Bridge_Api)
|
||||||
self::$api->delete();
|
self::$api->delete();
|
||||||
if (self::$account instanceof Bridge_Account)
|
if (self::$account instanceof Bridge_Account)
|
||||||
self::$account->delete();
|
self::$account->delete();
|
||||||
@@ -163,15 +163,6 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
|
self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLogoutDeconnected()
|
|
||||||
{
|
|
||||||
$url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
|
|
||||||
$crawler = $this->client->request('GET', $url);
|
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
|
||||||
$this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
|
|
||||||
$this->deconnected($crawler, $pageContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLogout()
|
public function testLogout()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
||||||
@@ -192,16 +183,6 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
|
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadElementsDisconnected()
|
|
||||||
{
|
|
||||||
$url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
|
||||||
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
|
||||||
$this->assertTrue($this->client->getResponse()->isOk());
|
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
|
||||||
$this->assertContains($url, $pageContent);
|
|
||||||
$this->deconnected($crawler, $pageContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLoadRecords()
|
public function testLoadRecords()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
||||||
@@ -215,7 +196,8 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testLoadRecordsDisconnected()
|
public function testLoadRecordsDisconnected()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", null);//deconnected
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
$url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
|
$url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
|
||||||
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
@@ -235,7 +217,8 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testLoadContainersDisconnected()
|
public function testLoadContainersDisconnected()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", null);//deconnected
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
$url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
|
$url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
|
||||||
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
@@ -243,9 +226,33 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->deconnected($crawler, $pageContent);
|
$this->deconnected($crawler, $pageContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoadElementsDisconnected()
|
||||||
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
|
$url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
||||||
|
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
||||||
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
|
$this->assertContains($url, $pageContent);
|
||||||
|
$this->deconnected($crawler, $pageContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLogoutDeconnected()
|
||||||
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
|
$url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
|
||||||
|
$crawler = $this->client->request('GET', $url);
|
||||||
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
|
$this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
|
||||||
|
$this->deconnected($crawler, $pageContent);
|
||||||
|
}
|
||||||
|
|
||||||
public function testActionDeconnected()
|
public function testActionDeconnected()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", null);//deconnected
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
$url = sprintf("/bridge/action/%s/une action/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
$url = sprintf("/bridge/action/%s/une action/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
||||||
$crawler = $this->client->request('GET', $url);
|
$crawler = $this->client->request('GET', $url);
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
|
@@ -33,7 +33,7 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
*
|
*
|
||||||
* @var \record_adapter
|
* @var \record_adapter
|
||||||
*/
|
*/
|
||||||
protected static $need_story = true;
|
protected static $need_story = true;
|
||||||
protected static $need_records = 2;
|
protected static $need_records = 2;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
@@ -53,16 +53,16 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$route = "/story/";
|
$route = "/story/";
|
||||||
|
|
||||||
$collections = self::$core->getAuthenticatedUser()
|
$collections = self::$core->getAuthenticatedUser()
|
||||||
->ACL()
|
->ACL()
|
||||||
->get_granted_base(array('canaddrecord'));
|
->get_granted_base(array('canaddrecord'));
|
||||||
|
|
||||||
$collection = array_shift($collections);
|
$collection = array_shift($collections);
|
||||||
|
|
||||||
$crawler = $this->client->request(
|
$crawler = $this->client->request(
|
||||||
'POST', $route, array(
|
'POST', $route, array(
|
||||||
'base_id' => $collection->get_base_id(),
|
'base_id' => $collection->get_base_id(),
|
||||||
'name' => 'test story',
|
'name' => 'test story'
|
||||||
'description' => 'test_description')
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
@@ -70,7 +70,7 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->assertEquals(302, $response->getStatusCode());
|
$this->assertEquals(302, $response->getStatusCode());
|
||||||
|
|
||||||
$query = self::$core->getEntityManager()->createQuery(
|
$query = self::$core->getEntityManager()->createQuery(
|
||||||
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
|
'SELECT COUNT(w.id) FROM \Entities\StoryWZ w'
|
||||||
);
|
);
|
||||||
|
|
||||||
$count = $query->getSingleScalarResult();
|
$count = $query->getSingleScalarResult();
|
||||||
@@ -83,17 +83,16 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$route = "/story/";
|
$route = "/story/";
|
||||||
|
|
||||||
$collections = self::$core->getAuthenticatedUser()
|
$collections = self::$core->getAuthenticatedUser()
|
||||||
->ACL()
|
->ACL()
|
||||||
->get_granted_base(array('canaddrecord'));
|
->get_granted_base(array('canaddrecord'));
|
||||||
|
|
||||||
$collection = array_shift($collections);
|
$collection = array_shift($collections);
|
||||||
|
|
||||||
$crawler = $this->client->request(
|
$crawler = $this->client->request(
|
||||||
'POST', $route, array(
|
'POST', $route, array(
|
||||||
'base_id' => $collection->get_base_id(),
|
'base_id' => $collection->get_base_id(),
|
||||||
'name' => 'test story',
|
'name' => 'test story'), array(), array(
|
||||||
'description' => 'test_description'), array(), array(
|
"HTTP_ACCEPT" => "application/json")
|
||||||
"HTTP_ACCEPT" => "application/json")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
@@ -117,9 +116,6 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$filter = "form[action='/prod/story/'] input[name='name']";
|
$filter = "form[action='/prod/story/'] input[name='name']";
|
||||||
$this->assertEquals(1, $crawler->filter($filter)->count());
|
$this->assertEquals(1, $crawler->filter($filter)->count());
|
||||||
|
|
||||||
$filter = "form[action='/prod/story/'] textarea[name='description']";
|
|
||||||
$this->assertEquals(1, $crawler->filter($filter)->count());
|
|
||||||
|
|
||||||
$filter = "form[action='/prod/story/'] select[name='base_id']";
|
$filter = "form[action='/prod/story/'] select[name='base_id']";
|
||||||
$this->assertEquals(1, $crawler->filter($filter)->count());
|
$this->assertEquals(1, $crawler->filter($filter)->count());
|
||||||
}
|
}
|
||||||
@@ -144,8 +140,8 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
|
$route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
|
||||||
|
|
||||||
$records = array(
|
$records = array(
|
||||||
self::$record_1->get_serialize_key(),
|
self::$record_1->get_serialize_key(),
|
||||||
self::$record_2->get_serialize_key()
|
self::$record_2->get_serialize_key()
|
||||||
);
|
);
|
||||||
|
|
||||||
$lst = implode(';', $records);
|
$lst = implode(';', $records);
|
||||||
@@ -166,15 +162,15 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
|
$route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
|
||||||
|
|
||||||
$records = array(
|
$records = array(
|
||||||
self::$record_1->get_serialize_key(),
|
self::$record_1->get_serialize_key(),
|
||||||
self::$record_2->get_serialize_key()
|
self::$record_2->get_serialize_key()
|
||||||
);
|
);
|
||||||
|
|
||||||
$lst = implode(';', $records);
|
$lst = implode(';', $records);
|
||||||
|
|
||||||
$crawler = $this->client->request('POST', $route, array('lst' => $lst)
|
$crawler = $this->client->request('POST', $route, array('lst' => $lst)
|
||||||
, array(), array(
|
, array(), array(
|
||||||
"HTTP_ACCEPT" => "application/json"));
|
"HTTP_ACCEPT" => "application/json"));
|
||||||
|
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
@@ -188,21 +184,21 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$story = self::$story_1;
|
$story = self::$story_1;
|
||||||
|
|
||||||
$records = array(
|
$records = array(
|
||||||
self::$record_1,
|
self::$record_1,
|
||||||
self::$record_2
|
self::$record_2
|
||||||
);
|
);
|
||||||
|
|
||||||
$totalRecords = count($records);
|
$totalRecords = count($records);
|
||||||
$n = 0;
|
$n = 0;
|
||||||
foreach ($records as $record)
|
foreach ($records as $record)
|
||||||
{
|
{
|
||||||
/* @var $record \record_adapter */
|
/* @var $record \record_adapter */
|
||||||
$route = sprintf(
|
$route = sprintf(
|
||||||
"/story/%s/%s/delete/%s/%s/"
|
"/story/%s/%s/delete/%s/%s/"
|
||||||
, $story->get_sbas_id()
|
, $story->get_sbas_id()
|
||||||
, $story->get_record_id()
|
, $story->get_record_id()
|
||||||
, $record->get_sbas_id()
|
, $record->get_sbas_id()
|
||||||
, $record->get_record_id()
|
, $record->get_record_id()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (($n % 2) === 0)
|
if (($n % 2) === 0)
|
||||||
@@ -216,10 +212,10 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$crawler = $this->client->request(
|
$crawler = $this->client->request(
|
||||||
'POST', $route, array(), array(), array(
|
'POST', $route, array(), array(), array(
|
||||||
"HTTP_ACCEPT" => "application/json")
|
"HTTP_ACCEPT" => "application/json")
|
||||||
);
|
);
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
@@ -229,7 +225,4 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Alchemy\Phrasea\Controller\Setup as Controller;
|
use Alchemy\Phrasea\Controller\Setup as Controller;
|
||||||
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../../bootstrap.php';
|
|
||||||
|
|
||||||
return call_user_func(function()
|
return call_user_func(function()
|
||||||
{
|
{
|
||||||
|
@@ -7,7 +7,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Alchemy\Phrasea\Controller\Setup as Controller;
|
use Alchemy\Phrasea\Controller\Setup as Controller;
|
||||||
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../../bootstrap.php';
|
|
||||||
|
|
||||||
return call_user_func(function()
|
return call_user_func(function()
|
||||||
{
|
{
|
||||||
|
@@ -27,14 +27,12 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
"debug" => false
|
"debug" => false
|
||||||
, "log" => array('service'=>"Log\\sql_logger")
|
, "log" => array('service' => "Log\\sql_logger")
|
||||||
, "dbal" => "main_connexion"
|
, "dbal" => "main_connexion"
|
||||||
, "orm" => array(
|
, "cache" => array(
|
||||||
"cache" => array(
|
"metadata" => array('service' => "Cache\\array_cache")
|
||||||
"metadata" => array('service'=>"Cache\\array_cache")
|
, "query" => array('service' => "Cache\\array_cache")
|
||||||
, "query" => array('service'=>"Cache\\array_cache")
|
, "result" => array('service' => "Cache\\array_cache")
|
||||||
, "result" => array('service'=>"Cache\\array_cache")
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -83,7 +81,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testNoCacheInOptions()
|
public function testNoCacheInOptions()
|
||||||
{
|
{
|
||||||
unset($this->options["orm"]["cache"]);
|
unset($this->options["cache"]);
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||||
self::$core, 'hello', $this->options
|
self::$core, 'hello', $this->options
|
||||||
);
|
);
|
||||||
@@ -96,7 +94,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testUnknowCache()
|
public function testUnknowCache()
|
||||||
{
|
{
|
||||||
$this->options["orm"]["cache"]["result"] = "unknowCache";
|
$this->options["cache"]["result"] = "unknowCache";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
|
||||||
|
|
||||||
$include_path = realpath(__DIR__ . '/../../vendor/');
|
$include_path = realpath(__DIR__ . '/../../vendor/');
|
||||||
if(strpos(get_include_path(), $include_path) === false)
|
if(strpos(get_include_path(), $include_path) === false)
|
||||||
|
@@ -23,7 +23,7 @@ use Doctrine\Common\DataFixtures\Loader;
|
|||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bootstrap::execute('test');
|
\bootstrap::register_autoloads();
|
||||||
|
|
||||||
|
|
||||||
abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||||
@@ -483,7 +483,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
//create a new core instance loaded with the test environment for each test
|
//create a new core instance loaded with the test environment for each test
|
||||||
self::$core = new \Alchemy\Phrasea\Core('test');
|
self::$core = \bootstrap::execute('test');
|
||||||
|
//$this->app['EM'] = self::$core->getEntityManager();
|
||||||
//set Mozilla user agent as default
|
//set Mozilla user agent as default
|
||||||
$browser = Browser::getInstance();
|
$browser = Browser::getInstance();
|
||||||
$browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
|
$browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
|
||||||
|
@@ -8,14 +8,13 @@
|
|||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
namespace Events\Processor\Factory;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @return \Alchemy\Phrasea\Core
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class Exception extends \Exception
|
require_once dirname(__FILE__) . '/../classes/bootstrap.class.php';
|
||||||
{
|
|
||||||
|
|
||||||
}
|
return bootstrap::execute('test');
|
@@ -300,72 +300,6 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_regdate().
|
|
||||||
*/
|
|
||||||
public function testSet_regdate()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_regdesc().
|
|
||||||
*/
|
|
||||||
public function testSet_regdesc()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_regname().
|
|
||||||
*/
|
|
||||||
public function testSet_regname()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIs_regname().
|
|
||||||
*/
|
|
||||||
public function testIs_regname()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIs_regdesc().
|
|
||||||
*/
|
|
||||||
public function testIs_regdesc()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIs_regdate().
|
|
||||||
*/
|
|
||||||
public function testIs_regdate()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Implement testGet_thumbtitle().
|
* @todo Implement testGet_thumbtitle().
|
||||||
*/
|
*/
|
||||||
|
@@ -468,11 +468,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet_reg_name()
|
|
||||||
{
|
|
||||||
$this->assertTrue(is_string(self::$story_1->get_reg_name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGet_record_by_sha()
|
public function testGet_record_by_sha()
|
||||||
{
|
{
|
||||||
$tmp_records = record_adapter::get_record_by_sha(self::$record_1->get_sbas_id(), self::$record_1->get_sha256());
|
$tmp_records = record_adapter::get_record_by_sha(self::$record_1->get_sbas_id(), self::$record_1->get_sha256());
|
||||||
|
2
lib/vendor/doctrine2-orm
vendored
2
lib/vendor/doctrine2-orm
vendored
Submodule lib/vendor/doctrine2-orm updated: 0e107880cf...3e7c9a1ff4
2
lib/vendor/sphinx
vendored
2
lib/vendor/sphinx
vendored
Submodule lib/vendor/sphinx updated: 3435431efe...4e878fa9c7
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user