This commit is contained in:
Nicolas Le Goff
2011-12-27 13:06:51 +01:00
300 changed files with 3436 additions and 3162 deletions

3
.gitmodules vendored
View File

@@ -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

View File

@@ -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', $Core->getVersion()->getName()
. ' ' . $Core->getVersion()->getNumber());
$app->add(new module_console_aboutAuthors('about:authors'));
$app->add(new module_console_aboutLicense('about:license'));

View File

@@ -2,4 +2,4 @@
dir.src=/tmp/jenkinsWorking-dev
# test.ci
dir.dest=/home/sites_web/test-dev.ci.alchemyasp.com
dir.dest=/home/sites_web/test-dev.ci.alchemyasp.com/pv3

View File

@@ -32,6 +32,8 @@ return call_user_func(function()
$app = new Silex\Application();
$app["Core"] = bootstrap::getCore();
$app["appbox"] = appbox::get_instance();
/**
@@ -68,7 +70,7 @@ return call_user_func(function()
*/
$app['api'] = function () use ($app)
{
return new API_V1_adapter(false, $app["appbox"]);
return new API_V1_adapter(false, $app["appbox"], $app["Core"]);
};

View File

@@ -20,7 +20,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
return call_user_func(
function()
{
@@ -30,17 +29,29 @@ return call_user_func(
$app = new Silex\Application();
$app->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())
@@ -71,7 +82,7 @@ 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'));
@@ -107,19 +118,30 @@ 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);
$em = $app['Core']->getEntityManager();
$repository = $em->getRepository('\Entities\BasketElement');
/* @var $repository \Repositories\BasketElementRepository */
$BasketElement = $repository->findUserElement(
$sselcont_id
, $app['Core']->getAuthenticatedUser()
);
$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 +152,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'));
@@ -182,15 +204,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');
/* @var $repository \Repositories\BasketRepository */
$basket_collection = $repository->findActiveByUser(
$app['Core']->getAuthenticatedUser()
);
$basket = $repository->findUserBasket(
$ssel_id
, $app['Core']->getAuthenticatedUser()
);
if ($basket->is_valid())
{
@@ -220,20 +252,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();
@@ -260,7 +297,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 +330,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) use ($appbox, $app)
{
$twig = new supertwig();
$twig->addFilter(array('nl2br' => 'nl2br'));
@@ -311,7 +348,7 @@ 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
@@ -352,7 +389,7 @@ 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');
@@ -388,7 +425,7 @@ 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());

View File

@@ -34,6 +34,8 @@ 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',
));

View File

@@ -30,6 +30,8 @@ return call_user_func(
$app = new Silex\Application();
$app['Core'] = bootstrap::getCore();
$deliver_content = function(Session_Handler $session, record_adapter $record, $subdef, $watermark, $stamp, $app)
{

View File

@@ -15,6 +15,7 @@ use Silex\Application;
use Alchemy\Phrasea\Controller\Setup as Controller;
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
require_once dirname(__FILE__) . '/../../../bootstrap.php';
/**
*
* @package
@@ -26,6 +27,8 @@ return call_user_func(function()
{
$app = new Silex\Application();
$app['Core'] = bootstrap::getCore();
$app['install'] = false;
$app['upgrade'] = false;

View File

@@ -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']);
$twig = new \supertwig();
$twig->addFilter(array('floor' => 'floor'));
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
$users->apply_template();
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');

View File

@@ -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 */
@@ -343,6 +343,61 @@ class Basket implements ControllerProviderInterface
}
});
$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)
{
$twig = new \supertwig();
@@ -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+');

View File

@@ -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);
@@ -420,7 +420,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 +447,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();

View File

@@ -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';

View File

@@ -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)
{

View File

@@ -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';

View File

@@ -46,9 +46,8 @@ 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));
});
return $controllers;

View File

@@ -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,14 +114,15 @@ 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()

View File

@@ -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();
@@ -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');

View File

