diff --git a/README.md b/README.md index 99d1b6e858..9d5cde124d 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,12 @@ Phraseanet 3.5 - Digital Asset Management application Metadatas Management (include Thesaurus and DublinCore Mapping) 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 #Documentation : -http://docs.phraseanet.com +https://docs.phraseanet.com/3.6/ #Easy Installation diff --git a/bin/console b/bin/console index 0671e9eab0..a4002e4ebc 100755 --- a/bin/console +++ b/bin/console @@ -64,6 +64,7 @@ try $app->add(new module_console_schedulerStart('scheduler:start')); $app->add(new module_console_fileConfigCheck('check:config')); $app->add(new module_console_fileEnsureProductionSetting('check:ensureProductionSettings')); + $app->add(new module_console_fileEnsureDevSetting('check:ensureDevSettings')); $app->add(new module_console_systemConfigCheck('check:system')); $result_code = $app->run(); } diff --git a/bin/doctrine b/bin/doctrine index 268b9be6ed..e595ff2e0d 100755 --- a/bin/doctrine +++ b/bin/doctrine @@ -29,11 +29,7 @@ bootstrap::register_autoloads(); try { - $handler = new \Alchemy\Phrasea\Core\Configuration\Handler( - new \Alchemy\Phrasea\Core\Configuration\Application(), - new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml() - ); - $configuration = new \Alchemy\Phrasea\Core\Configuration($handler); + $configuration = \Alchemy\Phrasea\Core\Configuration::build(); $serviceName = $configuration->getOrm(); $confService = $configuration->getService($serviceName); diff --git a/config/config.sample.yml b/config/config.sample.yml index 298c3d8851..21fd501fbf 100644 --- a/config/config.sample.yml +++ b/config/config.sample.yml @@ -41,8 +41,8 @@ prod: template_engine: twig orm: doctrine_prod - cache: memcache_cache - opcodecache: apc_cache + cache: array_cache + opcodecache: array_cache ############## # TEST # diff --git a/config/services.sample.yml b/config/services.sample.yml index 8a67682467..ad315a3f3c 100644 --- a/config/services.sample.yml +++ b/config/services.sample.yml @@ -52,11 +52,11 @@ Orm: dbal: main_connexion cache: query: - service: Cache\apc_cache + service: Cache\array_cache result: - service: Cache\memcache_cache + service: Cache\array_cache metadata: - service: Cache\apc_cache + service: Cache\array_cache TemplateEngine: #Define a template engine service diff --git a/hudson/testJS.sh b/hudson/testJS.sh index 66b751d2d3..2d61299367 100755 --- a/hudson/testJS.sh +++ b/hudson/testJS.sh @@ -38,7 +38,7 @@ echo "ok !"; # Valid link ? 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 ] then echo "Link does not exists."; @@ -60,10 +60,11 @@ do echo "nok !"; cat /tmp/jsunitphantom; testOK=1; + else + echo "ok !"; fi echo ""; echo ""; - echo ""; done exit $testOK; diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index cc80d392b3..64696fdfac 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -315,6 +315,19 @@ return call_user_func(function() return $app['response']($result); } ); + + + $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); /** diff --git a/lib/Alchemy/Phrasea/Application/Lightbox.php b/lib/Alchemy/Phrasea/Application/Lightbox.php index caf0a34e6d..fd67182353 100644 --- a/lib/Alchemy/Phrasea/Application/Lightbox.php +++ b/lib/Alchemy/Phrasea/Application/Lightbox.php @@ -232,7 +232,7 @@ return call_user_func( $repository = $em->getRepository('\Entities\Basket'); /* @var $repository \Repositories\BasketRepository */ - $basket_collection = $repository->findActiveByUser( + $basket_collection = $repository->findActiveValidationAndBasketByUser( $app['Core']->getAuthenticatedUser() ); @@ -290,10 +290,10 @@ return call_user_func( $repository = $em->getRepository('\Entities\Basket'); /* @var $repository \Repositories\BasketRepository */ - $basket_collection = $repository->findActiveByUser( + $basket_collection = $repository->findActiveValidationAndBasketByUser( $app['Core']->getAuthenticatedUser() ); - + $basket = $repository->findUserBasket( $ssel_id , $app['Core']->getAuthenticatedUser() diff --git a/lib/Alchemy/Phrasea/Cache/ApcCache.php b/lib/Alchemy/Phrasea/Cache/ApcCache.php index ca20934668..64bc65b742 100644 --- a/lib/Alchemy/Phrasea/Cache/ApcCache.php +++ b/lib/Alchemy/Phrasea/Cache/ApcCache.php @@ -52,4 +52,9 @@ class ApcCache extends DoctrineApc implements Cache return $this; } + public function flush() + { + return apc_clear_cache() && apc_clear_cache('user'); + } + } \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Cache/ArrayCache.php b/lib/Alchemy/Phrasea/Cache/ArrayCache.php index a01e9bfb36..c5f45834ea 100644 --- a/lib/Alchemy/Phrasea/Cache/ArrayCache.php +++ b/lib/Alchemy/Phrasea/Cache/ArrayCache.php @@ -53,4 +53,11 @@ class ArrayCache extends DoctrineArray implements Cache return; } + public function flush() + { + $this->deleteAll(); + + return true; + } + } \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Cache/Cache.php b/lib/Alchemy/Phrasea/Cache/Cache.php index cd19553f6a..810260a4f8 100644 --- a/lib/Alchemy/Phrasea/Cache/Cache.php +++ b/lib/Alchemy/Phrasea/Cache/Cache.php @@ -26,6 +26,8 @@ interface Cache extends DoctrineCache public function getStats(); + public function flush(); + public function get($key); public function deleteMulti(array $array_keys); diff --git a/lib/Alchemy/Phrasea/Cache/Manager.php b/lib/Alchemy/Phrasea/Cache/Manager.php index 467e2def09..06d72e2233 100644 --- a/lib/Alchemy/Phrasea/Cache/Manager.php +++ b/lib/Alchemy/Phrasea/Cache/Manager.php @@ -60,7 +60,7 @@ class Manager { foreach ($this->registry as $cacheKey => $service_name) { - $this->get($cacheKey, $service_name)->getDriver()->deleteAll(); + $this->get($cacheKey, $service_name)->getDriver()->flush(); } return $this; @@ -71,22 +71,25 @@ class Manager try { $configuration = $this->core->getConfiguration()->getService($service_name); + $service = Builder::create($this->core, $service_name, $configuration); + $driver = $service->getDriver(); $write = true; } catch (\Exception $e) { $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; } - $service = Builder::create($this->core, $service_name, $configuration); - if ($this->hasChange($cacheKey, $service_name)) { - $service->getDriver()->deleteAll(); - if($write) + $driver->flush(); + + if ($write) { $this->registry[$cacheKey] = $service_name; $this->save($cacheKey, $service_name); @@ -108,7 +111,7 @@ class Manager $this->registry[$name] = $driver; $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); } diff --git a/lib/Alchemy/Phrasea/Cache/MemcacheCache.php b/lib/Alchemy/Phrasea/Cache/MemcacheCache.php index 1d81e5e9b8..c3de20998f 100644 --- a/lib/Alchemy/Phrasea/Cache/MemcacheCache.php +++ b/lib/Alchemy/Phrasea/Cache/MemcacheCache.php @@ -52,4 +52,9 @@ class MemcacheCache extends DoctrineMemcache implements Cache return $this; } + public function flush() + { + return $this->getMemcache()->flush(); + } + } \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Cache/RedisCache.php b/lib/Alchemy/Phrasea/Cache/RedisCache.php index b30b49e3c5..c3234a9940 100644 --- a/lib/Alchemy/Phrasea/Cache/RedisCache.php +++ b/lib/Alchemy/Phrasea/Cache/RedisCache.php @@ -23,7 +23,7 @@ class RedisCache extends AbstractCache implements Cache { /** - * @var Memcache + * @var \Redis */ private $_redis; @@ -124,4 +124,9 @@ class RedisCache extends AbstractCache implements Cache return $this; } + public function flush() + { + return $this->_redis->flushAll(); + } + } diff --git a/lib/Alchemy/Phrasea/Cache/XcacheCache.php b/lib/Alchemy/Phrasea/Cache/XcacheCache.php index c8c4145629..dce9e3412f 100644 --- a/lib/Alchemy/Phrasea/Cache/XcacheCache.php +++ b/lib/Alchemy/Phrasea/Cache/XcacheCache.php @@ -52,4 +52,9 @@ class XcacheCache extends DoctrineXcache implements Cache return $this; } + public function flush() + { + return xcache_clear_cache(XC_TYPE_VAR, 0); + } + } \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Description.php b/lib/Alchemy/Phrasea/Controller/Admin/Description.php index c01601ffcb..53944dcdac 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Description.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Description.php @@ -99,18 +99,6 @@ class Description implements ControllerProviderInterface $field->set_dces_element($dces_element); $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) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php index d2dc2e5f78..014066d9ac 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php @@ -412,11 +412,29 @@ class Basket implements ControllerProviderInterface $em->persist($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++; } - $em->merge($basket); $em->flush(); $data = array( diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index 5cd9c0b497..52c83931e2 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -183,10 +183,12 @@ class Push implements ControllerProviderInterface $appbox = \appbox::get_instance($app['Core']); - $push_name = $request->get( - 'name' - , sprintf(_('Push from %s'), $user->get_display_name()) - ); + $push_name = $request->get('name'); + + if (trim($push_name) === '') + { + $push_name = sprintf(_('Push from %s'), $user->get_display_name()); + } $push_description = $request->get('push_description'); @@ -322,10 +324,12 @@ class Push implements ControllerProviderInterface $repository = $em->getRepository('\Entities\Basket'); - $validation_name = $request->get( - 'name' - , sprintf(_('Validation from %s'), $user->get_display_name()) - ); + $validation_name = $request->get('name'); + + if (trim($validation_name) === '') + { + $validation_name = sprintf(_('Validation from %s'), $user->get_display_name()); + } $validation_description = $request->get('validation_description'); @@ -759,7 +763,7 @@ class Push implements ControllerProviderInterface { $query->havePositions($request->get('Position')); } - + $sort = $request->get('srt', 'usr_creationdate'); $ord = $request->get('ord', 'desc'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index b631e76e57..c43e56f6ee 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -205,11 +205,9 @@ class Query implements ControllerProviderInterface } } - $json['results'] = $twig->render($template, array( 'results' => $result, 'GV_social_tools' => $registry->get('GV_social_tools'), - 'array_selected' => explode(';', $request->get('sel')), 'highlight' => $search_engine->get_query(), 'searchEngine' => $search_engine, 'suggestions' => $prop diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index c227378d88..f9fb355df8 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request, Symfony\Component\HttpFoundation\Response, Symfony\Component\HttpFoundation\RedirectResponse, Symfony\Component\HttpKernel\Exception\HttpException, + Symfony\Component\Finder\Finder, Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Alchemy\Phrasea\Helper; @@ -40,49 +41,56 @@ class Root implements ControllerProviderInterface \User_Adapter::updateClientInfos(1); $appbox = \appbox::get_instance($app['Core']); + $registry = $app['Core']->getRegistry(); + $user = $app['Core']->getAuthenticatedUser(); + $cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/'; + $css = array(); $cssfile = false; - $registry = $app['Core']->getRegistry(); - $session = $appbox->get_session(); - $user = $app['Core']->getAuthenticatedUser(); + $finder = new Finder(); - $cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/'; + $iterator = $finder + ->directories() + ->depth(0) + ->filter(function(\SplFileInfo $fileinfo) + { + return ctype_xdigit($fileinfo->getBasename()); + }) + ->in($cssPath); - if ($hdir = opendir($cssPath)) + foreach ($iterator as $dir) { - while (false !== ($file = readdir($hdir))) - { - if (substr($file, 0, 1) == "." || mb_strtolower($file) == "cvs") - continue; - if (is_dir($cssPath . $file)) - { - $css[$file] = $file; - } - } - closedir($hdir); + $baseName = $dir->getBaseName(); + $css[$baseName] = $baseName; } $cssfile = $user->getPrefs('css'); + if (!$cssfile && isset($css['000000'])) + { $cssfile = '000000'; + } $user_feeds = \Feed_Collection::load_all($appbox, $user); $feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds()); - $srt = 'name asc'; - - $thjslist = ""; $queries_topics = ''; + 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') + { $queries_topics = \queries::tree_topics(); + } $sbas = $bas2sbas = array(); + foreach ($appbox->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); @@ -131,8 +139,6 @@ class Root implements ControllerProviderInterface 'GV_bitly_key' => $registry->get('GV_bitly_key') )); - - return new Response($out); }); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Story.php b/lib/Alchemy/Phrasea/Controller/Prod/Story.php index 6e31a2b06b..1aa7099fcd 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Story.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Story.php @@ -38,282 +38,311 @@ class Story implements ControllerProviderInterface $controllers->get('/create/', function(Application $app) - { - /* @var $twig \Twig_Environment */ - $twig = $app['Core']->getTwig(); + { + /* @var $twig \Twig_Environment */ + $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) - { - /* @var $request \Symfony\Component\HttpFoundation\Request */ - $em = $app['Core']->getEntityManager(); + { + /* @var $request \Symfony\Component\HttpFoundation\Request */ + $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')) - throw new \Exception_Forbidden('You can not create a story on this collection'); + 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'); + } - $system_file = new \system_file( - $app['Core']->getRegistry() - ->get('GV_RootPath') . 'www/skins/icons/substitution/regroup_doc.png' - ); + $system_file = new \system_file( + $app['Core']->getRegistry() + ->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 ($meta->is_regname()) - $value = $request->get('name'); - elseif ($meta->is_regdesc()) - $value = $request->get('description'); - else - continue; + if (count($sbas_rec) !== 2) + { + continue; + } - $metadatas[] = array( - 'meta_struct_id' => $meta->get_id() - , 'meta_id' => null - , 'value' => $value - ); - } + $record = new \record_adapter($sbas_rec[0], $sbas_rec[1]); - $Story->set_metadatas($metadatas) - ->rebuild_subdefs(); + if (!$user->ACL()->has_access_to_base($record->get_base_id()) + && !$user->ACL()->has_hd_grant($record) + && !$user->ACL()->has_preview_grant($record)) + { + continue; + } - $StoryWZ = new \Entities\StoryWZ(); - $StoryWZ->setUser($user); - $StoryWZ->setRecord($Story); + if ($Story->hasChild($record)) + continue; - $em->persist($StoryWZ); + $Story->appendChild($record); + } - $em->flush(); + $metadatas = array(); - 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(), - ) - ); + foreach ($collection->get_databox()->get_meta_structure() as $meta) + { + if ($meta->get_thumbtitle()) + { + $value = $request->get('name'); + } + else + { + continue; + } - $datas = $app['Core']['Serializer']->serialize($data, 'json'); + $metadatas[] = array( + 'meta_struct_id' => $meta->get_id() + , 'meta_id' => null + , 'value' => $value + ); + + break; + } - return new Response($datas, 200, array('Content-type' => 'application/json')); - } - else - { - return new RedirectResponse(sprintf('/%d/', $StoryWZ->getId())); - } - }); + $Story->set_metadatas($metadatas)->rebuild_subdefs(); + + $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) - { - $Story = new \record_adapter($sbas_id, $record_id); + { + $Story = new \record_adapter($sbas_id, $record_id); - /* @var $twig \Twig_Environment */ - $twig = $app['Core']->getTwig(); + /* @var $twig \Twig_Environment */ + $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); - })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); + return new Response($html); + })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); $controllers->post( - '/{sbas_id}/{record_id}/addElements/' - , function(Application $app, Request $request, $sbas_id, $record_id) - { - $Story = new \record_adapter($sbas_id, $record_id); + '/{sbas_id}/{record_id}/addElements/' + , function(Application $app, Request $request, $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')) - throw new \Exception_Forbidden('You can not add document to this Story'); + if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) + 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) - { - $sbas_rec = explode('_', $sbas_rec); + foreach (explode(';', $request->get('lst')) as $sbas_rec) + { + $sbas_rec = explode('_', $sbas_rec); - if (count($sbas_rec) !== 2) - continue; + if (count($sbas_rec) !== 2) + 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()) - && !$user->ACL()->has_hd_grant($record) - && !$user->ACL()->has_preview_grant($record)) - { - continue; - } + if (!$user->ACL()->has_access_to_base($record->get_base_id()) + && !$user->ACL()->has_hd_grant($record) + && !$user->ACL()->has_preview_grant($record)) + { + continue; + } - if ($Story->hasChild($record)) - continue; + if ($Story->hasChild($record)) + continue; - $Story->appendChild($record); + $Story->appendChild($record); - $n++; - } + $n++; + } - $data = array( - 'success' => true - , 'message' => sprintf(_('%d records added'), $n) - ); + $data = array( + 'success' => true + , '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')); - } - else - { - return new RedirectResponse('/'); - } - })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); + return new Response($datas, 200, array('Content-type' => 'application/json')); + } + else + { + return new RedirectResponse('/'); + } + })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); $controllers->post( - '/{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) - { - $Story = new \record_adapter($sbas_id, $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) + { + $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')) - throw new \Exception_Forbidden('You can not add document to this Story'); + if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) + 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( - 'success' => true - , 'message' => _('Record removed from story') - ); + $data = array( + 'success' => true + , 'message' => _('Record removed from story') + ); - if ($request->getRequestFormat() == 'json') - { - $datas = $app['Core']['Serializer']->serialize($data, 'json'); + if ($request->getRequestFormat() == 'json') + { + $datas = $app['Core']['Serializer']->serialize($data, 'json'); - return new Response($datas, 200, array('Content-type' => 'application/json')); - } - else - { - return new RedirectResponse('/'); - } - }) - ->assert('sbas_id', '\d+') - ->assert('record_id', '\d+') - ->assert('child_sbas_id', '\d+') - ->assert('child_record_id', '\d+'); + return new Response($datas, 200, array('Content-type' => 'application/json')); + } + else + { + return new RedirectResponse('/'); + } + }) + ->assert('sbas_id', '\d+') + ->assert('record_id', '\d+') + ->assert('child_sbas_id', '\d+') + ->assert('child_record_id', '\d+'); /** * Get the Basket reorder form */ $controllers->get( - '/{sbas_id}/{record_id}/reorder/' - , function(Application $app, $sbas_id, $record_id) - { - /* @var $em \Doctrine\ORM\EntityManager */ - $em = $app['Core']->getEntityManager(); + '/{sbas_id}/{record_id}/reorder/' + , function(Application $app, $sbas_id, $record_id) + { + /* @var $em \Doctrine\ORM\EntityManager */ + $em = $app['Core']->getEntityManager(); - $story = new \record_adapter($sbas_id, $record_id); + $story = new \record_adapter($sbas_id, $record_id); - if (!$story->is_grouping()) - { - throw new \Exception('This is not a story'); - } + if (!$story->is_grouping()) + { + throw new \Exception('This is not a story'); + } - /* @var $twig \Twig_Environment */ - $twig = $app['Core']->getTwig(); + /* @var $twig \Twig_Environment */ + $twig = $app['Core']->getTwig(); - return new Response( - $twig->render( - 'prod/Story/Reorder.html.twig' - , array('story' => $story) - ) - ); - }) - ->assert('sbas_id', '\d+') - ->assert('record_id', '\d+'); + return new Response( + $twig->render( + 'prod/Story/Reorder.html.twig' + , array('story' => $story) + ) + ); + }) + ->assert('sbas_id', '\d+') + ->assert('record_id', '\d+'); $controllers->post( - '/{sbas_id}/{record_id}/reorder/' - , function(Application $app, $sbas_id, $record_id) - { - $ret = array('success' => false, 'message' => _('An error occured')); - try - { - $user = $app['Core']->getAuthenticatedUser(); - /* @var $user \User_Adapter */ + '/{sbas_id}/{record_id}/reorder/' + , function(Application $app, $sbas_id, $record_id) + { + $ret = array('success' => false, 'message' => _('An error occured')); + try + { + $user = $app['Core']->getAuthenticatedUser(); + /* @var $user \User_Adapter */ - $story = new \record_adapter($sbas_id, $record_id); + $story = new \record_adapter($sbas_id, $record_id); - if (!$story->is_grouping()) - { - throw new \Exception('This is not a story'); - } + if (!$story->is_grouping()) + { + throw new \Exception('This is not a story'); + } - if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) - { - throw new ControllerException(_('You can not edit this story')); - } + if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) + { + 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'; - $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) - { - $params = array( - ':ord' => $ord, - ':parent_id' => $story->get_record_id(), - ':children_id' => $record_id - ); - $stmt->execute($params); - } + foreach ($app['request']->get('element') as $record_id => $ord) + { + $params = array( + ':ord' => $ord, + ':parent_id' => $story->get_record_id(), + ':children_id' => $record_id + ); + $stmt->execute($params); + } - $stmt->closeCursor(); + $stmt->closeCursor(); - $ret = array('success' => true, 'message' => _('Story updated')); - } - catch (ControllerException $e) - { - $ret = array('success' => false, 'message' => $e->getMessage()); - } - catch (\Exception $e) - { + $ret = array('success' => true, 'message' => _('Story updated')); + } + catch (ControllerException $e) + { + $ret = array('success' => false, 'message' => $e->getMessage()); + } + catch (\Exception $e) + { + + } - } + $Serializer = $app['Core']['Serializer']; - $Serializer = $app['Core']['Serializer']; - - return new Response($Serializer->serialize($ret, 'json'), 200, array('Content-type' => 'application/json')); - }) - ->assert('sbas_id', '\d+') - ->assert('record_id', '\d+'); + return new Response($Serializer->serialize($ret, 'json'), 200, array('Content-type' => 'application/json')); + }) + ->assert('sbas_id', '\d+') + ->assert('record_id', '\d+'); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index 932f4621a3..18d9801fd0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -286,7 +286,6 @@ class UsrLists implements ControllerProviderInterface $list->setName($list_name); - $em->merge($list); $em->flush(); $datas = array( @@ -459,7 +458,7 @@ class UsrLists implements ControllerProviderInterface $list->addUsrListEntry($entry); $em->persist($entry); - $em->merge($list); + $inserted_usr_ids[] = $user_entry->get_id(); } @@ -585,14 +584,12 @@ class UsrLists implements ControllerProviderInterface $list->addUsrListOwner($owner); $em->persist($owner); - $em->merge($list); } $role = $app['request']->get('role'); $owner->setRole($role); - $em->merge($owner); $em->flush(); $datas = array( diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php index a89899e07a..bd047d8d85 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php @@ -33,293 +33,323 @@ class Installer implements ControllerProviderInterface $controllers = new ControllerCollection(); $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(); - - 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 - ) + $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; - $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) + foreach ($constraints_coll as $key => $constraints) { - switch ($task) + $unset = true; + foreach ($constraints as $constraint) { - 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 = "\n\n" - . str_replace('/phraseanet_indexer', '', $request->get('binary_phraseanet_indexer')) - . "" . $host . "" - . $port . "" - . $appbox_name . "" - . $user_ab . "" - . $password . "25200" - . "10" - . "0utf8"; - } - else - { - $settings = null; - } - - \task_abstract::create($appbox, $class_name, $settings); - break; - default: - break; + if (!$constraint->is_ok() && $constraint->is_blocker()) + $redirect = $unset = false; + } + if ($unset === true) + { + unset($constraints_coll[$key]); } } - } - } - \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); - } - catch (\Exception $e) - { - \setup::rollback($conn, $connbas); - } + return new Response($html); + }); - 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 = "\n\n" + . str_replace('/phraseanet_indexer', '', $request->get('binary_phraseanet_indexer')) + . "" . $host . "" + . $port . "" + . $appbox_name . "" + . $user_ab . "" + . $password . "25200" + . "10" + . "0utf8"; + } + 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; } diff --git a/lib/Alchemy/Phrasea/Core.php b/lib/Alchemy/Phrasea/Core.php index 5708fc4768..8277d5aad0 100644 --- a/lib/Alchemy/Phrasea/Core.php +++ b/lib/Alchemy/Phrasea/Core.php @@ -275,7 +275,12 @@ class Core extends \Pimple $appbox = \appbox::get_instance($this); $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; } /** diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php index b31328201a..254a335687 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class ApcCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + public function getScope() { return 'cache'; @@ -38,11 +40,14 @@ class ApcCache extends ServiceAbstract implements ServiceInterface 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() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php index d2fe9cfb06..919f4bc78b 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php @@ -27,6 +27,8 @@ use Alchemy\Phrasea\Core, class ArrayCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + public function getScope() { return 'cache'; @@ -34,11 +36,14 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface 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() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php index 3342e08867..b0c3ebb533 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class MemcacheCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + const DEFAULT_HOST = "localhost"; const DEFAULT_PORT = "11211"; @@ -53,27 +55,30 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface throw new \Exception('The Memcache cache requires the Memcache extension.'); } - $memcache = new \Memcache(); - - $memcache->addServer($this->host, $this->port); - - $key = sprintf("%s:%s", $this->host, $this->port); - - $stats = @$memcache->getExtendedStats(); - - if (isset($stats[$key])) + if(!$this->cache) { - $service = new CacheDriver\MemcacheCache(); - $service->setMemcache($memcache); - } - else - { - throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port)); + $memcache = new \Memcache(); + + $memcache->addServer($this->host, $this->port); + + $key = sprintf("%s:%s", $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 $service; + return $this->cache; } public function getType() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php index 5f999b9f19..586ad6b56c 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class RedisCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + const DEFAULT_HOST = "localhost"; const DEFAULT_PORT = "6379"; @@ -34,7 +36,7 @@ class RedisCache extends ServiceAbstract implements ServiceInterface 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; @@ -57,26 +59,30 @@ class RedisCache extends ServiceAbstract implements ServiceInterface 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)) - { - $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; + return $this->cache; } public function getType() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php index aa2b5acdce..fcdf9af11b 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class XcacheCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + public function getScope() { return 'cache'; @@ -38,11 +40,14 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface 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() @@ -55,5 +60,4 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface return array(); } - } diff --git a/lib/Alchemy/Phrasea/Core/Service/Log/FirePHP.php b/lib/Alchemy/Phrasea/Core/Service/Log/FirePHP.php new file mode 100644 index 0000000000..819d6bdbec --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Service/Log/FirePHP.php @@ -0,0 +1,63 @@ +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(); + } + +} \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Core/Service/Log/Monolog.php b/lib/Alchemy/Phrasea/Core/Service/Log/Monolog.php index 6739399e3e..438cac0ec2 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Log/Monolog.php +++ b/lib/Alchemy/Phrasea/Core/Service/Log/Monolog.php @@ -66,7 +66,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface , $handler , $this->name , $this->getScope() - , implode(", ", $this->handler) + , implode(", ", $this->handlers) ) ); } diff --git a/lib/Alchemy/Phrasea/Core/Service/Orm/Doctrine.php b/lib/Alchemy/Phrasea/Core/Service/Orm/Doctrine.php index f88cc5f1d0..093958e7c2 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Orm/Doctrine.php +++ b/lib/Alchemy/Phrasea/Core/Service/Orm/Doctrine.php @@ -17,8 +17,6 @@ use Alchemy\Phrasea\Core, Alchemy\Phrasea\Core\Service\ServiceInterface; use Doctrine\DBAL\Types\Type; 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)); } - //get cache $cache = isset($options["cache"]) ? $options["cache"] : false; - + if (!$cache || $this->debug) { $metaCache = $this->core['CacheService']->get('ORMmetadata', '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 { $query = isset($cache["query"]['service']) ? $cache["query"]['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); $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->setQueryCacheImpl($queryCache->getDriver()); $config->setResultCacheImpl($resultCache->getDriver()); - //define autoregeneration of proxies base on debug mode $config->setAutoGenerateProxyClasses($this->debug); @@ -124,11 +122,6 @@ class Doctrine extends ServiceAbstract implements ServiceInterface $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 { $this->entityManager = \Doctrine\ORM\EntityManager::create($dbalConf, $config, $evm); diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php index 8c4772fa23..511438b2b4 100644 --- a/lib/Alchemy/Phrasea/Helper/Prod.php +++ b/lib/Alchemy/Phrasea/Helper/Prod.php @@ -32,10 +32,13 @@ class Prod extends Helper ); $bases = $fields = $dates = array(); - $appbox = \appbox::get_instance($this->core); - $session = $appbox->get_session(); $user = $this->getCore()->getAuthenticatedUser(); + if(!$user instanceof \User_Adapter) + { + return $search_datas; + } + $searchSet = $user->getPrefs('search'); foreach ($user->ACL()->get_granted_sbas() as $databox) diff --git a/lib/Alchemy/Phrasea/Helper/Record/Edit.php b/lib/Alchemy/Phrasea/Helper/Record/Edit.php index a3b43f14c7..f9c2771cbb 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Edit.php @@ -422,27 +422,6 @@ class Edit extends RecordHelper { $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(); $separator = $meta->get_separator(); @@ -455,12 +434,11 @@ class Edit extends RecordHelper , 'required' => $meta->is_required() , 'readonly' => $meta->is_readonly() , 'type' => $meta->get_type() - , 'format' => $format - , 'explain' => $explain + , 'format' => '' + , 'explain' => '' , 'tbranch' => $meta->get_tbranch() , 'maxLength' => $source ? $source->maxlength() : 0 , 'minLength' => $source ? $source->minLength() : 0 - , 'regfield' => $regfield , 'multi' => $meta->is_multi() , 'separator' => $separator , 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null @@ -615,55 +593,6 @@ class Edit extends RecordHelper } 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; } } diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 035d9afce4..08874ae68f 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -131,10 +131,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper sum(remain_dwnld) as remain_dwnld, sum(month_dwnld_max) as month_dwnld_max, - mask_xor as maskxordec, - bin(mask_xor) as maskxorbin, - mask_and as maskanddec, - bin(mask_and) as maskandbin + sum(mask_and + mask_xor) as masks FROM (usr u, bas b, sbas s) 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) $parm['base_id']; - $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) WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . " diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index 823ca22c45..6d92f7e829 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -184,8 +184,10 @@ class PDF $fimg = $subdef->get_pathfile(); if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") - && $subdef->get_type() == media_subdef::TYPE_IMAGE) - $fimg = recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id()); + && $subdef->get_type() == \media_subdef::TYPE_IMAGE) + { + $fimg = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id()); + } $wimg = $himg = $ImgSize; if ($subdef->get_height() > 0 && $subdef->get_width() > 0) @@ -479,8 +481,8 @@ class PDF $f = $subdef->get_pathfile(); if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") - && $subdef->get_type() == media_subdef::TYPE_IMAGE) - $f = recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id()); + && $subdef->get_type() == \media_subdef::TYPE_IMAGE) + $f = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id()); $wimg = $himg = 150; // preview dans un carre de 150 mm if ($subdef->get_width() > 0 && $subdef->get_height() > 0) diff --git a/lib/Doctrine/Events/Listener/Cache/Action/Clear.php b/lib/Doctrine/Events/Listener/Cache/Action/Clear.php deleted file mode 100644 index 7a96b5e66a..0000000000 --- a/lib/Doctrine/Events/Listener/Cache/Action/Clear.php +++ /dev/null @@ -1,57 +0,0 @@ -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) - { - - } - } - -} diff --git a/lib/Doctrine/Events/Processor/Cache/Action/AbstractClear.php b/lib/Doctrine/Events/Processor/Cache/Action/AbstractClear.php deleted file mode 100644 index b0bd35f9b7..0000000000 --- a/lib/Doctrine/Events/Processor/Cache/Action/AbstractClear.php +++ /dev/null @@ -1,57 +0,0 @@ -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"); - } - -} diff --git a/lib/Doctrine/Events/Processor/Cache/Action/Clear/Basket.php b/lib/Doctrine/Events/Processor/Cache/Action/Clear/Basket.php deleted file mode 100644 index 22ca40a2ac..0000000000 --- a/lib/Doctrine/Events/Processor/Cache/Action/Clear/Basket.php +++ /dev/null @@ -1,35 +0,0 @@ -getCacheAdapter($args); - $cache->deleteBySuffix(Entities\Basket::CACHE_SUFFIX); - $cache->deleteBySuffix(Entities\BasketElement::CACHE_SUFFIX); - } - -} diff --git a/lib/Doctrine/Events/Processor/Cache/Action/Clear/BasketElement.php b/lib/Doctrine/Events/Processor/Cache/Action/Clear/BasketElement.php deleted file mode 100644 index 70e2db494d..0000000000 --- a/lib/Doctrine/Events/Processor/Cache/Action/Clear/BasketElement.php +++ /dev/null @@ -1,34 +0,0 @@ -getCacheAdapter($args); - $cache->deleteBySuffix(Entities\Basket::CACHE_SUFFIX); - $cache->deleteBySuffix(Entities\BasketElement::CACHE_SUFFIX); - } - -} diff --git a/lib/Doctrine/Events/Processor/Factory/CacheAction.php b/lib/Doctrine/Events/Processor/Factory/CacheAction.php deleted file mode 100644 index d97d7613ca..0000000000 --- a/lib/Doctrine/Events/Processor/Factory/CacheAction.php +++ /dev/null @@ -1,37 +0,0 @@ -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); - -} - diff --git a/lib/Doctrine/Events/Processor/Processor.php b/lib/Doctrine/Events/Processor/Processor.php deleted file mode 100644 index 69054850b6..0000000000 --- a/lib/Doctrine/Events/Processor/Processor.php +++ /dev/null @@ -1,30 +0,0 @@ -_entityPersister, $this->_identifier); } } - - + + public function getId() { $this->__load(); @@ -218,6 +218,6 @@ class EntitiesBasketProxy extends \Entities\Basket implements \Doctrine\ORM\Prox } unset($this->_entityPersister, $this->_identifier); } - + } } \ No newline at end of file diff --git a/lib/Doctrine/Repositories/BasketElementRepository.php b/lib/Doctrine/Repositories/BasketElementRepository.php index d0a4df3780..524f30b612 100644 --- a/lib/Doctrine/Repositories/BasketElementRepository.php +++ b/lib/Doctrine/Repositories/BasketElementRepository.php @@ -35,8 +35,8 @@ class BasketElementRepository extends EntityRepository $query = $this->_em->createQuery($dql); $query->setParameters($params); - $cacheId = "_user_basket_element_" . $element_id . "_" . $user->get_id() . Entities\BasketElement::CACHE_SUFFIX; - $query->useResultCache(true, 1800, $cacheId); +// $cacheId = "_user_basket_element_" . $element_id . "_" . $user->get_id() . Entities\BasketElement::CACHE_SUFFIX; +// $query->useResultCache(true, 1800, $cacheId); $element = $query->getOneOrNullResult(); @@ -66,8 +66,9 @@ class BasketElementRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); } @@ -98,8 +99,9 @@ class BasketElementRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); } @@ -123,8 +125,9 @@ class BasketElementRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); } diff --git a/lib/Doctrine/Repositories/BasketRepository.php b/lib/Doctrine/Repositories/BasketRepository.php index 1e7aa9a768..06ac092e44 100644 --- a/lib/Doctrine/Repositories/BasketRepository.php +++ b/lib/Doctrine/Repositories/BasketRepository.php @@ -56,9 +56,9 @@ class BasketRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); } @@ -79,9 +79,11 @@ class BasketRepository extends EntityRepository WHERE b.archived = false AND ( (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 - AND p.is_aware = false) + OR (b.usr_id != :usr_id_ownertwo + 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'; $params = array( @@ -93,9 +95,8 @@ class BasketRepository extends EntityRepository $query = $this->_em->createQuery($dql); $query->setParameters($params); - $idCache = "findUnreadActiveByUser" . $user->get_id() . Entities\Basket::CACHE_SUFFIX; - - $query->useResultCache(true, 1800, $idCache); +// $idCache = "findUnreadActiveByUser" . $user->get_id() . Entities\Basket::CACHE_SUFFIX; +// $query->useResultCache(true, 1800, $idCache); return $query->getResult(); } @@ -129,8 +130,9 @@ class BasketRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); } @@ -157,8 +159,9 @@ class BasketRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); @@ -211,8 +214,9 @@ class BasketRepository extends EntityRepository $query = $this->_em->createQuery($dql); $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(); } @@ -255,10 +259,9 @@ class BasketRepository extends EntityRepository ); break; default: - $type = 'default'; $dql = 'SELECT b, e, s, p FROM Entities\Basket b - JOIN b.elements e + LEFT JOIN b.elements e LEFT JOIN b.validation s LEFT JOIN s.participants p 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() ); 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) @@ -285,7 +299,7 @@ class BasketRepository extends EntityRepository $params['description'] = '%' . $query . '%'; } - $dql .= ' ORDER BY e.ord ASC'; + $dql .= ' ORDER BY b.id DESC, e.ord ASC'; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -293,12 +307,44 @@ class BasketRepository extends EntityRepository $count = Paginate::getTotalQueryResults($query); $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(); 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(); + } + } diff --git a/lib/Doctrine/Repositories/StoryWZRepository.php b/lib/Doctrine/Repositories/StoryWZRepository.php index e14467ad79..1e739a3844 100644 --- a/lib/Doctrine/Repositories/StoryWZRepository.php +++ b/lib/Doctrine/Repositories/StoryWZRepository.php @@ -44,7 +44,25 @@ class StoryWZRepository extends EntityRepository 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; @@ -54,7 +72,7 @@ class StoryWZRepository extends EntityRepository { $story = $this->find($id); - if($story) + if ($story) { try { @@ -66,7 +84,7 @@ class StoryWZRepository extends EntityRepository 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'); } @@ -79,16 +97,6 @@ class StoryWZRepository extends EntityRepository 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) { $story = $this->findOneBy( diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index 903b18fdbd..5391d08f8a 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -204,6 +204,25 @@ class API_V1_adapter extends API_V1_Abstract 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 * diff --git a/lib/classes/Bridge/Api/Dailymotion/Container.class.php b/lib/classes/Bridge/Api/Dailymotion/Container.class.php index 99f23fc1d5..75cfda257c 100644 --- a/lib/classes/Bridge/Api/Dailymotion/Container.class.php +++ b/lib/classes/Bridge/Api/Dailymotion/Container.class.php @@ -130,5 +130,19 @@ class Bridge_Api_Dailymotion_Container implements Bridge_Api_ContainerInterface { return $this->url; } - + + public function get_duration() + { + return ''; + } + + public function get_category() + { + return ''; + } + + public function is_private() + { + return null; + } } diff --git a/lib/classes/Bridge/Api/Flickr/Container.class.php b/lib/classes/Bridge/Api/Flickr/Container.class.php index 20f2954f97..b11dcfb831 100644 --- a/lib/classes/Bridge/Api/Flickr/Container.class.php +++ b/lib/classes/Bridge/Api/Flickr/Container.class.php @@ -138,4 +138,19 @@ class Bridge_Api_Flickr_Container implements Bridge_Api_ContainerInterface return $this->type; } + + public function get_duration() + { + return ''; + } + + public function get_category() + { + return ''; + } + + public function is_private() + { + return null; + } } diff --git a/lib/classes/Bridge/Api/Flickr/Element.class.php b/lib/classes/Bridge/Api/Flickr/Element.class.php index 241f6397f2..a62874740d 100644 --- a/lib/classes/Bridge/Api/Flickr/Element.class.php +++ b/lib/classes/Bridge/Api/Flickr/Element.class.php @@ -210,7 +210,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface */ public function get_category() { - return null; + return ''; } /** @@ -219,7 +219,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface */ public function get_duration() { - return null; + return ''; } /** @@ -279,5 +279,4 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface { return $this->entry["tags"]; } - } diff --git a/lib/classes/Bridge/Api/Youtube/Container.class.php b/lib/classes/Bridge/Api/Youtube/Container.class.php index 6a63aee7c0..28663f39e3 100644 --- a/lib/classes/Bridge/Api/Youtube/Container.class.php +++ b/lib/classes/Bridge/Api/Youtube/Container.class.php @@ -117,4 +117,20 @@ class Bridge_Api_Youtube_Container implements Bridge_Api_ContainerInterface return $this->type; } + public function get_duration() + { + return ''; + } + + + public function get_category() + { + return ''; + } + + + public function is_private() + { + return null; + } } diff --git a/lib/classes/Session/Handler.class.php b/lib/classes/Session/Handler.class.php index d6b37b3448..949a776078 100644 --- a/lib/classes/Session/Handler.class.php +++ b/lib/classes/Session/Handler.class.php @@ -558,7 +558,7 @@ class Session_Handler $browser = Browser::getInstance(); 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); } diff --git a/lib/classes/appbox.class.php b/lib/classes/appbox.class.php index c5b7408fe3..2d68228088 100644 --- a/lib/classes/appbox.class.php +++ b/lib/classes/appbox.class.php @@ -456,15 +456,6 @@ class appbox extends base $cacheService = "array_cache"; - if (extension_loaded('apc')) - { - $cacheService = "apc_cache"; - } - elseif (extension_loaded('xcache')) - { - $cacheService = "xcache_cache"; - } - $Core->getConfiguration()->setConnexions($connexion); $services = $Core->getConfiguration()->getConfigurations(); @@ -474,7 +465,7 @@ class appbox extends base if ($serviceName === "doctrine_prod") { - $services["doctrine_prod"]["options"]["orm"]["cache"] = array( + $services["doctrine_prod"]["options"]["cache"] = array( "query" => $cacheService, "result" => $cacheService, "metadata" => $cacheService @@ -499,7 +490,7 @@ class appbox extends base } $Core->getConfiguration()->setConfigurations($arrayConf); - + $Core->getConfiguration()->setEnvironnement('prod'); } try diff --git a/lib/classes/base.class.php b/lib/classes/base.class.php index b5f476b619..cd2cb38946 100644 --- a/lib/classes/base.class.php +++ b/lib/classes/base.class.php @@ -60,11 +60,12 @@ abstract class base implements cache_cacheableInterface /** * */ + 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() { if ($this->schema) - return $this->schema; $this->load_schema(); @@ -178,7 +178,7 @@ abstract class base implements cache_cacheableInterface 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); } @@ -232,7 +232,6 @@ abstract class base implements cache_cacheableInterface { if ($this->version) - return $this->version; $version = '0.0.0'; @@ -245,9 +244,9 @@ abstract class base implements cache_cacheableInterface if ($sql !== '') { - $stmt = $this->get_connection()->prepare($sql); + $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); + $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); if ($row) $version = $row['version']; @@ -261,10 +260,8 @@ abstract class base implements cache_cacheableInterface public function upgradeavailable() { if ($this->get_version()) - return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>'); else - return true; } @@ -281,13 +278,25 @@ abstract class base implements cache_cacheableInterface $upgrader->add_steps(count($allTables) + 1); - $sql = "SHOW TABLE STATUS"; + $sql = "SHOW TABLE STATUS"; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); + $ORMTables = array( + 'BasketElements', + 'Baskets', + 'StoryWZ', + 'UsrListOwners', + 'UsrLists', + 'UsrListsContent', + 'ValidationDatas', + 'ValidationParticipants', + 'ValidationSessions', + ); + foreach ($rs as $row) { $tname = $row["Name"]; @@ -296,7 +305,7 @@ abstract class base implements cache_cacheableInterface { $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']); if ($engine != $ref_engine && in_array($engine, array('innodb', 'myisam'))) @@ -311,22 +320,22 @@ abstract class base implements cache_cacheableInterface catch (Exception $e) { $recommends[] = array( - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), - 'sql' => $sql + 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'sql' => $sql ); } } - $ret = self::upgradeTable($allTables[$tname]); + $ret = self::upgradeTable($allTables[$tname]); $recommends = array_merge($recommends, $ret); unset($allTables[$tname]); $upgrader->add_steps_complete(1); } - else + elseif (!in_array($tname, $ORMTables)) { $recommends[] = array( - 'message' => 'Une table pourrait etre supprime', - 'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;' + 'message' => 'Une table pourrait etre supprime', + 'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;' ); } } @@ -390,7 +399,6 @@ abstract class base implements cache_cacheableInterface protected function load_schema() { if ($this->schema) - return $this; $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) { - $field_stmt = $defaults_stmt = array(); + $field_stmt = $defaults_stmt = array(); $create_stmt = "CREATE TABLE `" . $table['name'] . "` ("; @@ -451,8 +459,8 @@ abstract class base implements cache_cacheableInterface $character_set = ''; if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext')) - || substr(strtolower((string) $field->type), 0, 7) == 'varchar' - || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) + || substr(strtolower((string) $field->type), 0, 7) == 'varchar' + || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) { $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->extra . " " . $character_set . " " - . $is_default . " " . $isnull . ""; + . $field->extra . " " . $character_set . " " + . $is_default . " " . $isnull . ""; } @@ -482,7 +490,7 @@ abstract class base implements cache_cacheableInterface $primary_fields[] = "`" . $field . "`"; } - $field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')'; + $field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')'; break; case "UNIQUE": $unique_fields = array(); @@ -511,32 +519,32 @@ abstract class base implements cache_cacheableInterface { foreach ($table->defaults->default as $default) { - $k = $v = $params = $dates_values = array(); + $k = $v = $params = $dates_values = array(); $nonce = random::generatePassword(16); foreach ($default->data as $data) { - $k = trim($data['key']); + $k = trim($data['key']); if ($k === 'usr_password') $data = User_Adapter::salt_password($data, $nonce); if ($k === '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()') $dates_values [$k] = 'NOW()'; 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) ? ', ' : ''); $defaults_stmt[] = array( - 'sql' => - 'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params)) - . $separator . implode(', ', array_keys($dates_values)) . ') + 'sql' => + 'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params)) + . $separator . implode(', ', array_keys($dates_values)) . ') VALUES (:' . implode(', :', array_keys($params)) - . $separator . implode(', ', array_values($dates_values)) . ') ' - , 'params' => $params + . $separator . implode(', ', array_values($dates_values)) . ') ' + , 'params' => $params ); } } @@ -562,8 +570,8 @@ abstract class base implements cache_cacheableInterface catch (Exception $e) { $recommends[] = array( - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), - 'sql' => $def['sql'] + 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'sql' => $def['sql'] ); } } @@ -574,7 +582,7 @@ abstract class base implements cache_cacheableInterface protected function upgradeTable(SimpleXMLElement $table) { $correct_table = array('fields' => array(), 'indexes' => array(), 'collation' => array()); - $alter = $alter_pre = $return = array(); + $alter = $alter_pre = $return = array(); $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'; if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext')) - || substr(strtolower((string) $field->type), 0, 7) == 'varchar' - || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) + || substr(strtolower((string) $field->type), 0, 7) == 'varchar' + || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) { $code = array_pop(array_reverse(explode('_', $collation))); @@ -618,7 +626,7 @@ abstract class base implements cache_cacheableInterface foreach ($table->indexes->index as $index) { $i_name = (string) $index->name; - $expr = array(); + $expr = array(); foreach ($index->fields->field as $field) $expr[] = '`' . trim((string) $field) . '`'; @@ -630,25 +638,25 @@ abstract class base implements cache_cacheableInterface $correct_table['indexes']['PRIMARY'] = 'PRIMARY KEY (' . $expr . ')'; break; case "UNIQUE": - $correct_table['indexes'][$i_name] = 'UNIQUE KEY `' . $i_name . '` (' . $expr . ')'; + $correct_table['indexes'][$i_name] = 'UNIQUE KEY `' . $i_name . '` (' . $expr . ')'; break; case "INDEX": - $correct_table['indexes'][$i_name] = 'KEY `' . $i_name . '` (' . $expr . ')'; + $correct_table['indexes'][$i_name] = 'KEY `' . $i_name . '` (' . $expr . ')'; break; } } } - $sql = "SHOW FULL FIELDS FROM `" . $table['name'] . "`"; + $sql = "SHOW FULL FIELDS FROM `" . $table['name'] . "`"; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); - $rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC); + $rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs2 as $row2) { - $f_name = $row2['Field']; + $f_name = $row2['Field']; $expr_found = trim($row2['Type']); $_extra = $row2['Extra']; @@ -727,8 +735,8 @@ abstract class base implements cache_cacheableInterface else { $return[] = array( - 'message' => 'Un champ pourrait etre supprime', - 'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;" + 'message' => 'Un champ pourrait etre supprime', + 'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;" ); } } @@ -739,16 +747,16 @@ abstract class base implements cache_cacheableInterface } $tIndex = array(); - $sql = "SHOW INDEXES FROM `" . $table['name'] . "`"; + $sql = "SHOW INDEXES FROM `" . $table['name'] . "`"; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); - $rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC); + $rs2 = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs2 as $row2) { 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']; } @@ -786,8 +794,8 @@ abstract class base implements cache_cacheableInterface else { $return[] = array( - 'message' => 'Un index pourrait etre supprime', - 'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';' + 'message' => 'Un index pourrait etre supprime', + 'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';' ); } } @@ -806,8 +814,8 @@ abstract class base implements cache_cacheableInterface catch (Exception $e) { $return[] = array( - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), - 'sql' => $a + 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'sql' => $a ); } } @@ -823,8 +831,8 @@ abstract class base implements cache_cacheableInterface catch (Exception $e) { $return[] = array( - 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), - 'sql' => $a + 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), + 'sql' => $a ); } } @@ -882,8 +890,8 @@ abstract class base implements cache_cacheableInterface } $upgrader->add_steps_complete(1) - ->add_steps(count($list_patches)) - ->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname())); + ->add_steps(count($list_patches)) + ->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname())); ksort($list_patches); $success = true; diff --git a/lib/classes/caption/record.class.php b/lib/classes/caption/record.class.php index fc99c71940..e80e54d995 100644 --- a/lib/classes/caption/record.class.php +++ b/lib/classes/caption/record.class.php @@ -50,10 +50,6 @@ class caption_record implements caption_interface, cache_cacheableInterface $this->record = $record; $this->databox = $databox; - - $this->retrieve_fields(); - - 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) { $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)) continue; diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 9f923c2e8b..4b25166763 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -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; diff --git a/lib/classes/databox/field.class.php b/lib/classes/databox/field.class.php index afdabcc906..ef47d891fb 100644 --- a/lib/classes/databox/field.class.php +++ b/lib/classes/databox/field.class.php @@ -98,24 +98,6 @@ class databox_field implements cache_cacheableInterface */ protected $thumbtitle; - /** - * - * @var - */ - protected $regdate; - - /** - * - * @var - */ - protected $regdesc; - - /** - * - * @var - */ - protected $regname; - /** * * @var int @@ -163,7 +145,7 @@ class databox_field implements cache_cacheableInterface $connbas = $this->get_connection(); - $sql = "SELECT `regdate`, `regdesc`, `regname`, `thumbtitle`, `separator` + $sql = "SELECT `thumbtitle`, `separator` , `dces_element`, `tbranch`, `type`, `report`, `multi`, `required` , `readonly`, `indexable`, `name`, `src` , `VocabularyControlType`, `RestrictToVocabularyControl` @@ -216,10 +198,6 @@ class databox_field implements cache_cacheableInterface $this->separator = $separator; $this->thumbtitle = $row['thumbtitle']; - $this->regdesc = !!$row['regdesc']; - $this->regname = !!$row['regname']; - $this->regdate = !!$row['regdate']; - return $this; } @@ -621,39 +599,6 @@ class databox_field implements cache_cacheableInterface 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 @@ -683,33 +628,6 @@ class databox_field implements cache_cacheableInterface 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 @@ -870,10 +788,10 @@ class databox_field implements cache_cacheableInterface $sql = "INSERT INTO metadatas_structure (`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`, - `thumbtitle`, `multi`, `regname`, `regdesc`, `regdate` , + `thumbtitle`, `multi`, `report`, `sorter`) VALUES (null, :name, '', 0, 1, 'text', '', - null, 0, null, null, null, + null, 0, 1, :sorter)"; $stmt = $databox->get_connection()->prepare($sql); diff --git a/lib/classes/eventsmanager/notify/downloadmailfail.class.php b/lib/classes/eventsmanager/notify/downloadmailfail.class.php new file mode 100644 index 0000000000..4ca0204621 --- /dev/null +++ b/lib/classes/eventsmanager/notify/downloadmailfail.class.php @@ -0,0 +1,177 @@ + 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; + } + +} diff --git a/lib/classes/mail.class.php b/lib/classes/mail.class.php index 28c88e0e26..72b195c736 100644 --- a/lib/classes/mail.class.php +++ b/lib/classes/mail.class.php @@ -208,8 +208,9 @@ class mail $body = eregi_replace("[\]", '', $body); - $body .= "
\n"._('Si le lien n\'est pas cliquable, copiez-collez le dans votre navigateur.')."
\n"; $body .= "



