diff --git a/.gitmodules b/.gitmodules index 4337ee5ac0..3d9c349027 100644 --- a/.gitmodules +++ b/.gitmodules @@ -63,3 +63,6 @@ url = https://github.com/wavded/humane-js.git +[submodule "www/include/vendor/qunit"] + path = www/include/vendor/qunit + url = git://github.com/jquery/qunit.git diff --git a/bin/changefield.exe.php b/bin/changefield.exe.php index 47e2d1e409..965a494239 100644 --- a/bin/changefield.exe.php +++ b/bin/changefield.exe.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../lib/bootstrap.php"; +require_once __DIR__ . "/../lib/bootstrap.php"; $registry = registry::get_instance(); require($registry->get('GV_RootPath') . "lib/classes/deprecated/getargs.php"); // le parser d'arguments de la ligne de commande diff --git a/bin/console b/bin/console index 8a5fce126e..28463174ba 100755 --- a/bin/console +++ b/bin/console @@ -27,7 +27,9 @@ require_once dirname(__FILE__) . '/../lib/classes/bootstrap.class.php'; try { - bootstrap::register_autoloads(); + \bootstrap::register_autoloads(); + + $Core = \bootstrap::getCore(); $app = new Application(" _____ _ _ _____ _____ ______ _ _ ______ _______ @@ -45,7 +47,8 @@ try This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; type `about:license' for details.\n\n" - . ' KONSOLE KOMMANDER', GV_version . ' ' . GV_version_name); + . ' KONSOLE KOMMANDER', \Alchemy\Phrasea\Core\Version::getName() + . ' ' . \Alchemy\Phrasea\Core\Version::getNumber()); $app->add(new module_console_aboutAuthors('about:authors')); $app->add(new module_console_aboutLicense('about:license')); diff --git a/bin/doctrine b/bin/doctrine index a376777853..bf5c59b5cd 100755 --- a/bin/doctrine +++ b/bin/doctrine @@ -28,6 +28,7 @@ require_once dirname(__FILE__) . '/../lib/Alchemy/Phrasea/Core/Service/Doctrine. try { + $doctrineConf = array(); $doctrine = new Phrasea\Core\Service\Doctrine(); $app = new Application("Phraseanet Doctrine Console", $doctrine->getVersion()); diff --git a/bin/dumpbase.exe.php b/bin/dumpbase.exe.php index a7dad8487f..1df4e0a890 100644 --- a/bin/dumpbase.exe.php +++ b/bin/dumpbase.exe.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../lib/bootstrap.php"; +require_once __DIR__ . "/../lib/bootstrap.php"; define('DOCPERDIR', 100); diff --git a/bin/suggest_cron.php b/bin/suggest_cron.php index 06891067e4..23f4c88e8b 100644 --- a/bin/suggest_cron.php +++ b/bin/suggest_cron.php @@ -1,6 +1,6 @@ get('/', function () use ($session, $appbox) + $app['Core'] = bootstrap::getCore(); + + $app->get('/', function (Silex\Application $app) use ($session, $appbox) { User_Adapter::updateClientInfos((6)); - $basket_collection = new basketCollection($appbox, $session->get_usr_id()); + + $em = $app['Core']->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + $basket_collection = $repository->findActiveByUser( + $app['Core']->getAuthenticatedUser() + ); + $twig = new supertwig(); $twig->addFilter(array('nl2br' => 'nl2br')); $browser = Browser::getInstance(); $template = 'lightbox/index.twig'; if (!$browser->isNewGeneration() && !$browser->isMobile()) + { $template = 'lightbox/IE6/index.twig'; + } $output = $twig->render($template, array( 'baskets_collection' => $basket_collection, @@ -55,7 +66,7 @@ return call_user_func( } ); - $app->get('/ajax/NOTE_FORM/{sselcont_id}/', function($sselcont_id) use ($session, $appbox) + $app->get('/ajax/NOTE_FORM/{sselcont_id}/', function(Silex\Application $app, $sselcont_id) use ($session, $appbox) { $browser = Browser::getInstance(); if (!$browser->isMobile()) @@ -63,7 +74,14 @@ return call_user_func( $twig = new supertwig(); $twig->addFilter(array('nl2br' => 'nl2br')); - $basket_element = basket_element_adapter::getInstance($sselcont_id); + + $em = $app['Core']->getEntityManager(); + + /* @var $repository \Repositories\BasketElementRepository */ + $repository = $em->getRepository('\Entities\BasketElement'); + + $basket_element = $repository->findUserElement($sselcont_id, $app['Core']->getAuthenticatedUser()); + $template = '/lightbox/note_form.twig'; $output = $twig->render($template, array('basket_element' => $basket_element, 'module_name' => '')); @@ -71,20 +89,25 @@ return call_user_func( } )->assert('sselcont_id', '\d+'); - $app->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function($sselcont_id) + $app->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function(Silex\Application $app, $sselcont_id) { $twig = new supertwig(); $twig->addFilter(array('nl2br' => 'nl2br', 'formatoctet' => 'p4string::format_octets')); $browser = Browser::getInstance(); + $em = $app['Core']->getEntityManager(); + + /* @var $repository \Repositories\BasketElementRepository */ + $repository = $em->getRepository('\Entities\BasketElement'); + + $BasketElement = $repository->findUserElement($sselcont_id, $app['Core']->getAuthenticatedUser()); + if ($browser->isMobile()) { - $basket_element = basket_element_adapter::getInstance($sselcont_id); - $output = $twig->render('lightbox/basket_element.twig', array( - 'basket_element' => $basket_element, - 'module_name' => $basket_element->get_record()->get_title() + 'basket_element' => $BasketElement, + 'module_name' => $BasketElement->getRecord()->get_title() ) ); @@ -107,19 +130,19 @@ return call_user_func( $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - $basket_element = basket_element_adapter::getInstance($sselcont_id); - $basket = basket_adapter::getInstance($appbox, $basket_element->get_ssel_id(), $usr_id); + + $Basket = $BasketElement->getBasket(); $ret = array(); - $ret['number'] = $basket_element->get_record()->get_number(); - $ret['title'] = $basket_element->get_record()->get_title(); + $ret['number'] = $BasketElement->getRecord()->get_number(); + $ret['title'] = $BasketElement->getRecord()->get_title(); - $ret['preview'] = $twig->render($template_preview, array('record' => $basket_element->get_record(), 'not_wrapped' => true)); - $ret['options_html'] = $twig->render($template_options, array('basket_element' => $basket_element)); - $ret['agreement_html'] = $twig->render($template_agreement, array('basket' => $basket, 'basket_element' => $basket_element)); - $ret['selector_html'] = $twig->render($template_selector, array('basket_element' => $basket_element)); - $ret['note_html'] = $twig->render($template_note, array('basket_element' => $basket_element)); - $ret['caption'] = $twig->render($template_caption, array('view' => 'preview', 'record' => $basket_element->get_record())); + $ret['preview'] = $twig->render($template_preview, array('record' => $BasketElement->getRecord(), 'not_wrapped' => true)); + $ret['options_html'] = $twig->render($template_options, array('basket_element' => $BasketElement)); + $ret['agreement_html'] = $twig->render($template_agreement, array('basket' => $Basket, 'basket_element' => $BasketElement)); + $ret['selector_html'] = $twig->render($template_selector, array('basket_element' => $BasketElement)); + $ret['note_html'] = $twig->render($template_note, array('basket_element' => $BasketElement)); + $ret['caption'] = $twig->render($template_caption, array('view' => 'preview', 'record' => $BasketElement->getRecord())); $output = p4string::jsonencode($ret); return new Response($output, 200, array('Content-Type' => 'application/json')); @@ -130,7 +153,7 @@ return call_user_func( - $app->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function($entry_id, $item_id) + $app->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(Silex\Application $app, $entry_id, $item_id) { $twig = new supertwig(); $twig->addFilter(array('nl2br' => 'nl2br', 'formatoctet' => 'p4string::format_octets')); @@ -153,13 +176,13 @@ return call_user_func( } else { - $template_options = 'lightbox/sc_options_box.twig'; + $template_options = 'lightbox/feed_options_box.twig'; $template_preview = 'common/preview.html'; $template_caption = 'common/caption.html'; if (!$browser->isNewGeneration()) { - $template_options = 'lightbox/IE6/sc_options_box.twig'; + $template_options = 'lightbox/IE6/feed_options_box.twig'; } $usr_id = $appbox->get_session()->get_usr_id(); @@ -168,7 +191,7 @@ return call_user_func( $ret['title'] = $item->get_record()->get_title(); $ret['preview'] = $twig->render($template_preview, array('record' => $item->get_record(), 'not_wrapped' => true)); - $ret['options_html'] = $twig->render($template_options, array('basket_element' => $item)); + $ret['options_html'] = $twig->render($template_options, array('feed_element' => $item)); $ret['caption'] = $twig->render($template_caption, array('view' => 'preview', 'record' => $item->get_record())); @@ -182,20 +205,25 @@ return call_user_func( } )->assert('entry_id', '\d+')->assert('item_id', '\d+'); - $app->get('/validate/{ssel_id}/', function ($ssel_id) use ($session, $appbox) + $app->get('/validate/{ssel_id}/', function (Silex\Application $app, $ssel_id) use ($session, $appbox) { User_Adapter::updateClientInfos((6)); $browser = Browser::getInstance(); - $basket_collection = new basketCollection($appbox, $session->get_usr_id()); - $basket = basket_adapter::getInstance($appbox, $ssel_id, $session->get_usr_id()); + $em = $app['Core']->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); - if ($basket->is_valid()) - { - $basket->get_first_element()->load_users_infos(); - } + /* @var $repository \Repositories\BasketRepository */ + $basket_collection = $repository->findActiveByUser( + $app['Core']->getAuthenticatedUser() + ); + + $basket = $repository->findUserBasket( + $ssel_id + , $app['Core']->getAuthenticatedUser() + ); $twig = new supertwig(); @@ -209,7 +237,7 @@ return call_user_func( $response = new Response($twig->render($template, array( 'baskets_collection' => $basket_collection, 'basket' => $basket, - 'local_title' => strip_tags($basket->get_name()), + 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') ) @@ -220,20 +248,25 @@ return call_user_func( } )->assert('ssel_id', '\d+'); - $app->get('/compare/{ssel_id}/', function ($ssel_id) use ($session, $appbox) + $app->get('/compare/{ssel_id}/', function (Silex\Application $app, $ssel_id) use ($session, $appbox) { User_Adapter::updateClientInfos((6)); $browser = Browser::getInstance(); - $basket_collection = new basketCollection($appbox, $session->get_usr_id()); - $basket = basket_adapter::getInstance($appbox, $ssel_id, $session->get_usr_id()); + $em = $app['Core']->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); - if ($basket->is_valid()) - { - $basket->get_first_element()->load_users_infos(); - } + /* @var $repository \Repositories\BasketRepository */ + $basket_collection = $repository->findActiveByUser( + $app['Core']->getAuthenticatedUser() + ); + + $basket = $repository->findUserBasket( + $ssel_id + , $app['Core']->getAuthenticatedUser() + ); $twig = new supertwig(); @@ -247,7 +280,7 @@ return call_user_func( $response = new Response($twig->render($template, array( 'baskets_collection' => $basket_collection, 'basket' => $basket, - 'local_title' => strip_tags($basket->get_name()), + 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') ) @@ -260,7 +293,7 @@ return call_user_func( - $app->get('/feeds/entry/{entry_id}/', function ($entry_id) use ($session, $appbox) + $app->get('/feeds/entry/{entry_id}/', function (Silex\Application $app, $entry_id) use ($session, $appbox) { User_Adapter::updateClientInfos((6)); @@ -293,7 +326,7 @@ return call_user_func( } )->assert('entry_id', '\d+'); - $app->get('/ajax/LOAD_REPORT/{ssel_id}/', function($ssel_id) use ($appbox, $app) + $app->get('/ajax/LOAD_REPORT/{ssel_id}/', function(Silex\Application $app, $ssel_id) { $twig = new supertwig(); $twig->addFilter(array('nl2br' => 'nl2br')); @@ -302,7 +335,14 @@ return call_user_func( $template = 'lightbox/basket_content_report.twig'; - $basket = basket_adapter::getInstance($appbox, $ssel_id, $appbox->get_session()->get_usr_id()); + $em = $app['Core']->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + $basket = $repository->findUserBasket( + $ssel_id + , $app['Core']->getAuthenticatedUser() + ); $response = new Response($twig->render($template, array('basket' => $basket))); $response->setCharset('UTF-8'); @@ -311,39 +351,46 @@ return call_user_func( } )->assert('ssel_id', '\d+'); - $app->post('/ajax/SET_NOTE/{sselcont_id}/', function ($sselcont_id) use ($app) + $app->post('/ajax/SET_NOTE/{sselcont_id}/', function (Silex\Application $app, $sselcont_id) { $output = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')); - try + + $request = $app['request']; + $note = $request->get('note'); + + if (is_null($note)) { - $request = $app['request']; - $note = $request->get('note'); - - $basket_element = basket_element_adapter::getInstance($sselcont_id); - $basket_element->set_note($note); - $twig = new supertwig(); - $twig->addFilter(array('nl2br' => 'nl2br')); - - $browser = Browser::getInstance(); - - if ($browser->isMobile()) - { - $datas = $twig->render('lightbox/sc_note.twig', array('basket_element' => $basket_element)); - - $output = array('error' => false, 'datas' => $datas); - } - else - { - $template = 'lightbox/sc_note.twig'; - - $datas = $twig->render($template, array('basket_element' => $basket_element)); - - $output = array('error' => false, 'datas' => $datas); - } + Return new Response('You must provide a note value', 400); } - catch (Exception $e) + + $em = $app['Core']->getEntityManager(); + + /* @var $repository \Repositories\BasketElementRepository */ + $repository = $em->getRepository('\Entities\BasketElement'); + + $basket_element = $repository->findUserElement($sselcont_id, $app['Core']->getAuthenticatedUser()); + + + $basket_element->getUserValidationDatas($app['Core']->getAuthenticatedUser()) + ->setNote($note); + $twig = new supertwig(); + $twig->addFilter(array('nl2br' => 'nl2br')); + + $browser = Browser::getInstance(); + + if ($browser->isMobile()) { - return new Response('Bad Request : ' . $e->getMessage() . $e->getFile() . $e->getLine(), 400); + $datas = $twig->render('lightbox/sc_note.twig', array('basket_element' => $basket_element)); + + $output = array('error' => false, 'datas' => $datas); + } + else + { + $template = 'lightbox/sc_note.twig'; + + $datas = $twig->render($template, array('basket_element' => $basket_element)); + + $output = array('error' => false, 'datas' => $datas); } $output = p4string::jsonencode($output); @@ -352,35 +399,56 @@ return call_user_func( } )->assert('sselcont_id', '\d+'); - $app->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function($sselcont_id) use ($app) + $app->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function(Silex\Application $app, $sselcont_id) { $request = $app['request']; - $agreement = (int) $request->get('agreement'); + $agreement = $request->get('agreement'); + + if (is_null($agreement)) + { + Return new Response('You must provide an agreement value', 400); + } + + $agreement = $agreement > 0; $ret = array( 'error' => true, 'releasable' => false, 'datas' => _('Erreur lors de la mise a jour des donnes ') ); - - try - { - $appbox = appbox::get_instance(); - $basket_element = basket_element_adapter::getInstance($sselcont_id); - $basket_element->set_agreement($agreement); - $basket = basket_adapter::getInstance($appbox, $basket_element->get_ssel_id(), $appbox->get_session()->get_usr_id()); + $user = $app['Core']->getAuthenticatedUser(); + $em = $app['Core']->getEntityManager(); + $repository = $em->getRepository('\Entities\BasketElement'); - $ret = array( - 'error' => false - , 'datas' => '' - , 'releasable' => $basket->is_releasable() ? _('Do you want to send your report ?') : false - ); - } - catch (Exception $e) + /* @var $repository \Repositories\BasketElementRepository */ + $basket_element = $repository->findUserElement( + $sselcont_id + , $user + ); + /* @var $basket_element \Entities\BasketElement */ + $basket_element->getUserValidationDatas($user) + ->setAgreement($agreement); + + $participant = $basket_element->getBasket() + ->getValidation() + ->getParticipant($user); + + if ($participant->getIsConfirmed() === true) { - return new Response('Bad Request', 400); + $releasable = false; } + else + { + $releasable = _('Do you want to send your report ?'); + } + + $ret = array( + 'error' => false + , 'datas' => '' + , 'releasable' => $releasable + ); + $output = p4string::jsonencode($ret); return new Response($output, 200, array('Content-Type' => 'application/json')); @@ -388,24 +456,31 @@ return call_user_func( )->assert('sselcont_id', '\d+'); - $app->post('/ajax/SET_RELEASE/{ssel_id}/', function($ssel_id) use ($session, $appbox) + $app->post('/ajax/SET_RELEASE/{ssel_id}/', function(Silex\Application $app, $ssel_id) use ($session, $appbox) { - $basket = basket_adapter::getInstance($appbox, $ssel_id, $appbox->get_session()->get_usr_id()); - $datas = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')); - try - { - $appbox->get_connection()->beginTransaction(); - $basket->set_released(); - $datas = array('error' => false, 'datas' => _('Envoie avec succes')); - $appbox->get_connection()->commit(); - } - catch (Exception $e) - { - $appbox->get_connection()->rollBack(); + $em = $app['Core']->getEntityManager(); - return new Response('Bad Request', 400); + $user = $app['Core']->getAuthenticatedUser(); + + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + $basket = $repository->findUserBasket( + $ssel_id + , $user + ); + + if (!$basket->getValidation()) + { + Return new Response('There is no validation session attached to this basket', 400); } + /* @var $basket \Entities\Basket */ + $participant = $basket->getValidation()->getParticipant($user); + $participant->setIsConfirmed(true); + + $datas = array('error' => false, 'datas' => _('Envoie avec succes')); + $output = p4string::jsonencode($datas); $response = new Response($output, 200, array('Content-Type' => 'application/json')); diff --git a/lib/Alchemy/Phrasea/Application/OAuth2.php b/lib/Alchemy/Phrasea/Application/OAuth2.php index 9aeab670d7..92a5c4174c 100644 --- a/lib/Alchemy/Phrasea/Application/OAuth2.php +++ b/lib/Alchemy/Phrasea/Application/OAuth2.php @@ -33,6 +33,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; return call_user_func(function() { $app = new Silex\Application(); + + $app['Core'] = bootstrap::getCore(); $app->register(new Silex\Provider\ValidatorServiceProvider(), array( 'validator.class_path' => __DIR__ . '/../../../../lib/vendor/symfony/src', diff --git a/lib/Alchemy/Phrasea/Application/Overview.php b/lib/Alchemy/Phrasea/Application/Overview.php index bca38e533d..aa39d2ca6b 100644 --- a/lib/Alchemy/Phrasea/Application/Overview.php +++ b/lib/Alchemy/Phrasea/Application/Overview.php @@ -29,6 +29,8 @@ return call_user_func( $session = $appbox->get_session(); $app = new Silex\Application(); + + $app['Core'] = bootstrap::getCore(); $deliver_content = function(Session_Handler $session, record_adapter $record, $subdef, $watermark, $stamp, $app) @@ -112,11 +114,18 @@ return call_user_func( if ($watermark) { - if (basket_element_adapter::is_in_validation_session($record, $user)) + + $em = $app['Core']->getEntityManager(); + + $repository = $em->getRepository('\Entities\BasketElement'); + + /* @var $repository \Repositories\BasketElementRepository */ + + if ($repository->findReceivedValidationElementsByRecord($record, $user)->count() > 0) { $watermark = false; } - elseif (basket_element_adapter::has_been_received($record, $user)) + elseif ($repository->findReceivedElementsByRecord($record, $user)->count() > 0) { $watermark = false; } @@ -159,14 +168,20 @@ return call_user_func( if ($watermark) { - if (basket_element_adapter::is_in_validation_session($record, $user)) + + $em = $app['Core']->getEntityManager(); + + $repository = $em->getRepository('\Entities\BasketElement'); + + if ($repository->findReceivedValidationElementsByRecord($record, $user)->count() > 0) { $watermark = false; } - elseif (basket_element_adapter::has_been_received($record, $user)) + elseif ($repository->findReceivedElementsByRecord($record, $user)->count() > 0) { $watermark = false; } + } return $deliver_content($session, $record, $subdef, $watermark, $stamp, $app); diff --git a/lib/Alchemy/Phrasea/Application/Prod.php b/lib/Alchemy/Phrasea/Application/Prod.php index 8c1c26f826..4a89070691 100644 --- a/lib/Alchemy/Phrasea/Application/Prod.php +++ b/lib/Alchemy/Phrasea/Application/Prod.php @@ -44,6 +44,7 @@ return call_user_func(function() $app->mount('/records/edit', new Controller\Edit()); $app->mount('/records/movecollection', new Controller\MoveCollection()); $app->mount('/bridge/', new Controller\Bridge()); + $app->mount('/printer/', new Controller\Printer()); $app->mount('/feeds', new Controller\Feed()); $app->mount('/tooltip', new Controller\Tooltip()); $app->mount('/', new Controller\Root()); diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php index f4f9548afb..5c406e30bf 100644 --- a/lib/Alchemy/Phrasea/Application/Root.php +++ b/lib/Alchemy/Phrasea/Application/Root.php @@ -45,7 +45,7 @@ return call_user_func(function() $app->get('robots.txt', function() use ($app) { - require dirname(__FILE__) . "/../lib/bootstrap.php"; + require __DIR__ . "/../lib/bootstrap.php"; $appbox = appbox::get_instance(); $registry = $appbox->get_registry(); diff --git a/lib/Alchemy/Phrasea/Application/Setup.php b/lib/Alchemy/Phrasea/Application/Setup.php index 20470a1b9b..be6c0d7f68 100644 --- a/lib/Alchemy/Phrasea/Application/Setup.php +++ b/lib/Alchemy/Phrasea/Application/Setup.php @@ -15,6 +15,7 @@ use Silex\Application; use Alchemy\Phrasea\Controller\Setup as Controller; use Alchemy\Phrasea\Controller\Utils as ControllerUtils; +require_once __DIR__ . '/../../../bootstrap.php'; /** * * @package @@ -25,6 +26,8 @@ use Alchemy\Phrasea\Controller\Utils as ControllerUtils; return call_user_func(function() { $app = new Silex\Application(); + + $app['Core'] = bootstrap::getCore(); $app['install'] = false; $app['upgrade'] = false; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index 9ee68a3777..0340f38242 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -39,8 +39,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $template = 'admin/editusers.twig'; $twig = new \supertwig(); @@ -55,8 +54,7 @@ class Users implements ControllerProviderInterface $controllers->get('/rights/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $template = 'admin/editusers.twig'; $twig = new \supertwig(); @@ -71,11 +69,7 @@ class Users implements ControllerProviderInterface $controllers->post('/delete/', function() use ($app) { - $request = $app['request']; - - - - $module = new UserHelper\Edit($request); + $module = new UserHelper\Edit($app['Core']); $module->delete_users(); return $app->redirect('/admin/users/search/'); @@ -88,8 +82,7 @@ class Users implements ControllerProviderInterface try { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $rights->apply_rights(); $rights->apply_infos(); @@ -110,8 +103,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/quotas/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $template = 'admin/editusers_quotas.twig'; $twig = new \supertwig(); @@ -125,8 +117,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/quotas/apply/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $rights->apply_quotas(); return; @@ -135,8 +126,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/time/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $template = 'admin/editusers_timelimit.twig'; $twig = new \supertwig(); @@ -150,8 +140,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/time/apply/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $rights->apply_time(); return; @@ -160,8 +149,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/masks/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $template = 'admin/editusers_masks.twig'; $twig = new \supertwig(); @@ -175,46 +163,40 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/masks/apply/', function() use ($app) { - $request = $app['request']; - $rights = new UserHelper\Edit($request); + $rights = new UserHelper\Edit($app['Core']); $rights->apply_masks(); return; } ); - $controllers->post('/search/', function() use ($app) + $controllers->match('/search/', function() use ($app) { - $request = $app['request']; - $users = new UserHelper\Manage($request); + $users = new UserHelper\Manage($app['Core']); $template = 'admin/users.html'; $twig = new \supertwig(); $twig->addFilter(array('floor' => 'floor')); $twig->addFilter(array('getDate' => 'phraseadate::getDate')); - return $twig->render($template, $users->search($request)); + return $twig->render($template, $users->search()); } ); - $controllers->get('/search/', function() use ($app) + $controllers->post('/apply_template/', function() use ($app) { - $request = $app['request']; - $users = new UserHelper\Manage($request); - $template = 'admin/users.html'; + $users = UserHelper\Manage($app['Core']); + + $users->apply_template(); - $twig = new \supertwig(); - $twig->addFilter(array('floor' => 'floor')); - $twig->addFilter(array('getDate' => 'phraseadate::getDate')); - - return $twig->render($template, $users->search($request)); + return new Symfony\Component\HttpFoundation\RedirectResponse('/admin/users/search/'); } ); $controllers->get('/typeahead/search/', function() use ($app, $appbox) { $request = $app['request']; - $user_query = new User_Query($appbox); + $user_query = new \User_Query($appbox); $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $like_value = $request->get('term'); @@ -258,7 +240,7 @@ class Users implements ControllerProviderInterface try { $request = $app['request']; - $module = new UserHelper\Manage($request); + $module = new UserHelper\Manage($app['Core']); if ($request->get('template') == '1') { $user = $module->create_template(); @@ -285,7 +267,7 @@ class Users implements ControllerProviderInterface $controllers->post('/export/csv/', function() use ($appbox, $app) { $request = $app['request']; - $user_query = new \User_Query($appbox); + $user_query = new \User_Query($appbox, $app['Core']); $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $like_value = $request->get('like_value'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php index a0e5716807..a27a292604 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php @@ -136,7 +136,7 @@ class Basket implements ControllerProviderInterface }); $controllers->post( - '/{basket_id}/{basket_element_id}/delete/' + '/{basket_id}/delete/{basket_element_id}/' , function(Application $app, Request $request, $basket_id, $basket_element_id) { /* @var $em \Doctrine\ORM\EntityManager */ @@ -342,6 +342,61 @@ class Basket implements ControllerProviderInterface return new RedirectResponse('/'); } }); + + + + $controllers->post( + '/{basket_id}/stealElements/' + , function(Application $app, Request $request, $basket_id) + { + $em = $app['Core']->getEntityManager(); + + /* @var $em \Doctrine\ORM\EntityManager */ + $basket = $em->getRepository('\Entities\Basket') + ->findUserBasket($basket_id, $app['Core']->getAuthenticatedUser()); + + $user = $app['Core']->getAuthenticatedUser(); + /* @var $user \User_Adapter */ + + $n = 0; + + foreach ($request->get('elements') as $bask_element_id) + { + $basket_element = $em->getRepository('\Entities\BasketElement') + ->findUserElement($bask_element_id, $user); + + if(!$basket_element) + { + continue; + } + + $basket_element->setBasket($basket); + + $em->merge($basket_element); + + $n++; + } + + $em->merge($basket); + $em->flush(); + + $data = array( + 'success' => true + , 'message' => sprintf(_('%d records moved'), $n) + ); + + 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('/'); + } + }); $controllers->get('/create/', function(Application $app) { @@ -364,7 +419,7 @@ class Basket implements ControllerProviderInterface $twig = new \supertwig(); - $html = $twig->render('prod/basket.twig', array('basket' => $basket)); + $html = $twig->render('prod/WorkZone/Basket.html.twig', array('basket' => $basket)); return new Response($html); })->assert('basket_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index ae536a6735..3963371c89 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -45,9 +45,9 @@ class Bridge implements ControllerProviderInterface }; if (!$account->get_api()->get_connector()->is_configured()) - throw new \Bridge_Exception_ApiConnectorNotConfigured(); + throw new \Bridge_Exception_ApiConnectorNotConfigured("Bridge API Connector is not configured"); if (!$account->get_api()->get_connector()->is_connected()) - throw new \Bridge_Exception_ApiConnectorNotConnected (); + throw new \Bridge_Exception_ApiConnectorNotConnected ("Bridge API Connector is not connected"); return; }); @@ -55,7 +55,7 @@ class Bridge implements ControllerProviderInterface $controllers->post('/manager/' , function() use ($app, $twig) { - $route = new RecordHelper\Bridge($app['request']); + $route = new RecordHelper\Bridge($app['Core']); $appbox = \appbox::get_instance(); $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); @@ -63,6 +63,7 @@ class Bridge implements ControllerProviderInterface 'user_accounts' => \Bridge_Account::get_accounts_by_user($appbox, $user) , 'available_apis' => \Bridge_Api::get_availables($appbox) , 'route' => $route + , 'current_account_id' => '' ); return new Response($twig->render('prod/actions/Bridge/index.twig', $params) @@ -171,7 +172,7 @@ class Bridge implements ControllerProviderInterface $app['require_connection']($account); $elements = $account->get_api()->list_elements($type, $offset_start, $quantity); - + $params = array( 'action_type' => $type , 'adapter_action' => 'load-elements' @@ -274,6 +275,8 @@ class Bridge implements ControllerProviderInterface , 'destination' => $destination , 'element_type' => $element_type , 'action' => $action + , 'constraint_errors' => null + , 'adapter_action' => $action , 'elements' => $elements , 'error_message' => $app['request']->get('error') , 'notice_message' => $app['request']->get('notice') @@ -420,7 +423,7 @@ class Bridge implements ControllerProviderInterface $account = \Bridge_Account::load_account($appbox, $request->get('account_id')); $app['require_connection']($account); - $route = new RecordHelper\Bridge($request); + $route = new RecordHelper\Bridge($app['Core']); $route->grep_records($account->get_api()->acceptable_records()); $params = array( @@ -447,7 +450,7 @@ class Bridge implements ControllerProviderInterface $account = \Bridge_Account::load_account($appbox, $request->get('account_id')); $app['require_connection']($account); - $route = new RecordHelper\Bridge($request); + $route = new RecordHelper\Bridge($app['Core']); $route->grep_records($account->get_api()->acceptable_records()); $connector = $account->get_api()->get_connector(); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index f6f6539d00..8d91dec23b 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -30,9 +30,7 @@ class Edit implements ControllerProviderInterface $controllers->post('/', function() use ($app) { - $request = $app['request']; - - $handler = new RecordHelper\Edit($request); + $handler = new RecordHelper\Edit($app['Core']); $handler->propose_editing(); @@ -48,7 +46,7 @@ class Edit implements ControllerProviderInterface $controllers->post('/apply/', function() use ($app) { $request = $app['request']; - $editing = new RecordHelper\Edit($request); + $editing = new RecordHelper\Edit($app['Core']); $editing->execute($request); $template = 'prod/actions/edit_default.twig'; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index abbcb87436..ff3456643d 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -43,7 +43,7 @@ class Feed implements ControllerProviderInterface $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $feeds = \Feed_Collection::load_all($appbox, $user); $request = $app['request']; - $publishing = new RecordHelper\Feed($request); + $publishing = new RecordHelper\Feed($app['Core']); $datas = $twig->render('prod/actions/publish/publish.html', array('publishing' => $publishing, 'feeds' => $feeds)); @@ -71,7 +71,7 @@ class Feed implements ControllerProviderInterface $entry = \Feed_Entry_Adapter::create($appbox, $feed, $publisher, $title, $subtitle, $author_name, $author_mail); - $publishing = new RecordHelper\Feed($request); + $publishing = new RecordHelper\Feed($app['Core']); foreach ($publishing->get_elements() as $record) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php index 406756f730..d30eea7d57 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php @@ -34,7 +34,7 @@ class MoveCollection implements ControllerProviderInterface $controllers->post('/', function() use ($app) { $request = $app['request']; - $move = new RecordHelper\MoveCollection($request); + $move = new RecordHelper\MoveCollection($app['Core']); $move->propose(); $template = 'prod/actions/collection_default.twig'; @@ -49,7 +49,7 @@ class MoveCollection implements ControllerProviderInterface $controllers->post('/apply/', function() use ($app) { $request = $app['request']; - $move = new RecordHelper\MoveCollection($request); + $move = new RecordHelper\MoveCollection($app['Core']); $move->execute($request); $template = 'prod/actions/collection_submit.twig'; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php new file mode 100644 index 0000000000..69f066a2d2 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php @@ -0,0 +1,71 @@ +post('/', function() use ($app) + { + $printer = new RecordHelper\Printer($app['Core']); + + $template = 'prod/actions/printer_default.html.twig'; + + $twig = new \supertwig(); + + return $twig->render($template, array('printer' => $printer, 'message' => '')); + } + ); + + + + $controllers->post('/print.pdf', function() use ($app) + { + $printer = new RecordHelper\Printer($app['Core']); + + $request = $app['request']; + + $session = \Session_Handler::getInstance(\appbox::get_instance()); + + $layout = $request->get('lay'); + + foreach ($printer->get_elements() as $record) + { + $session->get_logger($record->get_databox()) + ->log($record, \Session_Logger::EVENT_PRINT, $layout, ''); + } + $PDF = new PDFExport($printer->get_elements(), $layout); + return new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf')); + } + ); + + return $controllers; + } + +} diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index bf87920c5a..305d70d2cf 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -37,7 +37,6 @@ class Root implements ControllerProviderInterface $controllers->get('/', function(Application $app) { - \User_Adapter::updateClientInfos(1); $appbox = \appbox::get_instance(); @@ -115,11 +114,10 @@ class Root implements ControllerProviderInterface 'module_prod' => new Helper\Prod($app['Core']), 'cssfile' => $cssfile, 'module' => 'prod', - 'events' => \eventsmanager_broker::getInstance($appbox), + 'events' => \eventsmanager_broker::getInstance($appbox, $app['Core']), 'GV_defaultQuery_type' => $registry->get('GV_defaultQuery_type'), 'GV_multiAndReport' => $registry->get('GV_multiAndReport'), 'GV_thesaurus' => $registry->get('GV_thesaurus'), -// 'basket_collection' => new \basketCollection($appbox, $user->get_id(), $srt), 'cgus_agreement' => \databox_cgu::askAgreement(), 'css' => $css, 'feeds' => $feeds, diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Story.php b/lib/Alchemy/Phrasea/Controller/Prod/Story.php index 45f57ce188..40f2363161 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Story.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Story.php @@ -43,12 +43,9 @@ class Story implements ControllerProviderInterface return new Response($twig->render('prod/Story/Create.html.twig', array())); }); - $controllers->post('/', function(Application $app) + $controllers->post('/', function(Application $app, Request $request) { - $request = $app['request']; - -// /* @var $request \Symfony\Component\HttpFoundation\Request */ -// + /* @var $request \Symfony\Component\HttpFoundation\Request */ $em = $app['Core']->getEntityManager(); $user = $app['Core']->getAuthenticatedUser(); @@ -107,7 +104,7 @@ class Story implements ControllerProviderInterface 'record_id' => $Story->get_record_id(), ) ); - + $datas = $app['Core']['Serializer']->serialize($data, 'json'); return new Response($datas, 200, array('Content-type' => 'application/json')); @@ -222,87 +219,6 @@ class Story implements ControllerProviderInterface return new RedirectResponse('/'); } }); - - $controllers->post( - '/{sbas_id}/{record_id}/attach/' - , function(Application $app, Request $request, $sbas_id, $record_id) - { - $Story = new \record_adapter($sbas_id, $record_id); - - if (!$Story->is_grouping()) - throw new \Exception('You can only attach stories'); - - $user = $app['Core']->getAuthenticatedUser(); - - if (!$user->ACL()->has_right_on_base($Story->get_base_id())) - throw new \Exception_Forbidden('You do not have access to this Story'); - - $em = $app['Core']->getEntityManager(); - - $StoryWZ = new \Entities\StoryWZ(); - $StoryWZ->setUser($user); - $StoryWZ->setRecord($Story); - - $em->persist($StoryWZ); - - $data = array( - 'success' => true - , 'message' => _('Story attached to the WorkZone') - , 'StoryWZ' => array( - 'id' => $StoryWZ->getId() - ) - ); - - 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('/{sbas_id}/{record_id}/'); - } - }); - $controllers->post( - '/{sbas_id}/{record_id}/detach/' - , function(Application $app, Request $request, $sbas_id, $record_id) - { - $Story = new \record_adapter($sbas_id, $record_id); - - $user = $app['Core']->getAuthenticatedUser(); - - $em = $app['Core']->getEntityManager(); - - $repository = $em->getRepository('Entities\StoryWZ'); - - /* @var $repository \Repositories\StoryWZRepository */ - $StoryWZ = $repository->findUserStory($user, $Story); - - if (!$StoryWZ) - { - throw new \Exception_NotFound('Story not found'); - } - - - $data = array( - 'success' => true - , 'message' => _('Story detached from the WorkZone') - ); - - 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('/'); - } - }); - // $controllers->post('/{basket_id}/delete/', function(Application $app, Request $request, $basket_id) // { // $em = $app['Core']->getEntityManager(); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php index fdfbe5fecd..f13bfaa4c4 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php @@ -46,11 +46,151 @@ class WorkZone implements ControllerProviderInterface , 'srt' => $app['request']->get('sort') ); - $twig->addFilter(array('get_collection_logo' => 'collection::getLogo')); - return new Response($twig->render('prod/baskets.html', $params)); + return new Response($twig->render('prod/WorkZone/WorkZone.html.twig', $params)); }); + + $controllers->post( + '/attachStories/' + , function(Application $app, Request $request) + { + + + $user = $app['Core']->getAuthenticatedUser(); + + $em = $app['Core']->getEntityManager(); + /* @var $em \Doctrine\ORM\EntityManager */ + + $StoryWZRepo = $em->getRepository('\Entities\StoryWZ'); + + $alreadyFixed = $done = 0; + + foreach ( explode(';', $request->get('stories')) as $element) + { + $element = explode('_', $element); + $Story = new \record_adapter($element[0], $element[1]); + + if (!$Story->is_grouping()) + throw new \Exception('You can only attach stories'); + + if (!$user->ACL()->has_access_to_base($Story->get_base_id())) + throw new \Exception_Forbidden('You do not have access to this Story'); + + + if ($StoryWZRepo->findUserStory($user, $Story)) + { + $alreadyFixed++; + continue; + } + + $StoryWZ = new \Entities\StoryWZ(); + $StoryWZ->setUser($user); + $StoryWZ->setRecord($Story); + + $em->persist($StoryWZ); + $done++; + } + + $em->flush(); + + if ($alreadyFixed === 0) + { + if ($done <= 1) + { + $message = sprintf( + _('%d Story attached to the WorkZone') + , $done + ); + } + else + { + $message = sprintf( + _('%d Stories attached to the WorkZone') + , $done + ); + } + } + else + { + if ($done <= 1) + { + $message = sprintf( + _('%1$d Story attached to the WorkZone, %2$d already attached') + , $done + , $alreadyFixed + ); + } + else + { + $message = sprintf( + _('%1$d Story attached to the WorkZone, %2$d already attached') + , $done + , $alreadyFixed + ); + } + } + + $data = array( + 'success' => true + , 'message' => $message + ); + + 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('/{sbas_id}/{record_id}/'); + } + }); + + + $controllers->post( + '/detachStory/{sbas_id}/{record_id}/' + , function(Application $app, Request $request, $sbas_id, $record_id) + { + $Story = new \record_adapter($sbas_id, $record_id); + + $user = $app['Core']->getAuthenticatedUser(); + + $em = $app['Core']->getEntityManager(); + + $repository = $em->getRepository('\Entities\StoryWZ'); + + /* @var $repository \Repositories\StoryWZRepository */ + $StoryWZ = $repository->findUserStory($user, $Story); + + if (!$StoryWZ) + { + throw new \Exception_NotFound('Story not found'); + } + $em->remove($StoryWZ); + + $em->flush(); + + $data = array( + 'success' => true + , 'message' => _('Story detached from the WorkZone') + ); + + 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('/'); + } + }); + + return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php index 20aa0cee39..f0a66ff8b6 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php +++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php @@ -44,15 +44,21 @@ class RSSFeeds implements ControllerProviderInterface $registry = \registry::get_instance(); - if ($format == 'rss') + if ($format == \Feed_Adapter::FORMAT_RSS) { $content = new \Feed_XML_RSS(); } - if ($format == 'atom') + + if ($format == \Feed_Adapter::FORMAT_ATOM) { $content = new \Feed_XML_Atom(); } - + + if($format == \Feed_Adapter::FORMAT_COOLIRIS) + { + $content = new \Feed_XML_Cooliris(); + } + if ($user instanceof \User_Adapter) $link = $feed->get_user_link($registry, $user, $format, $page); else @@ -80,7 +86,7 @@ class RSSFeeds implements ControllerProviderInterface } foreach ($entries->get_entries() as $entry) $content->set_item($entry); - + $render = $content->render(); $response = new Response($render, 200, array('Content-Type' => $content->get_mimetype())); $response->setCharset('UTF-8'); @@ -164,7 +170,18 @@ class RSSFeeds implements ControllerProviderInterface return $display_feed($feed, $format, $page); })->assert('format', '(rss|atom)'); + $controllers->get('/cooliris/', function() use ($app, $appbox, $display_feed) { + $feeds = \Feed_Collection::load_public_feeds($appbox); + $feed = $feeds->get_aggregate(); + + $request = $app['request']; + $page = (int) $request->get('page'); + $page = $page < 1 ? 1 : $page; + + return $display_feed($feed, \Feed_Adapter::FORMAT_COOLIRIS , $page); + }); + return $controllers; } -} \ No newline at end of file +} diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php index 49c5f1675a..9437af03a3 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php @@ -20,15 +20,6 @@ use Silex\ControllerProviderInterface; use Silex\ControllerCollection; date_default_timezone_set('Europe/Berlin'); -require_once dirname(__FILE__) . '/../../../../version.inc'; -require_once dirname(__FILE__) . '/../../../../classes/phrasea.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/bootstrap.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/cache/cacheableInterface.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/cache/interface.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/cache/nocache.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/cache/adapter.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/User/Interface.class.php'; -require_once dirname(__FILE__) . '/../../../../classes/User/Adapter.class.php'; /** * @@ -43,8 +34,6 @@ class Installer implements ControllerProviderInterface { $controllers = new ControllerCollection(); - $app['available_languages'] = \User_Adapter::detectLanguage(new \Setup_Registry()); - $controllers->get('/', function() use ($app) { $request = $app['request']; @@ -89,17 +78,17 @@ class Installer implements ControllerProviderInterface } - $ld_path = array(dirname(__FILE__) . '/../../../../templates/web'); - $loader = new Twig_Loader_Filesystem($ld_path); - $twig = new Twig_Environment($loader); + $ld_path = array(__DIR__ . '/../../../../../templates/web'); + $loader = new \Twig_Loader_Filesystem($ld_path); + $twig = new \Twig_Environment($loader); $html = $twig->render( '/setup/index.twig' , array_merge($constraints_coll, array( 'locale' => Session_Handler::get_locale() - , 'available_locales' => $app['available_languages'] - , 'version_number' => GV_version - , 'version_name' => GV_version_name + , 'available_locales' => $app['Core']::getAvailableLanguages() + , 'version_number' => $app['Core']['Version']->getNumber() + , 'version_name' => $app['Core']['Version']->getName() , 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/' )) ); @@ -111,12 +100,12 @@ class Installer implements ControllerProviderInterface { \phrasea::use_i18n(\Session_Handler::get_locale()); - $ld_path = array(dirname(__FILE__) . '/../../../../templates/web'); + $ld_path = array(__DIR__ . '/../../../../../templates/web'); - $loader = new Twig_Loader_Filesystem($ld_path); - $twig = new Twig_Environment($loader); + $loader = new \Twig_Loader_Filesystem($ld_path); + $twig = new \Twig_Environment($loader); - $twig->addExtension(new Twig_Extensions_Extension_I18n()); + $twig->addExtension(new \Twig_Extensions_Extension_I18n()); $request = $app['request']; @@ -125,18 +114,19 @@ class Installer implements ControllerProviderInterface { $warnings[] = _('It is not recommended to install Phraseanet without HTTPS support'); } + $html = $twig->render( '/setup/step2.twig' , array( 'locale' => \Session_Handler::get_locale() - , 'available_locales' => $app['available_languages'] + , 'available_locales' => $app['Core']::getAvailableLanguages() , 'available_templates' => \appbox::list_databox_templates() - , 'version_number' => GV_version - , 'version_name' => GV_version_name + , '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(dirname(__FILE__))))) . '/' + , 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/' ) ); @@ -215,7 +205,7 @@ class Installer implements ControllerProviderInterface if ($databox_name) { - $template = new \system_file(dirname(__FILE__) . '/../../../conf.d/data_templates/' . $request->get('db_template') . '.xml'); + $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())) diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php b/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php index d68079202d..e9a0e74034 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Upgrader.php @@ -25,7 +25,6 @@ use Silex\ControllerCollection; * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ - class Upgrader implements ControllerProviderInterface { @@ -34,7 +33,6 @@ class Upgrader implements ControllerProviderInterface $controllers = new ControllerCollection(); $app['registry'] = new \Setup_Registry(); - $app['available_languages'] = \User_Adapter::detectLanguage($app['registry']); $app['twig'] = function() { return new \supertwig(); @@ -42,7 +40,7 @@ class Upgrader implements ControllerProviderInterface $controllers->get('/', function() use ($app) { - require_once dirname(__FILE__) . '/../../../../bootstrap.php'; + require_once __DIR__ . '/../../../../bootstrap.php'; $upgrade_status = \Setup_Upgrade::get_status(); ini_set('display_errors', 'on'); @@ -51,10 +49,11 @@ class Upgrader implements ControllerProviderInterface , array( 'locale' => \Session_Handler::get_locale() , 'upgrade_status' => $upgrade_status - , 'available_locales' => $app['available_languages'] + , 'available_locales' => $app['Core']::getAvailableLanguages() , 'bad_users' => \User_Adapter::get_wrong_email_users(\appbox::get_instance()) - , 'version_number' => GV_version - , 'version_name' => GV_version_name) + , 'version_number' => $app['Core']['Version']->getNumber() + , 'version_name' => $app['Core']['Version']->getName() + ) ); ini_set('display_errors', 'on'); @@ -63,7 +62,7 @@ class Upgrader implements ControllerProviderInterface $controllers->get('/status/', function() use ($app) { - require_once dirname(__FILE__) . '/../../../../bootstrap.php'; + require_once __DIR__ . '/../../../../bootstrap.php'; ini_set('display_errors', 'on'); $datas = \Setup_Upgrade::get_status(); @@ -73,7 +72,7 @@ class Upgrader implements ControllerProviderInterface $controllers->post('/execute/', function() use ($app) { - require_once dirname(__FILE__) . '/../../../../bootstrap.php'; + require_once __DIR__ . '/../../../../bootstrap.php'; ini_set('display_errors', 'on'); set_time_limit(0); session_write_close(); diff --git a/lib/Alchemy/Phrasea/Core.php b/lib/Alchemy/Phrasea/Core.php index 77ca90737c..64078be0b6 100644 --- a/lib/Alchemy/Phrasea/Core.php +++ b/lib/Alchemy/Phrasea/Core.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea; use Symfony\Component\HttpFoundation\Request, Symfony\Component\Serializer; +use Alchemy\Phrasea\Core\Configuration; require_once __DIR__ . '/../../vendor/Silex/vendor/pimple/lib/Pimple.php'; @@ -24,7 +25,22 @@ require_once __DIR__ . '/../../vendor/Silex/vendor/pimple/lib/Pimple.php'; class Core extends \Pimple { - public function __construct($isDev = false) + + protected static $availableLanguages = array( + 'ar_SA' => 'العربية' + , 'de_DE' => 'Deutsch' + , 'en_GB' => 'English' + , 'es_ES' => 'Español' + , 'fr_FR' => 'Français' + ); + + /** + * + * @var Core\Configuration + */ + private $configuration; + + public function __construct($environnement) { /** @@ -32,22 +48,48 @@ class Core extends \Pimple */ static::initAutoloads(); + + /** + * Init conf + */ + $this->init($environnement); + + /** + * Set version + */ $this['Version'] = $this->share(function() { return new Core\Version(); }); - $this['EM'] = $this->share(function() + /** + * Set Entity Manager using configuration + */ + $configuration = $this->getConfiguration(); + $this['EM'] = $this->share(function() use ($configuration) { - $doctrine = new Core\Service\Doctrine(); + $doctrine = new Core\Service\Doctrine($configuration->getDoctrine()); return $doctrine->getEntityManager(); }); - $this['Registry'] = $this->share(function() - { - return \registry::get_instance(); - }); + if (\setup::is_installed()) + { + $this['Registry'] = $this->share(function() + { + return \registry::get_instance(); + }); + \phrasea::start(); + $this->enableEvents(); + } + else + { + + $this['Registry'] = $this->share(function() + { + return new \Setup_Registry(); + }); + } /** * Initialize Request @@ -72,27 +114,48 @@ class Core extends \Pimple $this->verifyTimeZone(); - \phrasea::start(); - $this->detectLanguage(); $this->enableLocales(); - $this->enableEvents(); define('JETON_MAKE_SUBDEF', 0x01); define('JETON_WRITE_META_DOC', 0x02); define('JETON_WRITE_META_SUBDEF', 0x04); define('JETON_WRITE_META', 0x06); - $gatekeeper = \gatekeeper::getInstance(); - $gatekeeper->check_directory(); - + if (\setup::is_installed()) + { + $gatekeeper = \gatekeeper::getInstance(); + $gatekeeper->check_directory(); + } return; } /** - * + * Load Configuration + * + * @param type $environnement + */ + private function init($environnement) + { + $this->loadConf($environnement); + + if ($this->getConfiguration()->displayErrors()) + { + ini_set('display_errors', 1); + error_reporting(E_ALL); + \Symfony\Component\HttpKernel\Debug\ErrorHandler::register(); + } + else + { + ini_set('display_errors', 0); + } + } + + /** + * Getter + * * @return Request */ public function getRequest() @@ -101,7 +164,8 @@ class Core extends \Pimple } /** - * + * Getter + * * @return \Registry */ public function getRegistry() @@ -110,7 +174,8 @@ class Core extends \Pimple } /** - * + * Getter + * * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() @@ -119,7 +184,8 @@ class Core extends \Pimple } /** - * + * Getter + * * @return Alchemy\Phrasea\Core\Version */ public function getVersion() @@ -128,7 +194,8 @@ class Core extends \Pimple } /** - * + * Tell if current seession is authenticated + * * @return boolean */ public function isAuthenticated() @@ -139,7 +206,8 @@ class Core extends \Pimple } /** - * + * Return the current authenticated phraseanet user + * * @return \User_adapter */ public function getAuthenticatedUser() @@ -150,6 +218,19 @@ class Core extends \Pimple return \User_Adapter::getInstance($session->get_usr_id(), $appbox); } + /** + * Getter + * + * @return Core\Configuration + */ + public function getConfiguration() + { + return $this->configuration; + } + + /** + * Set Default application Timezone + */ protected function verifyTimezone() { if ($this->getRegistry()->is_set('GV_timezone')) @@ -170,11 +251,17 @@ class Core extends \Pimple protected function enableEvents() { - \phrasea::load_events(); + $events = \eventsmanager_broker::getInstance(\appbox::get_instance(), $this); + $events->start(); return; } + /** + * Initialiaze phraseanet log process + * + * @return Core + */ protected function initLoggers() { $php_log = $this->getRegistry()->get('GV_RootPath') . 'logs/php_error.log'; @@ -204,30 +291,43 @@ class Core extends \Pimple return $this; } + /** + * Return available language for phraseanet + * + * @return Array + */ + public static function getAvailableLanguages() + { + return static::$availableLanguages; + } + + /** + * Set Language + * + */ protected function detectLanguage() { - $availables = array( - 'ar_SA' => 'العربية' - , 'de_DE' => 'Deutsch' - , 'en_GB' => 'English' - , 'es_ES' => 'Español' - , 'fr_FR' => 'Français' - ); - $this->getRequest()->setDefaultLocale( $this->getRegistry()->get('GV_default_lng', 'en_GB') ); $cookies = $this->getRequest()->cookies; - if (isset($availables[$cookies->get('locale')])) + if (isset(static::$availableLanguages[$cookies->get('locale')])) { $this->getRequest()->setLocale($cookies->get('locale')); } + + \Session_Handler::set_locale($this->getRequest()->getLocale()); return; } + /** + * Finds the path to the file where the class is defined. + * + * @param string $class_name the name of the class we are looking for + */ protected static function phraseaAutoload($class_name) { if (file_exists(__DIR__ . '/../../../config/classes/' @@ -246,6 +346,10 @@ class Core extends \Pimple return; } + /** + * Register directory and namespaces for autoloading app classes + * + */ public static function initAutoloads() { require_once __DIR__ . '/../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; @@ -265,6 +369,7 @@ class Core extends \Pimple 'Symfony\\Component\\Yaml' => __DIR__ . '/../../vendor/symfony/src', 'Symfony\\Component\\Console' => __DIR__ . '/../../vendor/symfony/src', 'Symfony\\Component\\Serializer' => __DIR__ . '/../../vendor/symfony/src', + 'Symfony\\Component\\DependencyInjection' => __DIR__ . '/../../vendor/symfony/src', )); $loader->register(); @@ -274,6 +379,10 @@ class Core extends \Pimple return; } + /** + * Initialize some PHP configuration variables + * + */ public static function initPHPConf() { ini_set('output_buffering', '4096'); @@ -291,4 +400,29 @@ class Core extends \Pimple return; } + /** + * Return the current working environnement (test, dev, prod etc ...) + * + * @return string + */ + public function getEnv() + { + return $this->conf->getEnvironnement(); + } + + /** + * Load application configuration + * + * @param type $env + */ + private function loadConf($env) + { + $confHandler = new Configuration\Handler( + new Configuration\Application(), + new Configuration\Parser\Yaml() + ); + + $this->configuration = new Configuration($env, $confHandler); + } + } diff --git a/lib/Alchemy/Phrasea/Core/Configuration.php b/lib/Alchemy/Phrasea/Core/Configuration.php new file mode 100644 index 0000000000..8480ddb4cf --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Configuration.php @@ -0,0 +1,208 @@ +environnement = $envName; + $this->configurationHandler = $handler; + $this->installed = false; + + try + { + $handler->getSpecification()->getMainConfigurationFile(); + + $this->installed = true; + } + catch (\Exception $e) + { + + } + } + + /** + * Getter + * @return Configuration\Handler + */ + public function getConfigurationHandler() + { + return $this->configurationHandler; + } + + /** + * Setter + * @param Configuration\Handler $configurationHandler + */ + public function setConfigurationHandler(Configuration\Handler $configurationHandler) + { + $this->configurationHandler = $configurationHandler; + } + + /** + * Return the current used environnement + * + * @return string + */ + public function getEnvironnement() + { + return $this->environnement; + } + + /** + * Return the DBAL Doctrine configuration + * + * @return Array + */ + public function getDoctrine() + { + $doctrine = $this->getConfiguration()->get('doctrine', array()); //get doctrine scope + + if (count($doctrine) > 0) + { + $doctrine["debug"] = $this->isDebug(); //set debug + + if (!!$doctrine["log"]['enable']) + { + $logger = $doctrine["log"]["type"]; + + if (!in_array($doctrine["log"]["type"], $this->getAvailableDoctrineLogger())) + { + throw new \Exception(sprintf('Unknow logger %s', $logger)); + } + + $doctrineLogger = $this->getConfiguration()->get($logger); //set logger + + $doctrine["logger"] = $doctrineLogger; + } + } + + return $doctrine; + } + + /** + * Check if current environnement is on debug mode + * Default to false + * @return boolean + */ + public function isDebug() + { + $phraseanet = $this->getPhraseanet(); + return isset($phraseanet["debug"]) ? !!$phraseanet["debug"] : false; + } + + /** + * Check if current environnement should display errors + * Default to false + * @return boolean + */ + public function displayErrors() + { + $phraseanet = $this->getPhraseanet(); + return isset($phraseanet["display_errors"]) ? !!$phraseanet["display_errors"] : false; + } + + /** + * Return the phraseanet scope configurations values + * + * @return Array|null + */ + public function getPhraseanet() + { + return $this->getConfiguration()->get('phraseanet', array()); + } + + /** + * Tell if the application is installed + * + * @return boolean + */ + public function isInstalled() + { + return $this->installed; + } + + /** + * Return the configuration + * + * @return ParameterBag\ParameterBag + */ + public function getConfiguration() + { + if (null === $this->configuration) + { + $this->configuration = new Configuration\Parameter(); + + if($this->installed) + { + $configuration = $this->configurationHandler->handle($this->getEnvironnement()); + $this->configuration = new Configuration\Parameter($configuration); + } + } + + return $this->configuration; + } + + /** + * Return Available logger + * + * @return Array + */ + public function getAvailableDoctrineLogger() + { + return array('echo', 'monolog'); + } + + +} \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Application.php b/lib/Alchemy/Phrasea/Core/Configuration/Application.php new file mode 100644 index 0000000000..66bb0b91a5 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Configuration/Application.php @@ -0,0 +1,99 @@ +getMainConfigurationFile(); + } + + return new \SplFileObject(sprintf("%s/config_%s.%s" + , $this->getConfigurationFilePath() + , $name + , $this->getConfFileExtension()) + ); + } + + /** + * + * {@inheritdoc} + */ + public function getConfigurationFilePath() + { + return __DIR__ . '/../../../../../config'; + } + + /** + * + * {@inheritdoc} + */ + public function getMainConfigurationFile() + { + $path = __DIR__ . '/../../../../../config/config.yml'; + return new \SplFileObject($path); + } + + /** + * + * {@inheritdoc} + */ + public function getConfFileExtension() + { + return 'yml'; + } + + /** + * + * {@inheritdoc} + */ + public function isExtended(Array $env) + { + return isset($env[self::EXTENDED_KEYWORD]); + } + + /** + * + * {@inheritdoc} + */ + public function getExtendedEnvName(Array $env) + { + return $this->isExtended($env) ? $env[self::EXTENDED_KEYWORD] : null; + } + +} diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Handler.php b/lib/Alchemy/Phrasea/Core/Configuration/Handler.php new file mode 100644 index 0000000000..6815a0f9ca --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Configuration/Handler.php @@ -0,0 +1,231 @@ +confSpecification = $configSpec; + $this->parser = $parser; + } + + /** + * Getter + * @return Specification + */ + public function getSpecification() + { + return $this->confSpecification; + } + + /** + * Getter + * @return Parser + */ + public function getParser() + { + return $this->parser; + } + + /** + * Stacks all envrironnement in $env that extends the loaded configuration file + * + * @param SplFileObject $file File of the current loaded config file + * @param array $envs A stack of conf environnments + * @return array + */ + public function retrieveExtendedEnvFromFile(\SplFileObject $file, Array $allEnvs = array()) + { + $env = $this->parser->parse($file); + + //stack current env to allEnvs + $allEnvs[] = $env; + + //check if the loaded environnement extends another configuration file + if ($this->confSpecification->isExtended($env)) + { + try + { + //get extended environnement name + $envName = $this->confSpecification->getExtendedEnvName($env); + //get extended configuration file + $file = $this->confSpecification->getConfFileFromEnvName($envName); + //recurse + return $this->retrieveExtendedEnvFromFile($file, $allEnvs); + } + catch (\Exception $e) + { + throw new \Exception(sprintf("filename %s not found", $file->getPathname())); + } + } + else + { + return $allEnvs; + } + } + + /** + * Get the value of a specified data path + * + * @param array $data The array where the data are stored + * @param array $path The Path as an array example : array('path', 'to', 'my', 'value') + * @return mixed + */ + private function getDataPath(Array $data, Array $path) + { + $found = true; + + for ($x = 0; ($x < count($path) && $found); $x++) + { + $key = $path[$x]; + + if (isset($data[$key])) + { + $data = $data[$key]; + } + else + { + $found = false; + } + } + + return $found ? $data : null; + } + + /** + * Handle the configuration process and return the final configuration + * + * @param strinig $name the name of the loaded environnement + * @return Array + */ + public function handle($name) + { + //get the corresepondant file + $file = $this->confSpecification->getConfFileFromEnvName($name); + + //get all extended configuration from current env + $allEnvs = $this->retrieveExtendedEnvFromFile($file); + + //Last env is the main one + $mainEnv = array_pop($allEnvs); + + $excludedPath = $pathToprocess = $this->confSpecification->getNonExtendablePath(); + + //at least 2 envs and one path to process + if (count($allEnvs) >= 1 && count($excludedPath) >= 1) + { + foreach ($allEnvs as $currentEnv) // run trought environnements + { + foreach ($pathToprocess as $kpath => $processedPath) //run throught path + { + $valueToReplace = $this->getDataPath($currentEnv, $processedPath); //retrive the value to replace + + if (null !== $valueToReplace) + { + + // reset current path + $currentPath = array(); + + //callback to iterate over the main conf environnement and replace value from extended file + $map = function($item, $key) use (&$mainEnv, $valueToReplace, &$map, &$currentPath, $processedPath) + { + if (count(array_diff($processedPath, $currentPath)) === 0) // current path and processed path match + { + /** + * Replace current value of the $currentpath in $searchArray by $value + */ + $replace = function(&$searchArray, $currentPath, $value) use (&$replace) + { + foreach ($searchArray as $k => $v) + { + if ($k === $currentPath[0]) //if key of searched path equal key of search array + { + array_shift($currentPath); //reduce path + + if (is_array($v) && count($currentPath) !== 0) //continue to run trought search array + { + $replace(&$searchArray[$k], $currentPath, $value); + } + elseif (count($currentPath) === 0) //no more scope to looking for + { + $searchArray[$k] = $value; + break; //quit + } + } + } + }; + + $replace($mainEnv, $currentPath, $valueToReplace); + } + elseif (is_array($item)) // if current item is an array + { + $currentPath[] = $key; // add item's key to current path + + array_walk($item, $map); // and dig into the current item + } + else //wrong path + { + $currentPath = array(); //reset + } + }; + + //run trough the main conf environnement + array_walk($mainEnv, $map); + + //once done + //reduce the paths to process + unset($pathToprocess[$kpath]); + + break; + } + } + } + } + //replace all other value + if(count($allEnvs) >= 1) + { + foreach($allEnvs as $extendedEnv) + $mainEnv = array_replace_recursive($mainEnv, $extendedEnv); + } + + return $mainEnv; + } + +} diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Parameter.php b/lib/Alchemy/Phrasea/Core/Configuration/Parameter.php new file mode 100644 index 0000000000..d93c39c0e7 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Configuration/Parameter.php @@ -0,0 +1,37 @@ +getPathname()); + } + catch(\Exception $e) + { + throw new \Exception(sprintf('Failed to parse the configuration file %s', $e->getMessage())); + } + } + +} \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Specification.php b/lib/Alchemy/Phrasea/Core/Configuration/Specification.php new file mode 100644 index 0000000000..74e73ca546 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Configuration/Specification.php @@ -0,0 +1,90 @@ +setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); + //debug mode + $debug = isset($doctrineConfiguration["debug"]) ? : false; + //doctrine cache + $cache = isset($doctrineConfiguration["orm"]["cache"]) ? $doctrineConfiguration["orm"]["cache"] : false; + //doctrine log configuration + $log = isset($doctrineConfiguration["log"]) ? $doctrineConfiguration["log"] : false; + //service logger configuration + $logger = !isset($doctrineConfiguration['logger']) ? : $doctrineConfiguration['logger']; + + //default query cache & meta chache + $metaCache = $this->getCache(); + $queryCache = $this->getCache(); + + //handle cache + $this->handleCache($metaCache, $queryCache, $cache, $debug); + //Handle logs + $this->handleLogs($config, $log, $logger); + + //set caches + $config->setMetadataCacheImpl($metaCache); + $config->setQueryCacheImpl($queryCache); + + //define autoregeneration of proxies base on debug mode + $config->setAutoGenerateProxyClasses($debug); $chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain(); @@ -52,24 +77,31 @@ class Doctrine $config->setProxyNamespace('Proxies'); - require __DIR__ . '/../../../../../config/connexion.inc'; + $dbalConf = isset($doctrineConfiguration["dbal"]) ? $doctrineConfiguration["dbal"] : false; + + if (!$dbalConf) + { +// throw new Exception("Unable to read dbal configuration"); + + require __DIR__ . '/../../../../../config/connexion.inc'; + + $dbalConf = array( + 'dbname' => $dbname, + 'user' => $user, + 'password' => $password, + 'host' => $hostname, + 'driver' => 'pdo_mysql', + ); + } - $connectionOptions = array( - 'dbname' => $dbname, - 'user' => $user, - 'password' => $password, - 'host' => $hostname, - 'driver' => 'pdo_mysql', - ); - $evm = new \Doctrine\Common\EventManager(); $evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener()); - $this->entityManager = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm); - + $this->entityManager = \Doctrine\ORM\EntityManager::create($dbalConf, $config, $evm); + $this->addTypes(); - + return $this; } @@ -77,7 +109,7 @@ class Doctrine { return $this->entityManager; } - + public function getVersion() { return \Doctrine\Common\Version::VERSION; @@ -98,6 +130,18 @@ class Doctrine ); $classLoader->register(); + $classLoader = new \Doctrine\Common\ClassLoader( + 'Doctrine\Common\DataFixtures' + , realpath(__DIR__ . '/../../../../vendor/data-fixtures/lib') + ); + $classLoader->register(); + + $classLoader = new \Doctrine\Common\ClassLoader( + 'PhraseaFixture' + , realpath(__DIR__ . '/../../../../conf.d/') + ); + $classLoader->register(); + $classLoader = new \Doctrine\Common\ClassLoader( 'Doctrine\Common' , realpath(__DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib') @@ -121,19 +165,33 @@ class Doctrine , realpath(__DIR__ . '/../../../../Doctrine') ); $classLoader->register(); - + $classLoader = new \Doctrine\Common\ClassLoader( 'Symfony' , realpath(__DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor') - ); - + ); + $classLoader->register(); - + + $classLoader = new \Doctrine\Common\ClassLoader( + 'Doctrine\Logger' + , realpath(__DIR__ . '/../../../../') + ); + + $classLoader->register(); + + $classLoader = new \Doctrine\Common\ClassLoader( + 'Monolog' + , realpath(__DIR__ . '/../../../../vendor/Silex/vendor/monolog/src') + ); + + $classLoader->register(); + $classLoader = new \Doctrine\Common\ClassLoader( 'Types' , realpath(__DIR__ . '/../../../../Doctrine') - ); - + ); + $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader( @@ -145,23 +203,167 @@ class Doctrine return; } - + protected function addTypes() { - + $platform = $this->entityManager->getConnection()->getDatabasePlatform(); - - Type::addType('blob', 'Types\Blob'); - Type::addType('enum', 'Types\Enum'); - Type::addType('longblob', 'Types\LongBlob'); - Type::addType('varbinary', 'Types\VarBinary'); - + + if(!Type::hasType('blob')) + Type::addType('blob', 'Types\Blob'); + if(!Type::hasType('enum')) + Type::addType('enum', 'Types\Enum'); + if(!Type::hasType('longblob')) + Type::addType('longblob', 'Types\LongBlob'); + if(!Type::hasType('varbinary')) + Type::addType('varbinary', 'Types\VarBinary'); + $platform->registerDoctrineTypeMapping('enum', 'enum'); $platform->registerDoctrineTypeMapping('blob', 'blob'); $platform->registerDoctrineTypeMapping('longblob', 'longblob'); $platform->registerDoctrineTypeMapping('varbinary', 'varbinary'); - + return; } + /** + * Return a cache object according to the $name + * + * @param type $cacheName + */ + private function getCache($cacheName = self::ARRAYCACHE) + { + switch ($cacheName) + { + case self::MEMCACHED: + $cache = new \Doctrine\Common\Cache\MemcacheCache(); + break; + case self::APC: + $cache = new \Doctrine\Common\Cache\ApcCache(); + break; + case self::ARRAYCACHE: + default: + $cache = new \Doctrine\Common\Cache\ArrayCache(); + break; + } + + return $cache; + } + + /** + * Handle Cache configuration + * + * @param AbstractCache $metaCache + * @param AbstractCache $queryCache + * @param type $cache + * @param type $debug + */ + private function handleCache(AbstractCache &$metaCache, AbstractCache &$queryCache, $cache, $debug) + { + if ($cache && !$debug) + { + //define query cache + $cacheName = isset($cache["query"]) ? $cache["query"] : self::ARRAYCACHE; + $queryCache = $this->getCache($cacheName); + + //define metadatas cache + $cacheName = isset($cache["metadata"]) ? $cache["metadata"] : self::ARRAYCACHE; + $metaCache = $this->getCache($cacheName); + } + } + + /** + * Handle logs configuration + * + * @param \Doctrine\ORM\Configuration $config + * @param type $log + * @param type $logger + */ + private function handleLogs(\Doctrine\ORM\Configuration &$config, $log, $logger) + { + $logEnable = isset($log["enable"]) ? !!$log["enable"] : false; + + if ($logEnable) + { + $loggerService = isset($log["type"]) ? $log["type"] : ''; + + switch ($loggerService) + { + case 'monolog': + //defaut to main handler + $doctrineHandler = isset($log["handler"]) ? $log["handler"] : 'main'; + + if (!isset($logger["handlers"])) + { + throw new \Exception("You must specify at least on monolog handler"); + } + + if (!array_key_exists($doctrineHandler, $logger["handlers"])) + { + throw new \Exception(sprintf('Unknow monolog handler %s'), $handlerType); + } + + $handlerName = ucfirst($logger["handlers"][$doctrineHandler]["type"]); + + $handlerClassName = sprintf('\Monolog\Handler\%sHandler', $handlerName); + + if (!class_exists($handlerClassName)) + { + throw new \Exception(sprintf('Unknow monolog handler class %s', $handlerClassName)); + } + + if (!isset($log["filename"])) + { + throw new \Exception('you must specify a file to write "filename: my_filename"'); + } + + $logPath = __DIR__ . '/../../../../../logs'; + $file = sprintf('%s/%s', $logPath, $log["filename"]); + + if ($doctrineHandler == 'rotate') + { + $maxDay = isset($log["max_day"]) ? (int) $log["max_day"] : (int) $logger["max_day"]; + + $handlerInstance = new $handlerClassName($file, $maxDay); + } + else + { + $handlerInstance = new $handlerClassName($file); + } + + $monologLogger = new \Monolog\Logger('query-logger'); + $monologLogger->pushHandler($handlerInstance); + + if (isset($log["output"])) + { + $output = $log["output"]; + } + elseif (isset($logger["output"])) + { + $output = $logger["output"]; + } + else + { + $output = null; + } + + if (null === $output) + { + $sqlLogger = new \Doctrine\Logger\MonologSQLLogger($monologLogger); + } + else + { + $sqlLogger = new \Doctrine\Logger\MonologSQLLogger($monologLogger, $output); + } + + $config->setSQLLogger($sqlLogger); + break; + case 'echo': + default: + $config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + break; + } + } + } + } \ No newline at end of file diff --git a/lib/Alchemy/Phrasea/Helper/Helper.php b/lib/Alchemy/Phrasea/Helper/Helper.php index 09f38fb519..2953aa0afc 100644 --- a/lib/Alchemy/Phrasea/Helper/Helper.php +++ b/lib/Alchemy/Phrasea/Helper/Helper.php @@ -22,7 +22,11 @@ use Alchemy\Phrasea\Core; class Helper { - private $core; + /** + * + * @var Alchemy\Phrasea\Core\Kernel + */ + protected $core; /** * diff --git a/lib/Alchemy/Phrasea/Helper/Record/Bridge.php b/lib/Alchemy/Phrasea/Helper/Record/Bridge.php index a921d009aa..e69619bf75 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Bridge.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Bridge.php @@ -12,7 +12,7 @@ namespace Alchemy\Phrasea\Helper\Record; -use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper; +use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; /** * diff --git a/lib/Alchemy/Phrasea/Helper/Record/Edit.php b/lib/Alchemy/Phrasea/Helper/Record/Edit.php index 7327fa029a..e3206f957c 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Edit.php @@ -8,13 +8,17 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Alchemy\Phrasea\Helper\Record; - -use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper; -use Symfony\Component\HttpFoundation\Request; +use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper, + Symfony\Component\HttpFoundation\Request; /** + * Edit Record Helper + * This object handles /edit/ request and filters records that user can edit + * + * It prepares metadatas, databases structures. * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 @@ -64,16 +68,21 @@ class Edit extends RecordHelper * @var boolean */ protected $works_on_unique_sbas = true; + + /** + * + * @var type + */ protected $has_thesaurus = false; - - - public function __construct(Request $request) + /** + * + * @param \Alchemy\Phrasea\Core $core + * @return Edit + */ + public function __construct(\Alchemy\Phrasea\Core $core) { - $appbox = \appbox::get_instance(); - - parent::__construct($request); - + parent::__construct($core); if ($this->is_single_grouping()) { @@ -186,9 +195,7 @@ class Edit extends RecordHelper protected function generate_javascript_elements() { $_lst = array(); - $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); - $user = \User_Adapter::getInstance($session->get_usr_id(), $appbox); + $user = $this->getCore()->getAuthenticatedUser(); $twig = new \supertwig(); foreach ($this->selection as $record) @@ -251,7 +258,7 @@ class Edit extends RecordHelper } catch (Exception $e) { - + } $_lst[$indice]['type'] = $record->get_type(); } @@ -282,7 +289,7 @@ class Edit extends RecordHelper $T_sgval['b' . $base_id] = array(); $collection = \collection::get_from_base_id($base_id); - + if ($sxe = simplexml_load_string($collection->get_prefs())) { $z = $sxe->xpath('/baseprefs/sugestedValues'); @@ -292,7 +299,7 @@ class Edit extends RecordHelper foreach ($z[0] as $ki => $vi) // les champs { - + $field = $databox->get_meta_structure()->get_element_by_name($ki); if (!$field) continue; // champ inconnu dans la structure ? @@ -323,9 +330,7 @@ class Edit extends RecordHelper protected function generate_javascript_status() { $_tstatbits = array(); - $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); - $user = \User_Adapter::getInstance($session->get_usr_id(), $appbox); + $user = $this->getCore()->getAuthenticatedUser(); if ($user->ACL()->has_right('changestatus')) { @@ -441,7 +446,7 @@ class Edit extends RecordHelper try { $reg_record = $this->get_grouping_head(); - $reg_sbas_id = $reg_record->get_base_id(); + $reg_sbas_id = $reg_record->get_sbas_id(); $newsubdef_reg = new record_adapter($reg_sbas_id, $request->get('newrepresent')); @@ -457,12 +462,11 @@ class Edit extends RecordHelper } catch (Exception $e) { - + } } if (!is_array($request->get('mds'))) - return $this; $sbas_id = (int) $request->get('sbid'); diff --git a/lib/Alchemy/Phrasea/Helper/Record/Feed.php b/lib/Alchemy/Phrasea/Helper/Record/Feed.php index 5f6702d749..ae56596e6f 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Feed.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Feed.php @@ -12,7 +12,7 @@ namespace Alchemy\Phrasea\Helper\Record; -use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper; +use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; use Symfony\Component\HttpFoundation\Request; /** @@ -43,15 +43,13 @@ class Feed extends RecordHelper /** * - * @param Request $request - * @return RecordsFeed + * @param \Alchemy\Phrasea\Core $core + * @return Feed */ - public function __construct(Request $request) + public function __construct(\Alchemy\Phrasea\Core $core) { - $appbox = \appbox::get_instance(); - - parent::__construct($request); - + parent::__construct($core); + if ($this->is_single_grouping()) { $record = array_pop($this->selection->get_elements()); diff --git a/lib/Alchemy/Phrasea/Helper/RecordsAbstract.php b/lib/Alchemy/Phrasea/Helper/Record/Helper.php similarity index 81% rename from lib/Alchemy/Phrasea/Helper/RecordsAbstract.php rename to lib/Alchemy/Phrasea/Helper/Record/Helper.php index 6d8d9a9976..11210779b6 100644 --- a/lib/Alchemy/Phrasea/Helper/RecordsAbstract.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Helper.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Alchemy\Phrasea\Helper; +namespace Alchemy\Phrasea\Helper\Record; use Symfony\Component\HttpFoundation\Request; @@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\Request; * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class RecordsAbstract +class Helper extends \Alchemy\Phrasea\Helper\Helper { /** @@ -92,45 +92,38 @@ class RecordsAbstract /** * - * @var basket_adapter + * @var \Entities\Basket */ protected $original_basket; - /** * - * @return action_move + * @param \Alchemy\Phrasea\Core $core + * @return Helper */ - public function __construct(Request $request) + public function __construct(\Alchemy\Phrasea\Core $core) { - $this->request = $request; + parent::__construct($core); + $this->selection = new \set_selection(); + + $request = $core->getRequest(); + $appbox = \appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - + if (trim($request->get('ssel')) !== '') { - $basket = \basket_adapter::getInstance($appbox, $request->get('ssel'), $usr_id); - - if ($basket->is_grouping() && $this->flatten_groupings === true) - { - foreach ($basket->get_elements() as $basket_element) - { - /* @var $basket_element basket_element_adapter */ - $this->selection->add_element($basket_element->get_record()); - } - } - elseif($basket->is_grouping()) - { - $grouping = new record_adapter($basket->get_sbas_id(), $basket->get_record_id()); - $this->selection->add_element($grouping); - } - else - { - $this->selection->load_basket($basket); - $this->is_basket = true; - } - $this->original_basket = $basket; + $em = $this->getCore()->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $$repository \Repositories\BasketRepository */ + $Basket = $repository->findUserBasket($request->get('ssel'), $this->getCore()->getAuthenticatedUser()); + + $this->selection->load_basket($Basket); + + $this->is_basket = true; + $this->original_basket = $Basket; } else { @@ -159,7 +152,7 @@ class RecordsAbstract /** * If the original selection was a basket, returns the basket object * - * @return basket_adapter + * @return \Entities\Basket */ public function get_original_basket() { @@ -304,17 +297,7 @@ class RecordsAbstract return $this->selection->serialize_list(); } - public function get_request() - { - return $this->request; - } - - public function set_request($request) - { - $this->request = $request; - } - - public function grep_records(Closure $closure) + public function grep_records(\Closure $closure) { foreach ($this->selection->get_elements() as $record) { diff --git a/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php b/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php index 5d85ad5329..bb58038a27 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Helper/Record/MoveCollection.php @@ -11,8 +11,7 @@ namespace Alchemy\Phrasea\Helper\Record; - -use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper; +use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; use Symfony\Component\HttpFoundation\Request; /** @@ -23,33 +22,37 @@ use Symfony\Component\HttpFoundation\Request; */ class MoveCollection extends RecordHelper { + /** * * @var Array */ protected $required_rights = array('candeleterecord'); + /** * * @var Array */ protected $available_destinations; + /** * */ protected $works_on_unique_sbas = true; /** - * Constructor * - * @return action_move + * @param \Alchemy\Phrasea\Core $core + * @return MoveCollection */ - public function __construct(Request $request) + public function __construct(\Alchemy\Phrasea\Core $core) { - parent::__construct($request); + parent::__construct($core); $this->evaluate_destinations(); return $this; } + /** * Check which collections can receive the documents * @@ -60,14 +63,13 @@ class MoveCollection extends RecordHelper $this->available_destinations = array(); if (!$this->is_possible) - return $this; - $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); - $user = \User_Adapter::getInstance($session->get_usr_id(), $appbox); - - $this->available_destinations = array_keys($user->ACL()->get_granted_base(array('canaddrecord'), array($this->sbas_id))); + $this->available_destinations = array_keys( + $this->getCore()->getAuthenticatedUser()->ACL()->get_granted_base( + array('canaddrecord'), array($this->sbas_id) + ) + ); return $this; } @@ -95,8 +97,7 @@ class MoveCollection extends RecordHelper public function execute(Request $request) { $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); - $user = \User_Adapter::getInstance($session->get_usr_id(), $appbox); + $user = $this->getCore()->getAuthenticatedUser(); $base_dest = $user->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord') ? @@ -130,4 +131,5 @@ class MoveCollection extends RecordHelper return $this; } + } diff --git a/lib/Alchemy/Phrasea/Helper/Record/Printer.php b/lib/Alchemy/Phrasea/Helper/Record/Printer.php new file mode 100644 index 0000000000..9f57ae1f8c --- /dev/null +++ b/lib/Alchemy/Phrasea/Helper/Record/Printer.php @@ -0,0 +1,94 @@ +get_thumbnail()->get_type() == \media_subdef::TYPE_IMAGE || + $record->get_preview()->get_type() == \media_subdef::TYPE_IMAGE; + } + catch(\Exception $e) + { + return false; + } + }; + + $this->grep_records($grep); + } + + public function get_count_preview() + { + $n = 0; + foreach($this->get_elements() as $element) + { + try + { + $element->get_preview()->get_type() == \media_subdef::TYPE_IMAGE; + $n++; + } + catch(\Exception $e) + { + + } + } + + return $n; + } + + public function get_count_thumbnail() + { + $n = 0; + foreach($this->get_elements() as $element) + { + try + { + $element->get_thumbnail()->get_type() == \media_subdef::TYPE_IMAGE; + $n++; + } + catch(\Exception $e) + { + + } + } + + return $n; + } +} diff --git a/lib/Alchemy/Phrasea/Helper/Record/Tooltip.php b/lib/Alchemy/Phrasea/Helper/Record/Tooltip.php index 7f586c0aeb..d43a749638 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Tooltip.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Tooltip.php @@ -12,7 +12,7 @@ namespace Alchemy\Phrasea\Helper\Record; -use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper; +use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; /** * diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 657b7d1f0e..ba8d3b997b 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -19,11 +19,9 @@ use Symfony\Component\HttpFoundation\Request; * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class Edit +class Edit extends \Alchemy\Phrasea\Helper\Helper { - protected $request; - /** * * @var array @@ -42,19 +40,11 @@ class Edit */ protected $base_id; - /** - * - * @param Symfony\Component\HttpFoundation\Request $request - * @return module_admin_route_users_edit - */ - public function __construct(Request $request) + public function __construct(\Alchemy\Phrasea\Core $core) { + parent::__construct($core); $this->users = explode(';', $request->get('users')); - $this->request = $request; - $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); - $users = array(); foreach ($this->users as $usr_id) { @@ -83,23 +73,26 @@ class Edit protected function delete_user(\User_Adapter $user) { - $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); + $master = $this->getCore()->getAuthenticatedUser(); - $list = array_keys(\User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL()->get_granted_base(array('canadmin'))); + $list = array_keys($master->ACL()->get_granted_base(array('canadmin'))); $user->ACL()->revoke_access_from_bases($list); + if ($user->ACL()->is_phantom()) + { $user->delete(); - + } + return $this; } public function get_users_rights() { + $user = $this->getCore()->getAuthenticatedUser(); $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); - $list = array_keys(\User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL()->get_granted_base(array('canadmin'))); + + $list = array_keys($user->ACL()->get_granted_base(array('canadmin'))); $sql = "SELECT b.sbas_id, @@ -203,7 +196,7 @@ class Edit public function get_quotas() { - $this->base_id = (int) $this->request->get('base_id'); + $this->base_id = (int) $this->getCore()->getRequest()->get('base_id'); // $this->base_id = (int) $parm['base_id']; @@ -230,7 +223,7 @@ class Edit public function get_masks() { - $this->base_id = (int) $this->request->get('base_id'); + $this->base_id = (int) $this->getCore()->getRequest()->get('base_id'); $sql = "SELECT BIN(mask_and) AS mask_and, BIN(mask_xor) AS mask_xor FROM basusr @@ -334,7 +327,7 @@ class Edit public function get_time() { - $this->base_id = (int) $this->request->get('base_id'); + $this->base_id = (int) $this->getCore()->getRequest()->get('base_id'); $sql = "SELECT u.usr_id, time_limited, limited_from, limited_to FROM (usr u INNER JOIN basusr bu ON u.usr_id = bu.usr_id) @@ -540,7 +533,14 @@ class Edit return $this; } - $appbox = \appbox::get_instance(); + $user = User_adapter::getInstance(array_pop($this->users), appbox::get_instance()); + + if ($user->is_template()) + { + return $this; + } + + $appbox = appbox::get_instance(); $session = $appbox->get_session(); $request = \http_request::getInstance(); @@ -584,15 +584,45 @@ class Edit return $this; } + public function apply_template() + { + $appbox = appbox::get_instance(); + $session = $appbox->get_session(); + + $template = \User_adapter::getInstance($this->request->get('template'), $appbox); + + if ($template->get_template_owner()->get_id() != $session->get_usr_id()) + { + throw new \Exception_Forbidden('You are not the owner of the template'); + } + + $current_user = \User_adapter::getInstance($session->get_usr_id(), $appbox); + $base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin'))); + + foreach ($this->users as $usr_id) + { + $user = \User_adapter::getInstance($usr_id, $appbox); + + if($user->is_template()) + { + continue; + } + + $user->ACL()->apply_model($template, $base_ids); + } + + return $this; + } + public function apply_quotas() { - $this->base_id = (int) $this->request->get('base_id'); + $this->base_id = (int) $this->getCore()->getRequest()->get('base_id'); foreach ($this->users as $usr_id) { $user = \User_Adapter::getInstance($usr_id, \appbox::get_instance()); - if ($this->request->get('quota')) - $user->ACL()->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes')); + if ($this->getCore()->getRequest()->get('quota')) + $user->ACL()->set_quotas_on_base($this->base_id, $this->getCore()->getRequest()->get('droits'), $this->getCore()->getRequest()->get('restes')); else $user->ACL()->remove_quotas_on_base($this->base_id); } @@ -602,12 +632,13 @@ class Edit public function apply_masks() { - $this->base_id = (int) $this->request->get('base_id'); + $request = $this->getCore()->getRequest(); + $this->base_id = (int) $request->get('base_id'); - $vand_and = $this->request->get('vand_and'); - $vand_or = $this->request->get('vand_or'); - $vxor_and = $this->request->get('vxor_and'); - $vxor_or = $this->request->get('vxor_or'); + $vand_and = $request->get('vand_and'); + $vand_or = $request->get('vand_or'); + $vxor_and = $request->get('vxor_and'); + $vxor_or = $request->get('vxor_or'); if ($vand_and && $vand_or && $vxor_and && $vxor_or) { @@ -624,13 +655,14 @@ class Edit public function apply_time() { + $request = $this->getCore()->getRequest(); + + $this->base_id = (int) $request->get('base_id'); - $this->base_id = (int) $this->request->get('base_id'); + $dmin = $request->get('dmin') ? new \DateTime($request->get('dmin')) : null; + $dmax = $request->get('dmax') ? new \DateTime($request->get('dmax')) : null; - $dmin = $this->request->get('dmin') ? new \DateTime($this->request->get('dmin')) : null; - $dmax = $this->request->get('dmax') ? new \DateTime($this->request->get('dmax')) : null; - - $activate = $this->request->get('limit'); + $activate = $request->get('limit'); foreach ($this->users as $usr_id) { diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index 961727fbbb..aceeddd4b5 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -19,10 +19,9 @@ use Symfony\Component\HttpFoundation\Request; * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class Manage +class Manage extends \Alchemy\Phrasea\Helper\Helper { - protected $request; /** * * @var array @@ -39,18 +38,11 @@ class Manage */ protected $usr_id; - public function __construct(Request $request) - { - $this->request = $request; - - - return $this; - } - - public function search(Request $request) + public function search() { + $request = $this->getCore()->getRequest(); + $appbox = \appbox::get_instance(); - $session = $appbox->get_session(); $offset_start = (int) $request->get('offset_start'); $offset_start = $offset_start < 0 ? 0 : $offset_start; @@ -69,7 +61,7 @@ class Manage , 'offset_start' => $offset_start ); - $user = \User_Adapter::getInstance($session->get_usr_id(), $appbox); + $user = $this->getCore()->getAuthenticatedUser(); $query = new \User_Query($appbox); if (is_array($request->get('base_id'))) @@ -110,18 +102,25 @@ class Manage if (is_null($v)) $this->query_parms[$k] = false; } + + + $query = new User_Query($appbox); + $templates = $query + ->only_templates(true) + ->execute()->get_results(); return array( 'users' => $this->results, 'parm' => $this->query_parms, 'invite_user' => $invite, - 'autoregister_user' => $autoregister + 'autoregister_user' => $autoregister, + 'templates' => $templates ); } public function create_newuser() { - $email = $this->request->get('value'); + $email = $this->getCore()->getRequest()->get('value'); if(!\mail::validateEmail($email)) { @@ -153,7 +152,7 @@ class Manage public function create_template() { - $name = $this->request->get('value'); + $name = $this->getCore()->getRequest()->get('value'); if(trim($name) === '') { @@ -161,7 +160,7 @@ class Manage } $appbox = \appbox::get_instance(); - $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + $user = $this->getCore()->getAuthenticatedUser(); $created_user = \User_Adapter::create($appbox, $name, \random::generatePassword(16), null, false, false); $created_user->set_template($user); diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php new file mode 100644 index 0000000000..4ea4e3364e --- /dev/null +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -0,0 +1,528 @@ +get_subdef('preview'); + if (!$subdef->is_physically_present()) + { + continue; + } + if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) + continue; + + $subdef = $record->get_subdef('thumbnail'); + if (!$subdef->is_physically_present()) + continue; + + if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) + continue; + } + catch (\Exception $e) + { + continue; + } + break; + case self::LAYOUT_THUMBNAILLIST: + case self::LAYOUT_THUMBNAILGRID: + try + { + $subdef = $record->get_subdef('thumbnail'); + if (!$subdef->is_physically_present()) + continue; + + if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) + throw new \Exception('Not suitable'); + } + catch (\Exception $e) + { + continue; + } + break; + } + + $record->set_number(count($list) + 1); + + $list[] = $record; + } + + $this->records = $list; + + $pdf = new PhraseaPDF("P", "mm", "A4", true, 'UTF-8', false); + + $pdf->SetAuthor("Phraseanet"); + $pdf->SetTitle("Phraseanet Print"); + $pdf->SetDisplayMode("fullpage", "single"); + + $this->pdf = $pdf; + + switch ($layout) + { + case "preview": + $this->print_preview(); + break; + case "previewCaption": + $this->print_preview(); + break; + case "previewCaptionTdm": + $this->print_preview(true); + break; + case "thumbnailList": + $this->print_thumbnailList(); + break; + case "thumbnailGrid": + $this->print_thumbnailGrid(); + break; + } + + return $this; + } + + public function render() + { + $this->pdf->Close(); + + return $this->pdf->Output('', 'S'); + } + + protected function print_thumbnailGrid($links=false) + { + $appbox = \appbox::get_instance(); + $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + + $NDiapoW = 3; + $NDiapoH = 4; + + $this->pdf->AddPage(); + + $oldMargins = $this->pdf->getMargins(); + $tmargin = $oldMargins['top']; + $lmargin = $oldMargins['left']; + $bmargin = $oldMargins['bottom']; + $rmargin = $oldMargins['right']; + + $this->pdf->SetLeftMargin($lmargin + 55); + + $clientW = $this->pdf->getPageWidth() - $lmargin - $rmargin; + $clientH = $this->pdf->getPageHeight() - $tmargin - $bmargin; + + $DiapoW = floor($clientW / $NDiapoW); + $DiapoH = floor($clientH / $NDiapoH); + $TitleH = 5; + $ImgSize = min($DiapoW, ($DiapoH - $TitleH)) - 5; + + $npages = ceil(count($this->records) / ($NDiapoW * $NDiapoH)); + + $irow = $ipage = 0; + $icol = -1; + foreach ($this->records as $rec) + { + /* @var $rec record_adapter */ + if (++$icol >= $NDiapoW) + { + $icol = 0; + if (++$irow >= $NDiapoH) + { + $irow = 0; + $ipage++; + $this->pdf->AddPage(); + } + } + $fimg = null; + $himg = 0; + + $subdef = $rec->get_subdef('preview'); + + $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()); + + $wimg = $himg = $ImgSize; + if ($subdef->get_height() > 0 && $subdef->get_width() > 0) + { + if ($subdef->get_width() > $subdef->get_height()) + $himg = $wimg * $subdef->get_height() / $subdef->get_width(); + else + $wimg = $himg * $subdef->get_width() / $subdef->get_height(); + } + + if ($fimg) + { + $x = $lmargin + ($icol * $DiapoW); + $y = $tmargin + ($irow * $DiapoH); + $this->pdf->SetDrawColor(0); + $this->pdf->Rect($x, $y, $DiapoW, $DiapoH, "D"); + + $this->pdf->SetXY($x, $y + 1); + $this->pdf->SetFont(PhraseaPDF::FONT, '', 10); + $t = $irow . '-' . $x; + $t = $rec->get_title(); + + $this->pdf->MultiCell($DiapoW, $TitleH, $t, '0', 'C', false); + + if ($links) + { + $lk = $this->pdf->AddLink(); + $this->pdf->SetLink($lk, 0, $npages + $rec->get_number()); + $this->pdf->Image( + $fimg + , $x + (($DiapoW - $wimg) / 2) + , $TitleH + $y + (($DiapoH - $TitleH - $himg) / 2) + , $wimg, $himg + , null, $lk + ); + } + else + { + $this->pdf->Image($fimg + , $x + (($DiapoW - $wimg) / 2) + , $TitleH + $y + (($DiapoH - $TitleH - $himg) / 2) + , $wimg, $himg + ); + } + } + } + $this->pdf->SetLeftMargin($oldMargins['left']); + } + + protected function print_thumbnailList() + { + $this->pdf->AddPage(); + $oldMargins = $this->pdf->getMargins(); + + $tmargin = $oldMargins['top']; + $lmargin = $oldMargins['left']; + $bmargin = $oldMargins['bottom']; + $rmargin = $oldMargins['right']; + + $this->pdf->SetLeftMargin($lmargin + 55); + + $ndoc = 0; + $lastpage = $this->pdf->PageNo(); + foreach ($this->records as $rec) + { + /* @var $rec record_adapter */ + $subdef = $rec->get_subdef('thumbnail'); + + $fimg = $subdef->get_pathfile(); + $wimg = $himg = 50; + + if ($subdef->get_width() > $subdef->get_height()) + $himg = round($wimg * $subdef->get_height() / $subdef->get_width()); + else + $wimg = round($himg * $subdef->get_width() / $subdef->get_height()); + + $himg = 0; + + if ($this->pdf->GetY() > $this->pdf->getPageHeight() - (6 + $himg + 20)) + $this->pdf->AddPage(); + + $title = "record : " . $rec->get_title(); + + $y = $this->pdf->GetY(); + + $t = phrasea::bas_names($rec->get_base_id()); + $this->pdf->SetFont(PhraseaPDF::FONT, '', 10); + $this->pdf->SetFillColor(220, 220, 220); + $this->pdf->SetLeftMargin($lmargin); + $this->pdf->SetRightMargin($rmargin); + $this->pdf->SetX($lmargin); + $this->pdf->SetY($y); + + $this->pdf->out = false; + $this->pdf->MultiCell(140, 4, $title, "LTR", "L", 1); + $y2 = $this->pdf->GetY(); + $h = $y2 - $y; + $this->pdf->out = true; + $this->pdf->SetX($lmargin); + $this->pdf->SetY($y); + $this->pdf->Cell(0, $h, "", "LTR", 1, "R", 1); + $this->pdf->SetX($lmargin); + $this->pdf->SetY($y); + $this->pdf->Cell(0, 4, $t, "", 1, "R"); + $this->pdf->SetX($lmargin); + $this->pdf->SetY($y); + $this->pdf->MultiCell(140, 4, $title, "", "L"); + $this->pdf->SetX($lmargin); + $this->pdf->SetY($y = $y2); + + $this->pdf->SetLeftMargin($lmargin + 55); + $this->pdf->SetY($y + 2); + + if ($fimg) + { + $y = $this->pdf->GetY(); + $this->pdf->Image($fimg, $lmargin, $y, $wimg, $himg); + $this->pdf->SetY($y); + } + + $nf = 0; + $this->pdf->SetX($lmargin + 55); + $p0 = $this->pdf->PageNo(); + $y0 = $this->pdf->GetY(); + foreach ($rec->get_caption()->get_fields() as $field) + { + /* @var $field caption_field */ + + $this->pdf->SetFont(PhraseaPDF::FONT, 'B', 12); + $this->pdf->Write(5, $field->get_name() . " : "); + + $this->pdf->SetFont(PhraseaPDF::FONT, '', 12); + $this->pdf->Write(5, $field->get_value(true)); + + $this->pdf->Write(6, "\n"); + $nf++; + } + if ($this->pdf->PageNo() == $p0 && ($this->pdf->GetY() - $y0) < $himg) + $this->pdf->SetY($y0 + $himg); + $ndoc++; + } + $this->pdf->SetLeftMargin($lmargin); + } + + protected function print_preview($withtdm=false) + { + $appbox = \appbox::get_instance(); + $registry = \registry::get_instance(); + $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + + if ($withtdm === true) + { + $this->print_thumbnailGrid($this->pdf, $this->records, true); + } + + foreach ($this->records as $krec => $rec) + { + /* @var $rec record_adapter */ + + $this->pdf->AddPage(); + + if ($withtdm === "CALCPAGES") + { + if ($presentationpage) + $rec->set_number($this->pdf->PageNo() + 1); + else + $rec->set_number($this->pdf->PageNo()); + } + $lmargin = $this->pdf->GetX(); + $tmargin = $this->pdf->GetY(); + $himg = 0; + $y = 0; + $miniConv = NULL; + + $LEFT__TEXT = ""; + $LEFT__IMG = NULL; + $RIGHT_TEXT = ""; + $RIGHT_IMG = NULL; + + $LEFT__IMG = $registry->get('GV_RootPath') . "config/minilogos/logopdf_" + . $rec->get_sbas_id() . ".jpg"; + + if (!is_file($LEFT__IMG)) + { + $databox = $rec->get_databox(); + $str = $databox->get_sxml_structure(); + $vn = (string) ($str->pdfPrintLogo); + if (($vn * 1) == 1) + { + $LEFT__TEXT = $databox->get_viewname(); + } + } + + $collection = \collection::get_from_base_id($rec->get_base_id()); + + $vn = ""; + if ($str = simplexml_load_string($collection->get_prefs())) + $vn = (string) ($str->pdfPrintappear); + + if ($vn == "" || $vn == "1") + { + $RIGHT_TEXT = \phrasea::bas_names($rec->get_base_id()); + } + elseif ($vn == "2") + { + $RIGHT_IMG = $registry->get('GV_RootPath') . "config/minilogos/" . $rec->get_base_id(); + } + + $xtmp = $this->pdf->GetX(); + $ytmp = $this->pdf->GetY(); + + $this->pdf->SetFont(PhraseaPDF::FONT, '', 12); + $this->pdf->SetFillColor(220, 220, 220); + $y = $this->pdf->GetY(); + $this->pdf->MultiCell(95, 7, $LEFT__TEXT, "LTB", "L", 1); + $y2 = $this->pdf->GetY(); + $h = $y2 - $y; + $this->pdf->SetY($y); + $this->pdf->SetX(105); + $this->pdf->Cell(95, $h, $RIGHT_TEXT, "TBR", 1, "R", 1); + + if ($LEFT__TEXT == "" && is_file($LEFT__IMG)) + { + if ($size = @getimagesize($LEFT__IMG)) + { + $wmm = (int) $size[0] * 25.4 / 72; + $hmm = (int) $size[1] * 25.4 / 72; + if ($hmm > 6) + { + $coeff = $hmm / 6; + $wmm = (int) $wmm / $coeff; + $hmm = (int) $hmm / $coeff; + } + $this->pdf->Image($LEFT__IMG, $xtmp + 0.5, $ytmp + 0.5, $wmm, $hmm); + } + } + + if ($RIGHT_IMG != NULL && is_file($RIGHT_IMG)) + { + if ($size = @getimagesize($RIGHT_IMG)) + { + + if ($size[2] == '1') + { + if (!isset($miniConv[$RIGHT_IMG])) + { + $tmp_filename = tempnam('minilogos/', 'gif4fpdf'); + $img = imagecreatefromgif($RIGHT_IMG); + imageinterlace($img, 0); + imagepng($img, $tmp_filename); + rename($tmp_filename, $tmp_filename . '.png'); + $miniConv[$RIGHT_IMG] = $tmp_filename . '.png'; + $RIGHT_IMG = $tmp_filename . '.png'; + } + else + $RIGHT_IMG = $miniConv[$RIGHT_IMG]; + + $wmm = (int) $size[0] * 25.4 / 72; + $hmm = (int) $size[1] * 25.4 / 72; + if ($hmm > 6) + { + $coeff = $hmm / 6; + $wmm = (int) $wmm / $coeff; + $hmm = (int) $hmm / $coeff; + } + $tt = 0; + if ($hmm < 6) + $tt = (6 - $hmm) / 2; + $this->pdf->Image($RIGHT_IMG, 200 - 0.5 - $wmm, $ytmp + 0.5 + $tt); + } + else + { + $wmm = (int) $size[0] * 25.4 / 72; + $hmm = (int) $size[1] * 25.4 / 72; + if ($hmm > 6) + { + $coeff = $hmm / 6; + $wmm = (int) $wmm / $coeff; + $hmm = (int) $hmm / $coeff; + } + $this->pdf->Image($RIGHT_IMG, 200 - 0.5 - $wmm, $ytmp + 0.5); + } + } + } + + $y = $this->pdf->GetY() + 3; + + $subdef = $rec->get_subdef('preview'); + + $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()); + + $wimg = $himg = 150; // preview dans un carre de 150 mm + if ($subdef->get_width() > 0 && $subdef->get_height() > 0) + { + if ($subdef->get_width() > $subdef->get_height()) + $himg = $wimg * $subdef->get_height() / $subdef->get_width(); + else + $wimg = $himg * $subdef->get_width() / $subdef->get_height(); + } + $this->pdf->Image($f, $lmargin, $y, $wimg, $himg); + + if ($miniConv != NULL) + { + foreach ($miniConv as $oneF) + unlink($oneF); + } + $this->pdf->SetXY($lmargin, $y += ( $himg + 5)); + + $nf = 0; + foreach ($rec->get_caption()->get_fields() as $field) + { + /* @var $field caption_field */ + if ($nf > 0) + $this->pdf->Write(6, "\n"); + + $this->pdf->SetFont(PhraseaPDF::FONT, 'B', 12); + $this->pdf->Write(5, $field->get_name() . " : "); + + $this->pdf->SetFont(PhraseaPDF::FONT, '', 12); + + $t = str_replace( + array("<", ">", "&") + , array("<", ">", "&") + , $field->get_value(true) + ); + + $this->pdf->Write(5, $t); + + $nf++; + } + } + + return; + } + +} diff --git a/lib/Alchemy/Phrasea/Out/Tool/PhraseaPDF.php b/lib/Alchemy/Phrasea/Out/Tool/PhraseaPDF.php new file mode 100644 index 0000000000..0740769fd3 --- /dev/null +++ b/lib/Alchemy/Phrasea/Out/Tool/PhraseaPDF.php @@ -0,0 +1,54 @@ +SetLeftMargin(0); + $mr = $this->SetRightMargin(0); + + $this->SetY(-15); + + $this->SetFont(self::FONT, 'I', 8); + $this->Cell(0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C'); + + $this->SetFont(self::FONT, '', 8); + $w = $this->GetStringWidth('Printed by'); + + $this->SetFont(self::FONT, 'B', 8); + $w += $this->GetStringWidth(' Phraseanet'); + + $this->SetXY(-$w - $mr - 5, -15); + + $this->SetFont(self::FONT, '', 8); + $this->Write(8, 'Printed by'); + + $this->SetFont(self::FONT, 'B', 8); + $this->Write(8, ' Phraseanet'); + } + +} diff --git a/lib/Doctrine/Entities/Basket.php b/lib/Doctrine/Entities/Basket.php index c5ccb605b6..31aaee68fe 100644 --- a/lib/Doctrine/Entities/Basket.php +++ b/lib/Doctrine/Entities/Basket.php @@ -20,7 +20,6 @@ require_once __DIR__ . '/../../classes/User/Adapter.class.php'; * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ - class Basket { @@ -325,7 +324,7 @@ class Basket foreach ($this->getElements() as $basket_element) { $bask_record = $basket_element->getRecord(); - + if ($bask_record->get_record_id() == $record->get_record_id() && $bask_record->get_sbas_id() == $record->get_sbas_id()) { @@ -336,4 +335,27 @@ class Basket return false; } + public function getSize() + { + $totSize = 0; + + foreach ($this->getElements() as $basket_element) + { + try + { + $totSize += $basket_element->getRecord() + ->get_subdef('document') + ->get_size(); + } + catch (Exception $e) + { + + } + } + + $totSize = round($totSize / (1024 * 1024), 2); + + return $totSize; + } + } \ No newline at end of file diff --git a/lib/Doctrine/Entities/BasketElement.php b/lib/Doctrine/Entities/BasketElement.php index ed0db18c92..059b7e7adf 100644 --- a/lib/Doctrine/Entities/BasketElement.php +++ b/lib/Doctrine/Entities/BasketElement.php @@ -22,214 +22,235 @@ require_once __DIR__ . '/../../classes/record/adapter.class.php'; */ class BasketElement { - /** - * @var integer $id - */ - private $id; - /** - * @var integer $record_id - */ - private $record_id; + /** + * @var integer $id + */ + private $id; - /** - * @var integer $sbas_id - */ - private $sbas_id; + /** + * @var integer $record_id + */ + private $record_id; - /** - * @var integer $ord - */ - private $ord; + /** + * @var integer $sbas_id + */ + private $sbas_id; - /** - * @var datetime $created - */ - private $created; + /** + * @var integer $ord + */ + private $ord; - /** - * @var datetime $updated - */ - private $updated; + /** + * @var datetime $created + */ + private $created; - /** - * @var Entities\Basket - */ - private $basket; + /** + * @var datetime $updated + */ + private $updated; + /** + * @var Entities\Basket + */ + private $basket; - /** - * Get id - * - * @return integer - */ - public function getId() + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set record_id + * + * @param integer $recordId + */ + public function setRecordId($recordId) + { + $this->record_id = $recordId; + } + + /** + * Get record_id + * + * @return integer + */ + public function getRecordId() + { + return $this->record_id; + } + + /** + * Set sbas_id + * + * @param integer $sbasId + */ + public function setSbasId($sbasId) + { + $this->sbas_id = $sbasId; + } + + /** + * Get sbas_id + * + * @return integer + */ + public function getSbasId() + { + return $this->sbas_id; + } + + /** + * Set ord + * + * @param integer $ord + */ + public function setOrd($ord) + { + $this->ord = $ord; + } + + /** + * Get ord + * + * @return integer + */ + public function getOrd() + { + return $this->ord; + } + + /** + * Set created + * + * @param datetime $created + */ + public function setCreated($created) + { + $this->created = $created; + } + + /** + * Get created + * + * @return datetime + */ + public function getCreated() + { + return $this->created; + } + + /** + * Set updated + * + * @param datetime $updated + */ + public function setUpdated($updated) + { + $this->updated = $updated; + } + + /** + * Get updated + * + * @return datetime + */ + public function getUpdated() + { + return $this->updated; + } + + /** + * Set basket + * + * @param Entities\Basket $basket + */ + public function setBasket(\Entities\Basket $basket) + { + $this->basket = $basket; + } + + /** + * Get basket + * + * @return Entities\Basket + */ + public function getBasket() + { + return $this->basket; + } + + public function getRecord() + { + return new \record_adapter($this->getSbasId(), $this->getRecordId(), $this->getOrd()); + } + + public function setRecord(\record_adapter $record) + { + $this->setRecordId($record->get_record_id()); + $this->setSbasId($record->get_sbas_id()); + } + + public function setLastInBasket() + { + $this->setOrd($this->getBasket()->getElements()->count() + 1); + } + + /** + * @var Entities\ValidationData + */ + private $validation_datas; + + public function __construct() + { + $this->validation_datas = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Add validation_datas + * + * @param Entities\ValidationData $validationDatas + */ + public function addValidationData(\Entities\ValidationData $validationDatas) + { + $this->validation_datas[] = $validationDatas; + } + + /** + * Get validation_datas + * + * @return Doctrine\Common\Collections\Collection + */ + public function getValidationDatas() + { + return $this->validation_datas; + } + + /** + * + * @param \User_Adapter $user + * @return \Entities\ValidationData + */ + public function getUserValidationDatas(\User_Adapter $user) + { + foreach ($this->validation_datas as $validationData) { - return $this->id; + /* @var $validationData \Entities\ValidationData */ + if ($validationData->getParticipant()->getUser()->get_id() == $user->get_id()) + { + return $validationData; + } } - /** - * Set record_id - * - * @param integer $recordId - */ - public function setRecordId($recordId) - { - $this->record_id = $recordId; - } + throw new \Exception('There is no such participant'); + } - /** - * Get record_id - * - * @return integer - */ - public function getRecordId() - { - return $this->record_id; - } - - /** - * Set sbas_id - * - * @param integer $sbasId - */ - public function setSbasId($sbasId) - { - $this->sbas_id = $sbasId; - } - - /** - * Get sbas_id - * - * @return integer - */ - public function getSbasId() - { - return $this->sbas_id; - } - - /** - * Set ord - * - * @param integer $ord - */ - public function setOrd($ord) - { - $this->ord = $ord; - } - - /** - * Get ord - * - * @return integer - */ - public function getOrd() - { - return $this->ord; - } - - /** - * Set created - * - * @param datetime $created - */ - public function setCreated($created) - { - $this->created = $created; - } - - /** - * Get created - * - * @return datetime - */ - public function getCreated() - { - return $this->created; - } - - /** - * Set updated - * - * @param datetime $updated - */ - public function setUpdated($updated) - { - $this->updated = $updated; - } - - /** - * Get updated - * - * @return datetime - */ - public function getUpdated() - { - return $this->updated; - } - - /** - * Set basket - * - * @param Entities\Basket $basket - */ - public function setBasket(\Entities\Basket $basket) - { - $this->basket = $basket; - } - - /** - * Get basket - * - * @return Entities\Basket - */ - public function getBasket() - { - return $this->basket; - } - - public function getRecord() - { - return new \record_adapter($this->getSbasId(), $this->getRecordId(), $this->getOrd()); - } - - public function setRecord(\record_adapter $record) - { - $this->setRecordId($record->get_record_id()); - $this->setSbasId($record->get_sbas_id()); - } - - public function setLastInBasket() - { - $this->setOrd($this->getBasket()->getElements()->count() + 1); - } - /** - * @var Entities\ValidationData - */ - private $validation_datas; - - public function __construct() - { - $this->validation_datas = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * Add validation_datas - * - * @param Entities\ValidationData $validationDatas - */ - public function addValidationData(\Entities\ValidationData $validationDatas) - { - $this->validation_datas[] = $validationDatas; - } - - /** - * Get validation_datas - * - * @return Doctrine\Common\Collections\Collection - */ - public function getValidationDatas() - { - return $this->validation_datas; - } } \ No newline at end of file diff --git a/lib/Doctrine/Entities/ValidationParticipant.php b/lib/Doctrine/Entities/ValidationParticipant.php index c588a8892a..2fb2330d23 100644 --- a/lib/Doctrine/Entities/ValidationParticipant.php +++ b/lib/Doctrine/Entities/ValidationParticipant.php @@ -8,7 +8,9 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace Entities; + /** * * @package @@ -28,19 +30,44 @@ class ValidationParticipant */ private $usr_id; - /** - * @var Entities\ValidationData - */ - private $datases; - /** * @var Entities\ValidationSession */ private $session; + /** + * @var datetime $reminded + */ + private $reminded = null; + + /** + * @var Entities\ValidationData + */ + private $datas; + + /** + * @var boolean $is_confirmed + */ + private $is_confirmed = false; + + /** + * @var boolean $can_agree + */ + private $can_agree = false; + + /** + * @var boolean $can_see_others + */ + private $can_see_others = false; + + /** + * @var boolean $is_aware + */ + private $is_aware = false; + public function __construct() { - $this->datases = new \Doctrine\Common\Collections\ArrayCollection(); + $this->datas = new \Doctrine\Common\Collections\ArrayCollection(); } /** @@ -76,21 +103,11 @@ class ValidationParticipant /** * Add datases * - * @param Entities\ValidationData $datases + * @param Entities\ValidationData $datas */ - public function addValidationData(\Entities\ValidationData $datases) + public function addValidationData(\Entities\ValidationData $datas) { - $this->datases[] = $datases; - } - - /** - * Get datases - * - * @return Doctrine\Common\Collections\Collection - */ - public function getDatases() - { - return $this->datases; + $this->datas[] = $datas; } /** @@ -113,12 +130,6 @@ class ValidationParticipant return $this->session; } - /** - * @var boolean $is_aware - */ - private $is_aware = false; - - /** * Set is_aware * @@ -144,10 +155,125 @@ class ValidationParticipant * @param \User_Adapter $user * @return ValidationParticipant */ - public function setParticipant(\User_Adapter $user) + public function setUser(\User_Adapter $user) { $this->usr_id = $user->get_id(); return $this; } + public function getUser() + { + return \User_Adapter::getInstance($this->getUsrId(), \appbox::get_instance()); + } + + /** + * Set reminded + * + * @param datetime $reminded + */ + public function setReminded($reminded) + { + $this->reminded = $reminded; + } + + /** + * Get reminded + * + * @return datetime + */ + public function getReminded() + { + return $this->reminded; + } + + /** + * Get datas + * + * @return Doctrine\Common\Collections\Collection + */ + public function getDatas() + { + return $this->datas; + } + + /** + * Set is_confirmed + * + * @param boolean $isConfirmed + */ + public function setIsConfirmed($isConfirmed) + { + $this->is_confirmed = $isConfirmed; + } + + /** + * Get is_confirmed + * + * @return boolean + */ + public function getIsConfirmed() + { + return $this->is_confirmed; + } + + /** + * Set can_agree + * + * @param boolean $canAgree + */ + public function setCanAgree($canAgree) + { + $this->can_agree = $canAgree; + } + + /** + * Get can_agree + * + * @return boolean + */ + public function getCanAgree() + { + return $this->can_agree; + } + + /** + * Set can_see_others + * + * @param boolean $canSeeOthers + */ + public function setCanSeeOthers($canSeeOthers) + { + $this->can_see_others = $canSeeOthers; + } + + /** + * Get can_see_others + * + * @return boolean + */ + public function getCanSeeOthers() + { + return $this->can_see_others; + } + + public function isReleasable() + { + + if ($this->getIsConfirmed()) + { + return false; + } + + foreach ($this->getDatas() as $validation_data) + { + /* @var $validation_data \Entities\ValidationData */ + if ($validation_data->getAgreement() === null) + { + return false; + } + } + + return true; + } + } \ No newline at end of file diff --git a/lib/Doctrine/Entities/ValidationSession.php b/lib/Doctrine/Entities/ValidationSession.php index 53ecd9e063..42d05e2767 100644 --- a/lib/Doctrine/Entities/ValidationSession.php +++ b/lib/Doctrine/Entities/ValidationSession.php @@ -265,6 +265,24 @@ class ValidationSession return $this->participants; } + /** + * Get a participant + * + * @return Entities\ValidationParticipant + */ + public function getParticipant(\User_Adapter $user) + { + foreach ($this->getParticipants() as $participant) + { + if ($participant->getUser()->get_id() == $user->get_id()) + { + return $participant; + } + } + + throw new \Exception_NotFound('Particpant not found'); + } + /** * @var integer $initiator */ @@ -295,6 +313,11 @@ class ValidationSession return $this->initiator_id; } + public function isInitiator(\User_Adapter $user) + { + return $this->getInitiatorId() == $user->get_id(); + } + public function setInitiator(\User_Adapter $user) { $this->initiator_id = $user->get_id(); @@ -309,4 +332,55 @@ class ValidationSession } } + public function isFinished() + { + if (is_null($this->getExpires())) + { + return null; + } + + $date_obj = new DateTime(); + + return $date_obj > $this->getExpires(); + } + + public function getValidationString(\User_Adapter $user) + { + + if ($this->isInitiator($user)) + { + if ($this->isFinished()) + { + return sprintf( + _('Vous aviez envoye cette demande a %d utilisateurs') + , (count($this->getParticipants()) - 1) + ); + } + else + { + return sprintf( + _('Vous avez envoye cette demande a %d utilisateurs') + , (count($this->getParticipants()) - 1) + ); + } + } + else + { + if ($this->getParticipant($user)->getCanSeeOthers()) + { + return sprintf( + _('Processus de validation recu de %s et concernant %d utilisateurs') + , $this->getInitiator()->get_display_name() + , (count($this->getParticipants()) - 1)); + } + else + { + return sprintf( + _('Processus de validation recu de %s') + , $this->getInitiator()->get_display_name() + ); + } + } + } + } \ No newline at end of file diff --git a/lib/Doctrine/Logger/MonologSQLLogger.php b/lib/Doctrine/Logger/MonologSQLLogger.php new file mode 100644 index 0000000000..dac02f09bd --- /dev/null +++ b/lib/Doctrine/Logger/MonologSQLLogger.php @@ -0,0 +1,92 @@ +logger = $logger; + $this->outputType = $type; + } + + /** + * {@inheritdoc} + */ + public function startQuery($sql, array $params = null, array $types = null) + { + $this->start = microtime(true); + + $this->output["sql"] = $sql; + + if ($params) + { + $this->output["params"] = $params; + } + } + + /** + * {@inheritdoc} + */ + public function stopQuery() + { + $mstime = microtime(true) - $this->start; + + $this->output["times"] = $mstime . " seconds"; + if ($this->outputType == self::JSON) + { + $this->log(json_encode($this->output)); + } + elseif ($this->outputType == self::YAML) + { + $this->log(\Symfony\Component\Yaml\Yaml::dump($this->output)); + } + else + { + $this->log(var_export($this->output, true)); + } + } + + protected function log($message) + { + $this->logger->debug($message); + } + +} \ No newline at end of file diff --git a/lib/Doctrine/Proxies/EntitiesBasketProxy.php b/lib/Doctrine/Proxies/EntitiesBasketProxy.php index 99fbd0491a..1ed363229c 100644 --- a/lib/Doctrine/Proxies/EntitiesBasketProxy.php +++ b/lib/Doctrine/Proxies/EntitiesBasketProxy.php @@ -192,6 +192,12 @@ class EntitiesBasketProxy extends \Entities\Basket implements \Doctrine\ORM\Prox return parent::hasRecord($record); } + public function getSize() + { + $this->__load(); + return parent::getSize(); + } + public function __sleep() { diff --git a/lib/Doctrine/Repositories/BasketElementRepository.php b/lib/Doctrine/Repositories/BasketElementRepository.php new file mode 100644 index 0000000000..d3346b6b2d --- /dev/null +++ b/lib/Doctrine/Repositories/BasketElementRepository.php @@ -0,0 +1,119 @@ + $user->get_id(), + 'element_id' => $element_id + ); + + $query = $this->_em->createQuery($dql); + $query->setParameters($params); + + return $query->getOneOrNullResult(); + } + + public function findElementsByRecord(\record_adapter $record) + { + $dql = 'SELECT e FROM Entities\BasketElement e + WHERE e.record_id = :record_id AND e.sbas_id = :sbas_id'; + + $params = array( + 'sbas_id' => $record->get_sbas_id(), + 'record_id' => $record->get_record_id() + ); + + $query = $this->_em->createQuery($dql); + $query->setParameters($params); + + return $query->getResult(); + } + + /** + * + * @param \record_adapter $record + * @param \User_Adapter $user + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function findReceivedElementsByRecord(\record_adapter $record, \User_Adapter $user) + { + $dql = 'SELECT e FROM Entities\BasketElement e + JOIN e.basket b + WHERE b.usr_id = :usr_id AND b.pusher_id IS NOT NULL + AND e.record_id = :record_id AND e.sbas_id = :sbas_id'; + + $params = array( + 'sbas_id' => $record->get_sbas_id(), + 'record_id' => $record->get_record_id(), + 'usr_id' => $user->get_id() + ); + + $query = $this->_em->createQuery($dql); + $query->setParameters($params); + + return $query->getResult(); + } + + public function findReceivedValidationElementsByRecord(\record_adapter $record, \User_Adapter $user) + { + $dql = 'SELECT e FROM Entities\BasketElement e + JOIN e.basket b + JOIN b.validation v + JOIN v.participants p + WHERE p.usr_id = :usr_id + AND e.record_id = :record_id AND e.sbas_id = :sbas_id'; + + $params = array( + 'sbas_id' => $record->get_sbas_id(), + 'record_id' => $record->get_record_id(), + 'usr_id' => $user->get_id() + ); + + $query = $this->_em->createQuery($dql); + $query->setParameters($params); + + return $query->getResult(); + } + + /** + * + * @param type $element_id + * @param \User_Adapter $user + * @return \Entities\BasketELement + */ + public function findElement($element_id, \User_Adapter $user) + { + $element = $this->find($element_id); + + /* @var $element \Entities\BasketElement */ + if (null === $element) + { + throw new \Exception_NotFound(_('Element is not found')); + } + + if ($element->getBasket()->getowner()->get_id() != $user->get_id()) + { + throw new \Exception_Forbidden(_('You have not access to this basket element')); + } + + return $element; + } + +} \ No newline at end of file diff --git a/lib/Doctrine/Repositories/BasketRepository.php b/lib/Doctrine/Repositories/BasketRepository.php index 5ec96c8c0d..6e819836b4 100644 --- a/lib/Doctrine/Repositories/BasketRepository.php +++ b/lib/Doctrine/Repositories/BasketRepository.php @@ -32,14 +32,31 @@ class BasketRepository extends EntityRepository { $dql = 'SELECT b FROM Entities\Basket b WHERE b.usr_id = :usr_id AND b.archived = false'; - + $query = $this->_em->createQuery($dql); $query->setParameters(array('usr_id' => $user->get_id())); return $query->getResult(); } - + /** + * Returns all unread basket for a given user that are not marked as archived + * + * @param \User_Adapter $user + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function findUnreadActiveByUser(\User_Adapter $user) + { + $dql = 'SELECT b FROM Entities\Basket b + WHERE b.usr_id = :usr_id + AND b.archived = false AND b.is_read = false'; + + $query = $this->_em->createQuery($dql); + $query->setParameters(array('usr_id' => $user->get_id())); + + return $query->getResult(); + } + /** * Returns all baskets that are in validation session not expired and * where a specified user is participant (not owner) @@ -54,18 +71,27 @@ class BasketRepository extends EntityRepository JOIN s.participants p WHERE b.usr_id != ?1 AND p.usr_id = ?2 AND s.expires > CURRENT_TIMESTAMP()'; - + $query = $this->_em->createQuery($dql); $query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id())); return $query->getResult(); } - + + /** + * Find a basket specified by his basket_id and his owner + * + * @throws \Exception_NotFound + * @throws \Exception_Forbidden + * @param type $basket_id + * @param \User_Adapter $user + * @return \Entities\Basket + */ public function findUserBasket($basket_id, \User_Adapter $user) { $basket = $this->find($basket_id); - /* @var $basket Entities\Basket */ + /* @var $basket \Entities\Basket */ if (null === $basket) { throw new \Exception_NotFound(_('Basket is not found')); @@ -79,4 +105,21 @@ class BasketRepository extends EntityRepository return $basket; } + public function findContainingRecord(\record_adapter $record) + { + + $dql = 'SELECT b FROM Entities\Basket b + JOIN b.elements e + WHERE e.record_id = :record_id AND e.sbas_id = e.sbas_id'; + + $params = array( + 'record_id' => $record->get_record_id() + ); + + $query = $this->_em->createQuery($dql); + $query->setParameters($params); + + return $query->getResult(); + } + } diff --git a/lib/Doctrine/Repositories/StoryWZRepository.php b/lib/Doctrine/Repositories/StoryWZRepository.php index 56ac4cc821..7e58bcaf28 100644 --- a/lib/Doctrine/Repositories/StoryWZRepository.php +++ b/lib/Doctrine/Repositories/StoryWZRepository.php @@ -20,7 +20,7 @@ class StoryWZRepository extends EntityRepository public function findUserStory(\User_Adapter $user, \record_adapter $Story) { - return $this->findBy( + return $this->findOneBy( array( 'usr_id' => $user->get_id(), 'sbas_id' => $Story->get_sbas_id(), diff --git a/lib/bootstrap.php b/lib/bootstrap.php index 08b4717058..36ad600b21 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -11,9 +11,10 @@ /** * - * @package + * @return \Alchemy\Phrasea\Core * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ require_once dirname(__FILE__) . '/classes/bootstrap.class.php'; -bootstrap::execute(); + +return bootstrap::execute(); diff --git a/lib/classes/ACL.class.php b/lib/classes/ACL.class.php index 3f8ffd0ff0..26949a568f 100644 --- a/lib/classes/ACL.class.php +++ b/lib/classes/ACL.class.php @@ -47,6 +47,7 @@ class ACL implements cache_cacheableInterface * @var Array */ protected $_rights_records_preview; + /** * * @var Array @@ -242,47 +243,88 @@ class ACL implements cache_cacheableInterface if (count($base_ids) == 0) return $this; - $params = array( - ':usr_id' => $this->user->get_id() - , ':template_id' => $template_user->get_id() + $sbas_ids = array(); + + foreach ($base_ids as $base_id) + { + $sbas_ids[] = phrasea::sbasFromBas($base_id); + } + + $sbas_ids = array_unique($sbas_ids); + + $sbas_rights = array('bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub'); + + $sbas_to_acces = array(); + $rights_to_give = array(); + + foreach ($template_user->ACL()->get_granted_sbas() as $databox) + { + $sbas_id = $databox->get_sbas_id(); + + if (!in_array($sbas_id, $sbas_ids)) + continue; + + + if (!$this->has_access_to_sbas($sbas_id)) + { + $sbas_to_acces[] = $sbas_id; + } + + foreach ($sbas_rights as $right) + { + if ($template_user->ACL()->has_right_on_sbas($sbas_id, $right)) + { + $rights_to_give[$sbas_id][$right] = '1'; + } + } + } + + $this->give_access_to_sbas($sbas_to_acces); + + foreach ($rights_to_give as $sbas_id => $rights) + { + $this->update_rights_to_sbas($sbas_id, $rights); + } + + $bas_rights = array('canputinalbum', 'candwnldhd' + , 'candwnldpreview', 'cancmd' + , 'canadmin', 'actif', 'canreport', 'canpush' + , 'canaddrecord', 'canmodifrecord', 'candeleterecord' + , 'chgstatus', 'imgtools' + , 'manage', 'modify_struct' + , 'nowatermark', 'order_master' ); - $sql = 'INSERT INTO sbasusr - (SELECT distinct null as sbasusr_id, sb.sbas_id, :usr_id as usr_id, bas_manage - , bas_modify_struct,bas_modif_th,bas_chupub - FROM sbasusr sb, bas b - WHERE b.base_id IN (' . implode(', ', $base_ids) . ') - AND b.sbas_id = sb.sbas_id - AND usr_id = :template_id)'; + $bas_to_acces = array(); + $rights_to_give = array(); - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); + foreach ($template_user->ACL()->get_granted_base() as $collection) + { + $base_id = $collection->get_base_id(); - $this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS); + if (!in_array($base_id, $base_ids)) + continue; - $sql = "INSERT INTO basusr - (SELECT null as id, base_id, :usr_id as usr_id, canputinalbum - , candwnldhd, candwnldsubdef, candwnldpreview, cancmd - , canadmin, actif, canreport, canpush, now() as creationdate - , basusr_infousr, mask_and, mask_xor, restrict_dwnld - , month_dwnld_max, remain_dwnld, time_limited, limited_from - , limited_to, canaddrecord, canmodifrecord, candeleterecord - , chgstatus, '0000-00-00 00:00:00' as lastconn, imgtools - , manage, modify_struct, bas_manage, bas_modify_struct - , nowatermark, order_master - FROM basusr - WHERE usr_id = - (SELECT usr_id - FROM usr WHERE usr_id = :template_id) - AND base_id IN (" . implode(', ', $base_ids) . "))"; + if (!$this->has_access_to_base($base_id)) + { + $bas_to_acces[] = $base_id; + } - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); + foreach ($bas_rights as $right) + { + if ($template_user->ACL()->has_right_on_base($base_id, $right)) + { + $rights_to_give[$base_id][$right] = '1'; + } + } + } - $this->inject_rights(); - $this->delete_data_from_cache(self::CACHE_RIGHTS_BAS); + $this->give_access_to_base($bas_to_acces); + + foreach ($rights_to_give as $sbas_id => $rights) + { + $this->update_rights_to_base($base_id, $rights); + } $this->user->set_last_template($template_user); @@ -315,7 +357,7 @@ class ACL implements cache_cacheableInterface { return false; } - + if (!isset($this->_rights_bas[$base_id][$right])) throw new Exception('right ' . $right . ' does not exists'); @@ -750,7 +792,7 @@ class ACL implements cache_cacheableInterface { if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) return $this; - + try { $this->_rights_bas = $this->get_data_from_cache(self::CACHE_RIGHTS_BAS); @@ -1399,12 +1441,12 @@ class ACL implements cache_cacheableInterface $this->load_rights_bas(); $datetime = new DateTime(); - + if (!isset($this->_limited[$base_id])) { return false; } - + $ret = ($this->_limited[$base_id]['dmin'] > $datetime || $this->_limited[$base_id]['dmax'] < $datetime); diff --git a/lib/classes/API/OAuth2/Adapter.class.php b/lib/classes/API/OAuth2/Adapter.class.php index ec5dcaddbd..c70cf6f381 100644 --- a/lib/classes/API/OAuth2/Adapter.class.php +++ b/lib/classes/API/OAuth2/Adapter.class.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__) . '/../../../vendor/oauth2/lib/OAuth2.inc'; +require_once __DIR__ . '/../../../vendor/oauth2/lib/OAuth2.inc'; /** * diff --git a/lib/classes/API/OAuth2/Autoloader.class.php b/lib/classes/API/OAuth2/Autoloader.class.php index 6fd696ef08..1099c5eac6 100644 --- a/lib/classes/API/OAuth2/Autoloader.class.php +++ b/lib/classes/API/OAuth2/Autoloader.class.php @@ -41,7 +41,7 @@ class API_OAuth2_Autoloader */ static public function autoload($class) { - if (file_exists($file = dirname(__FILE__) . '/../../../vendor/oauth2/lib/' . str_replace(array('_', "\0"), array('/', ''), $class) . '.inc')) + if (file_exists($file = __DIR__ . '/../../../vendor/oauth2/lib/' . str_replace(array('_', "\0"), array('/', ''), $class) . '.inc')) { require $file; } diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index 75b9fe69ec..99c8060c53 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -34,6 +34,13 @@ class API_V1_adapter extends API_V1_Abstract */ protected $appbox; + /** + * Phraseanet Core + * + * @var \Alchemy\Phrasea\Core + */ + protected $core; + /** * API constructor * @@ -41,9 +48,10 @@ class API_V1_adapter extends API_V1_Abstract * @param appbox $appbox Appbox object * @return API_V1_adapter */ - public function __construct($auth_token, appbox &$appbox) + public function __construct($auth_token, appbox &$appbox, Alchemy\Phrasea\Core $core) { $this->appbox = $appbox; + $this->core = $core; return $this; } @@ -332,7 +340,7 @@ class API_V1_adapter extends API_V1_Abstract $ret = array(); foreach ($containers as $basket) { - $ret[$basket->get_ssel_id()] = $this->list_basket($basket); + $ret[$basket->getId()] = $this->list_basket($basket); } $result->set_datas(array("baskets" => $ret)); @@ -549,7 +557,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function add_record_tobasket(Request $request, $databox_id, $record_id) { - + } /** @@ -577,16 +585,16 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_baskets($usr_id) { - $basket_coll = new basketCollection($this->appbox, $usr_id); - + $em = $this->core->getEntityManager(); + $repo = $em->getRepository('\Entities\Basket'); + /* @var $repo \Repositories\BasketRepository */ + + $baskets = $repo->findActiveByUser($this->core->getAuthenticatedUser()); + $ret = array(); - foreach ($basket_coll->get_baskets() as $basktype => $baskets) + foreach ($baskets as $basket) { - if (!in_array($basktype, array('recept', 'baskets'))) - continue; - - foreach ($baskets as $basket) - $ret[$basket->get_ssel_id()] = $this->list_basket($basket); + $ret[$basket->getId()] = $this->list_basket($basket); } return $ret; @@ -607,10 +615,18 @@ class API_V1_adapter extends API_V1_Abstract if (trim(strip_tags($name)) === '') throw new API_V1_exception_badrequest (); - $user = User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox); - $basket = basket_adapter::create($this->appbox, $name, $user); + $user = $this->core->getAuthenticatedUser(); + + $Basket = new \Entities\Basket(); + $Basket->setOwner($user); + $Basket->setName($name); + + $em = $this->core->getEntityManager(); + $em->persist($Basket); + $em->flush(); + $ret = array(); - $ret[$basket->get_ssel_id()] = $this->list_basket($basket); + $ret[$Basket->getId()] = $this->list_basket($Basket); $result->set_datas(array("basket" => $ret)); return $result; @@ -627,12 +643,15 @@ class API_V1_adapter extends API_V1_Abstract { $result = new API_V1_result($request, $this); - $basket = basket_adapter::getInstance( - $this->appbox - , $basket_id - , $this->appbox->get_session()->get_usr_id() - ); - $basket->delete(); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser()); + $em->remove($Basket); + $em->flush(); return $this->search_baskets($request); } @@ -647,21 +666,21 @@ class API_V1_adapter extends API_V1_Abstract public function get_basket(Request $request, $basket_id) { $result = new API_V1_result($request, $this); - try - { - $basket = basket_adapter::getInstance($this->appbox, $basket_id, $this->appbox->get_session()->get_usr_id()); - $result->set_datas( - array("basket_elements" => - array( - $basket->get_ssel_id() => $this->list_basket_content($basket) - ) - ) - ); - } - catch (Exception $e) - { - } + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser()); + + $result->set_datas( + array("basket_elements" => + array( + $Basket->getId() => $this->list_basket_content($Basket) + ) + ) + ); return $result; } @@ -669,16 +688,18 @@ class API_V1_adapter extends API_V1_Abstract /** * Retrieve elements of one basket * - * @param basket_adapter $basket + * @param \Entities\Basket $Basket * @return type */ - protected function list_basket_content(basket_adapter $basket) + protected function list_basket_content(\Entities\Basket $Basket) { - $ret = $this->list_basket($basket); + $ret = $this->list_basket($Basket); + $ret['basket_elements'] = array(); - foreach ($basket->get_elements() as $basket_element) + + foreach ($Basket->getElements() as $basket_element) { - $ret['basket_elements'][$basket_element->get_sselcont_id()] = $this->list_basket_element($basket_element); + $ret['basket_elements'][$basket_element->getId()] = $this->list_basket_element($basket_element); } return $ret; @@ -687,23 +708,46 @@ class API_V1_adapter extends API_V1_Abstract /** * Retrieve detailled informations about a basket element * - * @param basket_element_adapter $basket_element + * @param \Entities\BasketElement $basket_element * @return type */ - protected function list_basket_element(basket_element_adapter $basket_element) + protected function list_basket_element(\Entities\BasketElement $basket_element) { $ret = array( - 'basket_element_id' => $basket_element->get_sselcont_id() - , 'order' => $basket_element->get_order() - , 'record' => $this->list_record($basket_element->get_record()) - , 'validation_item' => $basket_element->is_validation_item() + 'basket_element_id' => $basket_element->getId() + , 'order' => $basket_element->getOrd() + , 'record' => $this->list_record($basket_element->getRecord()) + , 'validation_item' => !!$basket_element->getValidationDatas() ); - if ($basket_element->is_validation_item()) + if ($basket_element->getValidationDatas()) { - $ret['choices'] = $basket_element->get_choices(); - $ret['agreement'] = $basket_element->get_my_agreement(); - $ret['note'] = $basket_element->get_my_note(); + $choices = array(); + $agreement = $note = null; + + foreach ($basket_element->getValidationDatas() as $validation_datas) + { + $user = $validation_datas->getParticipant()->getUser(); + /* @var $validation_datas Entities\ValidationData */ + $choices[$user->get_id()] = array( + 'usr_id' => $user->get_id(), + 'usr_name' => $user->get_display_name(), + 'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(), + 'agreement' => $validation_datas->getAgreement(), + 'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM), + 'note' => $validation_datas->getNote() + ); + + if($user->get_id() == $this->core->getAuthenticatedUser()->get_id()) + { + $agreement = $validation_datas->getAgreement(); + $note = $validation_datas->getNote(); + } + } + + $ret['choices'] = $choices(); + $ret['agreement'] = $agreement(); + $ret['note'] = $note(); } return $ret; @@ -721,12 +765,23 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($request, $this); $name = $request->get('name'); - $basket = basket_adapter::getInstance($this->appbox, $basket_id, $this->appbox->get_session()->get_usr_id()); - $basket->set_name($name); + + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser()); + $Basket->setName($name); + + $em->merge($Basket); + $em->flush(); + $result->set_datas( array( "basket" => - array($basket->get_ssel_id() => $this->list_basket_content($basket) + array($Basket->getId() => $this->list_basket_content($Basket) ) ) ); @@ -746,12 +801,23 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($request, $this); $desc = $request->get('description'); - $basket = basket_adapter::getInstance($this->appbox, $basket_id, $this->appbox->get_session()->get_usr_id()); - $basket->set_description($desc); + + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket($basket_id, $this->core->getAuthenticatedUser()); + $Basket->setDescription($desc); + + $em->merge($Basket); + $em->flush(); + $result->set_datas( array( "basket" => - array($basket->get_ssel_id() => $this->list_basket_content($basket) + array($Basket->getId() => $this->list_basket_content($Basket) ) ) ); @@ -791,7 +857,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function remove_publications(Request $request, $publication_id) { - + } /** @@ -919,7 +985,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function search_users(Request $request) { - + } /** @@ -929,7 +995,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function get_user_acces(Request $request, $usr_id) { - + } /** @@ -938,7 +1004,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function add_user(Request $request) { - + } /** @@ -1032,7 +1098,6 @@ class API_V1_adapter extends API_V1_Abstract * @todo ajouter une option pour avoir les values serialisées * dans un cas multi */ - return array( 'meta_id' => $field->get_meta_id() , 'meta_structure_id' => $field->get_meta_struct_id() @@ -1044,30 +1109,53 @@ class API_V1_adapter extends API_V1_Abstract /** * Retirve information about one basket * - * @param basket_adapter $basket + * @param \Entities\Basket $basket * @return array */ - protected function list_basket(basket_adapter $basket) + protected function list_basket(\Entities\Basket $basket) { $ret = array( - 'created_on' => $basket->get_create_date()->format(DATE_ATOM) - , 'description' => $basket->get_description() - , 'name' => $basket->get_name() - , 'pusher_usr_id' => $basket->get_pusher() ? $basket->get_pusher()->get_id() : null - , 'ssel_id' => $basket->get_ssel_id() - , 'updated_on' => $basket->get_update_date()->format(DATE_ATOM) - , 'unread' => $basket->is_unread() + 'created_on' => $basket->getCreated()->format(DATE_ATOM) + , 'description' => (string) $basket->getDescription() + , 'name' => $basket->getName() + , 'pusher_usr_id' => $basket->getPusherId() + , 'ssel_id' => $basket->getId() + , 'updated_on' => $basket->getUpdated()->format(DATE_ATOM) + , 'unread' => !$basket->getIsRead() ); - if ($basket->is_valid()) + if ($basket->getValidation()) { + $users = array(); + + foreach ($basket->getValidation()->getParticipants() as $participant) + { + /* @var $participant \Entities\ValidationParticipant */ + $user = $participant->getUser(); + + $users[$user->get_id()] = array( + 'usr_id' => $user->get_id(), + 'usr_name' => $user->get_display_name(), + 'confirmed' => $participant->getIsConfirmed(), + 'can_agree' => $participant->getCanAgree(), + 'can_see_others' => $participant->getCanSeeOthers() + ); + } + + $expires_on_atom = $basket->getValidation()->getExpires(); + + if ($expires_on_atom instanceof DateTime) + $expires_on_atom = $expires_on_atom->format(DATE_ATOM); + + $user = \User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox); + $ret = array_merge( array( - 'validation_users' => $basket->get_validating_users() - , 'validation_end_date' => ($basket->get_validation_end_date() instanceof DateTime ? $basket->get_validation_end_date()->format(DATE_ATOM) : null) - , 'validation_infos' => $basket->get_validation_infos() - , 'validation_confirmed' => $basket->is_confirmed() - , 'mine' => $basket->is_mine() + 'validation_users' => $users + , 'validation_end_date' => $expires_on_atom + , 'validation_infos' => $basket->getValidation()->getValidationString($user) + , 'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed() + , 'mine' => $basket->getValidation()->isInitiator($user) ) , $ret ); diff --git a/lib/classes/API/V1/result.class.php b/lib/classes/API/V1/result.class.php index cf8f410e83..4469c26413 100644 --- a/lib/classes/API/V1/result.class.php +++ b/lib/classes/API/V1/result.class.php @@ -1,6 +1,6 @@ $response['refresh_token'], 'auth_token' => $response['access_token']); } diff --git a/lib/classes/Bridge/Api/Dailymotion.class.php b/lib/classes/Bridge/Api/Dailymotion.class.php index 8cbc9fdfb8..57a916af15 100644 --- a/lib/classes/Bridge/Api/Dailymotion.class.php +++ b/lib/classes/Bridge/Api/Dailymotion.class.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -require_once dirname(__FILE__) . "/../../../classes/DailymotionWithoutOauth2.php"; +require_once __DIR__ . "/../../../classes/DailymotionWithoutOauth2.php"; use \Symfony\Component\HttpFoundation\Request; diff --git a/lib/classes/Bridge/Api/Flickr.class.php b/lib/classes/Bridge/Api/Flickr.class.php index 47f1484f03..449bc885cc 100644 --- a/lib/classes/Bridge/Api/Flickr.class.php +++ b/lib/classes/Bridge/Api/Flickr.class.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -$new_include_path = dirname(__FILE__) . "/../../../vendor/" . PATH_SEPARATOR . get_include_path(); +$new_include_path = __DIR__ . "/../../../vendor/" . PATH_SEPARATOR . get_include_path(); set_include_path($new_include_path); use \Symfony\Component\HttpFoundation\Request; -require_once dirname(__FILE__) . "/../../../vendor/Phlickr/Api.php"; -require_once dirname(__FILE__) . "/../../../vendor/Phlickr/Uploader.php"; +require_once __DIR__ . "/../../../vendor/Phlickr/Api.php"; +require_once __DIR__ . "/../../../vendor/Phlickr/Uploader.php"; /** * diff --git a/lib/classes/Bridge/Api/Youtube.class.php b/lib/classes/Bridge/Api/Youtube.class.php index 7d0629d09e..e715d29178 100644 --- a/lib/classes/Bridge/Api/Youtube.class.php +++ b/lib/classes/Bridge/Api/Youtube.class.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -$new_include_path = dirname(__FILE__) . '/../../../vendor/gdata/' . PATH_SEPARATOR . get_include_path(); +$new_include_path = __DIR__ . '/../../../vendor/gdata/' . PATH_SEPARATOR . get_include_path(); set_include_path($new_include_path); require_once('Zend/Loader.php'); @@ -245,7 +245,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } } diff --git a/lib/classes/Bridge/Exception.class.php b/lib/classes/Bridge/Exception.class.php index d802d3e9f9..2c080be9da 100644 --- a/lib/classes/Bridge/Exception.class.php +++ b/lib/classes/Bridge/Exception.class.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class Bridge_Exception extends Exception +class Bridge_Exception extends \Exception { } \ No newline at end of file diff --git a/lib/classes/Bridge/Exception/ApiConnectorNotConfigured.class.php b/lib/classes/Bridge/Exception/ApiConnectorNotConfigured.class.php index 7fb7faf5f9..8799133c1b 100644 --- a/lib/classes/Bridge/Exception/ApiConnectorNotConfigured.class.php +++ b/lib/classes/Bridge/Exception/ApiConnectorNotConfigured.class.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class Bridge_Exception_ApiConnectorNotConfigured extends Bridge_Exception +class Bridge_Exception_ApiConnectorNotConfigured extends \Bridge_Exception { } diff --git a/lib/classes/Bridge/Exception/ApiConnectorNotConnected.class.php b/lib/classes/Bridge/Exception/ApiConnectorNotConnected.class.php index 351007ec8c..14844026ef 100644 --- a/lib/classes/Bridge/Exception/ApiConnectorNotConnected.class.php +++ b/lib/classes/Bridge/Exception/ApiConnectorNotConnected.class.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -class Bridge_Exception_ApiConnectorNotConnected extends Bridge_Exception +class Bridge_Exception_ApiConnectorNotConnected extends \Bridge_Exception { } diff --git a/lib/classes/Feed/Abstract.class.php b/lib/classes/Feed/Abstract.class.php index 32fc3c3753..b9450c260d 100644 --- a/lib/classes/Feed/Abstract.class.php +++ b/lib/classes/Feed/Abstract.class.php @@ -25,6 +25,10 @@ abstract class Feed_Abstract * */ const FORMAT_ATOM = 'atom'; + /** + * + */ + const FORMAT_COOLIRIS = 'cooliris'; /** * diff --git a/lib/classes/Feed/Adapter.class.php b/lib/classes/Feed/Adapter.class.php index eb55cbaee0..0a5a301ca8 100644 --- a/lib/classes/Feed/Adapter.class.php +++ b/lib/classes/Feed/Adapter.class.php @@ -57,6 +57,8 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea const CACHE_ENTRY_NUMBER = 'entrynumber'; const CACHE_USER_TOKEN = 'usr_token'; + + const MAX_ENTRIES = 20; /** * @@ -561,7 +563,7 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea public function get_entries($offset_start, $how_many) { $offset_start = (int) $offset_start; - $how_many = $how_many > 20 ? 20 : (int) $how_many; + $how_many = $how_many > self::MAX_ENTRIES ? self::MAX_ENTRIES : (int) $how_many; $sql = 'SELECT id FROM feed_entries diff --git a/lib/classes/Feed/Aggregate.class.php b/lib/classes/Feed/Aggregate.class.php index 4367eda24e..6d1c083e5c 100644 --- a/lib/classes/Feed/Aggregate.class.php +++ b/lib/classes/Feed/Aggregate.class.php @@ -158,6 +158,16 @@ class Feed_Aggregate extends Feed_Abstract implements Feed_Interface , 'application/atom+xml' ); break; + case self::FORMAT_COOLIRIS: + return new Feed_Link( + sprintf('%sfeeds/cooliris/%s' + , $registry->get('GV_ServerName') + , ($page ? '?page=' . $page : '') + ) + , sprintf('%s - %s', $this->get_title(), 'RSS') + , 'application/rss+xml' + ); + break; default: case self::FORMAT_RSS: return new Feed_Link( diff --git a/lib/classes/Feed/XML/Cooliris.class.php b/lib/classes/Feed/XML/Cooliris.class.php new file mode 100644 index 0000000000..36d2f3830c --- /dev/null +++ b/lib/classes/Feed/XML/Cooliris.class.php @@ -0,0 +1,459 @@ +language = $language; + + return $this; + } + + /** + * + * @param string $language + * @return Feed_XML_RSS + */ + public function set_copyright($copyright) + { + $this->copyright = $copyright; + + return $this; + } + + /** + * + * @param string $managingEditor + * @return Feed_XML_RSS + */ + public function set_managingEditor($managingEditor) + { + $this->managingEditor = $managingEditor; + + return $this; + } + + /** + * + * @param string $webMaster + * @return Feed_XML_RSS + */ + public function set_webMaster($webMaster) + { + $this->webMaster = $webMaster; + + return $this; + } + + /** + * + * @param DateTime $lastBuildDate + * @return Feed_XML_RSS + */ + public function set_lastBuildDate(DateTime $lastBuildDate) + { + $this->lastBuildDate = $lastBuildDate; + + return $this; + } + + /** + * + * @param string $category + * @return Feed_XML_RSS + */ + public function set_category($category) + { + $this->categories[] = $category; + + return $this; + } + + /** + * + * @param string $docs + * @return Feed_XML_RSS + */ + public function set_docs($docs) + { + $this->docs = $docs; + + return $this; + } + + /** + * + * @param int $ttl + * @return Feed_XML_RSS + */ + public function set_ttl($ttl) + { + $this->ttl = $ttl; + + return $this; + } + + /** + * + * @param Feed_XML_RSS_Image $image + * @return Feed_XML_RSS + */ + public function set_image(Feed_XML_RSS_Image $image) + { + $this->image = $image; + + return $this; + } + + /** + * + * @param string $skipHours + * @return Feed_XML_RSS + */ + public function set_skipHour($hour) + { + $this->skipHours[] = (int) $hour; + + return $this; + } + + /** + * + * @param string $skipDays + * @return Feed_XML_RSS + */ + public function set_skipDays($day) + { + $this->skipDays[] = $day; + + return $this; + } + + /** + * + * @return string + */ + public function render() + { + $doc = new DOMDocument('1.0', 'UTF-8'); + $doc->formatOutput = true; + $doc->standalone = true; + + + $root = $this->addTag($doc, $doc, 'rss'); + + $root->setAttribute('version', self::VERSION); + $root->setAttribute('xmlns:media', 'http://search.yahoo.com/mrss/'); + $root->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom'); + $root->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + + $channel = $this->addTag($doc, $root, 'channel'); + + $this->addTag($doc, $channel, 'title', $this->title); + $this->addTag($doc, $channel, 'dc:title', $this->title); + $this->addTag($doc, $channel, 'description', $this->subtitle); + if ($this->link instanceof Feed_Link) + $this->addTag($doc, $channel, 'link', $this->link->get_href()); + + if ($this->language) + $this->addTag($doc, $channel, 'language', $this->language); + if ($this->copyright) + $this->addTag($doc, $channel, 'copyright', $this->copyright); + if ($this->managingEditor) + $this->addTag($doc, $channel, 'managingEditor', $this->managingEditor); + if ($this->webMaster) + $this->addTag($doc, $channel, 'webMaster', $this->webMaster); + if ($this->updated_on instanceof DateTime) + { + $updated_on = $this->updated_on->format(DATE_RFC2822); + $this->addTag($doc, $channel, 'pubDate', $updated_on); + } + if ($this->lastBuildDate instanceof DateTime) + { + $last_build = $this->lastBuildDate->format(DATE_RFC2822); + $this->addTag($doc, $channel, 'lastBuildDate', $last_build); + } + if (count($this->categories) > 0) + { + foreach ($this->categories as $category) + { + $this->addTag($doc, $channel, 'category', $category); + } + } + if ($this->generator) + $this->addTag($doc, $channel, 'generator', $this->generator); + if ($this->docs) + $this->addTag($doc, $channel, 'docs', $this->docs); + if ($this->ttl) + $this->addTag($doc, $channel, 'ttl', $this->ttl); + if ($this->image instanceof Feed_XML_RSS_Image) + { + $image = $this->addTag($doc, $channel, 'image'); + $this->addTag($doc, $image, 'url', $this->image->get_url()); + $this->addTag($doc, $image, 'title', $this->image->get_title()); + $this->addTag($doc, $image, 'link', $this->image->get_link()); + if ($this->image->get_width()) + $this->addTag($doc, $image, 'width', $this->image->get_width()); + if ($this->image->get_height()) + $this->addTag($doc, $image, 'height', $this->image->get_height()); + if ($this->image->get_description()) + $this->addTag($doc, $image, 'description', $this->image->get_description()); + } + if (count($this->skipHours)) + { + $skipHours = $this->addTag($doc, $channel, 'skipHours'); + foreach ($this->skipHours as $hour) + { + $this->addTag($doc, $skipHours, 'hour', $hour); + } + } + if (count($this->skipDays) > 0) + { + $skipDays = $this->addTag($doc, $channel, 'skipDays'); + foreach ($this->skipDays as $day) + { + $this->addTag($doc, $skipDays, 'day', $day); + } + } + if ($this->link instanceof Feed_Link) + { + $self_link = $this->addTag($doc, $channel, 'atom:link'); + $self_link->setAttribute('rel', 'self'); + $self_link->setAttribute('href', $this->link->get_href()); + } + + $this->add_navigation($doc, $channel, true); + + foreach ($this->items as $item) + { + $this->add_item($doc, $channel, $item); + } + + return $doc->saveXML(); + } + + /** + * + * @param DOMDocument $document + * @param DOMNode $node + * @param Feed_Entry_Adapter $entry + * @return DOMElement + */ + protected function add_item(DOMDocument $document, DOMNode $node, Feed_Entry_Adapter $entry) + { + foreach ($entry->get_content() as $content) + { + $this->addContent($document, $node, $entry, $content); + } + + return; + } + + /** + * + * @param DOMDocument $document + * @param DOMNode $item + * @param Feed_Entry_Item $content + * @return Feed_XML_Interface + */ + protected function addContent(DOMDocument $document, DOMNode $node, Feed_Entry_Adapter $entry, Feed_Entry_Item $content) + { + + $preview_sd = $content->get_record()->get_subdef('preview'); + $preview_permalink = $preview_sd->get_permalink(); + $thumbnail_sd = $content->get_record()->get_thumbnail(); + $thumbnail_permalink = $thumbnail_sd->get_permalink(); + + $medium = strtolower($content->get_record()->get_type()); + + if (!in_array($medium, array('image', 'audio', 'video'))) + return $this; + + if (!$preview_permalink || !$thumbnail_permalink) + return $this; + + //add item node to channel node + $item = $this->addTag($document, $node, 'item'); + + $title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title); + if ($title_field) + { + $str_title = $title_field->get_value(true, ' '); + } + else + { + $str_title = $content->get_record()->get_title(); + } + + //attach tile node to item node + $title = $this->addTag($document, $item, 'title', $str_title); + + $desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description); + if ($desc_field) + { + $str_desc = $desc_field->get_value(true, ' '); + } + else + { + $str_desc = ''; + } + + //attach desc node to item node + $desc = $this->addTag($document, $item, 'description', $str_desc); + + $duration = $content->get_record()->get_duration(); + + if ($preview_permalink) + { + $preview = $this->addTag($document, $item, 'media:content'); + + $preview->setAttribute('url', $preview_permalink->get_url()); + $preview->setAttribute('fileSize', $preview_sd->get_size()); + $preview->setAttribute('type', $preview_sd->get_mime()); + $preview->setAttribute('medium', $medium); + $preview->setAttribute('expression', 'full'); + $preview->setAttribute('isDefault', 'true'); + + if ($preview_sd->get_width()) + $preview->setAttribute('width', $preview_sd->get_width()); + if ($preview_sd->get_height()) + $preview->setAttribute('height', $preview_sd->get_height()); + if ($duration) + $preview->setAttribute('duration', $duration); + } + + if ($thumbnail_permalink) + { + $thumbnail = $this->addTag($document, $item, 'media:thumbnail'); + + $thumbnail->setAttribute('url', $thumbnail_permalink->get_url()); + + if ($thumbnail_sd->get_width()) + $thumbnail->setAttribute('width', $thumbnail_sd->get_width()); + if ($thumbnail_sd->get_height()) + $thumbnail->setAttribute('height', $thumbnail_sd->get_height()); + + + $thumbnail = $this->addTag($document, $item, 'media:content'); + + $thumbnail->setAttribute('url', $thumbnail_permalink->get_url()); + $thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size()); + $thumbnail->setAttribute('type', $thumbnail_sd->get_mime()); + $thumbnail->setAttribute('medium', $medium); + $thumbnail->setAttribute('isDefault', 'false'); + + if ($thumbnail_sd->get_width()) + $thumbnail->setAttribute('width', $thumbnail_sd->get_width()); + if ($thumbnail_sd->get_height()) + $thumbnail->setAttribute('height', $thumbnail_sd->get_height()); + if ($duration) + $thumbnail->setAttribute('duration', $duration); + } + + return $this; + } + +} diff --git a/lib/classes/PHPShortener.class.php b/lib/classes/PHPShortener.class.php new file mode 100644 index 0000000000..d0d62c8e4d --- /dev/null +++ b/lib/classes/PHPShortener.class.php @@ -0,0 +1,3 @@ +is_authenticated()) return; - $user = User_Adapter::getInstance($this->get_usr_id(), $this->appbox); - $user->ACL()->delete_injected_rights(); + $this->storage()->reset(); $this->close_phrasea_session(); @@ -568,10 +567,12 @@ class Session_Handler return $this; } - $registry = $this->appbox->get_registry(); + $Core = bootstrap::getCore(); + + $registry = $Core->getRegistry(); $date_two_day = new DateTime('+' . (int) $registry->get('GV_validation_reminder') . ' days'); - $events_mngr = eventsmanager_broker::getInstance($this->appbox); + $events_mngr = eventsmanager_broker::getInstance($this->appbox, $Core); $sql = 'SELECT v.id as validate_id, v.usr_id, v.ssel_id , s.usr_id as owner, t.value diff --git a/lib/classes/Setup/Upgrade.class.php b/lib/classes/Setup/Upgrade.class.php index c8725b8a15..f656918ea2 100644 --- a/lib/classes/Setup/Upgrade.class.php +++ b/lib/classes/Setup/Upgrade.class.php @@ -179,7 +179,7 @@ class Setup_Upgrade */ public static function get_lock_file() { - return dirname(__FILE__) . '/../../../tmp/upgrade.lock'; + return __DIR__ . '/../../../tmp/upgrade.lock'; } /** diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 8061239e92..b573393be6 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -894,6 +894,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface return $this->is_template; } + public function get_template_owner() + { + return $this->template_owner; + } + public static function get_usr_id_from_email($email) { if(is_null($email)) @@ -1298,7 +1303,8 @@ class User_Adapter implements User_Interface, cache_cacheableInterface protected function load_notifications_preferences() { - $evt_mngr = eventsmanager_broker::getInstance($this->appbox); + $Core = bootstrap::getCore(); + $evt_mngr = eventsmanager_broker::getInstance($this->appbox, $Core); $notifications = $evt_mngr->list_notifications_available($this->id); foreach ($notifications as $notification_group => $nots) @@ -1401,7 +1407,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $lngs = array(); - $path = dirname(__FILE__) . "/../../../locale"; + $path = __DIR__ . "/../../../locale"; if ($hdir = opendir($path)) { while (false !== ($file = readdir($hdir))) @@ -1423,95 +1429,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface return $lngs; } - public static function detectLanguage(registryInterface $registry, $setLng = null) - { - $avLanguages = self::avLanguages(); - $sel = $askLng = $askLocale = ''; - - if ($setLng !== null) - { - $askLng = substr($setLng, 0, 2); - $askLocale = $setLng; - } - elseif (Session_Handler::isset_cookie('locale')) - { - $askLng = substr(Session_Handler::get_cookie('locale'), 0, 2); - $askLocale = Session_Handler::get_cookie('locale'); - } - elseif (strlen($registry->get('GV_default_lng')) > 2) - { - $askLng = substr($registry->get('GV_default_lng'), 0, 2); - $askLocale = $registry->get('GV_default_lng'); - } - - - if ($askLng != '' && isset($avLanguages[$askLng]) && isset($avLanguages[$askLng][$askLocale])) - { - $avLanguages[$askLng][$askLocale]['selected'] = true; - $sel = $askLocale; - } - - if ($sel === '' && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) - { - $languages = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']); - $found = false; - - foreach ($languages as $language) - { - $language = explode(',', strtolower($language)); - if (count($language) != 2) - continue; - - foreach ($language as $lang) - { - if (strpos($lang, '-') == 2 && strlen($lang) == 5) - { - $l = explode('-', $lang); - $l[0] = strtolower($l[0]); - $l[1] = strtoupper($l[1]); - - if ($sel != '') - { - $found = true; - break; - } - $lang = implode('_', $l); - if (isset($avLanguages[$l[0]])) - { - if (!isset($avLanguages[$l[0]][$lang])) - { - $lang = end(array_keys($avLanguages[$l[0]])); - } - $avLanguages[$l[0]][$lang]['selected'] = true; - $sel = $lang; - $found = true; - break; - } - } - } - if ($found) - break; - } - if (!$found && array_key_exists(substr($registry->get('GV_default_lng'), 0, 2), $avLanguages)) - { - $avLanguages[substr($registry->get('GV_default_lng'), 0, 2)][$registry->get('GV_default_lng')]['selected'] = true; - $sel = $registry->get('GV_default_lng'); - } - } - if ($sel == '') - { - $key = end(array_keys($avLanguages)); - $lang = end(array_keys($avLanguages[$key])); - $avLanguages[$key][$lang]['selected'] = true; - $sel = $lang; - } - Session_Handler::set_locale($sel); - - $sel = explode('_', $sel); - - return $avLanguages; - } - public static function get_wrong_email_users(appbox $appbox) { diff --git a/lib/classes/User/Interface.class.php b/lib/classes/User/Interface.class.php index d1eaac9c11..d44f1c7b60 100644 --- a/lib/classes/User/Interface.class.php +++ b/lib/classes/User/Interface.class.php @@ -147,8 +147,6 @@ interface User_Interface public static function avLanguages(); - public static function detectLanguage(registryInterface $registry, $setLng = null); - public function setPrefs($prop, $value); public function getPrefs($prop); diff --git a/lib/classes/User/Query.class.php b/lib/classes/User/Query.class.php index 16a73a413a..4794c485c2 100644 --- a/lib/classes/User/Query.class.php +++ b/lib/classes/User/Query.class.php @@ -88,6 +88,11 @@ class User_Query implements User_QueryInterface * @var boolean */ protected $include_templates = false; + /** + * + * @var boolean + */ + protected $only_templates = false; /** * * @var Array @@ -123,10 +128,10 @@ class User_Query implements User_QueryInterface const SORT_FIRSTNAME= 'usr_prenom'; const SORT_LASTNAME= 'usr_nom'; const SORT_COMPANY = 'societe'; - const SORT_LOGIN = 'login'; + const SORT_LOGIN = 'usr_login'; const SORT_EMAIL = 'usr_mail'; const SORT_ID = 'usr_id'; - const SORT_CREATIONDATE = 'creationdate'; + const SORT_CREATIONDATE = 'usr_creationdate'; const SORT_COUNTRY = 'pays'; const SORT_LASTMODEL = 'lastModel'; @@ -191,18 +196,22 @@ class User_Query implements User_QueryInterface $sql .= ' AND usr_login NOT LIKE "(#deleted_%" '; - if ($this->include_invite) + if (!$this->include_invite) { $sql .= ' AND usr.invite=0 '; } - if ($this->include_templates === false) + if ($this->only_templates === true) + { + $sql .= ' AND model_of = ' . $session->get_usr_id(); + } + elseif ($this->include_templates === false) { $sql .= ' AND model_of=0'; } else { - $sql .= ' AND (model_of=0 OR model_of= ' . $session->get_usr_id() . ' ) '; + $sql .= ' AND (model_of=0 OR model_of = ' . $session->get_usr_id() . ' ) '; } $baslist = array(); @@ -355,6 +364,17 @@ class User_Query implements User_QueryInterface return $this; } + /** + * + * @param boolean $boolean + * @return User_Query + */ + public function only_templates($boolean) + { + $this->only_templates = !!$boolean; + + return $this; + } /** * @@ -390,6 +410,8 @@ class User_Query implements User_QueryInterface case self::SORT_COMPANY: case self::SORT_LOGIN: case self::SORT_EMAIL: + $sorter[$k] = ' usr.`' . $sort . '` COLLATE utf8_unicode_ci '; + break; case self::SORT_ID: case self::SORT_CREATIONDATE: case self::SORT_COUNTRY: @@ -410,7 +432,7 @@ class User_Query implements User_QueryInterface $sorter[$k] .= ' ASC '; break; case self::ORD_DESC: - $sorter[$k] .= ' ASC '; + $sorter[$k] .= ' DESC '; break; } } diff --git a/lib/classes/appbox.class.php b/lib/classes/appbox.class.php index fe42b0516b..101571e9a0 100644 --- a/lib/classes/appbox.class.php +++ b/lib/classes/appbox.class.php @@ -74,7 +74,7 @@ class appbox extends base $this->registry = $registry; $this->session = Session_Handler::getInstance($this); - require dirname(__FILE__) . '/../../config/connexion.inc'; + require __DIR__ . '/../../config/connexion.inc'; $this->host = $hostname; $this->port = $port; @@ -371,15 +371,17 @@ class appbox extends base protected function post_upgrade(Setup_Upgrade &$upgrader) { + $Core = bootstrap::getCore(); + $upgrader->add_steps(1 + count($this->get_databoxes())); - $this->apply_patches($this->get_version(), GV_version, true, $upgrader); - $this->setVersion(GV_version); + $this->apply_patches($this->get_version(), $Core->getVersion()->getNumber(), true, $upgrader); + $this->setVersion($Core->getVersion()->getNumber()); $upgrader->add_steps_complete(1); foreach ($this->get_databoxes() as $databox) { - $databox->apply_patches($databox->get_version(), GV_version, true, $upgrader); - $databox->setVersion(GV_version); + $databox->apply_patches($databox->get_version(), $Core->getVersion()->getNumber(), true, $upgrader); + $databox->setVersion($Core->getVersion()->getNumber()); $upgrader->add_steps_complete(1); } @@ -407,7 +409,7 @@ class appbox extends base { $credentials['dbname'] = $dbname; } - $connexion = dirname(__FILE__) . "/../../config/connexion.inc"; + $connexion = __DIR__ . "/../../config/connexion.inc"; if (is_file($connexion)) unlink($connexion); @@ -420,7 +422,7 @@ class appbox extends base } if (!file_put_contents($connexion, $connexionINI, FILE_APPEND) !== false) - throw new Exception(sprintf(_('Impossible d\'ecrire dans le dossier %s'), dirname(dirname(__FILE__)) . "/config/")); + throw new Exception(sprintf(_('Impossible d\'ecrire dans le dossier %s'), dirname(__DIR__) . "/config/")); if (function_exists('chmod')) chmod($connexion, 0700); @@ -543,7 +545,7 @@ class appbox extends base public static function list_databox_templates() { $files = array(); - $dir = new DirectoryIterator(dirname(__FILE__) . '/../conf.d/data_templates/'); + $dir = new DirectoryIterator(__DIR__ . '/../conf.d/data_templates/'); foreach ($dir as $fileinfo) { if ($fileinfo->isFile()) diff --git a/lib/classes/base.class.php b/lib/classes/base.class.php index 2aaab24e52..c6ad4c2fca 100644 --- a/lib/classes/base.class.php +++ b/lib/classes/base.class.php @@ -257,9 +257,10 @@ abstract class base implements cache_cacheableInterface public function upgradeavailable() { + $Core = bootstrap::getCore(); if ($this->get_version()) - return version_compare(GV_version, $this->get_version(), '>'); + return version_compare($Core->getVersion()->getNumber(), $this->get_version(), '>'); else return true; @@ -267,7 +268,7 @@ abstract class base implements cache_cacheableInterface protected function upgradeDb($apply_patches, Setup_Upgrade &$upgrader) { - require_once dirname(__FILE__) . '/../version.inc'; + require_once __DIR__ . '/../version.inc'; $recommends = array(); @@ -338,10 +339,12 @@ abstract class base implements cache_cacheableInterface } $current_version = $this->get_version(); + $Core = bootstrap::getCore(); + $upgrader->set_current_message(sprintf(_('Applying patches on %s'), $this->get_dbname())); if ($apply_patches) { - $this->apply_patches($current_version, GV_version, false, $upgrader); + $this->apply_patches($current_version, $Core->getVersion()->getNumber(), false, $upgrader); } $upgrader->add_steps_complete(1); @@ -390,7 +393,7 @@ abstract class base implements cache_cacheableInterface return $this; - $structure = simplexml_load_file(dirname(__FILE__) . "/../../lib/conf.d/bases_structure.xml"); + $structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml"); if (!$structure) throw new Exception('Unable to load schema'); @@ -418,8 +421,8 @@ abstract class base implements cache_cacheableInterface $this->createTable($table); } - if (defined('GV_version')) - $this->setVersion(GV_version); + $Core = bootstrap::getCore(); + $this->setVersion($Core->getVersion()->getNumber()); return $this; } diff --git a/lib/classes/basket/adapter.class.php b/lib/classes/basket/adapter.class.php deleted file mode 100644 index c2a3d6f63b..0000000000 --- a/lib/classes/basket/adapter.class.php +++ /dev/null @@ -1,1876 +0,0 @@ -base_id; - } - - /** - * - * @return User_Adapter - */ - public function get_pusher() - { - return $this->pusher; - } - - /** - * - * @return DateTime - */ - public function get_create_date() - { - return $this->created_on; - } - - /** - * - * @return DateTime - */ - public function get_update_date() - { - return $this->updated_on; - } - - /** - * - * @return int - */ - public function get_record_id() - { - return $this->record_id; - } - - /** - * - * @return boolean - */ - public function is_mine() - { - return $this->is_mine; - } - - /** - * - * @return boolean - */ - public function is_grouping() - { - return $this->is_grouping; - } - - /** - * - * @return string - */ - public function get_name() - { - return $this->name; - } - - /** - * - * @return string - */ - public function get_description() - { - return $this->desc; - } - - /** - * - * @return int - */ - public function get_ssel_id() - { - return $this->ssel_id; - } - - /** - * - * @return array - */ - public function get_validating_users() - { - return $this->validating_users; - } - - /** - * - * @return basket_element_adapter - */ - public function get_elements() - { - if (!$this->elements) - $this->load_elements(); - - return $this->elements; - } - - /** - * - * @return int - */ - public function get_sbas_id() - { - return $this->sbas_id; - } - - /** - * - * @return boolean - */ - public function is_valid() - { - return in_array($this->valid, array('valid', 'myvalid')); - } - - /** - * - * @return boolean - */ - public function is_my_valid() - { - return $this->valid == 'myvalid'; - } - - /** - * - * @return boolean - */ - public function is_unread() - { - return $this->noview; - } - - /** - * - * @return basket_element_adapter - */ - public function get_first_element() - { - foreach ($this->get_elements() as $basket_element) - - return $basket_element; - return null; - } - - /** - * - * @return DateTime - */ - public function get_validation_end_date() - { - if (!$this->valid || !$this->validation_end_date) - - return null; - return $this->validation_end_date; - } - - /** - * - * @return boolean - */ - public function is_validation_finished() - { - if (!$this->valid || !$this->validation_end_date) - - return null; - $now = new DateTime(); - - return ($now > $this->validation_end_date); - } - - /** - * - * @return boolean - */ - public function is_confirmed() - { - if (!$this->valid) - - return null; - - return $this->validation_is_confirmed; - } - - public function is_releasable() - { - if (!$this->valid) - - return false; - - if ($this->is_confirmed()) - - return false; - - foreach($this->get_elements() as $element) - { - if($element->get_my_agreement() == '0') - - return false; - } - - return true; - } - - /** - * - * @param const $option - * @return string - */ - public function get_cache_key($option = null) - { - return 'basket_' . $this->usr_id . '_' . $this->ssel_id . ($option ? '_' . $option : ''); - } - - /** - * - * @param $option - * @return - */ - public function get_data_from_cache($option = null) - { - return $this->appbox->get_data_from_cache($this->get_cache_key($option)); - } - - /** - * - * @param $value - * @param $option - * @param $duration - * @return - */ - public function set_data_to_cache($value, $option = null, $duration = 0) - { - return $this->appbox->set_data_to_cache($value, $this->get_cache_key($option), $duration); - } - - /** - * - * @param $option - * @return - */ - public function delete_data_from_cache($option = null) - { - if ($option === self::CACHE_ELEMENTS) - $this->elements = null; - - return $this->appbox->delete_data_from_cache($this->get_cache_key($option)); - } - - /** - * - * @param appbox $appbox - * @param int $ssel_id - * @param int $usr_id - * @return basket_adapter - */ - protected function __construct(appbox &$appbox, $ssel_id, $usr_id) - { - $this->instance_key = 'basket_' . $usr_id . '_' . $ssel_id; - $this->appbox = $appbox; - $this->ssel_id = (int) $ssel_id; - $this->usr_id = $usr_id; - - $this->load(); - - if ($this->valid) - $this->load_validation_users(); - - return $this; - } - - protected function load() - { - - try - { - $datas = $this->get_data_from_cache(); - - $this->sbas_id = $datas['sbas_id']; - $this->record_id = $datas['record_id']; - $this->is_grouping = $datas['is_grouping']; - $this->pusher = $datas['pusher_id'] ? User_Adapter::getInstance($datas['pusher_id'], $this->appbox) : null; - $this->validation_is_confirmed = $datas['validation_is_confirmed']; - $this->validation_end_date = $datas['validation_end_date']; - $this->validation_see_others = $datas['validation_see_others']; - $this->valid = $datas['valid']; - $this->is_mine = $datas['is_mine']; - $this->noview = $datas['noview']; - $this->updated_on = $datas['updated_on']; - $this->created_on = $datas['created_on']; - $this->name = $datas['name']; - $this->desc = $datas['desc']; - - return $this; - } - catch (Exception $e) - { - - } - - $sql = 'SELECT s.pushFrom, n.id as noview, s.usr_id as owner, s.rid - , s.sbas_id, s.temporaryType, s.name, s.descript, s.pushFrom - , s.date, s.updater - , v.id as validate_id, v.can_see_others, v.expires_on, v.confirmed - FROM ssel s - LEFT JOIN validate v - ON (s.ssel_id = v.ssel_id AND v.usr_id = :validate_usr_id) - LEFT JOIN sselnew n - ON (n.usr_id = :receive_usr_id AND n.ssel_id = s.ssel_id) - WHERE s.ssel_id = :ssel_id - AND (s.usr_id = :usr_id OR v.id IS NOT NULL)'; - - $params = array( - ':usr_id' => $this->usr_id, - ':receive_usr_id' => $this->usr_id, - ':validate_usr_id' => $this->usr_id, - ':ssel_id' => $this->ssel_id - ); - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if (!$row) - throw new Exception_Basket_NotFound(); - - $this->name = $row['name']; - $this->desc = $row['descript']; - $this->created_on = new DateTime($row['date']); - $this->updated_on = new DateTime($row['updater']); - $this->usr_id = (int) $row['owner']; - $this->noview = !!$row['noview']; - - $this->is_mine = ($row['owner'] == $this->usr_id); - - if ($row['validate_id'] != null) - { - $this->valid = 'valid'; - if ($this->is_mine) - { - $this->valid = 'myvalid'; - $this->validation_see_others = true; - } - elseif ($row['can_see_others'] == '1') - { - $this->validation_see_others = true; - } - $this->validation_end_date = $row['expires_on'] ? new DateTime($row['expires_on']) : null; - $this->validation_is_confirmed = !!$row['confirmed']; - - $this->load_validation_users(); - } - - - if ((int) $row['pushFrom'] > 0) - { - try - { - $this->pusher = User_Adapter::getInstance($row['pushFrom'], $this->appbox); - } - catch (Exception $e) - { - - } - } - - $this->is_grouping = ($row['temporaryType'] == 1); - if ($this->is_grouping) - { - $this->record_id = $row['rid']; - $this->sbas_id = $row['sbas_id']; - } - - $pusher_id = $this->pusher instanceof User_Adapter ? $this->pusher->get_id() : null; - - $datas = array( - 'sbas_id' => $this->sbas_id - , 'record_id' => $this->record_id - , 'is_grouping' => $this->is_grouping - , 'pusher_id' => $pusher_id - , 'validation_is_confirmed' => $this->validation_is_confirmed - , 'validation_end_date' => $this->validation_end_date - , 'validation_see_others' => $this->validation_see_others - , 'valid' => $this->valid - , 'is_mine' => $this->is_mine - , 'noview' => $this->noview - , 'updated_on' => $this->updated_on - , 'created_on' => $this->created_on - , 'name' => $this->name - , 'desc' => $this->desc - ); - - $this->set_data_to_cache($datas); - - return $this; - } - - /** - * - * @param $order - * @return basket_adapter - */ - public function sort($order) - { - if (!$this->valid || !in_array($order, array('asc', 'desc'))) - - return; - - $this->load_elements(); - - if ($order == 'asc') - uasort($this->elements, array('basket_adapter', 'order_validation_asc')); - else - uasort($this->elements, array('basket_adapter', 'order_validation_desc')); - - return $this; - } - - /** - * - * @todo change this shit - * @param mixed $lst - * @param boolean $fixing - * @return array - */ - public function push_list($lst, $fixing) - { - $ret = array('error' => false, 'datas' => array()); - - if (!is_array($lst)) - $lst = explode(';', $lst); - - foreach ($lst as $basrec) - { - try - { - if (!is_array($basrec)) - $basrec = explode('_', $basrec); - if (count($basrec) != 2) - continue; - $sbas_id = $basrec[0]; - $record = new record_adapter($sbas_id, $basrec[1]); - $push = $this->push_element($record, $this->record_id, $fixing); - unset($record); - if ($push['error']) - $ret['error'] = $push['error']; - else - $ret['datas'] = array_merge($ret['datas'], $push['datas']); - } - catch (Exception_Record_AdapterNotFound $e) - { - - } - catch (Exception $e) - { - $ret['error'] = "an error occured"; - } - } - - return $ret; - } - - /** - * - * @param record_Interface $record - * @param int $parent_record_id - * @param boolean $fixing - * @return array - */ - public function push_element(record_Interface $record, $parent_record_id, $fixing) - { - $base_id = $record->get_base_id(); - $record_id = $record->get_record_id(); - if ($parent_record_id === true && phrasea::sbasFromBas($base_id) != $this->sbas_id) - { - return array( - 'error' => _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre'), - 'datas' => array() - ); - } - - if ($this->valid && !$this->is_mine) - { - return array('error' => _('Ce panier est en lecture seule'), 'datas' => array()); - } - - try - { - $sselcont_id = basket_element_adapter::create($this, $base_id, $record_id, $parent_record_id, $this->valid, $fixing); - - $this->add_element($sselcont_id); - - $this->delete_data_from_cache(self::CACHE_ELEMENTS); - - $ret['error'] = false; - $ret['datas'] = array($sselcont_id->get_sselcont_id()); - } - catch (Exception $e) - { - $ret['error'] = $e->getMessage(); - $ret['datas'] = array(); - } - - return $ret; - } - - /** - * - * @return string - */ - public function get_excerpt() - { - $ret = ''; - - $i = 0; - - foreach ($this->get_elements() as $basket_element) - { - $i++; - if ($i > 9) - break; - - $thumbnail = $basket_element->get_record()->get_thumbnail(); - - $ratio = $thumbnail->get_width() / $thumbnail->get_height(); - $top = $left = 0; - if ($thumbnail->get_width() > $thumbnail->get_height())//paysage - { - $h = 80; - $w = $h * $ratio; - $left = round((80 - $w) / 2); - } - else - { - $w = 80; - $h = $w / $ratio; - $top = round((80 - $h) / 2); - } - $ret .= '
- -
'; - } - - return $ret; - } - - /** - * - * Return the total HD size of documents inside the basket - * @return - */ - public function get_size() - { - $totSize = 0; - $session = $this->appbox->get_session(); - - foreach ($this->get_elements() as $basket_element) - { - try - { - $sd = $basket_element->get_record()->get_subdef('document'); - $totSize += $sd->get_size(); - } - catch (Exception $e) - { - - } - } - - $totSize = round($totSize / (1024 * 1024), 2); - - return $totSize; - } - - /** - * - * @return - */ - public function getOrderDatas() - { - $out = ''; - $n = 0; - - foreach ($this->get_elements() as $basket_element) - { - $thumbnail = $basket_element->get_record()->get_thumbnail(); - if ($thumbnail->get_width() > $thumbnail->get_height()) - { - $h = (int) (82 * $thumbnail->get_height() / $thumbnail->get_width()); - $w = 82; - } - else - { - $w = (int) (82 * $thumbnail->get_width() / $thumbnail->get_height()); - $h = 82; - } - - $title = $basket_element->get_record()->get_title(); - $record = $basket_element->get_record(); - - $out .= '
' . - '
- ' . $title . '
' . - ''; - $out .= '
- '; - - $out .= ''; - - $out .= ' - - -
'; - $out .= '
'; - - $n++; - } - - return $out . '
- -
'; - } - - /** - * Save re-ordered basket - * @param Json serialized array - * @return Json serialized array - */ - public function saveOrderDatas($value) - { - $conn = connection::getPDOConnection(); - - $conn->beginTransaction(); - - $error = false; - - $value = json_decode($value); - - $rid_parent = (int) $this->record_id; - $ssel_id = (int) $this->ssel_id; - $sbas_id = (int) $this->sbas_id; - - $cacheusers = array(); - $sselcont_equiv = array(); - - - if ($this->is_grouping) - { - $sql = 'SELECT c1.sselcont_id, s.usr_id, s.ssel_id, c2.sselcont_id as equiv FROM sselcont c1, sselcont c2, ssel s - WHERE temporaryType="1" AND s.rid = :record_id AND s.sbas_id = :sbas_id - AND s.ssel_id = c1.ssel_id AND s.ssel_id != :ssel_id_dif AND c1.base_id = c2.base_id - AND c1.record_id = c2.record_id AND c2.ssel_id = :ssel_id'; - - $params = array( - ':record_id' => $this->get_record_id() - , ':sbas_id' => $this->get_sbas_id() - , ':ssel_id_dif' => $this->get_ssel_id() - , ':ssel_id' => $ssel_id - ); - - $stmt = $conn->prepare($sql); - $stmt->execute($params); - $row = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - if (!isset($cacheusers[$row['usr_id']])) - $cacheusers[$row['usr_id']] = array(); - - $cacheusers[$row['usr_id']][$row['ssel_id']] = $row['ssel_id']; - - $sselcont_equiv[$row['equiv']][] = $row['sselcont_id']; - } - } - - foreach ($value as $id => $infos) - { - $infos->order = trim($infos->order); - $infos->record_id = (int) $infos->record_id; - $id = trim($id); - - if ($this->is_grouping) - { - try - { - $connbas = connection::getPDOConnection($sbas_id); - - $sql = 'UPDATE regroup SET ord = :ordre - WHERE rid_parent = :record_id_parent - AND rid_child = :record_id'; - - $params = array( - ':ordre' => $infos->order - , ':record_id_parent' => $rid_parent - , ':record_id' => $infos->record_id - ); - - $stmt = $connbas->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - - if (isset($sselcont_equiv[trim($id)])) - { - try - { - $sql = "UPDATE sselcont SET ord = :ordre'' - WHERE sselcont_id IN (" . implode(', ', $sselcont_equiv[$id]) . ")"; - $stmt = $conn->prepare($sql); - $stmt->execute(array(':ordre' => $infos->order)); - $stmt->closeCursor(); - } - catch (Exception $e) - { - - } - } - } - catch (Exception $e) - { - $error = true; - } - } - - try - { - $sql = "UPDATE sselcont SET ord = :ordre - WHERE sselcont_id = :sselcont_id AND ssel_id = :ssel_id"; - - $params = array( - ':ordre' => $infos->order - , ':sselcont_id' => $id - , ':ssel_id' => $ssel_id - ); - $stmt = $conn->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - } - catch (Exception $e) - { - $error = true; - } - } - - foreach ($cacheusers as $usr_id => $ssel_ids) - { - foreach ($ssel_ids as $ssel_id) - { - $basket_usr = self::getInstance($this->appbox, $ssel_id, $usr_id); - $basket_usr->set_unread(); - } - } - - if (!$error) - { - $conn->commit(); - } - else - { - $conn->rollBack(); - } - $this->delete_cache(); - - $ret = array('error' => $error); - - return p4string::jsonencode($ret); - } - - /** - * Delete the basket - * @return boolean - */ - public function delete() - { - $sql = 'DELETE FROM ssel WHERE ssel_id = :ssel_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->ssel_id)); - $stmt->closeCursor(); - - $sql = 'DELETE FROM sselcont WHERE ssel_id = :ssel_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->ssel_id)); - $stmt->closeCursor(); - - $sql = 'DELETE FROM sselnew WHERE ssel_id = :ssel_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->ssel_id)); - $stmt->closeCursor(); - - $this->delete_cache(); - unset(self::$_instance[$this->instance_key]); - - return false; - } - - /** - * Set the basket unread for the user - * @return boolean - */ - public function set_unread($usr_id = null) - { - if (is_null($usr_id)) - $usr_id = $this->usr_id; - - try - { - $sql = 'INSERT INTO sselnew (id, ssel_id, usr_id) - VALUES (null, :ssel_id, :usr_id)'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->ssel_id, ':usr_id' => $usr_id)); - $stmt->closeCursor(); - - $this->noview = true; - } - catch (Exception $e) - { - return false; - } - $this->delete_cache(); - - return true; - } - - /** - * Set the basket read for the user - * @return boolean - */ - public function set_read() - { - if (!$this->noview) - - return true; - $session = $this->appbox->get_session(); - - try - { - $sql = 'DELETE FROM sselnew WHERE ssel_id = :ssel_id AND usr_id = :usr_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->ssel_id, ':usr_id' => $session->get_usr_id())); - $stmt->closeCursor(); - - $this->noview = false; - } - catch (Exception $e) - { - return false; - } - $this->delete_cache(); - - return true; - } - - /** - * Add users to the validation process - * - * @param Integer $usr_id - * @param boolean $can_agree - * @param boolean $can_see_others - * @param boolean $can_hd - * @param DateTime $expire - */ - public function validation_to_users(User_Adapter $user, $can_agree, $can_see_others, $can_hd, DateTime $expire = null) - { - try - { - $sql = 'REPLACE INTO validate (id, ssel_id, created_on, updated_on, expires_on, - last_reminder, usr_id, confirmed, can_agree, can_see_others) - VALUES - (null, :ssel_id, NOW(), NOW(), :expire, - null, :usr_id, 0, :can_agree, :can_see_others)'; - - $stmt = $this->appbox->get_connection()->prepare($sql); - - $params = array( - ':ssel_id' => $this->ssel_id - , ':expire' => (is_null($expire) ? null : $expire->format(DATE_ISO8601)) - , ':usr_id' => $user->get_id() - , ':can_agree' => ($can_agree ? '1' : '0') - , ':can_see_others' => ($can_see_others ? '1' : '0') - ); - - $stmt->execute($params); - $insert_id = $this->appbox->get_connection()->lastInsertId(); - $stmt->closeCursor(); - - $me = User_Adapter::getInstance($this->appbox->get_session()->get_usr_id(), $this->appbox); - - foreach ($this->get_elements() as $basket_element) - { - $basket_element->validate($me, $user, $insert_id, $can_hd); - } - - $this->valid = 'myvalid'; - - $this->set_unread($user->get_id()); - $this->delete_data_from_cache(self::CACHE_VALIDATING_USERS); - } - catch (Exception $e) - { - return false; - } - - $this->delete_cache(); - - return true; - } - - /** - * - * @return string - */ - public function get_validation_infos() - { - if ($this->is_mine) - { - if ($this->is_validation_finished()) - - return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); - else - - return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); - } - else - { - if ($this->validation_see_others) - - return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1)); - else - - return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name()); - } - } - - /** - * - * @return basket_adapter - */ - public function set_released() - { - if(!$this->is_valid()) - throw new Exception('Not a validation basket'); - - $session = $this->appbox->get_session(); - - $sql = 'UPDATE validate SET confirmed="1" - WHERE ssel_id = :ssel_id AND usr_id = :usr_id'; - - $params = array( - ':ssel_id' => $this->get_ssel_id() - , ':usr_id' => $session->get_usr_id() - ); - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - $evt_mngr = eventsmanager_broker::getInstance($this->appbox); - - $sql = 'SELECT s.usr_id FROM validate v, ssel s - WHERE s.ssel_id = v.ssel_id - AND v.usr_id = :usr_id AND v.ssel_id = :ssel_id'; - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($row) - { - $to = $row['usr_id']; - $params = array( - 'ssel_id' => $this->ssel_id, - 'from' => $session->get_usr_id(), - 'to' => $to - ); - $evt_mngr->trigger('__VALIDATION_DONE__', $params); - } - - return $this; - } - - /** - * - * @param appbox $appbox - * @param $ssel_id - * @param $usr_id - * @return basket_adapter - */ - public static function getInstance(appbox &$appbox, $ssel_id, $usr_id) - { - $instance_key = 'basket_' . $usr_id . '_' . $ssel_id; - if (!isset(self::$_instance[$instance_key])) - { - self::$_instance[$instance_key] = new self($appbox, $ssel_id, $usr_id); - } - - return array_key_exists($instance_key, self::$_instance) ? self::$_instance[$instance_key] : false; - } - - /** - * @todo ameliorer les tests connbas - * @return basket_adapter - */ - protected function load_elements() - { - if (!is_null($this->elements)) - - return; - - $this->elements = array(); - - $user = User_Adapter::getInstance($this->usr_id, $this->appbox); - - $rs = array(); - - try - { - $rs = $this->get_data_from_cache(self::CACHE_ELEMENTS); - } - catch (Exception $e) - { - - try - { - $sql = 'SELECT sselcont_id FROM sselcont WHERE ssel_id = :ssel_id ORDER BY ord ASC'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->ssel_id)); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $this->set_data_to_cache($rs, self::CACHE_ELEMENTS); - $stmt->closeCursor(); - } - catch (Exception $e) - { - - } - } - - foreach ($rs as $row) - { - try - { - $this->add_element(basket_element_adapter::getInstance($row['sselcont_id'])); - } - catch (Exception $e) - { - /** - * @todo - * manage case where record has been deleted and not removed from basket - */ - } - } - - return $this; - } - - public function set_name($name) - { - $sql = 'UPDATE ssel SET name = :name WHERE ssel_id = :ssel_id'; - - $name = trim(strip_tags($name)); - if ($name === '') - throw new Exception_InvalidArgument (); - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':name' => $name, ':ssel_id' => $this->get_ssel_id())); - $stmt->closeCursor(); - - $this->name = $name; - - $this->delete_data_from_cache(); - - return $this; - } - - public function set_description($desc) - { - - $sql = 'UPDATE ssel SET descript = :description WHERE ssel_id = :ssel_id'; - - $desc = trim(strip_tags($desc)); - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':description' => $desc, ':ssel_id' => $this->get_ssel_id())); - $stmt->closeCursor(); - - $this->desc = $desc; - - $this->delete_data_from_cache(); - - return $this; - } - - /** - * Add an element to the basket - * - * @param basket_element_adapter $basket_element - * @return basket_adapter - */ - protected function add_element(basket_element_adapter &$basket_element) - { - $this->elements[$basket_element->get_sselcont_id()] = $basket_element; - $this->elements[$basket_element->get_sselcont_id()]->set_order(count($this->elements) + 1); - - return $this; - } - - /** - * - * @param $sselcont_id - * @return - */ - protected function remove_basket_elements($sselcont_id) - { - try - { - $sql = 'DELETE FROM sselcont - WHERE sselcont_id = :sselcont_id AND ssel_id = :ssel_id'; - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':sselcont_id' => $sselcont_id, ':ssel_id' => $this->ssel_id)); - - $sql = 'DELETE FROM validate_datas WHERE sselcont_id = :sselcont_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':sselcont_id' => $sselcont_id)); - - $this->delete_data_from_cache(self::CACHE_ELEMENTS); - - return array('error' => false, 'status' => 1); - } - catch (Exception $e) - { - - } - - return array('error' => true, 'status' => 0); - } - - /** - * - * @param $sselcont_id - * @return - */ - protected function remove_grouping_elements($sselcont_id) - { - $session = $this->appbox->get_session(); - - $sbas_id = $parent_record_id = $collid = $base_id = $record_id = null; - - $ssel_id = $this->ssel_id; - - try - { - $sql = 'SELECT s.sbas_id, s.ssel_id, s.rid, c.record_id, c.base_id - FROM ssel s, sselcont c - WHERE c.sselcont_id = :sselcont_id - AND c.ssel_id = s.ssel_id AND s.ssel_id = :ssel_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':sselcont_id' => $sselcont_id, ':ssel_id' => $this->ssel_id)); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($row) - { - $parent_record_id = $row["rid"]; - $base_id = $row['base_id']; - $sbas_id = $row['sbas_id']; - $record_id = $row['record_id']; - } - } - catch (Exception $e) - { - - } - - $ret = array('error' => false, 'status' => 0); - - try - { - $user = User_Adapter::getInstance($session->get_usr_id(), $this->appbox); - - if (!$user->ACL()->has_right_on_base($base_id, 'canmodifrecord')) - throw new Exception('Not enough rights'); - $connbas = connection::getPDOConnection($sbas_id); - - $sql = "DELETE FROM regroup WHERE rid_parent = :parent_record_id - AND rid_child = :record_id"; - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':parent_record_id' => $parent_record_id, ':record_id' => $record_id)); - $stmt->closeCursor(); - - $sql = 'SELECT sselcont_id, s.ssel_id, s.usr_id FROM ssel s, sselcont c - WHERE s.rid = :parent_record_id AND s.sbas_id = :sbas_id - AND temporaryType="1" AND c.ssel_id = s.ssel_id - AND c.base_id = :base_id AND c.record_id = :record_id'; - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute( - array( - ':parent_record_id' => $parent_record_id - , ':sbas_id' => $sbas_id - , ':base_id' => $base_id - , ':record_id' => $record_id - ) - ); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - $first = true; - $good = false; - - foreach ($rs as $row) - { - $sql = 'DELETE FROM sselcont WHERE sselcont_id = :sselcont_id'; - $stmt = $this->appbox->get_connection()->prepare($sql); - if ($first) - $good = true; - $first = false; - try - { - $stmt->execute(array(':sselcont_id' => $row['sselcont_id'])); - - $basket_usr = self::getInstance($this->appbox, $row['ssel_id'], $row['usr_id']); - $basket_usr->set_unread(); - $stmt->closeCursor(); - } - catch (Exception $e) - { - $good = false; - } - } - - if (!$good) - $ret = array('error' => _('panier:: erreur lors de la suppression'), 'status' => 0); - else - $ret = array('error' => false, 'status' => 1); - $this->delete_data_from_cache(self::CACHE_ELEMENTS); - } - catch (Exception $e) - { - - $ret = array( - 'error' => _('phraseanet :: droits insuffisants, vous devez avoir les doits d\'edition sur le regroupement '), - 'status' => 0); - } - - return $ret; - } - - /** - * Flattent a basket - * Remove groupings from the basket and and their contents - * - * @return basket_adapter - */ - public function flatten() - { - foreach ($this->get_elements() as $basket_element) - { - $record = $basket_element->get_record(); - if ($record->is_grouping()) - { - $lst = array(); - foreach ($record->get_children() as $tmp_record) - { - $lst[] = sprintf("%s_%s", $tmp_record->get_base_id(), $tmp_record->get_record_id()); - } - - $this->push_list($lst, true); - $this->remove_from_ssel($basket_element); - } - unset($record); - } - - return $this; - } - - /** - * - * @param $sselcont_id - * @return - */ - public function remove_from_ssel($sselcont_id) - { - if (!$this->is_mine) - - return array('error' => 'error', 'status' => 0); - - if ($this->is_grouping) - - return $this->remove_grouping_elements($sselcont_id); - else - - return $this->remove_basket_elements($sselcont_id); - } - - /** - * - * @return basket_adapter - */ - public function delete_cache() - { - $keys = array(); - - if ($this->is_valid()) - { - foreach ($this->get_validating_users() as $user_data) - { - $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id(); - $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id().'_'.self::CACHE_ELEMENTS; - $keys[] = 'basket_' . $user_data['usr_id'] . '_' . $this->get_ssel_id().'_'.self::CACHE_VALIDATING_USERS; - } - } - - $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id(); - $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id().'_'.self::CACHE_ELEMENTS; - $keys[] = 'basket_' . $this->usr_id . '_' . $this->get_ssel_id().'_'.self::CACHE_VALIDATING_USERS; - - $this->appbox->delete_data_from_cache($keys); - - return $this; - } - - /** - * - * @param $lst - * @return - */ - public static function fix_grouping($lst) - { - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); - $usr_id = $session->get_usr_id(); - $registry = $appbox->get_registry(); - - $retour = array(); - - if (!is_array($lst)) - $lst = explode(";", $lst); - - foreach ($lst as $basrec) - { - $basrec = explode('_', $basrec); - $record_id = (int) $basrec[1]; - $sbas_id = (int) $basrec[0]; - - $record = new record_adapter($sbas_id, $record_id); - $base_id = $record->get_base_id(); - - $regfield = self::getRegFields($sbas_id, $record->get_caption()); - $connbas = connection::getPDOConnection($sbas_id); - - $sql = 'SELECT moddate FROM record WHERE record_id = :record_id'; - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record_id)); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - $moddate = $row ? $row['moddate'] : ''; - - $sql = 'SELECT ssel_id FROM ssel - WHERE usr_id = :usr_id - AND temporaryType=1 AND rid = :record_id AND sbas_id = :base_id'; - - $params = array( - ':usr_id' => $usr_id - , ':record_id' => $record_id - , ':base_id' => $record->get_sbas_id() - ); - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if (!$row) - { - $sql = 'INSERT INTO ssel (ssel_id, usr_id, date,temporaryType , rid , sbas_id, updater,name,descript ) - VALUES (null, :usr_id, :date, "1" , :record_id ,:sbas_id, :moddate, :name, :desc )'; - - $params = array( - ':usr_id' => $usr_id - , ':date' => $regfield['regdate'] - , ':record_id' => $record_id - , ':sbas_id' => $sbas_id - , ':moddate' => $moddate - , ':name' => $regfield['regname'] - , ':desc' => $regfield['regdesc'] - ); - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - $id = $appbox->get_connection()->lastInsertId(); - $basket = self::getInstance($appbox, $id, $usr_id); - - $lst = $record->get_children(); - $lst = $lst->serialize_list(); - $basket->push_list($lst, true); - $retour[] = $id; - } - else - { - $retour[] = $row['ssel_id']; - } - } - - return p4string::jsonencode($retour); - } - - /** - * - * @param $sselid - * @return boolean - */ - public static function unfix_grouping($sselid) - { - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); - - try - { - $appbox->get_connection()->beginTransaction(); - $sql = 'DELETE FROM ssel WHERE ssel_id = :ssel_id AND usr_id = :usr_id'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $sselid, ':usr_id' => $session->get_usr_id())); - $stmt->closeCursor(); - - $sql = 'DELETE FROM sselcont WHERE ssel_id = :ssel_id'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $sselid)); - $stmt->closeCursor(); - $ret = true; - $appbox->get_connection()->commit(); - } - catch (Exception $e) - { - $appbox->get_connection()->rollBack(); - $ret = false; - } - - return $ret; - } - - /** - * - * @param appbox $appbox - * @param $name - * @param User_Interface $user - * @param $desc - * @param User_Adapter $pusher - * @param $base_id - * @return - */ - public static function create(appbox $appbox, $name, User_Interface $user, $desc = '', User_Adapter $pusher=null, $base_id = null) - { - $conn = $appbox->get_connection(); - - $record = false; - - $desc = trim(strip_tags(str_replace('
', "\n", $desc))); - $name = trim(strip_tags($name)); - - - if ($base_id) - { - $databox = $appbox->get_databox(phrasea::sbasFromBas($base_id)); - $meta_struct = $databox->get_meta_structure(); - - try - { - if (!$user->ACL()->has_right_on_base($base_id, 'canaddrecord')) - throw new Exception('No rights'); - - $ret = FALSE; - - $registry = $appbox->get_registry(); - $collection = collection::get_from_base_id($base_id); - - $record = record_adapter::create( - $collection - , new system_file($registry->get('GV_RootPath') . 'www/skins/icons/substitution/regroup_doc.png') - , false - , true - ); - - - $record_id = $record->get_record_id(); - - $metadatas = array(); - - foreach ($meta_struct as $meta) - { - if ($meta->is_regname()) - $value = $name; - elseif ($meta->is_regdesc()) - $value = $desc; - else - continue; - - $metadatas[] = array( - 'meta_struct_id' => $meta->get_id() - , 'meta_id' => null - , 'value' => array($value) - ); - } - - $record->set_metadatas($metadatas) - ->rebuild_subdefs(); - - $ret = true; - } - catch (Exception $e) - { - $ret = false; - } - } - - $sql = 'INSERT INTO ssel (ssel_id, name, descript, usr_id, pushFrom, date, updater, temporaryType, rid, sbas_id) - VALUES (null, :name, :description, :usr_id, :pushFrom, NOW(), NOW(), :temporaryType, :record_id, :sbas_id)'; - - $stmt = $conn->prepare($sql); - - $params = array( - ':name' => $name - , ':usr_id' => $user->get_id() - , ':description' => $desc - , ':pushFrom' => ($pusher instanceof User_Interface ? $pusher->get_id() : '0') - , ':temporaryType' => ($record instanceof record_adapter ? '1' : '0') - , ':record_id' => ($record instanceof record_adapter ? $record->get_record_id() : '0') - , ':sbas_id' => ($record instanceof record_adapter ? $record->get_sbas_id() : '0') - ); - - if (!$stmt->execute($params)) - { - throw new Exception('Error while creating basket'); - } - $ssel_id = $conn->lastInsertId(); - - return self::getInstance($appbox, $ssel_id, $user->get_id()); - } - - /** - * Revoke cache when user documents have their collection changed or status - * - do not cache datas which are now forbidden - * - * @param $usr_id - * @return boolean - */ - public static function revoke_baskets_record(record_adapter &$record, appbox &$appbox) - { - $keys = array(); - - $sql = 'SELECT s.ssel_id, s.usr_id FROM ssel s, sselcont c - WHERE base_id = "' . $record->get_base_id() . '" - AND record_id="' . $record->get_record_id() . '" - AND c.ssel_id = s.ssel_id'; - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - $keys[] = 'basket_' . $row['usr_id'] . '_' . $row['ssel_id']; - } - - return $appbox->delete_data_from_cache($keys); - } - - /** - * - * @param User_Interface $user - * @return - */ - public static function revoke_baskets_usr(User_Interface $user) - { - $ssel_ids = array(); - $appbox = appbox::get_instance(); - try - { - $sql = 'SELECT distinct s.ssel_id FROM ssel s, validate v - WHERE s.usr_id=:usr_id - OR (v.usr_id=:other_usr_id AND v.ssel_id = s.ssel_id)'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id(), ':other_usr_id' => $user->get_id())); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - foreach ($rs as $row) - { - $ssel_ids[] = 'basket_' . $user->get_id() . '_' . $row['ssel_id']; - } - } - catch (Exception $e) - { - - } - - return $appbox->delete_data_from_cache($ssel_ids); - } - - /** - * Load users in current validation process - * @return void - */ - protected function load_validation_users() - { - try - { - $datas = $this->get_data_from_cache(self::CACHE_VALIDATING_USERS); - $this->validating_users = $datas; - - foreach ($this->validating_users as $row) - { - $user = User_Adapter::getInstance($row['usr_id'], $this->appbox); - $name = $user->get_display_name(); - $this->validating_users[$row['usr_id']]['usr_name'] = $name; - } - - return $this; - } - catch (Exception $e) - { - - } - - $sql = 'SELECT id, usr_id, confirmed, can_agree, can_see_others - FROM validate WHERE ssel_id = :ssel_id'; - - $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $this->get_ssel_id())); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - $this->validating_users[$row['usr_id']] = array( - 'usr_id' => $row['usr_id'], - 'usr_name' => User_Adapter::getInstance($row['usr_id'], $this->appbox)->get_display_name(), - 'confirmed' => $row['confirmed'], - 'can_agree' => $row['can_agree'], - 'can_see_others' => $row['can_see_others'] - ); - } - - $this->set_data_to_cache($this->validating_users, self::CACHE_VALIDATING_USERS); - - return $this; - } - - /** - * - * @param $a - * @param $b - * @return - */ - protected function order_validation_asc($a, $b) - { - if (is_null($a->get_avrDisAgree()) || is_null($b->get_avrDisAgree())) - { - return 0; - } - $comp = $a->get_avrDisAgree() - $b->get_avrDisAgree(); - - if ($comp == 0) - { - $comp = $b->get_avrAgree() - $a->get_avrAgree(); - if ($comp == 0) - { - return 0; - } - } - - return $comp > 0 ? -1 : 1; - } - - /** - * - * @param $a - * @param $b - * @return - */ - protected function order_validation_desc($a, $b) - { - if (is_null($a->get_avrAgree()) || is_null($b->get_avrAgree())) - { - return 0; - } - $comp = $a->get_avrAgree() - $b->get_avrAgree(); - - if ($comp == 0) - { - $comp = $b->get_avrDisAgree() - $a->get_avrDisAgree(); - if ($comp == 0) - { - return 0; - } - } - - return $comp > 0 ? -1 : 1; - } - -} diff --git a/lib/classes/basket/element/adapter.class.php b/lib/classes/basket/element/adapter.class.php deleted file mode 100644 index 67ab3a32ca..0000000000 --- a/lib/classes/basket/element/adapter.class.php +++ /dev/null @@ -1,831 +0,0 @@ -get_session(); - $this->usr_id = $session->get_usr_id(); - $this->sselcont_id = (int) $sselcont_id; - - $this->load(); - - return $this; - } - - protected function load() - { - - try - { - $datas = $this->get_data_from_cache(); - - $this->ssel_id = $datas['ssel_id']; - $this->order = $datas['order']; - $this->record = new record_adapter($datas['sbas_id'], $datas['record_id'], $this->order); - $this->avrDisAgree = $datas['avrDisAgree']; - $this->avrAgree = $datas['avrAgree']; - $this->is_validation_item = $datas['is_validation_item']; - $this->my_agreement = $datas['my_agreement']; - $this->my_note = $datas['my_note']; - $this->validate_id = $datas['validate_id']; - $this->choices = $datas['choices']; - $this->avrAgree = $datas['avrAgree']; - $this->avrDisAgree = $datas['avrDisAgree']; - - return $this; - } - catch (Exception $e) - { - - } - - $sql = 'SELECT s.usr_id as owner, v.id as validate_id, v.can_see_others, - c.base_id, c.record_id, c.ord, c.ssel_id, v.usr_id, - d.agreement, d.note, d.updated_on - FROM (sselcont c, ssel s) - LEFT JOIN (validate v, validate_datas d) - ON (d.sselcont_id = c.sselcont_id AND d.validate_id = v.id ) - WHERE s.ssel_id = c.ssel_id - AND c.sselcont_id = :sselcont_id'; - - try - { - $conn = connection::getPDOConnection(); - $stmt = $conn->prepare($sql); - $stmt->execute(array(':sselcont_id' => $this->sselcont_id)); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - } - catch (Exception $e) - { - - } - - $first = true; - - - foreach ($rs as $row) - { - if ($row['validate_id']) - { - $this->is_validation_item = true; - - if ($row['owner'] == $this->usr_id) - $see_others = true; - else - $see_others = ($row['can_see_others'] == '1'); - - if (!$see_others) - { - if ($row['usr_id'] != $this->usr_id) - continue; - } - } - - if ($first) - { - $sbas_id = (int) phrasea::sbasFromBas($row['base_id']); - $record_id = (int) $row['record_id']; - $this->ssel_id = (int) $row['ssel_id']; - $this->order = $number = (int) $row['ord']; - - $this->record = new record_adapter($sbas_id, $record_id, $number); - - if ($this->is_validation_item) - { - $this->choices = array(); - $this->avrAgree = 0; - $this->avrDisAgree = 0; - } - - $first = false; - } - - if ($this->is_validation_item) - { - if ($row['usr_id'] == $this->usr_id) - { - $this->my_agreement = (int) $row['agreement']; - $this->my_note = $row['note']; - $this->validate_id = (int) $row['validate_id']; - } - $this->choices[$row['usr_id']] = array( - 'usr_id' => $row['usr_id'], - 'usr_name' => User_Adapter::getInstance($row['usr_id'], appbox::get_instance())->get_display_name(), - 'is_mine' => ($row['usr_id'] == $this->usr_id), - 'agreement' => $row['agreement'], - 'updated_on' => $row['updated_on'], - 'note' => $row['note'] - ); - $this->avrAgree += $row["agreement"] > 0 ? 1 : 0; - $this->avrDisAgree += $row["agreement"] < 0 ? 1 : 0; - } - } - - $datas = array( - 'ssel_id' => $this->ssel_id - , 'sbas_id' => (int) $sbas_id - , 'record_id' => $record_id - , 'order' => $this->order - , 'is_validation_item' => $this->is_validation_item - , 'my_agreement' => $this->my_agreement - , 'my_note' => $this->my_note - , 'validate_id' => $this->validate_id - , 'choices' => $this->choices - , 'avrAgree' => $this->avrAgree - , 'avrDisAgree' => $this->avrDisAgree - ); - - $this->set_data_to_cache($datas); - - return $this; - } - - public function get_record() - { - return $this->record; - } - - /** - * - * @return int - */ - public function get_order() - { - return $this->order; - } - - /** - * - * @param int $number - * @return basket_element_adapter - */ - public function set_order($order) - { - $this->order = (int) $order; - - return $this; - } - - /** - * @return basket_element_adapter - */ - public static function getInstance($sselcont_id) - { - if (!isset(self::$_instance[$sselcont_id])) - { - self::$_instance[$sselcont_id] = new self($sselcont_id); - } - - return array_key_exists($sselcont_id, self::$_instance) ? self::$_instance[$sselcont_id] : false; - } - - /** - * - * @param basket_adapter $basket - * @param int $base_id - * @param int $record_id - * @param int $parent_record_id - * @param string $adjust_validation_datas - * @param boolean $fixing - * @return basket_element_adapter - */ - public static function create(basket_adapter $basket, $base_id, $record_id, $parent_record_id, $adjust_validation_datas, $fixing) - { - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); - $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); - $sbas_id = phrasea::sbasFromBas($base_id); - $record = new record_adapter($sbas_id, $record_id); - - $ssel_id = $basket->get_ssel_id(); - - if (!$user->ACL()->has_right_on_base($base_id, 'canputinalbum')) - throw new Exception('You do not have rights' . - ' to use this document in basket.'); - - $exists = false; - - $sql = 'SELECT sselcont_id FROM sselcont - WHERE ssel_id = :ssel_id AND base_id = :base_id AND record_id = :record_id '; - $stmt = $appbox->get_connection()->prepare($sql); - $params = array( - ':ssel_id' => $basket->get_ssel_id() - , ':base_id' => $base_id - , ':record_id' => $record_id - ); - $stmt->execute($params); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($row) - { - return new self($row['sselcont_id']); - } - - $connbas = connection::getPDOConnection($sbas_id); - - if (!$sbas_id) - throw new Exception('Unknown database'); - - if ($parent_record_id && $fixing === false) - { - if (!$user->ACL()->has_right_on_base($base_id, 'canaddrecord')) - throw new Exception('You do not have the right'); - - if ($record->is_grouping()) - throw new Exception('Can\'t add grouping to grouping'); - - $ord = 0; - $sql = "SELECT (max(ord)+1) as ord - FROM regroup WHERE rid_parent = :parent_record_id"; - - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':parent_record_id' => $parent_record_id)); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($row) - { - $ord = is_null($row["ord"]) ? 0 : $row["ord"]; - } - else - { - $ord = 0; - } - - $sql = 'INSERT INTO regroup (id, rid_parent, rid_child, dateadd, ord) - VALUES (null, :parent_record_id, :record_id, NOW(), :ord)'; - - $params = array( - ':parent_record_id' => $parent_record_id - , ':record_id' => $record_id - , ':ord' => $ord - ); - - $stmt = $connbas->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :parent_record_id'; - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':parent_record_id' => $parent_record_id)); - $stmt->closeCursor(); - } - - $sql = 'SELECT max(ord) as ord FROM sselcont WHERE ssel_id = :ssel_id'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $basket->get_ssel_id())); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($row) - { - $ord = (int) $row['ord'] + 1; - } - else - { - $ord = 0; - } - - $sql = ' INSERT INTO sselcont - (sselcont_id, ssel_id, base_id, record_id, ord) - VALUES (null, :ssel_id, :base_id, :record_id, :ord) '; - - $stmt = $appbox->get_connection()->prepare($sql); - $params = array( - ':ssel_id' => $basket->get_ssel_id() - , ':base_id' => $base_id - , ':record_id' => $record_id - , ':ord' => $ord - ); - $stmt->execute($params); - $stmt->closeCursor(); - - $sselcont_id = $appbox->get_connection()->lastInsertId(); - - $ret['error'] = false; - $ret['datas'][] = $sselcont_id; - - $sql = 'UPDATE ssel SET updater=NOW() WHERE ssel_id = :ssel_id'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $basket->get_ssel_id())); - $stmt->closeCursor(); - - - if ($adjust_validation_datas == 'myvalid') - { - $sql = 'INSERT INTO validate_datas - (SELECT distinct null as id, id as validate_id - , :sselcont_id as sselcont_id - , null as updated_on, 0 as agreement, "" as note - FROM validate - WHERE ssel_id = :ssel_id)'; - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':sselcont_id' => $sselcont_id, ':ssel_id' => $basket->get_ssel_id())); - $stmt->closeCursor(); - - $sql = 'SELECT usr_id FROM validate WHERE ssel_id = :ssel_id'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $basket->get_ssel_id())); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - if ($session->get_usr_id() != $row['usr_id']) - { - $basket->set_unread($row['usr_id']); - } - } - } - - if ($parent_record_id) - { - $sql = 'SELECT null as id, ssel_id, usr_id - FROM ssel - WHERE usr_id != :usr_id AND rid = :parent_record_id - AND sbas_id = :sbas_id AND temporaryType="1"'; - - $stmt = $appbox->get_connection()->prepare($sql); - $params = array( - ':usr_id' => $session->get_usr_id() - , ':parent_record_id' => $parent_record_id - , ':sbas_id' => $sbas_id - ); - $stmt->execute($params); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - $sql = 'SELECT max(ord) as ord FROM sselcont WHERE ssel_id = :ssel_id'; - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $row['ssel_id'])); - $row2 = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if ($row) - { - $ord = (int) $row2['ord'] + 1; - } - else - { - $ord = 0; - } - - $sqlUp = ' INSERT INTO sselcont - (sselcont_id, ssel_id, base_id, record_id,ord) - VALUES (null, :ssel_id, :base_id, :record_id, :ord) '; - - $stmt = $appbox->get_connection()->prepare($sql); - $params = array( - ':ssel_id' => $row['ssel_id'] - , ':base_id' => $base_id - , ':record_id' => $record_id - , ':ord' => $ord - ); - $stmt->execute($params); - $stmt->closeCursor(); - - $sql = 'UPDATE ssel SET updater=NOW() WHERE ssel_id = :ssel_id'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $row['ssel_id'])); - $stmt->closeCursor(); - - try - { - $basket_to_clean = basket_adapter::getInstance($appbox, $row['ssel_id'], $user->get_id()); - $basket_to_clean->set_unread($row['usr_id']); - } - catch (Exception $e) - { - - } - } - } - - $basket->delete_cache(); - - return new self($sselcont_id); - } - - /** - * - * @param string $note - * @return boolean - */ - function set_note($note) - { - if (!$this->is_validation_item) - { - throw new Exception('Element ' . $this->sselcont_id . ' is not a validation item'); - } - - $note = strip_tags($note); - - if (!$this->validate_id) - - return false; - - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - - $sql = 'UPDATE validate_datas SET note = :note - WHERE sselcont_id = :sselcont_id AND validate_id = :validate_id '; - $stmt = $appbox->get_connection()->prepare($sql); - - $params = array( - ':note' => $note - , ':sselcont_id' => $this->sselcont_id - , ':validate_id' => $this->validate_id - ); - - $stmt->execute($params); - $stmt->closeCursor(); - - $this->my_note = $note; - foreach ($this->choices as $key => $values) - { - if ($values['is_mine']) - { - $this->choices[$key]['note'] = $note; - break; - } - } - - try - { - $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id); - $basket->delete_cache(); - } - catch (Exception $e) - { - - } - - return $this; - } - - /** - * - * @return void - */ - function load_users_infos() - { - if (!$this->is_validation_item) - { - throw new Exception('Element is not a validation item'); - - return false; - } - - foreach ($this->choices as $key => $value) - { - $this->choices[$key]['usr_display'] = User_Adapter::getInstance($value['usr_id'], appbox::get_instance())->get_display_name(); - } - } - - /** - * - * @return int - */ - function get_note_count() - { - if (!$this->is_validation_item) - { - throw new Exception('Element is not a validation item'); - - return false; - } - - $n = 0; - foreach ($this->choices as $key => $value) - { - if (trim($value['note']) != '') - $n++; - } - - return $n; - } - - /** - * - * @param boolean $boolean - * @return string - */ - function set_agreement($boolean) - { - - if (!$this->is_validation_item) - { - throw new Exception('not a validation item'); - } - - if (!$this->validate_id) - throw new Exception('not a validation item'); - - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - - $boolean = in_array($boolean, array('1', '-1')) ? $boolean : '0'; - - $sql = 'UPDATE validate_datas - SET agreement = :agreement - WHERE sselcont_id = :sselcont_id - AND validate_id = :validate_id'; - - $params = array( - ':agreement' => $boolean - , ':sselcont_id' => $this->sselcont_id - , ':validate_id' => $this->validate_id - ); - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - $this->delete_data_from_cache(); - $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $usr_id); - $basket->delete_cache(); - - return $this; - } - - /** - * - * @return int - */ - public function get_sselcont_id() - { - return $this->sselcont_id; - } - - /** - * - * @return boolean - */ - public function is_validation_item() - { - return $this->is_validation_item; - } - - /** - * - * @return int - */ - public function get_my_agreement() - { - return $this->my_agreement; - } - - /** - * - * @return string - */ - public function get_my_note() - { - return $this->my_note; - } - - /** - * - * @return Array - */ - public function get_choices() - { - return $this->choices; - } - - /** - * - * @return int - */ - public function get_ssel_id() - { - return $this->ssel_id; - } - - public static function is_in_validation_session(record_Interface $record, User_Interface $user) - { - $conn = connection::getPDOConnection(); - $sql = 'SELECT v.id FROM sselcont c, validate v - WHERE c.base_id = :base_id AND c.record_id = :record_id - AND v.usr_id = :usr_id AND c.ssel_id = v.ssel_id'; - - $params = array( - ':base_id' => $record->get_base_id() - , ':record_id' => $record->get_record_id() - , ':usr_id' => $user->get_id() - ); - - $stmt = $conn->prepare($sql); - $stmt->execute($params); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - return!!$row; - } - - public static function has_been_received(record_Interface $record, User_Interface $user) - { - $conn = connection::getPDOConnection(); - $sql = 'SELECT sselcont_id FROM sselcont c, ssel s - WHERE c.ssel_id=s.ssel_id AND c.record_id = :record_id - AND c.base_id = :base_id AND s.pushFrom > 0 - AND s.usr_id = :usr_id'; - - $params = array( - ':base_id' => $record->get_base_id() - , ':record_id' => $record->get_record_id() - , ':usr_id' => $user->get_id() - ); - - $stmt = $conn->prepare($sql); - $stmt->execute($params); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - return!!$row; - } - - public function get_avrAgree() - { - return $this->avrAgree; - } - - public function get_avrDisAgree() - { - return $this->avrDisAgree; - } - - public function validate(user_adapter $from_user, User_Adapter $to_user, $validate_id, $can_hd) - { - $appbox = appbox::get_instance(); - - if ($can_hd) - $to_user->ACL()->grant_hd_on($this->get_record(), $from_user, 'validate'); - else - $to_user->ACL()->grant_preview_on($this->get_record(), $from_user, 'validate'); - - $sql = 'REPLACE INTO validate_datas - (id, validate_id, sselcont_id, updated_on, agreement) - VALUES - (null, :validate_id, :sselcont_id, null, 0)'; - $stmt = $appbox->get_connection()->prepare($sql); - - $params = array( - ':validate_id' => $validate_id - , ':sselcont_id' => $this->get_sselcont_id() - ); - $stmt->execute($params); - - $stmt->closeCursor(); - - if (!$this->is_validation_item) - { - $this->choices = array(); - $this->avrAgree = 0; - $this->avrDisAgree = 0; - } - - $this->is_validation_item = true; - $this->choices[$to_user->get_id()] = array( - 'usr_id' => $to_user->get_id(), - 'usr_name' => $to_user->get_display_name(), - 'is_mine' => ($to_user->get_id() == $this->usr_id), - 'agreement' => 0, - 'updated_on' => new DateTime(), - 'note' => '' - ); - if ($to_user->get_id() == $this->usr_id) - { - $this->validate_id = (int) $validate_id; - } - - $this->delete_data_from_cache(); - - return $this; - } - - public function get_cache_key($option = null) - { - return 'basket_element_' . $this->usr_id . '_' . $this->sselcont_id . ($option ? '_' . $option : ''); - ; - } - - public function get_data_from_cache($option = null) - { - $appbox = appbox::get_instance(); - - return $appbox->get_data_from_cache($this->get_cache_key($option)); - } - - public function set_data_to_cache($value, $option = null, $duration = 0) - { - $appbox = appbox::get_instance(); - - return $appbox->set_data_to_cache($value, $this->get_cache_key($option), $duration); - } - - public function delete_data_from_cache($option = null) - { - $appbox = appbox::get_instance(); - - return $appbox->delete_data_from_cache($this->get_cache_key($option)); - } - -} diff --git a/lib/classes/basketCollection.class.php b/lib/classes/basketCollection.class.php deleted file mode 100644 index 584cdcbaa5..0000000000 --- a/lib/classes/basketCollection.class.php +++ /dev/null @@ -1,179 +0,0 @@ -format('U'); - - $sql = 'SELECT ssel_id FROM ssel WHERE usr_id = :usr_id - AND temporaryType="0"'; - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr_id)); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if (count($rs) === 0) - { - $basket = basket_adapter::create($appbox, '', $user); - } - - $baskets = array(); - $baskets['baskets'] = $baskets['recept'] = $baskets['regroup'] = array(); - - - $core = bootstrap::getCore(); - $em = $core->getEntityManager(); - - $baskets['baskets'] = $em->getRepository('Entities\Basket') - ->findBy(array('usr_id' => $usr_id, 'pusher_id' => null)); - - $baskets['regroup'] = $em->getRepository('Entities\StoryWZ') - ->findBy(array('usr_id' => $usr_id)); - -// $sql = 'SELECT s.ssel_id, s.usr_id as owner, v.id as validate_id, -// s.temporaryType, s.pushFrom, v.expires_on FROM ssel s -// LEFT JOIN validate v -// ON (v.ssel_id = s.ssel_id AND v.usr_id = :usr_id_v) -// WHERE (s.usr_id = :usr_id_o OR v.id IS NOT NULL)'; -// -// $stmt = $appbox->get_connection()->prepare($sql); -// $stmt->execute(array(':usr_id_o' => $usr_id, ':usr_id_v' => $usr_id)); -// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); -// $stmt->closeCursor(); - -// foreach ($rs as $row) -// { -// $is_mine = ($row['owner'] == $usr_id); -// -// $expires_on_obj = new DateTime($row['expires_on']); -// $expires_on = $expires_on_obj->format('U'); -// -// if ($row['validate_id'] != null && !$is_mine && $expires_on < $current_timestamp) -// continue; -// -// if ($row['temporaryType'] == '1') -// $baskets['regroup'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id); -// elseif (!is_null($row['validate_id'])) -// { -//// $baskets['baskets'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id); -// } -// elseif ((int) $row['pushFrom'] > 0) -// $baskets['recept'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id); -//// else -//// $baskets['baskets'][] = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id); -// } - - $to_remove = array_intersect(array('recept', 'regroup', 'baskets'), $except); - - foreach ($to_remove as $type) - $baskets[$type] = array(); - - if ($order == 'name asc') - { - uasort($baskets['baskets'], array('basketCollection', 'story_name_sort')); - uasort($baskets['regroup'], array('basketCollection', 'story_name_sort')); - uasort($baskets['recept'], array('basketCollection', 'story_name_sort')); - } - if ($order == 'date desc') - { - uasort($baskets['baskets'], array('basketCollection', 'story_date_sort')); - uasort($baskets['regroup'], array('basketCollection', 'story_date_sort')); - uasort($baskets['recept'], array('basketCollection', 'story_date_sort')); - } - - - $this->baskets = $baskets; - - return $this; - } - - public function get_baskets() - { - return $this->baskets; - } - - function get_names() - { - $array_names = array(); - - foreach ($this->baskets as $type_name => $type) - { - foreach ($type as $basket) - { - - $array_names[] = array('ssel_id' => $basket->get_ssel_id(), 'name' => $basket->get_name(), 'type' => $type_name); - } - } - - return $array_names; - } - - function story_date_sort($a, $b) - { - if (!$a->create || !$b->create) - return 0; - - $comp = strcasecmp($a->create, $b->create); - - if ($comp == 0) - return 0; - - return $comp < 0 ? -1 : 1; - } - - function story_name_sort($a, $b) - { - if (!$a->getName() || !$b->getName()) - { - return 0; - } - $comp = strcasecmp($a->getName(), $b->getName()); - - if ($comp == 0) - return 0; - - return $comp < 0 ? -1 : 1; - } - - public static function get_updated_baskets() - { - $appbox = appbox::get_instance(); - $conn = $appbox->get_connection(); - $session = $appbox->get_session(); - $sql = 'SELECT ssel_id FROM sselnew WHERE usr_id = :usr_id'; - $stmt = $conn->prepare($sql); - $stmt->execute(array(':usr_id' => $session->get_usr_id())); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - $baskets = array(); - foreach ($rs as $row) - { - $baskets[] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); - } - - return $baskets; - } - -} diff --git a/lib/classes/binaryAdapter/video/progressive/moovRelocator.class.php b/lib/classes/binaryAdapter/video/progressive/moovRelocator.class.php index 3fbf455407..5eac57d440 100644 --- a/lib/classes/binaryAdapter/video/progressive/moovRelocator.class.php +++ b/lib/classes/binaryAdapter/video/progressive/moovRelocator.class.php @@ -1,5 +1,5 @@ 1) + $separator = $separator[0]; + if (trim($separator) === '') $separator = ' '; else @@ -346,9 +349,9 @@ class caption_field implements cache_cacheableInterface if ($this->databox_field->is_multi() === true) { if ($as_string === true && $custom_separator === false) - + { return $this->value; - + } $separator = $this->databox_field->get_separator(); $array_values = self::get_multi_values($this->value, $separator); diff --git a/lib/classes/caption/record.class.php b/lib/classes/caption/record.class.php index fd608c404f..c5073e43f2 100644 --- a/lib/classes/caption/record.class.php +++ b/lib/classes/caption/record.class.php @@ -59,8 +59,7 @@ class caption_record implements caption_interface, cache_cacheableInterface protected function retrieve_fields() { - if(is_array($this->fields)) - + if (is_array($this->fields)) return $this->fields; $fields = array(); @@ -97,7 +96,7 @@ class caption_record implements caption_interface, cache_cacheableInterface } catch (Exception $e) { - + } } $this->fields = $rec_fields; @@ -134,7 +133,6 @@ class caption_record implements caption_interface, cache_cacheableInterface { $fields = $this->retrieve_fields(); if (isset($this->dces_elements[$label])) - return $fields[$this->dces_elements[$label]]; return null; } @@ -172,7 +170,10 @@ class caption_record implements caption_interface, cache_cacheableInterface , $field->highlight_thesaurus() ); - $fields[$field->get_name()] = $value; + $fields[$field->get_name()] = array( + 'value' => $value + , 'separator' => $field->get_databox_field()->get_separator() + ); } if ($searchEngine instanceof searchEngine_adapter) @@ -185,7 +186,7 @@ class caption_record implements caption_interface, cache_cacheableInterface foreach ($fields as $key => $value) { - $fields[$key] = $ret[$n]; + $fields[$key]['value'] = $ret[$n]; $n++; } } diff --git a/lib/classes/connection.class.php b/lib/classes/connection.class.php index 7bf6e7b28a..9d691f7c90 100755 --- a/lib/classes/connection.class.php +++ b/lib/classes/connection.class.php @@ -134,9 +134,9 @@ class connection } else { - if (!is_file(dirname(__FILE__) . '/../../config/connexion.inc')) + if (!is_file(__DIR__ . '/../../config/connexion.inc')) throw new Exception('Unable to load config file'); - require (dirname(__FILE__) . '/../../config/connexion.inc'); + require (__DIR__ . '/../../config/connexion.inc'); } if (isset($connection_params[$name])) { diff --git a/lib/classes/connection/pdo.class.php b/lib/classes/connection/pdo.class.php index 8450390eaf..e04753ed03 100644 --- a/lib/classes/connection/pdo.class.php +++ b/lib/classes/connection/pdo.class.php @@ -88,7 +88,7 @@ class connection_pdo extends connection_abstract implements connection_interface */ protected function log($message) { - file_put_contents(dirname(__FILE__) . '/../../../logs/sql_log.log', $message . "\n", FILE_APPEND); + file_put_contents(__DIR__ . '/../../../logs/sql_log.log', $message . "\n", FILE_APPEND); return $this; } diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 210fcad890..a42131ed30 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -142,7 +142,7 @@ class databox extends base } catch (Exception $e) { - + } } @@ -157,7 +157,7 @@ class databox extends base } catch (Exception $e) { - + } $conn = connection::getPDOConnection(); @@ -277,6 +277,7 @@ class databox extends base SUM(1) AS n, SUM(size) AS siz FROM (record, subdef) LEFT JOIN coll ON record.coll_id=coll.coll_id WHERE record.record_id = subdef.record_id + GROUP BY record.coll_id, name UNION SELECT coll.coll_id, 0, asciiname, '_' AS name, 0 AS n, 0 AS siz FROM coll LEFT JOIN record ON record.coll_id=coll.coll_id @@ -450,7 +451,6 @@ class databox extends base $stmt->closeCursor(); if ($row) - return self::get_instance((int) $row['sbas_id']); try @@ -463,7 +463,7 @@ class databox extends base } catch (Exception $e) { - + } $sql = 'USE `' . $dbname . '`'; @@ -575,7 +575,6 @@ class databox extends base public function get_meta_structure() { if ($this->meta_struct) - return $this->meta_struct; try @@ -698,7 +697,6 @@ class databox extends base } } if ($n > $limit) - return true; return false; @@ -725,7 +723,7 @@ class databox extends base public static function get_available_metadatas() { $available_fields = array(); - $dir = dirname(__FILE__) . '/metadata/description/'; + $dir = __DIR__ . '/metadata/description/'; $registry = registry::get_instance(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { @@ -960,15 +958,24 @@ class databox extends base $this->saveStructure($dom_struct); $type = isset($field['type']) ? $field['type'] : 'string'; - $type = in_array($type, array(databox_field::TYPE_DATE, databox_field::TYPE_NUMBER, databox_field::TYPE_TEXT)) ? $type : databox_field::TYPE_TEXT; + $type = in_array($type + , array( + databox_field::TYPE_DATE + , databox_field::TYPE_NUMBER + , databox_field::TYPE_STRING + , databox_field::TYPE_TEXT + ) + ) ? $type : databox_field::TYPE_STRING; $meta_struct_field = databox_field::create($this, $fname); $meta_struct_field ->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0) ->set_indexable(isset($field['index']) ? $field['index'] : '1') + ->set_separator(isset($field['separator']) ? $field['separator'] : '') + ->set_required((isset($field['required']) && $field['required'] == 1)) ->set_type($type) ->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '') - ->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : '0') + ->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) ->set_multi(isset($field['multi']) ? $field['multi'] : 0) ->set_report(isset($field['report']) ? $field['report'] : '1') ->save(); @@ -979,7 +986,7 @@ class databox extends base } catch (Exception $e) { - + } if (isset($field['regname'])) @@ -1213,7 +1220,6 @@ class databox extends base public function get_structure() { if ($this->structure) - return $this->structure; $this->structure = $this->retrieve_structure(); @@ -1228,7 +1234,7 @@ class databox extends base } catch (Exception $e) { - + } $structure = null; @@ -1254,7 +1260,6 @@ class databox extends base public function get_cterms() { if ($this->cterms) - return $this->cterms; $sql = "SELECT value FROM pref WHERE prop='cterms'"; @@ -1421,7 +1426,6 @@ class databox extends base public function get_cgus() { if ($this->cgus) - return $this->cgus; $this->load_cgus(); @@ -1439,7 +1443,7 @@ class databox extends base } catch (Exception $e) { - + } $sql = 'SELECT value, locale, updated_on FROM pref WHERE prop ="ToU"'; diff --git a/lib/classes/databox/field.class.php b/lib/classes/databox/field.class.php index cb83c8b037..7f36cab930 100644 --- a/lib/classes/databox/field.class.php +++ b/lib/classes/databox/field.class.php @@ -124,6 +124,7 @@ class databox_field implements cache_cacheableInterface const TYPE_TEXT = "text"; const TYPE_DATE = "date"; + const TYPE_STRING = "string"; const TYPE_NUMBER = "number"; /** @@ -176,7 +177,7 @@ class databox_field implements cache_cacheableInterface $this->required = !!$row['required']; $this->multi = !!$row['multi']; $this->report = !!$row['report']; - $this->type = $row['type']; + $this->type = $row['type'] ?: self::TYPE_STRING; $this->tbranch = $row['tbranch']; if ($row['dces_element']) { @@ -551,6 +552,9 @@ class databox_field implements cache_cacheableInterface */ public function set_separator($separator) { + if (strpos($separator, ';') === false) + $separator .= ';'; + $this->separator = $separator; return $this; diff --git a/lib/classes/deprecated/prodUtils.php b/lib/classes/deprecated/prodUtils.php index aa4233ae95..670c075435 100644 --- a/lib/classes/deprecated/prodUtils.php +++ b/lib/classes/deprecated/prodUtils.php @@ -17,13 +17,16 @@ */ function deleteRecord($lst, $del_children) { + $Core = bootstrap::getCore(); + $em = $Core->getEntityManager(); + $BE_repository = $em->getRepository('\Entities\BasketElement'); + $appbox = appbox::get_instance(); $session = $appbox->get_session(); - $registry = $appbox->get_registry(); + $registry = $Core->getRegistry(); - $usr_id = $session->get_usr_id(); - - $ACL = User_Adapter::getInstance($usr_id, $appbox)->ACL(); + $user = $Core->getAuthenticatedUser(); + $ACL = $user->ACL(); $lst = explode(";", $lst); @@ -103,84 +106,14 @@ function deleteRecord($lst, $del_children) } } - $sql = array(); - $params = array(); - $n = 0; - foreach ($ret as $key=>$basrec) + $basket_elements = $BE_repository->findElementsByRecord($record); + + foreach($basket_elements as $basket_element) { - $br = explode('_', $basrec); - $sql[] = '(base_id = :base_id' . $n . ' AND record_id = :record_id' . $n . ')'; - - $params[':base_id' . $n] = $br[2]; - $params[':record_id' . $n] = $br[1]; - - - $sql_ssel = 'SELECT ssel_id, usr_id FROM ssel - WHERE sbas_id = :sbas_id AND rid = :record_id'; - - $stmt = $conn->prepare($sql_ssel); - $stmt->execute(array(':sbas_id' => $br[0], ':record_id' => $br[1])); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - try - { - $basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $row['usr_id']); - $basket->delete_cache(); - unset($basket); - } - catch (Exception $e) - { - - } - } - - - $sql_ssel = 'DELETE FROM ssel WHERE sbas_id = :sbas_id AND rid = :record_id'; - $stmt = $conn->prepare($sql_ssel); - $stmt->execute(array(':sbas_id' => $br[0], ':record_id' => $br[1])); - $stmt->closeCursor(); - - unset($br[2]); - $ret[$key] = implode('_', $br); - $n++; + $em->remove($basket_element); } - - if (count($sql) > 0) - { - $sql_res = 'SELECT DISTINCT ssel.usr_id, ssel.ssel_id FROM sselcont ,ssel - WHERE (' . implode(' OR ', $sql) . ') - AND sselcont.ssel_id = ssel.ssel_id AND ssel.usr_id = :usr_id'; - $params[':usr_id'] = $usr_id; - - $stmt = $conn->prepare($sql_res); - $stmt->execute($params); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - try - { - $basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $usr_id); - $basket->delete_cache(); - } - catch (Exception $e) - { - - } - } - - - $sql = 'DELETE FROM sselcont WHERE (' . implode(' OR ', $sql) . ') - AND ssel_id IN (SELECT ssel_id FROM ssel WHERE usr_id = :usr_id)'; - $stmt = $conn->prepare($sql_res); - $stmt->execute($params); - $stmt->closeCursor(); - } - + $em->flush(); + return p4string::jsonencode($ret); } diff --git a/lib/classes/deprecated/push.api.php b/lib/classes/deprecated/push.api.php index 1311427b61..594819a78a 100644 --- a/lib/classes/deprecated/push.api.php +++ b/lib/classes/deprecated/push.api.php @@ -1486,6 +1486,7 @@ function getUsrInfos($usr, $arrayUsrs) function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse) { + $Core = bootstrap::getCore(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -1507,6 +1508,8 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse) $reading_confirm_to = $me->get_email(); } + $em = $Core->getEntityManager(); + foreach ($users as $oneuser => $rights) { $new_basket = null; @@ -1516,20 +1519,40 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse) $user = User_Adapter::getInstance($oneuser, $appbox); $pusher = User_Adapter::getInstance($usr, $appbox); - $new_basket = basket_adapter::create($appbox, $newBask, $user, '', $pusher); - $new_basket->set_unread(); - + $new_basket = new \Entities\Basket(); + $new_basket->setName($newBask); + $new_basket->setIsRead(false); + $new_basket->setPusher($pusher); + $new_basket->setOwner($user); + + $em->persist($new_basket); + $nbchu++; - $new_basket->push_list($parmLST, false); + foreach($parmLST as $basrec) + { + $basrec = explode('_', $basrec); + + $record = new record_adapter($basrec[0], $basrec[1]); + + $BasketElement = new Entities\BasketElement(); + $BasketElement->setRecord($record); + $BasketElement->setBasket($new_basket); + + $em->persist($BasketElement); + + $new_basket->addBasketElement($BasketElement); + } + + $em->flush(); $finalUsers[] = $user->get_id(); $canSendHD = sendHdOk($usr, $parmLST); - foreach ($new_basket->get_elements() as $element) + foreach ($new_basket->getElements() as $element) { - $record = $element->get_record(); + $record = $element->getRecord(); if ($rights['canHD'] && in_array($record->get_base_id(), $canSendHD)) $user->ACL()->grant_hd_on($record, $me, 'push'); else @@ -1541,7 +1564,7 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse) $from = trim($me->get_email()) != "" ? $me->get_email() : false; - $url = $registry->get('GV_ServerName') . 'lightbox/index.php?LOG=' . random::getUrlToken('view', $user->get_id(), null, $new_basket->get_ssel_id()); + $url = $registry->get('GV_ServerName') . 'lightbox/index.php?LOG=' . random::getUrlToken('view', $user->get_id(), null, $new_basket->getId()); if ($me->get_id() == $user->get_id()) $my_link = $url; @@ -1557,11 +1580,11 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse) , 'url' => $url , 'accuse' => $reading_confirm_to , 'message' => $mail_content - , 'ssel_id' => $new_basket->get_ssel_id() + , 'ssel_id' => $new_basket->getId() ); - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $evt_mngr->trigger('__PUSH_DATAS__', $params); } catch (Exception $e) @@ -1575,6 +1598,7 @@ function pushIt($usr, $newBask, $parmLST, $users, $mail_content, $lng, $accuse) function pushValidation($usr, $ssel_id, $listUsrs, $time, $mail_content, $accuse) { + $Core = bootstrap::getCore(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -1605,10 +1629,16 @@ function pushValidation($usr, $ssel_id, $listUsrs, $time, $mail_content, $accuse $expires = null; } + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $Core->getAuthenticatedUser()); - - $basket = basket_adapter::getInstance($appbox, $ssel_id, $session->get_usr_id()); - $basket->set_unread(); + $basket->setIsRead(false); + + $em->merge($basket); + + $em->flush(); foreach ($listUsrs as $oneuser => $rights) { @@ -1637,7 +1667,7 @@ function pushValidation($usr, $ssel_id, $listUsrs, $time, $mail_content, $accuse , 'accuse' => $reading_confirm_to ); - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $evt_mngr->trigger('__PUSH_VALIDATION__', $params); if ($me->get_id() == $user->get_id()) diff --git a/lib/classes/eventsmanager/broker.class.php b/lib/classes/eventsmanager/broker.class.php index 2b15317d02..6a8712cb83 100644 --- a/lib/classes/eventsmanager/broker.class.php +++ b/lib/classes/eventsmanager/broker.class.php @@ -12,10 +12,16 @@ class eventsmanager_broker * @var appbox */ protected $appbox; + /** + * + * @var \Alchemy\Phrasea\Core + */ + protected $core; - private function __construct(appbox &$appbox) + private function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core) { $this->appbox = $appbox; + $this->core = $core; return $this; } @@ -23,11 +29,11 @@ class eventsmanager_broker /** * @return eventsmanager */ - public static function getInstance(appbox &$appbox) + public static function getInstance(appbox &$appbox, \Alchemy\Phrasea\Core $core) { if (!self::$_instance) { - self::$_instance = new self($appbox); + self::$_instance = new self($appbox, $core); } return self::$_instance; @@ -50,7 +56,7 @@ class eventsmanager_broker { continue; } - $this->pool_classes[$classname] = new $classname($this->appbox, $this->appbox->get_registry(), $this); + $this->pool_classes[$classname] = new $classname($this->appbox, $this->core, $this); foreach ($this->pool_classes[$classname]->get_events() as $event) $this->bind($event, $classname); @@ -67,17 +73,17 @@ class eventsmanager_broker { $iterators_pool = array(); - $root = dirname(__FILE__) . '/../../'; + $root = __DIR__ . '/../../'; if ($type == 'event') { - $iterators_pool['event'][] = new DirectoryIterator(dirname(__FILE__) . '/event/'); - if (file_exists(dirname(__FILE__) . '/event/')) - $iterators_pool['event'][] = new DirectoryIterator(dirname(__FILE__) . '/event/'); + $iterators_pool['event'][] = new DirectoryIterator(__DIR__ . '/event/'); + if (file_exists(__DIR__ . '/event/')) + $iterators_pool['event'][] = new DirectoryIterator(__DIR__ . '/event/'); } if ($type == 'notify') { - $iterators_pool['notify'][] = new DirectoryIterator(dirname(__FILE__) . '/notify/'); + $iterators_pool['notify'][] = new DirectoryIterator(__DIR__ . '/notify/'); } $ret = array(); @@ -100,7 +106,7 @@ class eventsmanager_broker { continue; } - $obj = new $classname($this->appbox, $this->appbox->get_registry(), $this); + $obj = new $classname($this->appbox, $this->core, $this); $ret[$classname] = $obj->get_name(); } diff --git a/lib/classes/eventsmanager/eventAbstract.class.php b/lib/classes/eventsmanager/eventAbstract.class.php index 40373f8d44..b1f97412a3 100644 --- a/lib/classes/eventsmanager/eventAbstract.class.php +++ b/lib/classes/eventsmanager/eventAbstract.class.php @@ -15,6 +15,11 @@ abstract class eventsmanager_eventAbstract * @var registryInterface */ protected $registry; + /** + * + * @var \Alchemy\Phrasea\Core + */ + protected $core; /** * * @var eventsmanager @@ -22,10 +27,11 @@ abstract class eventsmanager_eventAbstract protected $broker; - public function __construct(appbox &$appbox, registryInterface $registry, eventsmanager_broker &$broker) + public function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker) { $this->appbox = $appbox; - $this->registry = $registry; + $this->registry = $core->getRegistry(); + $this->core = $core; $this->broker = $broker; return $this; diff --git a/lib/classes/eventsmanager/notify/orderdeliver.class.php b/lib/classes/eventsmanager/notify/orderdeliver.class.php index b441f88e1f..1470b49d6a 100644 --- a/lib/classes/eventsmanager/notify/orderdeliver.class.php +++ b/lib/classes/eventsmanager/notify/orderdeliver.class.php @@ -28,10 +28,10 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract * * @return notify_orderdeliver */ - function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker) + function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker) { $this->group = _('Commande'); - parent::__construct($appbox, $registry, $broker); + parent::__construct($appbox, $core, $broker); return $this; } @@ -147,7 +147,10 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract try { - $basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id()); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser()); } catch (Exception $e) { @@ -159,7 +162,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract $sender, $n, '' - . $basket->get_name() . '' + . $basket->getName() . '' ) , 'class' => '' ); @@ -196,7 +199,10 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract { try { - $basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id()); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser()); } catch (Exception $e) { @@ -204,7 +210,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract } $subject = sprintf( _('push::mail:: Reception de votre commande %s'), - $basket->get_name() + $basket->getName() ); $body = "
" diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.class.php b/lib/classes/eventsmanager/notify/ordernotdelivered.class.php index 537d32ecdb..a1e737983e 100644 --- a/lib/classes/eventsmanager/notify/ordernotdelivered.class.php +++ b/lib/classes/eventsmanager/notify/ordernotdelivered.class.php @@ -24,10 +24,10 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac */ public $events = array('__ORDER_NOT_DELIVERED__'); - function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker) + function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker) { $this->group = _('Commande'); - parent::__construct($appbox, $registry, $broker); + parent::__construct($appbox, $core, $broker); return $this; } diff --git a/lib/classes/eventsmanager/notify/validate.class.php b/lib/classes/eventsmanager/notify/validate.class.php index 2de351364e..ebe965a58a 100644 --- a/lib/classes/eventsmanager/notify/validate.class.php +++ b/lib/classes/eventsmanager/notify/validate.class.php @@ -28,10 +28,10 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract * * @return notify_validate */ - function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker) + function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker) { $this->group = _('Validation'); - parent::__construct($appbox, $registry, $broker); + parent::__construct($appbox, $core, $broker); return $this; } @@ -140,9 +140,12 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract try { - $basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id()); - $basket_name = (trim($basket->get_name()) != '' ? - $basket->get_name() : _('Une selection')); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser()); + + $basket_name = trim($basket->getName()) ?: _('Une selection'); } catch (Exception $e) { diff --git a/lib/classes/eventsmanager/notify/validationdone.class.php b/lib/classes/eventsmanager/notify/validationdone.class.php index 107409993e..172ece27f8 100644 --- a/lib/classes/eventsmanager/notify/validationdone.class.php +++ b/lib/classes/eventsmanager/notify/validationdone.class.php @@ -28,10 +28,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract * * @return notify_validationdone */ - function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker) + function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker) { $this->group = _('Validation'); - parent::__construct($appbox, $registry, $broker); + parent::__construct($appbox, $core, $broker); return $this; } @@ -143,7 +143,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract try { - $basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id()); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser()); } catch (Exception $e) { @@ -156,7 +159,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract $sender, '' - . $basket->get_name() . '' + . $basket->getName() . '' ) , 'class' => '' ); @@ -193,7 +196,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract { try { - $basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id()); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser()); } catch (Exception $e) { @@ -203,7 +209,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract $subject = sprintf( _('push::mail:: Rapport de validation de %1$s pour %2$s'), $to['name'], - $basket->get_name() + $basket->getName() ); $body = "
" . sprintf( diff --git a/lib/classes/eventsmanager/notify/validationreminder.class.php b/lib/classes/eventsmanager/notify/validationreminder.class.php index 934b87eccc..548bb48a6b 100644 --- a/lib/classes/eventsmanager/notify/validationreminder.class.php +++ b/lib/classes/eventsmanager/notify/validationreminder.class.php @@ -28,10 +28,10 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra * * @return notify_validationreminder */ - function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker) + function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker) { $this->group = _('Validation'); - parent::__construct($appbox, $registry, $broker); + parent::__construct($appbox, $core, $broker); return $this; } @@ -156,9 +156,12 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra try { - $basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id()); - $basket_name = (trim($basket->get_name()) != '' ? - $basket->get_name() : _('Une selection')); + $em = $this->core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser()); + + $basket_name = trim($basket->getName()) ? : _('Une selection'); } catch (Exception $e) { diff --git a/lib/classes/media/subdef.class.php b/lib/classes/media/subdef.class.php index d11a7ea94e..dae599d315 100644 --- a/lib/classes/media/subdef.class.php +++ b/lib/classes/media/subdef.class.php @@ -192,6 +192,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/'; $this->file = 'deleted.png'; $this->is_physically_present = false; + $this->is_substituted = true; } if (!$row || !file_exists($this->path . $this->file)) { @@ -204,6 +205,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/'; $this->file = 'regroup_thumb.png'; + $this->is_substituted = true; } else { @@ -217,6 +219,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/'; $this->file = str_replace('+', '%20', $mime) . '.png'; + $this->is_substituted = true; } $this->is_physically_present = false; if (!file_exists($this->path . $this->file)) @@ -225,6 +228,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/'; $this->file = 'substitution.png'; + $this->is_substituted = true; } } diff --git a/lib/classes/module/console/aboutAuthors.class.php b/lib/classes/module/console/aboutAuthors.class.php index 50e9698a6d..5ed63eac7f 100644 --- a/lib/classes/module/console/aboutAuthors.class.php +++ b/lib/classes/module/console/aboutAuthors.class.php @@ -37,7 +37,7 @@ class module_console_aboutAuthors extends Command public function execute(InputInterface $input, OutputInterface $output) { - $output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../AUTHORS')); + $output->writeln(file_get_contents(__DIR__ . '/../../../../AUTHORS')); return; } diff --git a/lib/classes/module/console/aboutLicense.class.php b/lib/classes/module/console/aboutLicense.class.php index 246140dbbc..04c6ccf958 100644 --- a/lib/classes/module/console/aboutLicense.class.php +++ b/lib/classes/module/console/aboutLicense.class.php @@ -37,7 +37,7 @@ class module_console_aboutLicense extends Command public function execute(InputInterface $input, OutputInterface $output) { - $output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../LICENSE')); + $output->writeln(file_get_contents(__DIR__ . '/../../../../LICENSE')); return; } diff --git a/lib/classes/module/console/schedulerStart.class.php b/lib/classes/module/console/schedulerStart.class.php index 52afd000be..d0b2591f55 100644 --- a/lib/classes/module/console/schedulerStart.class.php +++ b/lib/classes/module/console/schedulerStart.class.php @@ -45,7 +45,7 @@ class module_console_schedulerStart extends Command throw new RuntimeException('Phraseanet is not set up'); } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $scheduler = new task_Scheduler(); $scheduler->run($output, true); diff --git a/lib/classes/module/console/schedulerState.class.php b/lib/classes/module/console/schedulerState.class.php index 4861e02224..cedf9fc9f1 100644 --- a/lib/classes/module/console/schedulerState.class.php +++ b/lib/classes/module/console/schedulerState.class.php @@ -40,7 +40,7 @@ class module_console_schedulerState extends Command throw new RuntimeException('Phraseanet is not set up'); } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $appbox = appbox::get_instance(); $task_manager = new task_manager($appbox); diff --git a/lib/classes/module/console/schedulerStop.class.php b/lib/classes/module/console/schedulerStop.class.php index b806770dd1..ab487f4157 100644 --- a/lib/classes/module/console/schedulerStop.class.php +++ b/lib/classes/module/console/schedulerStop.class.php @@ -40,7 +40,7 @@ class module_console_schedulerStop extends Command throw new RuntimeException('Phraseanet is not set up'); } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $appbox = appbox::get_instance(); $task_manager = new task_manager($appbox); diff --git a/lib/classes/module/console/systemBackupDB.class.php b/lib/classes/module/console/systemBackupDB.class.php index f477da44c3..6384e76bfc 100644 --- a/lib/classes/module/console/systemBackupDB.class.php +++ b/lib/classes/module/console/systemBackupDB.class.php @@ -31,7 +31,7 @@ class module_console_systemBackupDB extends Command $dir = sprintf( '%s/config/' - , dirname(dirname(dirname(dirname(dirname(__FILE__))))) + , dirname(dirname(dirname(dirname(__DIR__)))) ); $this->setDescription('Backup Phraseanet Databases'); @@ -48,7 +48,7 @@ class module_console_systemBackupDB extends Command throw new RuntimeException('Phraseanet is not set up'); } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $output->write('Phraseanet is going to be backup...', true); diff --git a/lib/classes/module/console/systemClearCache.class.php b/lib/classes/module/console/systemClearCache.class.php index 262f20fb83..bb597514da 100644 --- a/lib/classes/module/console/systemClearCache.class.php +++ b/lib/classes/module/console/systemClearCache.class.php @@ -44,8 +44,8 @@ class module_console_systemClearCache extends Command ->exclude('.git') ->exclude('.svn') ->in(array( - dirname(__FILE__) . '/../../../../tmp/cache_minify/' - , dirname(__FILE__) . '/../../../../tmp/cache_twig/' + __DIR__ . '/../../../../tmp/cache_minify/' + , __DIR__ . '/../../../../tmp/cache_twig/' )) ; $count = 1; @@ -59,8 +59,8 @@ class module_console_systemClearCache extends Command $finder ->directories() ->in(array( - dirname(__FILE__) . '/../../../../tmp/cache_minify' - , dirname(__FILE__) . '/../../../../tmp/cache_twig' + __DIR__ . '/../../../../tmp/cache_minify' + , __DIR__ . '/../../../../tmp/cache_twig' )) ->exclude('.git') ->exclude('.svn') diff --git a/lib/classes/module/console/systemTemplateGenerator.class.php b/lib/classes/module/console/systemTemplateGenerator.class.php index 5ca41ac1ba..4b65d4c5d1 100644 --- a/lib/classes/module/console/systemTemplateGenerator.class.php +++ b/lib/classes/module/console/systemTemplateGenerator.class.php @@ -36,16 +36,16 @@ class module_console_systemTemplateGenerator extends Command public function execute(InputInterface $input, OutputInterface $output) { - require_once dirname(__FILE__) . '/../../../../lib/vendor/Twig/lib/Twig/Autoloader.php'; - require_once dirname(__FILE__) . '/../../../../lib/vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php'; + require_once __DIR__ . '/../../../../lib/vendor/Twig/lib/Twig/Autoloader.php'; + require_once __DIR__ . '/../../../../lib/vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php'; Twig_Autoloader::register(); Twig_Extensions_Autoloader::register(); - $tplDir = dirname(__FILE__) . '/../../../../templates/'; - $tmpDir = dirname(__FILE__) . '/../../../../tmp/cache_twig/'; + $tplDir = __DIR__ . '/../../../../templates/'; + $tmpDir = __DIR__ . '/../../../../tmp/cache_twig/'; $loader = new Twig_Loader_Filesystem($tplDir); $twig = new Twig_Environment($loader, array( @@ -81,6 +81,7 @@ class module_console_systemTemplateGenerator extends Command $twig->addFilter('formatdate', new Twig_Filter_Function('phraseadate::getDate')); $twig->addFilter('getPrettyDate', new Twig_Filter_Function('phraseadate::getPrettyString')); $twig->addFilter('prettyDate', new Twig_Filter_Function('phraseadate::getPrettyString')); + $twig->addFilter('prettyString', new Twig_Filter_Function('phraseadate::getPrettyString')); $twig->addFilter('formatoctet', new Twig_Filter_Function('p4string::format_octet')); $twig->addFilter('getDate', new Twig_Filter_Function('phraseadate::getDate')); $twig->addFilter('geoname_name_from_id', new Twig_Filter_Function('geonames::name_from_id')); diff --git a/lib/classes/module/console/systemUpgrade.class.php b/lib/classes/module/console/systemUpgrade.class.php index 22d62f2a66..b8de9d1b5e 100644 --- a/lib/classes/module/console/systemUpgrade.class.php +++ b/lib/classes/module/console/systemUpgrade.class.php @@ -39,9 +39,9 @@ class module_console_systemUpgrade extends Command if (!setup::is_installed()) { - if (file_exists(dirname(__FILE__) . "/../../../../config/connexion.inc") - && !file_exists(dirname(__FILE__) . "/../../../../config/config.inc") - && file_exists(dirname(__FILE__) . "/../../../../config/_GV.php")) + if (file_exists(__DIR__ . "/../../../../config/connexion.inc") + && !file_exists(__DIR__ . "/../../../../config/config.inc") + && file_exists(__DIR__ . "/../../../../config/_GV.php")) { $output->writeln('This version of Phraseanet requires a config/config.inc'); @@ -76,7 +76,7 @@ class module_console_systemUpgrade extends Command } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $output->write('Phraseanet is going to be upgraded', true); $dialog = $this->getHelperSet()->get('dialog'); diff --git a/lib/classes/module/console/tasklist.class.php b/lib/classes/module/console/tasklist.class.php index 58fd108ed0..91da2498d5 100644 --- a/lib/classes/module/console/tasklist.class.php +++ b/lib/classes/module/console/tasklist.class.php @@ -42,7 +42,7 @@ class module_console_tasklist extends Command throw new RuntimeException('Phraseanet is not set up'); } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $appbox = appbox::get_instance(); $task_manager = new task_manager($appbox); diff --git a/lib/classes/module/console/taskrun.class.php b/lib/classes/module/console/taskrun.class.php index 6e22d6fd24..da62654ed0 100644 --- a/lib/classes/module/console/taskrun.class.php +++ b/lib/classes/module/console/taskrun.class.php @@ -50,7 +50,7 @@ class module_console_taskrun extends Command throw new RuntimeException('Phraseanet is not set up'); } - require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + require_once __DIR__ . '/../../../../lib/bootstrap.php'; $task_id = (int) $input->getArgument('task_id'); diff --git a/lib/classes/patch/320aa.class.php b/lib/classes/patch/320aa.class.php index a3b28f1fe6..5468abc4d5 100644 --- a/lib/classes/patch/320aa.class.php +++ b/lib/classes/patch/320aa.class.php @@ -54,9 +54,9 @@ class patch_320aa implements patchInterface function apply(base &$appbox) { - if(is_file(dirname(__FILE__) . '/../../../config/_GV.php')) - require dirname(__FILE__) . '/../../../config/_GV.php'; - require dirname(__FILE__) . '/../../../lib/conf.d/_GV_template.inc'; + if(is_file(__DIR__ . '/../../../config/_GV.php')) + require __DIR__ . '/../../../config/_GV.php'; + require __DIR__ . '/../../../lib/conf.d/_GV_template.inc'; define('GV_STATIC_URL', ''); define('GV_sphinx', false); diff --git a/lib/classes/phrasea.class.php b/lib/classes/phrasea.class.php index 70b22feae2..e4d3a54c9f 100644 --- a/lib/classes/phrasea.class.php +++ b/lib/classes/phrasea.class.php @@ -105,7 +105,7 @@ class phrasea public static function start() { - require (dirname(__FILE__) . '/../../config/connexion.inc'); + require (__DIR__ . '/../../config/connexion.inc'); if (!extension_loaded('phrasea2')) printf("Missing Extension php-phrasea"); @@ -269,12 +269,6 @@ class phrasea return $user->ACL()->get_granted_base() > 0; } - public static function load_events() - { - $events = eventsmanager_broker::getInstance(appbox::get_instance()); - $events->start(); - } - public static function use_i18n($locale, $textdomain = 'phraseanet') { $codeset = "UTF-8"; @@ -283,7 +277,7 @@ class phrasea putenv('LANGUAGE=' . $locale . '.' . $codeset); bind_textdomain_codeset($textdomain, 'UTF-8'); - bindtextdomain($textdomain, dirname(__FILE__) . '/../../locale/'); + bindtextdomain($textdomain, __DIR__ . '/../../locale/'); setlocale(LC_ALL , $locale . '.UTF-8' , $locale . '.UTF8' @@ -497,7 +491,7 @@ class phrasea else { $request->set_code($code); - include(dirname(__FILE__) . '/../../www/include/error.php'); + include(__DIR__ . '/../../www/include/error.php'); } die(); break; diff --git a/lib/classes/record/Interface.class.php b/lib/classes/record/Interface.class.php index 1730c36fe7..a97c859d17 100644 --- a/lib/classes/record/Interface.class.php +++ b/lib/classes/record/Interface.class.php @@ -97,8 +97,6 @@ interface record_Interface public function get_reg_name(); - public function get_bitly_link(); - 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 22bf8b7514..bd039fbc82 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -479,23 +479,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ public function move_to_collection(collection &$collection, appbox &$appbox) { - $sql = 'UPDATE sselcont - SET base_id = :base_id - WHERE record_id = :record_id - AND base_id IN (SELECT base_id FROM bas WHERE sbas_id = :sbas_id)'; - - $params = array( - ':base_id' => $collection->get_base_id(), - ':record_id' => $this->get_record_id(), - ':sbas_id' => $this->get_sbas_id() - ); - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $stmt->closeCursor(); - - basket_adapter::revoke_baskets_record($this, $appbox); - $sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id"; $params = array( @@ -880,9 +863,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface $titles = array(); foreach ($retrieved_fields as $key => $value) { - if (trim($value === '')) + if (trim($value['value'] === '')) continue; - $titles[] = $value; + $titles[] = $value['value']; } $title = trim(implode(' - ', $titles)); } @@ -1047,7 +1030,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface $base_url = ''; $original_file = $subdef_def = false; - $subdefs = $this->get_databox()->get_subdef_structure(); foreach ($subdefs as $type => $datas) @@ -1068,7 +1050,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface try { $value = $this->get_subdef($name); - $original_file = p4string::addEndSlash($value['path']) . $value['file']; + + if ($value->is_substituted()) + { + throw new Exception('Cannot replace a substitution'); + } + + $original_file = p4string::addEndSlash($value->get_path()) . $value->get_file(); unlink($original_file); } catch (Exception $e) @@ -1083,7 +1071,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface if (trim($subdef_def->get_baseurl()) !== '') { $base_url = str_replace( - array((string) $subdef_def->get_path(), $newfilename), array((string) $subdef_def->get_baseurl(), ''), $path_file_dest + array((string) $subdef_def->get_path(), $newfilename) + , array((string) $subdef_def->get_baseurl(), '') + , $path_file_dest ); } @@ -1093,7 +1083,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->record_id, ':name' => $name)); + $stmt->execute( + array( + ':record_id' => $this->record_id + , ':name' => $name + ) + ); $registry = registry::get_instance(); @@ -1128,7 +1123,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id'; $stmt = $connbas->prepare($sql); - $stmt->bindParam(':record_id', $this->get_record_id()); + $stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(); $this->delete_data_from_cache(self::CACHE_SUBDEFS); @@ -1381,54 +1376,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface return $regname; } - /** - * - * @return string - */ - public function get_bitly_link() - { - - $registry = registry::get_instance(); - - if ($this->bitly_link !== null) - return $this->bitly_link; - - $this->bitly_link = false; - - if (trim($registry->get('GV_bitly_user')) == '' - && trim($registry->get('GV_bitly_key')) == '') - return $this->bitly_link; - - try - { - $short = new PHPShortener(); - $bitly = $short->encode($url . 'view/', 'bit.ly', $registry); - - if (preg_match('/^(http:\/\/)?(www\.)?([^\/]*)\/(.*)$/', $bitly, $results)) - { - if ($results[3] && $results[4]) - { - $hash = 'http://bit.ly/' . $results[4]; - $sql = 'UPDATE record SET bitly = :hash WHERE record_id = :record_id'; - - $connbas = connection::getPDOConnection($this->get_sbas_id()); - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':hash' => $hash, ':record_id' => $this->get_record_id())); - $stmt->closeCursor(); - - $this->bitly_link = 'http://bit.ly/' . $hash; - } - } - } - catch (Exception $e) - { - unset($e); - } - $this->delete_data_from_cache(); - - return $this->bitly_link; - } - /** * * @param collection $collection @@ -1714,21 +1661,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface $stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->closeCursor(); - $sql = 'SELECT s.ssel_id, c.sselcont_id, s.usr_id - FROM sselcont c, ssel s - WHERE c.base_id = :base_id AND c.record_id = :record_id - AND s.ssel_id = c.ssel_id'; - $stmt = $conn->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id(), ':base_id' => $this->get_base_id())); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); + $em = bootstrap::getCore()->getEntityManager(); - foreach ($rs as $row) + $repository = $em->getRepository('\Entities\BasketElement'); + + /* @var $repository \Repositories\BasketElementRepository */ + foreach ($repository->findElementsByRecord($this) as $basket_element) { - $basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $row['usr_id']); - $basket->remove_from_ssel($row['sselcont_id']); + $em->remove($basket_element); } - $stmt->closeCursor(); + $em->flush(); foreach ($ftodel as $f) @unlink($f); @@ -1935,37 +1878,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ public function get_container_baskets() { - if ($this->container_basket) - return $this->container_basket; + $Core = bootstrap::getCore(); + $em = $Core->getEntityManager(); - $appbox = appbox::get_instance(); - $session = $appbox->get_session(); + $repo = $em->getRepository('\Entities\Basket'); - $baskets = array(); - $sql = 'SELECT s.ssel_id FROM ssel s, sselcont c - WHERE s.ssel_id = c.ssel_id - AND c.base_id = :base_id AND record_id = :record_id - AND usr_id = :usr_id AND temporaryType="0"'; - - $params = array( - ':base_id' => $this->get_base_id() - , ':record_id' => $this->get_record_id() - , ':usr_id' => $session->get_usr_id() - ); - - $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute($params); - $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - foreach ($rs as $row) - { - $baskets[$row['ssel_id']] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id()); - } - - $this->container_basket = $baskets; - - return $this->container_basket; + /* @var $$repo \Repositories\BasketRepository */ + return $repo->findContainingRecord($this); } /** diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index 5f5cf88dc2..bcf7ee2893 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -89,6 +89,7 @@ class record_preview extends record_adapter public function __construct($env, $pos, $contId, $reload_train, searchEngine_adapter $search_engine =null, $query='') { $appbox = appbox::get_instance(); + $Core = bootstrap::getCore(); $number = null; $this->env = $env; @@ -112,8 +113,7 @@ class record_preview extends record_adapter break; case "REG": $contId = explode('_', $contId); - $base_id = $contId[0]; - $sbas_id = phrasea::sbasFromBas($base_id); + $sbas_id = $contId[0]; $record_id = $contId[1]; $this->container = new record_adapter($sbas_id, $record_id); @@ -139,37 +139,42 @@ class record_preview extends record_adapter break; case "BASK": - $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id()); + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + $Basket = $repository->findUserBasket($contId, $Core->getAuthenticatedUser()); - $this->container = $basket; - $this->total = count($basket->get_elements()); + /* @var $Basket \Entities\Basket */ + $this->container = $Basket; + $this->total = $Basket->getElements()->count(); $i = 0; $first = true; - foreach ($basket->get_elements() as $element) + foreach ($Basket->getElements() as $element) { + /* @var $element \Entities\BasketElement */ $i++; if ($first) { - $sbas_id = $element->get_record()->get_sbas_id(); - $record_id = $element->get_record()->get_record_id(); - $this->name = $basket->get_name(); - $number = $element->get_order(); + $sbas_id = $element->getRecord()->get_sbas_id(); + $record_id = $element->getRecord()->get_record_id(); + $this->name = $Basket->getName(); + $number = $element->getOrd(); } $first = false; - if ($element->get_order() == $pos) + if ($element->getOrd() == $pos) { - $sbas_id = $element->get_record()->get_sbas_id(); - $record_id = $element->get_record()->get_record_id(); - $this->name = $basket->get_name(); - $number = $element->get_order(); + $sbas_id = $element->getRecord()->get_sbas_id(); + $record_id = $element->getRecord()->get_record_id(); + $this->name = $Basket->getName(); + $number = $element->getOrd(); } } break; case "FEED": $entry = Feed_Entry_Adapter::load_from_id($appbox, $contId); -// $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id()); $this->container = $entry; $this->total = count($entry->get_content()); @@ -219,7 +224,7 @@ class record_preview extends record_adapter $this->train = $results->get_datas(); break; case 'BASK': - $this->train = $this->container->get_elements(); + $this->train = $this->container->getElements(); break; case 'REG': $this->train = $this->container->get_children(); diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index e8c13dfd3b..ada342d04d 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -41,7 +41,7 @@ class registry implements registryInterface */ public static function get_instance() { - $prefix = crc32(dirname(__FILE__)); + $prefix = crc32(__DIR__); if (!self::$_instance instanceof self) self::$_instance = new self(new cache_opcode_adapter($prefix)); @@ -57,8 +57,8 @@ class registry implements registryInterface { $this->cache = $cache; - require dirname(__FILE__) . '/../../config/config.inc'; - $this->cache->set('GV_RootPath', dirname(dirname(dirname(__FILE__))) . '/'); + require __DIR__ . '/../../config/config.inc'; + $this->cache->set('GV_RootPath', dirname(dirname(__DIR__)) . '/'); $this->cache->set('GV_ServerName', p4string::addEndSlash($servername)); $this->cache->set('GV_debug', !!$debug); $this->cache->set('GV_maintenance', !!$maintenance); diff --git a/lib/classes/searchEngine/adapter/phrasea/engine.class.php b/lib/classes/searchEngine/adapter/phrasea/engine.class.php index 965eb33c4a..416f5f0446 100644 --- a/lib/classes/searchEngine/adapter/phrasea/engine.class.php +++ b/lib/classes/searchEngine/adapter/phrasea/engine.class.php @@ -639,9 +639,20 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract foreach ($fields as $name => $field) { if ($sxe->description->$name) - $ret[] = str_replace(array('[[em]]', '[[/em]]'), array('', ''), (string) $sxe->description->$name); + { + $val = array(); + foreach($sxe->description->$name as $value) + { + $val[] = str_replace(array('[[em]]', '[[/em]]'), array('', ''), (string) $value); + } + $val = implode(' '.$field['separator'].' ', $val); + } else - $ret[] = $field; + { + $val = $field['value']; + } + + $ret[] = $val; } return $ret; diff --git a/lib/classes/searchEngine/adapter/sphinx/engine.class.php b/lib/classes/searchEngine/adapter/sphinx/engine.class.php index 29b2c72346..ffec0529b3 100644 --- a/lib/classes/searchEngine/adapter/sphinx/engine.class.php +++ b/lib/classes/searchEngine/adapter/sphinx/engine.class.php @@ -1,6 +1,6 @@ "", 'after_match' => "" ); + + $fields_to_send = array(); + + foreach($fields as $k=>$f) + { + $fields_to_send[$k] = $f['value']; + } - return $this->sphinx->BuildExcerpts($fields, $index, $query, $opts); + return $this->sphinx->BuildExcerpts($fields_to_send, $index, $query, $opts); } } diff --git a/lib/classes/set/export.class.php b/lib/classes/set/export.class.php index 02f7f94601..6aa6c29aa9 100644 --- a/lib/classes/set/export.class.php +++ b/lib/classes/set/export.class.php @@ -36,25 +36,31 @@ class set_export extends set_abstract */ public function __construct($lst, $sstid) { + $Core = bootstrap::getCore(); + $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); - - $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); - + $user = $Core->getAuthenticatedUser(); + $download_list = array(); $remain_hd = array(); if ($sstid != "") { - $basket = basket_adapter::getInstance($appbox, $sstid, $user->get_id()); + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + $Basket = $repository->findUserBasket($sstid, $user); - foreach ($basket->get_elements() as $basket_element) + foreach ($Basket->getElements() as $basket_element) { - $base_id = $basket_element->get_record()->get_base_id(); - $record_id = $basket_element->get_record()->get_record_id(); + /* @var $basket_element \Entities\BasketElement */ + $base_id = $basket_element->getRecord()->get_base_id(); + $record_id = $basket_element->getRecord()->get_record_id(); if (!isset($remain_hd[$base_id])) { @@ -70,9 +76,9 @@ class set_export extends set_abstract $current_element = $download_list[] = new record_exportElement( - $basket_element->get_record()->get_sbas_id(), + $basket_element->getRecord()->get_sbas_id(), $record_id, - $basket->get_name() . '/', + $basket->getName() . '/', $remain_hd[$base_id] ); @@ -950,7 +956,7 @@ class set_export extends set_abstract public static function stream_file( $file, $exportname, $mime, $disposition='attachment') { - require_once dirname(__FILE__) . "/../../../lib/vendor/Silex/autoload.php"; + require_once __DIR__ . "/../../../lib/vendor/Silex/autoload.php"; $registry = registry::get_instance(); $disposition = in_array($disposition, array('inline', 'attachment')) ? diff --git a/lib/classes/set/exportorder.class.php b/lib/classes/set/exportorder.class.php index 9094fa70c0..975f4c9abc 100644 --- a/lib/classes/set/exportorder.class.php +++ b/lib/classes/set/exportorder.class.php @@ -27,6 +27,8 @@ class set_exportorder extends set_export */ public function order_available_elements($from_usr_id, $usage, $deadline) { + $Core = bootstrap::getCore(); + $lst = $this->get_orderable_lst(); $conn = connection::getPDOConnection(); @@ -89,7 +91,7 @@ class set_exportorder extends set_export return false; } - $evt_mngr = eventsmanager_broker::getInstance(appbox::get_instance()); + $evt_mngr = eventsmanager_broker::getInstance(appbox::get_instance(), $Core); $params = array( 'order_id' => $order_id, diff --git a/lib/classes/set/order.class.php b/lib/classes/set/order.class.php index 1c7f93104d..327f0d0bed 100644 --- a/lib/classes/set/order.class.php +++ b/lib/classes/set/order.class.php @@ -219,19 +219,29 @@ class set_order extends set_abstract } } - try + $core = \bootstrap::getCore(); + + $em = $core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + $Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser()); + + if(!$Basket) { - $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $session->get_usr_id()); - } - catch (Exception $e) - { - $basket = basket_adapter::create($appbox, sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')), $this->user, '', $pusher); - - $this->ssel_id = $basket->get_ssel_id(); - + $Basket = new Basket(); + $Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d'))); + $Basket->setOwner($this->user); + $Basket->setPusher($core->getAuthenticatedUser()); + + $em->persist($Basket); + $em->flush(); + + $this->ssel_id = $Basket->getId(); + $sql = 'UPDATE `order` SET ssel_id = :ssel_id WHERE id = :order_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':ssel_id' => $basket->get_ssel_id(), ':order_id' => $this->id)); + $stmt->execute(array(':ssel_id' => $Basket->getId(), ':order_id' => $this->id)); $stmt->closeCursor(); } @@ -254,20 +264,28 @@ class set_order extends set_abstract { $sbas_id = phrasea::sbasFromBas($basrec['base_id']); $record = new record_adapter($sbas_id, $basrec['record_id']); - $ret = $basket->push_element($record, false, false); - if ($ret['error'] === false) - { - $params = array( - ':usr_id' => $session->get_usr_id() - , ':order_id' => $this->id - , ':order_element_id' => $order_element_id - ); + + $BasketElement = new 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 + , ':order_element_id' => $order_element_id + ); - $stmt->execute($params); + $stmt->execute($params); - $n++; - $this->user->ACL()->grant_hd_on($record, $pusher, 'order'); - } + $n++; + $this->user->ACL()->grant_hd_on($record, $pusher, 'order'); + unset($record); } catch (Exception $e) @@ -275,11 +293,13 @@ class set_order extends set_abstract } } + + $em->flush(); $stmt->closeCursor(); if ($n > 0) { - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $core); $params = array( 'ssel_id' => $this->ssel_id, @@ -301,6 +321,7 @@ class set_order extends set_abstract */ public function deny_elements(Array $elements_ids) { + $Core = bootstrap::getCore(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); $conn = $appbox->get_connection(); @@ -328,7 +349,7 @@ class set_order extends set_abstract if ($n > 0) { - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $params = array( 'from' => $session->get_usr_id(), diff --git a/lib/classes/set/selection.class.php b/lib/classes/set/selection.class.php index ce5a6ae235..f257649f47 100644 --- a/lib/classes/set/selection.class.php +++ b/lib/classes/set/selection.class.php @@ -31,21 +31,14 @@ class set_selection extends set_abstract /** * - * @param basket_adapter $basket - * @param boolean $flatten_if_grouping + * @param \Entities\Basket $basket * @return set_selection */ - public function load_basket(basket_adapter $basket, $flatten_if_grouping = true) + public function load_basket(\Entities\Basket $Basket) { - if ($basket->is_grouping() && !$flatten_if_grouping) + foreach ($Basket->getElements() as $basket_element) { - $record = new record_adapter($basket->get_sbas_id(), $basket->get_record_id(), count($this->elements)); - $this->add_element($record); - } - else - { - foreach ($basket->get_elements() as $basket_element) - $this->add_element($basket_element->get_record()); + $this->add_element($basket_element->getRecord()); } return $this; diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php index f906ed0f67..1337281771 100644 --- a/lib/classes/setup.class.php +++ b/lib/classes/setup.class.php @@ -68,13 +68,13 @@ class setup public static function is_installed() { - return file_exists(dirname(__FILE__) . "/../../config/connexion.inc") - && file_exists(dirname(__FILE__) . "/../../config/config.inc"); + return file_exists(__DIR__ . "/../../config/connexion.inc") + && file_exists(__DIR__ . "/../../config/config.inc"); } function create_global_values(registryInterface &$registry, $datas=array()) { - require(dirname(__FILE__) . "/../../lib/conf.d/_GV_template.inc"); + require(__DIR__ . "/../../lib/conf.d/_GV_template.inc"); if ($registry->is_set('GV_timezone')) @@ -257,12 +257,12 @@ class setup { if (system_server::get_platform() == 'WINDOWS') { - $exiftool = dirname(dirname(__FILE__)) . '/vendor/exiftool/exiftool.exe'; - $indexer = dirname(dirname(dirname(__FILE__))) . '/bin/phraseanet_indexer.exe'; + $exiftool = dirname(__DIR__) . '/vendor/exiftool/exiftool.exe'; + $indexer = dirname(dirname(__DIR__)) . '/bin/phraseanet_indexer.exe'; } else { - $exiftool = dirname(dirname(__FILE__)) . '/vendor/exiftool/exiftool'; + $exiftool = dirname(__DIR__) . '/vendor/exiftool/exiftool'; $indexer = null; } @@ -453,7 +453,7 @@ class setup public static function check_writability(registryInterface $registry) { - $root = p4string::addEndSlash(realpath(dirname(__FILE__) . '/../../')); + $root = p4string::addEndSlash(realpath(__DIR__ . '/../../')); $pathes = array( $root . 'config', @@ -765,17 +765,17 @@ class setup public static function get_config_filepath() { - return dirname(__FILE__) . '/../../config/config.inc'; + return __DIR__ . '/../../config/config.inc'; } public static function get_connexion_filepath() { - return dirname(__FILE__) . '/../../config/connexion.inc'; + return __DIR__ . '/../../config/connexion.inc'; } public static function rollback(connection_pdo $conn, connection_pdo $connbas =null) { - $structure = simplexml_load_file(dirname(__FILE__) . "/../../lib/conf.d/bases_structure.xml"); + $structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml"); if (!$structure) throw new Exception('Unable to load schema'); @@ -814,7 +814,7 @@ class setup } } } - $connexion = dirname(__FILE__) . "/../../config/connexion.inc"; + $connexion = __DIR__ . "/../../config/connexion.inc"; if (file_exists($connexion)) unlink($connexion); diff --git a/lib/classes/sphinx/configuration.class.php b/lib/classes/sphinx/configuration.class.php index b2d1278466..92d9d43607 100644 --- a/lib/classes/sphinx/configuration.class.php +++ b/lib/classes/sphinx/configuration.class.php @@ -37,7 +37,7 @@ class sphinx_configuration public function get_available_charsets() { $available_charsets = array(); - $dir = dirname(__FILE__) . '/charsetTable/'; + $dir = __DIR__ . '/charsetTable/'; echo $dir; $registry = registry::get_instance(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) diff --git a/lib/classes/supertwig.class.php b/lib/classes/supertwig.class.php index 8c3ddc9c5c..ad1c415606 100644 --- a/lib/classes/supertwig.class.php +++ b/lib/classes/supertwig.class.php @@ -111,6 +111,7 @@ class supertwig $this->addFilter(array('round' => 'round')); $this->addFilter(array('nl2br' => 'nl2br')); $this->addFilter(array('prettyString' => 'phraseadate::getPrettyString')); + $this->addFilter(array('get_collection_logo' => 'collection::getLogo')); } catch (Exception $e) { @@ -249,6 +250,7 @@ class supertwig } $core = bootstrap::getCore(); + $eventsmanager = eventsmanager_broker::getInstance($appbox, $core); $this->default_vars = array( 'session' => $session, @@ -257,6 +259,7 @@ class supertwig 'core' => $core, 'browser' => $browser, 'request' => $request, + 'events' => $eventsmanager, 'display_chrome_frame' => $registry->is_set('GV_display_gcf') ? $registry->get('GV_display_gcf') : true, 'user' => $user, 'current_date' => new DateTime(), diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index 782879a89b..207f6eaa47 100644 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -45,14 +45,14 @@ class task_Scheduler protected static function get_connection() { - require dirname(__FILE__) . '/../../../config/connexion.inc'; + require __DIR__ . '/../../../config/connexion.inc'; return new connection_pdo('appbox', $hostname, $port, $user, $password, $dbname); } public function run(OutputInterface $output = null, $log_tasks = true) { - require_once dirname(__FILE__) . '/../../bootstrap.php'; + require_once __DIR__ . '/../../bootstrap.php'; $this->output = $output; $appbox = appbox::get_instance(); $registry = $appbox->get_registry(); @@ -108,11 +108,16 @@ class task_Scheduler foreach ($task_manager->get_tasks() as $task) { if (!$task->is_active()) + { continue; + } + $tid = $task->get_task_id(); if (!$task->is_running()) { + /* @var $task task_abstract */ + $task->reset_crash_counter(); $task->set_status(task_abstract::STATUS_TOSTART); } } diff --git a/lib/classes/task/appboxAbstract.class.php b/lib/classes/task/appboxAbstract.class.php index d33fc86554..80344bea4c 100644 --- a/lib/classes/task/appboxAbstract.class.php +++ b/lib/classes/task/appboxAbstract.class.php @@ -38,8 +38,9 @@ abstract class task_appboxAbstract extends task_abstract $this->log(("Warning : abox connection lost, restarting in 10 min.")); sleep(60 * 10); $this->running = false; + $this->return_value = self::RETURNSTATUS_TORESTART; - return(''); + return; } $this->set_last_exec_time(); @@ -85,7 +86,7 @@ abstract class task_appboxAbstract extends task_abstract $this->pause($duration); } - return($this->return_value); + return; } /** diff --git a/lib/classes/task/databoxAbstract.class.php b/lib/classes/task/databoxAbstract.class.php index f0559140d0..6049b7a48b 100644 --- a/lib/classes/task/databoxAbstract.class.php +++ b/lib/classes/task/databoxAbstract.class.php @@ -46,8 +46,9 @@ abstract class task_databoxAbstract extends task_abstract $this->log(("Warning : abox connection lost, restarting in 10 min.")); sleep(60 * 10); $this->running = false; + $this->return_value = self::RETURNSTATUS_TORESTART; - return(''); + return; } $this->set_last_exec_time(); @@ -104,7 +105,7 @@ abstract class task_databoxAbstract extends task_abstract $this->pause($duration); } - return($this->return_value); + return; } /** diff --git a/lib/classes/task/manager.class.php b/lib/classes/task/manager.class.php index 6c5c69ad37..51767999d7 100644 --- a/lib/classes/task/manager.class.php +++ b/lib/classes/task/manager.class.php @@ -112,5 +112,44 @@ class task_manager return $row; } + + public static function getAvailableTasks() + { + $registry = registry::get_instance(); + $taskdir = array( $registry->get('GV_RootPath') . "lib/classes/task/period/" + , $registry->get('GV_RootPath') . "config/classes/task/period/" + ); + $tasks = array(); + foreach($taskdir as $path) + { + if( ($hdir = @opendir($path)) ) + { + $tskin = array(); + $max = 9999; + while (($max-- > 0) && (($file = readdir($hdir)) !== false)) + { + if (!is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php") + continue; + + $classname = 'task_period_' . substr($file, 0, strlen($file) - 10); + + try + { + // $testclass = new $classname(null); + if ($classname::interfaceAvailable()) + { + $tasks[] = array("class" => $classname, "name" => $classname::getName(), "err" => null); + } + } + catch (Exception $e) + { + + } + } + closedir($hdir); + } + } + return $tasks; + } } diff --git a/lib/classes/task/period/apibridge.class.php b/lib/classes/task/period/apibridge.class.php index 998cd15f9d..611a081e32 100644 --- a/lib/classes/task/period/apibridge.class.php +++ b/lib/classes/task/period/apibridge.class.php @@ -145,6 +145,7 @@ class task_period_apibridge extends task_appboxAbstract */ protected function update_element(Bridge_Element &$element) { + $Core = bootstrap::getCore(); $account = $element->get_account(); $connector_status = $account->get_api()->get_element_status($element); @@ -176,7 +177,7 @@ class task_period_apibridge extends task_appboxAbstract , 'sbas_id' => $element->get_record()->get_sbas_id() , 'record_id' => $element->get_record()->get_record_id() ); - $events_mngr = eventsmanager_broker::getInstance(appbox::get_instance()); + $events_mngr = eventsmanager_broker::getInstance(appbox::get_instance(), $Core); $events_mngr->trigger('__BRIDGE_UPLOAD_FAIL__', $params); break; diff --git a/lib/classes/task/period/upgradetov32.class.php b/lib/classes/task/period/upgradetov32.class.php index f61cd25c65..7d365b2a74 100644 --- a/lib/classes/task/period/upgradetov32.class.php +++ b/lib/classes/task/period/upgradetov32.class.php @@ -67,8 +67,8 @@ class task_period_upgradetov32 extends task_abstract if (!$this->sbas_id) { printf("sbas_id '" . $this->sbas_id . "' invalide\n"); - - return 'stopped'; + $this->return_value = self::RETURNSTATUS_STOPPED; + return; } try @@ -78,6 +78,8 @@ class task_period_upgradetov32 extends task_abstract } catch (Exception $e) { + $this->return_value = self::RETURNSTATUS_STOPPED; + return; } @@ -94,6 +96,7 @@ class task_period_upgradetov32 extends task_abstract catch (Exception $e) { printf("Please verify all your databox meta fields before migrating, It seems somes are wrong\n"); + $this->return_value = self::RETURNSTATUS_STOPPED; return 'stopped'; } @@ -194,7 +197,7 @@ class task_period_upgradetov32 extends task_abstract $sql = 'select record_id, coll_id, xml, BIN(status) as status FROM record - WHERE record_id NOT IN (select distinct record_id from technical_datas) + WHERE migrated="0" AND record_id NOT IN (select distinct record_id from technical_datas) LIMIT 0, 500'; $stmt = $connbas->prepare($sql); @@ -238,7 +241,7 @@ class task_period_upgradetov32 extends task_abstract } catch (Exception $e) { - + } } @@ -280,9 +283,6 @@ class task_period_upgradetov32 extends task_abstract { $record = new record_adapter($this->sbas_id, $row['record_id']); - -// $sbas_id = $this->sbas_id; - $metas = $databox->get_meta_structure(); $metadatas = array(); @@ -367,12 +367,16 @@ class task_period_upgradetov32 extends task_abstract $memory = memory_get_usage() >> 20; if ($n_done >= 5000) - - return task_abstract::RETURNSTATUS_TORESTART; + { + $this->return_value = task_abstract::RETURNSTATUS_TORESTART; + return; + } if ($memory > 100) - - return task_abstract::RETURNSTATUS_TORESTART; - } + { + $this->return_value = task_abstract::RETURNSTATUS_TORESTART; + return; + } + } catch (Exception $e) { @@ -393,8 +397,6 @@ class task_period_upgradetov32 extends task_abstract $conn = connection::getPDOConnection(); - $ret = 'stopped'; - printf("taskid %s ending." . PHP_EOL, $this->get_task_id()); sleep(1); printf("good bye world I was task upgrade to version 3.2" . PHP_EOL); @@ -406,11 +408,12 @@ class task_period_upgradetov32 extends task_abstract $stmt->closeCursor(); $this->setProgress(0, 0); - $ret = 'todelete'; - + + $this->return_value = self::RETURNSTATUS_TODELETE; + flush(); - return $ret; + return; } } diff --git a/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml b/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml index 8c07f0c891..1ec3141289 100644 --- a/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml +++ b/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml @@ -1,5 +1,6 @@ Entities\BasketElement: type: entity + repositoryClass: Repositories\BasketElementRepository table: BasketElements uniqueConstraints: unique_recordcle: diff --git a/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml index 019a2688ca..bf9bbe799a 100644 --- a/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml +++ b/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml @@ -9,8 +9,10 @@ Entities\ValidationData: fields: agreement: type: boolean + nullable: true note: type: text + nullable: true updated: type: datetime gedmo: @@ -19,7 +21,7 @@ Entities\ValidationData: manyToOne: participant: targetEntity: ValidationParticipant - inversedBy: datases + inversedBy: datas joinColumn: name: participant_id referencedColumnName: id diff --git a/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml index f5a499051d..cc0038ecf4 100644 --- a/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml +++ b/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml @@ -12,8 +12,17 @@ Entities\ValidationParticipant: type: integer is_aware: type: boolean + is_confirmed: + type: boolean + can_agree: + type: boolean + can_see_others: + type: boolean + reminded: + type: datetime + nullable: true; oneToMany: - datases: + datas: targetEntity: ValidationData mappedBy: participant cascade: ["ALL"] diff --git a/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml index 38c677fe58..1c3c901c27 100644 --- a/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml +++ b/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml @@ -21,9 +21,7 @@ Entities\ValidationSession: on: update expires: type: datetime - reminded: - type: datetime - nullable: true; + nullable: true oneToOne: basket: targetEntity: Basket diff --git a/lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php b/lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php new file mode 100644 index 0000000000..2224bcc632 --- /dev/null +++ b/lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php @@ -0,0 +1,56 @@ +setName('test ' . $i); + $basket->setDescription('description'); + + if (null === $this->user) + { + throw new \LogicException('Fill a user to store a new basket'); + } + + $basket->setOwner($this->user); + + $manager->persist($basket); + + $this->baskets[] = $basket; + } + $this->addReference('five-basket', $basket); + $manager->flush(); + } + +} \ No newline at end of file diff --git a/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php index d28efd4d07..187be190ad 100644 --- a/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php +++ b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php @@ -104,7 +104,7 @@ class LoadOneBasketEnv extends \PhraseaFixture\AbstractWZ implements FixtureInte { $validationParticipant = new \Entities\ValidationParticipant(); - $validationParticipant->setParticipant($participant); + $validationParticipant->setUser($participant); $validationParticipant->setSession($validationSession); diff --git a/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php b/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php index 13a11a0078..a4ca44b00a 100644 --- a/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php +++ b/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php @@ -43,7 +43,7 @@ class LoadParticipantWithSession extends \PhraseaFixture\AbstractWZ implements F { throw new \LogicException('Fill a user to store a new validation Session'); } - $validationParticipant->setParticipant($this->user); + $validationParticipant->setUser($this->user); if (null === $this->session) { diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 9e9ada3840..d210fcc941 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -19,8 +19,8 @@ foreach ($lngs as $lng => $locales) $avLanguages[$loc] = $locname['name']; } } - $eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance()); +$eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance(), bootstrap::getCore()); $PHP_CONF = array( 'output_buffering' => '4096' //INI_ALL diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index 702ceef86e..56efc01fbc 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -1349,16 +1349,6 @@ - - bas_manage - int(1) unsigned - - - - - 0 - - bas_modify_struct int(1) unsigned diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php new file mode 100644 index 0000000000..b24f2bc3a5 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/WorkZoneTest.php @@ -0,0 +1,168 @@ +client = $this->createClient(); + $this->purgeDatabase(); + } + + public function createApplication() + { + return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; + } + + public function testRootGet() + { + + $this->insertOneWZ(); + + $route = "/WorkZone/"; + + $this->client->request('GET', $route); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + } + + + public function testAttachStoryToWZ() + { + $story = self::$story_1; + /* @var $story \Record_Adapter */ + $route = sprintf("/WorkZone/attachStories/"); + try + { + $this->client->request('POST', $route); + $this->fail("we can attach none stories to WZ"); + } + catch (\Exception $e) + { + + } + + try + { + $this->client->request('POST', $route, array('stories'=> $story->get_serialize_key())); + + $response = $this->client->getResponse(); + } + catch (\Exception $e) + { + $this->fail($e->getMessage()); + } + + $this->assertEquals(302, $response->getStatusCode()); + + $em = self::$core->getEntityManager(); + /* @var $em \Doctrine\ORM\EntityManager */ + $query = $em->createQuery( + 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' + ); + + $count = $query->getSingleScalarResult(); + + $this->assertEquals(1, $count); + + $query = $em->createQuery( + 'SELECT w FROM \Entities\StoryWZ w' + ); + + $storyWZ = $query->getResult(); + $em->remove(array_shift($storyWZ)); + + $em->flush(); + + + //attach JSON + $this->client->request('POST', $route, array('stories'=> $story->get_serialize_key()), array(), array( + "HTTP_ACCEPT" => "application/json") + ); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + } + + public function testDetachStoryFromWZ() + { + $story = self::$story_1; + + $route = sprintf("/WorkZone/detachStory/%s/%s/", $story->get_sbas_id(), $story->get_record_id()); + //story not yet Attched + + try + { + $this->client->request('POST', $route); + $this->fail("Story should not be found"); + } + catch (\Exception $e) + { + + } + + //attach + $attachRoute = sprintf("/WorkZone/attachStories/"); + $this->client->request('POST', $attachRoute, array('stories'=> $story->get_serialize_key())); + + $query = self::$core->getEntityManager()->createQuery( + 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' + ); + + $count = $query->getSingleScalarResult(); + + $this->assertEquals(1, $count); + + + //detach + $this->client->request('POST', $route); + $response = $this->client->getResponse(); + $this->assertEquals(302, $response->getStatusCode()); + + $query = self::$core->getEntityManager()->createQuery( + 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' + ); + + $count = $query->getSingleScalarResult(); + + $this->assertEquals(0, $count); + + //attach + $this->client->request('POST', $attachRoute, array('stories'=> $story->get_serialize_key())); + + //detach JSON + $this->client->request('POST', $route, array(), array(), array( + "HTTP_ACCEPT" => "application/json") + ); + $response = $this->client->getResponse(); + $this->assertEquals(200, $response->getStatusCode()); + } +} \ No newline at end of file diff --git a/lib/unitTest/basketTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/basketTest.php similarity index 84% rename from lib/unitTest/basketTest.php rename to lib/unitTest/Alchemy/Phrasea/Controller/Prod/basketTest.php index 06a8e9f793..f134b673d5 100644 --- a/lib/unitTest/basketTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/basketTest.php @@ -9,10 +9,8 @@ * file that was distributed with this source code. */ -require_once __DIR__ . '/PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; +require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; -use Doctrine\Common\DataFixtures\Loader; -use PhraseaFixture\Basket as MyFixture; use Alchemy\Phrasea\Helper; use Alchemy\Phrasea\RouteProcessor as routeProcessor; @@ -26,29 +24,36 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract { protected $client; - protected $loader; protected static $need_records = 2; public function setUp() { parent::setUp(); $this->client = $this->createClient(); - $this->loader = new Loader(); + $this->purgeDatabase(); } public function createApplication() { - return require __DIR__ . '/../Alchemy/Phrasea/Application/Prod.php'; + return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; } public function testRootPost() { $route = '/baskets/'; + $records = array( + self::$record_1->get_serialize_key(), + self::$record_2->get_serialize_key() + ); + + $lst = implode(';', $records); + $this->client->request( 'POST', $route, array( 'name' => 'panier', - 'desc' => 'mon beau panier') + 'desc' => 'mon beau panier', + 'lst' => $lst) ); $response = $this->client->getResponse(); @@ -62,6 +67,15 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(1, $count); $this->assertEquals(302, $response->getStatusCode()); + + $query = self::$core->getEntityManager()->createQuery( + 'SELECT b FROM \Entities\Basket b' + ); + + + $basket = array_shift($query->getResult()); + /* @var $basket \Entities\Basket */ + $this->assertEquals(2, $basket->getElements()->count()); } public function testRootPostJSON() @@ -144,7 +158,7 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract $em->flush(); $route = sprintf( - "/baskets/%s/%s/delete/", $basket->getId(), $basket_element->getId() + "/baskets/%s/delete/%s/", $basket->getId(), $basket_element->getId() ); $crawler = $this->client->request('POST', $route); @@ -182,7 +196,7 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract $em->flush(); $route = sprintf( - "/baskets/%s/%s/delete/", $basket->getId(), $basket_element->getId() + "/baskets/%s/delete/%s/", $basket->getId(), $basket_element->getId() ); $crawler = $this->client->request( @@ -296,6 +310,25 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, $response->getStatusCode()); } + public function testReorderGet() + { + $basket = $this->insertOneBasketEnv(); + + $route = sprintf("/baskets/%s/reorder/", $basket->getId()); + + $crawler = $this->client->request("GET", $route); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + + foreach ($basket->getElements() as $elements) + { + $filter = sprintf("form[action='/prod/baskets/%s/reorder/']", $elements->getId()); + $this->assertEquals(1, $crawler->filter($filter)->count()); + } + } + public function testBasketUpdateGet() { $basket = $this->insertOneBasket(); @@ -453,7 +486,7 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(2, $basket->getElements()->count()); } - + /** * Test when i remove a basket, all relations are removed too : * - basket elements @@ -462,124 +495,48 @@ class basketTest extends PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRemoveBasket() { - $this->insertOneBasketEnv(); - + $basket = $this->insertOneBasketEnv(); + $em = self::$core->getEntityManager(); /* @var $em \Doctrine\ORM\EntityManager */ - $basket = $em->find("Entities\Basket", 1); - + $basket = $em->find("Entities\Basket", $basket->getId()); + $em->remove($basket); - + $em->flush(); - + $query = $em->createQuery( 'SELECT COUNT(v.id) FROM \Entities\ValidationParticipant v' ); $count = $query->getSingleScalarResult(); - + $this->assertEquals(0, $count); - + $query = $em->createQuery( 'SELECT COUNT(b.id) FROM \Entities\BasketElement b' ); $count = $query->getSingleScalarResult(); - + $this->assertEquals(0, $count); - + $query = $em->createQuery( 'SELECT COUNT(v.id) FROM \Entities\ValidationSession v' ); $count = $query->getSingleScalarResult(); - + $this->assertEquals(0, $count); - - + + $query = $em->createQuery( 'SELECT COUNT(b.id) FROM \Entities\Basket b' ); - + $count = $query->getSingleScalarResult(); $this->assertEquals(0, $count); - - } - - /** - * - * @return \Entities\Basket - */ - protected function insertOneBasket() - { - $basketFixture = new MyFixture\LoadOneBasket(); - - $basketFixture->setUser(self::$user); - - $this->loader->addFixture($basketFixture); - - $this->insertFixtureInDatabase($this->loader); - - $query = self::$core->getEntityManager()->createQuery( - 'SELECT COUNT(b.id) FROM \Entities\Basket b' - ); - - $count = $query->getSingleScalarResult(); - - $this->assertEquals(1, $count); - - return $basketFixture->basket; - } - - /** - * - * @return \Entities\Basket - */ - protected function insertOneBasketEnv() - { - $em = self::$core->getEntityManager(); - /* @var $em \Doctrine\ORM\EntityManager */ - - $basketFixture = new MyFixture\LoadOneBasketEnv(); - - $basketFixture->setUser(self::$user); - - $basketFixture->addParticipant(self::$user_alt1); - $basketFixture->addParticipant(self::$user_alt2); - - $basketFixture->addBasketElement(self::$record_1); - $basketFixture->addBasketElement(self::$record_2); - - $this->loader->addFixture($basketFixture); - - $this->insertFixtureInDatabase($this->loader); - - $query = $em->createQuery( - 'SELECT COUNT(b.id) FROM \Entities\Basket b' - ); - - $count = $query->getSingleScalarResult(); - - $this->assertEquals(1, $count); - - $query = $em->createQuery( - 'SELECT COUNT(v.id) FROM \Entities\ValidationParticipant v' - ); - - $count = $query->getSingleScalarResult(); - - $this->assertEquals(2, $count); - - $query = $em->createQuery( - 'SELECT COUNT(v.id) FROM \Entities\ValidationSession v' - ); - - $count = $query->getSingleScalarResult(); - - $this->assertEquals(1, $count); - - return $basketFixture->basket; } } \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Prod/storyTest.php b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/storyTest.php new file mode 100644 index 0000000000..a8c86388ae --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Prod/storyTest.php @@ -0,0 +1,233 @@ +client = $this->createClient(); + $this->purgeDatabase(); + } + + public function createApplication() + { + return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php'; + } + + public function testRootPost() + { + $route = "/story/"; + + $collections = self::$core->getAuthenticatedUser() + ->ACL() + ->get_granted_base(array('canaddrecord')); + + $collection = array_shift($collections); + + $crawler = $this->client->request( + 'POST', $route, array( + 'base_id' => $collection->get_base_id(), + 'name' => 'test story', + 'description' => 'test_description') + ); + + $response = $this->client->getResponse(); + + $this->assertEquals(302, $response->getStatusCode()); + + $query = self::$core->getEntityManager()->createQuery( + 'SELECT COUNT(w.id) FROM \Entities\StoryWZ w' + ); + + $count = $query->getSingleScalarResult(); + + $this->assertEquals(1, $count); + } + + public function testRootPostJSON() + { + $route = "/story/"; + + $collections = self::$core->getAuthenticatedUser() + ->ACL() + ->get_granted_base(array('canaddrecord')); + + $collection = array_shift($collections); + + $crawler = $this->client->request( + 'POST', $route, array( + 'base_id' => $collection->get_base_id(), + 'name' => 'test story', + 'description' => 'test_description'), array(), array( + "HTTP_ACCEPT" => "application/json") + ); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + } + + public function testCreateGet() + { + $route = "/story/create/"; + + $crawler = $this->client->request('GET', $route); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + + $filter = "form[action='/prod/story/']"; + $this->assertEquals(1, $crawler->filter($filter)->count()); + + $filter = "form[action='/prod/story/'] input[name='name']"; + $this->assertEquals(1, $crawler->filter($filter)->count()); + + $filter = "form[action='/prod/story/'] textarea[name='description']"; + $this->assertEquals(1, $crawler->filter($filter)->count()); + + $filter = "form[action='/prod/story/'] select[name='base_id']"; + $this->assertEquals(1, $crawler->filter($filter)->count()); + } + + public function testByIds() + { + $story = self::$story_1; + + $route = sprintf("/story/%d/%d/", $story->get_sbas_id(), $story->get_record_id()); + + $crawler = $this->client->request('GET', $route); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + } + + public function testAddElementsToStory() + { + $story = self::$story_1; + + $route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id()); + + $records = array( + self::$record_1->get_serialize_key(), + self::$record_2->get_serialize_key() + ); + + $lst = implode(';', $records); + + $crawler = $this->client->request('POST', $route, array('lst' => $lst)); + + $response = $this->client->getResponse(); + + $this->assertEquals(302, $response->getStatusCode()); + + $this->assertEquals(2, self::$story_1->get_children()->get_count()); + } + + public function testAddElementsToStoryJSON() + { + $story = self::$story_1; + + $route = sprintf("/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id()); + + $records = array( + self::$record_1->get_serialize_key(), + self::$record_2->get_serialize_key() + ); + + $lst = implode(';', $records); + + $crawler = $this->client->request('POST', $route, array('lst' => $lst) + , array(), array( + "HTTP_ACCEPT" => "application/json")); + + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + + $this->assertEquals(2, self::$story_1->get_children()->get_count()); + } + + public function testRemoveElementFromStory() + { + $story = self::$story_1; + + $records = array( + self::$record_1, + self::$record_2 + ); + + $totalRecords = count($records); + $n = 0; + foreach ($records as $record) + { + /* @var $record \record_adapter */ + $route = sprintf( + "/story/%s/%s/delete/%s/%s/" + , $story->get_sbas_id() + , $story->get_record_id() + , $record->get_sbas_id() + , $record->get_record_id() + ); + + if (($n % 2) === 0) + { + $crawler = $this->client->request('POST', $route); + + $response = $this->client->getResponse(); + + $this->assertEquals(302, $response->getStatusCode()); + } + else + { + $crawler = $this->client->request( + 'POST', $route, array(), array(), array( + "HTTP_ACCEPT" => "application/json") + ); + $response = $this->client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + } + $n++; + + $this->assertEquals($totalRecords - $n, self::$story_1->get_children()->get_count()); + } + } + + + + +} \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ApplicationTest.php b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ApplicationTest.php new file mode 100644 index 0000000000..00d4713628 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ApplicationTest.php @@ -0,0 +1,139 @@ +getNonExtendablePath(); + $this->assertTrue(is_array($paths)); + foreach ($paths as $path) + { + $this->assertTrue(is_array($path)); + foreach ($path as $key) + { + $this->assertTrue(is_string($key)); + } + } + } + + public function testGetConfFileFromEnvName() + { + $app = $this->getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile', 'getConfigurationFilePath') + ); + + $fileName = __DIR__ . '/confTestFiles/good.yml'; + + $app->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + new \SplFileObject($fileName) + ) + ); + $app->expects($this->any()) + ->method('getConfigurationFilePath') + ->will( + $this->returnValue( + __DIR__ . '/confTestFiles' + ) + ); + + $this->assertInstanceOf('SplFileObject', $app->getConfFileFromEnvName('oneenv')); + $this->assertInstanceOf('SplFileObject', $app->getConfFileFromEnvName(Application::EXTENDED_MAIN_KEYWORD)); + + try + { + $app->getConfFileFromEnvName('unknow_env'); + $this->fail('An exception shoud be raised'); + } + catch (\Exception $e) + { + + } + } + + public function testGetConfigurationFilePath() + { + $app = new Application(); + $this->assertTrue(is_string($app->getConfigurationFilePath())); + } + + public function testGetMainConfigurationFile() + { + $app = new Application(); + try + { + $this->assertInstanceOf('SplFileObject', $app->getMainConfigurationFile()); + } + catch(Exception $e) + { + $this->markTestSkipped('Config file config.yml is not present'); + } + } + + public function testGetConfFileExtension() + { + $app = new Application(); + $this->assertEquals('yml', $app->getConfFileExtension()); + } + + public function testIsExtended() + { + $app = new Application(); + + $testExtendedEnv = array('extends' => 'value'); + $testNonExtendedEnv = array('blabla' => 'blabla'); + + $this->assertTrue($app->isExtended($testExtendedEnv)); + $this->assertFalse($app->isExtended($testNonExtendedEnv)); + } + + public function testGetExtendedEnvName() + { + $app = new Application(); + $testExtendedEnv = array('extends' => 'value'); + $testNonExtendedEnv = array('blabla' => 'blabla'); + + $this->assertEquals('value', $app->getExtendedEnvName($testExtendedEnv)); + $this->assertNull($app->getExtendedEnvName($testNonExtendedEnv)); + } + +} diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php new file mode 100644 index 0000000000..e78fd3c115 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ConfigurationTest.php @@ -0,0 +1,174 @@ +getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile') + ); + + $fileName = __DIR__ . '/confTestFiles/good.yml'; + + $spec->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + new \SplFileObject($fileName) + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + $this->assertEquals($environnement, $configuration->getEnvironnement()); + $this->assertTrue($configuration->isInstalled()); + $this->assertInstanceOf( + 'Alchemy\Phrasea\Core\Configuration\Parameter' + , $configuration->getConfiguration() + ); + $this->assertFalse($configuration->isDebug()); + $this->assertFalse($configuration->displayErrors()); + $this->assertTrue(is_array($configuration->getPhraseanet())); + $this->assertTrue(is_array($configuration->getDoctrine())); + } + + public function testInstalled() + { + $spec = $this->getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile') + ); + + $spec->expects($this->any()) + ->method('getMainConfigurationFile') + ->will($this->throwException(new \Exception())); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + $this->assertFalse($configuration->isInstalled()); + $this->assertTrue(is_array($configuration->getPhraseanet())); + $this->assertTrue(is_array($configuration->getDoctrine())); + } + + public function testGetAvailableLogger() + { + $spec = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application'); + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + $availableLogger = $configuration->getAvailableDoctrineLogger(); + + $this->assertTrue(is_array($availableLogger)); + $this->assertContains('monolog', $availableLogger); + $this->assertContains('echo', $availableLogger); + } + + public function testGetHandler() + { + $spec = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application'); + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + $this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Handler', $configuration->getConfigurationHandler()); + } + + public function testSetHandler() + { + $spec = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application'); + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + $spec2 = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application'); + + $spec2->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + 'test' + ) + ); + + $newHandler = new Configuration\Handler($spec2, new Configuration\Parser\Yaml()); + + $configuration->setConfigurationHandler($newHandler); + + $this->assertEquals('test', $configuration->getConfigurationHandler()->getSpecification()->getMainConfigurationFile()); + } + + public function testBadDoctrineLogger() + { + $spec = $this->getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile') + ); + + $fileName = __DIR__ . '/confTestFiles/bad_doctrine_logger.yml'; + + $spec->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + new \SplFileObject($fileName) + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + try + { + $configuration->getDoctrine(); + $this->fail('An exception should be raised'); + } + catch(Exception $e) + { + + } + } +} \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/HandlerTest.php b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/HandlerTest.php new file mode 100644 index 0000000000..cc3a6293b7 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/HandlerTest.php @@ -0,0 +1,164 @@ +getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile') + ); + + $fileName = __DIR__ . '/confTestFiles/good.yml'; + + $spec->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + new \SplFileObject($fileName) + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Specification', $handler->getSpecification()); + } + + public function testGetParser() + { + $spec = $this->getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile') + ); + + $fileName = __DIR__ . '/confTestFiles/good.yml'; + + $spec->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + new \SplFileObject($fileName) + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Parser', $handler->getParser()); + } + + public function testRetrieveExtendedEnvFromFile() + { + + $handler = new Configuration\Handler(new Application(), new Configuration\Parser\Yaml()); + + $fileName = __DIR__ . '/confTestFiles/config_test.yml'; + $file = new \SplFileObject($fileName); + + $envs = $handler->retrieveExtendedEnvFromFile($file); + + $this->assertEquals(3, count($envs)); + } + + public function testRetrieveExtendedEnvFromFileNonExisting() + { + + $handler = new Configuration\Handler(new Application(), new Configuration\Parser\Yaml()); + + $fileName = __DIR__ . '/confTestFiles/extends_non_existing_file.yml'; + $file = new \SplFileObject($fileName); + + try + { + $envs = $handler->retrieveExtendedEnvFromFile($file); + $this->fail('An exception should have been raised'); + } + catch (Exception $e) + { + + } + } + + public function testHandle() + { + $spec = $this->getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getConfigurationFilePath') + ); + + $spec->expects($this->any()) + ->method('getConfigurationFilePath') + ->will( + $this->returnValue( + __DIR__ . '/confTestFiles' + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $result = $handler->handle('test'); + + $this->assertTrue(is_array($result)); + } + + public function testHandleDataNotfound() + { + $spec = $this->getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getConfigurationFilePath', 'getNonExtendablePath') + ); + + $spec->expects($this->any()) + ->method('getConfigurationFilePath') + ->will( + $this->returnValue( + __DIR__ . '/confTestFiles' + ) + ); + + $spec->expects($this->any()) + ->method('getNonExtendablePath') + ->will( + $this->returnValue( + array(array('NON', 'EXISTING', 'VALUE')) + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $result = $handler->handle('test'); + + $this->assertTrue(is_array($result)); + } + +} \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ParserTest.php b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ParserTest.php new file mode 100644 index 0000000000..32472aba86 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/ParserTest.php @@ -0,0 +1,64 @@ +parse($file); + + $this->assertTrue(is_array($result)); + + $filename = $fileName = __DIR__ . '/confTestFiles/test.json'; + + $file = new SplFileObject($filename); + + try + { + $result = $parser->parse($file); + $this->fail('An exception shoud have been raised'); + } + catch(Exception $e) + { + + } + + + } +} \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/bad_doctrine_logger.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/bad_doctrine_logger.yml new file mode 100644 index 0000000000..d715751e74 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/bad_doctrine_logger.yml @@ -0,0 +1,60 @@ +## YAML Template. +--- +phraseanet: + servername: http://dev.phrasea.net/ + maintenance: false + debug: false + display_errors: false + +# Twig Configuration +twig: + debug: false + strict_variables: true + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_mysql + host: localhost + port: 3306 + dbname: ab_trunk + user: root + password: nicolas007 + charset: UTF8 + + orm: + auto_generate_proxy_classes: %phraseanet.debug% + auto_mapping: true + cache: + query: array + result: array + metadata: array + + log: + enable: true + type: bad_logger + handler: rotate + output: json + filename: doctrine-query.log + max_day: 10 + +# Monolog LOG Configuration +monolog: + output: yaml + handlers: + main: + type: stream + level: debug + rotate: + type: rotatingFile + level: debug + max_day: 10 + +# Memchache Configuration +memcached: + host: 11211 + + + + + \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config.yml new file mode 100644 index 0000000000..2d01e4fa18 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config.yml @@ -0,0 +1,60 @@ +## YAML Template. +--- +phraseanet: + servername: http://dev.phrasea.net/ + maintenance: false + debug: false + display_errors: false + +# Twig Configuration +twig: + debug: false + strict_variables: true + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_mysql + host: localhost + port: 3306 + dbname: ab_trunk + user: root + password: nicolas007 + charset: UTF8 + + orm: + auto_generate_proxy_classes: %phraseanet.debug% + auto_mapping: true + cache: + query: array + result: array + metadata: array + + log: + enable: false + type: monolog + handler: rotate + output: json + filename: doctrine-query.log + max_day: 10 + +# Monolog LOG Configuration +monolog: + output: yaml + handlers: + main: + type: stream + level: debug + rotate: + type: rotatingFile + level: debug + max_day: 10 + +# Memchache Configuration +memcached: + host: 11211 + + + + + \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_dev.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_dev.yml new file mode 100644 index 0000000000..34724fcc33 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_dev.yml @@ -0,0 +1,19 @@ +## YAML Template. +--- +extends: main + +phraseanet: + debug: true + + +doctrine: + orm: + cache: + query: array + result: array + metadata: array + log: + enable: true + output: json + rotate: + max_day: 2 \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_oneenv.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_oneenv.yml new file mode 100644 index 0000000000..68a2b380bd --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_oneenv.yml @@ -0,0 +1,2 @@ +## YAML Template. +--- diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_prod.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_prod.yml new file mode 100644 index 0000000000..893618d1b6 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_prod.yml @@ -0,0 +1,12 @@ +## YAML Template. +--- + +# Doctrine Configuration +doctrine: + orm: + cache: + query: apc + result: memcached + metadata: apc + log: + enable: true \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_test.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_test.yml new file mode 100644 index 0000000000..5f080b61bb --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/config_test.yml @@ -0,0 +1,10 @@ +## YAML Template. +--- + +extends: dev + +doctrine: + dbal: + driver: pdo_sqlite + path: /Users/nicolasl/workspace/phraseanet/lib/unitTest/tests.sqlite + charset: UTF8 \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/extends_non_existing_file.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/extends_non_existing_file.yml new file mode 100644 index 0000000000..b0de733d80 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/extends_non_existing_file.yml @@ -0,0 +1,5 @@ +## YAML Template. +--- + + +extends: unknow \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good.yml new file mode 100644 index 0000000000..824f4d1759 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good.yml @@ -0,0 +1,60 @@ +## YAML Template. +--- +phraseanet: + servername: http://dev.phrasea.net/ + maintenance: false + debug: false + display_errors: false + +# Twig Configuration +twig: + debug: false + strict_variables: true + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_mysql + host: localhost + port: 3306 + dbname: ab_trunk + user: root + password: nicolas007 + charset: UTF8 + + orm: + auto_generate_proxy_classes: %phraseanet.debug% + auto_mapping: true + cache: + query: array + result: array + metadata: array + + log: + enable: true + type: monolog + handler: rotate + output: json + filename: doctrine-query.log + max_day: 10 + +# Monolog LOG Configuration +monolog: + output: yaml + handlers: + main: + type: stream + level: debug + rotate: + type: rotatingFile + level: debug + max_day: 10 + +# Memchache Configuration +memcached: + host: 11211 + + + + + \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good_no_output.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good_no_output.yml new file mode 100644 index 0000000000..22907c6a1f --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good_no_output.yml @@ -0,0 +1,59 @@ +## YAML Template. +--- +phraseanet: + servername: http://dev.phrasea.net/ + maintenance: false + debug: false + display_errors: false + +# Twig Configuration +twig: + debug: false + strict_variables: true + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_mysql + host: localhost + port: 3306 + dbname: ab_trunk + user: root + password: nicolas007 + charset: UTF8 + + orm: + auto_generate_proxy_classes: %phraseanet.debug% + auto_mapping: true + cache: + query: array + result: array + metadata: array + + log: + enable: true + type: monolog + handler: rotate + filename: doctrine-query.log + max_day: 10 + +# Monolog LOG Configuration +monolog: + output: yaml + handlers: + main: + type: stream + level: debug + rotate: + type: rotatingFile + level: debug + max_day: 10 + +# Memchache Configuration +memcached: + host: 11211 + + + + + \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good_with_no_logger_output.yml b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good_with_no_logger_output.yml new file mode 100644 index 0000000000..22907c6a1f --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/good_with_no_logger_output.yml @@ -0,0 +1,59 @@ +## YAML Template. +--- +phraseanet: + servername: http://dev.phrasea.net/ + maintenance: false + debug: false + display_errors: false + +# Twig Configuration +twig: + debug: false + strict_variables: true + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_mysql + host: localhost + port: 3306 + dbname: ab_trunk + user: root + password: nicolas007 + charset: UTF8 + + orm: + auto_generate_proxy_classes: %phraseanet.debug% + auto_mapping: true + cache: + query: array + result: array + metadata: array + + log: + enable: true + type: monolog + handler: rotate + filename: doctrine-query.log + max_day: 10 + +# Monolog LOG Configuration +monolog: + output: yaml + handlers: + main: + type: stream + level: debug + rotate: + type: rotatingFile + level: debug + max_day: 10 + +# Memchache Configuration +memcached: + host: 11211 + + + + + \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/test.json b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/test.json new file mode 100644 index 0000000000..43133b13c7 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Configuration/confTestFiles/test.json @@ -0,0 +1,12 @@ +{ + "meta": { + "api_version": "1.0", + "request": "GET /api/v1/feeds/288/content/", + "response_time": "2011-07-27T15:52:04+02:00", + "http_code": 200, + "error_message": null, + "error_details": null, + "charset": "UTF-8" + }, + "response": {} +} \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/Service/DoctrineTest.php b/lib/unitTest/Alchemy/Phrasea/Core/Service/DoctrineTest.php new file mode 100644 index 0000000000..da93855096 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/Service/DoctrineTest.php @@ -0,0 +1,87 @@ +getMock( + '\Alchemy\Phrasea\Core\Configuration\Application' + , array('getMainConfigurationFile') + ); + + $fileName = __DIR__ . '/../Configuration/confTestFiles/good.yml'; + + $spec->expects($this->any()) + ->method('getMainConfigurationFile') + ->will( + $this->returnValue( + new SplFileObject($fileName) + ) + ); + + $handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml()); + + $environnement = 'main'; + $configuration = new PhraseaCore\Configuration($environnement, $handler); + + $doctrineService = new Doctrine(); + $doctrineService = new Doctrine($configuration->getDoctrine()); + } + catch (Exception $e) + { + $this->fail($e->getMessage()); + } + } + + public function testGetVersion() + { + $doctrineService = new Doctrine(); + $this->assertTrue(is_string($doctrineService->getVersion())); + } + + public function testGetEntityManager() + { + $doctrineService = new Doctrine(); + $this->assertInstanceOf('\Doctrine\ORM\EntityManager', $doctrineService->getEntityManager()); + } + +} \ No newline at end of file diff --git a/lib/unitTest/Alchemy/Phrasea/Core/VersionTest.php b/lib/unitTest/Alchemy/Phrasea/Core/VersionTest.php new file mode 100644 index 0000000000..1794633db2 --- /dev/null +++ b/lib/unitTest/Alchemy/Phrasea/Core/VersionTest.php @@ -0,0 +1,48 @@ +assertTrue(is_string(Version::getName())); + } + + public function testGetName() + { + $this->assertTrue(is_string(Version::getNumber())); + } +} \ No newline at end of file diff --git a/lib/unitTest/Bridge/ApplicationTest.php b/lib/unitTest/Bridge/ApplicationTest.php index a71ccbb2e9..e60a10150b 100644 --- a/lib/unitTest/Bridge/ApplicationTest.php +++ b/lib/unitTest/Bridge/ApplicationTest.php @@ -17,6 +17,37 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract public static function setUpBeforeClass() { parent::setUpBeforeClass(); +// try +// { +// self::$api = Bridge_Api::get_by_api_name(appbox::get_instance(), 'youtube'); +// } +// catch (Bridge_Exception_ApiNotFound $e) +// { +// self::$api = Bridge_Api::create(appbox::get_instance(), 'youtube'); +// } +// +// try +// { +// self::$account = Bridge_Account::load_account_from_distant_id(appbox::get_instance(), self::$api, self::$user, 'kirikoo'); +// } +// catch (Bridge_Exception_AccountNotFound $e) +// { +// self::$account = Bridge_Account::create(appbox::get_instance(), self::$api, self::$user, 'kirikoo', 'coucou'); +// } + } + + public static function tearDownAfterClass() + { + parent::tearDownAfterClass(); +// self::$api->delete(); +// if (self::$account instanceof Bridge_Account) +// self::$account->delete(); + } + + public function setUp() + { + parent::setUp(); + $this->client = $this->createClient(); try { self::$api = Bridge_Api::get_by_api_name(appbox::get_instance(), 'apitest'); @@ -36,23 +67,12 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract } } - public static function tearDownAfterClass() - { - parent::tearDownAfterClass(); - self::$api->delete(); - if (self::$account instanceof Bridge_Account) - self::$account->delete(); - } - - public function setUp() - { - parent::setUp(); - $this->client = $this->createClient(); - } - public function tearDown() { parent::tearDown(); + self::$api->delete(); + if (self::$account instanceof Bridge_Account) + self::$account->delete(); } public function createApplication() @@ -71,24 +91,11 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract $accounts = Bridge_Account::get_accounts_by_user($appbox, self::$user); $usr_id = self::$user->get_id(); - try - { - $basket_coll = new basketCollection($appbox, $usr_id); - $baskets = $basket_coll->get_baskets(); - if (count($baskets["baskets"]) > 0) - { - $basket = array_shift($baskets["baskets"]); - $crawler = $this->client->request('POST', '/bridge/manager/', array('ssel' => $basket->get_ssel_id())); - $pageContent = $this->client->getResponse()->getContent(); - $this->assertNotContains("Oups ! something went wrong !", $pageContent); - $this->assertEquals(count($accounts) + 2, $crawler->filter('form')->count()); - $this->assertTrue($this->client->getResponse()->isOk()); - } - } - catch (Exception $e) - { + $basket = $this->insertOneBasket(); - } + $crawler = $this->client->request('POST', '/bridge/manager/', array('ssel' => $basket->getId())); + $pageContent = $this->client->getResponse()->getContent(); + $this->assertTrue($this->client->getResponse()->isOk()); } public function testLogin() @@ -105,7 +112,6 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract $crawler = $this->client->request('GET', '/bridge/callback/apitest/'); $this->assertTrue($this->client->getResponse()->isOk()); $pageContent = $this->client->getResponse()->getContent(); - $this->assertNotContains("Oups ! something went wrong !", $pageContent); //check for errors in the crawler $phpunit = $this; $crawler @@ -192,19 +198,18 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract public function testLoadElements() { self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected - $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_name()); + $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); + $account = new Bridge_Account(appbox::get_instance(), self::$api, self::$account->get_id()); $crawler = $this->client->request('GET', $url, array("page" => 1)); $this->assertTrue($this->client->getResponse()->isOk()); - $this->assertEquals(5, $crawler->filterXPath("//div[@class='element']")->count()); - $pageContent = $this->client->getResponse()->getContent(); - $this->assertNotContains("Oups ! something went wrong !", $pageContent); - self::$account->get_settings()->set("auth_token", null); //disconnected + $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); } public function testLoadElementsDisconnected() { - $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_name()); + $url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $crawler = $this->client->request('GET', $url, array("page" => 1)); + $this->assertTrue($this->client->getResponse()->isOk()); $pageContent = $this->client->getResponse()->getContent(); $this->assertContains($url, $pageContent); $this->deconnected($crawler, $pageContent); @@ -218,7 +223,7 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(), self::$account); $this->assertTrue($this->client->getResponse()->isOk()); $this->assertEquals(sizeof($elements), $crawler->filterXPath("//table/tr")->count()); - self::$account->get_settings()->set("auth_token", null); //disconnected + $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); } public function testLoadRecordsDisconnected() @@ -237,8 +242,7 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract $crawler = $this->client->request('GET', $url, array("page" => 1)); $elements = Bridge_Element::get_elements_by_account(appbox::get_instance(), self::$account); $this->assertTrue($this->client->getResponse()->isOk()); - $this->assertEquals(5, $crawler->filterXPath("//div[@class='element']")->count()); - self::$account->get_settings()->set("auth_token", null); //disconnected + $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); } public function testLoadContainersDisconnected() @@ -270,9 +274,8 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract } catch (Exception $e) { - + } - self::$account->get_settings()->set("auth_token", null); //disconnected } public function testActionModifyTooManyElements() @@ -284,7 +287,7 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract $this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertContains($redirect, $this->client->getResponse()->headers->get("location")); $this->assertContains("error=", $this->client->getResponse()->headers->get("location")); - self::$account->get_settings()->set("auth_token", null); //disconnected + $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); } public function testActionModifyElement() @@ -292,11 +295,8 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $crawler = $this->client->request('GET', $url, array("elements_list" => "element123qcs789")); - $pageContent = $this->client->getResponse()->getContent(); $this->assertTrue($this->client->getResponse()->isOk()); - $this->assertContains("element123qcs789", $pageContent); - $this->assertNotContains("Oups ! something went wrong !", $pageContent); - self::$account->get_settings()->set("auth_token", null); //disconnected + $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); } /** @@ -310,7 +310,7 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn")); $this->assertTrue($this->client->getResponse()->isOk()); $pageContent = $this->client->getResponse()->getContent(); - self::$account->get_settings()->set("auth_token", null); //disconnected + $this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent()); } public function testActionMoveInto() @@ -318,22 +318,16 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/bridge/action/%s/moveinto/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $crawler = $this->client->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); + $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", $this->client->getResponse()->getContent()); $this->assertTrue($this->client->getResponse()->isOk()); - $pageContent = $this->client->getResponse()->getContent(); - $this->assertContains("containerudt456shn", $pageContent); - $this->assertNotContains("Oups ! something went wrong !", $pageContent); - self::$account->get_settings()->set("auth_token", null); //disconnected } public function deconnected($crawler, $pageContent) { - $this->assertNotContains("Oups ! something went wrong !", $pageContent); $this->assertTrue($this->client->getResponse()->isOk()); $this->assertContains("/prod/bridge/login/" . mb_strtolower(self::$account->get_api()->get_connector()->get_name()), $pageContent); - - $this->assertEquals(2, $crawler->filter("form")->count()); } } diff --git a/lib/unitTest/Bridge/Bridge_datas.inc b/lib/unitTest/Bridge/Bridge_datas.inc index 52c8194079..0915c86ece 100644 --- a/lib/unitTest/Bridge/Bridge_datas.inc +++ b/lib/unitTest/Bridge/Bridge_datas.inc @@ -67,6 +67,21 @@ class Bridge_Api_Apitest_Containers implements Bridge_Api_ContainerInterface { } + + public function get_category() + { + + } + + public function is_private() + { + + } + + public function get_rating() + { + + } } diff --git a/lib/unitTest/Doctrine/Entities/BasketTest.php b/lib/unitTest/Doctrine/Entities/BasketTest.php new file mode 100644 index 0000000000..6c7761cabf --- /dev/null +++ b/lib/unitTest/Doctrine/Entities/BasketTest.php @@ -0,0 +1,207 @@ +em = self::$core->getEntityManager(); + $this->basket = $this->insertOneBasket(); + + parent::setUp(); + } + + public function tearDown() + { + parent::tearDown(); + } + + public function testGetId() + { + $this->assertTrue(is_int($this->basket->getId())); + $otherBasket = $this->insertOneBasket(); + $this->assertGreaterThan($this->basket->getId(), $otherBasket->getId()); + } + + public function testGetName() + { + $this->basket->setName('one name'); + $this->em->persist($this->basket); + $this->em->flush(); + $this->assertEquals('one name', $this->basket->getName()); + } + + public function testGetDescription() + { + $this->basket->setDescription('une jolie description pour mon super panier'); + $this->em->persist($this->basket); + $this->em->flush(); + $this->assertEquals('une jolie description pour mon super panier', $this->basket->getDescription()); + } + + public function testGetUsrId() + { + $this->basket->setUsrId(1); + $this->em->persist($this->basket); + $this->em->flush(); + $this->assertEquals(1, $this->basket->getUsrId()); + } + + public function testGetPusherId() + { + $this->basket->setPusherId(1); + $this->em->persist($this->basket); + $this->em->flush(); + $this->assertEquals(1, $this->basket->getPusherId()); + } + + public function testGetArchived() + { + $this->basket->setArchived(true); + $this->em->persist($this->basket); + $this->em->flush(); + $this->assertTrue($this->basket->GetArchived()); + $this->basket->setArchived(false); + $this->em->persist($this->basket); + $this->em->flush(); + $this->assertFalse($this->basket->GetArchived()); + } + + public function testGetCreated() + { + $date = $this->basket->getCreated(); + $this->assertInstanceOf('\DateTime', $date); + } + + public function testGetUpdated() + { + $date = $this->basket->getUpdated(); + $this->assertInstanceOf('\DateTime', $date); + +// sleep(5); +// $this->basket->setName('hello COCOCOCO'); +// $this->basket->setDescription('44WDFDFOLSDF'); +// $this->em->persist($this->basket); +// $this->em->flush(); +// var_dump($this->basket->getId()); +// $basket = $this->em->getRepository('\Entities\Basket')->find($this->basket->getId()); +// $dateUpdated = $basket->getUpdated(); +// var_dump($date->format(DATE_ATOM), $dateUpdated->format(DATE_ATOM)); +// $this->assertGreaterThan($dateUpdated, $date); +// $this->assertGreaterThan($dateUpdated, $this->basket->getCreated()); + } + + public function testGetElements() + { + $elements = $this->basket->getElements(); + + $this->assertInstanceOf('\Doctrine\ORM\PersistentCollection', $elements); + + $this->assertEquals(0, $elements->count()); + + $basketElement = new \Entities\BasketElement(); + + $basketElement->setRecord(self::$record_1); + + $basketElement->setBasket($this->basket); + + $this->em->persist($basketElement); + + $this->em->flush(); + + $this->em->refresh($this->basket); + + $this->assertEquals(1, $this->basket->getElements()->count()); + } + + public function testGetPusher() + { + $this->assertNull($this->basket->getPusher()); //no pusher + $this->basket->setPusherId(self::$user->get_id()); + $this->assertInstanceOf('\User_Adapter', $this->basket->getPusher()); + $this->assertEquals($this->basket->getPusher()->get_id(), self::$user->get_id()); + } + + public function testGetOwner() + { + $this->assertNotNull($this->basket->getOwner()); //no owner + $this->basket->setUsrId(self::$user->get_id()); + $this->assertInstanceOf('\User_Adapter', $this->basket->getOwner()); + $this->assertEquals($this->basket->getOwner()->get_id(), self::$user->get_id()); + } + + public function testGetValidation() + { + $this->assertNull($this->basket->getValidation()); + + $validationSession = new \Entities\ValidationSession(); + + $validationSession->setBasket($this->basket); + + $validationSession->setDescription('Une description au hasard'); + + $validationSession->setName('Un nom de validation'); + + $expires = new \DateTime(); + $expires->modify('+1 week'); + + $validationSession->setExpires($expires); + + $validationSession->setInitiator(self::$user); + + $this->em->persist($validationSession); + + $this->em->flush(); + + $this->em->refresh($this->basket); + + $this->assertInstanceOf('\Entities\ValidationSession', $this->basket->getValidation()); + } + + public function testGetIsRead() + { + $this->markTestIncomplete(); + } + + public function testGetSize() + { + $this->markTestIncomplete(); + } + + public function hasRecord() + { + $this->markTestIncomplete(); + } + +} diff --git a/lib/unitTest/FeedValidator.inc b/lib/unitTest/FeedValidator.inc index cb54be21b2..ceea8f0227 100644 --- a/lib/unitTest/FeedValidator.inc +++ b/lib/unitTest/FeedValidator.inc @@ -41,7 +41,7 @@ abstract class W3CFeedValidator { const VALIDATOR_ENDPOINT = "http://validator.w3.org/feed/check.cgi"; const OUTPOUT = "soap12"; - const TIME_BETWEEN_REQUEST = 1; + const TIME_BETWEEN_REQUEST = 2; public abstract function validate(); } @@ -83,7 +83,7 @@ class W3CFeedUrlValidator extends W3CFeedValidator { $url_validator = sprintf("%s?url=%s&output=%s", self::VALIDATOR_ENDPOINT, $this->url, self::OUTPOUT); sleep(self::TIME_BETWEEN_REQUEST); - $response = file_get_contents($url_validator); + $response = @file_get_contents($url_validator); if (!$response) { throw new W3CFeedValidatorException("Unable to request W3C API"); @@ -146,7 +146,7 @@ class W3CFeedRawValidator extends W3CFeedValidator ), )); sleep(self::TIME_BETWEEN_REQUEST); - $response = file_get_contents(self::VALIDATOR_ENDPOINT, false, $context); + $response = @file_get_contents(self::VALIDATOR_ENDPOINT, false, $context); if (!$response) { throw new W3CFeedValidatorException("Unable to request W3C API"); diff --git a/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc b/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc index c93138fac0..3c80eb21e1 100644 --- a/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc +++ b/lib/unitTest/PhraseanetPHPUnitAbstract.class.inc @@ -9,18 +9,22 @@ * file that was distributed with this source code. */ +require_once dirname(__FILE__) . "/../../lib/classes/bootstrap.class.php"; + /** * * @package * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; -bootstrap::register_autoloads(); + +bootstrap::execute('test'); use Silex\WebTestCase; use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpFoundation\Response; +use Doctrine\Common\DataFixtures\Loader; +use PhraseaFixture\Basket as MyFixture; abstract class PhraseanetPHPUnitAbstract extends WebTestCase { @@ -32,7 +36,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase * @var Symfony\Component\HttpKernel\Client */ protected $client; - + /** + * + * @var record_adapter + */ + protected static $story_1; /** * * @var record_adapter @@ -314,11 +322,13 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase * @var User_Adapter */ protected static $user; + /** * * @var User_Adapter */ protected static $user_alt1; + /** * * @var User_Adapter @@ -327,6 +337,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase protected static $updated; protected static $need_records = false; protected static $need_subdefs = false; + protected static $need_story = false; /** * @@ -336,25 +347,27 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase protected static $time_start; protected static $generated_subdefs = array(); + /** + * + * @var \Alchemy\Phrasea\Core + */ protected static $core; + /** + * + * @var \Doctrine\ORM\Tools\SchemaTools + */ + protected $schematTool; + + /** + * Class metadatas + * @var Array + */ + protected $classesMetatdas; + public static function setUpBeforeClass() { - - if(is_file(__DIR__ .'/tests.sqlite')) - { - unlink(__DIR__ .'/tests.sqlite'); - } - - self::$core = bootstrap::getCore(); - self::$core["EM"] = self::$core->share(function() - { - $doctrine = new \Alchemy\Phrasea\Core\Service\DoctrineTestSQLite(); - return $doctrine->getEntityManager(); - }); - - - + if (!self::$time_start) self::$time_start = microtime(true); @@ -466,6 +479,14 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase self::$collection = $coll; + if (static::$need_story) + { + self::$story_1 = \record_adapter::create( + self::$collection, new system_file(dirname(__FILE__) . '/testfiles/test001.CR2'), false, true + ); + echo "\ngenerate story 01\n"; + } + if (static::$need_records) { if ((static::$need_records === true || static::$need_records >= 1) && !self::$record_1 instanceof record_adapter) @@ -750,10 +771,62 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase } } $appbox->get_session()->logout(); + + return; } + /** + * Delete temporay sqlite database + * Create schema using $this->classesMetatdas + * Load DoctrineTestServices + * + * @return + */ + public function __construct() + { + if (null === self::$core) + { + if (is_file(__DIR__ . '/tests.sqlite')) + { + unlink(__DIR__ . '/tests.sqlite'); + } + + self::$core = bootstrap::getCore(); + self::$core["EM"] = self::$core->share(function() + { + $doctrine = new \Alchemy\Phrasea\Core\Service\DoctrineTestSQLite(); + return $doctrine->getEntityManager(); + }); + + $em = self::$core->getEntityManager(); + /* @var $em \Doctrine\ORM\EntityManager */ + + //create schema + $this->schematTool = new \Doctrine\ORM\Tools\SchemaTool($em); + $this->classesMetatdas = array( + $em->getClassMetadata('Entities\Basket') + , $em->getClassMetadata('Entities\BasketElement') + , $em->getClassMetadata('Entities\StoryWZ') + , $em->getClassMetadata('Entities\ValidationData') + , $em->getClassMetadata('Entities\ValidationParticipant') + , $em->getClassMetadata('Entities\ValidationSession') + ); + + $this->schematTool->createSchema($this->classesMetatdas); + } + } + + /** + * Delete all ressources created during the test + */ public function __destruct() { + if (self::$story_1 instanceof record_adapter) + { + echo "."; + self::$story_1->delete(); + self::$story_1 = null; + } if (self::$record_1 instanceof record_adapter) { echo "."; @@ -914,34 +987,22 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase public function setUp() { parent::setUp(); - - - $em = self::$core["EM"]; - - //create schema - $this->schematTool = new \Doctrine\ORM\Tools\SchemaTool($em); - $this->classesMetatdas = array( - $em->getClassMetadata('Entities\Basket') - ,$em->getClassMetadata('Entities\BasketElement') - ,$em->getClassMetadata('Entities\StoryWZ') - ,$em->getClassMetadata('Entities\ValidationData') - ,$em->getClassMetadata('Entities\ValidationParticipant') - ,$em->getClassMetadata('Entities\ValidationSession') - ); - $this->schematTool->createSchema($this->classesMetatdas); - + $browser = Browser::getInstance(); $browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC); } public function tearDown() { - //drop schema - $this->schematTool->dropSchema($this->classesMetatdas); parent::tearDown(); } - - + + /** + * Insert fixture contained in the specified fixtureLoader + * into sqlLite test temporary database + * + * @param Doctrine\Common\DataFixtures\Loader $fixtureLoader + */ public function insertFixtureInDatabase(Doctrine\Common\DataFixtures\Loader $fixtureLoader) { $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger(); @@ -949,6 +1010,16 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $executor->execute($fixtureLoader->getFixtures()); } + /** + * Purge sqlLite test temporary database by truncate all existing tables + */ + protected function purgeDatabase() + { + $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger(); + $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger); + $executor->execute(array()); + } + protected function assertDateAtom($date) { return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date); @@ -960,4 +1031,214 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $browser->setUserAgent($user_agent); } -} \ No newline at end of file + /** + * Insert one basket entry ans set current authenticated user as owner + * + * @return \Entities\Basket + */ + protected function insertOneBasket() + { + try + { + $basketFixture = new MyFixture\LoadOneBasket(); + + $basketFixture->setUser(self::$user); + + $loader = new Loader(); + $loader->addFixture($basketFixture); + + $this->insertFixtureInDatabase($loader); + + return $basketFixture->basket; + } + catch (\Exception $e) + { + $this->fail('Fail load one Basket : ' . $e->getMessage()); + } + } + + /** + * Insert five baskets and set current authenticated user as owner + * + * @return \Entities\Basket + */ + protected function insertFiveBasket() + { + try + { + $basketFixture = new MyFixture\LoadFiveBaskets(); + + $basketFixture->setUser(self::$user); + + $loader = new Loader(); + $loader->addFixture($basketFixture); + + $this->insertFixtureInDatabase($loader); + + return $basketFixture->baskets; + } + catch (\Exception $e) + { + $this->fail('Fail load one Basket : ' . $e->getMessage()); + } + } + + /** + * + * @return \Entities\BasketElement + */ + protected function insertOneBasketElement() + { + $basket = $this->insertOneBasket(); + + $basketElement = new \Entities\BasketElement(); + $basketElement->setRecord(self::$record_1); + $basketElement->setBasket($basket); + + $basket->addBasketElement($basketElement); + + $em = self::$core->getEntityManager(); + + $em->persist($basketElement); + + $em->merge($basket); + + $em->flush(); + + return $basketElement; + } + + + /** + * + * @return \Entities\Basket + */ + protected function insertOneValidationBasket() + { + $em = self::$core->getEntityManager(); + + $basketElement = $this->insertOneBasketElement(); + $basket = $basketElement->getBasket(); + + $Validation = new Entities\ValidationSession(); + $Validation->setBasket($basket); + $Validation->setInitiator(self::$user); + + $basket->setValidation($Validation); + + $em->persist($Validation); + $em->merge($basket); + + $Participant = new Entities\ValidationParticipant(); + $Participant->setUser(self::$user); + $Participant->setCanAgree(true); + $Participant->setCanSeeOthers(true); + + $Validation->addValidationParticipant($Participant); + $Participant->setSession($Validation); + + $em->persist($Participant); + $em->merge($Validation); + + $Data = new Entities\ValidationData(); + $Data->setBasketElement($basketElement); + $Data->setParticipant($Participant); + $basketElement->addValidationData($Data); + + $em->persist($Data); + $em->merge($basketElement); + + $em->flush(); + + return $basket; + + } + + /** + * Create a new basket with current auhtenticated user as owner + * Create a new sessionValidation with the newly created basket + * Set current authenticated user as sessionValidation initiator + * Add 2 records as elments of the newly created basket + * Add 2 participants to the newly created sessionValidation + * + * @return \Entities\Basket + */ + protected function insertOneBasketEnv() + { + try + { + $em = self::$core->getEntityManager(); + /* @var $em \Doctrine\ORM\EntityManager */ + + $basketFixture = new MyFixture\LoadOneBasketEnv(); + + $basketFixture->setUser(self::$user); + + $basketFixture->addParticipant(self::$user_alt1); + $basketFixture->addParticipant(self::$user_alt2); + + $basketFixture->addBasketElement(self::$record_1); + $basketFixture->addBasketElement(self::$record_2); + + $loader = new Loader(); + $loader->addFixture($basketFixture); + + $this->insertFixtureInDatabase($loader); + + return $basketFixture->basket; + } + catch (\Exception $e) + { + $this->fail('Fail load one Basket context : ' . $e->getMessage()); + } + } + + /** + * Load One WZ with + * One basket + * One story + * One ValidationSession & one participant + * @return + */ + protected function insertOneWZ() + { + try + { + $currentUser = self::$user; + $altUser = self::$user_alt1; + //add one basket + $basket = new PhraseaFixture\Basket\LoadOneBasket(); + $basket->setUser($currentUser); + //add one story + $story = new PhraseaFixture\Story\LoadOneStory(); + $story->setUser($currentUser); + $story->setRecord(self::$record_1); + //add a validation session initiated by alt user + $validationSession = new PhraseaFixture\ValidationSession\LoadOneValidationSession(); + $validationSession->setUser($altUser); + + $loader = new Loader(); + $loader->addFixture($basket); + $loader->addFixture($story); + $loader->addFixture($validationSession); + + $this->insertFixtureInDatabase($loader); + + //add current user as participant + $validationParticipant = new PhraseaFixture\ValidationParticipant\LoadParticipantWithSession(); + $validationParticipant->setSession($validationSession->validationSession); + $validationParticipant->setUser($currentUser); + + $loader = new Loader(); + $loader->addFixture($validationParticipant); + $this->insertFixtureInDatabase($loader); + } + catch (\Exception $e) + { + $this->fail('Fail load one WorkingZone : ' . $e->getMessage()); + } + + return; + } + +} diff --git a/lib/unitTest/Session/Session_HandlerTest.php b/lib/unitTest/Session/Session_HandlerTest.php index e657053c72..545d3a7bca 100644 --- a/lib/unitTest/Session/Session_HandlerTest.php +++ b/lib/unitTest/Session/Session_HandlerTest.php @@ -380,20 +380,6 @@ class Session_HandlerTest extends PhraseanetPHPUnitAbstract $this->object->logout(); - foreach($user->ACL()->get_granted_sbas() as $databox) - { - $sql = 'SELECT usr_id FROM collusr WHERE site = :site AND usr_id = :usr_id AND coll_id = :coll_id'; - $stmt = $databox->get_connection()->prepare($sql); - - foreach($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $collection) - { - $stmt->execute(array(':site'=>$registry->get('GV_sit'),':usr_id'=>$user->get_id(), ':coll_id'=>$collection->get_coll_id())); - $this->assertEquals(0, $stmt->rowCount()); - } - - $stmt->closeCursor(); - } - } /** diff --git a/lib/unitTest/WorkZoneTest.php b/lib/unitTest/WorkZoneTest.php deleted file mode 100644 index d267d38e11..0000000000 --- a/lib/unitTest/WorkZoneTest.php +++ /dev/null @@ -1,96 +0,0 @@ -client = $this->createClient(); - } - - public function createApplication() - { - return require __DIR__ . '/../Alchemy/Phrasea/Application/Prod.php'; - } - - public function testRootGet() - { - - $this->loadOneWZ(); - - $route = "/WorkZone/"; - - $this->client->request('GET', $route); - - $response = $this->client->getResponse(); - - $this->assertEquals(200, $response->getStatusCode()); - } - - protected function loadOneWZ() - { - try - { - $currentUser = self::$user; - $altUser = self::$user_alt1; - //add one basket - $basket = new PhraseaFixture\Basket\LoadOneBasket(); - $basket->setUser($currentUser); - //add one story - $story = new PhraseaFixture\Story\LoadOneStory(); - $story->setUser($currentUser); - $story->setRecord(self::$record_1); - //add a validation session initiated by alt user - $validationSession = new PhraseaFixture\ValidationSession\LoadOneValidationSession(); - $validationSession->setUser($altUser); - - $loader = new Loader(); - $loader->addFixture($basket); - $loader->addFixture($story); - $loader->addFixture($validationSession); - - $this->insertFixtureInDatabase($loader); - - //add current user as participant - $validationParticipant = new PhraseaFixture\ValidationParticipant\LoadParticipantWithSession(); - $validationParticipant->setSession($validationSession->validationSession); - $validationParticipant->setUser($currentUser); - - $loader = new Loader(); - $loader->addFixture($validationParticipant); - $this->insertFixtureInDatabase($loader); - } - catch (\Exception $e) - { - $this->fail($e->getMessage()); - } - - return; - } - -} \ No newline at end of file diff --git a/lib/unitTest/api/v1/api_v1_adapterTest.php b/lib/unitTest/api/v1/api_v1_adapterTest.php index 400c84d55f..dae0553685 100644 --- a/lib/unitTest/api/v1/api_v1_adapterTest.php +++ b/lib/unitTest/api/v1/api_v1_adapterTest.php @@ -22,7 +22,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { parent::setUp(); $appbox = appbox::get_instance(); - $this->object = new API_V1_adapter(FALSE, $appbox); + $this->object = new API_V1_adapter(FALSE, $appbox, self::$core); } public function testGet_error_code() @@ -270,7 +270,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSet_record_status() { $appbox = appbox::get_instance(); - $stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox)); + $stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox, bootstrap::getCore())); $appbox = appbox::get_instance(); $databox = self::$record_1->get_databox(); @@ -307,7 +307,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSet_record_collection() { $appbox = appbox::get_instance(); - $stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox)); + $stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox, bootstrap::getCore())); $databox = self::$record_1->get_databox(); $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); @@ -370,10 +370,16 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $appbox = appbox::get_instance(); $session = $appbox->get_session(); $usr_id = $session->get_usr_id(); + + $em = self::$core->getEntityManager(); + $repo = $em->getRepository('\Entities\Basket'); + + /* @var $repo \Repositories\BasketRepository */ + $basket = $repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser()); - $basket = basket_adapter::getInstance(appbox::get_instance(), $ssel_id, $usr_id); - $this->assertTrue($basket instanceof basket_adapter); - $basket->delete(); + $this->assertTrue($basket instanceof \Entities\Basket); + $em->remove($basket); + $em->flush(); } public function testDelete_basket() @@ -381,8 +387,17 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); $user = User_Adapter::getInstance($usr_id, $appbox); - $basket = basket_adapter::create($appbox, 'test suppression', $user); - $ssel_id = $basket->get_ssel_id(); + + $em = self::$core->getEntityManager(); + + $Basket = new Entities\Basket(); + $Basket->setName('Delete test'); + $Basket->setOwner($user); + + $em->persist($Basket); + $em->flush(); + + $ssel_id = $Basket->getId(); $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); $result = $this->object->delete_basket($request, $ssel_id); @@ -390,12 +405,14 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->assertEquals('application/json', $result->get_content_type()); $this->assertTrue(is_object(json_decode($result->format()))); + $repo = $em->getRepository('\Entities\Basket'); + try { - basket_adapter::getInstance($appbox, $ssel_id, $usr_id); + $repo->findUserBasket($ssel_id, $user); $this->fail('An exception should have been raised'); } - catch (Exception_Basket_NotFound $e) + catch (Exception_NotFound $e) { } @@ -405,12 +422,11 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); - $baskets = $basket_coll->get_baskets(); - $basket = array_pop($baskets['baskets']); + + $basket = $this->insertOneBasket(); $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); - $result = $this->object->get_basket($request, $basket->get_ssel_id()); + $result = $this->object->get_basket($request, $basket->getId()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); $this->assertTrue(is_object(json_decode($result->format()))); @@ -420,42 +436,46 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); - $baskets = $basket_coll->get_baskets(); - $basket = array_pop($baskets['baskets']); - + + $basket = $this->insertOneBasket(); + $request = new Request(array(), array(), array('name' => 'PROUTO'), array(), array(), array('HTTP_Accept' => 'application/json')); - $result = $this->object->set_basket_title($request, $basket->get_ssel_id()); + $result = $this->object->set_basket_title($request, $basket->getId()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); $this->assertTrue(is_object(json_decode($result->format()))); - $basket = basket_adapter::getInstance($appbox, $basket->get_ssel_id(), $usr_id); - $this->assertEquals('PROUTO', $basket->get_name()); + $repository =self::$core->getEntityManager()->getRepository('\Entities\Basket'); + + $ret_bask = $repository->find($basket->getId()); + + $this->assertEquals('PROUTO', $ret_bask->getName()); } public function testSet_basket_description() { $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); - $baskets = $basket_coll->get_baskets(); - $basket = array_pop($baskets['baskets']); + + $basket = $this->insertOneBasket(); $request = new Request(array(), array(), array('description' => 'une belle description'), array(), array(), array('HTTP_Accept' => 'application/json')); - $result = $this->object->set_basket_description($request, $basket->get_ssel_id()); + $result = $this->object->set_basket_description($request, $basket->getId()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); $this->assertTrue(is_object(json_decode($result->format()))); - $basket = basket_adapter::getInstance($appbox, $basket->get_ssel_id(), $usr_id); - $this->assertEquals('une belle description', $basket->get_description()); + $repository =self::$core->getEntityManager()->getRepository('\Entities\Basket'); + + $ret_bask = $repository->find($basket->getId()); + + $this->assertEquals('une belle description', $ret_bask->getDescription()); } public function testSearch_publications() { $appbox = appbox::get_instance(); - $stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox)); + $stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox, bootstrap::getCore())); $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); $feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut"); $result = $this->object->search_publications($request, self::$user); diff --git a/lib/unitTest/api/v1/aplicationTest.php b/lib/unitTest/api/v1/aplicationTest.php index 130a358e33..8cb5565d6d 100644 --- a/lib/unitTest/api/v1/aplicationTest.php +++ b/lib/unitTest/api/v1/aplicationTest.php @@ -246,7 +246,7 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract $this->assertTrue((strlen($metadatas->separator) > 0)); $this->assertTrue(is_string($metadatas->thesaurus_branch)); - $this->assertTrue(in_array($metadatas->type, array(databox_field::TYPE_DATE, databox_field::TYPE_NUMBER, databox_field::TYPE_TEXT))); + $this->assertTrue(in_array($metadatas->type, array(databox_field::TYPE_DATE,databox_field::TYPE_STRING, databox_field::TYPE_NUMBER, databox_field::TYPE_TEXT))); $this->assertTrue(is_bool($metadatas->indexable)); $this->assertTrue(is_bool($metadatas->multivalue)); $this->assertTrue(is_bool($metadatas->readonly)); @@ -795,8 +795,6 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract { $this->evaluateGoodBasket($basket); $this->assertEquals('un Joli Nom', $basket->name); - $basket_obj = basket_adapter::getInstance($appbox, $basket->ssel_id, $appbox->get_session()->get_usr_id()); - $basket_obj->delete(); } } @@ -804,180 +802,131 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract { $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); + + $basket = $this->insertOneBasket(); + + $route = '/baskets/' . $basket->getId() . '/content/?oauth_token=' . self::$token; - $found = false; - foreach ($basket_coll->get_baskets() as $bask_group => $baskets) + $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + + $crawler = $this->client->request('GET', $route); + $content = json_decode($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaJson200($content); + + $this->assertEquals(1, count((array) $content->response)); + + $this->assertObjectHasAttribute("basket_elements", $content->response); + + foreach ($content->response->basket_elements as $basket_str) { - if (!in_array($bask_group, array('recept', 'baskets'))) - continue; - foreach ($baskets as $basket) + $this->evaluateGoodBasket($basket_str); + + $this->assertEquals(count($basket->getElements()), count((array) $basket_str->basket_elements)); + foreach ($basket_str->basket_elements as $basket_element) { - $found = true; - $route = '/baskets/' . $basket->get_ssel_id() . '/content/?oauth_token=' . self::$token; - - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); - - $crawler = $this->client->request('GET', $route); - $content = json_decode($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaJson200($content); - - $this->assertEquals(1, count((array) $content->response)); - - $this->assertObjectHasAttribute("basket_elements", $content->response); - - foreach ($content->response->basket_elements as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals(count($basket->get_elements()), count((array) $basket_str->basket_elements)); - foreach ($basket_str->basket_elements as $basket_element) - { - $this->assertObjectHasAttribute('basket_element_id', $basket_element); - $this->assertObjectHasAttribute('order', $basket_element); - $this->assertObjectHasAttribute('record', $basket_element); - $this->assertObjectHasAttribute('validation_item', $basket_element); - $this->assertTrue(is_bool($basket_element->validation_item)); - $this->assertTrue(is_int($basket_element->order)); - $this->assertTrue(is_int($basket_element->basket_element_id)); - $this->evaluateGoodRecord($basket_element->record); - } - } + $this->assertObjectHasAttribute('basket_element_id', $basket_element); + $this->assertObjectHasAttribute('order', $basket_element); + $this->assertObjectHasAttribute('record', $basket_element); + $this->assertObjectHasAttribute('validation_item', $basket_element); + $this->assertTrue(is_bool($basket_element->validation_item)); + $this->assertTrue(is_int($basket_element->order)); + $this->assertTrue(is_int($basket_element->basket_element_id)); + $this->evaluateGoodRecord($basket_element->record); } } - if (!$found) - $this->markTestSkipped('Unable to test basket set title'); } public function testSetBasketTitle() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); + $basket = $this->insertOneBasket(); + + $route = '/baskets/' . $basket->getId() . '/setname/?oauth_token=' . self::$token; - $found = false; + $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); - foreach ($basket_coll->get_baskets() as $bask_group => $baskets) + $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom')); + $content = json_decode($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaJson200($content); + + $this->assertEquals(1, count((array) $content->response)); + $this->assertObjectHasAttribute("basket", $content->response); + foreach ($content->response->basket as $basket_str) { - if (!in_array($bask_group, array('recept', 'baskets'))) - continue; - foreach ($baskets as $basket) - { + $this->evaluateGoodBasket($basket_str); - $found = true; - $route = '/baskets/' . $basket->get_ssel_id() . '/setname/?oauth_token=' . self::$token; - - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); - - $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom')); - $content = json_decode($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaJson200($content); - - $this->assertEquals(1, count((array) $content->response)); - $this->assertObjectHasAttribute("basket", $content->response); - foreach ($content->response->basket as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals($basket_str->name, 'un Joli Nom'); - } - - $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom')); - $content = json_decode($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaJson200($content); - - $this->assertEquals(1, count((array) $content->response)); - - $this->assertObjectHasAttribute("basket", $content->response); - - foreach ($content->response->basket as $basket) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals($basket_str->name, 'un Joli Nom'); - } - - $crawler = $this->client->request('POST', $route, array('name' => 'aéaa')); - $content = json_decode($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaJson200($content); - - $this->assertEquals(1, count((array) $content->response)); - $this->assertObjectHasAttribute("basket", $content->response); - foreach ($content->response->basket as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - $this->assertEquals($basket_str->name, 'aéaa'); - } - - - break; - } + $this->assertEquals($basket_str->name, 'un Joli Nom'); } - if (!$found) - $this->markTestSkipped('Unable to test basket set title'); + + $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom')); + $content = json_decode($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaJson200($content); + + $this->assertEquals(1, count((array) $content->response)); + + $this->assertObjectHasAttribute("basket", $content->response); + + foreach ($content->response->basket as $basket) + { + $this->evaluateGoodBasket($basket_str); + + $this->assertEquals($basket_str->name, 'un Joli Nom'); + } + + $crawler = $this->client->request('POST', $route, array('name' => 'aéaa')); + $content = json_decode($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaJson200($content); + + $this->assertEquals(1, count((array) $content->response)); + $this->assertObjectHasAttribute("basket", $content->response); + foreach ($content->response->basket as $basket_str) + { + $this->evaluateGoodBasket($basket_str); + $this->assertEquals($basket_str->name, 'aéaa'); + } + } public function testSetBasketDescription() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); + $basket = $this->insertOneBasket(); + + $route = '/baskets/' . $basket->getId() . '/setdescription/?oauth_token=' . self::$token; - $found = false; + $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); - foreach ($basket_coll->get_baskets() as $bask_group => $baskets) + $crawler = $this->client->request('POST', $route, array('description' => 'une belle desc')); + $content = json_decode($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaJson200($content); + + $this->assertEquals(1, count((array) $content->response)); + + $this->assertObjectHasAttribute("basket", $content->response); + foreach ($content->response->basket as $basket_str) { - if (!in_array($bask_group, array('recept', 'baskets'))) - continue; - foreach ($baskets as $basket) - { + $this->evaluateGoodBasket($basket_str); - $found = true; - $route = '/baskets/' . $basket->get_ssel_id() . '/setdescription/?oauth_token=' . self::$token; - - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); - - $crawler = $this->client->request('POST', $route, array('description' => 'une belle desc')); - $content = json_decode($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaJson200($content); - - $this->assertEquals(1, count((array) $content->response)); - - $this->assertObjectHasAttribute("basket", $content->response); - foreach ($content->response->basket as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals($basket_str->description, 'une belle desc'); - } - - - break; - } + $this->assertEquals($basket_str->description, 'une belle desc'); } - if (!$found) - $this->markTestSkipped('Unable to test basket set description'); + + } public function testDeleteBasket() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); + $baskets = $this->insertFiveBasket(); - $basket = basket_adapter::create($appbox, 'test suppression panier', User_Adapter::getInstance($usr_id, $appbox)); - - $route = '/baskets/' . $basket->get_ssel_id() . '/delete/?oauth_token=' . self::$token; + $route = '/baskets/' . $baskets[0]->getId() . '/delete/?oauth_token=' . self::$token; $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); @@ -988,9 +937,16 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract $this->evaluateMetaJson200($content); $this->assertObjectHasAttribute("baskets", $content->response); + + $found = false; foreach ($content->response->baskets as $basket) { $this->evaluateGoodBasket($basket); + $found = true; + } + if(!$found) + { + $this->fail('There should be four baskets left'); } } diff --git a/lib/unitTest/api/v1/aplicationYamlTest.php b/lib/unitTest/api/v1/aplicationYamlTest.php index ea3d70333e..045d530fb6 100644 --- a/lib/unitTest/api/v1/aplicationYamlTest.php +++ b/lib/unitTest/api/v1/aplicationYamlTest.php @@ -215,7 +215,7 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract } catch (Exception_Databox_FieldNotFound $e) { - + } $route = '/databoxes/' . $databox_id . '/metadatas/?oauth_token=' . self::$token; @@ -254,7 +254,7 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract $this->assertTrue((strlen($metadatas["separator"]) > 0)); $this->assertTrue(is_string($metadatas["thesaurus_branch"])); - $this->assertTrue(in_array($metadatas["type"], array(databox_field::TYPE_DATE, databox_field::TYPE_NUMBER, databox_field::TYPE_TEXT))); + $this->assertTrue(in_array($metadatas["type"], array(databox_field::TYPE_DATE, databox_field::TYPE_STRING, databox_field::TYPE_NUMBER, databox_field::TYPE_TEXT))); $this->assertTrue(is_bool($metadatas["indexable"])); $this->assertTrue(is_bool($metadatas["multivalue"])); $this->assertTrue(is_bool($metadatas["readonly"])); @@ -487,7 +487,7 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract $this->assertNotEquals($subdef->get_size(), $headers["download_content_length"]); break; case "url" : - $this->assertTrue(strpos($headers['content_type'], $subdef->get_mime()) === 0, 'Verify that header '.$headers['content_type'].' contains subdef mime type '.$subdef->get_mime()); + $this->assertTrue(strpos($headers['content_type'], $subdef->get_mime()) === 0, 'Verify that header ' . $headers['content_type'] . ' contains subdef mime type ' . $subdef->get_mime()); $this->assertEquals($subdef->get_size(), $headers["download_content_length"]); break; } @@ -805,189 +805,132 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract { $this->evaluateGoodBasket($basket); $this->assertEquals('un Joli Nom', $basket["name"]); - $basket_obj = basket_adapter::getInstance($appbox, $basket["ssel_id"], $appbox->get_session()->get_usr_id()); - $basket_obj->delete(); } } public function testBasketContent() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); + $basket = $this->insertOneBasket(); - $found = false; - foreach ($basket_coll->get_baskets() as $bask_group => $baskets) + $route = '/baskets/' . $basket->getId() . '/content/?oauth_token=' . self::$token; + + $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + + $crawler = $this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml")); + $content = self::$yaml->parse($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaYaml200($content); + + $this->assertEquals(1, count((array) $content["response"])); + + $this->assertArrayHasKey("basket_elements", $content["response"]); + + foreach ($content["response"]["basket_elements"] as $basket_str) { - if (!in_array($bask_group, array('recept', 'baskets'))) - continue; - foreach ($baskets as $basket) + $this->evaluateGoodBasket($basket_str); + + $this->assertEquals(count($basket->getElements()), count((array) $basket_str["basket_elements"])); + foreach ($basket_str["basket_elements"] as $basket_element) { - $found = true; - $route = '/baskets/' . $basket->get_ssel_id() . '/content/?oauth_token=' . self::$token; - - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); - - $crawler = $this->client->request('GET', $route, array(), array(), array("HTTP_ACCEPT" => "application/yaml")); - $content = self::$yaml->parse($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaYaml200($content); - - $this->assertEquals(1, count((array) $content["response"])); - - $this->assertArrayHasKey("basket_elements", $content["response"]); - - foreach ($content["response"]["basket_elements"] as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals(count($basket->get_elements()), count((array) $basket_str["basket_elements"])); - foreach ($basket_str["basket_elements"] as $basket_element) - { - $this->assertArrayHasKey('basket_element_id', $basket_element); - $this->assertArrayHasKey('order', $basket_element); - $this->assertArrayHasKey('record', $basket_element); - $this->assertArrayHasKey('validation_item', $basket_element); - $this->assertTrue(is_bool($basket_element["validation_item"])); - $this->assertTrue(is_int($basket_element["order"])); - $this->assertTrue(is_int($basket_element["basket_element_id"])); - $this->evaluateGoodRecord($basket_element["record"]); - } - } + $this->assertArrayHasKey('basket_element_id', $basket_element); + $this->assertArrayHasKey('order', $basket_element); + $this->assertArrayHasKey('record', $basket_element); + $this->assertArrayHasKey('validation_item', $basket_element); + $this->assertTrue(is_bool($basket_element["validation_item"])); + $this->assertTrue(is_int($basket_element["order"])); + $this->assertTrue(is_int($basket_element["basket_element_id"])); + $this->evaluateGoodRecord($basket_element["record"]); } } - if (!$found) - $this->markTestSkipped('Unable to test basket set title'); } public function testSetBasketTitle() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); + $basket = $this->insertOneBasket(); - $found = false; + $route = '/baskets/' . $basket->getId() . '/setname/?oauth_token=' . self::$token; - foreach ($basket_coll->get_baskets() as $bask_group => $baskets) + $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + + $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom'), array(), array("HTTP_ACCEPT" => "application/yaml")); + $content = self::$yaml->parse($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaYaml200($content); + + $this->assertEquals(1, count((array) $content["response"])); + $this->assertArrayHasKey("basket", $content["response"]); + foreach ($content["response"]["basket"] as $basket_str) { - if (!in_array($bask_group, array('recept', 'baskets'))) - continue; - foreach ($baskets as $basket) - { + $this->evaluateGoodBasket($basket_str); - $found = true; - $route = '/baskets/' . $basket->get_ssel_id() . '/setname/?oauth_token=' . self::$token; - - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); - - $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom'), array(), array("HTTP_ACCEPT" => "application/yaml")); - $content = self::$yaml->parse($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaYaml200($content); - - $this->assertEquals(1, count((array) $content["response"])); - $this->assertArrayHasKey("basket", $content["response"]); - foreach ($content["response"]["basket"] as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals($basket_str["name"], 'un Joli Nom'); - } - - $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom'), array(), array("HTTP_ACCEPT" => "application/yaml")); - $content = self::$yaml->parse($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaYaml200($content); - - $this->assertEquals(1, count((array) $content["response"])); - - $this->assertArrayHasKey("basket", $content["response"]); - - foreach ($content["response"]["basket"] as $basket) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals($basket_str["name"], 'un Joli Nom'); - } - - $crawler = $this->client->request('POST', $route, array('name' => 'aéaa'), array(), array("HTTP_ACCEPT" => "application/yaml")); - $content = self::$yaml->parse($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaYaml200($content); - - $this->assertEquals(1, count((array) $content["response"])); - $this->assertArrayHasKey("basket", $content["response"]); - foreach ($content["response"]["basket"] as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - $this->assertEquals($basket_str["name"], 'aéaa'); - } - - - break; - } + $this->assertEquals($basket_str["name"], 'un Joli Nom'); + } + + $crawler = $this->client->request('POST', $route, array('name' => 'un Joli Nom'), array(), array("HTTP_ACCEPT" => "application/yaml")); + $content = self::$yaml->parse($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaYaml200($content); + + $this->assertEquals(1, count((array) $content["response"])); + + $this->assertArrayHasKey("basket", $content["response"]); + + foreach ($content["response"]["basket"] as $basket) + { + $this->evaluateGoodBasket($basket_str); + + $this->assertEquals($basket_str["name"], 'un Joli Nom'); + } + + $crawler = $this->client->request('POST', $route, array('name' => 'aéaa'), array(), array("HTTP_ACCEPT" => "application/yaml")); + $content = self::$yaml->parse($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaYaml200($content); + + $this->assertEquals(1, count((array) $content["response"])); + $this->assertArrayHasKey("basket", $content["response"]); + foreach ($content["response"]["basket"] as $basket_str) + { + $this->evaluateGoodBasket($basket_str); + $this->assertEquals($basket_str["name"], 'aéaa'); } - if (!$found) - $this->markTestSkipped('Unable to test basket set title'); } public function testSetBasketDescription() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); + $basket = $this->insertOneBasket(); - $found = false; + $route = '/baskets/' . $basket->getId() . '/setdescription/?oauth_token=' . self::$token; - foreach ($basket_coll->get_baskets() as $bask_group => $baskets) + $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + + $crawler = $this->client->request('POST', $route, array('description' => 'une belle desc'), array(), array("HTTP_ACCEPT" => "application/yaml")); + $content = self::$yaml->parse($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMetaYaml200($content); + + $this->assertEquals(1, count((array) $content["response"])); + + $this->assertArrayHasKey("basket", $content["response"]); + foreach ($content["response"]["basket"] as $basket_str) { - if (!in_array($bask_group, array('recept', 'baskets'))) - continue; - foreach ($baskets as $basket) - { + $this->evaluateGoodBasket($basket_str); - $found = true; - $route = '/baskets/' . $basket->get_ssel_id() . '/setdescription/?oauth_token=' . self::$token; - - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); - - $crawler = $this->client->request('POST', $route, array('description' => 'une belle desc'), array(), array("HTTP_ACCEPT" => "application/yaml")); - $content = self::$yaml->parse($this->client->getResponse()->getContent()); - - $this->evaluateResponse200($this->client->getResponse()); - $this->evaluateMetaYaml200($content); - - $this->assertEquals(1, count((array) $content["response"])); - - $this->assertArrayHasKey("basket", $content["response"]); - foreach ($content["response"]["basket"] as $basket_str) - { - $this->evaluateGoodBasket($basket_str); - - $this->assertEquals($basket_str["description"], 'une belle desc'); - } - - - break; - } + $this->assertEquals($basket_str["description"], 'une belle desc'); } - if (!$found) - $this->markTestSkipped('Unable to test basket set description'); } public function testDeleteBasket() { - $appbox = appbox::get_instance(); - $usr_id = $appbox->get_session()->get_usr_id(); + $baskets = $this->insertFiveBasket(); - $basket = basket_adapter::create($appbox, 'test suppression panier', User_Adapter::getInstance($usr_id, $appbox)); - - $route = '/baskets/' . $basket->get_ssel_id() . '/delete/?oauth_token=' . self::$token; + $route = '/baskets/' . $baskets[0]->getId() . '/delete/?oauth_token=' . self::$token; $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); @@ -998,9 +941,16 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract $this->evaluateMetaYaml200($content); $this->assertArrayHasKey("baskets", $content["response"]); + + $found = false; foreach ($content["response"]["baskets"] as $basket) { $this->evaluateGoodBasket($basket); + $found = true; + } + if (!$found) + { + $this->fail('There should be four baskets left'); } } diff --git a/lib/unitTest/module/lightboxTest.php b/lib/unitTest/module/lightboxTest.php index dbc5573985..ae3dcb24b7 100644 --- a/lib/unitTest/module/lightboxTest.php +++ b/lib/unitTest/module/lightboxTest.php @@ -14,6 +14,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract protected $item; protected $validation_basket; protected static $need_records = 1; + // protected static $need_subdefs = true; public function setUp() @@ -25,16 +26,11 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract $publisher = array_shift($this->feed->get_publishers()); $this->entry = Feed_Entry_Adapter::create($appbox, $this->feed, $publisher, 'title', "sub Titkle", " jean pierre", "jp@test.com"); $this->item = Feed_Entry_Item::create($appbox, $this->entry, self::$record_1); - $basket = basket_adapter::create($appbox, 'bask validation', self::$user); - $basket->push_element(self::$record_1, false, false); - $basket->validation_to_users(self::$user, true, true, true); - $this->validation_basket = $basket; } public function tearDown() { $this->feed->delete(); -// $this->validation_basket->delete(); parent::tearDown(); } @@ -43,79 +39,16 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract return require dirname(__FILE__) . '/../../Alchemy/Phrasea/Application/Lightbox.php'; } - /** - * - * @return array - */ - protected function get_baskets() - { - $appbox = appbox::get_instance(); - $basketcoll = new basketCollection($appbox, self::$user->get_id()); - $basket_coll = $basketcoll->get_baskets(); - - return $basket_coll['baskets']; - } - - /** - * - * @return basket_adapter - */ - protected function get_basket() - { - $appbox = appbox::get_instance(); - $basketcoll = new basketCollection($appbox, self::$user->get_id()); - $basket_coll = $basketcoll->get_baskets(); - while(($basket = array_shift($basket_coll['baskets']))) - { - if(!$basket->is_valid()) - - return $basket; - } - $this->fail('Unable to find a basket'); - } - protected function get_validation_basket() - { - return $this->validation_basket; - } - - /** - * - * @return basket_element_adapter - */ - protected function get_basket_element() - { - $basket = $this->get_basket(); - $basket->push_element(self::$record_1, false, false); - - foreach($basket->get_elements() as $basket_element) - { - return $basket_element; - } - } - /** - * - * @return basket_element_adapter - */ - protected function get_validation_basket_element() - { - $basket = $this->get_validation_basket(); - - foreach($basket->get_elements() as $basket_element) - { - return $basket_element; - } - } - public function testRouteSlash() { - $baskets = $this->get_baskets(); + $baskets = $this->insertFiveBasket(); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); $crawler = $this->client->request('GET', '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); - $this->assertEquals($crawler->filter('div.basket_wrapper')->count(), count($baskets)); + $this->assertEquals(5, $crawler->filter('div.basket_wrapper')->count()); $this->set_user_agent(self::USER_AGENT_IE6); @@ -133,34 +66,35 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract public function testAjaxNoteForm() { - $basket_element = $this->get_basket_element(); + $basket = $this->insertOneValidationBasket(); + $basket_element = $basket->getELements()->first(); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/'.$basket_element->get_sselcont_id().'/'); + $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('', trim($this->client->getResponse()->getContent())); $this->set_user_agent(self::USER_AGENT_IE6); - $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/'.$basket_element->get_sselcont_id().'/'); + $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('', trim($this->client->getResponse()->getContent())); $this->set_user_agent(self::USER_AGENT_IPHONE); - $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/'.$basket_element->get_sselcont_id().'/'); + $crawler = $this->client->request('GET', '/ajax/NOTE_FORM/' . $basket_element->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertNotEquals('', trim($this->client->getResponse()->getContent())); } public function testAjaxElement() { - $basket_element = $this->get_basket_element(); + $basket_element = $this->insertOneBasketElement(); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/'.$basket_element->get_sselcont_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); @@ -176,7 +110,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->set_user_agent(self::USER_AGENT_IE6); - $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/'.$basket_element->get_sselcont_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); @@ -192,7 +126,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->set_user_agent(self::USER_AGENT_IPHONE); - $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/'.$basket_element->get_sselcont_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_BASKET_ELEMENT/' . $basket_element->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertNotEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); } @@ -201,7 +135,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract { $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/'.$this->entry->get_id().'/'.$this->item->get_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); @@ -217,7 +151,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->set_user_agent(self::USER_AGENT_IE6); - $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/'.$this->entry->get_id().'/'.$this->item->get_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); @@ -233,7 +167,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->set_user_agent(self::USER_AGENT_IPHONE); - $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/'.$this->entry->get_id().'/'.$this->item->get_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_FEED_ITEM/' . $this->entry->get_id() . '/' . $this->item->get_id() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertNotEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); } @@ -241,46 +175,46 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract public function testValidate() { - $basket = $this->get_basket(); + $basket = $this->insertOneValidationBasket(); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/validate/'.$basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); $this->set_user_agent(self::USER_AGENT_IE6); - $crawler = $this->client->request('GET', '/validate/'.$basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); $this->set_user_agent(self::USER_AGENT_IPHONE); - $crawler = $this->client->request('GET', '/validate/'.$basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/validate/' . $basket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); } public function testCompare() { - $basket = $this->get_basket(); + $basket = $this->insertOneBasket(); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/compare/'.$basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); $this->set_user_agent(self::USER_AGENT_IE6); - $crawler = $this->client->request('GET', '/compare/'.$basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); $this->set_user_agent(self::USER_AGENT_IPHONE); - $crawler = $this->client->request('GET', '/compare/'.$basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/compare/' . $basket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); } @@ -289,54 +223,74 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract { $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/feeds/entry/'.$this->entry->get_id().'/'); + $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); $this->set_user_agent(self::USER_AGENT_IE6); - $crawler = $this->client->request('GET', '/feeds/entry/'.$this->entry->get_id().'/'); + $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); $this->set_user_agent(self::USER_AGENT_IPHONE); - $crawler = $this->client->request('GET', '/feeds/entry/'.$this->entry->get_id().'/'); + $crawler = $this->client->request('GET', '/feeds/entry/' . $this->entry->get_id() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); } public function testAjaxReport() { + $validationBasket = $this->insertOneValidationBasket(); + $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC); - $crawler = $this->client->request('GET', '/ajax/LOAD_REPORT/'.$this->validation_basket->get_ssel_id().'/'); + $crawler = $this->client->request('GET', '/ajax/LOAD_REPORT/' . $validationBasket->getId() . '/'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertEquals('UTF-8', $this->client->getResponse()->getCharset()); } + public function testAjaxSetNote() { - $crawler = $this->client->request('POST', '/ajax/SET_NOTE/'.$this->get_basket_element()->get_sselcont_id().'/'); + $validationBasket = $this->insertOneValidationBasket(); + $validationBasketElement = $validationBasket->getElements()->first(); + + $crawler = $this->client->request('POST', '/ajax/SET_NOTE/' . $validationBasketElement->getId() . '/'); $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); - $crawler = $this->client->request('POST', '/ajax/SET_NOTE/'.$this->get_validation_basket_element()->get_sselcont_id().'/'); + $crawler = $this->client->request( + 'POST' + , '/ajax/SET_NOTE/' . $validationBasketElement->getId() . '/' + , array('note' => 'une jolie note') + ); - $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ',$this->get_validation_basket_element()->get_sselcont_id())); + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId())); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); $this->assertTrue(is_object($datas), 'asserting good json datas'); $this->assertObjectHasAttribute('datas', $datas); $this->assertObjectHasAttribute('error', $datas); - } + public function testAjaxSetAgreement() { - $crawler = $this->client->request('POST', '/ajax/SET_ELEMENT_AGREEMENT/'.$this->get_basket_element()->get_sselcont_id().'/'); + $validationBasket = $this->insertOneValidationBasket(); + $validationBasketElement = $validationBasket->getElements()->first(); + + $crawler = $this->client->request( + 'POST' + , '/ajax/SET_ELEMENT_AGREEMENT/' . $validationBasketElement->getId() . '/' + ); $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); - $crawler = $this->client->request('POST', '/ajax/SET_ELEMENT_AGREEMENT/'.$this->get_validation_basket_element()->get_sselcont_id().'/'); + $crawler = $this->client->request( + 'POST' + , '/ajax/SET_ELEMENT_AGREEMENT/' . $validationBasketElement->getId() . '/' + , array('agreement' => 1) + ); - $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ',$this->get_validation_basket_element()->get_sselcont_id())); + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId())); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); @@ -344,14 +298,19 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract $this->assertObjectHasAttribute('datas', $datas); $this->assertObjectHasAttribute('error', $datas); } + public function testAjaxSetRelease() { - $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/'.$this->get_basket()->get_ssel_id().'/'); + $basket = $this->insertOneBasket(); + + $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/' . $basket->getId() . '/'); $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); - $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/'.$this->get_validation_basket()->get_ssel_id().'/'); + $validationBasket = $this->insertOneValidationBasket(); - $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ',$this->get_validation_basket()->get_ssel_id())); + $crawler = $this->client->request('POST', '/ajax/SET_RELEASE/' . $validationBasket->getId() . '/'); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasket->getId())); $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-type')); $datas = json_decode($this->client->getResponse()->getContent()); diff --git a/lib/unitTest/module/prod/route/tooltipapplicationTest.php b/lib/unitTest/module/prod/route/tooltipapplicationTest.php index a93ed143c0..b6d4f94005 100644 --- a/lib/unitTest/module/prod/route/tooltipapplicationTest.php +++ b/lib/unitTest/module/prod/route/tooltipapplicationTest.php @@ -27,12 +27,10 @@ class Module_Prod_Route_TooltipTest extends PhraseanetWebTestCaseAuthenticatedAb public function testRouteBasket() { $appbox = appbox::get_instance(); - $basketcoll = new basketCollection($appbox, self::$user->get_id()); - $basket_coll = $basketcoll->get_baskets(); - $basket = array_shift($basket_coll['baskets']); + $basket = $this->insertOneBasket(); - $crawler = $this->client->request('POST', '/tooltip/basket/' . $basket->get_ssel_id() . '/'); + $crawler = $this->client->request('POST', '/tooltip/basket/' . $basket->getId() . '/'); $pageContent = $this->client->getResponse()->getContent(); $this->assertTrue($this->client->getResponse()->isOk()); diff --git a/lib/unitTest/module/rssFeedTest.php b/lib/unitTest/module/rssFeedTest.php index e462b62846..f11b99b73e 100644 --- a/lib/unitTest/module/rssFeedTest.php +++ b/lib/unitTest/module/rssFeedTest.php @@ -15,6 +15,13 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract * @var Feed_Adapter */ public static $feed; + + /** + * + * @var Feed_Adapter_Entry + */ + public static $entry; + public static $publisher; public static $need_records = 1; protected $client; @@ -22,22 +29,30 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract { parent::setUp(); $this->client = $this->createClient(); + self::$feed = Feed_Adapter::create(appbox::get_instance(), self::$user, 'title', 'subtitle'); + self::$publisher = Feed_Publisher_Adapter::getPublisher(appbox::get_instance(), self::$feed, self::$user); + self::$entry = Feed_Entry_Adapter::create(appbox::get_instance(), self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com"); + Feed_Entry_Item::create(appbox::get_instance(), self::$entry, self::$record_1); + self::$feed->set_public(true); + } + + public function tearDown() + { + self::$publisher->delete(); + self::$entry->delete(); + self::$feed->delete(); + parent::tearDown(); } public static function setUpBeforeClass() { parent::setUpBeforeClass(); - self::$feed = Feed_Adapter::create(appbox::get_instance(), self::$user, 'title', 'subtitle'); - $publisher = Feed_Publisher_Adapter::getPublisher(appbox::get_instance(), self::$feed, self::$user); - $entry = Feed_Entry_Adapter::create(appbox::get_instance(), self::$feed, $publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com"); - Feed_Entry_Item::create(appbox::get_instance(), $entry, self::$record_1); - self::$feed->set_public(true); } public static function tearDownAfterClass() { + parent::tearDownAfterClass(); - self::$feed->delete(); } public function createApplication() @@ -45,6 +60,33 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract return require dirname(__FILE__) . '/../../Alchemy/Phrasea/Application/Root.php'; } + public function testGetFeedFormat() + { + $feeds = Feed_Collection::load_public_feeds(appbox::get_instance()); + $feed = array_shift($feeds->get_feeds()); + + $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/"); + $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type")); + $xml = $this->client->getResponse()->getContent(); + $this->verifyXML($xml); + $this->verifyRSS($feed, $xml); + + $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/"); + $this->assertEquals("application/atom+xml", $this->client->getResponse()->headers->get("content-type")); + $xml = $this->client->getResponse()->getContent(); + $this->verifyXML($xml); + $this->verifyATOM($feed, $xml); + } + + public function testCooliris() + { + $crawler = $this->client->request("GET", "/feeds/cooliris/"); + $this->assertTrue($this->client->getResponse()->isOk()); + $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type")); + $xml = $this->client->getResponse()->getContent(); + $this->verifyXML($xml); + } + public function testAggregatedRss() { $feeds = Feed_Collection::load_public_feeds(appbox::get_instance()); @@ -56,7 +98,6 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract $crawler = $this->client->request("GET", "/feeds/aggregated/rss/"); $this->assertTrue($this->client->getResponse()->isOk()); $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type")); -// $this->assertEquals($feeds->get_aggregate()->get_count_total_entries(), $crawler->filterXPath("//channel/item")->count()); $xml = $this->client->getResponse()->getContent(); $this->verifyXML($xml); } @@ -86,35 +127,21 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); } - public function testGetFeedFormat() - { - $feeds = Feed_Collection::load_public_feeds(appbox::get_instance()); - $feed = array_shift($feeds->get_feeds()); - $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/"); - $this->assertEquals("application/rss+xml", $this->client->getResponse()->headers->get("content-type")); - $xml = $this->client->getResponse()->getContent(); - $this->verifyRSS($feed, $xml); - $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/"); - $this->assertEquals("application/atom+xml", $this->client->getResponse()->headers->get("content-type")); - $xml = $this->client->getResponse()->getContent(); - $this->verifyATOM($feed, $xml); - } - public function testGetFeedId() { $feeds = Feed_Collection::load_public_feeds(appbox::get_instance()); $all_feeds = $feeds->get_feeds(); - foreach ($all_feeds as $feed) - { - $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/"); - $this->assertTrue($this->client->getResponse()->isOk()); - $xml = $this->client->getResponse()->getContent(); - $this->verifyRSS($feed, $xml); - $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/"); - $this->assertTrue($this->client->getResponse()->isOk()); - $xml = $this->client->getResponse()->getContent(); - $this->verifyATOM($feed, $xml); - } + $feed = array_shift($all_feeds); + + $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/rss/"); + $this->assertTrue($this->client->getResponse()->isOk()); + $xml = $this->client->getResponse()->getContent(); + $this->verifyRSS($feed, $xml); + + $crawler = $this->client->request("GET", "/feeds/feed/" . $feed->get_id() . "/atom/"); + $this->assertTrue($this->client->getResponse()->isOk()); + $xml = $this->client->getResponse()->getContent(); + $this->verifyATOM($feed, $xml); } public function testPrivateFeedAccess() @@ -129,7 +156,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract public function verifyXML($xml) { - $this->markTestSkipped("En attente"); + return; try { $validator = new W3CFeedRawValidator($xml); @@ -139,7 +166,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract } catch (W3CFeedValidatorException $e) { - $this->fail($e->getMessage()); + print "\nCould not use W3C FEED VALIDATOR API : " . $e->getMessage() . "\n"; } } @@ -180,7 +207,8 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract $this->assertEquals($feed->get_homepage_link(registry::get_instance(), Feed_Adapter::FORMAT_RSS, 1)->get_href(), $child->nodeValue); break; case 'pubDate': - $this->assertTrue(new DateTime() > new DateTime($child->nodeValue)); + $this->assertTrue(new DateTime() >= new DateTime($child->nodeValue)); + break; case 'generator': $this->assertEquals("Phraseanet", $child->nodeValue); @@ -443,12 +471,13 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract { if ($p4field = $entry_item->get_record()->get_caption()->get_dc_field($field["dc_field"])) { - $this->assertEquals($p4field->get_value(true, $field["separator"]), $node->nodeValue); + $this->assertEquals($p4field->get_value(true, $field["separator"]), $node->nodeValue + , sprintf('Asserting good value for DC %s', $field["dc_field"])); if (sizeof($field["media_field"]["attributes"]) > 0) { foreach ($node->attributes as $attribute) { - $this->assertTrue(in_array($attribute->name, $field["media_field"]["attributes"]), "MIssing attribute for " . $field['media_field']['name']); + $this->assertTrue(array_key_exists($attribute->name, $field["media_field"]["attributes"]), "MIssing attribute " . $attribute->name . " for " . $field['media_field']['name']); } } } @@ -509,7 +538,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract $this->assertEquals($feed->get_subtitle(), $subtitles->item(0)->nodeValue); $updateds = $xpath->query('/Atom:feed/Atom:updated'); - $this->assertTrue(new DateTime() > new DateTime($updateds->item(0)->nodeValue)); + $this->assertTrue(new DateTime() >= new DateTime($updateds->item(0)->nodeValue)); $entries_item = $xpath->query('/Atom:feed/Atom:entry'); @@ -583,15 +612,26 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract } $content = $entry->get_content(); - $available_medium = array('image', 'audio', 'video'); - array_walk($content, $this->removeBadItems($content, $available_medium)); - $media_group = $xpath->query("//media:group"); - $this->assertEquals(sizeof($content), $media_group->length); - foreach ($media_group as $media) + + $available_medium = array('image', 'audio', 'video'); + + array_walk($content, $this->removeBadItems($content, $available_medium)); + + + $media_group = $xpath->query("/Atom:feed/Atom:entry[0]/media:group"); + + if ($media_group->length > 0) { - $entry_item = array_shift($content); - $this->verifyMediaItem($entry_item, $media); + foreach ($media_group as $media) + { + + $entry_item = array_shift($content); + if ($entry_item instanceof Feed_Entry_Item) + { + $this->verifyMediaItem($entry_item, $media); + } + } } } diff --git a/lib/unitTest/record/adapterTest.php b/lib/unitTest/record/adapterTest.php index 3c7460e469..67aa823284 100644 --- a/lib/unitTest/record/adapterTest.php +++ b/lib/unitTest/record/adapterTest.php @@ -14,6 +14,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract */ protected static $grouping; protected static $need_records = true; + protected static $need_story = true; protected static $need_subdefs = true; public static function setUpBeforeClass() @@ -30,12 +31,10 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract static::$record_23->set_metadatas($metadatas['metadatas']); $system_file = new system_file(dirname(__FILE__) . '/../testfiles/cestlafete.jpg'); - self::$grouping = record_adapter::create(self::$collection, $system_file, false, true); } public static function tearDownAfterClass() { - self::$grouping->delete(); parent::tearDownAfterClass(); } @@ -102,21 +101,21 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testIs_grouping() { $this->assertFalse(self::$record_1->is_grouping()); - $this->assertTrue(self::$grouping->is_grouping()); + $this->assertTrue(self::$story_1->is_grouping()); } public function testGet_base_id() { $this->assertTrue(is_int(static::$record_1->get_base_id())); $this->assertEquals(self::$collection->get_base_id(), static::$record_1->get_base_id()); - $this->assertTrue(is_int(static::$grouping->get_base_id())); - $this->assertEquals(self::$collection->get_base_id(), static::$grouping->get_base_id()); + $this->assertTrue(is_int(self::$story_1->get_base_id())); + $this->assertEquals(self::$collection->get_base_id(), self::$story_1->get_base_id()); } public function testGet_record_id() { $this->assertTrue(is_int(static::$record_1->get_record_id())); - $this->assertTrue(is_int(static::$grouping->get_record_id())); + $this->assertTrue(is_int(self::$story_1->get_record_id())); } public function testGet_thumbnail() @@ -175,7 +174,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { $this->assertNotNull(static::$record_1->get_sha256()); $this->assertRegExp('/[a-zA-Z0-9]{64}/', static::$record_1->get_sha256()); - $this->assertNull(static::$grouping->get_sha256()); + $this->assertNull(self::$story_1->get_sha256()); } public function testGet_mime() @@ -416,7 +415,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_reg_name() { - $this->assertTrue(is_string(self::$grouping->get_reg_name())); + $this->assertTrue(is_string(self::$story_1->get_reg_name())); } public function testGet_record_by_sha() @@ -473,16 +472,25 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { $appbox = appbox::get_instance(); $usr_id = $appbox->get_session()->get_usr_id(); - $basket_coll = new basketCollection($appbox, $usr_id); - $baskets = $basket_coll->get_baskets(); - $baskets = $baskets['baskets']; - - $basket = array_shift($baskets); - $this->assertInstanceOf('basket_adapter', $basket); - - $basket->push_element(self::$record_1, false, false); - self::$record_1->get_container_baskets(); + + $em = self::$core->getEntityManager(); + $basket = $this->insertOneBasket(); + $this->assertInstanceOf('\Entities\Basket', $basket); + + /* @var $basket \Entities\Basket */ + $basket_element = new \Entities\BasketElement(); + $basket_element->setRecord(self::$record_1); + $basket_element->setBasket($basket); + + $em->persist($basket_element); + + $basket->addBasketElement($basket_element); + + $em->merge($basket); + + $em->flush(); + $found = $sselcont_id = false; $sbas_id = self::$record_1->get_sbas_id(); @@ -490,13 +498,13 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach (self::$record_1->get_container_baskets() as $c_basket) { - if ($c_basket->get_ssel_id() == $basket->get_ssel_id()) + if ($c_basket->getId() == $basket->getId()) { $found = true; - foreach ($c_basket->get_elements() as $b_el) + foreach ($c_basket->getElements() as $b_el) { - if ($b_el->get_record()->get_record_id() == $record_id && $b_el->get_record()->get_sbas_id() == $sbas_id) - $sselcont_id = $b_el->get_sselcont_id(); + if ($b_el->getRecord()->get_record_id() == $record_id && $b_el->getRecord()->get_sbas_id() == $sbas_id) + $sselcont_id = $b_el->getId(); } } } @@ -505,7 +513,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract if (!$found) $this->fail(); - $basket->remove_from_ssel($sselcont_id); } } diff --git a/lib/unitTest/userTest.php b/lib/unitTest/userTest.php index 82e4fc5a3d..4bcc3d3912 100644 --- a/lib/unitTest/userTest.php +++ b/lib/unitTest/userTest.php @@ -37,12 +37,22 @@ class userTest extends PhraseanetPHPUnitAbstract $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); self::$user->set_email(''); $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); - self::$user->set_email('noonealt1@example.com'); - $this->assertEquals(self::$user->get_id(), User_Adapter::get_usr_id_from_email('noonealt1@example.com')); + self::$user->set_email('noone@example.com'); + $this->assertEquals(self::$user->get_id(), User_Adapter::get_usr_id_from_email('noone@example.com')); } catch(Exception $e) { $this->fail($e->getMessage()); + } + try + { + + self::$user->set_email('noonealt1@example.com'); + $this->fail('A user already got this address'); + } + catch(Exception $e) + { + } $this->assertFalse(User_Adapter::get_usr_id_from_email(null)); } diff --git a/templates/mobile/lightbox/basket_element.twig b/templates/mobile/lightbox/basket_element.twig index 9a870f8b6e..a982e7b254 100644 --- a/templates/mobile/lightbox/basket_element.twig +++ b/templates/mobile/lightbox/basket_element.twig @@ -11,28 +11,30 @@ {% endblock %} {% block content %} - {% set record = basket_element.get_record() %} + {% set record = basket_element.getRecord() %}
- Back -

{{basket_element.get_order()}} - {{record.get_title()}}

+ Back +

{{basket_element.getOrd()}} - {{record.get_title()}}

Home
{{ thumbnail.format100percent(record.get_preview(),'',session, record.get_thumbnail()) }} - {% if basket_element.is_validation_item() %} + {% if basket_element.getBasket().getValidation() %}
- - + + - - + +
-
    +
      {% include 'lightbox/sc_note.twig' %}
diff --git a/templates/mobile/lightbox/feed.twig b/templates/mobile/lightbox/feed.twig index 3fabc50d41..933e7385be 100644 --- a/templates/mobile/lightbox/feed.twig +++ b/templates/mobile/lightbox/feed.twig @@ -20,10 +20,10 @@ {{feed_entry.get_subtitle()|nl2br|raw}}

+ {% set author = feed_entry.get_author_name() %} {% trans %}Par {{ author }}{% endtrans %} {% set entry_length = feed_entry.get_content()|length %} {% trans %}{{entry_length}} documents{% endtrans %} - {% set author = feed_entry.get_author_name() %}

diff --git a/templates/mobile/lightbox/feed_element.twig b/templates/mobile/lightbox/feed_element.twig index 28fe319a89..907a6c05b7 100644 --- a/templates/mobile/lightbox/feed_element.twig +++ b/templates/mobile/lightbox/feed_element.twig @@ -15,7 +15,7 @@
Back -

{{feed_element.get_order()}} - {{record.get_title()}}

+

{{feed_element.get_ord()}} - {{record.get_title()}}

Home
diff --git a/templates/mobile/lightbox/index.twig b/templates/mobile/lightbox/index.twig index 9e7a2f9b7a..3e2c140483 100644 --- a/templates/mobile/lightbox/index.twig +++ b/templates/mobile/lightbox/index.twig @@ -13,27 +13,23 @@ {% endblock %} {% macro valid_baskets_length(baskets) %} - {% set foo = 0 %} + {% set number = 0 %} {% for item in baskets %} - {% if item.is_valid() %} - {% set foo = foo + 1 %} + {% if item.getValidation() %} + {% set number = number + 1 %} {% endif %} {% endfor %} - {{foo}} + {{number}} {% endmacro %} -{% macro baskets_length(baskets_collection) %} - {% set foo = 0 %} - {% for key,baskets in baskets_collection.get_baskets() %} - {% if key == 'baskets' or key == 'recept' %} - {% for item in baskets %} - {% if item.is_valid() == false %} - {% set foo = foo + 1 %} - {% endif %} - {% endfor %} +{% macro baskets_length(baskets) %} + {% set number = 0 %} + {% for item in baskets %} + {% if item.getValidation() == false %} + {% set number = number + 1 %} {% endif %} {% endfor %} - {{foo}} + {{number}} {% endmacro %} {% block content %} @@ -46,7 +42,7 @@
-

Phraseanet Version {{session.get_version()}}

+

Phraseanet Version {{core.getVersion().getName()}} - {{core.getVersion().getNumber()}}

@@ -91,22 +87,18 @@ {% trans 'Voici vos validations en cours' %}

@@ -124,22 +116,18 @@ {% trans 'Voici vos paniers' %}

    - {% for key,baskets in baskets_collection.get_baskets() %} - {% if key == 'baskets' or key == 'recept' %} - {% for item in baskets %} - {% if item.is_valid() == false %} - {% set basket_length = item.get_elements()|length%} -
  • - {% if item.get_first_element() %} - - {% endif %} -

    {{item.get_name()}}

    -

    {{item.get_description()}}

    - {{basket_length}} -
  • - {% endif %} - {% endfor %} - {% endif %} + {% for basket in baskets_collection %} + {% if basket.getValidation() is empty %} + {% set basket_length = basket.getElements().count() %} +
  • + {% if basket.getElements().first() %} + + {% endif %} +

    {{ basket.getName() }}

    +

    {{ basket.getDescription() }}

    + {{basket_length}} +
  • + {% endif %} {% endfor %}
diff --git a/templates/mobile/lightbox/note_form.twig b/templates/mobile/lightbox/note_form.twig index b17e2e1dfc..25ac74de76 100644 --- a/templates/mobile/lightbox/note_form.twig +++ b/templates/mobile/lightbox/note_form.twig @@ -11,17 +11,17 @@ {% endblock %} {% block content %} -
+
-

{{basket_element.get_record().get_title}} - Note

+

{{basket_element.getRecord().get_title}} - Note

- - + id="note_area_{{basket_element.getId()}}" + {% if basket_element.getUserValidationDatas(user).getNote() == '' %}placeholder="Note"{% endif %}>{{basket_element.getUserValidationDatas(user).getNote()}} + +
diff --git a/templates/mobile/lightbox/sc_note.twig b/templates/mobile/lightbox/sc_note.twig index 8d0a550ee9..40295e61b2 100644 --- a/templates/mobile/lightbox/sc_note.twig +++ b/templates/mobile/lightbox/sc_note.twig @@ -1,15 +1,16 @@ -{% for choice in basket_element.get_choices() %} - {% if choice.note != '' or (choice.agreement != 0 and choice.is_mine == false) %} +{% for validationDatas in basket_element.getValidationDatas() %} + {% set is_mine = validationDatas.getParticipant().getUser().get_id() == user.get_id() %} + {% if validationDatas.getNote() != '' or (validationDatas.getAgreement() != null and is_mine) %}
  • - {% if choice.is_mine == false and choice.agreement != 0 %} + {% if is_mine == false and validationDatas.getAgreement() != null %} + src="/skins/lightbox/{% if validationDatas.getAgreement() == true %}agree.png{% else %}disagree.png{% endif %}" /> {% endif %} - {{choice.usr_name}} + {{ validationDatas.getParticipant().getUser().get_display_name() }}

    - {% if choice.note != '' %} -

    {% trans 'validation:: note'%} : {{choice.note|nl2br|raw}}

    + {% if validationDatas.getNote() != '' %} +

    {% trans 'validation:: note'%} : {{ validationDatas.getNote()|nl2br }}

    {% endif %}
  • {% endif %} diff --git a/templates/mobile/lightbox/validate.twig b/templates/mobile/lightbox/validate.twig index d0518636fb..24b7a618d4 100644 --- a/templates/mobile/lightbox/validate.twig +++ b/templates/mobile/lightbox/validate.twig @@ -12,24 +12,24 @@ {% block content %}
    - {% trans 'Back' %} -

    {{basket.get_name()}}

    + {% trans 'Back' %} +

    {{basket.getName()}}

    {% trans 'Home' %}

    - {% set basket_length = basket.get_elements()|length %} + {% set basket_length = basket.getElements().count() %} {% trans %}{{basket_length}} documents{% endtrans %}

    diff --git a/templates/web/admin/databox/doc_structure.twig b/templates/web/admin/databox/doc_structure.twig index 5819a174ae..f3fe059f73 100644 --- a/templates/web/admin/databox/doc_structure.twig +++ b/templates/web/admin/databox/doc_structure.twig @@ -252,12 +252,18 @@ {% trans 'Indexable' %} + + {% trans 'Required' %} + {% trans 'Lecture seule' %} {% trans 'Type' %} + + {% trans 'Separateur' %} + {% trans 'Branche Thesaurus' %} @@ -307,12 +313,15 @@ + + + - {{field.get_type()}} + + + + diff --git a/templates/web/admin/editusers.twig b/templates/web/admin/editusers.twig index 8e7a18f87e..dd36b33274 100644 --- a/templates/web/admin/editusers.twig +++ b/templates/web/admin/editusers.twig @@ -111,7 +111,7 @@
  • Droits
  • - {% if main_user is not empty %} + {% if main_user is not empty and main_user.is_template is empty %}
  • Fiche
  • @@ -142,7 +142,7 @@ - + @@ -402,7 +402,7 @@
    - {% if main_user is not empty %} + {% if main_user is not empty and main_user.is_template is empty %}
    diff --git a/templates/web/admin/publications/fiche.html b/templates/web/admin/publications/fiche.html index 7478e9a41d..a942e5065b 100644 --- a/templates/web/admin/publications/fiche.html +++ b/templates/web/admin/publications/fiche.html @@ -42,7 +42,7 @@ {% for databox in user.ACL().get_granted_sbas('bas_chupub') %} {% for collection in databox.get_collections() %} - + {% endfor %} {% endfor %} diff --git a/templates/web/admin/task.html b/templates/web/admin/task.html index eb35b69976..34ffc87d5d 100644 --- a/templates/web/admin/task.html +++ b/templates/web/admin/task.html @@ -1,440 +1,449 @@ - - - - - {{task.printInterfaceHEAD()}} - - + + + - - {{task.printInterfaceJS()}} - + + + {{task.printInterfaceJS()}} + - + - -
    -

    {{task.getName()}} id : {{task.get_task_id()}}

    - - - - - - -
    - {% trans 'admin::tasks: Nombre de crashes : ' %} {{task.get_crash_counter()}} - - - {% trans 'admin::tasks: reinitialiser el compteur de crashes' %} -
    -
    - -
    -
    -
    - {% if task.printInterfaceHTML %} -
    - {% trans 'boutton::vue graphique' %} -
    - {% endif %} -
    - {% trans 'boutton::vue xml' %} -
    -
    - {% if task.getGraphicForm %} -
    - {% if task.printInterfaceHTML %} - {{task.printInterfaceHTML()|raw}} - {% else %} -
    - {% endif %} -
    - - {% endif %} - -
    -
    - - - - - - + +
    +

    {{task.getName()}} id : {{task.get_task_id()}}

    + + + + + -
    - +
    + {% trans 'admin::tasks: Nombre de crashes : ' %} {{task.get_crash_counter()}} + + + {% trans 'admin::tasks: reinitialiser el compteur de crashes' %} +
    -
    +
    +
    +
    + {% if task.printInterfaceHTML %} +
    + {% trans 'boutton::vue graphique' %} +
    + {% endif %} +
    + {% trans 'boutton::vue xml' %} +
    +
    + {% if task.getGraphicForm %} +
    + {% if task.printInterfaceHTML %} + {{task.printInterfaceHTML()|raw}} + {% else %} +
    + {% endif %} +
    + + {% endif %} + +
    +
    + + + + + + + +
    + +
    -
    -
    -
    - - -
    -
    - -
    - - +
    +
    +
    + + + +
    +
    + +
    + + + \ No newline at end of file diff --git a/templates/web/admin/users.html b/templates/web/admin/users.html index e396f3c187..47c1ea5099 100644 --- a/templates/web/admin/users.html +++ b/templates/web/admin/users.html @@ -52,33 +52,91 @@

    +
    +

    + {% trans 'Apply a template' %} + + +

    +
    - - - - - - - - @@ -120,8 +178,8 @@ {{users.get_total}} resultats - {% set pages = users.get_total() / 20 %} - {% set modulo = users.get_total() % 20 %} + {% set pages = users.get_total() / parm['per_page'] %} + {% set modulo = users.get_total() % parm['per_page'] %} {% if modulo > 0 %}{% set pages = pages + 1 %}{% endif %} {{pages|floor}} pages @@ -188,6 +246,9 @@ el.addClass('selected'); } }); + $('#users_page_form select[name="per_page"]').bind('change', function(){ + $(this).closest('form').submit(); + }); }); diff --git a/templates/web/common/caption.html b/templates/web/common/caption.html index 29dfc8ba3f..4139c808b7 100644 --- a/templates/web/common/caption.html +++ b/templates/web/common/caption.html @@ -6,13 +6,13 @@ {% import 'common/caption_templates/preview.html' as cap_prev %} {% if view == 'answer' %} - {{cap_ans.format_caption(record, highlight, searchEngine)}} + {{cap_ans.format_caption(record, highlight|default(''), searchEngine|default(null))}} {% elseif view == 'lazaret' %} - {{cap_laz.format_caption(record, highlight, searchEngine)}} + {{cap_laz.format_caption(record, highlight|default(''), searchEngine|default(null))}} {% elseif view == 'preview' %} - {{cap_prev.format_caption(record, highlight, searchEngine)}} + {{cap_prev.format_caption(record, highlight|default(''), searchEngine|default(null))}} {% elseif view == 'basket' %} - {{cap_bas.format_caption(record, highlight|default(''), searchEngine)}} + {{cap_bas.format_caption(record, highlight|default(''), searchEngine|default(null))}} {% elseif view == 'overview' %} - {{cap_ovr.format_caption(record, highlight|default(''), searchEngine)}} + {{cap_ovr.format_caption(record, highlight|default(''), searchEngine|default(null))}} {% endif %} \ No newline at end of file diff --git a/templates/web/common/caption_templates/answer.html b/templates/web/common/caption_templates/answer.html index f1fb7e9bf2..3e219f8320 100644 --- a/templates/web/common/caption_templates/answer.html +++ b/templates/web/common/caption_templates/answer.html @@ -1,5 +1,5 @@ {% macro format_caption(record, highlight, searchEngine) %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine) %} -
    {{name}} : {{value|raw}}
    +
    {{name}} : {{value.value|raw}}
    {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/web/common/caption_templates/basket_element.html b/templates/web/common/caption_templates/basket_element.html index 8e4e1afefb..1ed37f824d 100644 --- a/templates/web/common/caption_templates/basket_element.html +++ b/templates/web/common/caption_templates/basket_element.html @@ -1,5 +1,5 @@ {% macro format_caption(record) %} {% for name, value in record.get_caption().get_highlight_fields() %} -
    {{name}} : {{value|raw}}
    +
    {{name}} : {{value.value|raw}}
    {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/web/common/caption_templates/internal_publi.html b/templates/web/common/caption_templates/internal_publi.html index 8e4e1afefb..1ed37f824d 100644 --- a/templates/web/common/caption_templates/internal_publi.html +++ b/templates/web/common/caption_templates/internal_publi.html @@ -1,5 +1,5 @@ {% macro format_caption(record) %} {% for name, value in record.get_caption().get_highlight_fields() %} -
    {{name}} : {{value|raw}}
    +
    {{name}} : {{value.value|raw}}
    {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/web/common/caption_templates/lazaret.html b/templates/web/common/caption_templates/lazaret.html index 8e4e1afefb..1ed37f824d 100644 --- a/templates/web/common/caption_templates/lazaret.html +++ b/templates/web/common/caption_templates/lazaret.html @@ -1,5 +1,5 @@ {% macro format_caption(record) %} {% for name, value in record.get_caption().get_highlight_fields() %} -
    {{name}} : {{value|raw}}
    +
    {{name}} : {{value.value|raw}}
    {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/web/common/caption_templates/overview.html b/templates/web/common/caption_templates/overview.html index 04e2d1278b..55d1775e11 100644 --- a/templates/web/common/caption_templates/overview.html +++ b/templates/web/common/caption_templates/overview.html @@ -1,5 +1,5 @@ {% macro format_caption(record) %} {% for name, value in record.get_caption().get_highlight_fields() %} -
    {{name}} : {{value|raw}}
    +
    {{name}} : {{value.value|raw}}
    {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/web/common/caption_templates/preview.html b/templates/web/common/caption_templates/preview.html index f1fb7e9bf2..3e219f8320 100644 --- a/templates/web/common/caption_templates/preview.html +++ b/templates/web/common/caption_templates/preview.html @@ -1,5 +1,5 @@ {% macro format_caption(record, highlight, searchEngine) %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine) %} -
    {{name}} : {{value|raw}}
    +
    {{name}} : {{value.value|raw}}
    {% endfor %} {% endmacro %} \ No newline at end of file diff --git a/templates/web/common/dialog_export.twig b/templates/web/common/dialog_export.twig index b18a55bab9..2990e8b452 100644 --- a/templates/web/common/dialog_export.twig +++ b/templates/web/common/dialog_export.twig @@ -376,7 +376,7 @@
    - {% for datas in download.ftp_datas %} + {% for datas in download.get_ftp_datas() %} {{ _self.print_ftp_form(datas) }} {% endfor %}
    diff --git a/templates/web/lightbox/IE6/agreement_box.twig b/templates/web/lightbox/IE6/agreement_box.twig index 9c2db96dfd..18f220a9b0 100644 --- a/templates/web/lightbox/IE6/agreement_box.twig +++ b/templates/web/lightbox/IE6/agreement_box.twig @@ -1,41 +1,46 @@ -{% if basket_element and basket_element.is_validation_item() %} +{% if basket_element and basket_element.getBasket().getValidation() %}
    + {% trans 'admin::compte-utilisateur id utilisateur' %} + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur identifiant' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur nom/prenom' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur societe' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur email' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur pays' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur dernier modele applique' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + + + + {% trans 'admin::compte-utilisateur date de creation' %} + + + {{ parm.ord == 'asc' ? '▼' : '▲' }} + +
    - +
    {% trans 'VALIDATION' %}{% trans 'lightbox::recaptitulatif' %} + + {% trans 'lightbox::recaptitulatif' %} + +
    - {% if basket.is_valid() %} -
    {{basket.get_validation_infos}}
    + {% if basket.getValidation() %} +
    + {{ basket.getValidation().getValidationString(user) }} +
      - {% for choice in basket_element.get_choices() %} - {% if choice.agreement == 1 %} + {% for validation_data in basket_element.getValidationDatas() %} + {% if validation_data.getAgreement() == true %} {% set classuser = 'agree' %} - {% elseif choice.agreement == -1 %} - {% set classuser = 'disagree' %} - {% else %} + {% elseif validation_data.getAgreement() == false %} {% set classuser = '' %} + {% else %} + {% set classuser = 'disagree' %} {% endif %} -
    • {{choice.usr_name}}
    • {% endfor %}
    {% endif %} - {% if basket_element and basket_element.is_validation_item() %} + {% if basket_element and basket_element.getBasket().getValidation() %}
    diff --git a/templates/web/lightbox/IE6/basket_options.twig b/templates/web/lightbox/IE6/basket_options.twig index ef3212b290..543147f8da 100644 --- a/templates/web/lightbox/IE6/basket_options.twig +++ b/templates/web/lightbox/IE6/basket_options.twig @@ -1,4 +1,4 @@ -{% if basket.is_valid() %} +{% if basket.getValidation() %} @@ -46,8 +45,6 @@ {% set preview = first_item.get_record().get_preview() %} {{thumbnail.format(preview, preview.get_width(), preview.get_height(),'',session, false)}} {% endif %} - {% include 'lightbox/selector_box.twig' %} - {% include 'lightbox/sc_note.twig' %}
    @@ -109,38 +106,17 @@
    -
    +
    {% trans 'validation:: OUI' %}
    -
    +
    {% trans 'validation:: NON' %}
    -
    {% if first_item %}{{first_item.get_order()}}{% endif %}
    +
    {% if first_item %}{{first_item.get_ord()}}{% endif %}
    @@ -35,7 +35,6 @@
    - {% include 'lightbox/IE6/sc_options_box.twig' %}
    - + +
    - + + +
    +
    diff --git a/templates/web/lightbox/IE6/feed_options_box.twig b/templates/web/lightbox/IE6/feed_options_box.twig new file mode 100644 index 0000000000..174b50637a --- /dev/null +++ b/templates/web/lightbox/IE6/feed_options_box.twig @@ -0,0 +1,30 @@ + + {% if feed_element %} + + + + + + + + + + + | + {% endif %} + + diff --git a/templates/web/lightbox/IE6/index.twig b/templates/web/lightbox/IE6/index.twig index cfb6aa6a8b..56325083d6 100644 --- a/templates/web/lightbox/IE6/index.twig +++ b/templates/web/lightbox/IE6/index.twig @@ -30,67 +30,62 @@ - {% for key,baskets in baskets_collection.get_baskets() %} - {% if key == 'baskets' %} - {% for item in baskets %} - {% if item.is_valid() %} - {% set basket_length = item.get_elements()|length%} - - -
    - - - - - - - - -
    - {% if basket_length > 0%} - {{thumbnail.format(item.get_first_element.get_record().get_thumbnail, 170, 170, '', session, true)}} - {% endif %} - - -
    - - - - - - - - - - - -
    -

    - {{item.get_name()}} -

    - {% if item.is_validation_finished %} - {% trans '(validation) session terminee' %} - {% elseif item.is_confirmed %} - {% trans '(validation) envoyee' %} - {% else %} - {% trans '(validation) a envoyer' %} - {% endif %} -
    - {% set basket_length = item.get_elements()|length%} - ({% trans %}{{basket_length}} documents{% endtrans %}) -
    -
    {{item.get_description()}}
    -
    {{item.get_validation_infos}}
    -
    -
    -
    - -
    - - - {% endif %} - {% endfor %} - {% endif %} + {% for basket in baskets_collection %} + {% if basket.getValidation() %} + {% set basket_length = basket.getElements().count() %} + + +
    + + + + + + + + +
    + {% if basket_length > 0%} + {{thumbnail.format(basket.getELements().first().getRecord().get_thumbnail, 170, 170, '', session, true)}} + {% endif %} + + +
    + + + + + + + + + + + +
    +

    + {{basket.getName()}} +

    + {% if basket.getValidation().isFinished() %} + {% trans '(validation) session terminee' %} + {% elseif basket.getValidation().getParticipant(user).getIsConfirmed() %} + {% trans '(validation) envoyee' %} + {% else %} + {% trans '(validation) a envoyer' %} + {% endif %} +
    + ({% trans %}{{basket_length}} documents{% endtrans %}) +
    +
    {{ basket.getDescription() }}
    +
    {{ basket.getValidation.getValidationString(user) }}
    +
    +
    +
    + +
    + + + {% endif %} {% endfor %} @@ -100,59 +95,54 @@ {% trans 'Voici vos paniers' %} - {% for key,baskets in baskets_collection.get_baskets() %} - {% if key == 'baskets' or key == 'recept' %} - {% for item in baskets %} - {% if item.is_valid() == false %} - {% set basket_length = item.get_elements()|length%} - - -
    - - - - - - - - -
    - {% if basket_length > 0%} - {{thumbnail.format(item.get_first_element.get_record().get_thumbnail, 170, 170, '', session, true)}} - {% endif %} - - -
    - - - - - - - - - - - -
    -

    - {{item.get_name()}} -

    -
    - {% set basket_length = item.get_elements()|length%} - ({% trans %}{{basket_length}} documents{% endtrans %}) -
    -
    {{item.get_description()}}
    -
    -
    -
    - -
    - - - {% endif %} - {% endfor %} - {% endif %} + {% for basket in baskets_collection %} + {% if basket.getValidation() is null %} + {% set basket_length = basket.getElements().count() %} + + +
    + + + + + + + + +
    + {% if basket_length > 0%} + {{thumbnail.format(basket.getElements().first().getRecord().get_thumbnail, 170, 170, '', session, true)}} + {% endif %} + + +
    + + + + + + + + + + + +
    +

    + {{basket.getName()}} +

    +
    + ({% trans %}{{basket_length}} documents{% endtrans %}) +
    +
    {{basket.getDescription()}}
    +
    +
    +
    + +
    + + + {% endif %} {% endfor %} diff --git a/templates/web/lightbox/IE6/sc_container.twig b/templates/web/lightbox/IE6/sc_container.twig index 05e791c83e..1cd70808d6 100644 --- a/templates/web/lightbox/IE6/sc_container.twig +++ b/templates/web/lightbox/IE6/sc_container.twig @@ -1,24 +1,24 @@ {% block basket %}
    - {% for element in basket.get_elements() %} + {% for element in basket.getElements() %}
    - - diff --git a/templates/web/lightbox/IE6/sc_options_box.twig b/templates/web/lightbox/IE6/sc_options_box.twig index 50023759d5..ff4197a9de 100644 --- a/templates/web/lightbox/IE6/sc_options_box.twig +++ b/templates/web/lightbox/IE6/sc_options_box.twig @@ -22,13 +22,19 @@
    - +
    | - {% if basket_element.is_validation_item() %} + {% if basket_element.getBasket().getValidation() %} {% endif %} {% endif %} diff --git a/templates/web/lightbox/IE6/validate.twig b/templates/web/lightbox/IE6/validate.twig index c929ca9dd7..bf917423ba 100644 --- a/templates/web/lightbox/IE6/validate.twig +++ b/templates/web/lightbox/IE6/validate.twig @@ -16,7 +16,7 @@ {% endblock %} {% block content %} - {% set basket_element = basket.get_first_element%} + {% set basket_element = basket.getElements().first() %}
    @@ -27,11 +27,11 @@ -
    {% if basket_element %}{{basket_element.get_order()}}{% endif %}
    +
    {% if basket_element %}{{basket_element.getOrd()}}{% endif %}
    -
    - {% if basket_element %}{{basket_element.get_record().get_title}}{% endif %} +
    + {% if basket_element %}{{basket_element.getRecord().get_title}}{% endif %}
    @@ -44,7 +44,7 @@
    {% if basket_element %} - {% set bask_prev = basket_element.get_record().get_preview() %} + {% set bask_prev = basket_element.getRecord().get_preview() %} {{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'',session, false)}} {% endif %} {% include 'lightbox/selector_box.twig' %} @@ -60,8 +60,8 @@
    -
    - {% if basket_element %}{{basket_element.get_record().get_title}}{% endif %} +
    + {% if basket_element %}{{basket_element.getRecord().get_title}}{% endif %}
    @@ -82,7 +82,7 @@ {% trans 'notice'%} - {% if basket.is_valid() %} + {% if basket.getValidation() %} {% trans 'Validation'%} @@ -92,16 +92,16 @@
    -
    +
    {% if basket_element %} - {{caption.format_caption(basket_element.get_record())}} + {{caption.format_caption(basket_element.getRecord())}} {% endif %}
    - {% if basket.is_valid() %} + {% if basket.getValidation() %}
    {% include 'lightbox/IE6/agreement_box.twig' %}
    @@ -127,27 +127,19 @@ diff --git a/templates/web/lightbox/agreement_box.twig b/templates/web/lightbox/agreement_box.twig index cb0cdd6a05..b5f7c72ab6 100644 --- a/templates/web/lightbox/agreement_box.twig +++ b/templates/web/lightbox/agreement_box.twig @@ -8,32 +8,33 @@ - {% if basket.is_valid() %} -
    {{basket.get_validation_infos}}
    + {% if basket.getValidation() %} +
    {{ basket.getValidation().getValidationString(user) }}
      - {% for choice in basket_element.get_choices() %} - {% if choice.agreement == 1 %} + {% for choice in basket_element.getValidationDatas() %} + {% if choice.getAgreement() == true %} {% set classuser = 'agree' %} - {% elseif choice.agreement == -1 %} - {% set classuser = 'disagree' %} - {% else %} + {% elseif choice.getAgreement() == null %} {% set classuser = '' %} + {% else %} + {% set classuser = 'disagree' %} {% endif %} -
    • {{choice.usr_name}}
    • + {% set participant = choice.getParticipant().getUser() %} +
    • {{participant.get_display_name()}}
    • {% endfor %}
    {% endif %}
    -{% if basket_element and basket_element.is_validation_item() %} +{% if basket_element and basket_element.getBasket().getValidation() %}
    -
    +
    {% trans 'validation:: OUI' %}
    -
    +
    {% trans 'validation:: NON' %}
    diff --git a/templates/web/lightbox/basket_content_report.twig b/templates/web/lightbox/basket_content_report.twig index 59f9d28079..9acbfb4af1 100644 --- a/templates/web/lightbox/basket_content_report.twig +++ b/templates/web/lightbox/basket_content_report.twig @@ -2,17 +2,17 @@ {% import 'common/thumbnail.html' as thumbnail %}
    - {% for basket_element in basket.get_elements() %} - {% set record = basket_element.get_record() %} - + {% for basket_element in basket.getElements() %} + {% set record = basket_element.getRecord() %} +
    @@ -48,8 +48,6 @@ {% set bask_prev = first_item.get_record().get_preview() %} {{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'',session, false)}} {% endif %} - {% include 'lightbox/selector_box.twig' %} - {% include 'lightbox/sc_note.twig' %}
    diff --git a/templates/web/lightbox/feed_options_box.twig b/templates/web/lightbox/feed_options_box.twig new file mode 100644 index 0000000000..57b289427d --- /dev/null +++ b/templates/web/lightbox/feed_options_box.twig @@ -0,0 +1,30 @@ + + {% if feed_element %} + + + + + + + +
    + + + | + {% endif %} +
    + diff --git a/templates/web/lightbox/index.twig b/templates/web/lightbox/index.twig index 03b28347c4..bfd8e222d6 100644 --- a/templates/web/lightbox/index.twig +++ b/templates/web/lightbox/index.twig @@ -31,67 +31,62 @@
    - {% for key,baskets in baskets_collection.get_baskets() %} - {% if key == 'baskets' %} - {% for item in baskets %} - {% if item.is_valid() %} - {% set basket_length = item.get_elements()|length%} - - - - {% endif %} - {% endfor %} - {% endif %} + {% for basket in baskets_collection %} + {% if basket.getValidation() %} + {% set basket_length = basket.getElements().count() %} + + + + {% endif %} {% endfor %} - {% for key,baskets in baskets_collection.get_baskets() %} - {% if key == 'baskets' or key == 'recept' %} - {% for item in baskets %} - {% if item.is_valid() == false %} - {% set basket_length = item.get_elements()|length%} - - - - {% endif %} - {% endfor %} - {% endif %} + {% for basket in baskets_collection %} + {% if basket.getValidation is null %} + {% set basket_length = basket.getElements().count() %} + + + + {% endif %} {% endfor %}
    -
    - {{basket_element.get_order()}} + {{basket_element.getOrd()}}
    {{thumbnail.format(record.get_thumbnail(),165, 125, '', session, true)}}
    @@ -20,22 +20,22 @@
    - {% for choice in basket_element.get_choices()%} + {% for validationDatas in basket_element.getValidationDatas()%}
    - {% if choice.agreement == 1 %} + {% if validationDatas.getAgreement() == true %} {% set imguser = '' %} {% set styleuser = '' %} - {% elseif choice.agreement == -1 %} + {% elseif validationDatas.getAgreement() == false %} {% set imguser = '' %} {% set styleuser = '' %} {% else %} {% set imguser = '' %} {% set styleuser = 'margin-left:18px;' %} {% endif %} - {{imguser|raw}} {{choice.usr_name}} - {% if choice.note != '' %} - : {{choice.note|nl2br}} + {{imguser|raw}} {{validationDatas.getParticipant().getUser().get_display_name()}} + {% if validationDatas.getNote() != '' %} + : {{validationDatas.getNote()|nl2br}} {% endif %}
    diff --git a/templates/web/lightbox/basket_options.twig b/templates/web/lightbox/basket_options.twig index 34b8492981..2409f03bf0 100644 --- a/templates/web/lightbox/basket_options.twig +++ b/templates/web/lightbox/basket_options.twig @@ -1,4 +1,4 @@ -{% if basket.is_valid() %} +{% if basket.getValidation() %}
    - {% set basket_element = first_item %} - {% include 'lightbox/sc_options_box.twig' %} + {% set feed_element = first_item %} + {% include 'lightbox/feed_options_box.twig' %}
    -
    - - - - - - - - -
    - {% if basket_length > 0%} - {{thumbnail.format(item.get_first_element.get_record().get_thumbnail, 170, 170, '', session, true)}} - {% endif %} - - -
    - - - - - - - - - - - -
    -

    - {{item.get_name()|raw}} -

    - {% if item.is_validation_finished %} - {% trans '(validation) session terminee' %} - {% elseif item.is_confirmed %} - {% trans '(validation) envoyee' %} - {% else %} - {% trans '(validation) a envoyer' %} - {% endif %} -
    - {% set basket_length = item.get_elements()|length%} - ({% trans %}{{basket_length}} documents{% endtrans %}) -
    -
    {{item.get_description()}}
    -
    {{item.get_validation_infos}}
    -
    -
    -
    - -
    -
    +
    + + + + + + + + +
    + {% if basket_length > 0%} + {{thumbnail.format(basket.getElements().first().getRecord().get_thumbnail, 170, 170, '', session, true)}} + {% endif %} + + +
    + + + + + + + + + + + +
    +

    + {{basket.getName()|raw}} +

    + {% if basket.getValidation().isFinished() %} + {% trans '(validation) session terminee' %} + {% elseif basket.getValidation().getParticipant(user).getIsConfirmed() %} + {% trans '(validation) envoyee' %} + {% else %} + {% trans '(validation) a envoyer' %} + {% endif %} +
    + ({% trans %}{{basket_length}} documents{% endtrans %}) +
    +
    {{ basket.getDescription() }}
    +
    {{ basket.getValidation().getValidationString(user) }}
    +
    +
    +
    + +
    +
    @@ -101,59 +96,54 @@ {% trans 'Voici vos paniers' %}
    -
    - - - - - - - - -
    - {% if basket_length > 0%} - {{thumbnail.format(item.get_first_element.get_record().get_thumbnail, 170, 170, '', session, true)}} - {% endif %} - - -
    - - - - - - - - - - - -
    -

    - {{item.get_name()|raw}} -

    -
    - {% set basket_length = item.get_elements()|length%} - ({% trans %}{{basket_length}} documents{% endtrans %}) -
    -
    {{item.get_description()}}
    -
    -
    -
    - -
    -
    +
    + + + + + + + + +
    + {% if basket_length > 0%} + {{thumbnail.format(basket.getElements().first().getRecord().get_thumbnail, 170, 170, '', session, true)}} + {% endif %} + + +
    + + + + + + + + + + + +
    +

    + {{ basket.getName()|raw}} +

    +
    + ({% trans %}{{basket_length}} documents{% endtrans %}) +
    +
    {{ basket.getDescription() }}
    +
    +
    +
    + +
    +
    diff --git a/templates/web/lightbox/sc_container.twig b/templates/web/lightbox/sc_container.twig index 5ec72fd961..befd72af7e 100644 --- a/templates/web/lightbox/sc_container.twig +++ b/templates/web/lightbox/sc_container.twig @@ -1,24 +1,24 @@ {% block basket %}
    - {% for element in basket.get_elements() %} + {% for element in basket.getElements() %}
    - - diff --git a/templates/web/lightbox/sc_note.twig b/templates/web/lightbox/sc_note.twig index 6d0a83bbf5..19052320b3 100644 --- a/templates/web/lightbox/sc_note.twig +++ b/templates/web/lightbox/sc_note.twig @@ -1,25 +1,33 @@ -{% if basket_element and basket_element.is_validation_item() %} -
    -
    -
    -
    -

    {% trans 'validation:: votre note' %}

    -
    - {% for user, datas in basket_element.get_choices() %} - {% if datas.note != '' %} -
    - {{datas.usr_name}} : {{datas.note|nl2br}} -
    - {% endif %} - {% endfor %} - -
    - -
    - - -
    -
    -
    +{% if basket_element and basket_element.getBasket().getValidation() %} +
    +
    +
    +
    +

    {% trans 'validation:: votre note' %}

    +
    +
    + {% for validationDatas in basket_element.getValidationDatas() %} + {% if validationDatas.getNote() != '' %} +
    + + {{validationDatas.getParticipant().getUser().get_display_name()}} + : {{ validationDatas.getNote()|nl2br }} +
    + {% endif %} + {% endfor %} + +
    + +
    + + +
    +
    +
    +
    {% endif %} diff --git a/templates/web/lightbox/sc_options_box.twig b/templates/web/lightbox/sc_options_box.twig index d38f60c567..b5a31dbe45 100644 --- a/templates/web/lightbox/sc_options_box.twig +++ b/templates/web/lightbox/sc_options_box.twig @@ -22,13 +22,19 @@
    - +
    | - {% if basket_element.is_validation_item() %} + {% if basket_element.getBasket().getValidation() %} {% endif %} {% endif %} diff --git a/templates/web/lightbox/selector_box.twig b/templates/web/lightbox/selector_box.twig index 98237fd343..6ce75c7340 100644 --- a/templates/web/lightbox/selector_box.twig +++ b/templates/web/lightbox/selector_box.twig @@ -1,8 +1,8 @@ -{% if basket_element and basket_element.is_validation_item() %} +{% if basket_element and basket_element.getBasket().getValidation() %} {% endif %} diff --git a/templates/web/lightbox/validate.twig b/templates/web/lightbox/validate.twig index 897585b2c1..b4c72aae8f 100644 --- a/templates/web/lightbox/validate.twig +++ b/templates/web/lightbox/validate.twig @@ -18,7 +18,7 @@ {% block content %} - {% set basket_element = basket.get_first_element%} + {% set basket_element = basket.getElements().first() %}
    @@ -29,11 +29,17 @@ -
    {% if basket_element %}{{basket_element.get_order()}}{% endif %}
    +
    + {% if basket_element %} + {{basket_element.getOrd()}} + {% endif %} +
    -
    - {% if basket_element %}{{basket_element.get_record().get_title|raw}}{% endif %} +
    + {% if basket_element %} + {{basket_element.getRecord().get_title}} + {% endif %}
    @@ -46,7 +52,7 @@
    {% if basket_element %} - {% set bask_prev = basket_element.get_record().get_preview() %} + {% set bask_prev = basket_element.getRecord().get_preview() %} {{thumbnail.format(bask_prev,bask_prev.get_width(),bask_prev.get_height(),'',session, false)}} {% endif %} {% include 'lightbox/selector_box.twig' %} @@ -62,8 +68,8 @@
    -
    - {% if basket_element %}{{basket_element.get_record().get_title}}{% endif %} +
    + {% if basket_element %}{{basket_element.getRecord().get_title}}{% endif %}
    @@ -78,22 +84,22 @@
    - {% if basket.is_valid() %} + {% if basket.getValidation() %} {% endif %} {% trans 'notice'%}
    -
    +
    {% if basket_element %} - {{caption.format_caption(basket_element.get_record())}} + {{caption.format_caption(basket_element.getRecord())}} {% endif %}
    - {% if basket.is_valid() %} + {% if basket.getValidation() %}
    {% include 'lightbox/agreement_box.twig' %} @@ -116,32 +122,24 @@ - {% if basket.is_valid() %} + {% if basket.getValidation() %} {% endif %} @@ -168,13 +166,15 @@
    - {% if basket.is_valid() %} + {% if basket.getValidation() %} {% endif %} {% endblock %} diff --git a/templates/web/login/index_layout_displaycooliris.twig b/templates/web/login/index_layout_displaycooliris.twig index ec6d7404dd..4a0e325571 100644 --- a/templates/web/login/index_layout_displaycooliris.twig +++ b/templates/web/login/index_layout_displaycooliris.twig @@ -55,10 +55,10 @@ + value="feed=/feeds/cooliris/&glowColor=#0077BC&style=dark&backgroundColor=#000000&showChrome=false&showEMbed=false&showSearch=false" /> - - + diff --git a/templates/web/login/index_layout_displayx1.twig b/templates/web/login/index_layout_displayx1.twig index 5acc110401..d7092d3a64 100644 --- a/templates/web/login/index_layout_displayx1.twig +++ b/templates/web/login/index_layout_displayx1.twig @@ -9,7 +9,7 @@ - diff --git a/templates/web/prod/Baskets/Create.html.twig b/templates/web/prod/Baskets/Create.html.twig index 0a72f908a4..a1f08aacbe 100644 --- a/templates/web/prod/Baskets/Create.html.twig +++ b/templates/web/prod/Baskets/Create.html.twig @@ -13,7 +13,7 @@ \ No newline at end of file diff --git a/templates/web/prod/Baskets/Update.html.twig b/templates/web/prod/Baskets/Update.html.twig index 5234d6c26c..cbd06c9487 100644 --- a/templates/web/prod/Baskets/Update.html.twig +++ b/templates/web/prod/Baskets/Update.html.twig @@ -35,7 +35,7 @@ }, success: function(data){ - refreshBaskets(data.basket.id); + return p4.WorkZone.refresh(data.basket.id); $('#DIALOG').dialog('close').empty(); return; diff --git a/templates/web/prod/Story/Create.html.twig b/templates/web/prod/Story/Create.html.twig index 3e1fa2be1c..fac49fc3c7 100644 --- a/templates/web/prod/Story/Create.html.twig +++ b/templates/web/prod/Story/Create.html.twig @@ -20,7 +20,7 @@ - + + + + + + +

    QUnit example

    +

    +
    +

    +
      +
      test markup, will be hidden
      + + diff --git a/www/include/minify/builder/index.php b/www/include/minify/builder/index.php index bb5e000ad3..b2d28cc784 100644 --- a/www/include/minify/builder/index.php +++ b/www/include/minify/builder/index.php @@ -8,7 +8,7 @@ if (phpversion() < 5) { $encodeOutput = (function_exists('gzdeflate') && !ini_get('zlib.output_compression')); -require dirname(__FILE__) . '/../config.php'; +require __DIR__ . '/../config.php'; if (! $min_enableBuilder) { header('Location: /'); @@ -162,14 +162,14 @@ $serveOpts = array( ,'lastModifiedTime' => max( // regenerate cache if either of these change filemtime(__FILE__) - ,filemtime(dirname(__FILE__) . '/../config.php') + ,filemtime(__DIR__ . '/../config.php') ) ,'minifyAll' => true ,'encodeOutput' => $encodeOutput ); ob_end_clean(); -set_include_path(dirname(__FILE__) . '/../lib' . PATH_SEPARATOR . get_include_path()); +set_include_path(__DIR__ . '/../lib' . PATH_SEPARATOR . get_include_path()); require 'Minify.php'; diff --git a/www/include/minify/builder/ocCheck.php b/www/include/minify/builder/ocCheck.php index 001c012ce4..e78c13a123 100644 --- a/www/include/minify/builder/ocCheck.php +++ b/www/include/minify/builder/ocCheck.php @@ -8,7 +8,7 @@ $_oc = ini_get('zlib.output_compression'); // allow access only if builder is enabled -require dirname(__FILE__) . '/../config.php'; +require __DIR__ . '/../config.php'; if (! $min_enableBuilder) { header('Location: /'); exit(); diff --git a/www/include/minify/config.php b/www/include/minify/config.php index 32ba786f6a..5582e1eb55 100644 --- a/www/include/minify/config.php +++ b/www/include/minify/config.php @@ -1,5 +1,5 @@ uri( - '/' . basename(dirname(__FILE__)) . $path + '/' . basename(__DIR__) . $path ,$forceAmpersand ); } @@ -83,7 +83,7 @@ function _Minify_getBuild($group) static $builds = array(); static $gc = false; if (false === $gc) { - $gc = (require dirname(__FILE__) . '/groupsConfig.php'); + $gc = (require __DIR__ . '/groupsConfig.php'); } if (! isset($builds[$group])) { $builds[$group] = new Minify_Build($gc[$group]); diff --git a/www/include/multiexports.php b/www/include/multiexports.php index 976f0378f8..f8752a2c9e 100644 --- a/www/include/multiexports.php +++ b/www/include/multiexports.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/include/printpage.php b/www/include/printpage.php deleted file mode 100644 index bf5bf09e0f..0000000000 --- a/www/include/printpage.php +++ /dev/null @@ -1,235 +0,0 @@ -get_session(); -$registry = $appbox->get_registry(); -require($registry->get('GV_RootPath') . 'lib/vendor/fpdf/fpdf.php'); - - - -########################### -########################### -# Pour Affichage du viewname dans le bandeau en haut a gauche -$printViewName = FALSE; // viewname = base -$printlogosite = TRUE; - -########################### - -$presentationpage = false; - -$request = http_request::getInstance(); -$parm = $request->get_parms("lst" - , "ACT" - , "lay" - , "callclient" - , "SSTTID" -); - - -$gatekeeper = gatekeeper::getInstance(); -$gatekeeper->require_session(); - -$usr_id = $session->get_usr_id(); - -if ($parm["ACT"] != "PRINT") - phrasea::headers(); - -// les variables -$tot_record = 0; -$tot_hd = 0; -$tot_prev = 0; - - - -$regid = NULL; -$printReg = FALSE; -$child = 0; - -############## ACT STEP2 ###################### -if ($parm["ACT"] === null) -{ - $user = User_Adapter::getInstance($usr_id, $appbox); - $ACL = $user->ACL(); - - if ($parm["SSTTID"] != "") - { - $basket = basket_adapter::getInstance($appbox, $parm['SSTTID'], $usr_id); - foreach ($basket->get_elements() as $basket_element) - { - $parm["lst"] .= $basket_element->get_record()->get_serialize_key() . ";"; - } - } - - $lstTable = explode(";", $parm["lst"]); - - $unsets = array(); - foreach ($lstTable as $k => $br) - { - $br = explode('_', $br); - if (count($br) == 2) - { - try - { - $record = new record_adapter($br[0], $br[1]); - } - catch (Exception $e) - { - continue; - } - if ($record->is_grouping()) - { - foreach ($record->get_children() as $child) - { - $lstTable[] = implode('_', $child); - } - $unsets[] = $k; - } - } - } - - foreach ($unsets as $u) - unset($lstTable[$u]); - - $okbrec = liste::filter($lstTable); - - $lstTable = $okbrec; - - $parm['lst'] = implode(';', $lstTable); - - - - foreach ($lstTable as $basrec) - { - $basrec = explode("_", $basrec); - if (!$basrec || count($basrec) !== 2) - continue; - $tot_record++; - $sbas_id = $basrec[0]; - $record = new record_adapter($sbas_id, $basrec[1]); - $base_id = $record->get_base_id(); - $sd = $record->get_subdefs(); - - if (isset($sd['document']) && $ACL->has_right_on_base($base_id, 'candwnldhd')) - { - $tot_hd++; - } - if (isset($sd['preview']) && $ACL->has_right_on_base($base_id, 'candwnldpreview')) - { - $tot_prev++; - } - } - ?> - - - - - - - - - - - -
      -
      -
        -
      • -
      -
      - -

      -
      - 0) - { - if ($tot_prev > 0) - { - ?> -
      - 1) - { - ?> -
      - - -
      - 1) - { - ?> -
      - *( %s preview(s) / %s )", $tot_prev, $tot_record); - } - ?> -


      - 1) - { - ?> -
      - -
      - - - - " /> -
      -
      - - -
      -
      -
      - - - get_session(); -$registry = $appbox->get_registry(); -require($registry->get('GV_RootPath') . 'lib/vendor/tcpdf/tcpdf.php'); - -define('ZFONT', 'freesans'); - -# Pour Affichage du viewname dans le bandeau en haut a gauche -$printViewName = FALSE; // viewname = base -$printlogosite = TRUE; - - -$presentationpage = false; - -$request = http_request::getInstance(); -$parm = $request->get_parms('ACT' - , 'form' - , 'lay' - , 'lst' - , 'callclient' -); // , "SSTTID", false); - -$lng = Session_Handler::get_locale(); - -$gatekeeper = gatekeeper::getInstance(); -$gatekeeper->require_session(); - -$usr_id = $session->get_usr_id(); - -if ($parm['ACT'] == 'LOAD') -{ - ?> - - - - - - - -
      - - - - - -
      - - - lMargin; -// $mr = $this->rMargin; - - $ml = $this->SetLeftMargin(0); - $mr = $this->SetRightMargin(0); - -//Positionnement e 1,5 cm du bas - $this->SetY(-15); -//Police Arial italique 8 - $this->SetFont(ZFONT, 'I', 8); -//Numero de page centre - $this->Cell(0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C'); - - $this->SetFont(ZFONT, '', 8); - $w = $this->GetStringWidth('Printed by'); - $this->SetFont(ZFONT, 'B', 8); - $w += $this->GetStringWidth(' Phraseanet'); - - $this->SetXY(-$w - $mr - 5, -15); - - $this->SetFont(ZFONT, '', 8); - $this->Write(8, 'Printed by'); - $this->SetFont(ZFONT, 'B', 8); - $this->Write(8, ' Phraseanet'); - } - -} - -$tot_record = 0; -$tot_hd = 0; -$tot_prev = 0; - -$regid = NULL; -$printReg = FALSE; -$child = 0; - -$pdf = null; -$lst = explode(";", $parm["lst"]); -$list = array(); -foreach ($lst as $k => $basrec) -{ - if (count($basrec = explode("_", $basrec)) !== 2) - continue; - $record = new record_adapter($basrec[0], $basrec[1]); - - switch ($parm["lay"]) - { - case "preview": - case "previewCaption": - case "previewCaptionTdm": - default: - try - { - $subdef = $record->get_subdef('subdef'); - if (!$subdef->is_physically_present()) - continue; - - if ($subdef->get_type() !== media_subdef::TYPE_IMAGE) - continue; - - $subdef = $record->get_subdef('thumbnail'); - if (!$subdef->is_physically_present()) - continue; - - if ($subdef->get_type() !== media_subdef::TYPE_IMAGE) - continue; - } - catch (Exception $e) - { - continue; - } - break; - case "thumbnailList": - case "thumbnailGrid": - try - { - $subdef = $record->get_subdef('thumbnail'); - if (!$subdef->is_physically_present()) - continue; - - if ($subdef->get_type() !== media_subdef::TYPE_IMAGE) - throw new Exception('Not suitable'); - } - catch (Exception $e) - { - continue; - } - break; - } - - $record->set_number(count($list) + 1); - - $session->get_logger($record->get_databox()) - ->log($record, Session_Logger::EVENT_PRINT, $parm["lay"], ''); - - $list[] = $record; -} - -$lst = $list; - -$pdf = new PDF("P", "mm", "A4", true, 'UTF-8', false); - -switch ($parm["lay"]) -{ - case "preview": - print_preview($pdf, $lst); - break; - case "previewCaption": - print_preview($pdf, $lst); - break; - case "previewCaptionTdm": - print_preview($pdf, $lst, true); - break; - case "thumbnailList": - print_thumbnailList($pdf, $lst); - break; - case "thumbnailGrid": - print_thumbnailGrid($pdf, $lst); - break; - default: - $pdf = new PDF("P", "mm", "A4"); - $pdf->AddPage(); - $pdf->SetFont(ZFONT, 'B', 16); - $pdf->Cell(40, 10, 'Rien a imprimer !'); - break; -} - - - -$pdf->SetAuthor("Phraseanet"); -$pdf->SetTitle("Phraseanet Print"); -$pdf->SetDisplayMode("fullpage", "single"); -$pdf->Close(); -$pdf->Output(); - -function print_thumbnailGrid(PDF &$pdf, &$lst, $links=false) -{ - $appbox = appbox::get_instance(); - $registry = registry::get_instance(); - $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); - - $NDiapoW = 3; - $NDiapoH = 4; - - $pdf->AddPage(); - - $oldMargins = $pdf->getMargins(); - $tmargin = $oldMargins['top']; - $lmargin = $oldMargins['left']; - $bmargin = $oldMargins['bottom']; - $rmargin = $oldMargins['right']; - - $pdf->SetLeftMargin($lmargin + 55); - - $clientW = $pdf->getPageWidth() - $lmargin - $rmargin; - $clientH = $pdf->getPageHeight() - $tmargin - $bmargin; - - $DiapoW = floor($clientW / $NDiapoW); - $DiapoH = floor($clientH / $NDiapoH); - $TitleH = 5; - $ImgSize = min($DiapoW, ($DiapoH - $TitleH)) - 5; - - $npages = ceil(count($lst) / ($NDiapoW * $NDiapoH)); - - $irow = $ipage = 0; - $icol = -1; - foreach ($lst as $rec) - { - /* @var $rec record_adapter */ - if (++$icol >= $NDiapoW) - { - $icol = 0; - if (++$irow >= $NDiapoH) - { - $irow = 0; - $ipage++; - $pdf->AddPage(); - } - } - $fimg = null; - $himg = 0; - - $subdef = $rec->get_subdef('preview'); - - $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()); - - $wimg = $himg = $ImgSize; - if ($subdef->get_height() > 0 && $subdef->get_width() > 0) - { - if ($subdef->get_width() > $subdef->get_height()) - $himg = $wimg * $subdef->get_height() / $subdef->get_width(); - else - $wimg = $himg * $subdef->get_width() / $subdef->get_height(); - } - - if ($fimg) - { - $x = $lmargin + ($icol * $DiapoW); - $y = $tmargin + ($irow * $DiapoH); - $pdf->SetDrawColor(0); - $pdf->Rect($x, $y, $DiapoW, $DiapoH, "D"); - - $pdf->SetXY($x, $y + 1); - $pdf->SetFont(ZFONT, '', 10); - $t = $irow . '-' . $x; - $t = $rec->get_title(); - - $pdf->MultiCell($DiapoW, $TitleH, $t, '0', 'C', false); - - if ($links) - { - $lk = $pdf->AddLink(); - $pdf->SetLink($lk, 0, $npages + $rec->get_number()); - $pdf->Image($fimg, $x + (($DiapoW - $wimg) / 2), $TitleH + $y + (($DiapoH - $TitleH - $himg) / 2), $wimg, $himg, null, $lk); - } - else - { - $pdf->Image($fimg, $x + (($DiapoW - $wimg) / 2), $TitleH + $y + (($DiapoH - $TitleH - $himg) / 2), $wimg, $himg); - } - } - } - $pdf->SetLeftMargin($oldMargins['left']); -} - -function print_thumbnailList(PDF &$pdf, &$lst) -{ - $pdf->AddPage(); - $oldMargins = $pdf->getMargins(); - - $tmargin = $oldMargins['top']; - $lmargin = $oldMargins['left']; - $bmargin = $oldMargins['bottom']; - $rmargin = $oldMargins['right']; - - $pdf->SetLeftMargin($lmargin + 55); - - $ndoc = 0; - $lastpage = $pdf->PageNo(); - foreach ($lst as $rec) - { - /* @var $rec record_adapter */ - $subdef = $rec->get_subdef('thumbnail'); - - $fimg = $subdef->get_pathfile(); - $wimg = $himg = 50; - - if ($subdef->get_width() > $subdef->get_height()) - $himg = round($wimg * $subdef->get_height() / $subdef->get_width()); - else - $wimg = round($himg * $subdef->get_width() / $subdef->get_height()); - - $himg = 0; - - if ($pdf->GetY() > $pdf->getPageHeight() - (6 + $himg + 20)) - $pdf->AddPage(); - - $title = "record : " . $rec->get_title(); - - $y = $pdf->GetY(); - - $t = phrasea::bas_names($rec->get_base_id()); - $pdf->SetFont(ZFONT, '', 10); - $pdf->SetFillColor(220, 220, 220); - $pdf->SetLeftMargin($lmargin); - $pdf->SetRightMargin($rmargin); - $pdf->SetX($lmargin); - $pdf->SetY($y); - - $pdf->out = false; - $pdf->MultiCell(140, 4, $title, "LTR", "L", 1); - $y2 = $pdf->GetY(); - $h = $y2 - $y; - $pdf->out = true; - $pdf->SetX($lmargin); - $pdf->SetY($y); - $pdf->Cell(0, $h, "", "LTR", 1, "R", 1); - $pdf->SetX($lmargin); - $pdf->SetY($y); - $pdf->Cell(0, 4, $t, "", 1, "R"); - $pdf->SetX($lmargin); - $pdf->SetY($y); - $pdf->MultiCell(140, 4, $title, "", "L"); - $pdf->SetX($lmargin); - $pdf->SetY($y = $y2); - - $pdf->SetLeftMargin($lmargin + 55); - $pdf->SetY($y + 2); - - if ($fimg) - { - $y = $pdf->GetY(); - $pdf->Image($fimg, $lmargin, $y, $wimg, $himg); - $pdf->SetY($y); - } - - $nf = 0; - $pdf->SetX($lmargin + 55); - $p0 = $pdf->PageNo(); - $y0 = $pdf->GetY(); - foreach ($rec->get_caption()->get_fields() as $field) - { - /* @var $field caption_field */ - - $pdf->SetFont(ZFONT, 'B', 12); - $pdf->Write(5, $field->get_name() . " : "); - - $pdf->SetFont(ZFONT, '', 12); - $pdf->Write(5, $field->get_value(true)); - - $pdf->Write(6, "\n"); - $nf++; - } - if ($pdf->PageNo() == $p0 && ($pdf->GetY() - $y0) < $himg) - $pdf->SetY($y0 + $himg); - $ndoc++; - } - $pdf->SetLeftMargin($lmargin); -} - -function print_preview(PDF &$pdf, &$lst, $withtdm=false) -{ - $appbox = appbox::get_instance(); - $registry = registry::get_instance(); - $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); - global $printViewName; - - global $printlogosite, $presentationpage; - - if ($withtdm === true) - { - $tmppdf = new PDF("P", "mm", "A4"); - print_preview($tmppdf, $lst, "CALCPAGES"); // recursif pour calculer les no de page des previews - - print_thumbnailGrid($pdf, $lst, true); - } - - foreach ($lst as $krec => $rec) - { - /* @var $rec record_adapter */ - - $pdf->AddPage(); - - if ($withtdm === "CALCPAGES") - { - if ($presentationpage) - $rec->set_number($pdf->PageNo() + 1); - else - $rec->set_number($pdf->PageNo()); - } - $lmargin = $pdf->GetX(); - $tmargin = $pdf->GetY(); - $himg = 0; - $y = 0; - $miniConv = NULL; - - $LEFT__TEXT = ""; - $LEFT__IMG = NULL; - $RIGHT_TEXT = ""; - $RIGHT_IMG = NULL; - - $LEFT__IMG = $registry->get('GV_RootPath') . "config/minilogos/logopdf_" . $rec->get_sbas_id() . ".jpg"; - if (!is_file($LEFT__IMG)) - { - $databox = $rec->get_databox(); - $str = $databox->get_sxml_structure(); - $vn = (string) ($str->pdfPrintLogo); - if (($vn * 1) == 1) - { - $LEFT__TEXT = $databox->get_viewname(); - } - } - - $collection = collection::get_from_base_id($rec->get_base_id()); - - $vn = ""; - if ($str = simplexml_load_string($collection->get_prefs())) - $vn = (string) ($str->pdfPrintappear); - - if ($vn == "" || $vn == "1") - { - $RIGHT_TEXT = phrasea::bas_names($rec->get_base_id()); - } - elseif ($vn == "2") - { - $RIGHT_IMG = $registry->get('GV_RootPath') . "config/minilogos/" . $rec->get_base_id(); - } - - $xtmp = $pdf->GetX(); - $ytmp = $pdf->GetY(); - - $pdf->SetFont(ZFONT, '', 12); - $pdf->SetFillColor(220, 220, 220); - $y = $pdf->GetY(); - $pdf->MultiCell(95, 7, $LEFT__TEXT, "LTB", "L", 1); - $y2 = $pdf->GetY(); - $h = $y2 - $y; - $pdf->SetY($y); - $pdf->SetX(105); - $pdf->Cell(95, $h, $RIGHT_TEXT, "TBR", 1, "R", 1); - - if ($LEFT__TEXT == "" && is_file($LEFT__IMG)) - { - if ($size = @getimagesize($LEFT__IMG)) - { - $wmm = (int) $size[0] * 25.4 / 72; - $hmm = (int) $size[1] * 25.4 / 72; - if ($hmm > 6) - { - $coeff = $hmm / 6; - $wmm = (int) $wmm / $coeff; - $hmm = (int) $hmm / $coeff; - } - $pdf->Image($LEFT__IMG, $xtmp + 0.5, $ytmp + 0.5, $wmm, $hmm); - } - } - - if ($RIGHT_IMG != NULL && is_file($RIGHT_IMG)) - { - if ($size = @getimagesize($RIGHT_IMG)) - { - - if ($size[2] == '1') - { - if (!isset($miniConv[$RIGHT_IMG])) - { - $tmp_filename = tempnam('minilogos/', 'gif4fpdf'); - $img = imagecreatefromgif($RIGHT_IMG); - imageinterlace($img, 0); - imagepng($img, $tmp_filename); - rename($tmp_filename, $tmp_filename . '.png'); - $miniConv[$RIGHT_IMG] = $tmp_filename . '.png'; - $RIGHT_IMG = $tmp_filename . '.png'; - } - else - $RIGHT_IMG = $miniConv[$RIGHT_IMG]; - - $wmm = (int) $size[0] * 25.4 / 72; - $hmm = (int) $size[1] * 25.4 / 72; - if ($hmm > 6) - { - $coeff = $hmm / 6; - $wmm = (int) $wmm / $coeff; - $hmm = (int) $hmm / $coeff; - } - $tt = 0; - if ($hmm < 6) - $tt = (6 - $hmm) / 2; - $pdf->Image($RIGHT_IMG, 200 - 0.5 - $wmm, $ytmp + 0.5 + $tt); - } - else - { - $wmm = (int) $size[0] * 25.4 / 72; - $hmm = (int) $size[1] * 25.4 / 72; - if ($hmm > 6) - { - $coeff = $hmm / 6; - $wmm = (int) $wmm / $coeff; - $hmm = (int) $hmm / $coeff; - } - $pdf->Image($RIGHT_IMG, 200 - 0.5 - $wmm, $ytmp + 0.5); - } - } - } - - $y = $pdf->GetY() + 3; - - $subdef = $rec->get_subdef('preview'); - - $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()); - - $wimg = $himg = 150; // preview dans un carre de 150 mm - if ($subdef->get_width() > 0 && $subdef->get_height() > 0) - { - if ($subdef->get_width() > $subdef->get_height()) - $himg = $wimg * $subdef->get_height() / $subdef->get_width(); - else - $wimg = $himg * $subdef->get_width() / $subdef->get_height(); - } - $pdf->Image($f, $lmargin, $y, $wimg, $himg); - - if ($miniConv != NULL) - { - foreach ($miniConv as $oneF) - unlink($oneF); - } - $pdf->SetXY($lmargin, $y += ( $himg + 5)); - - $nf = 0; - foreach ($rec->get_caption()->get_fields() as $field) - { - /* @var $field caption_field */ - if ($nf > 0) - $pdf->Write(6, "\n"); - - $pdf->SetFont(ZFONT, 'B', 12); - $pdf->Write(5, $field->get_name() . " : "); - - $pdf->SetFont(ZFONT, '', 12); - $t = str_replace(array("<", ">", "&"), array("<", ">", "&"), $field->get_value(true)); - $pdf->Write(5, $t); - - $nf++; - } - } - - return; -} - diff --git a/www/include/sendmailpage.php b/www/include/sendmailpage.php index 5fd1c8840c..fd26aad1f4 100644 --- a/www/include/sendmailpage.php +++ b/www/include/sendmailpage.php @@ -15,10 +15,10 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . '/../../lib/bootstrap.php'; +$Core = require_once __DIR__ . '/../../lib/bootstrap.php'; $appbox = appbox::get_instance(); $session = $appbox->get_session(); -$registry = $appbox->get_registry(); +$registry = $Core->getRegistry(); ob_start(null, 0); @@ -44,8 +44,14 @@ $exportname = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999); if ($parm["ssttid"] != "") { - $basket = basket_adapter::getInstance($appbox, $parm['ssttid'], $session->get_usr_id()); - $exportname = str_replace(' ', '_', $basket->get_name()) . "_" . date("Y-n-d"); + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket($Core->getRequest()->get('ssttid'), $Core->getAuthenticatedUser()); + + $exportname = str_replace(' ', '_', $basket->getName()) . "_" . date("Y-n-d"); } $download = new set_export($parm['lst'], $parm['ssttid']); diff --git a/www/include/updses.php b/www/include/updses.php index 78462fea10..1a1da37eff 100644 --- a/www/include/updses.php +++ b/www/include/updses.php @@ -15,7 +15,11 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +$Core = require_once __DIR__ . "/../../lib/bootstrap.php"; + +$em = $Core->getEntityManager(); + +$user = $Core->getAuthenticatedUser(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); @@ -56,7 +60,7 @@ $session->set_event_module($parm['app'], true); $ret['status'] = 'ok'; $ret['notifications'] = false; -$evt_mngr = eventsmanager_broker::getInstance($appbox); +$evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $notif = $evt_mngr->get_notifications(); $browser = Browser::getInstance(); @@ -66,10 +70,14 @@ $ret['notifications'] = $twig->render('prod/notifications.twig', array('notifica $ret['changed'] = array(); -$baskets = basketCollection::get_updated_baskets(); +$repository = $em->getRepository('\Entities\Basket'); + +/* @var $repository \Repositories\BasketRepository */ +$baskets = $repository->findUnreadActiveByUser($user); + foreach ($baskets as $basket) { - $ret['changed'][] = $basket->get_ssel_id(); + $ret['changed'][] = $basket->getId(); } diff --git a/www/include/vendor/qunit b/www/include/vendor/qunit new file mode 160000 index 0000000000..0712230bb2 --- /dev/null +++ b/www/include/vendor/qunit @@ -0,0 +1 @@ +Subproject commit 0712230bb203c262211649b32bd712ec7df5f857 diff --git a/www/login/account.php b/www/login/account.php index 5c3e60e9f8..b7ab616ae0 100644 --- a/www/login/account.php +++ b/www/login/account.php @@ -14,9 +14,9 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +$Core = require_once __DIR__ . "/../../lib/bootstrap.php"; -require_once dirname(__FILE__) . "/../../lib/classes/API/OAuth2/Autoloader.class.php"; +require_once __DIR__ . "/../../lib/classes/API/OAuth2/Autoloader.class.php"; API_OAuth2_Autoloader::register(); @@ -141,7 +141,7 @@ if ($request->has_post_datas()) } if ($request->has_post_datas()) { - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $notifications = $evt_mngr->list_notifications_available($appbox->get_session()->get_usr_id()); $datas = array(); @@ -504,7 +504,7 @@ $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox) Notification par email list_notifications_available($appbox->get_session()->get_usr_id()); foreach ($notifications as $notification_group => $nots) diff --git a/www/login/authenticate.php b/www/login/authenticate.php index f05b9a4191..69e543ac31 100644 --- a/www/login/authenticate.php +++ b/www/login/authenticate.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/login/forgotpwd.php b/www/login/forgotpwd.php index 215119acc7..c19cd3279c 100644 --- a/www/login/forgotpwd.php +++ b/www/login/forgotpwd.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); @@ -27,7 +27,7 @@ $needed = array(); if (isset($parm["mail"]) && trim($parm["mail"]) != "") { - require_once(dirname (__FILE__) . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); + require_once(__DIR__ . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); if (!PHPMailer::ValidateAddress($parm['mail'])) { return phrasea::redirect('/login/forgotpwd.php?error=noaccount'); diff --git a/www/login/index.php b/www/login/index.php index e79c6d7902..d3546df22a 100644 --- a/www/login/index.php +++ b/www/login/index.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -125,7 +125,7 @@ if (!$registry->get('GV_maintenance')
      ' . _('login::captcha: recopier les mots ci dessous') . ' : -
      ' . recaptcha_get_html(GV_captcha_public_key) . '
      '; +
      ' . recaptcha_get_html($registry->get('GV_captcha_public_key')) . '
      '; } $public_feeds = Feed_Collection::load_public_feeds($appbox); diff --git a/www/login/logout.php b/www/login/logout.php index b336f4dacc..da46015a5b 100644 --- a/www/login/logout.php +++ b/www/login/logout.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); diff --git a/www/login/register-confirm.php b/www/login/register-confirm.php index 5bc5b93475..5ac4ae4d6d 100644 --- a/www/login/register-confirm.php +++ b/www/login/register-confirm.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $request = http_request::getInstance(); @@ -41,7 +41,7 @@ catch(Exception_NotFound $e) $user->set_mail_locked(false); random::removeToken($parm['code']); - require_once(dirname (__FILE__) . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); + require_once(__DIR__ . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); if (PHPMailer::ValidateAddress($user->get_email())) { if (count($user->ACL()->get_granted_base()) > 0) diff --git a/www/login/register.php b/www/login/register.php index cf354cefe7..7c0d5ecb81 100644 --- a/www/login/register.php +++ b/www/login/register.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +$Core = require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); @@ -102,7 +102,7 @@ if ($request->has_post_datas()) $needed['form_password'] = _('forms::la valeur donnee contient des caracteres invalides'); //2 - on verifie que lemail a lair correcte si elle est requise - require_once(dirname (__FILE__) . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); + require_once(__DIR__ . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); if (trim($parm['form_email']) != '' && !PHPMailer::ValidateAddress($parm['form_email'])) $needed['form_email'] = _('forms::l\'email semble invalide'); @@ -211,7 +211,7 @@ if ($request->has_post_datas()) $demandOK[$base_id] = true; } - $event_mngr = eventsmanager_broker::getInstance($appbox); + $event_mngr = eventsmanager_broker::getInstance($appbox, $Core); $params = array( 'demand' => $demandOK diff --git a/www/login/reset-email.php b/www/login/reset-email.php index f57157b38a..1f462a83a9 100644 --- a/www/login/reset-email.php +++ b/www/login/reset-email.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -133,7 +133,7 @@ if (isset($parm['form_password']) && isset($parm['form_email']) && isset($parm[' if (str_replace(array("\r\n", "\r", "\n", "\t"), '_', trim($parm['form_email'])) == $parm['form_email_confirm']) { - require_once(dirname(__FILE__) . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); + require_once(__DIR__ . '/../../lib/vendor/PHPMailer_v5.1/class.phpmailer.php'); if (PHPMailer::ValidateAddress($parm['form_email'])) { if (mail::reset_email($parm['form_email'], $session->get_usr_id()) === true) diff --git a/www/login/reset-password.php b/www/login/reset-password.php index fd58df4adc..30f6aeb40e 100644 --- a/www/login/reset-password.php +++ b/www/login/reset-password.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/login/sendmail-confirm.php b/www/login/sendmail-confirm.php index 363b5fba9d..b2ecbe96d3 100644 --- a/www/login/sendmail-confirm.php +++ b/www/login/sendmail-confirm.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $parm = $request->get_post_datas('usr_id'); diff --git a/www/prod/answer.php b/www/prod/answer.php index 41ba1d37f9..43f44978ac 100644 --- a/www/prod/answer.php +++ b/www/prod/answer.php @@ -18,7 +18,7 @@ * @see http://developer.phraseanet.com * */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/prod/chghddocument.php b/www/prod/chghddocument.php index 81872143cf..4748020fe3 100644 --- a/www/prod/chghddocument.php +++ b/www/prod/chghddocument.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/prod/chgstatus.php b/www/prod/chgstatus.php index 22427b8c97..1edfd6c10f 100644 --- a/www/prod/chgstatus.php +++ b/www/prod/chgstatus.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -100,30 +100,30 @@ if ($parm["act"] == "START" || $parm["act"] == "WORK") $basrec = explode('_', $basrec); if (count($basrec) !== 2) continue; - try + + try + { + $record = new record_adapter($basrec[0], $basrec[1]); + $base_id = $record->get_base_id(); + if (isset($mska[$basrec[0]]) && isset($msko[$basrec[0]])) { $record = new record_adapter($basrec[0], $basrec[1]); - $base_id = $record->get_base_id(); - if (isset($mska[$basrec[0]]) && isset($msko[$basrec[0]])) - { - $record = new record_adapter($basrec[0], $basrec[1]); - $status = $record->get_status(); - $status = databox_status::operation_and($status, $mska[$basrec[0]]); - $status = databox_status::operation_or($status, $msko[$basrec[0]]); - $record->set_binary_status($status); + $status = $record->get_status(); + $status = databox_status::operation_and($status, $mska[$basrec[0]]); + $status = databox_status::operation_or($status, $msko[$basrec[0]]); + $record->set_binary_status($status); - $session->get_logger($databox) - ->log($record, Session_Logger::EVENT_STATUS, '', ''); + $session->get_logger($databox) + ->log($record, Session_Logger::EVENT_STATUS, '', ''); - basket_adapter::revoke_baskets_record($record, $appbox); - $maj++; - unset($record); - } + $maj++; + unset($record); } - catch (Exception $e) - { + } + catch (Exception $e) + { - } + } } ?>
      diff --git a/www/prod/chgthumb.php b/www/prod/chgthumb.php index 1cd0b33892..94ce850028 100644 --- a/www/prod/chgthumb.php +++ b/www/prod/chgthumb.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/prod/chgtype.php b/www/prod/chgtype.php index 5ad7fbc29b..2509af63d3 100644 --- a/www/prod/chgtype.php +++ b/www/prod/chgtype.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); phrasea::headers(); diff --git a/www/prod/docfunction.php b/www/prod/docfunction.php index fa0004a327..2567a48b3e 100644 --- a/www/prod/docfunction.php +++ b/www/prod/docfunction.php @@ -14,7 +14,10 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; +$Core = bootstrap::getCore(); +$em = $Core->getEntityManager(); + $appbox = appbox::get_instance(); $session = $appbox->get_session(); phrasea::headers(); @@ -235,13 +238,17 @@ $user = User_Adapter::getInstance($usr_id, $appbox); if ($parm['SSTTID'] != '' && ($parm['lst'] == null || $parm['lst'] == '')) { $parm['lst'] = array(); - - $basket = basket_adapter::getInstance($appbox, $parm['SSTTID'], $usr_id); - - foreach ($basket->get_elements() as $basket_element) + + $repository = $em->getRepository('\Entities\Basket'); + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket($Core->getRequest()->get('SSTTID'), $Core->getAuthenticatedUser()); + + foreach ($Basket->getElements() as $basket_element) { - $record = $basket_element->get_record(); - $parm['lst'][] = $record->get_sbas_id() . '_' . $record->get_record_id(); + /* @var $basket_element \Entities\BasketElement */ + $record = $basket_element->getRecord(); + $parm['lst'][] = $record->get_serialize_key(); } $parm['lst'] = implode(';', $parm['lst']); } diff --git a/www/prod/imgfunction.php b/www/prod/imgfunction.php index f7435f6718..2a0f906272 100644 --- a/www/prod/imgfunction.php +++ b/www/prod/imgfunction.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +$Core = require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -46,11 +46,20 @@ if ($parm['ACT'] === null) if ($parm['SSTTID'] != '' && ($parm['lst'] == null || $parm['lst'] == '')) { - $basket = basket_adapter::getInstance($appbox, $parm['SSTTID'], $usr_id); - foreach ($basket->get_elements() as $basket_element) + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + /* @var $repository \Repositories\BasketRepository */ + + $Basket = $repository->findUserBasket( + $Core->getRequest()->get('SSTTID') + , $Core->getAuthenticatedUser() + ); + + foreach ($Basket->getElements() as $basket_element) { - $parm['lst'] .= $basket_element->get_record()->get_serialize_key() . ';'; + $parm['lst'] .= $basket_element->getRecord()->get_serialize_key() . ';'; } } diff --git a/www/prod/jquery.Alerts.js b/www/prod/jquery.Alerts.js new file mode 100644 index 0000000000..3b25facb9c --- /dev/null +++ b/www/prod/jquery.Alerts.js @@ -0,0 +1,50 @@ +var p4 = p4 || {}; + +(function(p4){ + + function create_dialog() + { + if($('#p4_alerts').length === 0) + { + $('body').append('
      '); + } + + return $('#p4_alerts'); + } + + function alert(title, message) + { + var dialog = create_dialog(); + + var button = new Object(); + + button[language.annuler] = function(){ + dialog.dialog('close'); + }; + + dialog.attr('title',title) + .empty() + .append(message) + .dialog({ + + autoOpen:false, + closeOnEscape:true, + resizable:false, + draggable:false, + modal:true, + buttons : button, + draggable:false, + overlay: { + backgroundColor: '#000', + opacity: 0.7 + } + }).dialog('open'); + + return; + } + + p4.Alerts = alert; + + + return; +}(p4)) diff --git a/www/prod/jquery.Phraseanet.js b/www/prod/jquery.Phraseanet.js new file mode 100644 index 0000000000..188d3dd8bb --- /dev/null +++ b/www/prod/jquery.Phraseanet.js @@ -0,0 +1,7 @@ +var p4 = p4 || {}; + +(function(p4){ + + + +}(p4)); \ No newline at end of file diff --git a/www/prod/jquery.Prod.js b/www/prod/jquery.Prod.js new file mode 100644 index 0000000000..e196b56526 --- /dev/null +++ b/www/prod/jquery.Prod.js @@ -0,0 +1,40 @@ +(function(){ + + $(document).ready(function(){ + + $('a.dialog').live('click', function(event){ + + var $this = $(this); + + + $('#DIALOG').attr('title', $this.attr('title')) + .empty().addClass('loading') + .dialog({ + resizable:false, + closeOnEscape:true, + modal:true, + width:'800', + height:'500' + }) + .dialog('open'); + + $.ajax({ + type: "GET", + url: $this.attr('href'), + dataType: 'html', + beforeSend:function(){ + + }, + success: function(data){ + $('#DIALOG').removeClass('loading').empty() + .append(data); + return; + } + }); + + return false; + }); + + }); + +}()) \ No newline at end of file diff --git a/www/prod/jquery.Results.js b/www/prod/jquery.Results.js new file mode 100644 index 0000000000..7510b09d8b --- /dev/null +++ b/www/prod/jquery.Results.js @@ -0,0 +1,22 @@ +var p4 = p4 || {}; + +(function(p4, window){ + + p4.Results = { + 'Selection':new Selectable({ + selector : '.IMGT', + container:$('#answers'), + selectStart:function(event, selection){ + $('#answercontextwrap table:visible').hide(); + }, + selectStop:function(event, selection){ + viewNbSelect(); + }, + callbackSelection:function(element){ + return $(element).attr('id').split('_').slice(1,3).join('_'); + } + }) + }; + + return; +}(p4, window)) diff --git a/www/prod/jquery.Search.js b/www/prod/jquery.Search.js new file mode 100644 index 0000000000..3089378655 --- /dev/null +++ b/www/prod/jquery.Search.js @@ -0,0 +1,6 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + + diff --git a/www/prod/jquery.WorkZone.js b/www/prod/jquery.WorkZone.js new file mode 100644 index 0000000000..f08bc1c301 --- /dev/null +++ b/www/prod/jquery.WorkZone.js @@ -0,0 +1,588 @@ +var p4 = p4 || {}; + +(function(p4){ + + + + + + function refreshBaskets(baskId, sort, scrolltobottom) + { + var active = $('#baskets .SSTT.ui-state-active'); + if(baskId == 'current' && active.length>0) + baskId = active.attr('id').split('_').slice(1,2).pop(); + sort = ($.inArray(sort, ['date', 'name'])>=0) ? sort : ''; + + scrolltobottom = typeof scrolltobottom == 'undefined' ? false : scrolltobottom; + + $.ajax({ + type: "GET", + url: "/prod/WorkZone/", + data: { + type:'basket', + id:baskId, + sort:sort + }, + beforeSend:function(){ + $('#basketcontextwrap').remove(); + }, + success: function(data){ + + var cache = $("#idFrameC #baskets"); + $(".SSTT",cache).droppable('destroy'); + + $('.bloc',cache).droppable('destroy'); + cache.accordion('destroy') + + .empty() + .append(data); + + activeBaskets(); + $('.basketTips').tooltip({ + delay: 200 + }); + cache.disableSelection(); + + if(!scrolltobottom) + return; + + p4.next_bask_scroll = true; + return; + } + }); + } + + + + function setTemporaryPref(name,value) + { + + $.ajax({ + type: "POST", + url: "/prod/prodFeedBack.php", + data: { + action: "SAVETEMPPREF", + prop:name, + value:value + }, + success: function(data){ + return; + } + }); + } + + $("#baskets div.content select[name=valid_ord]").live('change',function(){ + + var active = $('#baskets .SSTT.ui-state-active'); + if(active.length==0) + return; + + getContent(active); + }); + + + + function WorkZoneElementRemover(el, confirm) + { + + if(confirm !== true && $(el).hasClass('groupings') && p4.reg_delete == true) + { + var buttons = {}; + + + buttons[language.valider] = function() { + $("#DIALOG-baskets").dialog('close').remove(); + WorkZoneElementRemover(el,true); + }; + + buttons[language.annuler] = function(){ + $("#DIALOG-baskets").dialog('close').remove(); + }; + + var texte = '

      '+language.confirmRemoveReg+'

      '+language.hideMessage+'
      '; + $('body').append('
      '); + $("#DIALOG-baskets").attr('title',language.removeTitle) + .empty() + .append(texte) + .dialog({ + + autoOpen:false, + closeOnEscape:true, + resizable:false, + draggable:false, + modal:true, + buttons:buttons, + draggable:false, + overlay: { + backgroundColor: '#000', + opacity: 0.7 + } + }).dialog('open'); + return; + } + + var id = $(el).attr('id').split('_').slice(2,4).join('_'); + + $.ajax({ + type: "POST", + url: $(el).attr('href'), + dataType:'json', + beforeSend : function(){ + $('.wrapCHIM_'+id).find('.CHIM').fadeOut(); + }, + success: function(data){ + + if(data.success) + { + humane.info(data.message); + p4.WorkZone.Selection.remove(id); + + $('.wrapCHIM_'+id).find('.CHIM').draggable('destroy'); + $('.wrapCHIM_'+id).remove(); + } + else + { + humane.error(data.message); + $('.wrapCHIM_'+id).find('.CHIM').fadeIn(); + } + return; + } + }); + return false; + } + + + function activeBaskets() + { + var cache = $("#idFrameC #baskets"); + + cache.accordion({ + active:'active', + autoHeight: false, + collapsible:true, + header:'div.header', + change:function(event,ui){ + + if(p4.next_bask_scroll) + { + p4.next_bask_scroll = false; + + var b_active = $('#baskets .SSTT.active'); + + if(!b_active.next().is(':visible')) + return; + + var t = $('#baskets .SSTT.active').position().top + b_active.next().height() -200; + + t = t < 0 ? 0 : t; + + $('#baskets .bloc').stop().animate({ + scrollTop:t + }); + } + + var uiactive = $(this).find('.ui-state-active'); + + if(uiactive.length === 0) + { + return; /* everything is closed */ + } + + var clicked = uiactive.attr('id').split('_').pop(); + var href = $('a', uiactive).attr('href'); + + uiactive.addClass('ui-state-focus active'); + + p4.WorkZone.Selection.empty(); + + getContent(uiactive); + + }, + changestart:function(event,ui){ + $('#basketcontextwrap .basketcontextmenu').hide(); + } + }); + $('.bloc',cache).droppable({ + accept:function(elem){ + if($(elem).hasClass('grouping') && !$(elem).hasClass('SSTT')) + return true; + return false; + }, + scope:'objects', + hoverClass:'groupDrop', + tolerance:'pointer', + drop:function(){ + fix(); + } + }); + + if($('.SSTT.active',cache).length>0) + { + var el = $('.SSTT.active',cache)[0]; + $(el).trigger('click'); + } + + + $(".SSTT, .content",cache) + .droppable({ + scope:'objects', + hoverClass:'baskDrop', + tolerance:'pointer', + accept:function(elem){ + if($(elem).hasClass('CHIM')) + { + if($(elem).closest('.content').prev()[0] == $(this)[0]) + { + return false; + } + } + if($(elem).hasClass('grouping') || $(elem).parent()[0]==$(this)[0]) + return false; + return true; + }, + drop:function(event,ui){ + dropOnBask(event,ui.draggable,$(this)); + } + }); + + if($('#basketcontextwrap').length == 0) + $('body').append('
      '); + + $('.context-menu-item',cache).hover(function(){ + $(this).addClass('context-menu-item-hover'); + },function(){ + $(this).removeClass('context-menu-item-hover'); + }); + $.each($(".SSTT",cache),function(){ + var el = $(this); + $(this).find('.contextMenuTrigger').contextMenu('#'+$(this).attr('id')+' .contextMenu',{ + 'appendTo':'#basketcontextwrap', + openEvt:'click', + theme:'vista', + dropDown:true, + showTransition:'slideDown', + hideTransition:'hide', + shadow:false + }); + }); + + } + + + + function getContent(header) + { + if(window.console) + { + console.log('Reload content for ', header); + } + + $.ajax({ + type: "GET", + url: $('a', header).attr('href'), + dataType:'html', + beforeSend:function(){ + $('#tooltip').hide(); + header.next().addClass('loading'); + }, + success: function(data){ + header.removeClass('unread'); + + var dest = header.next(); + + dest.droppable('destroy').empty().removeClass('loading'); + + dest.append(data) + + $('a.WorkZoneElementRemover', dest) + .bind('mousedown', function(event){return false;}) + .bind('click', function(event){ + + return WorkZoneElementRemover($(this), false); + + }); + + dest.droppable({ + accept:function(elem){ + if($(elem).hasClass('CHIM')) + { + if($(elem).closest('.content')[0] == $(this)[0]) + { + return false; + } + } + if($(elem).hasClass('grouping') || $(elem).parent()[0]==$(this)[0]) + return false; + return true; + }, + hoverClass:'baskDrop', + scope:'objects', + drop:function(event, ui){ + dropOnBask(event,ui.draggable,$(this).prev()); + }, + tolerance:'pointer' + }); + + $('.noteTips, .captionRolloverTips', dest).tooltip(); + + dest.find('.CHIM').draggable({ + helper : function(){ + $('body').append('
      '+ + '
      '+ + p4.WorkZone.Selection.length() + '
      '); + return $('#dragDropCursor'); + }, + scope:"objects", + distance : 20, + scroll : false, + refreshPositions:true, + cursorAt: { + top:10, + left:-20 + }, + start:function(event, ui){ + var baskets = $('#baskets'); + baskets.append('
      '+ + '
      '); + $('.bottom-scroller',baskets).bind('mousemove',function(){ + $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop()+30); + }); + $('.top-scroller',baskets).bind('mousemove',function(){ + $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop()-30); + }); + }, + stop:function(){ + $('#baskets').find('.top-scroller, .bottom-scroller') + .unbind() + .remove(); + }, + drag:function(event,ui){ + if(is_ctrl_key(event) || $(this).closest('.content').hasClass('grouping')) + $('#dragDropCursor div').empty().append('+ '+p4.WorkZone.Selection.length()); + else + $('#dragDropCursor div').empty().append(p4.WorkZone.Selection.length()); + + } + }); + answerSizer(); + return; + } + }); + } + + + + + + + + function dropOnBask(event,from,destKey) + { + var action = "", + from = $(from), dest_uri = '', lstbr = [], + sselcont = [], act = "ADD"; + + if(from.hasClass("CHIM")) + { + /* Element(s) come from an open object in the workzone */ + action = $(' #baskets .ui-state-active').hasClass('grouping') ? 'REG2' : 'CHU2'; + } + else + { + /* Element(s) come from result */ + action = 'IMGT2'; + } + + action += destKey.hasClass('grouping') ? 'REG' : 'CHU'; + + if(destKey.hasClass('content')) + { + /* I dropped on content */ + dest_uri = $('a', destKey.prev()).attr('href'); + } + else + { + /* I dropped on Title */ + dest_uri = $('a', destKey).attr('href'); + } + + if(window.console) + { + window.console.log('Requested action is ', action, ' and act on ', dest_uri); + } + + if(action=="IMGT2CHU" || action=="IMGT2REG") + { + if($(from).hasClass('.baskAdder')) + { + lstbr = [$(from).attr('id').split('_').slice(2,4).join('_')]; + } + else + { + lstbr = p4.Results.Selection.get(); + } + } + else + { + sselcont = $.map(p4.WorkZone.Selection.get(), function(n,i){ + return $('.CHIM_'+n, $('#baskets .content:visible')).attr('id').split('_').slice(1,2).pop(); + }); + lstbr = p4.WorkZone.Selection.get(); + } + + switch(action) + { + case "CHU2CHU" : + if(!is_ctrl_key(event)) + act = "MOV"; + break; + + case "IMGT2REG": + case "CHU2REG" : + case "REG2REG": + var sameSbas = true, + sbas_reg = destKey.attr('sbas'); + + for (var i=0; iget_session(); -phrasea::headers(); - -$usr_id = $session->get_usr_id(); -$user = User_Adapter::getInstance($usr_id, $appbox); -$request = http_request::getInstance(); - -if ($request->has_post_datas()) -{ - $parm = $request->get_parms('name', 'type', 'desc', 'lst', 'coll'); - - if (trim($parm['name']) != '') - { - if (is_null($parm['type']) || $parm['type'] == "CHU") - { - try - { - $basket = basket_adapter::create($appbox, $parm['name'], $user, $parm['desc']); - - if (trim($parm['lst']) != '') - { - $basket->push_list($parm['lst'], false); - } - echo ""; - exit(); - } - catch (Exception $e) - { - - } - } - elseif ($parm['type'] == "REG") - { - try - { - $basket = basket_adapter::create($appbox, $parm['name'], $user, $parm['desc'], null, $parm['coll']); - if ($parm['lst'] != '') - $basket->push_list($parm['lst'], false); - echo ""; - exit(); - } - catch (Exception $e) - { -?> - - - -ACL(); -$html = array(); - -$list = $ACL->get_granted_base(array('canaddrecord')); -$current_sbas_id = false; -foreach ($list as $base_id=>$collection) -{ - $sbas_id = $collection->get_databox()->get_sbas_id(); - if (!isset($html[$sbas_id])) - $html[$sbas_id] = ''; - $html[$sbas_id] .= ''; -} - -$menu = ''; -foreach ($html as $sbas_id => $sbas) - $menu .= '' . $sbas . ''; - -$parm = $request->get_parms('type'); -?> - - - <?php echo _('action:: nouveau panier') ?> - - - - - - - - - -
      -
      -
        -
      • -
      -
      -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      - : -
      -
      - value="CHU"> -
      - - value="REG"> - -
      - - - -
      - - - - - - - - - - - - -
       :
       :
      -
      -
      - - -
      -
      -
      -
      - - - diff --git a/www/prod/page0.js b/www/prod/page0.js index f104f15ed6..ad98586b5d 100644 --- a/www/prod/page0.js +++ b/www/prod/page0.js @@ -1,6 +1,6 @@ document.getElementById('loader_bar').style.width = '30%'; -var p4 = {}; +var p4 = p4 || {}; var baskAjax,baskAjaxrunning; baskAjaxrunning = false; @@ -125,20 +125,6 @@ function getLanguage(){ } }); } -//function loadBask(sselid,el){ -// -// $("#baskets .SSTT").removeClass('ui-state-focus ui-state-hover active'); -// $(el).addClass('ui-state-focus active'); -// -// -// if($(el).next().is(':visible')) -// { -// return true; -// } -// -// getBask(sselid,el); -// p4.baskSel = []; -//} function is_ctrl_key(event) { @@ -166,312 +152,6 @@ function is_shift_key(event) } -function getBask(sselid,el,ord) -{ - if(typeof ord == 'undefined') - ord = ''; - - $.ajax({ - type: "GET", - url: "/prod/baskets/" + sselid+ "/", - dataType:'html', - data: { - ord:ord - }, - beforeSend:function(){ - $('#tooltip').hide(); - $(el).next().addClass('loading'); - - }, - success: function(data){ - $(el).removeClass('unread'); - $(el).next().droppable('destroy').empty().removeClass('loading'); - $(el).next().append(data).droppable({ - accept:function(elem){ - if($(elem).hasClass('CHIM')) - { - if($(elem).closest('.content')[0] == $(this)[0]) - { - return false; - } - } - if($(elem).hasClass('grouping') || $(elem).parent()[0]==$(this)[0]) - return false; - return true; - }, - hoverClass:'baskDrop', - scope:'objects', - drop:function(event, ui){ - dropOnBask(event,ui.draggable,$(this).prev()); - }, - tolerance:'pointer' - }); - $('.noteTips, .captionRolloverTips',$(el).next()).tooltip(); - $(el).next().find('.CHIM').draggable({ - helper : function(){ - $('body').append('
      '+ - '
      '+ - p4.baskSel.length+'
      '); - return $('#dragDropCursor'); - }, - scope:"objects", - distance : 20, - scroll : false, - refreshPositions:true, - cursorAt: { - top:10, - left:-20 - }, - start:function(event, ui){ - var baskets = $('#baskets'); - baskets.append('
      '+ - '
      '); - $('.bottom-scroller',baskets).bind('mousemove',function(){ - $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop()+30); - }); - $('.top-scroller',baskets).bind('mousemove',function(){ - $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop()-30); - }); - }, - stop:function(){ - $('#baskets').find('.top-scroller, .bottom-scroller') - .unbind() - .remove(); - }, - drag:function(event,ui){ - if(is_ctrl_key(event) || $(this).closest('.content').hasClass('grouping')) - $('#dragDropCursor div').empty().append('+ '+p4.baskSel.length); - else - $('#dragDropCursor div').empty().append(p4.baskSel.length); - - } - }); - answerSizer(); - return; - } - }); -} - -function dropOnBask(event,from,destKey) -{ - var action = "", - from = $(from), - current_opened_sstt = $(' #baskets .ui-state-active'); - - - if(from.hasClass("CHIM")) - action = (current_opened_sstt.hasClass('grouping')?'REG':'CHU') + "2"; - else - action = 'IMGT2'; - - action += destKey.hasClass('grouping')?'REG':'CHU'; - - - dest_sbas = destKey.attr('sbas') ; - cur_sbas = $(from).attr('sbas') ; - - var ssttid_dest = destKey.attr('id').split('_').slice(1,2).pop(); - - if(destKey.hasClass('content')) - { - var ssttid_dest_uri = $('a', destKey.prev()).attr('href'); - } - else - { - var ssttid_dest_uri = $('a', destKey).attr('href'); - } - - var lstbr; - var sselcont = []; - if(action=="IMGT2CHU" || action=="IMGT2REG") - { - sselcont = []; - lstbr = p4.sel.join(';'); - if($(from).hasClass('.baskAdder')) - lstbr = $(from).attr('id').split('_').slice(2,4).join('_'); - } - else - { - var content = $('#baskets .content:visible'); - sselcont = $.map(p4.baskSel, function(n,i){ - return $('.CHIM_'+n,content).attr('id').split('_').slice(1,2).pop(); - }); - lstbr = p4.baskSel.join(';'); - } - - var act = "ADD"; - - switch(action) - { - case "IMGT2CHU": // image de recherche vers une selection - case "CHU2CHU" : // image de selection vers une selection - - if(event && !is_ctrl_key(event) && action=="CHU2CHU") - act = "MOV"; - - break; - - case "IMGT2REG": // image de recherche vers un regroupement - case "CHU2REG" : // image de selection vers un regroupement - - if(action=="IMGT2REG") - { - var sbasDepart = destKey.attr('sbas'); - - lstbr = new Array; - sameSbas = true; - - for (var i=0; i0) - { - if(elem.attr('sbas')!=sbasDepart) - sameSbas = false; - else - lstbr.push(p4.sel[i]); - } - else - lstbr.push(p4.sel[i]); - - } - lstbr = lstbr.join(';'); - - } - - if(cur_sbas!=dest_sbas || (action=="IMGT2REG" && sameSbas==false )) - { - - var texte = language.reg_wrong_sbas; - - var button = new Object; - button[language.annuler] = function(){ - $('#DIALOG').dialog('close'); - }; - - $("#DIALOG").attr('title','') - .empty() - .append(texte) - .dialog({ - - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - buttons : button, - draggable:false, - overlay: { - backgroundColor: '#000', - opacity: 0.7 - } - }).dialog('open'); - // if(lstbr == '') - return; - } - if(action=="CHU2REG" && !is_ctrl_key(event)) - act = "MOV"; - - break; - - case "REG2REG": // image d'un regroupement vers un regroupement - if(cur_sbas!=dest_sbas) - { - alert(language.wrongsbas); - return; - } - // if(!is_ctrl_key(event)) - // act = "MOV"; - - break; - - case "REG2CHU": - - // if(!is_ctrl_key(event)) - // act = "MOV"; - - break; - } - - var from_id = false; - - if(action == 'CHU2CHU' || action == 'REG2REG' || action == 'CHU2REG' || action == 'REG2CHU') - { - from_id = $(from).closest('.content').attr('id').split('_').pop(); - } - - if(action == 'IMGT2CHU') - { - if(act == 'ADD') - { - var url = ssttid_dest_uri + "addElements/"; - var data = { - lst:lstbr - }; - } - } - else - { - if(action == 'IMGT2REG') - { - if(act == 'ADD') - { - var url = ssttid_dest_uri + "addElements/"; - var data = { - lst:lstbr - }; - } - } - } - - $.ajax({ - type: "POST", - url: url, - data: data, - dataType:'json', - // data: { - // action: act+action, - // sselcont:sselcont.join(';'), - // lst:lstbr, - // dest:ssttid_dest, - // from:from_id - // }, - beforeSend:function(){ - - }, - success: function(data){ - if(!data.success) - { - humane.error(data.message); - if(!data.result) - return; - } - else - { - humane.info(data.message); - } - // var main = action.substr(0,4); - // if(main == 'CHU2' || main=='REG2') - // { - // if(act == 'MOV') - // { - // $('.wrapCHIM_'+data.datas.join(', .wrapCHIM_')).remove(); - // p4.baskSel = []; - // } - // } - // - var current_id = current_opened_sstt.length > 0 ? current_opened_sstt.attr('id').split('_').pop() : null; - if((act == 'MOV') || (current_id == ssttid_dest)) - { - refreshBaskets('current','',true); - } - return; - } - }); -} - function checkBases(bool) @@ -670,7 +350,7 @@ function newSearch() bases.append(''); }); - p4.sel = []; + p4.Results.Selection.empty(); var val = $('#EDIT_query').val(); $('#searchForm input[name="qry"]').val(val); @@ -742,15 +422,8 @@ function newAdvSearch() $('#EDIT_query').val(val); newSearch(); -// $('#adv_search').dialog('close'); } -//function stopEvent(e) -//{ -// -// e.stopPropagation();e.preventDefault();e.cancelBubble;return false; -//} - function beforeSearch() { @@ -808,7 +481,7 @@ function afterSearch() viewNbSelect(); $('#idFrameA div.IMGT').draggable({ helper : function(){ - $('body').append('
      '+p4.sel.length+'
      '); + $('body').append('
      '+p4.Results.Selection.length()+'
      '); return $('#dragDropCursor'); }, scope:"objects", @@ -817,6 +490,11 @@ function afterSearch() cursorAt: { top:-10, left:-20 + }, + start:function(event, ui) + { + if(!$(this).hasClass('selected')) + return false; } }); linearize(); @@ -900,79 +578,6 @@ function answerSizer() } -function setTemporaryPref(name,value) -{ - - $.ajax({ - type: "POST", - url: "/prod/prodFeedBack.php", - data: { - action: "SAVETEMPPREF", - prop:name, - value:value - }, - success: function(data){ - return; - } - }); -} - -function unFix(el) -{ - var id = $(el).attr('id').split('_').slice(1,2).pop(); - $.ajax({ - type: "POST", - url: "/prod/prodFeedBack.php", - data: { - action: "UNFIX", - lst:id - }, - success: function(data){ - $('#SSTT_'+id).next().droppable('destroy').remove(); - $('#SSTT_'+id).droppable('destroy').remove(); - } - }); -} -function fix() -{ - $.ajax({ - type: "POST", - url: "/prod/prodFeedBack.php", - dataType: "json", - data: { - action: "FIX", - lst:p4.sel.join(';') - }, - success: function(data){ - if(data.length>0) - refreshBaskets(data.pop()); - } - }); -} - -function newTemp() -{ - $('#MODALDL').attr('src','about:blank'); - $('#MODALDL').attr('src',"newtemporary.php"); - - - var t = (bodySize.y - 400) / 2; - var l = (bodySize.x - 400) / 2; - - $('#MODALDL').css({ - 'display': 'block', - 'opacity': 0, - 'width': '400px', - 'position': 'absolute', - 'top': t, - 'left': l, - 'height': '440px' - }).fadeTo(500, 1); - - showOverlay(2); - -} - function linearize() { var list = $('#answers .list'); @@ -1008,254 +613,6 @@ function linearize() } -function refreshBaskets(baskId, sort, scrolltobottom) -{ - var active = $('#idFrameC #baskets .SSTT.ui-state-active'); - if(baskId == 'current' && active.length>0) - baskId = active.attr('id').split('_').slice(1,2).pop(); - sort = ($.inArray(sort, ['date', 'name'])>=0) ? sort : ''; - - scrolltobottom = typeof scrolltobottom == 'undefined' ? false : scrolltobottom; - - $.ajax({ - type: "GET", - url: "/prod/WorkZone/", - data: { - type:'basket', - id:baskId, - sort:sort - }, - beforeSend:function(){ - $('#basketcontextwrap').remove(); - }, - success: function(data){ - - var cache = $("#idFrameC #baskets"); - $(".SSTT",cache).droppable('destroy'); - - $('.bloc',cache).droppable('destroy'); - cache.accordion('destroy') - - .empty() - .append(data); - - activeBaskets(); - $('.basketTips').tooltip({ - delay: 200 - }); - cache.disableSelection(); - - if(!scrolltobottom) - return; - - p4.next_bask_scroll = true; - return; - } - }); -} - -function activeBaskets() -{ - var cache = $("#idFrameC #baskets"); - cache.accordion({ - active:'active', - autoHeight: false, - collapsible:true, - header:'div.header', - change:function(event,ui){ - - if(p4.next_bask_scroll) - { - p4.next_bask_scroll = false; - - var b_active = $('#baskets .SSTT.active'); - - if(!b_active.next().is(':visible')) - return; - - var t = $('#baskets .SSTT.active').position().top + b_active.next().height() -200; - - t = t < 0 ? 0 : t; - - $('#baskets .bloc').stop().animate({ - scrollTop:t - }); - } - - var uiactive = $(this).find('.ui-state-active'); - - if(uiactive.length === 0) - { - return; /* everything is closed */ - } - - var clicked = uiactive.attr('id').split('_').pop(); - var href = $('a', uiactive).attr('href'); - - uiactive.addClass('ui-state-focus active'); - - p4.baskSel = []; - - $('#SSTT_content_'+clicked) - .empty() - .addClass('loading') - .load(href, function(){ - $(this).removeClass('loading'); - - $('a.WorkZoneElementRemover', $(this)) - .bind('mousedown', function(event){return false;}) - .bind('click', function(event){ - - return WorkZoneElementRemover($(this), false); - - function WorkZoneElementRemover(el, confirm) - { - - if(confirm !== true && $(el).hasClass('groupings') && p4.reg_delete == true) - { - var buttons = {}; - - - buttons[language.valider] = function() { - $("#DIALOG-baskets").dialog('close').remove(); - WorkZoneElementRemover(el,true); - }; - - buttons[language.annuler] = function(){ - $("#DIALOG-baskets").dialog('close').remove(); - }; - - var texte = '

      '+language.confirmRemoveReg+'

      '+language.hideMessage+'
      '; - $('body').append('
      '); - $("#DIALOG-baskets").attr('title',language.removeTitle) - .empty() - .append(texte) - .dialog({ - - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - buttons:buttons, - draggable:false, - overlay: { - backgroundColor: '#000', - opacity: 0.7 - } - }).dialog('open'); - return; - } - - var full_id = $(el).attr('id').split('_'); - var id = full_id.pop(); - var ssel_id = full_id.pop(); - $.ajax({ - type: "POST", - url: $(el).attr('href'), - dataType:'json', - beforeSend : function(){ - $('.wrapCHIM_'+id).find('.CHIM').fadeOut(); - }, - success: function(data){ - - if(data.success) - { - humane.info(data.message); - var k = $(el).parent().attr('id').split('_').slice(2,4).join('_'); - if($.inArray(k,p4.baskSel)>=0) - { - p4.baskSel = $.grep(p4.baskSel,function(n){ - return(n!=k); - }); - } - $('.wrapCHIM_'+id).find('.CHIM').draggable('destroy'); - $('.wrapCHIM_'+id).remove(); - } - else - { - humane.error(data.message); - $('.wrapCHIM_'+id).find('.CHIM').fadeIn(); - } - return; - } - }); - return false; - } - }); - }); - - }, - changestart:function(event,ui){ - $('#basketcontextwrap .basketcontextmenu').hide(); - } - }); - $('.bloc',cache).droppable({ - accept:function(elem){ - if($(elem).hasClass('grouping') && !$(elem).hasClass('SSTT')) - return true; - return false; - }, - scope:'objects', - hoverClass:'groupDrop', - tolerance:'pointer', - drop:function(){ - fix(); - } - }); - - if($('.SSTT.active',cache).length>0) - { - var el = $('.SSTT.active',cache)[0]; - $(el).trigger('click'); - } - - - $(".SSTT, .content",cache) - .droppable({ - scope:'objects', - hoverClass:'baskDrop', - tolerance:'pointer', - accept:function(elem){ - if($(elem).hasClass('CHIM')) - { - if($(elem).closest('.content').prev()[0] == $(this)[0]) - { - return false; - } - } - if($(elem).hasClass('grouping') || $(elem).parent()[0]==$(this)[0]) - return false; - return true; - }, - drop:function(event,ui){ - dropOnBask(event,ui.draggable,$(this)); - } - }); - - if($('#basketcontextwrap').length == 0) - $('body').append('
      '); - - $('.context-menu-item',cache).hover(function(){ - $(this).addClass('context-menu-item-hover'); - },function(){ - $(this).removeClass('context-menu-item-hover'); - }); - $.each($(".SSTT",cache),function(){ - var el = $(this); - $(this).find('.contextMenuTrigger').contextMenu('#'+$(this).attr('id')+' .contextMenu',{ - 'appendTo':'#basketcontextwrap', - openEvt:'click', - theme:'vista', - dropDown:true, - showTransition:'slideDown', - hideTransition:'hide', - shadow:false - }); - }); - -} - function initLook() { @@ -1516,31 +873,28 @@ $(document).ready(function(){ }); $('.basket_refresher').live('click', function(){ - refreshBaskets('current'); + return p4.WorkZone.refresh('current'); return false; }); $('#loader_bar').stop().animate({ width:'70%' },450); - p4 = { - preview :{ + + p4.preview ={ open:false, current:false - }, - currentViewMode:'classic', - nbNoview:0, - reg_delete:true, - lng:'', - sel:[], - baskSel:[], - edit:{}, - thesau:{ + }; + p4.currentViewMode='classic'; + p4.nbNoview=0; + p4.reg_delete=true; + p4.lng=''; + p4.edit={}; + p4.thesau={ tabs:null - }, - active_zone:false, - next_bask_scroll: false - }; + }; + p4.active_zone=false; + p4.next_bask_scroll= false; $('#backcolorpickerHolder').ColorPicker({ @@ -1726,17 +1080,7 @@ $(document).ready(function(){ startThesaurus(); activeFilters(); checkFilters(); - activeBaskets(); - $("#baskets div.content select[name=valid_ord]").live('change',function(){ - - var active = $('#idFrameC #baskets .SSTT.ui-state-active'); - if(active.length==0) - return; - var baskId = active.attr('id').split('_').slice(1,2).pop(); - - getBask(baskId,$('#SSTT_'+baskId),$(this).val()); - }); activeZoning(); @@ -1831,48 +1175,6 @@ $(document).ready(function(){ } }); - $('#idFrameA div.IMGT').live('mousedown',function(event){ - evt_mdwn_obj(this, event); - return; - }); - - $('#idFrameA div.IMGT').live('click',function(event){ - if(is_shift_key(event) || is_ctrl_key(event)) - return true; - p4.sel = new Array(); - $('#answers .IMGT.selected').removeClass('selected last_selected'); - var k = $(this).attr('id').split('_').slice(1,3).join('_'); - select_this($(this),k) - $(this).addClass('last_selected'); - return; - }); - - - - - $('#idFrameC div.CHIM').live('mousedown',function(event){ - baskSelection(this, event); - return; - }); - - $('#idFrameC div.CHIM').live('click',function(event){ - if(is_shift_key(event) || is_ctrl_key(event)) - return true; - p4.baskSel = new Array(); - var cont = $('#idFrameC .SSTT.content:visible'); - $('.CHIM.selected, .CHIM.last_selected', cont).removeClass('selected last_selected'); - - var k = $(this).attr('id').split('_').slice(2,4).join('_'); - p4.baskSel.push(k); - $(this).addClass('selected last_selected'); - return; - }); - - - - $('#idFrameC .SSTT').live('mousedown',function(event){ - return; - }); $('button.answer_selector').bind('click',function(){ selector($(this)); }).bind('mouseover',function(event){ @@ -2092,19 +1394,19 @@ $(document).ready(function(){ case 80://P if(is_ctrl_key(event)) { - printThis("lst="+p4.sel.join(';')); + printThis("lst="+p4.Results.Selection.serialize()); cancelKey = shortCut = true; } break; case 69://e if(is_ctrl_key(event)) { - editThis('IMGT',p4.sel.join(';')); + editThis('IMGT',p4.Results.Selection.serialize()); cancelKey = shortCut = true; } break; // case 46://del - // deleteThis(p4.sel.join(';')); + // deleteThis(p4.Results.Selection.serialize()); // cancelKey = true; // break; case 40: // down arrow @@ -2140,33 +1442,26 @@ $(document).ready(function(){ case 65: // a if(is_ctrl_key(event)) { - $.each($("#baskets div.content:visible .CHIM.diapo"),function(i,n){ - var k = $(n).attr('id').split('_').slice(2,4).join('_'); - if($.inArray(k,p4.baskSel) <0) - { - p4.baskSel.push(k); - $(n).addClass('selected'); - } - }); + p4.WorkZone.Selection.selectAll(); cancelKey = shortCut = true; } break; case 80://P if(is_ctrl_key(event)) { - printThis("lst="+p4.baskSel.join(';')); + printThis("lst="+p4.WorkZone.Selection.serialize()); cancelKey = shortCut = true; } break; case 69://e if(is_ctrl_key(event)) { - editThis('IMGT',p4.baskSel.join(';')); + editThis('IMGT',p4.WorkZone.Selection.serialize()); cancelKey = shortCut = true; } break; // case 46://del - // deleteThis(p4.sel.join(';')); + // deleteThis(p4.Results.Selection.serialize()); // cancelKey = true; // break; case 40: // down arrow @@ -2389,64 +1684,6 @@ function editThis(type,value) return; } -function renameThis(ssel) -{ - $.ajax({ - type: "POST", - url: "/prod/prodFeedBack.php", - data: { - action: "BASKETRENAME", - ssel_id:ssel, - name:$('#basket-dialog input[name=name]').val(), - description:$('#basket-desc').val() - }, - success: function(data){ - refreshBaskets('current'); - } - }); -} - -function renameBasket(that,ssel) -{ - var buttons = {}; - - buttons[language.valider] = function() { - renameThis(ssel); - $('#basket-dialog').dialog('close'); - - }; - - buttons[language.annuler] = function(){ - $('#basket-dialog').dialog('close'); - }; - - $.ajax({ - type: "GET", - url: "/prod/baskets/"+ssel+'/update/', - dataType : 'html', - success: function(data){ - - $("#basket-dialog") - .dialog({ - title:language.bask_rename, - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - overlay: { - backgroundColor: '#000', - opacity: 0.7 - } - }).dialog('option','buttons',buttons) - .dialog('open'); - $('#basket-dialog input[name=name]').val(data.name); - $('#basket-dialog textarea').val(data.description); - } - }); -} - - (function($) { $.fn.extend({ highlight: function(color) { @@ -2685,15 +1922,15 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) - value = "lst=" + p4.sel.join(';'); + if(p4.Results.Selection.length() > 0) + value = "lst=" + p4.Results.Selection.serialize(); } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) - value = "lst=" + p4.baskSel.join(';'); + if(p4.WorkZone.Selection.length() > 0) + value = "lst=" + p4.WorkZone.Selection.serialize(); else value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); } @@ -2722,15 +1959,15 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) - datas.lst = p4.sel.join(';'); + if(p4.Results.Selection.length() > 0) + datas.lst = p4.Results.Selection.serialize(); } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) - datas.lst = p4.baskSel.join(';'); + if(p4.WorkZone.Selection.length() > 0) + datas.lst = p4.WorkZone.Selection.serialize(); else datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); } @@ -2761,14 +1998,14 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) + if(p4.Results.Selection.length() > 0) type = 'IMGT'; } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) + if(p4.WorkZone.Selection.length() > 0) type = 'CHIM'; } } @@ -2789,20 +2026,20 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) + if(p4.Results.Selection.length() > 0) { type = 'IMGT'; - value = p4.sel.join(';'); + value = p4.Results.Selection.serialize(); } } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) + if(p4.WorkZone.Selection.length() > 0) { type = 'IMGT'; - value = p4.baskSel.join(';'); + value = p4.WorkZone.Selection.serialize(); } else { @@ -2836,20 +2073,20 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) + if(p4.Results.Selection.length() > 0) { type = 'IMGT'; - value = p4.sel.join(';'); + value = p4.Results.Selection.serialize(); } } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) + if(p4.WorkZone.Selection.length() > 0) { type = 'IMGT'; - value = p4.baskSel.join(';'); + value = p4.WorkZone.Selection.serialize(); } else { @@ -2912,15 +2149,15 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) - value.lst = p4.sel.join(';'); + if(p4.Results.Selection.length() > 0) + value.lst = p4.Results.Selection.serialize(); } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) - value.lst = p4.baskSel.join(';'); + if(p4.WorkZone.Selection.length() > 0) + value.lst = p4.WorkZone.Selection.serialize(); else value.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); } @@ -2952,15 +2189,15 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) - value = "lst=" + p4.sel.join(';'); + if(p4.Results.Selection.length() > 0) + value = "lst=" + p4.Results.Selection.serialize(); } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) - value = "lst=" + p4.baskSel.join(';'); + if(p4.WorkZone.Selection.length() > 0) + value = "lst=" + p4.WorkZone.Selection.serialize(); else value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); } @@ -2987,15 +2224,15 @@ function activeIcons() var value=""; if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) - value = "lst=" + p4.sel.join(';'); + if(p4.Results.Selection.length() > 0) + value = "lst=" + p4.Results.Selection.serialize(); } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) - value = "lst=" + p4.baskSel.join(';'); + if(p4.WorkZone.Selection.length() > 0) + value = "lst=" + p4.WorkZone.Selection.serialize(); else value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); } @@ -3023,15 +2260,15 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) - value = "lst=" + p4.sel.join(';'); + if(p4.Results.Selection.length() > 0) + value = "lst=" + p4.Results.Selection.serialize(); } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) - value = "lst=" + p4.baskSel.join(';'); + if(p4.WorkZone.Selection.length() > 0) + value = "lst=" + p4.WorkZone.Selection.serialize(); else value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); } @@ -3060,18 +2297,18 @@ function activeIcons() if($(this).hasClass('results_window')) { - if(p4.sel.length > 0) + if(p4.Results.Selection.length() > 0) { - datas.lst = p4.sel.join(';'); + datas.lst = p4.Results.Selection.serialize(); } } else { if($(this).hasClass('basket_window')) { - if(p4.baskSel.length > 0) + if(p4.WorkZone.Selection.length() > 0) { - datas.lst = p4.baskSel.join(';'); + datas.lst = p4.WorkZone.Selection.serialize(); } else { @@ -3119,9 +2356,9 @@ function checkDeleteThis(type, el) var lst = ''; if(type == 'IMGT') - lst = p4.sel.join(';'); + lst = p4.Results.Selection.serialize(); if(type == 'CHIM') - lst = p4.baskSel.join(';'); + lst = p4.WorkZone.Selection.serialize(); deleteThis(lst); @@ -3194,27 +2431,33 @@ function shareThis(bas,rec) function printThis(value) { - var url = "/include/printpage.php?"+value; + + + $('#DIALOG').attr('title', 'Print') + .empty().addClass('loading') + .dialog({ + resizable:false, + closeOnEscape:true, + modal:true, + width:'800', + height:'500' + }) + .dialog('open'); - $('#MODALDL').attr('src','about:blank'); - $('#MODALDL').attr('src',url); + $.ajax({ + type: "POST", + url: '/prod/printer/?'+value, + dataType: 'html', + beforeSend:function(){ - - var t = (bodySize.y - 400) / 2; - var l = (bodySize.x - 550) / 2; - - $('#MODALDL').css({ - 'display': 'block', - 'opacity': 0, - 'width': '550px', - 'position': 'absolute', - 'top': t, - 'left': l, - 'height': '400px' - }).fadeTo(500, 1); - - showOverlay(2); - $('#tooltip').hide(); + }, + success: function(data){ + $('#DIALOG').removeClass('loading').empty() + .append(data); + return; + } + }); + } @@ -3260,7 +2503,7 @@ function downloadThis(datas) function viewNbSelect() { - $("#nbrecsel").empty().append(p4.sel.length); + $("#nbrecsel").empty().append(p4.Results.Selection.length()); } function selector(el) @@ -3373,12 +2616,12 @@ function selector(el) function select_this(n,k) { - if(p4.sel.length >= 800) + if(p4.Results.Selection.length() >= 800) { alert(language.max_record_selected); return false; } - p4.sel.push(k); + p4.Results.Selection.push(k); $(n).addClass('selected'); return true; } @@ -3400,210 +2643,6 @@ function evt_add_in_chutier(a,b,event,el) } -function evt_mdwn_obj(obj, evt) //, i, idx) -{ - if(typeof($(obj).attr('id')) == undefined) - return; - var objId = $(obj).attr('id').split('_'); - - $('#answercontextwrap table:visible').hide(); - - switch(objId[0]) - { - case "IMGT": - var cont = $('#idFrameA'); - // on a clique sur une imagette - k = objId.slice(1,3).join('_'); - - if(is_shift_key(evt) && $('.IMGT.last_selected', cont).length!=0) - { - // la touche shift est pressee - var lst = $('.IMGT', cont); - var index1 = $.inArray($('.IMGT.last_selected', cont)[0],lst); - var index2 = $.inArray($(obj)[0],lst); - - if(index2=0) - { - p4.sel = $.grep(p4.sel,function(n){ - return(n!=k); - }); - $(obj).removeClass('selected'); - } - else - { - // if(p4.sel >= 400) - // { - // alert(language.max_record_selected); - // return; - // } - - if(!select_this(obj,k)) - return false; - // p4.sel.push(k); - // $(obj).addClass('selected'); - } - } - } - - $('.last_selected', cont).removeClass('last_selected'); - $(obj).addClass('last_selected'); - - viewNbSelect(); - - break; - case "SSTT": // l'onglet d'un chutier - case "SSEL": // le contenant d'un chutier - case "CHIM": // une imagette dans un chutier - case "PREV": // une preview - // dragObj.dragSrc = obj; - break; - default: - break; - } - return false; -} - -function baskSelection(obj,evt) -{ - var cont = $('#idFrameC .content:visible'); - // on a clique sur une imagette - var objId = $(obj).attr('id'); - var k = $(obj).attr('id').split('_').slice(2,4).join('_'); - - if(is_shift_key(evt) && $('.CHIM.last_selected', cont).length!=0) - { - // la touche shift est pressee - var lst = $('.CHIM', cont); - var index1 = $.inArray($('.CHIM.last_selected', cont)[0],lst); - var index2 = $.inArray($(obj)[0],lst); - - if(index2=0) - { - p4.baskSel = $.grep(p4.baskSel,function(n){ - return(n!=k); - }); - $(obj).removeClass('selected'); - } - else - { - p4.baskSel.push(k); - $(obj).addClass('selected'); - } - } - } - - $('.last_selected', cont).removeClass('last_selected'); - $(obj).addClass('last_selected'); - return false; -} - -// ----------------------------------------------------------------------------------------------- - - function doSpecialSearch(qry, allbase){ if (allbase) { checkBases(true); @@ -3664,7 +2703,6 @@ function doDelete(lst) $.each(data,function(i,n){ var imgt = $('#IMGT_'+n); - var chim = $('.CHIM_'+n); $('.doc_infos', imgt).remove(); imgt.unbind("click").removeAttr("ondblclick").removeClass("selected").draggable("destroy").removeClass("IMGT").find("img").unbind(); imgt.find(".thumb img").attr("src","/skins/icons/deleted.png").css({ @@ -3674,15 +2712,10 @@ function doDelete(lst) chim.parent().slideUp().remove(); imgt.find(".status,.title,.bottom").empty(); - if($.inArray(n,p4.sel)>=0) - { - p4.sel = $.grep(p4.sel,function(m){ - return(m!=n); - }); - } + p4.Results.Selection.remove(n); + p4.WorkZone.Selection.remove(n); }); viewNbSelect(); - refreshBaskets('current'); } }); } @@ -3705,7 +2738,7 @@ function deleteBasket(item) $('#SSTT_'+k).slideUp().droppable('destroy').remove(); if($('#baskets .SSTT').length == 0) - refreshBaskets(false); + return p4.WorkZone.refresh(false); } else { @@ -3784,26 +2817,9 @@ function advSearch(event) { event.cancelBubble = true; alternateSearch(false); - // var adv_buttons = {}; - // adv_buttons[language.rechercher] = function(){ - // newAdvSearch(); - // }; - // adv_buttons[language.fermer] = function(){ - // $('#adv_search').dialog('close'); - // }; - $('#idFrameC .tabs a.adv_search').trigger('click'); -// $("#adv_search") -// .dialog('option','title',language.advsearch_title) -// .dialog('option','buttons',adv_buttons) -// .dialog('option','height',(bodySize.y-100)).dialog('open'); -// var h = $("#adv_search").innerHeight()-$("#adv_search .ui-tabs-nav").outerHeight(); -// $('#adv_search .ui-tabs-panel').height(h-30); -// $('#adv_search .ui-tabs-panel .innerBox').height(h-50); -// $('#adv_filters .adv_search_bind input').each(function(i,n){ -// $(this).val(''); -// }); -// $('#adv_search input[name=query_all]').val($('#EDIT_query').val()).select(); +$('#idFrameC .tabs a.adv_search').trigger('click'); + } function start_page_selector() @@ -3991,7 +3007,7 @@ function saveWindows() function gotopage(pag) { - document.forms['search'].sel.value = p4.sel.join(';'); + document.forms['search'].sel.value = p4.Results.Selection.serialize(); $('#formAnswerPage').val(pag); $('#searchForm').submit(); } @@ -4147,235 +3163,6 @@ function reverse_order() }); } - -function save_order() -{ - var ssel_id = $('#reorder_box form[name=save] input[name=ssel_id]').val(); - var forms = $('#reorder_box .diapo form'); - - var n = 1; - var datas_order = {}; - - forms.each(function(i,el){ - var val = $('input[name=id]',el).val()+' '; - var base_id = $('input[name=base_id]',el).val(); - var record_id = $('input[name=record_id]',el).val(); - - if(val == '') - return; - datas_order[val] = { - order:n, - base_id : base_id, - record_id : record_id - }; - n++; - }); - - var options = { - ssel_id : ssel_id, - value : JSON.stringify(datas_order), - action : 'SAVE_ORDER_DATAS' - }; - - $.post("prodFeedBack.php" - , options - , function(data){ - refreshBaskets('current'); - return; - }); - - -} - -function reorder(ssel_id) -{ - var buttons = {}; - - buttons[language.valider] = function(){ - save_order(); - $("#reorder_dialog").dialog('close'); - return; - }; - - $("#reorder_dialog") - .dialog({ - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - buttons:buttons, - width:700, - height:500, - overlay: { - backgroundColor: '#000', - opacity: 0.7 - }, - close:function(){} - }).dialog('open'); - - $.get("/prod/baskets/"+ssel_id+"/reorder/" - , function(data){ - $('#reorder_box').removeClass('loading'); - var cont = $("#reorder_box"); - cont.empty().append(data) - .sortable({ - appendTo : $("#reorder_box"), - placeholder: 'diapo ui-sortable-placeholder', - distance:20, - cursorAt: { - top:10, - left:-20 - }, - items:'div.diapo', - scroll:true, - scrollSensitivity:40, - scrollSpeed:30, - start:function(event, ui){ - var selected = $('.selected',cont); - - selected.each(function(i,n){ - $(n).attr('position',i); - }); - - var n = selected.length - 1; - - $('.selected:visible', cont).hide(); - - while(n > 0) - { - $('
      ').insertAfter($('.diapo.ui-sortable-placeholder', cont)); - n--; - } - }, - stop:function(event, ui){ - - $('.diapo.ui-sortable-placeholderfollow', cont).remove(); - - var main_id = $(ui.item[0]).attr('id'); - - var selected = $('.selected',cont); - var sorter = new Array(); - - - selected.each(function(i,n){ - - var position = parseInt($(n).attr('position')); - - if(position !== '') - { - sorter[position] = $(n); - } - - var id = $(n).attr('id'); - if(id == main_id) - { - return; - } - - }); - - var before = true; - var last_moved = $(ui.item[0]); - $(sorter).each(function(i,n){ - $(n).show().removeAttr('position'); - if($(n).attr('id') == main_id) - { - before = false; - } - else - { - if(before) - $(n).insertBefore($(ui.item[0])); - else - $(n).insertAfter($(last_moved)); - - } - last_moved = sorter[i]; - }); - - }, - change:function(){ - $('.diapo.ui-sortable-placeholderfollow', cont).remove(); - - var n = $('.selected',cont).length - 1 ; - while(n > 0) - { - $('
      ').insertAfter($('.diapo.ui-sortable-placeholder', cont)); - n--; - } - } - - }).disableSelection(); - - $('.diapo', cont).bind('mousedown',function(event){ - if(!$(this).hasClass('selected') && !is_ctrl_key(event) && !is_shift_key(event)) - { - $('.diapo.selected', cont).removeClass('selected'); - $('.diapo.last_selected', cont).removeClass('last_selected'); - $(this).addClass('last_selected selected'); - } - }); - - $('.diapo', cont).bind('click',function(event){ - if(is_ctrl_key(event)) - { - if($(this).hasClass('selected')) - { - $(this).removeClass('selected'); - } - else - { - $(this).addClass('selected'); - } - } - else - { - if(is_shift_key(event) && $('.diapo.last_selected', cont).length!=0) - { - var lst = $('.diapo', cont); - var index1 = $.inArray($('.diapo.last_selected', cont)[0],lst); - var index2 = $.inArray($(this)[0],lst); - - if(index2get_session(); $registry = $appbox->get_registry(); @@ -108,59 +108,6 @@ switch ($action) $output = 1; break; -// case 'BASKETS': -// require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); -// $parm = $request->get_parms('id', 'sort'); -// $baskets = new basketCollection($appbox, $usr_id); -// -// $twig = new supertwig(); -// $twig->addFilter(array('get_collection_logo' => 'collection::getLogo')); -// -// $output = $twig->render('prod/baskets.html', array( -// 'basket_collection' => $baskets, -// 'selected_ssel' => $parm['id'], -// 'srt' => $parm['sort'] -// ) -// ); -// break; -// case 'BASKETNAME': -// require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); -// $parm = $request->get_parms('ssel_id'); -// $basket = basket_adapter::getInstance($appbox, $parm['ssel_id'], $usr_id); -// $output = p4string::jsonencode(array('name' => $basket->get_name(), 'description' => $basket->get_description())); -// break; - case 'BASKETRENAME': - require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); - $parm = $request->get_parms('ssel_id', 'name', 'description'); - $basket = basket_adapter::getInstance($appbox, $parm['ssel_id'], $usr_id); - $basket->set_name($parm['name']); - $basket->set_description($parm['description']); -// $output = $basket->save(); - break; - - case 'GETBASKET': - require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); - - $twig = new supertwig(); - $twig->addFilter(array('nl2br' => 'nl2br')); - - $parm = $request->get_parms('id', 'ord'); - - $basket = basket_adapter::getInstance($appbox, $parm['id'], $usr_id); - $basket->set_read(); - - $order = $parm['ord']; - - if (trim($order) == '' || !in_array($order, array('asc', 'desc', 'nat'))) - $order = $user->getPrefs('bask_val_order'); - else - $user->setPrefs('bask_val_order', $order); - - $basket->sort($order); - - $output = p4string::jsonencode(array('content' => $twig->render('prod/basket.twig', array('basket' => $basket, 'ordre' => $order)))); - break; - case 'DELETE': require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); $parm = $request->get_parms('lst'); @@ -177,19 +124,6 @@ switch ($action) $output = query_phrasea::mail_request($parm['user'], $parm['contrib'], $parm['message'], $parm['query']); break; - - case 'REORDER_DATAS': - $parm = $request->get_parms('ssel_id'); - $basket = basket_adapter::getInstance($appbox, $parm['ssel_id'], $usr_id); - $output = $basket->getOrderDatas(); - break; - case 'SAVE_ORDER_DATAS': - $parm = $request->get_parms('ssel_id', 'value'); - $basket = basket_adapter::getInstance($appbox, $parm['ssel_id'], $usr_id); - $output = $basket->saveOrderDatas($parm['value']); - break; - - case 'DENY_CGU': $parm = $request->get_parms('sbas_id'); $output = databox_cgu::denyCgus($parm['sbas_id']); @@ -197,7 +131,7 @@ switch ($action) case 'READ_NOTIFICATIONS': try { - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $parm = $request->get_parms('notifications'); $output = $evt_mngr->read(explode('_', $parm['notifications']), $session->get_usr_id()); $output = p4string::jsonencode(array('error' => false, 'message' => '')); @@ -208,7 +142,7 @@ switch ($action) } break; case 'NOTIFICATIONS_FULL': - $evt_mngr = eventsmanager_broker::getInstance($appbox); + $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $parm = $request->get_parms('page'); $output = $evt_mngr->get_json_notifications($parm['page']); break; @@ -258,141 +192,7 @@ switch ($action) $output = $twig->render('prod/preview/reg_train.html', array('container_records' => $record->get_container()->get_children(), 'record' => $record, 'GV_rollover_reg_preview' => $registry->get('GV_rollover_reg_preview'))); break; - case 'UNFIX': - $parm = $request->get_parms('lst'); - $output = basket_adapter::unfix_grouping($parm['lst']); - break; - case 'FIX': - $parm = $request->get_parms('lst'); - $output = basket_adapter::fix_grouping($parm['lst']); - break; - case 'ADDIMGT2CHU': - case 'ADDCHU2CHU': - case 'ADDREG2CHU': - $parm = $request->get_parms('dest', 'lst'); - $basket = basket_adapter::getInstance($appbox, $parm['dest'], $usr_id); - $output = p4string::jsonencode($basket->push_list($parm['lst'], false)); - - break; - case 'ADDIMGT2REG': - case 'ADDCHU2REG': - case 'ADDREG2REG': - $parm = $request->get_parms('dest', 'lst'); - $basket = basket_adapter::getInstance($appbox, $parm['dest'], $usr_id); - $output = p4string::jsonencode($basket->push_list($parm['lst'], false)); - break; - case 'DELFROMBASK': - $parm = $request->get_parms('ssel_id', 'sselcont_id'); - $basket = basket_adapter::getInstance($appbox, $parm['ssel_id'], $usr_id); - $output = p4string::jsonencode($basket->remove_from_ssel($parm['sselcont_id'])); - break; - case 'DELBASK': - $parm = $request->get_parms('ssel'); - $basket = basket_adapter::getInstance($appbox, $parm['ssel'], $usr_id); - $output = $basket->delete(); - unset($basket); - break; - - case 'MOVCHU2CHU': - $parm = $request->get_parms('from', 'dest', 'sselcont'); - $from_basket = basket_adapter::getInstance($appbox, $parm['from'], $usr_id); - $to_basket = basket_adapter::getInstance($appbox, $parm['dest'], $usr_id); - - $ret = array('error' => _('phraseanet :: une erreur est survenue'), 'datas' => array()); - if (!is_array($parm['sselcont'])) - $parm['sselcont'] = explode(';', $parm['sselcont']); - - $elements = $from_basket->get_elements(); - foreach ($parm['sselcont'] as $sselcont_id) - { - if (!isset($elements[$sselcont_id])) - continue; - - $element = $elements[$sselcont_id]; - - if ($to_basket->push_element($element->get_record(), false, false)) - { - unset($elements[$sselcont_id]); - $from_basket->remove_from_ssel($sselcont_id); - - $ret['error'] = false; - $ret['datas'][] = $sselcont_id; - } - } - $output = p4string::jsonencode($ret); - break; - case 'MOVREG2REG': - require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); - $lst = array(); - $parm = $request->get_parms('lst', 'dest', 'sselcont', 'from'); - $basket = basket_adapter::getInstance($appbox, $parm['dest'], $usr_id); - $res = $basket->push_list($parm['lst'], false); - if (!$res['error']) - { - $basket = basket_adapter::getInstance($appbox, $parm['from'], $usr_id); - - $sselcont_ids = explode(';', $parm['sselcont']); - foreach ($sselcont_ids as $sselcont_id) - { - $basket->remove_from_ssel($sselcont_id); - } - } - $output = p4string::jsonencode(array('error' => $res['error'], 'datas' => explode(';', $parm['sselcont']))); - break; - case 'MOVCHU2REG': - require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); - $parm = $request->get_parms('lst', 'dest', 'sselcont', 'from'); - $basket = basket_adapter::getInstance($appbox, $parm['dest'], $usr_id); - $res = $basket->push_list($parm['lst'], false); - if (!$res['error']) - { - $basket = basket_adapter::getInstance($appbox, $parm['from'], $usr_id); - - $sselcont_ids = explode(';', $parm['sselcont']); - foreach ($sselcont_ids as $sselcont_id) - { - $basket->remove_from_ssel($sselcont_id); - } - } - $output = p4string::jsonencode(array('error' => $res['error'], 'datas' => explode(';', $parm['sselcont']))); - break; -// case 'MOVREG2CHU': -// require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); -// -// $parm = $request->get_parms('lst', 'dest', 'sselcont', 'from'); -// $basket = basket_adapter::getInstance($appbox, $parm['dest'], $usr_id); -// $add = $basket->push_list($parm['lst'], false); -// -// if (!$add['error']) -// { -// -// $basket = basket_adapter::getInstance($appbox, $parm['from'], $usr_id); -// -// $ret['error'] = false; -// $ret['datas'] = array(); -// -// $sselcont_ids = explode(';', $parm['sselcont']); -// foreach ($sselcont_ids as $sselcont_id) -// { -// $rem = $basket->remove_from_ssel($sselcont_id); -// if (!$rem['error']) -// { -// $ret['datas'][] = $sselcont_id; -// } -// else -// { -// $ret['error'] = true; -// } -// } -// } -// else -// $ret = array('datas' => array(), 'error' => $add['error']); -// $output = p4string::jsonencode($ret); -// break; - - - - + case 'GET_ORDERMANAGER': try { diff --git a/www/prod/publish.php b/www/prod/publish.php index 43ceb8076b..55da404848 100644 --- a/www/prod/publish.php +++ b/www/prod/publish.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $message = ''; try diff --git a/www/prod/push.feedback.php b/www/prod/push.feedback.php index a77fe208d3..cd1135acec 100644 --- a/www/prod/push.feedback.php +++ b/www/prod/push.feedback.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/prod/pushdoc.php b/www/prod/pushdoc.php index f22ad0ef66..5602641938 100644 --- a/www/prod/pushdoc.php +++ b/www/prod/pushdoc.php @@ -15,7 +15,7 @@ * @link www.phraseanet.com */ define('ZFONT', 'freesans'); -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +$Core = require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); @@ -82,12 +82,19 @@ if ($act == "STEP2") { $num = 0; + if ($parm['SSTTID'] != '') { - $basket = basket_adapter::getInstance($appbox, $parm['SSTTID'], $usr_id); + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($Core->getRequest()->get('SSTTID'), $Core->getAuthenticatedUser()); + $lst = array(); - foreach ($basket->get_elements() as $basket_element) - $lst[] = $basket_element->get_record()->get_serialize_key(); + foreach ($basket->getElements() as $basket_element) + { + $lst[] = $basket_element->getRecord()->get_serialize_key(); + } } else { @@ -603,76 +610,80 @@ if ($act == "SEND") { $lst = array_reverse($push_datas[$parm['token']]['lst']); - $basket = basket_adapter::create($appbox, $parm["nameBask"], $user); - $basket->set_unread(); - $basket->push_list($lst, false); - $basket->flatten(); - $ssel_id = $basket->get_ssel_id(); + $em = $Core->getEntityManager(); + + $basket = new \Entities\Basket(); + $basket->setName($Core->getRequest()->get('nameBask')); + $basket->setIsRead(false); + + $em->persist($basket); + + foreach($lst as $basrec) + { + $basrec = explode('_', $basrec); + + $record = new record_adapter($basrec[0], $basrec[1]); + $basket_element = new Entities\BasketElement(); + $basket_element->setRecord($record); + $basket_element->setBasket($basket); + $basket->addBasketElement($basket_element); + + $em->persist($basket_element); + } + + $em->flush(); + + $ssel_id = $basket->getId(); $outinfos = _('prod::push: votre nouveau panier a ete cree avec succes ; il contient vos documents de validation'); } else { - $basket = basket_adapter::getInstance($appbox, $ssel_id, $usr_id); - - if ($basket->is_grouping()) - { - $elements = $basket->get_elements(); - $basket = basket_adapter::create($appbox, $basket->get_name(), $user); - - foreach ($elements as $record) - { - $basket->push_element($record, false, false); - } - - unset($elements); - - $ssel_id = $basket->get_ssel_id(); - } - - $basket->flatten(); + $em = $Core->getEntityManager(); + $repository = $em->getRepository('\Entities\Basket'); + + $basket = $repository->findUserBasket($ssel_id, $Core->getAuthenticatedUser()); + + $ssel_id = $basket->getId(); } $my_link = ''; - if ($ssel_id && is_numeric($ssel_id)) + + $lstUsrs = $push_datas[$parm['token']]['usrs']; + $users = array(); + foreach ($lstUsrs as $usr => $right) { - $lstUsrs = $push_datas[$parm['token']]['usrs']; - $users = array(); - foreach ($lstUsrs as $usr => $right) + $users[$usr] = array('canHD' => (in_array($right['HD'], array('0', '1')) ? $right['HD'] : '0'), 'canRate' => '0', 'canAgree' => '1', 'canSeeOther' => ($parm['view_all'] == '1' ? '1' : '0'), 'canZone' => '0'); + } + + if (!array_key_exists($session->get_usr_id(), $lstUsrs)) + $users[$session->get_usr_id()] = array('canHD' => '0', 'canRate' => '0', 'canAgree' => '1', 'canSeeOther' => '1', 'canZone' => '0'); + + $push = pushValidation($usr_id, $basket->getId(), $users, $parm['timValS'], $parm["textmail"], $parm['accuse']); + $my_link = $push['mylink']; + + + $Endusers = $push['users']; + + $lstbyBase = array(); + + foreach ($basket->getElements() as $basket_element) + { + $record = $basket_element->getRecord(); + $lstbyBase[$record->get_sbas_id()][] = $record->get_record_id(); + } + + foreach ($lstbyBase as $sbas_id => $lst) + { + foreach ($lst as $record_id) { - $users[$usr] = array('canHD' => (in_array($right['HD'], array('0', '1')) ? $right['HD'] : '0'), 'canRate' => '0', 'canAgree' => '1', 'canSeeOther' => ($parm['view_all'] == '1' ? '1' : '0'), 'canZone' => '0'); - } - - if (!array_key_exists($session->get_usr_id(), $lstUsrs)) - $users[$session->get_usr_id()] = array('canHD' => '0', 'canRate' => '0', 'canAgree' => '1', 'canSeeOther' => '1', 'canZone' => '0'); - - $push = pushValidation($usr_id, $ssel_id, $users, $parm['timValS'], $parm["textmail"], $parm['accuse']); - $my_link = $push['mylink']; - - - $Endusers = $push['users']; - - $lstbyBase = array(); - - $basket = basket_adapter::getInstance($appbox, $ssel_id, $usr_id); - foreach ($basket as $basket_element) - { - $record = $basket_element->get_record(); - $lstbyBase[$record->get_sbas_id()][] = $record->get_record_id(); - } - - foreach ($lstbyBase as $sbas_id => $lst) - { - foreach ($lst as $record_id) + foreach ($Endusers as $u) { - foreach ($Endusers as $u) - { - $record = new record_adapter($sbas_id, $record_id); - $session->get_logger($record->get_databox()) - ->log($record, Session_Logger::EVENT_VALIDATE, $u, ''); - unset($record); - } + $record = new record_adapter($sbas_id, $record_id); + $session->get_logger($record->get_databox()) + ->log($record, Session_Logger::EVENT_VALIDATE, $u, ''); + unset($record); } } } @@ -687,7 +698,7 @@ if ($act == "SEND") } ?> get_session(); diff --git a/www/prod/share.php b/www/prod/share.php index 01e7f6245b..f178c22e24 100644 --- a/www/prod/share.php +++ b/www/prod/share.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(); $appbox = appbox::get_instance(); $registry = $appbox->get_registry(); @@ -67,7 +67,6 @@ if (!$right) $sha256 = $record->get_sha256(); $type = $record->get_type(); -$bitly = $record->get_bitly_link(); $url = ''; @@ -114,7 +113,7 @@ if ($url != '') ?>
      diff --git a/www/report/ajax_chart.php b/www/report/ajax_chart.php index fb172be261..074c3c42dc 100644 --- a/www/report/ajax_chart.php +++ b/www/report/ajax_chart.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $request = http_request::getInstance(); diff --git a/www/report/ajax_info_dashboard.php b/www/report/ajax_info_dashboard.php index f1d7b108b7..bab9720ece 100644 --- a/www/report/ajax_info_dashboard.php +++ b/www/report/ajax_info_dashboard.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $request = http_request::getInstance(); diff --git a/www/report/ajax_liste_base.php b/www/report/ajax_liste_base.php index 3d1eed98e3..65fffcbd0f 100644 --- a/www/report/ajax_liste_base.php +++ b/www/report/ajax_liste_base.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $parm = $request->get_parms( diff --git a/www/report/ajax_table_content.php b/www/report/ajax_table_content.php index d1e197e3b5..9c831bfaba 100644 --- a/www/report/ajax_table_content.php +++ b/www/report/ajax_table_content.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; /* get all the post parameters from report.php's form */ diff --git a/www/report/charts/drawLinePlotWithLegend.php b/www/report/charts/drawLinePlotWithLegend.php index a764f4f636..54ae2c8356 100644 --- a/www/report/charts/drawLinePlotWithLegend.php +++ b/www/report/charts/drawLinePlotWithLegend.php @@ -1,8 +1,8 @@ get_parms("value", 'legend', 'absc'); diff --git a/www/report/charts/draw_pie.php b/www/report/charts/draw_pie.php index dcc6d8e570..5ac850c623 100644 --- a/www/report/charts/draw_pie.php +++ b/www/report/charts/draw_pie.php @@ -1,8 +1,8 @@ get_parms("value", 'legend', 'title'); diff --git a/www/report/export_csv.php b/www/report/export_csv.php index 65c3f67351..7ad3a4d7bf 100644 --- a/www/report/export_csv.php +++ b/www/report/export_csv.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $parm = $request->get_parms('name', 'csv'); diff --git a/www/report/index.php b/www/report/index.php index 1db463852e..47394970ea 100644 --- a/www/report/index.php +++ b/www/report/index.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/report/report.php b/www/report/report.php index 1369a3aef9..7d5bbfb979 100644 --- a/www/report/report.php +++ b/www/report/report.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $registry = registry::get_instance(); diff --git a/www/report/tab.php b/www/report/tab.php index 7da2bbb74b..b6352c6d34 100644 --- a/www/report/tab.php +++ b/www/report/tab.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; /* get all the post parameters from report.php's form */ diff --git a/www/setup/installer.php b/www/setup/installer.php index 309847ec72..45a8007272 100644 --- a/www/setup/installer.php +++ b/www/setup/installer.php @@ -17,7 +17,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . '/../../lib/classes/bootstrap.class.php'; +require_once __DIR__ . '/../../lib/classes/bootstrap.class.php'; bootstrap::register_autoloads(); bootstrap::set_php_configuration(); diff --git a/www/skins/admin/admincolor.css b/www/skins/admin/admincolor.css index f45e65ee20..4733139710 100644 --- a/www/skins/admin/admincolor.css +++ b/www/skins/admin/admincolor.css @@ -48,6 +48,7 @@ FFFA00 9E9C3C 777400 FFFC65 FFFEB5 #left{ background-color:#fffbcd; + overflow:auto; } #FNDR{ overflow:auto; @@ -141,4 +142,20 @@ table.admintable tbody .dropdown{ .users_col.options{ cursor:pointer; color:#AFAFAF; +} +#users th.sortable span{ + margin:0 5px; +} +#users th.sortable{ + cursor:pointer; +} +#users th.sortable.hover, +#users th.sortable.sorted{ + background-color:#F0AD30; +} +#users th.sortable span.ord_notifier{ + display:none; +} +#users th.sortable.sorted span.ord_notifier{ + display:inline; } \ No newline at end of file diff --git a/www/skins/admin/fleche verte.png b/www/skins/admin/fleche verte.png deleted file mode 100644 index 914623748c..0000000000 Binary files a/www/skins/admin/fleche verte.png and /dev/null differ diff --git a/www/skins/lng/inclin-ar.gif b/www/skins/lng/inclin-ar.gif deleted file mode 100644 index 8ad6e70d9a..0000000000 Binary files a/www/skins/lng/inclin-ar.gif and /dev/null differ diff --git a/www/skins/lng/inclin-ar.png b/www/skins/lng/inclin-ar.png new file mode 100644 index 0000000000..3a95504d21 Binary files /dev/null and b/www/skins/lng/inclin-ar.png differ diff --git a/www/skins/lng/inclin-de.gif b/www/skins/lng/inclin-de.gif deleted file mode 100644 index 229f594a87..0000000000 Binary files a/www/skins/lng/inclin-de.gif and /dev/null differ diff --git a/www/skins/lng/inclin-de.png b/www/skins/lng/inclin-de.png new file mode 100644 index 0000000000..cb0a8c17f8 Binary files /dev/null and b/www/skins/lng/inclin-de.png differ diff --git a/www/skins/lng/inclin-en.gif b/www/skins/lng/inclin-en.gif deleted file mode 100644 index 5b7ce96b90..0000000000 Binary files a/www/skins/lng/inclin-en.gif and /dev/null differ diff --git a/www/skins/lng/inclin-en.png b/www/skins/lng/inclin-en.png new file mode 100644 index 0000000000..3a95504d21 Binary files /dev/null and b/www/skins/lng/inclin-en.png differ diff --git a/www/skins/lng/inclin-fr.gif b/www/skins/lng/inclin-fr.gif deleted file mode 100644 index 166e4aa9fb..0000000000 Binary files a/www/skins/lng/inclin-fr.gif and /dev/null differ diff --git a/www/skins/lng/inclin-fr.png b/www/skins/lng/inclin-fr.png new file mode 100644 index 0000000000..499c680c0a Binary files /dev/null and b/www/skins/lng/inclin-fr.png differ diff --git a/www/skins/prod/000000/prodcolor.css b/www/skins/prod/000000/prodcolor.css index 144abe0db9..a24350c4fa 100644 --- a/www/skins/prod/000000/prodcolor.css +++ b/www/skins/prod/000000/prodcolor.css @@ -263,6 +263,18 @@ span.ww_winTitle{ padding:0; min-height:120px; } +.ui-accordion-icons .ui-accordion-header a +{ + padding:2px 25px; +} +.ui-state-active .ui-icon +{ + background-image: url("/include/jslibs/jquery-ui-1.8.12/css/dark-hive/images/ui-icons_cccccc_256x240.png"); +} +#baskets .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { + color:#FFFFFF; + font-size:1em; +} .ui-accordion .ui-accordion-content.loading { background-image:url(/skins/icons/loader000.gif); @@ -2831,7 +2843,7 @@ dans l'onglet thesaurus : arbres, menus contextuels #DIALOG p{ line-height:18px; } -#DIALOG input{ +#DIALOG input:text{ height:24px; font-size:15px; margin:15px auto; diff --git a/www/skins/prod/959595/prodcolor.css b/www/skins/prod/959595/prodcolor.css index e6a3ca527a..e258bfaddf 100644 --- a/www/skins/prod/959595/prodcolor.css +++ b/www/skins/prod/959595/prodcolor.css @@ -266,6 +266,18 @@ span.ww_winTitle{ padding:0; min-height:120px; } +.ui-accordion-icons .ui-accordion-header a +{ + padding:2px 25px; +} +.ui-state-active .ui-icon +{ + background-image: url("/include/jslibs/jquery-ui-1.8.12/css/ui-lightness/images/ui-icons_ffffff_256x240.png"); +} +#baskets .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { + color:#FFFFFF; + font-size:1em; +} .ui-accordion .ui-accordion-content.loading { background-image:url(/skins/icons/loaderd9d9d9.gif); @@ -2832,7 +2844,7 @@ dans l'onglet thesaurus : arbres, menus contextuels #DIALOG p{ line-height:18px; } -#DIALOG input{ +#DIALOG input:text{ height:24px; font-size:15px; margin:15px auto; diff --git a/www/thesaurus2/accept.php b/www/thesaurus2/accept.php index 1a05eae6b1..f8b3a849e5 100644 --- a/www/thesaurus2/accept.php +++ b/www/thesaurus2/accept.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); diff --git a/www/thesaurus2/export_text.php b/www/thesaurus2/export_text.php index b74a58cef8..281caab130 100644 --- a/www/thesaurus2/export_text.php +++ b/www/thesaurus2/export_text.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/export_text_dlg.php b/www/thesaurus2/export_text_dlg.php index 932008f1a3..df0df49320 100644 --- a/www/thesaurus2/export_text_dlg.php +++ b/www/thesaurus2/export_text_dlg.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/export_topics.php b/www/thesaurus2/export_topics.php index 808aff4d70..e3d396440b 100644 --- a/www/thesaurus2/export_topics.php +++ b/www/thesaurus2/export_topics.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); diff --git a/www/thesaurus2/export_topics_dlg.php b/www/thesaurus2/export_topics_dlg.php index 0ea89aed32..b599457e79 100644 --- a/www/thesaurus2/export_topics_dlg.php +++ b/www/thesaurus2/export_topics_dlg.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/import.php b/www/thesaurus2/import.php index d48a1e094d..f2de0b25a7 100644 --- a/www/thesaurus2/import.php +++ b/www/thesaurus2/import.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/import_dlg.php b/www/thesaurus2/import_dlg.php index 80beeefb95..166d8ad6ed 100644 --- a/www/thesaurus2/import_dlg.php +++ b/www/thesaurus2/import_dlg.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); phrasea::headers(200, true); diff --git a/www/thesaurus2/index.php b/www/thesaurus2/index.php index db79401005..7b00fe45f7 100644 --- a/www/thesaurus2/index.php +++ b/www/thesaurus2/index.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry(); diff --git a/www/thesaurus2/linkfield.php b/www/thesaurus2/linkfield.php index 3467a9a91a..f8518718b9 100644 --- a/www/thesaurus2/linkfield.php +++ b/www/thesaurus2/linkfield.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); diff --git a/www/thesaurus2/linkfield2.php b/www/thesaurus2/linkfield2.php index 0dc349a0f6..f84c76ecbe 100644 --- a/www/thesaurus2/linkfield2.php +++ b/www/thesaurus2/linkfield2.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/linkfield3.php b/www/thesaurus2/linkfield3.php index 0dcd1abd5f..ab32570ba3 100644 --- a/www/thesaurus2/linkfield3.php +++ b/www/thesaurus2/linkfield3.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/loadth.php b/www/thesaurus2/loadth.php index 4817286cec..3ce20dedbb 100644 --- a/www/thesaurus2/loadth.php +++ b/www/thesaurus2/loadth.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . '/../../lib/bootstrap.php'; +require_once __DIR__ . '/../../lib/bootstrap.php'; $registry = registry::get_instance(); phrasea::headers(); $debug = false; diff --git a/www/thesaurus2/newsy_dlg.php b/www/thesaurus2/newsy_dlg.php index e8c0f2a1c2..20de190d9a 100644 --- a/www/thesaurus2/newsy_dlg.php +++ b/www/thesaurus2/newsy_dlg.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/newterm.php b/www/thesaurus2/newterm.php index 417286df87..5ac3ae4217 100644 --- a/www/thesaurus2/newterm.php +++ b/www/thesaurus2/newterm.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); diff --git a/www/thesaurus2/properties.php b/www/thesaurus2/properties.php index ffb6dc825b..6821d2cf07 100644 --- a/www/thesaurus2/properties.php +++ b/www/thesaurus2/properties.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/replace.php b/www/thesaurus2/replace.php index 58b3965949..11383977e3 100644 --- a/www/thesaurus2/replace.php +++ b/www/thesaurus2/replace.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/replace2.php b/www/thesaurus2/replace2.php index ff7b124550..f99b2c99b0 100644 --- a/www/thesaurus2/replace2.php +++ b/www/thesaurus2/replace2.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/replace3.php b/www/thesaurus2/replace3.php index 52de9a4ecc..c74cdd514e 100644 --- a/www/thesaurus2/replace3.php +++ b/www/thesaurus2/replace3.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/rescan.php b/www/thesaurus2/rescan.php index b6248a4ee4..7142412813 100644 --- a/www/thesaurus2/rescan.php +++ b/www/thesaurus2/rescan.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/rescan_dlg.php b/www/thesaurus2/rescan_dlg.php index aee025d95c..a07a3a4c7d 100644 --- a/www/thesaurus2/rescan_dlg.php +++ b/www/thesaurus2/rescan_dlg.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/search.php b/www/thesaurus2/search.php index 041e7feb55..1ecebcdc07 100644 --- a/www/thesaurus2/search.php +++ b/www/thesaurus2/search.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(200, true); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/thesaurus.php b/www/thesaurus2/thesaurus.php index 9ec547e088..bfc84b797d 100644 --- a/www/thesaurus2/thesaurus.php +++ b/www/thesaurus2/thesaurus.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; phrasea::headers(); $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/thesaurus2/xmlhttp/accept.x.php b/www/thesaurus2/xmlhttp/accept.x.php index 194e17bd8b..b84889a37c 100644 --- a/www/thesaurus2/xmlhttp/accept.x.php +++ b/www/thesaurus2/xmlhttp/accept.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/acceptcandidates.x.php b/www/thesaurus2/xmlhttp/acceptcandidates.x.php index 536456ac14..2b4f6d6c58 100644 --- a/www/thesaurus2/xmlhttp/acceptcandidates.x.php +++ b/www/thesaurus2/xmlhttp/acceptcandidates.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/changesylng.x.php b/www/thesaurus2/xmlhttp/changesylng.x.php index 47450fbe7d..c8b64ddecf 100644 --- a/www/thesaurus2/xmlhttp/changesylng.x.php +++ b/www/thesaurus2/xmlhttp/changesylng.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/changesypos.x.php b/www/thesaurus2/xmlhttp/changesypos.x.php index 8c7ba2c0d3..793d5fcdde 100644 --- a/www/thesaurus2/xmlhttp/changesypos.x.php +++ b/www/thesaurus2/xmlhttp/changesypos.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/deletenohits.x.php b/www/thesaurus2/xmlhttp/deletenohits.x.php index 3895ab8b8c..b48a8bb6be 100644 --- a/www/thesaurus2/xmlhttp/deletenohits.x.php +++ b/www/thesaurus2/xmlhttp/deletenohits.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); $request = http_request::getInstance(); diff --git a/www/thesaurus2/xmlhttp/delsy.x.php b/www/thesaurus2/xmlhttp/delsy.x.php index 70e46cf55c..5501328d80 100644 --- a/www/thesaurus2/xmlhttp/delsy.x.php +++ b/www/thesaurus2/xmlhttp/delsy.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); require("../xmlhttp.php"); diff --git a/www/thesaurus2/xmlhttp/delts.x.php b/www/thesaurus2/xmlhttp/delts.x.php index 33d17c7ea6..628210e29d 100644 --- a/www/thesaurus2/xmlhttp/delts.x.php +++ b/www/thesaurus2/xmlhttp/delts.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); $request = http_request::getInstance(); diff --git a/www/thesaurus2/xmlhttp/gethtmlbranch.x.php b/www/thesaurus2/xmlhttp/gethtmlbranch.x.php index c8b304d3b8..aaf1cdbeb3 100644 --- a/www/thesaurus2/xmlhttp/gethtmlbranch.x.php +++ b/www/thesaurus2/xmlhttp/gethtmlbranch.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/getsy.x.php b/www/thesaurus2/xmlhttp/getsy.x.php index 314d00447b..207c6177f4 100644 --- a/www/thesaurus2/xmlhttp/getsy.x.php +++ b/www/thesaurus2/xmlhttp/getsy.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/getterm.x.php b/www/thesaurus2/xmlhttp/getterm.x.php index 8baf058e6a..2a49f36cb5 100644 --- a/www/thesaurus2/xmlhttp/getterm.x.php +++ b/www/thesaurus2/xmlhttp/getterm.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/killterm.x.php b/www/thesaurus2/xmlhttp/killterm.x.php index 681b21ce23..e8112ec89b 100644 --- a/www/thesaurus2/xmlhttp/killterm.x.php +++ b/www/thesaurus2/xmlhttp/killterm.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); require("../xmlhttp.php"); diff --git a/www/thesaurus2/xmlhttp/newsy.x.php b/www/thesaurus2/xmlhttp/newsy.x.php index 7295bf8c98..62c84d63ee 100644 --- a/www/thesaurus2/xmlhttp/newsy.x.php +++ b/www/thesaurus2/xmlhttp/newsy.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/newts.x.php b/www/thesaurus2/xmlhttp/newts.x.php index 1cd95ddabf..39fc05b91a 100644 --- a/www/thesaurus2/xmlhttp/newts.x.php +++ b/www/thesaurus2/xmlhttp/newts.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/openbranches.x.php b/www/thesaurus2/xmlhttp/openbranches.x.php index a91e24716f..b0d024dc14 100644 --- a/www/thesaurus2/xmlhttp/openbranches.x.php +++ b/www/thesaurus2/xmlhttp/openbranches.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/reject.x.php b/www/thesaurus2/xmlhttp/reject.x.php index 57b341ebd7..fbdbe9f899 100644 --- a/www/thesaurus2/xmlhttp/reject.x.php +++ b/www/thesaurus2/xmlhttp/reject.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); require("../xmlhttp.php"); diff --git a/www/thesaurus2/xmlhttp/searchcandidate.x.php b/www/thesaurus2/xmlhttp/searchcandidate.x.php index 6b51c10e7a..cdb90ec346 100644 --- a/www/thesaurus2/xmlhttp/searchcandidate.x.php +++ b/www/thesaurus2/xmlhttp/searchcandidate.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../../lib/bootstrap.php"; +require_once __DIR__ . "/../../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/thesaurus2/xmlhttp/searchnohits.x.php b/www/thesaurus2/xmlhttp/searchnohits.x.php index 0f27c9ed0b..49754f3a55 100644 --- a/www/thesaurus2/xmlhttp/searchnohits.x.php +++ b/www/thesaurus2/xmlhttp/searchnohits.x.php @@ -1,6 +1,6 @@ get_session(); $registry = $appbox->get_registry(); @@ -332,7 +332,7 @@ $twig = new supertwig(); $twig->display('common/menubar.twig' , array( 'module' => 'upload' - , 'events' => eventsmanager_broker::getInstance($appbox) + , 'events' => eventsmanager_broker::getInstance($appbox, $Core) )); ?>
      diff --git a/www/upload/lazaret_image.php b/www/upload/lazaret_image.php index 8df9c736f1..7325858a02 100644 --- a/www/upload/lazaret_image.php +++ b/www/upload/lazaret_image.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $parm = $request->get_parms('id'); diff --git a/www/upload/upload.php b/www/upload/upload.php index 627de1f1db..383e65e618 100644 --- a/www/upload/upload.php +++ b/www/upload/upload.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . '/../../lib/classes/http/request.class.php'; +require_once __DIR__ . '/../../lib/classes/http/request.class.php'; $request = http_request::getInstance(); $parm = $request->get_parms('session', 'coll', 'status'); @@ -25,7 +25,7 @@ if ($parm["session"]) session_id($parm["session"]); } -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/upload/uploadFeedback.php b/www/upload/uploadFeedback.php index 734b64ad8b..1e09c4e7c1 100644 --- a/www/upload/uploadFeedback.php +++ b/www/upload/uploadFeedback.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $parm = $request->get_parms('action', 'from_id', 'to_id', 'actions', 'id'); diff --git a/www/xmlhttp/acceptcandidates.j.php b/www/xmlhttp/acceptcandidates.j.php index 6353c71a27..5ddb543fd4 100644 --- a/www/xmlhttp/acceptcandidates.j.php +++ b/www/xmlhttp/acceptcandidates.j.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/xmlhttp/checkcandidatetarget.j.php b/www/xmlhttp/checkcandidatetarget.j.php index 7b2406792c..8bb9d1c9c3 100644 --- a/www/xmlhttp/checkcandidatetarget.j.php +++ b/www/xmlhttp/checkcandidatetarget.j.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/xmlhttp/deletecandidates.j.php b/www/xmlhttp/deletecandidates.j.php index aec0cd1a3b..42065c4e4e 100644 --- a/www/xmlhttp/deletecandidates.j.php +++ b/www/xmlhttp/deletecandidates.j.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); $request = http_request::getInstance(); diff --git a/www/xmlhttp/editing_presets.j.php b/www/xmlhttp/editing_presets.j.php index d8be3d741c..fa302fb6c1 100644 --- a/www/xmlhttp/editing_presets.j.php +++ b/www/xmlhttp/editing_presets.j.php @@ -14,7 +14,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/xmlhttp/getsy_prod.x.php b/www/xmlhttp/getsy_prod.x.php index a7f9418435..a5150ceab6 100644 --- a/www/xmlhttp/getsy_prod.x.php +++ b/www/xmlhttp/getsy_prod.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); $request = http_request::getInstance(); diff --git a/www/xmlhttp/getterm_prod.h.php b/www/xmlhttp/getterm_prod.h.php index 8ed668a4c7..3de36ff492 100644 --- a/www/xmlhttp/getterm_prod.h.php +++ b/www/xmlhttp/getterm_prod.h.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); $request = http_request::getInstance(); diff --git a/www/xmlhttp/getterm_prod.x.php b/www/xmlhttp/getterm_prod.x.php index 77ce661f71..a92f4764dd 100644 --- a/www/xmlhttp/getterm_prod.x.php +++ b/www/xmlhttp/getterm_prod.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $request = http_request::getInstance(); $parm = $request->get_parms( "bid" diff --git a/www/xmlhttp/openbranch_prod.j.php b/www/xmlhttp/openbranch_prod.j.php index a7ccf7c12e..587b06d066 100644 --- a/www/xmlhttp/openbranch_prod.j.php +++ b/www/xmlhttp/openbranch_prod.j.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); diff --git a/www/xmlhttp/openbranches_prod.h.php b/www/xmlhttp/openbranches_prod.h.php index 5c91109a18..642224d104 100644 --- a/www/xmlhttp/openbranches_prod.h.php +++ b/www/xmlhttp/openbranches_prod.h.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/xmlhttp/openbranches_prod.x.php b/www/xmlhttp/openbranches_prod.x.php index ee6130178f..9664ddb6fe 100644 --- a/www/xmlhttp/openbranches_prod.x.php +++ b/www/xmlhttp/openbranches_prod.x.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); diff --git a/www/xmlhttp/replacecandidate.j.php b/www/xmlhttp/replacecandidate.j.php index 95bd8fdb68..52952e2162 100644 --- a/www/xmlhttp/replacecandidate.j.php +++ b/www/xmlhttp/replacecandidate.j.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $registry = registry::get_instance(); $request = http_request::getInstance(); diff --git a/www/xmlhttp/search_th_term_prod.j.php b/www/xmlhttp/search_th_term_prod.j.php index 4524ef9aea..870d7a2287 100644 --- a/www/xmlhttp/search_th_term_prod.j.php +++ b/www/xmlhttp/search_th_term_prod.j.php @@ -15,7 +15,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ -require_once dirname(__FILE__) . "/../../lib/bootstrap.php"; +require_once __DIR__ . "/../../lib/bootstrap.php"; $appbox = appbox::get_instance(); $session = $appbox->get_session(); $registry = $appbox->get_registry();