@@ -24,7 +24,16 @@ require_once __DIR__ . '/../../vendor/Silex/vendor/pimple/lib/Pimple.php';
class Core extends \Pimple
{
/**
protected static $availableLanguages = array(
'ar_SA' => 'العربية'
, 'de_DE' => 'Deutsch'
, 'en_GB' => 'English'
, 'es_ES' => 'Español'
, 'fr_FR' => 'Français'
);
/**
*
* @var Core\Configuration
*/
@@ -54,10 +63,23 @@ class Core extends \Pimple
});
$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
@@ -82,22 +104,21 @@ 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;
}
@@ -203,6 +224,7 @@ class Core extends \Pimple
protected function enableEvents()
{
\phrasea::load_events();
return;
@@ -216,8 +238,8 @@ class Core extends \Pimple
if ($this->getRegistry()->get('GV_debug'))
{
ini_set('display_errors', 'on');
ini_set('display_startup_errors', 'on');
ini_set('display_errors', 'on');
ini_set('display_startup_errors', 'on');
}
else
{
@@ -237,23 +259,24 @@ class Core extends \Pimple
return $this;
}
/**
*
* @return Array
*/
public static function getAvailableLanguages()
{
return static::$availableLanguages;
}
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'));
}

View File

@@ -22,7 +22,11 @@ use Alchemy\Phrasea\Core;
class Helper
{
private $core;
/**
*
* @var Alchemy\Phrasea\Core\Kernel
*/
protected $core;
/**
*

View File

@@ -12,7 +12,7 @@
namespace Alchemy\Phrasea\Helper\Record;
use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper;
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper;
/**
*

View File

@@ -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)
@@ -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'))
{
@@ -462,7 +467,6 @@ class Edit extends RecordHelper
}
if (!is_array($request->get('mds')))
return $this;
$sbas_id = (int) $request->get('sbid');

View File

@@ -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,14 +43,12 @@ 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())
{

View File

@@ -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,35 @@ 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();
$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);
$em = $this->getCore()->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
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;
/* @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 +149,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,16 +294,6 @@ 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)
{
foreach ($this->selection->get_elements() as $record)

View File

@@ -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;
}
}

View File

@@ -12,7 +12,7 @@
namespace Alchemy\Phrasea\Helper\Record;
use Alchemy\Phrasea\Helper\RecordsAbstract as RecordHelper;
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper;
/**
*

View File

@@ -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) $this->request->get('base_id');
$this->base_id = (int) $request->get('base_id');
$dmin = $this->request->get('dmin') ? new \DateTime($this->request->get('dmin')) : null;
$dmax = $this->request->get('dmax') ? new \DateTime($this->request->get('dmax')) : null;
$dmin = $request->get('dmin') ? new \DateTime($request->get('dmin')) : null;
$dmax = $request->get('dmax') ? new \DateTime($request->get('dmax')) : null;
$activate = $this->request->get('limit');
$activate = $request->get('limit');
foreach ($this->users as $usr_id)
{

View File

@@ -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)
public function search()
{
$this->request = $request;
$request = $this->getCore()->getRequest();
return $this;
}
public function search(Request $request)
{
$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')))
@@ -111,17 +103,24 @@ class Manage
$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);

View File

@@ -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;
}
}

View File

@@ -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 = false;
/**
* @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;
}
}

View File

@@ -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()
);
}
}
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Repositories;
use Doctrine\ORM\EntityRepository;
/**
* BasketElementRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class BasketElementRepository extends EntityRepository
{
public function findUserElement($element_id, \User_Adapter $user)
{
$dql = 'SELECT e FROM Entities\BasketElement e
JOIN e.basket b
WHERE b.usr_id = :usr_id AND e.id = :element_id';
$params = array(
'usr_id' => $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_id->get_record_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 findUserElement($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;
}
}

View File

@@ -39,7 +39,6 @@ class BasketRepository extends EntityRepository
return $query->getResult();
}
/**
* Returns all baskets that are in validation session not expired and
* where a specified user is participant (not owner)
@@ -61,11 +60,20 @@ class BasketRepository extends EntityRepository
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 +87,22 @@ 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(),
'sbas_id' => $record->get_sbas_id()
);
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
return $query->getResult();
}
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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';
/**
*

View File

@@ -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;
}

View File

@@ -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));
@@ -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)
)
)
);
@@ -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' => $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
);

View File

@@ -1,6 +1,6 @@
<?php
require_once dirname(__FILE__) . "/../../../../lib/vendor/oauth2/lib/OAuth2.inc";
require_once __DIR__ . "/../../../../lib/vendor/oauth2/lib/OAuth2.inc";
/*
* This file is part of Phraseanet
*

View File

@@ -9,11 +9,11 @@
* 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);
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";
/**
*

View File

@@ -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;

View File

@@ -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";
/**
*

View File

@@ -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');

View File

@@ -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
{
}

View File

@@ -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
{
}

View File

@@ -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
{
}

View File

@@ -1,21 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package Exception
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Exception_Basket_NotFound extends Exception_NotFound
{
}

View File

@@ -0,0 +1,3 @@
<?php
require_once __DIR__ . '/../vendor/PHPShortener/phpshortener.class.php';

View File

@@ -179,7 +179,7 @@ class Setup_Upgrade
*/
public static function get_lock_file()
{
return dirname(__FILE__) . '/../../../tmp/upgrade.lock';
return __DIR__ . '/../../../tmp/upgrade.lock';
}
/**

View File

@@ -871,6 +871,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))
@@ -1371,7 +1376,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)))
@@ -1393,95 +1398,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)
{

View File

@@ -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;
}
}

View File

@@ -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())

View File

@@ -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;
}

View File

@@ -518,7 +518,6 @@ class basket_element_adapter implements cache_cacheableInterface
$note = strip_tags($note);
if (!$this->validate_id)
return false;
$appbox = appbox::get_instance();
@@ -596,7 +595,9 @@ class basket_element_adapter implements cache_cacheableInterface
foreach ($this->choices as $key => $value)
{
if (trim($value['note']) != '')
{
$n++;
}
}
return $n;

View File

@@ -1,5 +1,5 @@
<?php
require_once dirname(__FILE__) . '/../../../../vendor/moov/relocator.class.php';
require_once __DIR__ . '/../../../../vendor/moov/relocator.class.php';
/*
* This file is part of Phraseanet
*

View File

@@ -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]))
{

View File

@@ -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;
}

View File

@@ -450,7 +450,6 @@ class databox extends base
$stmt->closeCursor();
if ($row)
return self::get_instance((int) $row['sbas_id']);
try
@@ -575,7 +574,6 @@ class databox extends base
public function get_meta_structure()
{
if ($this->meta_struct)
return $this->meta_struct;
try
@@ -698,7 +696,6 @@ class databox extends base
}
}
if ($n > $limit)
return true;
return false;
@@ -725,7 +722,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,7 +957,14 @@ 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
@@ -968,7 +972,7 @@ class databox extends base
->set_indexable(isset($field['index']) ? $field['index'] : '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();
@@ -1213,7 +1217,6 @@ class databox extends base
public function get_structure()
{
if ($this->structure)
return $this->structure;
$this->structure = $this->retrieve_structure();
@@ -1254,7 +1257,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 +1423,6 @@ class databox extends base
public function get_cgus()
{
if ($this->cgus)
return $this->cgus;
$this->load_cgus();

View File

@@ -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'])
{

View File

@@ -67,17 +67,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();

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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')

View File

@@ -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(

View File

@@ -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');

View File

@@ -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);

View File

@@ -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');

View File

@@ -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);

View File

@@ -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");
@@ -283,7 +283,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 +497,7 @@ class phrasea
else
{
$request->set_code($code);
include(dirname(__FILE__) . '/../../www/include/error.php');
include(__DIR__ . '/../../www/include/error.php');
}
die();
break;

View File

@@ -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(
@@ -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,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try
{
$value = $this->get_subdef($name);
$original_file = p4string::addEndSlash($value['path']) . $value['file'];
$original_file = p4string::addEndSlash($value->get_path()) . $value->get_file();
unlink($original_file);
}
catch (Exception $e)
@@ -1083,7 +1065,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 +1077,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 +1117,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);
@@ -1714,21 +1703,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 +1920,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\Baskets');
$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);
}
/**

View File

@@ -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;
@@ -139,37 +140,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');
$this->container = $basket;
$this->total = count($basket->get_elements());
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($contId, $Core->getAuthenticatedUser());
/* @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());

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
<?php
require_once dirname(__FILE__) . '/../../../../vendor/sphinx/sphinxapi.php';
require_once __DIR__ . '/../../../../vendor/sphinx/sphinxapi.php';
/*
* This file is part of Phraseanet
*

View File

@@ -36,12 +36,13 @@ 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();
@@ -49,12 +50,17 @@ class set_export extends set_abstract
if ($sstid != "")
{
$basket = basket_adapter::getInstance($appbox, $sstid, $user->get_id());
$em = $Core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
foreach ($basket->get_elements() as $basket_element)
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($sstid, $user);
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,7 +76,7 @@ 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() . '/',
$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')) ?

View File

@@ -219,19 +219,29 @@ class set_order extends set_abstract
}
}
try
{
$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);
$core = \bootstrap::getCore();
$this->ssel_id = $basket->get_ssel_id();
$em = $core->getEntityManager();
$repository = $em->getRepository('\Entities\Basket');
/* @var $repository \Repositories\BasketRepository */
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser());
if(!$Basket)
{
$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();
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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);
@@ -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;
}
}