\n\n\n\n"; + $body .= '
'._('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.').'
'; + $body .= "
\n"; $body .= '
' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "
\n"; $body .= '
' . $registry->get('GV_ServerName') . "
\n"; $body = '' . $body . ''; @@ -258,7 +259,7 @@ class mail $mail->ConfirmReadingTo = $reading_confirm_to; } - $mail->MsgHTML(strip_tags($body, '

  • ')); + $mail->MsgHTML(strip_tags($body, '


    • ')); foreach ($files as $f) { diff --git a/lib/classes/module/console/fileConfigCheck.class.php b/lib/classes/module/console/fileConfigCheck.class.php index 1174b48f47..efab242c14 100644 --- a/lib/classes/module/console/fileConfigCheck.class.php +++ b/lib/classes/module/console/fileConfigCheck.class.php @@ -143,7 +143,7 @@ class module_console_fileConfigCheck extends Command private function checkParse(OutputInterface $output) { - if (!$this->configuration->getConfigurations()) + if (!$this->configuration) { throw new \Exception("Unable to load configurations\n"); } @@ -163,7 +163,7 @@ class module_console_fileConfigCheck extends Command { try { - $this->configuration->getConfiguration(); + $this->configuration; } catch (\Exception $e) { @@ -178,15 +178,8 @@ class module_console_fileConfigCheck extends Command { $configuration = Core\Configuration::build(); - try - { - $configuration->getConfiguration(); - } - catch (\Exception $e) - { - throw new \Exception(sprintf("Check get selected environment from file\n"), null, $e); - } - $output->writeln("Get Selected Environment from file OK"); + $env = $configuration->getEnvironnement(); + $output->writeln("Get Selected Environment from file : ".$env.""); return; } diff --git a/lib/classes/module/console/fileEnsureDevSetting.class.php b/lib/classes/module/console/fileEnsureDevSetting.class.php new file mode 100644 index 0000000000..e3596c54a3 --- /dev/null +++ b/lib/classes/module/console/fileEnsureDevSetting.class.php @@ -0,0 +1,920 @@ +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 %s", $this->configuration->getEnvironnement())); + + $this->runTests($output); + + $retval = $this->errors; + if ($input->getOption('strict')) + { + $retval += $this->alerts; + } + + if ($retval > 0) + { + $output->writeln("\nSome errors found in your conf"); + } + else + { + $output->writeln("\nYour dev settings are setted correctly ! Enjoy"); + } + $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 = 'Works !'; + } + else + { + $work_message = 'Cache server recommended'; + $this->alerts++; + } + } + else + { + $work_message = 'Failed - could not connect !'; + $this->errors++; + } + + $verification = sprintf("\t--> Verify %s : %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 = 'Works !'; + } + else + { + $work_message = 'No cache required'; + $this->errors++; + } + } + else + { + $work_message = 'Failed - could not connect !'; + $this->errors++; + } + + $verification = sprintf("\t--> Verify %s : %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, 'Not recognized'); + break; + case 'servername': + $url = $value; + $required = array_diff($required, array($conf)); + + $parseUrl = parse_url($url); + + if (empty($url)) + { + $message = "should not be empty"; + $this->errors++; + } + elseif ($url == 'http://sub.domain.tld/') + { + $this->alerts++; + $message = "may be wrong"; + } + elseif (!filter_var($url, FILTER_VALIDATE_URL)) + { + $message = "not valid"; + $this->errors++; + } + else + { + $message = "OK"; + } + $this->printConf($output, $conf, $value, false, $message); + break; + case 'maintenance': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== false) + { + $message = 'Should be true'; + $this->errors++; + } + + $this->printConf($output, $conf, $value, false, $message); + break; + case 'debug': + case 'display_errors': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== true) + { + $message = 'Should be true'; + $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 = 'OK'; + } + else + { + $message = 'Connection not available'; + $this->errors++; + } + } + catch (\Exception $e) + { + $message = 'Unknown connection'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); + break; + } + } + + if (count($required) > 0) + { + $output->writeln(sprintf('Miss required keys %s', 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 = 'Works !'; + } + else + { + $work_message = 'Failed - could not connect !'; + $this->errors++; + } + } + catch (\Exception $e) + { + + $work_message = 'Failed - could not connect !'; + $this->errors++; + } + + $output->writeln(sprintf("\t--> Verify connection %s : %s", $connexionName, $work_message)); + + $required = array('driver'); + + if (!$connexion->has('driver')) + { + $output->writeln("\nConnection has no driver"); + $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("\nYour driver is not managed"); + $this->errors++; + } + + foreach ($connexion->all() as $conf => $value) + { + switch ($conf) + { + default: + $this->alerts++; + $this->printConf($output, $conf, $value, false, 'Not recognized'); + break; + case 'charset': + $required = array_diff($required, array($conf)); + $message = 'OK'; + if ($value !== 'UTF8') + { + $message = 'Not recognized'; + $this->alerts++; + } + $this->printConf($output, $conf, $value, false, $message); + break; + case 'path': + $required = array_diff($required, array($conf)); + $message = is_writable(dirname($value)) ? 'OK' : 'Not writeable'; + $this->printConf($output, $conf, $value, false, $message); + break; + case 'dbname': + case 'user': + case 'host': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if (!is_scalar($value)) + { + $message = 'Should be scalar'; + $this->errors++; + } + + $this->printConf($output, $conf, $value, false, $message); + break; + case 'port': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if (!ctype_digit($value)) + { + $message = 'Should be ctype_digit'; + $this->errors++; + } + + $this->printConf($output, $conf, $value, false, $message); + break; + case 'password': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if (!is_scalar($value)) + { + $message = 'Should be scalar'; + $this->errors++; + } + + $value = '***********'; + $this->printConf($output, $conf, $value, false, $message); + break; + case 'driver': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== 'pdo_mysql') + { + $message = 'MySQL recommended'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); + break; + } + } + + if (count($required) > 0) + { + $output->writeln(sprintf('Miss required keys %s', 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 = 'Works !'; + } + catch (\Exception $e) + { + $work_message = 'Failed - could not load template engine !'; + $this->errors++; + } + + $output->writeln(sprintf("\t--> Verify Template engine %s : %s", $templateEngineName, $work_message)); + + if (!$configuration->has('type')) + { + $output->writeln("\nConfiguration has no type"); + $this->errors++; + } + elseif ($configuration->get('type') == 'TemplateEngine\\Twig') + { + $required = array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer'); + } + else + { + $output->writeln("\nYour type is not managed"); + $this->errors++; + } + + + + foreach ($configuration->all() as $conf => $value) + { + switch ($conf) + { + case 'type': + $message = 'OK'; + + if ($value !== 'TemplateEngine\\Twig') + { + $message = 'Not recognized'; + $this->alerts++; + } + + $this->printConf($output, $conf, $value, false, $message); + break; + case 'options': + $message = 'OK'; + + if (!is_array($value)) + { + $message = 'Should be array'; + $this->errors++; + } + + $this->printConf($output, $conf, 'array()', false, $message); + break; + default: + $this->alerts++; + $this->printConf($output, $conf, 'unknown', false, 'Not recognized'); + break; + } + } + + foreach ($configuration->get('options') as $conf => $value) + { + switch ($conf) + { + case 'debug'; + case 'strict_variables'; + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== true) + { + $message = 'Should be false'; + $this->errors++; + } + + $this->printConf($output, "\t" . $conf, $value, false, $message); + break; + case 'autoescape'; + case 'optimizer'; + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== true) + { + $message = 'Should be true'; + $this->errors++; + } + + $this->printConf($output, "\t" . $conf, $value, false, $message); + break; + case 'charset'; + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== 'utf-8') + { + $message = 'Not recognized'; + $this->alerts++; + } + + $this->printConf($output, "\t" . $conf, $value, false, $message); + break; + default: + $this->alerts++; + $this->printConf($output, "\t" . $conf, $value, false, 'Not recognized'); + break; + } + } + + if (count($required) > 0) + { + $output->writeln(sprintf('Miss required keys %s', 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 = 'Works !'; + } + catch (\Exception $e) + { + $work_message = 'Failed - could not connect !'; + $this->errors++; + } + + $output->writeln(sprintf("\t--> Verify ORM engine %s : %s", $ormName, $work_message)); + + + + if (!$configuration->has('type')) + { + $output->writeln("\nConfiguration has no type"); + $this->errors++; + } + elseif ($configuration->get('type') == 'Orm\\Doctrine') + { + $required = array('debug', 'dbal', 'cache'); + } + else + { + $output->writeln("\nYour type is not managed"); + $this->errors++; + } + + + + foreach ($configuration->all() as $conf => $value) + { + switch ($conf) + { + case 'type': + $message = $value == 'Orm\\Doctrine' ? 'OK' : 'Not recognized'; + $this->printConf($output, $conf, $value, false, $message); + break; + case 'options': + $message = 'OK'; + + if (!is_array($value)) + { + $message = 'Should be array'; + $this->errors++; + } + + $this->printConf($output, $conf, 'array()', false, $message); + break; + default: + $this->alerts++; + $this->printConf($output, $conf, 'unknown', false, 'Not recognized'); + break; + } + } + + + foreach ($configuration->get('options') as $conf => $value) + { + switch ($conf) + { + case 'log': + $message = 'OK'; + + $this->printConf($output, $conf, $value, false, $message); + break; + case 'cache': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if (!is_array($value)) + { + $message = 'Should be Array'; + $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 = 'Works !'; + } + else + { + $this->errors++; + $work_message = 'No cache required'; + } + } + else + { + $work_message = 'Failed - could not connect !'; + $this->errors++; + } + + $verification = sprintf("\t--> Verify %s : %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, 'Not recognized'); + break; + } + if (!isset($cache_type['service'])) + { + $output->writeln('Miss service for %s', $cache_type); + $this->errors++; + } + } + } + + if (count($required_caches) > 0) + { + $output->writeln(sprintf('Miss required caches %s', implode(', ', $required_caches))); + $this->errors++; + } + break; + case 'debug': + $required = array_diff($required, array($conf)); + $message = 'OK'; + + if ($value !== true) + { + $message = 'Should be true'; + $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 = 'OK'; + } + catch (\Exception $e) + { + $message = 'Failed'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); + break; + default: + $this->alerts++; + $this->printConf($output, $conf, $value, false, 'Not recognized'); + break; + } + } + + if (count($required) > 0) + { + $output->writeln(sprintf('Miss required keys %s', 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 = 'OK'; + + if (!is_scalar($value)) + { + $message = 'Should be scalar'; + $this->errors++; + } + + $this->printConf($output, "\t\t" . $conf, $value, false, $message); + break; + case 'port'; + $required_options = array_diff($required_options, array($conf)); + $message = 'OK'; + + if (!ctype_digit($value)) + { + $message = 'Not recognized'; + $this->alerts++; + } + + $this->printConf($output, "\t\t" . $conf, $value, false, $message); + break; + default: + $this->alerts++; + $this->printConf($output, "\t\t" . $conf, $value, false, 'Not recognized'); + break; + } + } + } + + if (count($required_options) > 0) + { + $output->writeln(sprintf('Miss required keys %s', 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)); + } + } + +} diff --git a/lib/classes/module/console/fileEnsureProductionSetting.class.php b/lib/classes/module/console/fileEnsureProductionSetting.class.php index b9ed08de2f..66200366f3 100644 --- a/lib/classes/module/console/fileEnsureProductionSetting.class.php +++ b/lib/classes/module/console/fileEnsureProductionSetting.class.php @@ -44,6 +44,7 @@ class module_console_fileEnsureProductionSetting extends Command , 'checkOpcodeCacheService' ); protected $errors = 0; + protected $alerts = 0; public function __construct($name = null) { @@ -52,6 +53,7 @@ class module_console_fileEnsureProductionSetting extends Command $this->setDescription('Ensure production 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; } @@ -74,8 +76,23 @@ class module_console_fileEnsureProductionSetting extends Command $this->runTests($output); + $retval = $this->errors; + if ($input->getOption('strict')) + { + $retval += $this->alerts; + } + + if ($retval > 0) + { + $output->writeln("\nSome errors found in your conf"); + } + else + { + $output->writeln("\nYour production settings are setted correctly ! Enjoy"); + } $output->writeln('End'); - return 0; + + return $retval; } private function runTests(OutputInterface $output) @@ -112,15 +129,6 @@ class module_console_fileEnsureProductionSetting extends Command call_user_func(array($this, $test), $output); } - if ($this->errors) - { - $output->writeln("\nSome errors found in your conf"); - } - else - { - $output->writeln("\nYour production settings are setted correctly ! Enjoy"); - } - return $this->errors; } private function checkParse(OutputInterface $output) @@ -156,6 +164,7 @@ class module_console_fileEnsureProductionSetting extends Command else { $work_message = 'Cache server recommended'; + $this->alerts++; } } else @@ -185,6 +194,7 @@ class module_console_fileEnsureProductionSetting extends Command else { $work_message = 'Opcode recommended'; + $this->alerts++; } } else @@ -211,6 +221,7 @@ class module_console_fileEnsureProductionSetting extends Command switch ($conf) { default: + $this->alerts++; $this->printConf($output, $conf, $value, false, 'Not recognized'); break; case 'servername': @@ -226,6 +237,7 @@ class module_console_fileEnsureProductionSetting extends Command } elseif ($url == 'http://sub.domain.tld/') { + $this->alerts++; $message = "may be wrong"; } elseif (!filter_var($url, FILTER_VALIDATE_URL)) @@ -235,6 +247,7 @@ class module_console_fileEnsureProductionSetting extends Command } elseif ($parseUrl["scheme"] !== "https") { + $this->alerts++; $message = "should be https"; } else @@ -247,7 +260,14 @@ class module_console_fileEnsureProductionSetting extends Command case 'debug': case 'display_errors': $required = array_diff($required, array($conf)); - $message = $value ? 'Should be false' : 'OK'; + $message = 'OK'; + + if ($value !== false) + { + $message = 'Should be false'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); break; case 'database': @@ -335,11 +355,17 @@ class module_console_fileEnsureProductionSetting extends Command switch ($conf) { default: + $this->alerts++; $this->printConf($output, $conf, $value, false, 'Not recognized'); break; case 'charset': $required = array_diff($required, array($conf)); - $message = $value == 'UTF8' ? 'OK' : 'Not recognized'; + $message = 'OK'; + if ($value !== 'UTF8') + { + $message = 'Not recognized'; + $this->alerts++; + } $this->printConf($output, $conf, $value, false, $message); break; case 'path': @@ -351,23 +377,50 @@ class module_console_fileEnsureProductionSetting extends Command case 'user': case 'host': $required = array_diff($required, array($conf)); - $message = is_scalar($value) ? 'OK' : 'Should be scalar'; + $message = 'OK'; + + if (!is_scalar($value)) + { + $message = 'Should be scalar'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); break; case 'port': $required = array_diff($required, array($conf)); - $message = ctype_digit($value) ? 'OK' : 'Should be scalar'; + $message = 'OK'; + + if (!ctype_digit($value)) + { + $message = 'Should be ctype_digit'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); break; case 'password': $required = array_diff($required, array($conf)); - $message = is_scalar($value) ? 'OK' : 'Should be scalar'; + $message = 'OK'; + + if (!is_scalar($value)) + { + $message = 'Should be scalar'; + $this->errors++; + } + $value = '***********'; $this->printConf($output, $conf, $value, false, $message); break; case 'driver': $required = array_diff($required, array($conf)); - $message = $value === 'pdo_mysql' ? 'OK' : 'MySQL recommended'; + $message = 'OK'; + + if ($value !== 'pdo_mysql') + { + $message = 'MySQL recommended'; + $this->errors++; + } $this->printConf($output, $conf, $value, false, $message); break; } @@ -410,7 +463,7 @@ class module_console_fileEnsureProductionSetting extends Command } catch (\Exception $e) { - $work_message = 'Failed - could not connect !'; + $work_message = 'Failed - could not load template engine !'; $this->errors++; } @@ -438,14 +491,29 @@ class module_console_fileEnsureProductionSetting extends Command switch ($conf) { case 'type': - $message = $value == 'TemplateEngine\\Twig' ? 'OK' : 'Not recognized'; + $message = 'OK'; + + if($value !== 'TemplateEngine\\Twig') + { + $message = 'Not recognized'; + $this->alerts++; + } + $this->printConf($output, $conf, $value, false, $message); break; case 'options': - $message = is_array($value) ? 'OK' : 'Should be array'; + $message = 'OK'; + + if (!is_array($value)) + { + $message = 'Should be array'; + $this->errors++; + } + $this->printConf($output, $conf, 'array()', false, $message); break; default: + $this->alerts++; $this->printConf($output, $conf, 'unknown', false, 'Not recognized'); break; } @@ -458,21 +526,43 @@ class module_console_fileEnsureProductionSetting extends Command case 'debug'; case 'strict_variables'; $required = array_diff($required, array($conf)); - $message = $value == false ? 'OK' : 'Should be false'; + $message = 'OK'; + + if ($value !== false) + { + $message = 'Should be false'; + $this->errors++; + } + $this->printConf($output, "\t" . $conf, $value, false, $message); break; case 'autoescape'; case 'optimizer'; $required = array_diff($required, array($conf)); - $message = $value == true ? 'OK' : 'Should be true'; + $message = 'OK'; + + if ($value !== true) + { + $message = 'Should be true'; + $this->errors++; + } + $this->printConf($output, "\t" . $conf, $value, false, $message); break; case 'charset'; $required = array_diff($required, array($conf)); - $message = $value == 'utf-8' ? 'OK' : 'Not recognized'; + $message = 'OK'; + + if ($value !== 'utf-8') + { + $message = 'Not recognized'; + $this->alerts++; + } + $this->printConf($output, "\t" . $conf, $value, false, $message); break; default: + $this->alerts++; $this->printConf($output, "\t" . $conf, $value, false, 'Not recognized'); break; } @@ -533,10 +623,18 @@ class module_console_fileEnsureProductionSetting extends Command $this->printConf($output, $conf, $value, false, $message); break; case 'options': - $message = is_array($value) ? 'OK' : 'Should be array'; + $message = 'OK'; + + if (!is_array($value)) + { + $message = 'Should be array'; + $this->errors++; + } + $this->printConf($output, $conf, 'array()', false, $message); break; default: + $this->alerts++; $this->printConf($output, $conf, 'unknown', false, 'Not recognized'); break; } @@ -548,12 +646,26 @@ class module_console_fileEnsureProductionSetting extends Command switch ($conf) { case 'log': - $message = $value == false ? 'OK' : 'Should be deactivated'; + $message = 'OK'; + + if ($value !== false) + { + $message = 'Should be deactivated'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); break; case 'cache': $required = array_diff($required, array($conf)); - $message = is_array($value) ? 'OK' : 'Should be Array'; + $message = 'OK'; + + if (!is_array($value)) + { + $message = 'Should be Array'; + $this->errors++; + } + $this->printConf($output, $conf, 'array()', false, $message); $required_caches = array('query', 'result', 'metadata'); @@ -575,6 +687,7 @@ class module_console_fileEnsureProductionSetting extends Command } else { + $this->alerts++; if ($server) { $work_message = 'Cache server recommended'; @@ -598,6 +711,7 @@ class module_console_fileEnsureProductionSetting extends Command $this->verifyCacheOptions($output, $value_cache); break; default: + $this->alerts++; $this->printConf($output, "\t" . $key_cache, $value_cache, false, 'Not recognized'); break; } @@ -617,7 +731,14 @@ class module_console_fileEnsureProductionSetting extends Command break; case 'debug': $required = array_diff($required, array($conf)); - $message = $value == false ? 'OK' : 'Should be false'; + $message = 'OK'; + + if ($value !== false) + { + $message = 'Should be false'; + $this->errors++; + } + $this->printConf($output, $conf, $value, false, $message); break; case 'dbal': @@ -636,6 +757,7 @@ class module_console_fileEnsureProductionSetting extends Command $this->printConf($output, $conf, $value, false, $message); break; default: + $this->alerts++; $this->printConf($output, $conf, $value, false, 'Not recognized'); break; } @@ -684,15 +806,30 @@ class module_console_fileEnsureProductionSetting extends Command { case 'host'; $required_options = array_diff($required_options, array($conf)); - $message = is_scalar($value) ? 'OK' : 'Should be scalar'; + $message = 'OK'; + + if (!is_scalar($value)) + { + $message = 'Should be scalar'; + $this->errors++; + } + $this->printConf($output, "\t\t" . $conf, $value, false, $message); break; case 'port'; $required_options = array_diff($required_options, array($conf)); - $message = ctype_digit($value) ? 'OK' : 'Not recognized'; + $message = 'OK'; + + if (!ctype_digit($value)) + { + $message = 'Not recognized'; + $this->alerts++; + } + $this->printConf($output, "\t\t" . $conf, $value, false, $message); break; default: + $this->alerts++; $this->printConf($output, "\t\t" . $conf, $value, false, 'Not recognized'); break; } @@ -729,7 +866,7 @@ class module_console_fileEnsureProductionSetting extends Command return false; break; case 'memcache': - if (!memcache_connect($Service->getHost(), $Service->getPort())) + if (!@memcache_connect($Service->getHost(), $Service->getPort())) { return false; } diff --git a/lib/classes/module/report/activity.class.php b/lib/classes/module/report/activity.class.php index 368b34dadb..c81b080c82 100644 --- a/lib/classes/module/report/activity.class.php +++ b/lib/classes/module/report/activity.class.php @@ -453,7 +453,6 @@ class module_report_activity extends module_report $this->result[$i]['total'] += 1; $total['tot_dl'] += 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 * @return array */ - public function getConnexionBase($tab = false, $on= "") + public function getConnexionBase($tab = false, $on = "") { //default group on user column if (empty($on)) @@ -577,7 +576,7 @@ class module_report_activity extends module_report * @param array $tab config for the html table * @return array */ - public function getDetailDownload($tab = false, $on="") + public function getDetailDownload($tab = false, $on = "") { 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) { $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++; + + $this->result[$i]['nbprev'] = 0; + $this->result[$i]['poidprev'] = 0; + $this->result[$i]['nbdoc'] = 0; + $this->result[$i]['poiddoc'] = 0; + } + //doc info if ($row['final'] == 'document' && !is_null($user) && !is_null($row['usrid'])) { $this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0); - $this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? - 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]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0); $this->result[$i]['user'] = empty($row[$on]) ? "" . _('report:: non-renseigne') . "" : $row[$on]; $total['nbdoc'] += $this->result[$i]['nbdoc']; @@ -658,26 +675,25 @@ class module_report_activity extends module_report $this->result[$i]['usrid'] = $row['usrid']; } //preview info - if ($row['final'] == 'preview' && + if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') && !is_null($user) && !is_null($row['usrid'])) { - if (!isset($this->result[$i]['nbdoc'])) - $this->result[$i]['nbdoc'] = 0; - if (!isset($this->result[$i]['poiddoc'])) - $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]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0); + $this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0); + $this->result[$i]['user'] = empty($row[$on]) ? "" . _('report:: non-renseigne') . "" : $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); $this->result[$i]['usrid'] = $row['usrid']; } + $save_user = $user; } - + + unset($this->result[$i]); $nb_row = $i + 1; $this->total = $nb_row; @@ -756,7 +772,7 @@ class module_report_activity extends module_report } catch (Exception $e) { - + } } elseif ($value == "size") diff --git a/lib/classes/patch/320h.class.php b/lib/classes/patch/320h.class.php new file mode 100644 index 0000000000..1d4866eabf --- /dev/null +++ b/lib/classes/patch/320h.class.php @@ -0,0 +1,66 @@ +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; + } + +} diff --git a/lib/classes/patch/360.class.php b/lib/classes/patch/360.class.php index 231fcc3524..186e1427c5 100644 --- a/lib/classes/patch/360.class.php +++ b/lib/classes/patch/360.class.php @@ -59,7 +59,7 @@ class patch_360 implements patchInterface foreach ($tables as $table) { - $sql = 'TRUNCATE ' . $table; + $sql = 'DELETE FROM ' . $table; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); diff --git a/lib/classes/patch/3602.class.php b/lib/classes/patch/3602.class.php index f707bfb2c4..619ab62a73 100644 --- a/lib/classes/patch/3602.class.php +++ b/lib/classes/patch/3602.class.php @@ -54,13 +54,19 @@ class patch_3602 implements patchInterface 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(); - + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute(); + $stmt->closeCursor(); + } + catch(\PDOException $e) + { + + } + return true; } diff --git a/lib/classes/record/Interface.class.php b/lib/classes/record/Interface.class.php index 5583384643..69678b155b 100644 --- a/lib/classes/record/Interface.class.php +++ b/lib/classes/record/Interface.class.php @@ -95,8 +95,6 @@ interface record_Interface public function set_binary_status($status); - public function get_reg_name(); - public function get_hd_file(); public function delete(); diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 177348f54a..bd8d3323d1 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -140,8 +140,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface const CACHE_GROUPING = 'grouping'; const CACHE_STATUS = 'status'; - protected static $_regfields; - /** * * @param $base_id @@ -895,16 +893,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ 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 = ''; $appbox = appbox::get_instance(\bootstrap::getCore()); $session = $appbox->get_session(); @@ -944,98 +932,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface 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 $sbas_id - * @param caption_record $desc - * @return - */ - 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 - */ - 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 @@ -1487,42 +1383,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface 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; - } /** * diff --git a/lib/classes/searchEngine/adapter/phrasea/engine.class.php b/lib/classes/searchEngine/adapter/phrasea/engine.class.php index c410c6e498..55983f3d75 100644 --- a/lib/classes/searchEngine/adapter/phrasea/engine.class.php +++ b/lib/classes/searchEngine/adapter/phrasea/engine.class.php @@ -631,7 +631,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract return array(); $rs = $res['results']; $res = array_shift($rs); - if (!$res['xml']) + if (! isset($res['xml'])) return array(); $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('', ''), (string) $value); } - $val = implode(' '.$field['separator'].' ', $val); + $separator = $field['separator'] ? $field['separator'][0] : ''; + $val = implode(' '.$separator.' ', $val); } else { diff --git a/lib/classes/set/order.class.php b/lib/classes/set/order.class.php index 9eb0014cba..c81e43e67a 100644 --- a/lib/classes/set/order.class.php +++ b/lib/classes/set/order.class.php @@ -222,14 +222,26 @@ class set_order extends set_abstract $core = \bootstrap::getCore(); $em = $core->getEntityManager(); - $repository = $em->getRepository('\Entities\Basket'); - + + $Basket = null; /* @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) { - $Basket = new Basket(); + $Basket = new \Entities\Basket(); $Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d'))); $Basket->setOwner($this->user); $Basket->setPusher($core->getAuthenticatedUser()); @@ -265,16 +277,15 @@ class set_order extends set_abstract $sbas_id = phrasea::sbasFromBas($basrec['base_id']); $record = new record_adapter($sbas_id, $basrec['record_id']); - $BasketElement = new BasketElement(); + $BasketElement = new \Entities\BasketElement(); $BasketElement->setRecord($record); $BasketElement->setBasket($Basket); $Basket->addBasketElement($BasketElement); $em->persist($BasketElement); - - $em->merge($Basket); - + + $params = array( ':usr_id' => $session->get_usr_id() , ':order_id' => $this->id diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php index a35f90b03f..742941c4c6 100644 --- a/lib/classes/setup.class.php +++ b/lib/classes/setup.class.php @@ -607,18 +607,16 @@ class setup if ($Core->getCache()->isServer()) { $stats = $Core->getCache()->getStats(); - + + echo '
    • ' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '
    • '; + echo ""; + foreach ($stats as $name => $stat) { - echo '
    • Statistics given by `' . $name . '`
    • '; - echo '
    • ' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '
    • '; - echo "
      "; - foreach ($stat as $key => $value) - { - echo ""; - } - echo "
      " . $key . " " . $value . "
      "; + echo "" . $name . " " . $stat . ""; } + + echo ""; } else { @@ -643,9 +641,9 @@ class setup } 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) - $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); } diff --git a/lib/classes/sphinx/configuration.class.php b/lib/classes/sphinx/configuration.class.php index 92d9d43607..cbd3b40972 100644 --- a/lib/classes/sphinx/configuration.class.php +++ b/lib/classes/sphinx/configuration.class.php @@ -67,15 +67,17 @@ class sphinx_configuration $defaults = array( 'sbas' => self::OPT_ALL_SBAS - , 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE) + , 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE) , '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 , 'charset_tables' => array() ); $options = array_merge($defaults, $options); + $options['charset_tables'] = array_unique($options['charset_tables']); + $lb = phrasea::sbas_params(); $conf = ''; @@ -439,7 +441,7 @@ class sphinx_configuration path = /var/sphinx/datas/docs_realtime_' . $serialized . ' -' . $charset_abstract . ' + ' . $charset_abstract . ' rt_field = value # rt_field = meta_struct_id @@ -593,6 +595,9 @@ searchd # optional, default is 256 # max_filters = 512 + + compat_sphinxql_magics = 0 + } '; diff --git a/lib/classes/sphinxrt.class.php b/lib/classes/sphinxrt.class.php index a8c5b354ce..28deccec5a 100644 --- a/lib/classes/sphinxrt.class.php +++ b/lib/classes/sphinxrt.class.php @@ -81,7 +81,7 @@ class sphinxrt if ($rt_id) { $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->execute(); $stmt->closeCursor(); @@ -99,14 +99,13 @@ class sphinxrt $cl = new SphinxClient(); if ($cl->Status() === false) - return $this; $cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port')); $cl->SetConnectTimeout(1); - $status = strrev($status); + $status = strrev($status); $new_stat = array(); for ($i = 4; $i < strlen($status); $i++) { @@ -122,20 +121,18 @@ class sphinxrt 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_coll = crc32($sbas_id . '_' . $coll_id); + $crc_sbas_tag = crc32($sbas_id . '_' . $tag_id); + $crc_sbas_coll = crc32($sbas_id . '_' . $coll_id); $crc_sbas_record = crc32($sbas_id . '_' . $record_id); - $crc_type = crc32($type); + $crc_type = crc32($type); $this->connection->beginTransaction(); -// foreach ($content as $value) -// { - $sql = "REPLACE INTO " . $rt_id . " VALUES ( + $sql = "REPLACE INTO " . $rt_id . " VALUES ( '" . (int) $meta_id . "' - ,'" . str_replace("'", "\'", implode(' ', $content)) . "' + ,'" . str_replace("'", "\'", $content) . "' ,'" . (int) $tag_id . "' ," . (int) $record_id . " ," . (int) $sbas_id . " @@ -149,7 +146,6 @@ class sphinxrt ," . (int) $created->format('U') . " )"; $stmt = $this->connection->prepare($sql); $stmt->execute(); -// } $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) { - $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_type = crc32($type); + $crc_type = crc32($type); $this->connection->beginTransaction(); diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 7a5a950a50..bb69235ff5 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -10,8 +10,10 @@ $GV_sit = md5(time() . '--' . mt_rand(1000000, 9999999)); include_once dirname(__FILE__) . "/../../lib/classes/User/Interface.class.php"; include_once dirname(__FILE__) . "/../../lib/classes/User/Adapter.class.php"; -$lngs = User_Adapter::avLanguages(); + +$lngs = User_Adapter::avLanguages(); $avLanguages = array(); + foreach ($lngs as $lng => $locales) { foreach ($locales as $loc => $locname) @@ -20,28 +22,47 @@ foreach ($lngs as $lng => $locales) } } -$eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance(\bootstrap::getCore()), bootstrap::getCore()); +$Core = \bootstrap::getCore(); + +$extractDateFields = function(\Alchemy\Phrasea\Core $Core) { + $date_sort_fields = array(''=>''); + if ($Core->getConfiguration()->isInstalled()) + { + $ProdHelper = new Alchemy\Phrasea\Helper\Prod($Core, Symfony\Component\HttpFoundation\Request::createFromGlobals()); + $datas = $ProdHelper->get_search_datas(); + foreach ($datas['dates'] as $date) + { + $date_sort_fields[$date['fieldname']] = $date['fieldname']; + } + } + return $date_sort_fields; +}; + +$date_sort_fields = $extractDateFields($Core); + + +$eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance($Core), $Core); $PHP_CONF = array( - 'output_buffering' => '4096' //INI_ALL - , 'memory_limit' => '1024M' //INI_ALL - , 'error_reporting' => '6143' //INI_ALL - , 'default_charset' => 'UTF-8' //INI_ALL - , 'session.use_cookies' => '1' //INI_ALL - , 'session.use_only_cookies' => '1' //INI_ALL - , 'session.auto_start' => '0' //INI_ALL - , 'session.hash_function' => '1' //INI_ALL - , 'session.hash_bits_per_character' => '6' //INI_ALL - , 'allow_url_fopen' => 'on' //INI_ALL - , 'display_errors' => 'off' //INI_ALL - , 'display_startup_errors' => 'off' //INI_ALL - , 'log_errors' => 'off' //INI_ALL + 'output_buffering' => '4096' //INI_ALL + , 'memory_limit' => '1024M' //INI_ALL + , 'error_reporting' => '6143' //INI_ALL + , 'default_charset' => 'UTF-8' //INI_ALL + , 'session.use_cookies' => '1' //INI_ALL + , 'session.use_only_cookies' => '1' //INI_ALL + , 'session.auto_start' => '0' //INI_ALL + , 'session.hash_function' => '1' //INI_ALL + , 'session.hash_bits_per_character' => '6' //INI_ALL + , 'allow_url_fopen' => 'on' //INI_ALL + , 'display_errors' => 'off' //INI_ALL + , 'display_startup_errors' => 'off' //INI_ALL + , 'log_errors' => 'off' //INI_ALL ); -$PHP_REQ = array( - 'safe_mode' => 'off' - , 'file_uploads' => '1' - , 'magic_quotes_runtime' => 'off' //INI_ALL - , 'magic_quotes_gpc' => 'off' //INI_PER_DIR -- just for check +$PHP_REQ = array( + 'safe_mode' => 'off' + , 'file_uploads' => '1' + , 'magic_quotes_runtime' => 'off' //INI_ALL + , 'magic_quotes_gpc' => 'off' //INI_PER_DIR -- just for check ); $youtube_console_url = 'https://code.google.com/apis/console/'; @@ -57,472 +78,452 @@ $dailymotion_callback = '/prod/bridge/callback/dailymotion/'; $create_api_dailymotion = 'http://www.dailymotion.com/profile/developer'; $GV = array( - array( - 'section' => _('GV::section:: Serveur HTTP'), - 'vars' => array( - array( - 'type' => 'timezone', - 'name' => 'GV_timezone', - 'comment' => _('reglages:: Timezone de l\'installation'), - 'default' => 'Europe/Paris', - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_sit', - 'comment' => _('reglages:: Nom de linstallation'), - 'default' => $GV_sit, - 'readonly' => true, - 'required' => true - ), - array( - 'type' => 'enum', - 'name' => 'GV_default_lng', - 'comment' => _('reglages:: Langue par defaut'), - 'default' => 'fr_FR', - 'available' => $avLanguages, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_STATIC_URL', - 'end_slash' => false, - 'comment' => _('reglages:: URL statique (optionnel)'), - 'default' => '', - 'required' => false - ) - ) - ), array( - 'section' => _('GV::section:: Etat de maintenance'), - 'rolled' => true, - 'vars' => array( - array( - 'type' => 'text', - 'name' => 'GV_message', - 'comment' => _('reglages:: Message a diffuser aux utilisateurs'), - 'default' => "May the force be with you" - ), - array( - 'type' => 'boolean', - 'name' => 'GV_message_on', - 'comment' => _('reglages:: activation du message a diffuser aux utilistaeurs'), - 'default' => false - ), - array( - 'type' => 'boolean', - 'name' => 'GV_log_errors', - 'comment' => _('reglages:: logguer les erreurs'), - 'default' => false - ) - ) - ), array( - 'section' => _('GV::section:: Connectivite aux webservices'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_google_api', - 'comment' => _('reglages:: Utiliser els google apis'), - 'default' => true, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_i18n_service', - 'comment' => _('reglages:: Service phrasea de localisation'), - 'default' => 'http://localization.webservice.alchemyasp.com/', - 'end_slash' => true, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_bitly_user', - 'comment' => _('reglages:: Nom d\'utilisateur pour l\'api bit.ly'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_bitly_key', - 'comment' => _('reglages:: ccle d\'api pour l\'api bit.ly'), - 'default' => '', - ), - array( - 'type' => 'boolean', - 'name' => 'GV_captchas', - 'comment' => _('reglages:: Utilisation de l\'api recpatcha'), - 'default' => false, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_captcha_public_key', - 'comment' => _('reglages:: clef publique recaptcha'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_captcha_private_key', - 'comment' => _('reglages:: clef privee recaptcha'), - 'default' => '' - ) - ) - ), array( - 'section' => _('GV::section:: Connectivite a Youtube'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_youtube_api', - 'comment' => sprintf(_('reglages:: Utiliser l\'api youtube, voir %s,
      mettre la callback a WEBSITE_URL/prod/bridge/callback/youtube'), $youtube_console_url), - 'default' => false, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_youtube_client_id', - 'comment' => _('reglages:: Youtube client id'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_youtube_client_secret', - 'comment' => _('reglages:: Youtube clientsecret'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_youtube_dev_key', - 'comment' => sprintf(_('reglages:: Youtube cle developpeur, voir %s'), $dashboard_youtube), - 'default' => '' - ) - ) - ), array( - 'section' => _('GV::section:: Connectivite a FlickR'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_flickr_api', - 'comment' => sprintf(_('reglages:: Utiliser l api flickr, voir %s, puis set la callback a %s'), $create_api_flickr, $flickr_callback), - 'default' => false, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_flickr_client_id', - 'comment' => _('reglages:: FlickR client id'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_flickr_client_secret', - 'comment' => _('reglages:: FlickR client secret'), - 'default' => '' - ) - ) - ), array( - 'section' => _('GV::section:: Connectivite a Dailymotion'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_dailymotion_api', - 'comment' => sprintf(_('reglages:: Utiliser l api dailymotion, voir %s, puis set la callback a %s'), $create_api_dailymotion, $dailymotion_callback), - 'default' => false, - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_dailymotion_client_id', - 'comment' => _('reglages:: dailymotion client id'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_dailymotion_client_secret', - 'comment' => _('reglages:: dailymotion client secret'), - 'default' => '' - ) - ) - ), array( - 'section' => _('GV::section:: Gestionnaire d\'evenements'), - 'vars' => array( - array( - 'type' => 'enum_multi', - 'name' => 'GV_events', - 'default'=>null, - 'comment' => _('reglages:: Evenements'), - 'available'=> $eventsmanager->list_all('event'), - 'default'=> array_keys($eventsmanager->list_all('event')) - ), - array( - 'type' => 'enum_multi', - 'name' => 'GV_notifications', - 'default'=>null, - 'comment' => _('reglages:: Notifications'), - 'available'=> $eventsmanager->list_all('notify'), - 'default'=> array_keys($eventsmanager->list_all('notify')) - ) - ) - ), array( - 'section' => _('GV::section:: Stockage des documents'), - 'vars' => array( - array( - 'type' => 'string', - 'name' => 'GV_appletAllowedFileExt', - 'comment' => _('reglages:: extensions de fichier autorisees en upload, separees par des virgules. * pour autoriser tous les fichiers'), - 'default' => 'jpg,jpeg,bmp,tif,gif,png,pdf,doc,odt,mpg,mpeg,mov,avi,xls,flv,mp3,mp2', - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_base_datapath_web', - 'end_slash' => true, - 'comment' => _('reglages:: dossier de stockage des vignettes publiees en acces direct'), - 'default'=>'', - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_base_datapath_noweb', - 'end_slash' => true, - 'comment' => _('reglages:: dossier de stockage des fichiers proteges de l\'acces direct'), - 'default'=>'', - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_base_dataurl', - 'comment' => _('reglages:: point de montage des vignettes publiees en acces direct'), - 'default' => 'web', - 'end_slash' => false, - 'required' => true - ) - ) + array( + 'section' => _('GV::section:: Serveur HTTP'), + 'vars' => array( + array( + 'type' => 'timezone', + 'name' => 'GV_timezone', + 'comment' => _('reglages:: Timezone de l\'installation'), + 'default' => 'Europe/Paris', + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_sit', + 'comment' => _('reglages:: Nom de linstallation'), + 'default' => $GV_sit, + 'readonly' => true, + 'required' => true + ), + array( + 'type' => 'enum', + 'name' => 'GV_default_lng', + 'comment' => _('reglages:: Langue par defaut'), + 'default' => 'fr_FR', + 'available' => $avLanguages, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_STATIC_URL', + 'end_slash' => false, + 'comment' => _('reglages:: URL statique (optionnel)'), + 'default' => '', + 'required' => false + ) ) -// , array( -// 'section' => _('GV::section:: Serveurs de cache'), -// 'vars' => array( -// array( -// 'type' => 'boolean', -// 'name' => 'GV_use_cache', -// 'comment' => _('reglages:: Utiliser un serveur de cache'), -// 'default' => false, -// 'required' => true -// ), -// array( -// 'type' => 'enum', -// 'name' => 'GV_cache_server_type', -// 'comment' => _('reglages:: Utiliser un serveur de cache'), -// 'default' => '', -// 'available' => array(''=>_('Aucun'),'redis' => 'Redis', 'memcached' => 'Memcached') -// ), -// array( -// 'type' => 'string', -// 'name' => 'GV_cache_server_host', -// 'comment' => _('setup:: Hote du Serveur de cache'), -// 'default' => '127.0.0.1', -// 'required' => false -// ), -// array( -// 'type' => 'integer', -// 'name' => 'GV_cache_server_port', -// 'comment' => _('reglages:: port du serveur de cache'), -// 'default' => 11211 -// ) -// ) -// ) - ,array( - 'section' => _('GV::section:: Serveur Sphinx'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_sphinx', - 'comment' => _('Utiliser Sphinx'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_sphinx_host', - 'comment' => _('reglages:: de l\'adresse du serveur sphinx'), - 'default' => '127.0.0.1' - ), - array( - 'type' => 'integer', - 'name' => 'GV_sphinx_port', - 'comment' => _('reglages:: port du serveur sphinx'), - 'default' => 9306 - ), - array( - 'type' => 'string', - 'name' => 'GV_sphinx_rt_host', - 'comment' => _('reglages:: de l\'adresse du serveur RT sphinx'), - 'default' => '127.0.0.1' - ), - array( - 'type' => 'integer', - 'name' => 'GV_sphinx_rt_port', - 'comment' => _('reglages:: port du serveur RT sphinx'), - 'default' => 9308 - ) - ) - ), array( - 'section' => _('GV::section:: Executables externes'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_modxsendfile', - 'comment' => _('reglages:: mod_xsendfileapache active'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_X_Accel_Redirect', - 'comment' => _('reglages:: Path en acces pour X-Accel-Redirect (NginX Uniquement)'), - 'default' => '', - 'end_slash' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_X_Accel_Redirect_mount_point', - 'comment' => _('reglages:: Point de montage pour X-Accel-Redirect (NginX Uniquement)'), - 'default' => 'noweb', - 'end_slash' => false - ), - array( - 'type' => 'boolean', - 'name' => 'GV_h264_streaming', - 'comment' => _('reglages:: activation du stream h264 via mod_token - attention, necessite les modules apache mod_h264_streaming et mod_auth_token'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_mod_auth_token_directory', - 'end_slash' => true, - 'comment' => _('reglages:: point de montage du dossier protege via auth_token'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_mod_auth_token_directory_path', - 'end_slash' => false, - 'comment' => _('reglages:: path complet du dossier protege via auth_token'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_mod_auth_token_passphrase', - 'comment' => _('reglages:: passphrase du mod_auth_token (definie dans le fichier de configuration apache)'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_cli', - 'comment' => _('reglages:: executable PHP CLI'), - 'default'=>'', - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_PHP_INI', - 'comment' => _('reglages:: path du php.ini specifique (vide si non utilise)'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_imagick', - 'default'=>'', - 'comment' => _('reglages:: chemin de l\'executable convert'), - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_pathcomposite', - 'default'=>'', - 'comment' => _('reglages:: chemin de l\'executable composite'), - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_exiftool', - 'default'=>'', - 'comment' => _('reglages:: chemin de l\'executable exiftools'), - 'required' => true - ), - array( - 'type' => 'string', - 'name' => 'GV_swf_extract', - 'comment' => _('reglages:: chemin de l\'executable swfextract'), - 'default' => '', - 'required' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_pdf2swf', - 'comment' => _('reglages:: chemin de l\'executable pdf2swf'), - 'default' => '', - 'required' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_swf_render', - 'comment' => _('reglages:: chemin de l\'executable swfrender'), - 'default' => '', - 'required' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_unoconv', - 'comment' => _('reglages:: chemin de l\'executable unoconv'), - 'default' => '', - 'required' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_ffmpeg', - 'comment' => _('reglages:: chemin de l\'executable FFmpeg'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_mp4box', - 'comment' => _('reglages:: chemin de l\'executable MP4Box'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_mplayer', - 'comment' => _('reglages:: chemin de l\'executable Mplayer'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_pdftotext', - 'comment' => _('reglages:: chemin de l\'executable pdftotext (xpdf)'), - 'default' => '' - ), - array( - 'type' => 'integer', - 'name' => 'GV_pdfmaxpages', - 'comment' => _('reglages:: nombre maximum de page a extraire (PDF)'), - 'default' => 5 - ) - ) - ), array( - 'section' => _('GV::section:: Repertoires utilitaires'), - 'vars' => array( - array( - 'type' => 'string', - 'name' => 'GV_filesOwner', - 'comment' => _('reglages:: proprietaire des fichiers'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_filesGroup', - 'comment' => _('reglages:: groupes des fichiers'), - 'default' => '' - ) - ) - ), array( - 'section' => _('GV::section:: Configuration principale'), - 'vars' => array( + ), array( + 'section' => _('GV::section:: Etat de maintenance'), + 'rolled' => true, + 'vars' => array( + array( + 'type' => 'text', + 'name' => 'GV_message', + 'comment' => _('reglages:: Message a diffuser aux utilisateurs'), + 'default' => "May the force be with you" + ), + array( + 'type' => 'boolean', + 'name' => 'GV_message_on', + 'comment' => _('reglages:: activation du message a diffuser aux utilistaeurs'), + 'default' => false + ), + array( + 'type' => 'boolean', + 'name' => 'GV_log_errors', + 'comment' => _('reglages:: logguer les erreurs'), + 'default' => false + ) + ) + ), array( + 'section' => _('GV::section:: Connectivite aux webservices'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_google_api', + 'comment' => _('reglages:: Utiliser els google apis'), + 'default' => true, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_i18n_service', + 'comment' => _('reglages:: Service phrasea de localisation'), + 'default' => 'http://localization.webservice.alchemyasp.com/', + 'end_slash' => true, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_bitly_user', + 'comment' => _('reglages:: Nom d\'utilisateur pour l\'api bit.ly'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_bitly_key', + 'comment' => _('reglages:: ccle d\'api pour l\'api bit.ly'), + 'default' => '', + ), + array( + 'type' => 'boolean', + 'name' => 'GV_captchas', + 'comment' => _('reglages:: Utilisation de l\'api recpatcha'), + 'default' => false, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_captcha_public_key', + 'comment' => _('reglages:: clef publique recaptcha'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_captcha_private_key', + 'comment' => _('reglages:: clef privee recaptcha'), + 'default' => '' + ) + ) + ), array( + 'section' => _('GV::section:: Connectivite a Youtube'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_youtube_api', + 'comment' => sprintf(_('reglages:: Utiliser l\'api youtube, voir %s,
      mettre la callback a WEBSITE_URL/prod/bridge/callback/youtube'), $youtube_console_url), + 'default' => false, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_youtube_client_id', + 'comment' => _('reglages:: Youtube client id'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_youtube_client_secret', + 'comment' => _('reglages:: Youtube clientsecret'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_youtube_dev_key', + 'comment' => sprintf(_('reglages:: Youtube cle developpeur, voir %s'), $dashboard_youtube), + 'default' => '' + ) + ) + ), array( + 'section' => _('GV::section:: Connectivite a FlickR'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_flickr_api', + 'comment' => sprintf(_('reglages:: Utiliser l api flickr, voir %s, puis set la callback a %s'), $create_api_flickr, $flickr_callback), + 'default' => false, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_flickr_client_id', + 'comment' => _('reglages:: FlickR client id'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_flickr_client_secret', + 'comment' => _('reglages:: FlickR client secret'), + 'default' => '' + ) + ) + ), array( + 'section' => _('GV::section:: Connectivite a Dailymotion'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_dailymotion_api', + 'comment' => sprintf(_('reglages:: Utiliser l api dailymotion, voir %s, puis set la callback a %s'), $create_api_dailymotion, $dailymotion_callback), + 'default' => false, + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_dailymotion_client_id', + 'comment' => _('reglages:: dailymotion client id'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_dailymotion_client_secret', + 'comment' => _('reglages:: dailymotion client secret'), + 'default' => '' + ) + ) + ), array( + 'section' => _('GV::section:: Gestionnaire d\'evenements'), + 'vars' => array( + array( + 'type' => 'enum_multi', + 'name' => 'GV_events', + 'default' => null, + 'comment' => _('reglages:: Evenements'), + 'available' => $eventsmanager->list_all('event'), + 'default' => array_keys($eventsmanager->list_all('event')) + ), + array( + 'type' => 'enum_multi', + 'name' => 'GV_notifications', + 'default' => null, + 'comment' => _('reglages:: Notifications'), + 'available' => $eventsmanager->list_all('notify'), + 'default' => array_keys($eventsmanager->list_all('notify')) + ) + ) + ), array( + 'section' => _('GV::section:: Stockage des documents'), + 'vars' => array( + array( + 'type' => 'string', + 'name' => 'GV_appletAllowedFileExt', + 'comment' => _('reglages:: extensions de fichier autorisees en upload, separees par des virgules. * pour autoriser tous les fichiers'), + 'default' => 'jpg,jpeg,bmp,tif,gif,png,pdf,doc,odt,mpg,mpeg,mov,avi,xls,flv,mp3,mp2', + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_base_datapath_web', + 'end_slash' => true, + 'comment' => _('reglages:: dossier de stockage des vignettes publiees en acces direct'), + 'default' => '', + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_base_datapath_noweb', + 'end_slash' => true, + 'comment' => _('reglages:: dossier de stockage des fichiers proteges de l\'acces direct'), + 'default' => '', + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_base_dataurl', + 'comment' => _('reglages:: point de montage des vignettes publiees en acces direct'), + 'default' => 'web', + 'end_slash' => false, + 'required' => true + ) + ) + ) + , array( + 'section' => _('GV::section:: Serveur Sphinx'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_sphinx', + 'comment' => _('Utiliser Sphinx'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_sphinx_host', + 'comment' => _('reglages:: de l\'adresse du serveur sphinx'), + 'default' => '127.0.0.1' + ), + array( + 'type' => 'integer', + 'name' => 'GV_sphinx_port', + 'comment' => _('reglages:: port du serveur sphinx'), + 'default' => 9306 + ), + array( + 'type' => 'string', + 'name' => 'GV_sphinx_rt_host', + 'comment' => _('reglages:: de l\'adresse du serveur RT sphinx'), + 'default' => '127.0.0.1' + ), + array( + 'type' => 'integer', + 'name' => 'GV_sphinx_rt_port', + 'comment' => _('reglages:: port du serveur RT sphinx'), + 'default' => 9308 + ) + ) + ) + , array( + 'section' => _('Phrasea Engine'), + 'vars' => array( + array( + 'type' => 'enum', + 'name' => 'GV_phrasea_sort', + 'comment' => _('Default results sort'), + 'default' => '', + 'available' => $date_sort_fields + ) + ) + ), array( + 'section' => _('GV::section:: Executables externes'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_modxsendfile', + 'comment' => _('reglages:: mod_xsendfileapache active'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_X_Accel_Redirect', + 'comment' => _('reglages:: Path en acces pour X-Accel-Redirect (NginX Uniquement)'), + 'default' => '', + 'end_slash' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_X_Accel_Redirect_mount_point', + 'comment' => _('reglages:: Point de montage pour X-Accel-Redirect (NginX Uniquement)'), + 'default' => 'noweb', + 'end_slash' => false + ), + array( + 'type' => 'boolean', + 'name' => 'GV_h264_streaming', + 'comment' => _('reglages:: activation du stream h264 via mod_token - attention, necessite les modules apache mod_h264_streaming et mod_auth_token'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_mod_auth_token_directory', + 'end_slash' => true, + 'comment' => _('reglages:: point de montage du dossier protege via auth_token'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_mod_auth_token_directory_path', + 'end_slash' => false, + 'comment' => _('reglages:: path complet du dossier protege via auth_token'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_mod_auth_token_passphrase', + 'comment' => _('reglages:: passphrase du mod_auth_token (definie dans le fichier de configuration apache)'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_cli', + 'comment' => _('reglages:: executable PHP CLI'), + 'default' => '', + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_PHP_INI', + 'comment' => _('reglages:: path du php.ini specifique (vide si non utilise)'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_imagick', + 'default' => '', + 'comment' => _('reglages:: chemin de l\'executable convert'), + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_pathcomposite', + 'default' => '', + 'comment' => _('reglages:: chemin de l\'executable composite'), + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_exiftool', + 'default' => '', + 'comment' => _('reglages:: chemin de l\'executable exiftools'), + 'required' => true + ), + array( + 'type' => 'string', + 'name' => 'GV_swf_extract', + 'comment' => _('reglages:: chemin de l\'executable swfextract'), + 'default' => '', + 'required' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_pdf2swf', + 'comment' => _('reglages:: chemin de l\'executable pdf2swf'), + 'default' => '', + 'required' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_swf_render', + 'comment' => _('reglages:: chemin de l\'executable swfrender'), + 'default' => '', + 'required' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_unoconv', + 'comment' => _('reglages:: chemin de l\'executable unoconv'), + 'default' => '', + 'required' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_ffmpeg', + 'comment' => _('reglages:: chemin de l\'executable FFmpeg'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_mp4box', + 'comment' => _('reglages:: chemin de l\'executable MP4Box'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_mplayer', + 'comment' => _('reglages:: chemin de l\'executable Mplayer'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_pdftotext', + 'comment' => _('reglages:: chemin de l\'executable pdftotext (xpdf)'), + 'default' => '' + ), + array( + 'type' => 'integer', + 'name' => 'GV_pdfmaxpages', + 'comment' => _('reglages:: nombre maximum de page a extraire (PDF)'), + 'default' => 5 + ) + ) + ), array( + 'section' => _('GV::section:: Repertoires utilitaires'), + 'vars' => array( + array( + 'type' => 'string', + 'name' => 'GV_filesOwner', + 'comment' => _('reglages:: proprietaire des fichiers'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_filesGroup', + 'comment' => _('reglages:: groupes des fichiers'), + 'default' => '' + ) + ) + ), array( + 'section' => _('GV::section:: Configuration principale'), + 'vars' => array( // array( // 'type' => 'boolean', // 'name' => 'GV_logobeforebas', @@ -530,33 +531,33 @@ $GV = array( // 'default' => false, // 'required' => true // ), - array( - 'type' => 'string', - 'name' => 'GV_adminMail', - 'comment' => _('reglages:: email de l\'administrateur'), - 'default' => 'support@alchemy.fr' - ), - array( - 'type' => 'boolean', - 'name' => 'GV_view_bas_and_coll', - 'comment' => _('reglages:: Afficher le nom des bases et des collections'), - 'default' => true, - 'required' => true - ), - array( - 'type' => 'boolean', - 'name' => 'GV_choose_export_title', - 'comment' => _('reglages:: activer le choix du nom de fichier a l\'export'), - 'default' => false, - 'required' => true - ), - array( - 'type' => 'enum', - 'name' => 'GV_default_export_title', - 'comment' => _('reglages:: choix par defaut des noms de fichier a l\'export'), - 'default' => 'support@alchemy.fr', - 'available' => array('title' => 'Titre du document', 'original' => 'Nom original') - ), + array( + 'type' => 'string', + 'name' => 'GV_adminMail', + 'comment' => _('reglages:: email de l\'administrateur'), + 'default' => 'support@alchemy.fr' + ), + array( + 'type' => 'boolean', + 'name' => 'GV_view_bas_and_coll', + 'comment' => _('reglages:: Afficher le nom des bases et des collections'), + 'default' => true, + 'required' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_choose_export_title', + 'comment' => _('reglages:: activer le choix du nom de fichier a l\'export'), + 'default' => false, + 'required' => true + ), + array( + 'type' => 'enum', + 'name' => 'GV_default_export_title', + 'comment' => _('reglages:: choix par defaut des noms de fichier a l\'export'), + 'default' => 'support@alchemy.fr', + 'available' => array('title' => 'Titre du document', 'original' => 'Nom original') + ), // array( // 'type' => 'boolean', // 'name' => 'GV_ArchiveSorted', @@ -564,19 +565,19 @@ $GV = array( // 'default' => true, // 'required' => true // ), - array( - 'type' => 'enum', - 'name' => 'GV_social_tools', - 'comment' => _('reglages:: Active les partages Facebook et Twitter'), - 'available' => array('none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Activated'), - 'default' => 'none', - 'required' => false - ) - ) - ), array( - 'section' => _('GV::section:: Page d\'accueil'), - 'rolled' => true, - 'vars' => array( + array( + 'type' => 'enum', + 'name' => 'GV_social_tools', + 'comment' => _('reglages:: Active les partages Facebook et Twitter'), + 'available' => array('none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Activated'), + 'default' => 'none', + 'required' => false + ) + ) + ), array( + 'section' => _('GV::section:: Page d\'accueil'), + 'rolled' => true, + 'vars' => array( // array( // 'type' => 'boolean', // 'name' => 'GV_find_password', @@ -584,78 +585,78 @@ $GV = array( // 'default' => true, // 'required' => true // ), - array( - 'type' => 'enum', - 'name' => 'GV_home_publi', - 'comment' => _('reglages:: presentation sur la home'), - 'default' => 'COOLIRIS', - 'available' => array('DISPLAYx1' => 'slideshow', 'SCROLL' => 'Bandeau defilant', 'COOLIRIS' => 'Cooliris'), - 'required' => true - ) - ) - ), array( - 'section' => _('GV::section:: Moteur de recherche'), - 'rolled' => true, - 'vars' => array( - array( - 'type' => 'integer', - 'name' => 'GV_min_letters_truncation', - 'comment' => _('reglages:: Nombre minimal de lettre avec la troncature (Recherche)'), - 'default' => 1 - ), - array( - 'type' => 'string', - 'name' => 'GV_defaultQuery', - 'comment' => _('reglages:: Question par defaut'), - 'default' => 'all' - ), - array( - 'type' => 'enum', - 'name' => 'GV_defaultQuery_type', - 'comment' => _('reglages:: type de document cherches par defaut e l\'ouverture du site'), - 'available' => array('0' => 'Documents', '1' => 'Regroupements'), - 'default' => '0' - ) - ) - ), array( - 'section' => _('GV::section:: Report'), - 'rolled' => true, - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_anonymousReport', - 'comment' => _('reglages:: report anonyme (masque les infos concernant les utilisateurs)'), - 'default' => false, - 'required' => true - ) - ) - ), array( - 'section' => _('GV::section:: Modules supplementaires'), - 'rolled' => true, - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_thesaurus', - 'comment' => _('reglages:: Activation de l\'outil thesaurus'), - 'default' => true - ), array( - 'type' => 'boolean', - 'name' => 'GV_multiAndReport', - 'comment' => _('reglages:: Activation du Mode MultiDOC'), - 'default' => true - ), array( - 'type' => 'boolean', - 'name' => 'GV_seeOngChgDoc', - 'comment' => _('reglages:: Substitution de HD d\'un record '), - 'default' => false - ), array( - 'type' => 'boolean', - 'name' => 'GV_seeNewThumb', - 'comment' => _('reglages:: Substitution de thumbnail d\'un record'), - 'default' => false - ) - ) + array( + 'type' => 'enum', + 'name' => 'GV_home_publi', + 'comment' => _('reglages:: presentation sur la home'), + 'default' => 'COOLIRIS', + 'available' => array('DISPLAYx1' => 'slideshow', 'SCROLL' => 'Bandeau defilant', 'COOLIRIS' => 'Cooliris'), + 'required' => true + ) ) + ), array( + 'section' => _('GV::section:: Moteur de recherche'), + 'rolled' => true, + 'vars' => array( + array( + 'type' => 'integer', + 'name' => 'GV_min_letters_truncation', + 'comment' => _('reglages:: Nombre minimal de lettre avec la troncature (Recherche)'), + 'default' => 1 + ), + array( + 'type' => 'string', + 'name' => 'GV_defaultQuery', + 'comment' => _('reglages:: Question par defaut'), + 'default' => 'all' + ), + array( + 'type' => 'enum', + 'name' => 'GV_defaultQuery_type', + 'comment' => _('reglages:: type de document cherches par defaut e l\'ouverture du site'), + 'available' => array('0' => 'Documents', '1' => 'Regroupements'), + 'default' => '0' + ) + ) + ), array( + 'section' => _('GV::section:: Report'), + 'rolled' => true, + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_anonymousReport', + 'comment' => _('reglages:: report anonyme (masque les infos concernant les utilisateurs)'), + 'default' => false, + 'required' => true + ) + ) + ), array( + 'section' => _('GV::section:: Modules supplementaires'), + 'rolled' => true, + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_thesaurus', + 'comment' => _('reglages:: Activation de l\'outil thesaurus'), + 'default' => true + ), array( + 'type' => 'boolean', + 'name' => 'GV_multiAndReport', + 'comment' => _('reglages:: Activation du Mode MultiDOC'), + 'default' => true + ), array( + 'type' => 'boolean', + 'name' => 'GV_seeOngChgDoc', + 'comment' => _('reglages:: Substitution de HD d\'un record '), + 'default' => false + ), array( + 'type' => 'boolean', + 'name' => 'GV_seeNewThumb', + 'comment' => _('reglages:: Substitution de thumbnail d\'un record'), + 'default' => false + ) + ) + ) // , array( // 'section' => _('GV::section:: Authentification LDAP'), // 'rolled' => true, @@ -734,243 +735,242 @@ $GV = array( // ) // ) // ) - , array( - 'section' => _('GV::section:: Envois de mails'), - 'vars' => array( + , array( + 'section' => _('GV::section:: Envois de mails'), + 'vars' => array( // array( // 'type' => 'boolean', // 'name' => 'GV_exportmail', // 'comment' => _('reglages:: Activation de l\'export par mail'), // 'default' => true // ), - array( - 'type' => 'string', - 'name' => 'GV_defaulmailsenderaddr', - 'comment' => _('reglages:: Expediteur mail par defaut'), - 'default' => 'phraseanet@example.com' - ), - array( - 'type' => 'boolean', - 'name' => 'GV_smtp', - 'comment' => _('reglages:: Utilisation d\'un serveur SMTP'), - 'default' => false - ), - array( - 'type' => 'boolean', - 'name' => 'GV_smtp_auth', - 'comment' => _('reglages:: Activation de l\'authentification smtp'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_smtp_host', - 'comment' => _('reglages:: Hote SMTP'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_smtp_port', - 'comment' => _('reglages:: Port SMTP'), - 'default' => '' - ), - array( - 'type' => 'boolean', - 'name' => 'GV_smtp_secure', - 'comment' => _('reglages:: Utiliser une conenction SSL'), - 'default' => false - ), - array( - 'type' => 'string', - 'name' => 'GV_smtp_user', - 'comment' => _('reglages:: User SMTP'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_smtp_password', - 'comment' => _('reglages:: Mot de passe SMTP'), - 'default' => '' - ) - ) - ), array( - 'section' => _('GV::section:: Exports FTP'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_activeFTP', - 'comment' => _('reglages:: active la possibilite d\'exports FTP ou non (onglet dans multiexports)'), - 'default' => false - ), - array( - 'type' => 'boolean', - 'name' => 'GV_ftp_for_user', - 'comment' => _('reglages:: Donne ou non export FTP aux utilisateurs ou e l\'admin uniquement'), - 'default' => false - ) - ) - ), array( - 'section' => _('GV::section:: Configuration du client'), - 'vars' => array( -// array( -// 'type' => 'enum', -// 'name' => 'GV_bandeauHome', -// 'comment' => _('reglages:: Affichage par defaut de la home du client'), -// 'available' => array('QUERY' => _('Question'), 'PUBLI' => _('Publications'), 'HELP' => _('Aide')), -// 'default' => 'QUERY' -// ), - array( - 'type' => 'integer', - 'name' => 'GV_ong_search', - 'comment' => _('reglages:: position de l\'onglet de recherche'), - 'default' => 1 - ), - array( - 'type' => 'integer', - 'name' => 'GV_ong_advsearch', - 'comment' => _('reglages:: position de l\'onglet de recherche avancee'), - 'default' => 2 - ), - array( - 'type' => 'integer', - 'name' => 'GV_ong_topics', - 'comment' => _('reglages:: position de l\'onglet des topics'), - 'default' => 0 - ), - array( - 'type' => 'integer', - 'name' => 'GV_ong_actif', - 'comment' => _('reglages:: numero de l\'onglet actif'), - 'default' => 1 - ), - array( - 'type' => 'enum', - 'name' => 'GV_client_render_topics', - 'comment' => _('reglages:: rendu des topics'), - 'available' => array('tree' => 'Arbres', 'popups' => 'Menus deroulants'), - 'default' => 'tree' - ), + array( + 'type' => 'string', + 'name' => 'GV_defaulmailsenderaddr', + 'comment' => _('reglages:: Expediteur mail par defaut'), + 'default' => 'phraseanet@example.com' + ), + array( + 'type' => 'boolean', + 'name' => 'GV_smtp', + 'comment' => _('reglages:: Utilisation d\'un serveur SMTP'), + 'default' => false + ), + array( + 'type' => 'boolean', + 'name' => 'GV_smtp_auth', + 'comment' => _('reglages:: Activation de l\'authentification smtp'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_smtp_host', + 'comment' => _('reglages:: Hote SMTP'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_smtp_port', + 'comment' => _('reglages:: Port SMTP'), + 'default' => '' + ), + array( + 'type' => 'boolean', + 'name' => 'GV_smtp_secure', + 'comment' => _('reglages:: Utiliser une conenction SSL'), + 'default' => false + ), + array( + 'type' => 'string', + 'name' => 'GV_smtp_user', + 'comment' => _('reglages:: User SMTP'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_smtp_password', + 'comment' => _('reglages:: Mot de passe SMTP'), + 'default' => '' + ) + ) + ), array( + 'section' => _('GV::section:: Exports FTP'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_activeFTP', + 'comment' => _('reglages:: active la possibilite d\'exports FTP ou non (onglet dans multiexports)'), + 'default' => false + ), + array( + 'type' => 'boolean', + 'name' => 'GV_ftp_for_user', + 'comment' => _('reglages:: Donne ou non export FTP aux utilisateurs ou e l\'admin uniquement'), + 'default' => false + ) + ) + ), array( + 'section' => _('GV::section:: Configuration du client'), + 'vars' => array( + array( + 'type' => 'integer', + 'name' => 'GV_download_max', + 'comment' => _('Maximum megabytes allowed in download (if request is bigger, then mail is still available)'), + 'default' => 120 + ), + array( + 'type' => 'integer', + 'name' => 'GV_ong_search', + 'comment' => _('reglages:: position de l\'onglet de recherche'), + 'default' => 1 + ), + array( + 'type' => 'integer', + 'name' => 'GV_ong_advsearch', + 'comment' => _('reglages:: position de l\'onglet de recherche avancee'), + 'default' => 2 + ), + array( + 'type' => 'integer', + 'name' => 'GV_ong_topics', + 'comment' => _('reglages:: position de l\'onglet des topics'), + 'default' => 0 + ), + array( + 'type' => 'integer', + 'name' => 'GV_ong_actif', + 'comment' => _('reglages:: numero de l\'onglet actif'), + 'default' => 1 + ), + array( + 'type' => 'enum', + 'name' => 'GV_client_render_topics', + 'comment' => _('reglages:: rendu des topics'), + 'available' => array('tree' => 'Arbres', 'popups' => 'Menus deroulants'), + 'default' => 'tree' + ), // array( // 'type' => 'boolean', // 'name' => 'GV_grp_preview_list', // 'comment' => _('reglages:: Voir les elements d\'un reportage sans Thumbnail (fenetre de preview)'), // 'default' => false // ), - array( - 'type' => 'boolean', - 'name' => 'GV_rollover_reg_preview', - 'comment' => _('reglages:: Voir le rollover sur les regroupements (fenetre de preview)'), - 'default' => true - ), - array( - 'type' => 'boolean', - 'name' => 'GV_rollover_chu', - 'comment' => _('reglages:: Voir le rollover sur les elements du chutier'), - 'default' => true - ), - array( - 'type' => 'enum', - 'name' => 'GV_client_coll_ckbox', - 'comment' => _('reglages:: Presentation des collections'), - 'default' => 'checkbox', - 'available' => array('popup' => 'Menu deroulant', 'checkbox' => 'case a cocher') - ), - array( - 'type' => 'boolean', - 'name' => 'GV_viewSizeBaket', - 'comment' => _('reglages:: Voir taille HD total des doc d\'un chutiers'), - 'default' => true - ), - array( - 'type' => 'boolean', - 'name' => 'GV_clientAutoShowProposals', - 'comment' => _('reglages:: Afficher automatiquement l\'onglet des propositions s\'il y\'en a'), - 'default' => true - ), - array( - 'type' => 'boolean', - 'name' => 'GV_needAuth2DL', - 'comment' => _('reglages:: Il est necessaire d\'etre connecte pour pouvoir telecharger en compte invite'), - 'default' => true - ) - ) - ), array( - 'section' => _('GV::section:: Parametrage de l\'inscription'), - 'vars' => array( - array( - 'type' => 'boolean', - 'name' => 'GV_autoselectDB', - 'comment' => _('reglages:: A true, cette option descative le choix de selection des bases sur lesquelles on s\'inscrit, et l\'inscription se fait sur toutes les bases ou jai le droit de m\'inscrire'), - 'default' => true - ), - array( - 'type' => 'boolean', - 'name' => 'GV_autoregister', - 'comment' => _('reglages:: Activation de l\'autoinscription'), - 'default' => false - ) - ) - ), array( - 'section' => _('GV::section:: Configuration du push'), - 'vars' => array( - array( - 'type' => 'integer', - 'name' => 'GV_validation_reminder', - 'comment' => _('reglages:: Nombre de jour avant la fin de la validation pour envoie de mail de rappel'), - 'default' => 2 - ), + array( + 'type' => 'boolean', + 'name' => 'GV_rollover_reg_preview', + 'comment' => _('reglages:: Voir le rollover sur les regroupements (fenetre de preview)'), + 'default' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_rollover_chu', + 'comment' => _('reglages:: Voir le rollover sur les elements du chutier'), + 'default' => true + ), + array( + 'type' => 'enum', + 'name' => 'GV_client_coll_ckbox', + 'comment' => _('reglages:: Presentation des collections'), + 'default' => 'checkbox', + 'available' => array('popup' => 'Menu deroulant', 'checkbox' => 'case a cocher') + ), + array( + 'type' => 'boolean', + 'name' => 'GV_viewSizeBaket', + 'comment' => _('reglages:: Voir taille HD total des doc d\'un chutiers'), + 'default' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_clientAutoShowProposals', + 'comment' => _('reglages:: Afficher automatiquement l\'onglet des propositions s\'il y\'en a'), + 'default' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_needAuth2DL', + 'comment' => _('reglages:: Il est necessaire d\'etre connecte pour pouvoir telecharger en compte invite'), + 'default' => true + ) + ) + ), array( + 'section' => _('GV::section:: Parametrage de l\'inscription'), + 'vars' => array( + array( + 'type' => 'boolean', + 'name' => 'GV_autoselectDB', + 'comment' => _('reglages:: A true, cette option descative le choix de selection des bases sur lesquelles on s\'inscrit, et l\'inscription se fait sur toutes les bases ou jai le droit de m\'inscrire'), + 'default' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_autoregister', + 'comment' => _('reglages:: Activation de l\'autoinscription'), + 'default' => false + ) + ) + ), array( + 'section' => _('GV::section:: Configuration du push'), + 'vars' => array( + array( + 'type' => 'integer', + 'name' => 'GV_validation_reminder', + 'comment' => _('reglages:: Nombre de jour avant la fin de la validation pour envoie de mail de rappel'), + 'default' => 2 + ), // array( // 'type' => 'boolean', // 'name' => 'GV_DL_checkit', // 'comment' => _('reglages:: Autorise le telechargement des fichiers pendant le process de validation'), // 'default' => true // ), - array( - 'type' => 'integer', - 'name' => 'GV_val_expiration', - 'comment' => _('reglages:: dure de validite des liens genere pour les validations, si 0 => validite permanente'), - 'default' => 10 - ) - ) - ), array( - 'section' => _('GV::section:: Indexation par les robots'), - 'vars' => array( - array( - 'type' => 'string', - 'name' => 'GV_homeTitle', - 'comment' => _('reglages :: Titre de l\'installation'), - 'default' => 'Phraseanet' - ), - array( - 'type' => 'string', - 'name' => 'GV_metaKeywords', - 'comment' => _('reglages:: Mots clefs pour l\'indexation des robots de moteurs de recherche'), - 'default' => '' - ), - array( - 'type' => 'text', - 'name' => 'GV_metaDescription', - 'comment' => _('reglages :: Description de l\'installation'), - 'default' => '' - ), - array( - 'type' => 'string', - 'name' => 'GV_googleAnalytics', - 'comment' => _('reglages:: identifiant google analytics'), - 'default' => '' - ), - array( - 'type' => 'boolean', - 'name' => 'GV_allow_search_engine', - 'comment' => _('Allow the website to be indexed by search engines like Google'), - 'default' => true - ), - array( - 'type' => 'boolean', - 'name' => 'GV_display_gcf', - 'comment' => _('reglages:: Afficher le bandeau Google Chrome Frame'), - 'default' => true - ) - ) + array( + 'type' => 'integer', + 'name' => 'GV_val_expiration', + 'comment' => _('reglages:: dure de validite des liens genere pour les validations, si 0 => validite permanente'), + 'default' => 10 + ) ) - ) + ), array( + 'section' => _('GV::section:: Indexation par les robots'), + 'vars' => array( + array( + 'type' => 'string', + 'name' => 'GV_homeTitle', + 'comment' => _('reglages :: Titre de l\'installation'), + 'default' => 'Phraseanet' + ), + array( + 'type' => 'string', + 'name' => 'GV_metaKeywords', + 'comment' => _('reglages:: Mots clefs pour l\'indexation des robots de moteurs de recherche'), + 'default' => '' + ), + array( + 'type' => 'text', + 'name' => 'GV_metaDescription', + 'comment' => _('reglages :: Description de l\'installation'), + 'default' => '' + ), + array( + 'type' => 'string', + 'name' => 'GV_googleAnalytics', + 'comment' => _('reglages:: identifiant google analytics'), + 'default' => '' + ), + array( + 'type' => 'boolean', + 'name' => 'GV_allow_search_engine', + 'comment' => _('Allow the website to be indexed by search engines like Google'), + 'default' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_display_gcf', + 'comment' => _('reglages:: Afficher le bandeau Google Chrome Frame'), + 'default' => true + ) + ) + ) + ) ?> diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index e3ec3251d1..be5cc8b220 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -5160,30 +5160,6 @@ - - regdate - tinyint(1) unsigned - YES - - - - - - regname - tinyint(1) unsigned - YES - - - - - - regdesc - tinyint(1) unsigned - YES - - - - report tinyint(1) unsigned @@ -5261,27 +5237,6 @@ required - - regname - UNIQUE - - regname - - - - regdate - UNIQUE - - regdate - - - - regdesc - UNIQUE - - regdesc - - sorter UNIQUE @@ -5826,7 +5781,7 @@ results int(11) unsigned - + YES 0 diff --git a/lib/conf.d/data_templates/en-simple.xml b/lib/conf.d/data_templates/en-simple.xml index b483b3fdc4..1602fc3170 100644 --- a/lib/conf.d/data_templates/en-simple.xml +++ b/lib/conf.d/data_templates/en-simple.xml @@ -149,7 +149,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -179,7 +179,7 @@ - + diff --git a/lib/conf.d/data_templates/fr-simple.xml b/lib/conf.d/data_templates/fr-simple.xml index e2fa5ff18c..f8c5a5ab2a 100755 --- a/lib/conf.d/data_templates/fr-simple.xml +++ b/lib/conf.d/data_templates/fr-simple.xml @@ -149,7 +149,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -179,7 +179,7 @@ - + diff --git a/lib/phpunit.xml.dist b/lib/phpunit.xml.dist index 35bbca23e6..262c5f2fb4 100644 --- a/lib/phpunit.xml.dist +++ b/lib/phpunit.xml.dist @@ -9,6 +9,7 @@ stopOnFailure="false" syntaxCheck="true" verbose="false" + bootstrap="unitTest/bootstrap.inc" > +
    -$stmt = $conn->prepare($sql); -$usr_id = $session->get_usr_id(); -$stmt->execute(array(':usr_id' => $usr_id, ':usr_id_bis' => $usr_id, ':usr_id_sub' => $usr_id)); -$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); -$stmt->closeCursor(); - -$sselid = null; -$o = 0; -$out = ''; - +' . - '

    ' . _('publications:: dernieres publications') . '

    ' . - '