View File

@@ -1,5 +1,6 @@
Entities\BasketElement:
type: entity
repositoryClass: Repositories\BasketElementRepository
table: BasketElements
uniqueConstraints:
unique_recordcle:

View File

@@ -19,7 +19,7 @@ Entities\ValidationData:
manyToOne:
participant:
targetEntity: ValidationParticipant
inversedBy: datases
inversedBy: datas
joinColumn:
name: participant_id
referencedColumnName: id

View File

@@ -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"]

View File

@@ -21,9 +21,6 @@ Entities\ValidationSession:
on: update
expires:
type: datetime
reminded:
type: datetime
nullable: true;
oneToOne:
basket:
targetEntity: Basket

View File

@@ -1349,16 +1349,6 @@
<comment></comment>
</field>
<field>
<name>bas_manage</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default>0</default>
<comment></comment>
</field>
<field>
<name>bas_modify_struct</name>
<type>int(1) unsigned</type>

View File

@@ -172,11 +172,18 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract
public function testLogoutDeconnected()
{
try
{
$url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
$crawler = $this->client->request('GET', $url);
$pageContent = $this->client->getResponse()->getContent();
$this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
$this->deconnected($crawler, $pageContent);
}
catch(Exception $e)
{
exit($e);
}
}
public function testLogout()

View File

@@ -337,6 +337,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
protected static $collection;
protected static $time_start;
protected static $generated_subdefs = array();
/**
*
* @var \Alchemy\Phrasea\Core
*/
protected static $core;
public static function setUpBeforeClass()

View File

@@ -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()
@@ -371,9 +371,15 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$session = $appbox->get_session();
$usr_id = $session->get_usr_id();
$basket = basket_adapter::getInstance(appbox::get_instance(), $ssel_id, $usr_id);
$this->assertTrue($basket instanceof basket_adapter);
$basket->delete();
$em = self::$core->getEntityManager();
$repo = $em->getRepository('\Entities\Basket');
/* @var $repo \Repositories\BasketRepository */
$repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser());
$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)
{
}

View File

@@ -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));

View File

@@ -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"]));

View File

@@ -478,10 +478,9 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$baskets = $baskets['baskets'];
$basket = array_shift($baskets);
$this->assertInstanceOf('basket_adapter', $basket);
$this->assertInstanceOf('\Entities\Basket', $basket);
$basket->push_element(self::$record_1, false, false);
self::$record_1->get_container_baskets();
$found = $sselcont_id = false;
@@ -490,13 +489,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->get_ssel_id())
{
$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();
}
}
}

View File

@@ -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));
}

View File