'; -foreach ($rs as $row) +foreach ($feeds->get_aggregate()->get_entries(0, 5)->get_entries() as $entry) { - if ($row['ssel_id'] != $sselid) + /* @var $entry \Feed_Entry_Adapter */ + + $feed .= '
' . + '
' . + '

' . + '' + . $entry->get_title() . + '

' . + '' . + ' ' . \phraseadate::getPrettyString($entry->get_created_on()) . + ' '; + + if ($entry->get_author_email()) + $feed .= ''; + + $feed .= $entry->get_author_name(); + + if ($entry->get_author_email()) + $feed .= ''; + + if ($entry->get_updated_on() > $entry->get_created_on()) + $feed .= '
' . _('publications:: derniere mise a jour') + . ' ' . \phraseadate::getPrettyString($entry->get_updated_on()) . '

'; + + $feed .= '
'; + + + if (trim($entry->get_subtitle()) != '') { - if ($sselid !== null) - { - - - - $item .= '
' . $out; - $item .= '
' . - '
'; - - if ($itemIsOk) - $feed .= $item; - } - - $itemIsOk = false; - - $sselid = $row['ssel_id']; - $ord = $row['ord']; - $o = 0; - $out = ''; - $neverSeen = ''; - $publisher = $row['usr_prenom'] . ' ' . $row['usr_nom']; - if ($publisher == ' ') - $publisher = $row['usr_mail']; - if ($publisher == '') - $publisher = 'Unreferenced user'; - - if ($row['id'] != '') - $neverSeen = _('publications:: publication non lue'); - - $item = ''; - $item .= '
' . - '
' . - '