@@ -11,28 +11,30 @@
{% endblock %}
{% block content %}
{% set record = basket_element.get_record() %}
{% set record = basket_element.getRecord() %}
<div data-role="page">
<div data-role="header">
<a href="/lightbox/validate/{{basket_element.get_ssel_id()}}/" data-rel="back" data-icon="arrow-l">Back</a>
<h1>{{basket_element.get_order()}} - {{record.get_title()}}</h1>
<a href="/lightbox/validate/{{basket_element.getId()}}/" data-rel="back" data-icon="arrow-l">Back</a>
<h1>{{basket_element.getOrd()}} - {{record.get_title()}}</h1>
<a rel="external" href="/lightbox/" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
</div>
<div data-role="content">
{{ thumbnail.format100percent(record.get_preview(),'',session, record.get_thumbnail()) }}
{% if basket_element.is_validation_item() %}
{% if basket_element.getBasket().getValidation() %}
<fieldset data-role="controlgroup" data-type="horizontal" style="text-align:center;">
<input {% if basket_element.get_my_agreement() == '1'%}checked="checked"{% endif %} type="radio" name="radio-view" id="radio-view-yes_{{basket_element.get_sselcont_id()}}" value="yes" />
<label class="agreement_radio" style="width:130px;text-align:center;" for="radio-view-yes_{{basket_element.get_sselcont_id()}}">{% trans 'validation:: OUI' %}</label>
<input {% if basket_element.getUserValidationDatas(user).getAgreement() == true%}checked="checked"{% endif %} type="radio" name="radio-view" id="radio-view-yes_{{basket_element.getId()}}" value="yes" />
<label class="agreement_radio" style="width:130px;text-align:center;" for="radio-view-yes_{{basket_element.getId()}}">{% trans 'validation:: OUI' %}</label>
<input {% if basket_element.get_my_agreement() == '-1'%}checked="checked"{% endif %} type="radio" name="radio-view" id="radio-view-no_{{basket_element.get_sselcont_id()}}" value="no" />
<label class="agreement_radio" style="width:130px;text-align:center;" for="radio-view-no_{{basket_element.get_sselcont_id()}}">{% trans 'validation:: NON' %}</label>
<input {% if basket_element.getUserValidationDatas(user).getAgreement() == false%}checked="checked"{% endif %} type="radio" name="radio-view" id="radio-view-no_{{basket_element.getId()}}" value="no" />
<label class="agreement_radio" style="width:130px;text-align:center;" for="radio-view-no_{{basket_element.getId()}}">{% trans 'validation:: NON' %}</label>
</fieldset>
<div style="text-align:center;margin:0 0 1em 0">
<a href="/lightbox/ajax/NOTE_FORM/{{basket_element.get_sselcont_id()}}/" data-role="button" data-inline="true" data-rel="dialog" data-transition="slidedown">{% trans 'validation:: editer ma note' %}</a>
<a href="/lightbox/ajax/NOTE_FORM/{{basket_element.getId()}}/" data-role="button" data-inline="true" data-rel="dialog" data-transition="slidedown">
{% trans 'validation:: editer ma note' %}
</a>
</div>
<div>
<ul data-role="listview" id="notes_{{basket_element.get_sselcont_id()}}">
<ul data-role="listview" id="notes_{{basket_element.getId()}}">
{% include 'lightbox/sc_note.twig' %}
</ul>
</div>

View File

@@ -111,7 +111,7 @@
<li>
<a href="#rights_tab">Droits</a>
</li>
{% if main_user is not empty %}
{% if main_user is not empty and main_user.is_template is empty %}
<li>
<a href="#user_infos_tab">Fiche</a>
</li>
@@ -142,7 +142,7 @@
</th>
<th colspan="26">
<img src="/skins/lng/inclin-{{session.get_I18n()}}.gif" >
<img src="/skins/lng/inclin-{{session.get_I18n()}}.png" style="width:698px"/>
</th>
</tr>
</thead>
@@ -402,7 +402,7 @@
</form>
</div>
{% if main_user is not empty %}
{% if main_user is not empty and main_user.is_template is empty %}
<div id="user_infos_tab" class="PNB" style="top:40px;">
<form id="user_infos_form">
<table>

View File