' . - '' . $row['name'] . - ' ' . $neverSeen . '

' . - '' . - ' ' . $row['pub_date'] . - ' '; - - if ($row['usr_mail'] != '') - $item .= ''; - - $item .= $publisher; - - if ($row['usr_mail'] != '') - $item .= ''; - - if ($row['dateC1'] != $row['dateC2']) - $item .= '
' . _('publications:: derniere mise a jour') . ' ' . $row['updater'] . '

'; - - $item .= '
'; - - - if (trim(str_replace($RN, '', $row['descript'])) != '') - { - $row['descript'] = str_replace($RN, '
', $row['descript']); - $item .= '' . $row['descript']; - } - $item .= '
'; + $feed .= '' . nl2br($entry->get_subtitle()); } + $feed .= '
'; + + $feed .= '
'; - $ord = $row['ord']; - $statOk = true; - if ($row['public'] == 1 && $row['pub_restrict'] == 1) + + foreach ($entry->get_content() as $Feed_item) { - $statOk = false; - - try - { - $connsbas = connection::getPDOConnection($row['sbas_id']); - - $sql = 'SELECT record_id FROM record WHERE ((status ^ ' . $row['mask_xor'] . ') & ' . $row['mask_and'] . ')=0 - AND record_id = :record_id'; - $stmt = $connsbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); - $statOk = ($stmt->rowCount() > 0); - $stmt->closeCursor(); - } - catch (Exception $e) - { - - } - } - - - $layoutmode = $user->getPrefs('view'); - - if ($statOk) - { - $record = new record_adapter($row["sbas_id"], $row["record_id"]); - $sbas_id = phrasea::sbasFromBas($row['base_id']); - - $captionXML = $record->get_xml(); + /* @var $Feed_item \Feed_Entry_Item */ + $record = $Feed_item->get_record(); $thumbnail = $record->get_thumbnail(); - $title = $record->get_title(); - $exifinfos = $record->get_technical_infos(); - $caption = $twig->render('common/caption.html', array('view' => 'internal_publi', 'record' => $record)); + $title = $record->get_title(); + $caption = $twig->render( + 'common/caption.html', array('view' => 'internal_publi', 'record' => $record) + ); - $o++; - $itemIsOk = true; - $bottom = 0; - $right = 10; - $left = 0; - $top = 10; - - - if (trim($preview) != '') - $preview = "
 "; + $preview = "
 "; $docType = $record->get_type(); $isVideo = ($docType == 'video'); $isAudio = ($docType == 'audio'); $isImage = ($docType == 'image'); - $isDocument = ($docType == 'document'); $duration = ''; @@ -232,11 +126,11 @@ foreach ($rs as $row) if ($ratio > 1) { - $cw = min(((int) $th_size - 30), $thumbnail->get_width()); - $ch = $cw / $ratio; - $pv = floor(($th_size - $ch) / 2); - $ph = floor(($th_size - $cw) / 2); - $imgStyle = 'xwidth:' . $cw . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; + $cw = min(((int) $th_size - 30), $thumbnail->get_width()); + $ch = $cw / $ratio; + $pv = floor(($th_size - $ch) / 2); + $ph = floor(($th_size - $cw) / 2); + $imgStyle = 'width:' . $cw . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; } else { @@ -246,64 +140,51 @@ foreach ($rs as $row) $pv = floor(($th_size - $ch) / 2); $ph = floor(($th_size - $cw) / 2); - $imgStyle = 'xheight:' . $ch . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; + $imgStyle = 'height:' . $ch . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; } + $feed .= "
get_sbas_id() . "\" + id='IMGT_" . $record->get_serialize_key() . "_PUB_" . $entry->get_id() + . "' class='IMGT diapo' + onclick=\"openPreview('FEED','" . $Feed_item->get_ord() . "','" . $entry->get_id() . "');\">"; + + $feed .= '
'; + $feed .= "
"; + + $feed .= $title; + + $feed .= "
\n"; + + $feed .= '
'; + + $feed .= "\n
"; + + $feed .= $duration . "get_url() . "\" style=\"" . $imgStyle . "\" />"; + + $feed .= "
"; + + $feed .= '
'; + $feed .= ''; + $feed .= ''; + $feed .= '\n"; + + $feed .= ""; + $feed .= ""; + $feed .= "
'; + + $feed .= "\n"; + + $feed .= $preview; + + $feed .= "
"; + $feed .= "
"; - $ident = $row["base_id"] . "_" . $row["record_id"]; - - - $out .= "
"; - - $out .= '
'; - $out .= "
"; - - $out .= $title; //$data['title']; - - $out .= "
\n"; - - $out .= '
'; - - $out .= "\n
"; - - $out .= $duration . "get_url() . "\" style=\"" . $imgStyle . "\" />"; - - $out .= "
"; - - $out .= '
'; - $out .= ''; - $out .= ''; - $out .= '\n"; - - $out .= ""; - $out .= ""; - $out .= "
'; - - $out .= "\n"; - - $out .= $preview; - - $out .= "
"; - $out .= "
"; - - - $out .= "
"; + $feed .= "
"; } -} - -if (isset($item)) -{ - $item .= '
' . $out; - $item .= '
' . - '
'; - if ($itemIsOk) - $feed .= $item; + $feed .= '
' . + ''; } echo '
' . $feed . '
'; -$sql = 'DELETE FROM sselnew WHERE usr_id = :usr_id AND ssel_id IN (SELECT ssel_id FROM ssel WHERE public="1")'; -$stmt = $conn->prepare($sql); -$stmt->execute(array(':usr_id' => $usr_id)); -$stmt->closeCursor(); diff --git a/www/client/index.php b/www/client/index.php index 5dafe03272..4045b09716 100644 --- a/www/client/index.php +++ b/www/client/index.php @@ -56,7 +56,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox); - + +
@@ -231,17 +239,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); } foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { - if ($showbases) - { - $options .= ''; - $allbcol = array(); - $n_allbcol = 0; - if (count($databox->get_collections()) > 0) - { - $options .= ''; - } - foreach ($databox->get_collections() as $coll) - { $allbcol[] = $coll->get_base_id(); $n_allbcol++; @@ -262,8 +259,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); } } echo ''; - } - } ?>
get('GV_view_bas_and_coll')) { - if ($registry->get('GV_view_bas_and_coll')) - { ?>
@@ -434,28 +427,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); '' . '
'; } - } - } - if ($sxe->description) - { - foreach ($sxe->description->children() as $f => $field) - { - if ($field['type'] == 'date' && $field['searchclient'] == '1') - { - $dateFilters .= '
' . - '' . - '' . - '
' . - $f . '
' . _('phraseanet::time:: de') . - '' . - _('phraseanet::time:: a') . - '
' . - '' . - ' ' . - '' . - '
' . - '
'; - } elseif ($field['type'] != 'date') { $fieldsFilters .= ''; @@ -481,7 +452,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox);
get_collections() as $coll) + foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { $s = "checked"; echo '
'; @@ -497,7 +468,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); get('GV_thesaurus')) { ?> @@ -576,7 +546,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox);
-
    +
    • @@ -617,7 +587,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox); - +