@@ -52,33 +52,91 @@
<button type="submit">{% trans 'boutton::chercher' %}</button>
</p>
</form>
<form id="users_apply_template" method="post" action="/admin/users/apply_template/" target="_self">
<p class="admin_head_opts">
{% trans 'Apply a template' %}
<select name="template_chooser">
<option value="">{% trans 'boutton::choisir' %}</option>
{% for template in templates %}
<option value="{{ template.get_id() }}">{{ template.get_display_name() }}</option>
{% endfor %}
</select>
<button type="submit">{% trans 'boutton::appliquer' %}</button>
</p>
</form>
<table id="users" cellspacing="0" cellpadding="0" border="0" class="admintable">
<thead>
<tr>
<th style="text-align: center;">
<th style="text-align: center;" class="sortable {{ parm.srt == 'usr_id' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
{% trans 'admin::compte-utilisateur id utilisateur' %}
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="usr_id" />
</th>
<th>
<th class="sortable {{ parm.srt == 'usr_login' ? 'sorted' : '' }} ">
<span>
{% trans 'admin::compte-utilisateur identifiant' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="usr_login" />
</th>
<th>
<th class="sortable {{ parm.srt == 'usr_nom' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
<span>
{% trans 'admin::compte-utilisateur nom/prenom' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="usr_nom" />
</th>
<th>
<th class="sortable {{ parm.srt == 'societe' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
<span>
{% trans 'admin::compte-utilisateur societe' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="societe" />
</th>
<th>
<th class="sortable {{ parm.srt == 'usr_mail' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
<span>
{% trans 'admin::compte-utilisateur email' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="usr_mail" />
</th>
<th>
<th class="sortable {{ parm.srt == 'pays' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
<span>
{% trans 'admin::compte-utilisateur pays' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="pays" />
</th>
<th>
<th class="sortable {{ parm.srt == 'lastModel' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
<span>
{% trans 'admin::compte-utilisateur dernier modele applique' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="lastModel" />
</th>
<th>
<th class="sortable {{ parm.srt == 'usr_creationdate' ? 'sorted' : '' }} {{ parm.ord == 'asc' ? 'sort_asc' : 'sort_desc' }}">
<span>
{% trans 'admin::compte-utilisateur date de creation' %}
</span>
<span class="ord_notifier">
{{ parm.ord == 'asc' ? '&#x25bc;' : '&#x25B2;' }}
</span>
<input type="hidden" name="srt" value="usr_creationdate" />
</th>
</tr>
</thead>
@@ -120,8 +178,8 @@
<form id="users_page_form" method="post" target="_self" action="/admin/users/search/">
{{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();
});
});
</script>
</div>

View File

@@ -1,41 +1,49 @@
{% if basket_element and basket_element.is_validation_item() %}
{% if basket_element and basket_element.getBasket().getValidation() %}
<div class="left choices">
<table style="margin-left:10px;width:220px;height:30px;" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="title">{% trans 'VALIDATION' %}</td>
<td class="report_wrapper;"><a class="report" href="#">{% trans 'lightbox::recaptitulatif' %}</a></td>
<td class="report_wrapper">
<a class="report" href="#">
{% trans 'lightbox::recaptitulatif' %}
</a>
</td>
</tr>
</tbody>
</table>
{% if basket.is_valid() %}
<div style="margin-left:10px;width:220px;">{{basket.get_validation_infos}}</div>
{% if basket.getValidation() %}
<div style="margin-left:10px;width:220px;">
{{ basket.getValidation().getValidationString(user) }}
</div>
<ul style="margin:10px 0 0 20px;width:200px;">
{% for choice in basket_element.get_choices() %}
{% if choice.agreement == 1 %}
{% for validation_data in basket_element.getValidationData() %}
{% 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 %}
<li class="{% if choice.usr_id == session.get_usr_id() %}me{% endif %} {{classuser}} userchoice">{{choice.usr_name}}</li>
<li class="{% if validation_data.getParticipant().getUser().get_id() == user.get_id() %}me{% endif %} {{classuser}} userchoice">
{{ validation_data.getParticipant().getUser().get_display_name }}
</li>
{% endfor %}
</ul>
{% endif %}
{% if basket_element and basket_element.is_validation_item() %}
{% if basket_element and basket_element.getBasket().getValidation() %}
<div class="left choices">
<div style="height:60px;margin-top:15px;">
<table cellspacing="0" cellpadding="0" style="width:230px;">
<tr>
<td>
<div style="width:70px;margin:0px auto 0;" class="ui-corner-all big_box agree_{{basket_element.get_sselcont_id()}} agree {% if basket_element.get_my_agreement() != 1%}not_decided{% endif %}">
<div style="width:70px;margin:0px auto 0;" class="ui-corner-all big_box agree_{{basket_element.getId()}} agree {% if basket_element.getValidationData().getParticipant(user).getAgreement() != true %}not_decided{% endif %}">
<img src="/skins/lightbox/agree-bigie6.gif" style="vertical-align:middle;"/><span>{% trans 'validation:: OUI' %}</span>
</div>
</td>
<td>
<div style="width:70px;margin:0px auto;" class="ui-corner-all big_box disagree_{{basket_element.get_sselcont_id()}} disagree {% if basket_element.get_my_agreement() != -1%}not_decided{% endif %}">
<div style="width:70px;margin:0px auto;" class="ui-corner-all big_box disagree_{{basket_element.get_sselcont_id()}} disagree {% if basket_element.getValidationData().getParticipant(user).getAgreement() != false %}not_decided{% endif %}">
<img src="/skins/lightbox/disagree-bigie6.gif" style="vertical-align:middle;"/><span>{% trans 'validation:: NON' %}</span>
</div>
</td>

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