mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
Fix CS
This commit is contained in:
@@ -29,8 +29,7 @@ $result_code = 1;
|
||||
|
||||
$result_code = 1;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$app = new Application("
|
||||
_____ _ _ _____ _____ ______ _ _ ______ _______
|
||||
| __ \| | | | __ \ /\ / ____| ____| /\ | \ | | ____|__ __|
|
||||
@@ -82,9 +81,7 @@ try
|
||||
|
||||
|
||||
$result_code = $app->run() === 0 ? : 1;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
echo sprintf("an error occured : %s", $e->getMessage());
|
||||
}
|
||||
|
||||
|
13
bin/doctrine
13
bin/doctrine
@@ -26,15 +26,13 @@ use Alchemy\Phrasea;
|
||||
|
||||
$Core = require_once dirname(__FILE__) . '/../lib/bootstrap.php';
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
||||
|
||||
$serviceName = $configuration->getOrm();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
if ($confService->get("type") !== 'Orm\\Doctrine')
|
||||
{
|
||||
if ($confService->get("type") !== 'Orm\\Doctrine') {
|
||||
exit(sprintf("Doctrine is not declared as your ORM but %s is", $confService->get("type")));
|
||||
}
|
||||
|
||||
@@ -54,8 +52,7 @@ try
|
||||
);
|
||||
|
||||
$helperSet = $app->getHelperSet();
|
||||
foreach ($helpers as $name => $helper)
|
||||
{
|
||||
foreach ($helpers as $name => $helper) {
|
||||
$helperSet->set($helper, $name);
|
||||
}
|
||||
|
||||
@@ -81,8 +78,6 @@ try
|
||||
));
|
||||
|
||||
$app->run();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
echo "an error occured : " . $e->getMessage();
|
||||
}
|
||||
|
15
builder.php
15
builder.php
@@ -47,13 +47,11 @@ $finder
|
||||
|
||||
$files = array();
|
||||
|
||||
foreach ($finder as $file)
|
||||
{
|
||||
foreach ($finder as $file) {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
echo "rm $file\n";
|
||||
unlink($file);
|
||||
}
|
||||
@@ -83,15 +81,12 @@ $finder
|
||||
|
||||
$dirs = array();
|
||||
|
||||
foreach ($finder as $dir)
|
||||
{
|
||||
foreach ($finder as $dir) {
|
||||
$dirs[] = $dir->getPathname();
|
||||
}
|
||||
|
||||
foreach ($dirs as $dir)
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
foreach ($dirs as $dir) {
|
||||
if ( ! is_dir($dir)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
23
check_cs.php
23
check_cs.php
@@ -50,8 +50,7 @@ $finder
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($finder as $file)
|
||||
{
|
||||
foreach ($finder as $file) {
|
||||
|
||||
/* @var $file Symfony\Component\Finder\SplFileInfo */
|
||||
|
||||
@@ -63,8 +62,7 @@ foreach ($finder as $file)
|
||||
$new = str_replace('<? ', '<?php ', $new);
|
||||
|
||||
// [Structure] Indentation is done by steps of four spaces (tabs are never allowed)
|
||||
$new = preg_replace_callback('/^( *)(\t+)/m', function ($matches) use ($new)
|
||||
{
|
||||
$new = preg_replace_callback('/^( *)(\t+)/m', function ($matches) use ($new) {
|
||||
return $matches[1] . str_repeat(' ', strlen($matches[2]));
|
||||
}, $new);
|
||||
|
||||
@@ -78,16 +76,14 @@ foreach ($finder as $file)
|
||||
$new = preg_replace('/\t/m', ' ', $new);
|
||||
|
||||
// [Structure] Add a blank line before return statements
|
||||
$new = preg_replace_callback('/(^.*$)\n(^ +return)/m', function ($match)
|
||||
{
|
||||
$new = preg_replace_callback('/(^.*$)\n(^ +return)/m', function ($match) {
|
||||
// don't add it if the previous line is ...
|
||||
if (
|
||||
preg_match('/\{$/m', $match[1]) || // ... ending with an opening brace
|
||||
preg_match('/\:$/m', $match[1]) || // ... ending with a colon (e.g. a case statement)
|
||||
preg_match('%^ *//%m', $match[1]) || // ... an inline comment
|
||||
preg_match('/^$/m', $match[1]) // ... already blank
|
||||
)
|
||||
{
|
||||
) {
|
||||
return $match[1] . "\n" . $match[2];
|
||||
}
|
||||
|
||||
@@ -95,17 +91,14 @@ foreach ($finder as $file)
|
||||
}, $new);
|
||||
|
||||
// [Structure] A file must always ends with a linefeed character
|
||||
if (strlen($new) && "\n" != substr($new, -1))
|
||||
{
|
||||
if (strlen($new) && "\n" != substr($new, -1)) {
|
||||
$new .= "\n";
|
||||
}
|
||||
|
||||
if ($new != $old)
|
||||
{
|
||||
$count++;
|
||||
if ($new != $old) {
|
||||
$count ++;
|
||||
|
||||
if ($fix)
|
||||
{
|
||||
if ($fix) {
|
||||
file_put_contents($file->getRealpath(), $new);
|
||||
}
|
||||
printf('%4d) %s' . PHP_EOL, $count, $file->getRelativePathname());
|
||||
|
17
cleaner.php
17
cleaner.php
@@ -36,29 +36,24 @@ $finder
|
||||
|
||||
$files = array();
|
||||
|
||||
foreach ($finder as $file)
|
||||
{
|
||||
foreach ($finder as $file) {
|
||||
$result = '';
|
||||
|
||||
foreach (array('templates', 'lib/Alchemy', 'lib/Doctrine', 'lib/classes', 'www') as $dir)
|
||||
{
|
||||
$cmd = "grep -IR -m 1 --exclude='(*\.git*)' '" . str_replace(array(), array(), $file->getFilename()) . "' " . __DIR__.'/'.$dir;
|
||||
foreach (array('templates', 'lib/Alchemy', 'lib/Doctrine', 'lib/classes', 'www') as $dir) {
|
||||
$cmd = "grep -IR -m 1 --exclude='(*\.git*)' '" . str_replace(array(), array(), $file->getFilename()) . "' " . __DIR__ . '/' . $dir;
|
||||
$result .= @exec($cmd);
|
||||
|
||||
if (trim($result) !== '')
|
||||
{
|
||||
if (trim($result) !== '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (trim($result) === '')
|
||||
{
|
||||
if (trim($result) === '') {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
echo "rm $file\n";
|
||||
unlink($file);
|
||||
}
|
||||
|
@@ -20,8 +20,7 @@ use Symfony\Component\Finder\Finder;
|
||||
\Alchemy\Phrasea\Core::initAutoloads();
|
||||
|
||||
|
||||
if (!isset($argv[1]) || !is_dir(__DIR__ . '/' . $argv[1]))
|
||||
{
|
||||
if ( ! isset($argv[1]) || ! is_dir(__DIR__ . '/' . $argv[1])) {
|
||||
echo "You need to specify a directory with the latest launchpad locales" . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
@@ -41,8 +40,7 @@ $finder
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($finder as $file)
|
||||
{
|
||||
foreach ($finder as $file) {
|
||||
preg_match('/phraseanet-(.*)\.po/', $file->getFileName(), $matches);
|
||||
|
||||
$current_file = $file->getRealPath();
|
||||
@@ -50,15 +48,14 @@ foreach ($finder as $file)
|
||||
|
||||
$dest_file = __DIR__ . '/locale/' . $locale . '/LC_MESSAGES/phraseanet.po';
|
||||
|
||||
if (!file_exists($dest_file))
|
||||
{
|
||||
if ( ! file_exists($dest_file)) {
|
||||
echo "Destination $dest_file does not exists" . PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
system(sprintf('cp %s %s', $current_file, $dest_file));
|
||||
|
||||
$count++;
|
||||
$count ++;
|
||||
}
|
||||
|
||||
echo "$count files upgraded" . PHP_EOL;
|
||||
|
@@ -21,8 +21,7 @@ use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(
|
||||
function()
|
||||
{
|
||||
function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
@@ -36,7 +35,7 @@ return call_user_func(
|
||||
$app->mount('/tests/connection', new ControllerUtils\ConnectionTest());
|
||||
$app->mount('/tests/pathurl', new ControllerUtils\PathFileTest());
|
||||
|
||||
$app->error(function($e){
|
||||
$app->error(function($e) {
|
||||
return new \Symfony\Component\HttpFoundation\Response($e->getMessage(), 403);
|
||||
});
|
||||
|
||||
|
@@ -21,8 +21,7 @@ use Symfony\Component\HttpKernel\Exception;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(function()
|
||||
{
|
||||
return call_user_func(function() {
|
||||
|
||||
|
||||
$app = new \Silex\Application();
|
||||
@@ -40,17 +39,15 @@ return call_user_func(function()
|
||||
* Api Service
|
||||
* @var Closure
|
||||
*/
|
||||
$app['api'] = function () use ($app)
|
||||
{
|
||||
$app['api'] = function () use ($app) {
|
||||
return new \API_V1_adapter(false, $app["appbox"], $app["Core"]);
|
||||
};
|
||||
|
||||
/** *********************************************************
|
||||
/** * ********************************************************
|
||||
* oAuth token verification process
|
||||
* @ throws \API_V1_exception_unauthorized
|
||||
* ********************************************************* */
|
||||
$mustBeLogged = function($request) use ($app)
|
||||
{
|
||||
$mustBeLogged = function($request) use ($app) {
|
||||
$session = $app["appbox"]->get_session();
|
||||
$oauth2_adapter = new \API_OAuth2_Adapter($app["appbox"]);
|
||||
$oauth2_adapter->verifyAccessToken();
|
||||
@@ -58,21 +55,16 @@ return call_user_func(function()
|
||||
$user = \User_Adapter::getInstance($oauth2_adapter->get_usr_id(), $app["appbox"]);
|
||||
$app['token'] = \API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
|
||||
|
||||
if ($session->is_authenticated())
|
||||
{
|
||||
if ($session->is_authenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($oauth2_adapter->has_ses_id())
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($oauth2_adapter->has_ses_id()) {
|
||||
try {
|
||||
$session->restore($user, $oauth2_adapter->get_ses_id());
|
||||
|
||||
return;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -84,33 +76,26 @@ return call_user_func(function()
|
||||
};
|
||||
|
||||
|
||||
/* *********************************************************
|
||||
/* * ********************************************************
|
||||
* oAUth log process
|
||||
* ******************************************************* */
|
||||
|
||||
$parseRoute = function ($route, Response $response)
|
||||
{
|
||||
$parseRoute = function ($route, Response $response) {
|
||||
$ressource = $general = $aspect = $action = null;
|
||||
$exploded_route = explode('/', \p4string::delFirstSlash(\p4string::delEndSlash($route)));
|
||||
if (sizeof($exploded_route) > 0 && $response->isOk())
|
||||
{
|
||||
if (sizeof($exploded_route) > 0 && $response->isOk()) {
|
||||
$ressource = $exploded_route[0];
|
||||
|
||||
if (sizeof($exploded_route) == 2 && (int) $exploded_route[1] == 0)
|
||||
{
|
||||
if (sizeof($exploded_route) == 2 && (int) $exploded_route[1] == 0) {
|
||||
$general = $exploded_route[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ($ressource)
|
||||
{
|
||||
} else {
|
||||
switch ($ressource) {
|
||||
case \API_V1_Log::DATABOXES_RESSOURCE :
|
||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
||||
$aspect = $exploded_route[2];
|
||||
break;
|
||||
case \API_V1_Log::RECORDS_RESSOURCE :
|
||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 4)
|
||||
{
|
||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 4) {
|
||||
if ( ! isset($exploded_route[3]))
|
||||
$aspect = "record";
|
||||
elseif (preg_match("/^set/", $exploded_route[3]))
|
||||
@@ -120,8 +105,7 @@ return call_user_func(function()
|
||||
}
|
||||
break;
|
||||
case \API_V1_Log::BASKETS_RESSOURCE :
|
||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
||||
{
|
||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3) {
|
||||
if (preg_match("/^set/", $exploded_route[2]) || preg_match("/^delete/", $exploded_route[2]))
|
||||
$action = $exploded_route[2];
|
||||
else
|
||||
@@ -139,8 +123,7 @@ return call_user_func(function()
|
||||
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
|
||||
};
|
||||
|
||||
$app->after(function (Request $request, Response $response) use ($app, $parseRoute)
|
||||
{
|
||||
$app->after(function (Request $request, Response $response) use ($app, $parseRoute) {
|
||||
$account = $app['token']->get_account();
|
||||
$pathInfo = $request->getPathInfo();
|
||||
$route = $parseRoute($pathInfo, $response);
|
||||
@@ -160,8 +143,7 @@ return call_user_func(function()
|
||||
/**
|
||||
* Method Not Allowed Closure
|
||||
*/
|
||||
$bad_request_exception = function()
|
||||
{
|
||||
$bad_request_exception = function() {
|
||||
throw new \API_V1_exception_badrequest();
|
||||
};
|
||||
|
||||
@@ -176,8 +158,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/databoxes/list/';
|
||||
$app->get(
|
||||
$route, function() use ($app)
|
||||
{
|
||||
$route, function() use ($app) {
|
||||
return $app['api']->get_databoxes($app['request'])->get_response();
|
||||
}
|
||||
)->middleware($mustBeLogged);
|
||||
@@ -194,8 +175,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/databoxes/{databox_id}/collections/';
|
||||
$app->get(
|
||||
$route, function($databox_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id) use ($app) {
|
||||
$result = $app['api']->get_databox_collections($app['request'], $databox_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -217,8 +197,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/databoxes/{databox_id}/status/';
|
||||
$app->get(
|
||||
$route, function($databox_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id) use ($app) {
|
||||
$result = $app['api']->get_databox_status($app['request'], $databox_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -237,8 +216,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/databoxes/{databox_id}/metadatas/';
|
||||
$app->get(
|
||||
$route, function($databox_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id) use ($app) {
|
||||
$result = $app['api']->get_databox_metadatas($app['request'], $databox_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -257,8 +235,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/databoxes/{databox_id}/termsOfUse/';
|
||||
$app->get(
|
||||
$route, function($databox_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id) use ($app) {
|
||||
$result = $app['api']->get_databox_terms($app['request'], $databox_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -286,8 +263,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/search/';
|
||||
$app->match(
|
||||
$route, function() use ($app)
|
||||
{
|
||||
$route, function() use ($app) {
|
||||
$result = $app['api']->search_records($app['request']);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -297,8 +273,7 @@ return call_user_func(function()
|
||||
|
||||
$route = '/records/{databox_id}/{record_id}/caption/';
|
||||
$app->get(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->caption_records($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -320,8 +295,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/metadatas/';
|
||||
$app->get(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->get_record_metadatas($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -342,8 +316,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/status/';
|
||||
$app->get(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->get_record_status($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -364,8 +337,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/related/';
|
||||
$app->get(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->get_record_related($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -386,8 +358,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/embed/';
|
||||
$app->get(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->get_record_embed($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -408,8 +379,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/setmetadatas/';
|
||||
$app->post(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->set_record_metadatas($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -430,8 +400,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/setstatus/';
|
||||
$app->post(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->set_record_status($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -453,8 +422,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/records/{databox_id}/{record_id}/setcollection/';
|
||||
$app->post(
|
||||
$route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->set_record_collection($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -464,8 +432,7 @@ return call_user_func(function()
|
||||
|
||||
|
||||
$route = '/records/{databox_id}/{record_id}/';
|
||||
$app->get($route, function($databox_id, $record_id) use ($app)
|
||||
{
|
||||
$app->get($route, function($databox_id, $record_id) use ($app) {
|
||||
$result = $app['api']->get_record($app['request'], $databox_id, $record_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -482,8 +449,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/baskets/list/';
|
||||
$app->get(
|
||||
$route, function() use ($app)
|
||||
{
|
||||
$route, function() use ($app) {
|
||||
$result = $app['api']->search_baskets($app['request']);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -501,8 +467,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/baskets/add/';
|
||||
$app->post(
|
||||
$route, function() use ($app)
|
||||
{
|
||||
$route, function() use ($app) {
|
||||
$result = $app['api']->create_basket($app['request']);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -522,8 +487,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/baskets/{basket_id}/content/';
|
||||
$app->get(
|
||||
$route, function($basket_id) use ($app)
|
||||
{
|
||||
$route, function($basket_id) use ($app) {
|
||||
$result = $app['api']->get_basket($app['request'], $basket_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -543,8 +507,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/baskets/{basket_id}/setname/';
|
||||
$app->post(
|
||||
$route, function($basket_id) use ($app)
|
||||
{
|
||||
$route, function($basket_id) use ($app) {
|
||||
$result = $app['api']->set_basket_title($app['request'], $basket_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -564,8 +527,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/baskets/{basket_id}/setdescription/';
|
||||
$app->post(
|
||||
$route, function($basket_id) use ($app)
|
||||
{
|
||||
$route, function($basket_id) use ($app) {
|
||||
$result = $app['api']->set_basket_description($app['request'], $basket_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -584,8 +546,7 @@ return call_user_func(function()
|
||||
*/
|
||||
$route = '/baskets/{basket_id}/delete/';
|
||||
$app->post(
|
||||
$route, function($basket_id) use ($app)
|
||||
{
|
||||
$route, function($basket_id) use ($app) {
|
||||
$result = $app['api']->delete_basket($app['request'], $basket_id);
|
||||
|
||||
return $result->get_response();
|
||||
@@ -607,8 +568,7 @@ return call_user_func(function()
|
||||
|
||||
$route = '/feeds/list/';
|
||||
$app->get(
|
||||
$route, function() use ($app)
|
||||
{
|
||||
$route, function() use ($app) {
|
||||
$result = $app['api']->search_publications($app['request'], $app['Core']->getAuthenticatedUser());
|
||||
|
||||
return $result->get_response();
|
||||
@@ -628,8 +588,7 @@ return call_user_func(function()
|
||||
|
||||
$route = '/feeds/{feed_id}/content/';
|
||||
$app->get(
|
||||
$route, function($feed_id) use ($app)
|
||||
{
|
||||
$route, function($feed_id) use ($app) {
|
||||
$result = $app['api']->get_publication($app['request'], $feed_id, $app['Core']->getAuthenticatedUser());
|
||||
|
||||
return $result->get_response();
|
||||
@@ -643,8 +602,7 @@ return call_user_func(function()
|
||||
* Route Errors
|
||||
*
|
||||
*/
|
||||
$app->error(function (\Exception $e) use ($app)
|
||||
{
|
||||
$app->error(function (\Exception $e) use ($app) {
|
||||
|
||||
if ($e instanceof \API_V1_exception_methodnotallowed)
|
||||
$code = \API_V1_result::ERROR_METHODNOTALLOWED;
|
||||
|
@@ -21,8 +21,7 @@ use Symfony\Component\HttpKernel\Exception;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(function()
|
||||
{
|
||||
return call_user_func(function() {
|
||||
|
||||
$app = new \Silex\Application();
|
||||
|
||||
@@ -31,8 +30,7 @@ return call_user_func(function()
|
||||
$app["appbox"] = \appbox::get_instance($app['Core']);
|
||||
|
||||
$app->get(
|
||||
'/', function() use ($app)
|
||||
{
|
||||
'/', function() use ($app) {
|
||||
$registry = $app["Core"]->getRegistry();
|
||||
|
||||
$apiAdapter = new \API_V1_adapter(false, $app["appbox"], $app["Core"]);
|
||||
|
@@ -24,16 +24,14 @@ use Alchemy\Phrasea\Controller\Exception as ControllerException;
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(
|
||||
function()
|
||||
{
|
||||
function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
|
||||
$app->get('/', function (\Silex\Application $app) use ($appbox)
|
||||
{
|
||||
$app->get('/', function (\Silex\Application $app) use ($appbox) {
|
||||
\User_Adapter::updateClientInfos((6));
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
@@ -54,8 +52,7 @@ return call_user_func(
|
||||
$browser = \Browser::getInstance();
|
||||
|
||||
$template = 'lightbox/index.twig';
|
||||
if ( ! $browser->isNewGeneration() && ! $browser->isMobile())
|
||||
{
|
||||
if ( ! $browser->isNewGeneration() && ! $browser->isMobile()) {
|
||||
$template = 'lightbox/IE6/index.twig';
|
||||
}
|
||||
|
||||
@@ -72,14 +69,12 @@ return call_user_func(
|
||||
}
|
||||
);
|
||||
|
||||
$app->get('/ajax/NOTE_FORM/{sselcont_id}/', function(\Silex\Application $app, $sselcont_id) use ($appbox)
|
||||
{
|
||||
$app->get('/ajax/NOTE_FORM/{sselcont_id}/', function(\Silex\Application $app, $sselcont_id) use ($appbox) {
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
$browser = \Browser::getInstance();
|
||||
|
||||
if ( ! $browser->isMobile())
|
||||
{
|
||||
if ( ! $browser->isMobile()) {
|
||||
return new Response('');
|
||||
}
|
||||
|
||||
@@ -98,8 +93,7 @@ return call_user_func(
|
||||
}
|
||||
)->assert('sselcont_id', '\d+');
|
||||
|
||||
$app->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function(\Silex\Application $app, $sselcont_id)
|
||||
{
|
||||
$app->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function(\Silex\Application $app, $sselcont_id) {
|
||||
$browser = \Browser::getInstance();
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -112,8 +106,7 @@ return call_user_func(
|
||||
|
||||
$BasketElement = $repository->findUserElement($sselcont_id, $app['Core']->getAuthenticatedUser());
|
||||
|
||||
if ($browser->isMobile())
|
||||
{
|
||||
if ($browser->isMobile()) {
|
||||
$output = $twig->render('lightbox/basket_element.twig', array(
|
||||
'basket_element' => $BasketElement,
|
||||
'module_name' => $BasketElement->getRecord()->get_title()
|
||||
@@ -121,9 +114,7 @@ return call_user_func(
|
||||
);
|
||||
|
||||
return new Response($output);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$template_options = 'lightbox/sc_options_box.twig';
|
||||
$template_agreement = 'lightbox/agreement_box.twig';
|
||||
$template_selector = 'lightbox/selector_box.twig';
|
||||
@@ -131,8 +122,7 @@ return call_user_func(
|
||||
$template_preview = 'common/preview.html';
|
||||
$template_caption = 'common/caption.html';
|
||||
|
||||
if ( ! $browser->isNewGeneration())
|
||||
{
|
||||
if ( ! $browser->isNewGeneration()) {
|
||||
$template_options = 'lightbox/IE6/sc_options_box.twig';
|
||||
$template_agreement = 'lightbox/IE6/agreement_box.twig';
|
||||
}
|
||||
@@ -167,8 +157,7 @@ return call_user_func(
|
||||
|
||||
|
||||
|
||||
$app->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(\Silex\Application $app, $entry_id, $item_id)
|
||||
{
|
||||
$app->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function(\Silex\Application $app, $entry_id, $item_id) {
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
@@ -178,8 +167,7 @@ return call_user_func(
|
||||
|
||||
$browser = \Browser::getInstance();
|
||||
|
||||
if ($browser->isMobile())
|
||||
{
|
||||
if ($browser->isMobile()) {
|
||||
$output = $twig->render('lightbox/feed_element.twig', array(
|
||||
'feed_element' => $item,
|
||||
'module_name' => $item->get_record()->get_title()
|
||||
@@ -187,15 +175,12 @@ return call_user_func(
|
||||
);
|
||||
|
||||
return new Response($output);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$template_options = 'lightbox/feed_options_box.twig';
|
||||
$template_preview = 'common/preview.html';
|
||||
$template_caption = 'common/caption.html';
|
||||
|
||||
if ( ! $browser->isNewGeneration())
|
||||
{
|
||||
if ( ! $browser->isNewGeneration()) {
|
||||
$template_options = 'lightbox/IE6/feed_options_box.twig';
|
||||
}
|
||||
$usr_id = $appbox->get_session()->get_usr_id();
|
||||
@@ -222,8 +207,7 @@ return call_user_func(
|
||||
}
|
||||
)->assert('entry_id', '\d+')->assert('item_id', '\d+');
|
||||
|
||||
$app->get('/validate/{ssel_id}/', function (\Silex\Application $app, $ssel_id) use ($appbox)
|
||||
{
|
||||
$app->get('/validate/{ssel_id}/', function (\Silex\Application $app, $ssel_id) use ($appbox) {
|
||||
|
||||
\User_Adapter::updateClientInfos((6));
|
||||
|
||||
@@ -244,15 +228,13 @@ return call_user_func(
|
||||
);
|
||||
|
||||
|
||||
if ($basket->getIsRead() === false)
|
||||
{
|
||||
if ($basket->getIsRead() === false) {
|
||||
$basket = $em->merge($basket);
|
||||
$basket->setIsRead(true);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->getIsAware() === false)
|
||||
{
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->getIsAware() === false) {
|
||||
$basket = $em->merge($basket);
|
||||
$basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->setIsAware(true);
|
||||
$em->flush();
|
||||
@@ -280,8 +262,7 @@ return call_user_func(
|
||||
}
|
||||
)->assert('ssel_id', '\d+');
|
||||
|
||||
$app->get('/compare/{ssel_id}/', function (\Silex\Application $app, $ssel_id) use ($appbox)
|
||||
{
|
||||
$app->get('/compare/{ssel_id}/', function (\Silex\Application $app, $ssel_id) use ($appbox) {
|
||||
|
||||
\User_Adapter::updateClientInfos((6));
|
||||
|
||||
@@ -302,15 +283,13 @@ return call_user_func(
|
||||
);
|
||||
|
||||
|
||||
if ($basket->getIsRead() === false)
|
||||
{
|
||||
if ($basket->getIsRead() === false) {
|
||||
$basket = $em->merge($basket);
|
||||
$basket->setIsRead(true);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->getIsAware() === false)
|
||||
{
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->getIsAware() === false) {
|
||||
$basket = $em->merge($basket);
|
||||
$basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->setIsAware(true);
|
||||
$em->flush();
|
||||
@@ -340,8 +319,7 @@ return call_user_func(
|
||||
|
||||
|
||||
|
||||
$app->get('/feeds/entry/{entry_id}/', function (\Silex\Application $app, $entry_id) use ($appbox)
|
||||
{
|
||||
$app->get('/feeds/entry/{entry_id}/', function (\Silex\Application $app, $entry_id) use ($appbox) {
|
||||
|
||||
\User_Adapter::updateClientInfos((6));
|
||||
|
||||
@@ -372,8 +350,7 @@ return call_user_func(
|
||||
}
|
||||
)->assert('entry_id', '\d+');
|
||||
|
||||
$app->get('/ajax/LOAD_REPORT/{ssel_id}/', function(\Silex\Application $app, $ssel_id)
|
||||
{
|
||||
$app->get('/ajax/LOAD_REPORT/{ssel_id}/', function(\Silex\Application $app, $ssel_id) {
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
@@ -398,15 +375,13 @@ return call_user_func(
|
||||
}
|
||||
)->assert('ssel_id', '\d+');
|
||||
|
||||
$app->post('/ajax/SET_NOTE/{sselcont_id}/', function (\Silex\Application $app, $sselcont_id)
|
||||
{
|
||||
$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'));
|
||||
|
||||
$request = $app['request'];
|
||||
$note = $request->get('note');
|
||||
|
||||
if (is_null($note))
|
||||
{
|
||||
if (is_null($note)) {
|
||||
Return new Response('You must provide a note value', 400);
|
||||
}
|
||||
|
||||
@@ -430,14 +405,11 @@ return call_user_func(
|
||||
|
||||
$browser = \Browser::getInstance();
|
||||
|
||||
if ($browser->isMobile())
|
||||
{
|
||||
if ($browser->isMobile()) {
|
||||
$datas = $twig->render('lightbox/sc_note.twig', array('basket_element' => $basket_element));
|
||||
|
||||
$output = array('error' => false, 'datas' => $datas);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$template = 'lightbox/sc_note.twig';
|
||||
|
||||
$datas = $twig->render($template, array('basket_element' => $basket_element));
|
||||
@@ -455,21 +427,18 @@ return call_user_func(
|
||||
}
|
||||
)->assert('sselcont_id', '\d+');
|
||||
|
||||
$app->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function(\Silex\Application $app, $sselcont_id)
|
||||
{
|
||||
$app->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function(\Silex\Application $app, $sselcont_id) {
|
||||
$request = $app['request'];
|
||||
$agreement = $request->get('agreement');
|
||||
|
||||
if (is_null($agreement))
|
||||
{
|
||||
if (is_null($agreement)) {
|
||||
Return new Response('You must provide an agreement value', 400);
|
||||
}
|
||||
|
||||
$agreement = $agreement > 0;
|
||||
|
||||
$releasable = false;
|
||||
try
|
||||
{
|
||||
try {
|
||||
$ret = array(
|
||||
'error' => true,
|
||||
'releasable' => false,
|
||||
@@ -490,8 +459,7 @@ return call_user_func(
|
||||
|
||||
if ( ! $basket_element->getBasket()
|
||||
->getValidation()
|
||||
->getParticipant($user)->getCanAgree())
|
||||
{
|
||||
->getParticipant($user)->getCanAgree()) {
|
||||
throw new ControllerException('You can not agree on this');
|
||||
}
|
||||
|
||||
@@ -506,8 +474,7 @@ return call_user_func(
|
||||
$em->flush();
|
||||
|
||||
$releasable = false;
|
||||
if ($participant->isReleasable() === true)
|
||||
{
|
||||
if ($participant->isReleasable() === true) {
|
||||
$releasable = _('Do you want to send your report ?');
|
||||
}
|
||||
|
||||
@@ -516,9 +483,7 @@ return call_user_func(
|
||||
, 'datas' => ''
|
||||
, 'releasable' => $releasable
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$ret['datas'] = $e->getMessage();
|
||||
}
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
@@ -532,8 +497,7 @@ return call_user_func(
|
||||
)->assert('sselcont_id', '\d+');
|
||||
|
||||
|
||||
$app->post('/ajax/SET_RELEASE/{ssel_id}/', function(\Silex\Application $app, $ssel_id) use ($appbox)
|
||||
{
|
||||
$app->post('/ajax/SET_RELEASE/{ssel_id}/', function(\Silex\Application $app, $ssel_id) use ($appbox) {
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -543,8 +507,7 @@ return call_user_func(
|
||||
|
||||
$datas = array('error' => true, 'datas' => '');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
/* @var $repository \Repositories\BasketRepository */
|
||||
$basket = $repository->findUserBasket(
|
||||
$ssel_id
|
||||
@@ -552,13 +515,11 @@ return call_user_func(
|
||||
, false
|
||||
);
|
||||
|
||||
if ( ! $basket->getValidation())
|
||||
{
|
||||
if ( ! $basket->getValidation()) {
|
||||
throw new ControllerException('There is no validation session attached to this basket');
|
||||
}
|
||||
|
||||
if ( ! $basket->getValidation()->getParticipant($user)->getCanAgree())
|
||||
{
|
||||
if ( ! $basket->getValidation()->getParticipant($user)->getCanAgree()) {
|
||||
throw new ControllerException('You have not right to agree');
|
||||
}
|
||||
|
||||
@@ -598,9 +559,7 @@ return call_user_func(
|
||||
$em->flush();
|
||||
|
||||
$datas = array('error' => false, 'datas' => _('Envoie avec succes'));
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array('error' => true, 'datas' => $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -620,8 +579,7 @@ return call_user_func(
|
||||
|
||||
|
||||
|
||||
$app->error(function($e) use($app)
|
||||
{
|
||||
$app->error(function($e) use($app) {
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
@@ -629,8 +587,7 @@ return call_user_func(
|
||||
|
||||
$template = 'lightbox/error.twig';
|
||||
|
||||
if ($registry->get('GV_debug'))
|
||||
{
|
||||
if ($registry->get('GV_debug')) {
|
||||
$options = array(
|
||||
'module' => 'validation',
|
||||
'module_name' => _('admin::monitor: module validation'),
|
||||
@@ -641,9 +598,7 @@ return call_user_func(
|
||||
, $e->getLine()
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$options = array(
|
||||
'module' => 'validation',
|
||||
'module_name' => _('admin::monitor: module validation'),
|
||||
|
@@ -28,8 +28,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(function()
|
||||
{
|
||||
return call_user_func(function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
@@ -38,13 +37,11 @@ return call_user_func(function()
|
||||
'validator.class_path' => __DIR__ . '/../../../../vendor/symfony/validator',
|
||||
));
|
||||
|
||||
$app['appbox'] = function() use ($app)
|
||||
{
|
||||
$app['appbox'] = function() use ($app) {
|
||||
return \appbox::get_instance($app['Core']);
|
||||
};
|
||||
|
||||
$app['oauth'] = function($app)
|
||||
{
|
||||
$app['oauth'] = function($app) {
|
||||
return new \API_OAuth2_Adapter($app['appbox']);
|
||||
};
|
||||
|
||||
@@ -53,8 +50,7 @@ return call_user_func(function()
|
||||
* @var Closure
|
||||
* @return Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
$app['response'] = $app->protect(function ($template, $variable) use ($app)
|
||||
{
|
||||
$app['response'] = $app->protect(function ($template, $variable) use ($app) {
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
@@ -80,8 +76,7 @@ return call_user_func(function()
|
||||
* Authorization endpoint - used to obtain authorization from the
|
||||
* resource owner via user-agent redirection.
|
||||
*/
|
||||
$authorize_func = function() use ($app)
|
||||
{
|
||||
$authorize_func = function() use ($app) {
|
||||
$request = $app['request'];
|
||||
$oauth2_adapter = $app['oauth'];
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -112,27 +107,21 @@ return call_user_func(function()
|
||||
);
|
||||
|
||||
|
||||
if (file_exists($custom_template))
|
||||
{
|
||||
if (file_exists($custom_template)) {
|
||||
$template = sprintf(
|
||||
'api/auth/end_user_authorization/%s.twig'
|
||||
, $client->get_id()
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $authenticated)
|
||||
{
|
||||
if ($action_login !== null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! $authenticated) {
|
||||
if ($action_login !== null) {
|
||||
try {
|
||||
$login = $request->get("login");
|
||||
$password = $request->get("password");
|
||||
$auth = new \Session_Authentication_Native($app['appbox'], $login, $password);
|
||||
$session->authenticate($auth);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$params = array(
|
||||
"auth" => $oauth2_adapter
|
||||
, "session" => $session
|
||||
@@ -143,9 +132,7 @@ return call_user_func(function()
|
||||
|
||||
return new Response($html, 200, array("content-type" => "text/html"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$params = array(
|
||||
"auth" => $oauth2_adapter
|
||||
, "session" => $session
|
||||
@@ -164,8 +151,7 @@ return call_user_func(function()
|
||||
, $app['Core']->getAuthenticatedUser()
|
||||
);
|
||||
|
||||
foreach ($user_auth_clients as $auth_client)
|
||||
{
|
||||
foreach ($user_auth_clients as $auth_client) {
|
||||
if ($client->get_client_id() == $auth_client->get_client_id())
|
||||
$app_authorized = true;
|
||||
}
|
||||
@@ -174,8 +160,7 @@ return call_user_func(function()
|
||||
|
||||
$params['account_id'] = $account->get_id();
|
||||
|
||||
if ( ! $app_authorized && $action_accept === null)
|
||||
{
|
||||
if ( ! $app_authorized && $action_accept === null) {
|
||||
$params = array(
|
||||
"auth" => $oauth2_adapter
|
||||
, "session" => $session
|
||||
@@ -186,24 +171,19 @@ return call_user_func(function()
|
||||
$html = $twig->render($template, $params);
|
||||
|
||||
return new Response($html, 200, array("content-type" => "text/html"));
|
||||
}
|
||||
elseif ( ! $app_authorized && $action_accept !== null)
|
||||
{
|
||||
} elseif ( ! $app_authorized && $action_accept !== null) {
|
||||
$app_authorized = ! ! $action_accept;
|
||||
$account->set_revoked( ! $app_authorized);
|
||||
}
|
||||
|
||||
//if native app show template
|
||||
if ($oauth2_adapter->isNativeApp($params['redirect_uri']))
|
||||
{
|
||||
if ($oauth2_adapter->isNativeApp($params['redirect_uri'])) {
|
||||
$params = $oauth2_adapter->finishNativeClientAuthorization($app_authorized, $params);
|
||||
$params['user'] = $app['Core']->getAuthenticatedUser();
|
||||
$html = $twig->render("api/auth/native_app_access_token.twig", $params);
|
||||
|
||||
return new Response($html, 200, array("content-type" => "text/html"));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$oauth2_adapter->finishClientAuthorization($app_authorized, $params);
|
||||
}
|
||||
};
|
||||
@@ -219,11 +199,9 @@ return call_user_func(function()
|
||||
* Token endpoint - used to exchange an authorization grant for an access token.
|
||||
*/
|
||||
$route = '/token';
|
||||
$app->post($route, function(\Silex\Application $app, Request $request)
|
||||
{
|
||||
if(!$request->isSecure())
|
||||
{
|
||||
throw new HttpException(400, 'require the use of the https', null, array('content-type'=> 'application/json'));
|
||||
$app->post($route, function(\Silex\Application $app, Request $request) {
|
||||
if ( ! $request->isSecure()) {
|
||||
throw new HttpException(400, 'require the use of the https', null, array('content-type' => 'application/json'));
|
||||
}
|
||||
|
||||
$app['oauth']->grantAccessToken();
|
||||
@@ -243,8 +221,7 @@ return call_user_func(function()
|
||||
* list of all authorized apps by logged user
|
||||
*/
|
||||
$route = '/applications';
|
||||
$app->get($route, function() use ($app)
|
||||
{
|
||||
$app->get($route, function() use ($app) {
|
||||
$apps = \API_OAuth2_Application::load_app_by_user($app['appbox'], $app['Core']->getAuthenticatedUser());
|
||||
|
||||
return $app['response']('api/auth/applications.twig', array("apps" => $apps, 'user' => $app['Core']->getAuthenticatedUser()));
|
||||
@@ -254,8 +231,7 @@ return call_user_func(function()
|
||||
* list of apps created by user
|
||||
*/
|
||||
$route = "/applications/dev";
|
||||
$app->get($route, function() use ($app)
|
||||
{
|
||||
$app->get($route, function() use ($app) {
|
||||
$rs = \API_OAuth2_Application::load_dev_app_by_user($app['appbox'], $app['Core']->getAuthenticatedUser());
|
||||
|
||||
return $app['response']('api/auth/application_dev.twig', array("apps" => $rs));
|
||||
@@ -265,8 +241,7 @@ return call_user_func(function()
|
||||
* display a new app form
|
||||
*/
|
||||
$route = "/applications/dev/new";
|
||||
$app->get($route, function() use ($app)
|
||||
{
|
||||
$app->get($route, function() use ($app) {
|
||||
$var = array("violations" => null, 'form' => null, 'request' => $app['request']);
|
||||
|
||||
return $app['response']('api/auth/application_dev_new.twig', $var);
|
||||
@@ -275,15 +250,11 @@ return call_user_func(function()
|
||||
|
||||
|
||||
$route = "/applications/dev/create";
|
||||
$app->post($route, function() use ($app)
|
||||
{
|
||||
$app->post($route, function() use ($app) {
|
||||
$submit = false;
|
||||
if ($app['request']->get("type") == "desktop")
|
||||
{
|
||||
if ($app['request']->get("type") == "desktop") {
|
||||
$post = new \API_OAuth2_Form_DevAppDesktop($app['request']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$post = new \API_OAuth2_Form_DevAppInternet($app['request']);
|
||||
}
|
||||
|
||||
@@ -294,8 +265,7 @@ return call_user_func(function()
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
if ($submit) {
|
||||
$application = \API_OAuth2_Application::create($app['appbox'], $app['Core']->getAuthenticatedUser(), $post->getName());
|
||||
$application->set_description($post->getDescription())
|
||||
->set_redirect_uri($post->getSchemeCallback() . $post->getCallback())
|
||||
@@ -318,8 +288,7 @@ return call_user_func(function()
|
||||
* show details of app identified by its id
|
||||
*/
|
||||
$route = "/applications/dev/{id}/show";
|
||||
$app->get($route, function($id) use ($app)
|
||||
{
|
||||
$app->get($route, function($id) use ($app) {
|
||||
$client = new \API_OAuth2_Application($app['appbox'], $id);
|
||||
$token = $client->get_user_account($app['Core']->getAuthenticatedUser())->get_token()->get_value();
|
||||
$var = array("app" => $client, "user" => $app['Core']->getAuthenticatedUser(), "token" => $token);
|
||||
@@ -332,17 +301,13 @@ return call_user_func(function()
|
||||
* identified by account id
|
||||
*/
|
||||
$route = "/applications/revoke_access/";
|
||||
$app->post($route, function() use ($app)
|
||||
{
|
||||
$app->post($route, function() use ($app) {
|
||||
$result = array("ok" => false);
|
||||
try
|
||||
{
|
||||
try {
|
||||
$account = new \API_OAuth2_Account($app['appbox'], $app['request']->get('account_id'));
|
||||
$account->set_revoked((bool) $app['request']->get('revoke'));
|
||||
$result['ok'] = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -356,11 +321,9 @@ return call_user_func(function()
|
||||
});
|
||||
|
||||
$route = "/applications/{id}/generate_access_token/";
|
||||
$app->post($route, function($id) use ($app)
|
||||
{
|
||||
$app->post($route, function($id) use ($app) {
|
||||
$result = array("ok" => false);
|
||||
try
|
||||
{
|
||||
try {
|
||||
$client = new \API_OAuth2_Application($app['appbox'], $id);
|
||||
$account = $client->get_user_account($app['Core']->getAuthenticatedUser());
|
||||
|
||||
@@ -375,9 +338,7 @@ return call_user_func(function()
|
||||
"ok" => true
|
||||
, 'token' => $token->get_value()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -391,19 +352,15 @@ return call_user_func(function()
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$route = "/applications/oauth_callback";
|
||||
$app->post($route, function() use ($app)
|
||||
{
|
||||
$app->post($route, function() use ($app) {
|
||||
$app_id = $app['request']->request->get("app_id");
|
||||
$app_callback = $app["request"]->request->get("callback");
|
||||
$result = array("success" => false);
|
||||
try
|
||||
{
|
||||
try {
|
||||
$client = new \API_OAuth2_Application($app['appbox'], $app_id);
|
||||
$client->set_redirect_uri($app_callback);
|
||||
$result['success'] = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -417,17 +374,13 @@ return call_user_func(function()
|
||||
});
|
||||
|
||||
$route = "/applications/{id}";
|
||||
$app->delete($route, function($id) use ($app)
|
||||
{
|
||||
$app->delete($route, function($id) use ($app) {
|
||||
$result = array("success" => false);
|
||||
try
|
||||
{
|
||||
try {
|
||||
$client = new \API_OAuth2_Application($app['appbox'], $id);
|
||||
$client->delete();
|
||||
$result['success'] = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -445,10 +398,8 @@ return call_user_func(function()
|
||||
* Route Errors
|
||||
*
|
||||
*/
|
||||
$app->error(function (\Exception $e) use ($app)
|
||||
{
|
||||
if ($e instanceof NotFoundHttpException || $e instanceof \Exception_NotFound)
|
||||
{
|
||||
$app->error(function (\Exception $e) use ($app) {
|
||||
if ($e instanceof NotFoundHttpException || $e instanceof \Exception_NotFound) {
|
||||
return new Response('The requested page could not be found.', 404);
|
||||
}
|
||||
|
||||
@@ -456,14 +407,12 @@ return call_user_func(function()
|
||||
$msg = 'We are sorry, but something went wrong';
|
||||
$headers = array();
|
||||
|
||||
if($e instanceof HttpExceptionInterface)
|
||||
{
|
||||
if ($e instanceof HttpExceptionInterface) {
|
||||
$headers = $e->getHeaders();
|
||||
$msg = $e->getMessage();
|
||||
$code = $e->getStatusCode();
|
||||
|
||||
if(isset($headers['content-type']) && $headers['content-type'] == 'application/json')
|
||||
{
|
||||
if (isset($headers['content-type']) && $headers['content-type'] == 'application/json') {
|
||||
$obj = new \stdClass();
|
||||
$obj->msg = $msg;
|
||||
$obj->code = $code;
|
||||
|
@@ -23,8 +23,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(
|
||||
function()
|
||||
{
|
||||
function() {
|
||||
|
||||
$app = new \Silex\Application();
|
||||
|
||||
@@ -33,30 +32,24 @@ return call_user_func(
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$session = $appbox->get_session();
|
||||
|
||||
$deliver_content = function(\Session_Handler $session, \record_adapter $record, $subdef, $watermark, $stamp, $app)
|
||||
{
|
||||
$deliver_content = function(\Session_Handler $session, \record_adapter $record, $subdef, $watermark, $stamp, $app) {
|
||||
|
||||
$file = $record->get_subdef($subdef);
|
||||
if ($file->get_baseurl() !== '')
|
||||
{
|
||||
if ($file->get_baseurl() !== '') {
|
||||
return $app->redirect($file->get_url());
|
||||
}
|
||||
|
||||
$pathIn = $pathOut = $file->get_pathfile();
|
||||
|
||||
if ($watermark === true && $file->get_type() === \media_subdef::TYPE_IMAGE)
|
||||
{
|
||||
if ($watermark === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
|
||||
$pathOut = \recordutils_image::watermark($record->get_base_id(), $record->get_record_id());
|
||||
}
|
||||
elseif ($stamp === true && $file->get_type() === \media_subdef::TYPE_IMAGE)
|
||||
{
|
||||
} elseif ($stamp === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
|
||||
$pathOut = \recordutils_image::stamp($record->get_base_id(), $record->get_record_id());
|
||||
}
|
||||
|
||||
|
||||
$log_id = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
$registry = \registry::get_instance();
|
||||
$logger = $session->get_logger($record->get_databox());
|
||||
$log_id = $logger->get_id();
|
||||
@@ -67,17 +60,14 @@ return call_user_func(
|
||||
$referrer = $_SERVER['HTTP_REFERER'];
|
||||
|
||||
$record->log_view($log_id, $referrer, $registry->get('GV_sit'));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return \set_export::stream_file($pathOut, $file->get_file(), $file->get_mime(), 'attachment');
|
||||
};
|
||||
|
||||
$app->get('/datafiles/{sbas_id}/{record_id}/{subdef}/', function($sbas_id, $record_id, $subdef) use ($app, $session, $deliver_content)
|
||||
{
|
||||
$app->get('/datafiles/{sbas_id}/{record_id}/{subdef}/', function($sbas_id, $record_id, $subdef) use ($app, $session, $deliver_content) {
|
||||
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
$record = new \record_adapter($sbas_id, $record_id);
|
||||
@@ -95,25 +85,20 @@ return call_user_func(
|
||||
$stamp = false;
|
||||
$watermark = ! $user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
|
||||
|
||||
if ($watermark)
|
||||
{
|
||||
if ($watermark) {
|
||||
$subdef_class = $databox
|
||||
->get_subdef_structure()
|
||||
->get_subdef($record->get_type(), $subdef)
|
||||
->get_class();
|
||||
|
||||
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $user->ACL()->has_preview_grant($record))
|
||||
{
|
||||
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $user->ACL()->has_preview_grant($record)) {
|
||||
$watermark = false;
|
||||
}
|
||||
elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record))
|
||||
{
|
||||
} elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record)) {
|
||||
$watermark = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($watermark)
|
||||
{
|
||||
if ($watermark) {
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -124,12 +109,9 @@ return call_user_func(
|
||||
$ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $user);
|
||||
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $user);
|
||||
|
||||
if ($ValidationByRecord && $ValidationByRecord->count() > 0)
|
||||
{
|
||||
if ($ValidationByRecord && $ValidationByRecord->count() > 0) {
|
||||
$watermark = false;
|
||||
}
|
||||
elseif ($ReceptionByRecord && $ReceptionByRecord->count() > 0)
|
||||
{
|
||||
} elseif ($ReceptionByRecord && $ReceptionByRecord->count() > 0) {
|
||||
$watermark = false;
|
||||
}
|
||||
}
|
||||
@@ -139,8 +121,7 @@ return call_user_func(
|
||||
|
||||
|
||||
$app->get('/permalink/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/'
|
||||
, function($label, $sbas_id, $record_id, $key, $subdef) use($app)
|
||||
{
|
||||
, function($label, $sbas_id, $record_id, $key, $subdef) use($app) {
|
||||
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
|
||||
@@ -165,8 +146,7 @@ return call_user_func(
|
||||
|
||||
|
||||
$app->get('/permalink/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/'
|
||||
, function($label, $sbas_id, $record_id, $key, $subdef) use ($app, $session, $deliver_content)
|
||||
{
|
||||
, function($label, $sbas_id, $record_id, $key, $subdef) use ($app, $session, $deliver_content) {
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
$record = \media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef);
|
||||
if ( ! ($record instanceof \record_adapter))
|
||||
@@ -174,36 +154,28 @@ return call_user_func(
|
||||
|
||||
$watermark = $stamp = false;
|
||||
|
||||
if ($session->is_authenticated())
|
||||
{
|
||||
if ($session->is_authenticated()) {
|
||||
$user = \User_Adapter::getInstance($session->get_usr_id(), \appbox::get_instance($app['Core']));
|
||||
|
||||
$watermark = ! $user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
|
||||
|
||||
if ($watermark)
|
||||
{
|
||||
if ($watermark) {
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$repository = $em->getRepository('\Entities\BasketElement');
|
||||
|
||||
if ($repository->findReceivedValidationElementsByRecord($record, $user)->count() > 0)
|
||||
{
|
||||
if ($repository->findReceivedValidationElementsByRecord($record, $user)->count() > 0) {
|
||||
$watermark = false;
|
||||
}
|
||||
elseif ($repository->findReceivedElementsByRecord($record, $user)->count() > 0)
|
||||
{
|
||||
} elseif ($repository->findReceivedElementsByRecord($record, $user)->count() > 0) {
|
||||
$watermark = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $deliver_content($session, $record, $subdef, $watermark, $stamp, $app);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$collection = \collection::get_from_base_id($record->get_base_id());
|
||||
switch ($collection->get_pub_wm())
|
||||
{
|
||||
switch ($collection->get_pub_wm()) {
|
||||
default:
|
||||
case 'none':
|
||||
$watermark = false;
|
||||
@@ -223,25 +195,17 @@ return call_user_func(
|
||||
->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
|
||||
$app->error(function (\Exception $e)
|
||||
{
|
||||
if ($e instanceof \Exception_Session_NotAuthenticated)
|
||||
{
|
||||
$app->error(function (\Exception $e) {
|
||||
if ($e instanceof \Exception_Session_NotAuthenticated) {
|
||||
$code = 403;
|
||||
$message = 'Forbidden';
|
||||
}
|
||||
elseif ($e instanceof \Exception_NotAllowed)
|
||||
{
|
||||
} elseif ($e instanceof \Exception_NotAllowed) {
|
||||
$code = 403;
|
||||
$message = 'Forbidden';
|
||||
}
|
||||
elseif ($e instanceof \Exception_NotFound)
|
||||
{
|
||||
} elseif ($e instanceof \Exception_NotFound) {
|
||||
$code = 404;
|
||||
$message = 'Not Found';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$code = 404;
|
||||
$message = 'Not Found';
|
||||
}
|
||||
|
@@ -21,13 +21,11 @@ use Alchemy\Phrasea\Controller\Prod as Controller;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(function()
|
||||
{
|
||||
return call_user_func(function() {
|
||||
$app = new \Silex\Application();
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
|
||||
$app->before(function(Request $request)
|
||||
{
|
||||
$app->before(function(Request $request) {
|
||||
$request->setRequestFormat(
|
||||
$request->getFormat(
|
||||
array_shift(
|
||||
@@ -56,13 +54,11 @@ return call_user_func(function()
|
||||
$app->mount('/tools/', new Controller\Tools());
|
||||
$app->mount('/', new Controller\Root());
|
||||
|
||||
$app->error(function (\Exception $e, $code) use ($app)
|
||||
{
|
||||
$app->error(function (\Exception $e, $code) use ($app) {
|
||||
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
||||
$request = $app['request'];
|
||||
|
||||
if ($e instanceof \Bridge_Exception)
|
||||
{
|
||||
if ($e instanceof \Bridge_Exception) {
|
||||
|
||||
$params = array(
|
||||
'message' => $e->getMessage()
|
||||
@@ -76,26 +72,19 @@ return call_user_func(function()
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured)
|
||||
{
|
||||
if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) {
|
||||
$params = array_merge($params, array('account' => $app['current_account']));
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/notconfigured.twig', $params), 200);
|
||||
}
|
||||
elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected)
|
||||
{
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) {
|
||||
$params = array_merge($params, array('account' => $app['current_account']));
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/disconnected.twig', $params), 200);
|
||||
}
|
||||
elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed)
|
||||
{
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) {
|
||||
$params = array_merge($params, array('account' => $app['current_account']));
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/disconnected.twig', $params), 200);
|
||||
}
|
||||
elseif ($e instanceof \Bridge_Exception_ApiDisabled)
|
||||
{
|
||||
} elseif ($e instanceof \Bridge_Exception_ApiDisabled) {
|
||||
$params = array_merge($params, array('api' => $e->get_api()));
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200);
|
||||
@@ -103,8 +92,7 @@ return call_user_func(function()
|
||||
|
||||
return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200);
|
||||
}
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
@@ -114,16 +102,13 @@ return call_user_func(function()
|
||||
|
||||
return new Response($json, 200, array('Content-Type' => 'application/json'));
|
||||
}
|
||||
if ($e instanceof \Exception_BadRequest)
|
||||
{
|
||||
if ($e instanceof \Exception_BadRequest) {
|
||||
return new Response('Bad Request', 400);
|
||||
}
|
||||
if ($e instanceof \Exception_NotFound)
|
||||
{
|
||||
if ($e instanceof \Exception_NotFound) {
|
||||
return new Response('Not Found', 404);
|
||||
}
|
||||
if ($e instanceof \Exception_Forbidden)
|
||||
{
|
||||
if ($e instanceof \Exception_Forbidden) {
|
||||
return new Response('Not Found', 403);
|
||||
}
|
||||
});
|
||||
|
@@ -23,46 +23,36 @@ use Alchemy\Phrasea\Controller\Root as Controller;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(function()
|
||||
{
|
||||
return call_user_func(function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
|
||||
if (!\setup::is_installed())
|
||||
{
|
||||
if ( ! \setup::is_installed()) {
|
||||
$response = new \Symfony\Component\HttpFoundation\RedirectResponse('/setup/');
|
||||
|
||||
return $response->send();
|
||||
}
|
||||
|
||||
$app->get('/', function() use ($app)
|
||||
{
|
||||
$app->get('/', function() use ($app) {
|
||||
$browser = \Browser::getInstance();
|
||||
if ($browser->isMobile())
|
||||
|
||||
return $app->redirect("/login/?redirect=/lightbox");
|
||||
elseif ($browser->isNewGeneration())
|
||||
|
||||
return $app->redirect("/login/?redirect=/prod");
|
||||
else
|
||||
|
||||
return $app->redirect("/login/?redirect=/client");
|
||||
});
|
||||
|
||||
$app->get('/robots.txt', function() use ($app)
|
||||
{
|
||||
$app->get('/robots.txt', function() use ($app) {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
if ($registry->get('GV_allow_search_engine') === true)
|
||||
{
|
||||
if ($registry->get('GV_allow_search_engine') === true) {
|
||||
$buffer = "User-Agent: *\n"
|
||||
. "Allow: /\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$buffer = "User-Agent: *\n"
|
||||
. "Disallow: /\n";
|
||||
}
|
||||
|
@@ -22,8 +22,7 @@ use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
return call_user_func(function()
|
||||
{
|
||||
return call_user_func(function() {
|
||||
$app = new \Silex\Application();
|
||||
|
||||
$app['Core'] = \bootstrap::getCore();
|
||||
@@ -31,21 +30,16 @@ return call_user_func(function()
|
||||
$app['install'] = false;
|
||||
$app['upgrade'] = false;
|
||||
|
||||
$app->before(function($a) use ($app)
|
||||
{
|
||||
if (\setup::is_installed())
|
||||
{
|
||||
$app->before(function($a) use ($app) {
|
||||
if (\setup::is_installed()) {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
|
||||
if (!$appbox->need_major_upgrade())
|
||||
{
|
||||
if ( ! $appbox->need_major_upgrade()) {
|
||||
throw new \Exception_Setup_PhraseaAlreadyInstalled();
|
||||
}
|
||||
|
||||
$app['upgrade'] = true;
|
||||
}
|
||||
elseif (\setup::needUpgradeConfigurationFile())
|
||||
{
|
||||
} elseif (\setup::needUpgradeConfigurationFile()) {
|
||||
$connexionInc = new \SplFileObject(__DIR__ . '/../../../../config/connexion.inc');
|
||||
$configInc = new \SplFileObject(__DIR__ . '/../../../../config/config.inc');
|
||||
|
||||
@@ -53,9 +47,7 @@ return call_user_func(function()
|
||||
$configuration->upgradeFromOldConf($configInc, $connexionInc);
|
||||
|
||||
$app['install'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$app['install'] = true;
|
||||
}
|
||||
|
||||
@@ -63,13 +55,10 @@ return call_user_func(function()
|
||||
});
|
||||
|
||||
|
||||
$app->get('/', function() use ($app)
|
||||
{
|
||||
$app->get('/', function() use ($app) {
|
||||
if ($app['install'] === true)
|
||||
|
||||
return $app->redirect('/setup/installer/');
|
||||
if ($app['upgrade'] === true)
|
||||
|
||||
return $app->redirect('/setup/upgrader/');
|
||||
});
|
||||
|
||||
@@ -79,10 +68,8 @@ return call_user_func(function()
|
||||
$app->mount('/test', new ControllerUtils\PathFileTest());
|
||||
$app->mount('/connection_test', new ControllerUtils\ConnectionTest());
|
||||
|
||||
$app->error(function($e) use ($app)
|
||||
{
|
||||
if ($e instanceof \Exception_Setup_PhraseaAlreadyInstalled)
|
||||
{
|
||||
$app->error(function($e) use ($app) {
|
||||
if ($e instanceof \Exception_Setup_PhraseaAlreadyInstalled) {
|
||||
return $app->redirect('/login/');
|
||||
}
|
||||
|
||||
|
@@ -29,8 +29,7 @@ class ApcCache extends DoctrineApc implements Cache
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if (!$this->contains($key))
|
||||
{
|
||||
if ( ! $this->contains($key)) {
|
||||
throw new Exception('Unable to retrieve the value');
|
||||
}
|
||||
|
||||
@@ -39,12 +38,10 @@ class ApcCache extends DoctrineApc implements Cache
|
||||
|
||||
public function deleteMulti(array $array_keys)
|
||||
{
|
||||
foreach ($array_keys as $id)
|
||||
{
|
||||
foreach ($array_keys as $id) {
|
||||
$this->delete($id);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -30,8 +30,7 @@ class ArrayCache extends DoctrineArray implements Cache
|
||||
|
||||
public function get($id)
|
||||
{
|
||||
if (!$this->contains($id))
|
||||
{
|
||||
if ( ! $this->contains($id)) {
|
||||
throw new Exception(sprintf('Unable to find key %s', $id));
|
||||
}
|
||||
|
||||
@@ -40,12 +39,10 @@ class ArrayCache extends DoctrineArray implements Cache
|
||||
|
||||
public function deleteMulti(array $array_keys)
|
||||
{
|
||||
foreach ($array_keys as $id)
|
||||
{
|
||||
foreach ($array_keys as $id) {
|
||||
$this->delete($id);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,5 +27,4 @@ interface Cache extends DoctrineCache
|
||||
public function get($key);
|
||||
|
||||
public function deleteMulti(array $array_keys);
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ use \Alchemy\Phrasea\Core\Service\Builder,
|
||||
*/
|
||||
class Manager
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \SplFileObject
|
||||
@@ -58,8 +57,7 @@ class Manager
|
||||
|
||||
public function flushAll()
|
||||
{
|
||||
foreach ($this->registry as $cacheKey => $service_name)
|
||||
{
|
||||
foreach ($this->registry as $cacheKey => $service_name) {
|
||||
$this->get($cacheKey, $service_name)->getDriver()->flushAll();
|
||||
}
|
||||
|
||||
@@ -70,15 +68,12 @@ class Manager
|
||||
|
||||
public function get($cacheKey, $service_name)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
$configuration = $this->core->getConfiguration()->getService($service_name);
|
||||
$service = Builder::create($this->core, $configuration);
|
||||
$driver = $service->getDriver();
|
||||
$write = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array('type' => 'Cache\\ArrayCache')
|
||||
);
|
||||
@@ -87,11 +82,9 @@ class Manager
|
||||
$write = false;
|
||||
}
|
||||
|
||||
if ($this->hasChange($cacheKey, $service_name))
|
||||
{
|
||||
if ($this->hasChange($cacheKey, $service_name)) {
|
||||
$service->getDriver()->flushAll();
|
||||
if ($write)
|
||||
{
|
||||
if ($write) {
|
||||
$this->registry[$cacheKey] = $service_name;
|
||||
$this->save($cacheKey, $service_name);
|
||||
}
|
||||
@@ -116,6 +109,5 @@ class Manager
|
||||
|
||||
file_put_contents($this->cacheFile->getPathname(), $datas);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -29,8 +29,7 @@ class MemcacheCache extends DoctrineMemcache implements Cache
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if (!$this->contains($key))
|
||||
{
|
||||
if ( ! $this->contains($key)) {
|
||||
throw new Exception('Unable to retrieve the value');
|
||||
}
|
||||
|
||||
@@ -39,12 +38,10 @@ class MemcacheCache extends DoctrineMemcache implements Cache
|
||||
|
||||
public function deleteMulti(array $array_keys)
|
||||
{
|
||||
foreach ($array_keys as $id)
|
||||
{
|
||||
foreach ($array_keys as $id) {
|
||||
$this->delete($id);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ use Doctrine\Common\Cache\CacheProvider;
|
||||
*/
|
||||
class RedisCache extends CacheProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Redis
|
||||
*/
|
||||
@@ -68,12 +67,9 @@ class RedisCache extends CacheProvider
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if (0 === $lifeTime)
|
||||
{
|
||||
if (0 === $lifeTime) {
|
||||
return $this->_redis->set($id, $data);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return $this->_redis->setex($id, $lifeTime, $data);
|
||||
}
|
||||
}
|
||||
@@ -109,8 +105,7 @@ class RedisCache extends CacheProvider
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if (!$this->contains($key))
|
||||
{
|
||||
if ( ! $this->contains($key)) {
|
||||
throw new Exception('Unable to retrieve the value');
|
||||
}
|
||||
|
||||
@@ -119,12 +114,10 @@ class RedisCache extends CacheProvider
|
||||
|
||||
public function deleteMulti(array $array_keys)
|
||||
{
|
||||
foreach ($array_keys as $id)
|
||||
{
|
||||
foreach ($array_keys as $id) {
|
||||
$this->delete($id);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,8 +29,7 @@ class XcacheCache extends DoctrineXcache implements Cache
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if (!$this->contains($key))
|
||||
{
|
||||
if ( ! $this->contains($key)) {
|
||||
throw new Exception('Unable to retrieve the value');
|
||||
}
|
||||
|
||||
@@ -39,12 +38,10 @@ class XcacheCache extends DoctrineXcache implements Cache
|
||||
|
||||
public function deleteMulti(array $array_keys)
|
||||
{
|
||||
foreach ($array_keys as $id)
|
||||
{
|
||||
foreach ($array_keys as $id) {
|
||||
$this->delete($id);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,15 +35,13 @@ class Description implements ControllerProviderInterface
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
|
||||
$controllers->post('/{sbas_id}/', function(Application $app, $sbas_id)
|
||||
{
|
||||
$controllers->post('/{sbas_id}/', function(Application $app, $sbas_id) {
|
||||
$Core = $app['Core'];
|
||||
$user = $Core->getAuthenticatedUser();
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
if (!$user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
|
||||
{
|
||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||
throw new \Exception_Forbidden('You are not allowed to access this zone');
|
||||
}
|
||||
|
||||
@@ -55,14 +53,10 @@ class Description implements ControllerProviderInterface
|
||||
|
||||
$databox->get_connection()->beginTransaction();
|
||||
$error = false;
|
||||
try
|
||||
{
|
||||
if (is_array($request->get('field_ids')))
|
||||
{
|
||||
foreach ($request->get('field_ids') as $id)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (is_array($request->get('field_ids'))) {
|
||||
foreach ($request->get('field_ids') as $id) {
|
||||
try {
|
||||
$field = \databox_field::get_instance($databox, $id);
|
||||
$field->set_name($request->get('name_' . $id));
|
||||
$field->set_thumbtitle($request->get('thumbtitle_' . $id));
|
||||
@@ -80,14 +74,11 @@ class Description implements ControllerProviderInterface
|
||||
$field->setVocabularyControl(null);
|
||||
$field->setVocabularyRestricted(false);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$vocabulary = \Alchemy\Phrasea\Vocabulary\Controller::get($request->get('vocabulary_' . $id));
|
||||
$field->setVocabularyControl($vocabulary);
|
||||
$field->setVocabularyRestricted($request->get('vocabularyrestricted_' . $id));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -99,38 +90,27 @@ class Description implements ControllerProviderInterface
|
||||
|
||||
$field->set_dces_element($dces_element);
|
||||
$field->save();
|
||||
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->get('newfield'))
|
||||
{
|
||||
if ($request->get('newfield')) {
|
||||
$field = \databox_field::create($databox, $request->get('newfield'));
|
||||
}
|
||||
|
||||
if (is_array($request->get('todelete_ids')))
|
||||
{
|
||||
foreach ($request->get('todelete_ids') as $id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (is_array($request->get('todelete_ids'))) {
|
||||
foreach ($request->get('todelete_ids') as $id) {
|
||||
try {
|
||||
$field = \databox_field::get_instance($databox, $id);
|
||||
$field->delete();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -142,16 +122,14 @@ class Description implements ControllerProviderInterface
|
||||
return new RedirectResponse('/admin/description/' . $sbas_id . '/');
|
||||
})->assert('sbas_id', '\d+');
|
||||
|
||||
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id)
|
||||
{
|
||||
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id) {
|
||||
|
||||
$Core = $app['Core'];
|
||||
$user = $Core->getAuthenticatedUser();
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
if (!$user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
|
||||
{
|
||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||
throw new \Exception_Forbidden('You are not allowed to access this zone');
|
||||
}
|
||||
|
||||
@@ -174,5 +152,4 @@ class Description implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -34,8 +34,7 @@ class Fields implements ControllerProviderInterface
|
||||
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/checkmulti/', function() use ($app, $appbox)
|
||||
{
|
||||
$controllers->get('/checkmulti/', function() use ($app, $appbox) {
|
||||
$request = $app['request'];
|
||||
|
||||
$multi = ($request->get('multi') === 'true');
|
||||
@@ -56,8 +55,7 @@ class Fields implements ControllerProviderInterface
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->get('/checkreadonly/', function() use ($app, $appbox)
|
||||
{
|
||||
$controllers->get('/checkreadonly/', function() use ($app, $appbox) {
|
||||
$request = $app['request'];
|
||||
$readonly = ($request->get('readonly') === 'true');
|
||||
|
||||
@@ -79,5 +77,4 @@ class Fields implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,8 +35,7 @@ class Publications implements ControllerProviderInterface
|
||||
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/list/', function() use ($app, $appbox)
|
||||
{
|
||||
$controllers->get('/list/', function() use ($app, $appbox) {
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
|
||||
@@ -48,8 +47,7 @@ class Publications implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
|
||||
$controllers->post('/create/', function() use ($app, $appbox)
|
||||
{
|
||||
$controllers->post('/create/', function() use ($app, $appbox) {
|
||||
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
$request = $app['request'];
|
||||
@@ -65,8 +63,7 @@ class Publications implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox)
|
||||
{
|
||||
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox) {
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -81,24 +78,19 @@ class Publications implements ControllerProviderInterface
|
||||
})->assert('id', '\d+');
|
||||
|
||||
|
||||
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox)
|
||||
{
|
||||
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox) {
|
||||
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
|
||||
if (!$feed->is_owner($user))
|
||||
|
||||
if ( ! $feed->is_owner($user))
|
||||
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$collection = \collection::get_from_base_id($request->get('base_id'));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$collection = null;
|
||||
}
|
||||
|
||||
@@ -111,13 +103,11 @@ class Publications implements ControllerProviderInterface
|
||||
})->assert('id', '\d+');
|
||||
|
||||
|
||||
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox)
|
||||
{
|
||||
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox) {
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
|
||||
if (!$feed->is_owner($user))
|
||||
|
||||
if ( ! $feed->is_owner($user))
|
||||
return new Response('ERROR:you are not allowed');
|
||||
|
||||
$request = $app["request"];
|
||||
@@ -125,25 +115,20 @@ class Publications implements ControllerProviderInterface
|
||||
$fileData = $request->files->get("Filedata");
|
||||
|
||||
if ($fileData['error'] !== 0)
|
||||
|
||||
return new Response('ERROR:error while upload');
|
||||
|
||||
$file = new \system_file($fileData['tmp_name']);
|
||||
if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
|
||||
|
||||
if ( ! in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
|
||||
return new Response('ERROR:bad filetype');
|
||||
|
||||
if ($file->getSize() > 200000)
|
||||
|
||||
return new Response('ERROR:file too large');
|
||||
|
||||
$datas = $file->get_technical_datas();
|
||||
if (!isset($datas[\system_file::TC_DATAS_WIDTH]) || !isset($datas[\system_file::TC_DATAS_HEIGHT]))
|
||||
|
||||
if ( ! isset($datas[\system_file::TC_DATAS_WIDTH]) || ! isset($datas[\system_file::TC_DATAS_HEIGHT]))
|
||||
return new Response('ERROR:file is not square');
|
||||
|
||||
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT])
|
||||
|
||||
return new Response('ERROR:file is not square');
|
||||
|
||||
$feed->set_icon($file);
|
||||
@@ -152,18 +137,14 @@ class Publications implements ControllerProviderInterface
|
||||
return new Response('FILEHREF:' . $feed->get_icon_url() . '?' . mt_rand(100000, 999999));
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/feed/{id}/addpublisher/', function($id) use ($app, $appbox)
|
||||
{
|
||||
$controllers->post('/feed/{id}/addpublisher/', function($id) use ($app, $appbox) {
|
||||
$error = '';
|
||||
try
|
||||
{
|
||||
try {
|
||||
$request = $app['request'];
|
||||
$user = \User_Adapter::getInstance($request->get('usr_id'), $appbox);
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
$feed->add_publisher($user);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -171,10 +152,8 @@ class Publications implements ControllerProviderInterface
|
||||
})->assert('id', '\d+');
|
||||
|
||||
|
||||
$controllers->post('/feed/{id}/removepublisher/', function($id) use ($app, $appbox)
|
||||
{
|
||||
try
|
||||
{
|
||||
$controllers->post('/feed/{id}/removepublisher/', function($id) use ($app, $appbox) {
|
||||
try {
|
||||
$request = $app['request'];
|
||||
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
@@ -182,17 +161,14 @@ class Publications implements ControllerProviderInterface
|
||||
$user = $publisher->get_user();
|
||||
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
|
||||
$publisher->delete();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
|
||||
return $app->redirect('/admin/publications/feed/' . $id . '/?err=' . $error);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox)
|
||||
{
|
||||
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox) {
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
$feed->delete();
|
||||
|
||||
@@ -201,5 +177,4 @@ class Publications implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -38,8 +38,7 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
|
||||
$Core = $app['Core'];
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
@@ -63,10 +62,8 @@ class Root implements ControllerProviderInterface
|
||||
$feature = 'connected';
|
||||
$featured = false;
|
||||
$position = explode(':', $section);
|
||||
if (count($position) > 0)
|
||||
{
|
||||
if (in_array($position[0], $available))
|
||||
{
|
||||
if (count($position) > 0) {
|
||||
if (in_array($position[0], $available)) {
|
||||
$feature = $position[0];
|
||||
if (isset($position[1]))
|
||||
$featured = $position[1];
|
||||
@@ -74,17 +71,13 @@ class Root implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
$databoxes = $off_databoxes = array();
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!$user->ACL()->has_access_to_sbas($databox->get_sbas_id()))
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
try {
|
||||
if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id()))
|
||||
continue;
|
||||
|
||||
$connbas = $databox->get_connection();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$off_databoxes[] = $databox;
|
||||
continue;
|
||||
}
|
||||
@@ -110,5 +103,4 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -34,8 +34,7 @@ class Subdefs implements ControllerProviderInterface
|
||||
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id)
|
||||
{
|
||||
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id) {
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
|
||||
return new response($app['Core']->getTwig()->render(
|
||||
@@ -47,8 +46,7 @@ class Subdefs implements ControllerProviderInterface
|
||||
);
|
||||
})->assert('sbas_id', '\d+');
|
||||
|
||||
$controllers->post('/{sbas_id}/', function(Application $app, Request $request, $sbas_id)
|
||||
{
|
||||
$controllers->post('/{sbas_id}/', function(Application $app, Request $request, $sbas_id) {
|
||||
$delete_subdef = $request->get('delete_subdef');
|
||||
$toadd_subdef = $request->get('add_subdef');
|
||||
$Parmsubdefs = $request->get('subdefs', array());
|
||||
@@ -56,24 +54,20 @@ class Subdefs implements ControllerProviderInterface
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
|
||||
$add_subdef = array('class' => null, 'name' => null, 'group' => null);
|
||||
foreach ($add_subdef as $k => $v)
|
||||
{
|
||||
if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '')
|
||||
foreach ($add_subdef as $k => $v) {
|
||||
if ( ! isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '')
|
||||
unset($add_subdef[$k]);
|
||||
else
|
||||
$add_subdef[$k] = $toadd_subdef[$k];
|
||||
}
|
||||
|
||||
if ($delete_subdef)
|
||||
{
|
||||
if ($delete_subdef) {
|
||||
$delete_subef = explode('_', $delete_subdef);
|
||||
$group = $delete_subef[0];
|
||||
$name = $delete_subef[1];
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$subdefs->delete_subdef($group, $name);
|
||||
}
|
||||
elseif (count($add_subdef) === 3)
|
||||
{
|
||||
} elseif (count($add_subdef) === 3) {
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$UnicodeProcessor = new \unicode();
|
||||
|
||||
@@ -82,15 +76,12 @@ class Subdefs implements ControllerProviderInterface
|
||||
$class = $add_subdef['class'];
|
||||
|
||||
$subdefs->add_subdef($group, $name, $class);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($Parmsubdefs as $post_sub)
|
||||
{
|
||||
foreach ($Parmsubdefs as $post_sub) {
|
||||
$post_sub_ex = explode('_', $post_sub);
|
||||
|
||||
$group = $post_sub_ex[0];
|
||||
@@ -101,12 +92,10 @@ class Subdefs implements ControllerProviderInterface
|
||||
|
||||
$defaults = array('path', 'baseurl', 'meta', 'mediatype');
|
||||
|
||||
foreach ($defaults as $def)
|
||||
{
|
||||
foreach ($defaults as $def) {
|
||||
$parm_loc = $request->get($post_sub . '_' . $def);
|
||||
|
||||
if ($def == 'meta' && !$parm_loc)
|
||||
{
|
||||
if ($def == 'meta' && ! $parm_loc) {
|
||||
$parm_loc = "no";
|
||||
}
|
||||
|
||||
@@ -116,10 +105,8 @@ class Subdefs implements ControllerProviderInterface
|
||||
$mediatype = $request->get($post_sub . '_mediatype');
|
||||
$media = $request->get($post_sub . '_' . $mediatype, array());
|
||||
|
||||
foreach ($media as $option => $value)
|
||||
{
|
||||
if ($option == 'resolution' && $mediatype == 'image')
|
||||
{
|
||||
foreach ($media as $option => $value) {
|
||||
if ($option == 'resolution' && $mediatype == 'image') {
|
||||
$option = 'dpi';
|
||||
}
|
||||
$options[$option] = $value;
|
||||
@@ -133,5 +120,4 @@ class Subdefs implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,8 +37,7 @@ class Users implements ControllerProviderInterface
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
|
||||
$controllers->post('/rights/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
|
||||
$template = 'admin/editusers.twig';
|
||||
@@ -49,8 +48,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->get('/rights/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/rights/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
|
||||
$template = 'admin/editusers.twig';
|
||||
@@ -61,18 +59,14 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/reset/', function(Application $app, Request $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
$controllers->post('/rights/reset/', function(Application $app, Request $request) {
|
||||
try {
|
||||
$core = $app['Core'];
|
||||
$datas = array('error' => false);
|
||||
|
||||
$helper = new UserHelper\Edit($core, $request);
|
||||
$helper->resetRights();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$datas['error'] = true;
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
@@ -85,8 +79,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/delete/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/delete/', function(Application $app) {
|
||||
$module = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
$module->delete_users();
|
||||
|
||||
@@ -94,26 +87,21 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/apply/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/apply/', function(Application $app) {
|
||||
$datas = array('error' => true);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
$rights->apply_rights();
|
||||
|
||||
if ($app['request']->get('template'))
|
||||
{
|
||||
if ($app['request']->get('template')) {
|
||||
$rights->apply_template();
|
||||
}
|
||||
|
||||
$rights->apply_infos();
|
||||
|
||||
$datas = array('error' => false);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -127,8 +115,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/quotas/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/quotas/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
|
||||
$template = 'admin/editusers_quotas.twig';
|
||||
@@ -139,8 +126,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/quotas/apply/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/quotas/apply/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
$rights->apply_quotas();
|
||||
|
||||
@@ -148,8 +134,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/time/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/time/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
|
||||
$template = 'admin/editusers_timelimit.twig';
|
||||
@@ -160,8 +145,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/time/apply/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/time/apply/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
$rights->apply_time();
|
||||
|
||||
@@ -169,8 +153,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/masks/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/masks/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
|
||||
$template = 'admin/editusers_masks.twig';
|
||||
@@ -181,8 +164,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/rights/masks/apply/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/rights/masks/apply/', function(Application $app) {
|
||||
$rights = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
$rights->apply_masks();
|
||||
|
||||
@@ -190,8 +172,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->match('/search/', function(Application $app)
|
||||
{
|
||||
$controllers->match('/search/', function(Application $app) {
|
||||
$users = new UserHelper\Manage($app['Core'], $app['request']);
|
||||
$template = 'admin/users.html';
|
||||
|
||||
@@ -202,8 +183,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/search/export/', function() use ($app)
|
||||
{
|
||||
$controllers->post('/search/export/', function() use ($app) {
|
||||
$request = $app['request'];
|
||||
|
||||
$users = new UserHelper\Manage($app['Core'], $app['request']);
|
||||
@@ -234,8 +214,7 @@ class Users implements ControllerProviderInterface
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($users->export() as $user)
|
||||
{
|
||||
foreach ($users->export() as $user) {
|
||||
/* @var $user \User_Adapter */
|
||||
$userTable[] = array(
|
||||
$user->get_id(),
|
||||
@@ -267,8 +246,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/apply_template/', function() use ($app)
|
||||
{
|
||||
$controllers->post('/apply_template/', function() use ($app) {
|
||||
$users = new UserHelper\Edit($app['Core'], $app['request']);
|
||||
|
||||
$users->apply_template();
|
||||
@@ -277,8 +255,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->get('/typeahead/search/', function(Application $app) use ($appbox)
|
||||
{
|
||||
$controllers->get('/typeahead/search/', function(Application $app) use ($appbox) {
|
||||
$request = $app['request'];
|
||||
|
||||
$user_query = new \User_Query($appbox);
|
||||
@@ -307,8 +284,7 @@ class Users implements ControllerProviderInterface
|
||||
|
||||
$datas = array();
|
||||
|
||||
foreach ($elligible_users as $user)
|
||||
{
|
||||
foreach ($elligible_users as $user) {
|
||||
$datas[] = array(
|
||||
'email' => $user->get_email() ? : ''
|
||||
, 'login' => $user->get_login() ? : ''
|
||||
@@ -327,29 +303,22 @@ class Users implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
|
||||
$controllers->post('/create/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/create/', function(Application $app) {
|
||||
|
||||
$datas = array('error' => false, 'message' => '', 'data' => null);
|
||||
try
|
||||
{
|
||||
try {
|
||||
$request = $app['request'];
|
||||
$module = new UserHelper\Manage($app['Core'], $app['request']);
|
||||
if ($request->get('template') == '1')
|
||||
{
|
||||
if ($request->get('template') == '1') {
|
||||
$user = $module->create_template();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$user = $module->create_newuser();
|
||||
}
|
||||
if (!($user instanceof \User_Adapter))
|
||||
if ( ! ($user instanceof \User_Adapter))
|
||||
throw new \Exception('Unknown error');
|
||||
|
||||
$datas['data'] = $user->get_id();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$datas['error'] = true;
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
@@ -360,8 +329,7 @@ class Users implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/export/csv/', function(Application $app) use ($appbox)
|
||||
{
|
||||
$controllers->post('/export/csv/', function(Application $app) use ($appbox) {
|
||||
$request = $app['request'];
|
||||
$user_query = new \User_Query($appbox, $app['Core']);
|
||||
|
||||
@@ -398,15 +366,13 @@ class Users implements ControllerProviderInterface
|
||||
, _('admin::compte-utilisateur societe')
|
||||
, _('admin::compte-utilisateur activite')
|
||||
);
|
||||
do
|
||||
{
|
||||
do {
|
||||
$elligible_users->limit($offset, 20);
|
||||
$offset += 20;
|
||||
|
||||
$results = $elligible_users->execute()->get_results();
|
||||
|
||||
foreach ($results as $user)
|
||||
{
|
||||
foreach ($results as $user) {
|
||||
$buffer[] = array(
|
||||
$user->get_id()
|
||||
, $user->get_login()
|
||||
@@ -426,8 +392,7 @@ class Users implements ControllerProviderInterface
|
||||
, $user->get_position()
|
||||
);
|
||||
}
|
||||
}
|
||||
while (count($results) > 0);
|
||||
} while (count($results) > 0);
|
||||
|
||||
$out = \format::arr_to_csv($buffer);
|
||||
|
||||
@@ -444,6 +409,5 @@ class Users implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,9 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Controller;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
|
@@ -45,8 +45,7 @@ class Basket implements ControllerProviderInterface
|
||||
* @accept JSON / YAML
|
||||
*
|
||||
*/
|
||||
$controllers->post('/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
|
||||
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
||||
@@ -65,8 +64,7 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||
{
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2)
|
||||
@@ -74,10 +72,9 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record))
|
||||
{
|
||||
if ( ! $user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& ! $user->ACL()->has_hd_grant($record)
|
||||
&& ! $user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -92,13 +89,12 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$Basket->addBasketElement($basket_element);
|
||||
|
||||
$n++;
|
||||
$n ++;
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => _('Basket created')
|
||||
@@ -110,9 +106,7 @@ class Basket implements ControllerProviderInterface
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse(sprintf('/%d/', $Basket->getId()));
|
||||
}
|
||||
});
|
||||
@@ -123,8 +117,7 @@ class Basket implements ControllerProviderInterface
|
||||
* @accept JSON / HTML
|
||||
*
|
||||
*/
|
||||
$controllers->post('/{basket_id}/delete/', function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
$controllers->post('/{basket_id}/delete/', function(Application $app, Request $request, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
@@ -138,15 +131,12 @@ class Basket implements ControllerProviderInterface
|
||||
, 'message' => _('Basket has been deleted')
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('basket_id', '\d+');
|
||||
@@ -156,19 +146,16 @@ class Basket implements ControllerProviderInterface
|
||||
*/
|
||||
$controllers->post(
|
||||
'/{basket_id}/delete/{basket_element_id}/'
|
||||
, function(Application $app, Request $request, $basket_id, $basket_element_id)
|
||||
{
|
||||
, function(Application $app, Request $request, $basket_id, $basket_element_id) {
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
->findUserBasket($basket_id, $app['Core']->getAuthenticatedUser(), true);
|
||||
|
||||
foreach ($basket->getElements() as $basket_element)
|
||||
{
|
||||
foreach ($basket->getElements() as $basket_element) {
|
||||
/* @var $basket_element \Entities\BasketElement */
|
||||
if ($basket_element->getId() == $basket_element_id)
|
||||
{
|
||||
if ($basket_element->getId() == $basket_element_id) {
|
||||
$em->remove($basket_element);
|
||||
}
|
||||
}
|
||||
@@ -180,14 +167,11 @@ class Basket implements ControllerProviderInterface
|
||||
, 'message' => _('Record removed from basket')
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('basket_id', '\d+')->assert('basket_element_id', '\d+');
|
||||
@@ -199,8 +183,7 @@ class Basket implements ControllerProviderInterface
|
||||
* @param description string optionnal
|
||||
*
|
||||
*/
|
||||
$controllers->post('/{basket_id}/update/', function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
$controllers->post('/{basket_id}/update/', function(Application $app, Request $request, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
@@ -218,15 +201,12 @@ class Basket implements ControllerProviderInterface
|
||||
, 'basket' => array('id' => $basket->getId())
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('basket_id', '\d+');
|
||||
@@ -234,8 +214,7 @@ class Basket implements ControllerProviderInterface
|
||||
/**
|
||||
* Get the form to update the Basket attributes (name and description)
|
||||
*/
|
||||
$controllers->get('/{basket_id}/update/', function(Application $app, $basket_id)
|
||||
{
|
||||
$controllers->get('/{basket_id}/update/', function(Application $app, $basket_id) {
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -259,8 +238,7 @@ class Basket implements ControllerProviderInterface
|
||||
*/
|
||||
$controllers->get(
|
||||
'/{basket_id}/reorder/'
|
||||
, function(Application $app, $basket_id)
|
||||
{
|
||||
, function(Application $app, $basket_id) {
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -281,11 +259,9 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$controllers->post(
|
||||
'/{basket_id}/reorder/'
|
||||
, function(Application $app, $basket_id)
|
||||
{
|
||||
, function(Application $app, $basket_id) {
|
||||
$ret = array('success' => false, 'message' => _('An error occured'));
|
||||
try
|
||||
{
|
||||
try {
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -297,10 +273,8 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
|
||||
/* @var $basket \Entities\Basket */
|
||||
foreach ($basket->getElements() as $basketElement)
|
||||
{
|
||||
if (isset($order[$basketElement->getId()]))
|
||||
{
|
||||
foreach ($basket->getElements() as $basketElement) {
|
||||
if (isset($order[$basketElement->getId()])) {
|
||||
$basketElement->setOrd($order[$basketElement->getId()]);
|
||||
|
||||
$em->merge($basketElement);
|
||||
@@ -309,9 +283,7 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$em->flush();
|
||||
$ret = array('success' => true, 'message' => _('Basket updated'));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
@@ -327,26 +299,22 @@ class Basket implements ControllerProviderInterface
|
||||
*
|
||||
* @returns JSON / HTML
|
||||
*/
|
||||
$controllers->post('/{basket_id}/archive/', function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
$controllers->post('/{basket_id}/archive/', function(Application $app, Request $request, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
->findUserBasket($basket_id, $app['Core']->getAuthenticatedUser(), true);
|
||||
|
||||
$archive_status = !!$request->get('archive');
|
||||
$archive_status = ! ! $request->get('archive');
|
||||
|
||||
$basket->setArchived($archive_status);
|
||||
|
||||
$em->merge($basket);
|
||||
$em->flush();
|
||||
|
||||
if ($archive_status)
|
||||
{
|
||||
if ($archive_status) {
|
||||
$message = _('Basket has been archived');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = _('Basket has been unarchived');
|
||||
}
|
||||
|
||||
@@ -356,15 +324,12 @@ class Basket implements ControllerProviderInterface
|
||||
, 'message' => $message
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('basket_id', '\d+');
|
||||
@@ -374,8 +339,7 @@ class Basket implements ControllerProviderInterface
|
||||
*/
|
||||
$controllers->post(
|
||||
'/{basket_id}/addElements/'
|
||||
, function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
, function(Application $app, Request $request, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
@@ -386,8 +350,7 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||
{
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2)
|
||||
@@ -395,10 +358,9 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record))
|
||||
{
|
||||
if ( ! $user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& ! $user->ACL()->has_hd_grant($record)
|
||||
&& ! $user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -413,13 +375,11 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$basket->addBasketElement($basket_element);
|
||||
|
||||
if(null !== $validationSession = $basket->getValidation())
|
||||
{
|
||||
if (null !== $validationSession = $basket->getValidation()) {
|
||||
|
||||
$participants = $validationSession->getParticipants();
|
||||
|
||||
foreach($participants as $participant)
|
||||
{
|
||||
foreach ($participants as $participant) {
|
||||
$validationData = new \Entities\ValidationData();
|
||||
$validationData->setParticipant($participant);
|
||||
$validationData->setBasketElement($basket_element);
|
||||
@@ -428,7 +388,7 @@ class Basket implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
$n++;
|
||||
$n ++;
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
@@ -438,15 +398,12 @@ class Basket implements ControllerProviderInterface
|
||||
, 'message' => sprintf(_('%d records added'), $n)
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('basket_id', '\d+');
|
||||
@@ -463,8 +420,7 @@ class Basket implements ControllerProviderInterface
|
||||
*/
|
||||
$controllers->post(
|
||||
'/{basket_id}/stealElements/'
|
||||
, function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
, function(Application $app, Request $request, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
@@ -476,21 +432,17 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach ($request->get('elements') as $bask_element_id)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($request->get('elements') as $bask_element_id) {
|
||||
try {
|
||||
$basket_element = $em->getRepository('\Entities\BasketElement')
|
||||
->findUserElement($bask_element_id, $user);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$basket_element->setBasket($basket);
|
||||
$basket->addBasketElement($basket_element);
|
||||
$n++;
|
||||
$n ++;
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
@@ -500,15 +452,12 @@ class Basket implements ControllerProviderInterface
|
||||
, 'message' => sprintf(_('%d records moved'), $n)
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('basket_id', '\d+');
|
||||
@@ -516,8 +465,7 @@ class Basket implements ControllerProviderInterface
|
||||
/**
|
||||
* Get basket creation form
|
||||
*/
|
||||
$controllers->get('/create/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/create/', function(Application $app) {
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
@@ -527,23 +475,19 @@ class Basket implements ControllerProviderInterface
|
||||
/**
|
||||
* Get a basket
|
||||
*/
|
||||
$controllers->get('/{basket_id}/', function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
$controllers->get('/{basket_id}/', function(Application $app, Request $request, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
->findUserBasket($basket_id, $app['Core']->getAuthenticatedUser(), false);
|
||||
|
||||
if ($basket->getIsRead() === false)
|
||||
{
|
||||
if ($basket->getIsRead() === false) {
|
||||
$basket->setIsRead(true);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
if ($basket->getValidation())
|
||||
{
|
||||
if ($basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->getIsAware() === false)
|
||||
{
|
||||
if ($basket->getValidation()) {
|
||||
if ($basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->getIsAware() === false) {
|
||||
$basket->getValidation()->getParticipant($app['Core']->getAuthenticatedUser())->setIsAware(true);
|
||||
$em->flush();
|
||||
}
|
||||
@@ -564,5 +508,4 @@ class Basket implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,24 +36,21 @@ class Bridge implements ControllerProviderInterface
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
$app['require_connection'] = $app->protect(function(\Bridge_Account $account) use ($app)
|
||||
{
|
||||
$app['current_account'] = function() use ($account)
|
||||
{
|
||||
$app['require_connection'] = $app->protect(function(\Bridge_Account $account) use ($app) {
|
||||
$app['current_account'] = function() use ($account) {
|
||||
return $account;
|
||||
};
|
||||
|
||||
if (!$account->get_api()->get_connector()->is_configured())
|
||||
if ( ! $account->get_api()->get_connector()->is_configured())
|
||||
throw new \Bridge_Exception_ApiConnectorNotConfigured("Bridge API Connector is not configured");
|
||||
if (!$account->get_api()->get_connector()->is_connected())
|
||||
if ( ! $account->get_api()->get_connector()->is_connected())
|
||||
throw new \Bridge_Exception_ApiConnectorNotConnected("Bridge API Connector is not connected");
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
$controllers->post('/manager/'
|
||||
, function(Application $app) use ($twig)
|
||||
{
|
||||
, function(Application $app) use ($twig) {
|
||||
$route = new RecordHelper\Bridge($app['Core'], $app['request']);
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
@@ -69,19 +66,16 @@ class Bridge implements ControllerProviderInterface
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->get('/login/{api_name}/', function($api_name) use ($app, $twig)
|
||||
{
|
||||
$controllers->get('/login/{api_name}/', function($api_name) use ($app, $twig) {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$connector = \Bridge_Api::get_connector_by_name($appbox->get_registry(), $api_name);
|
||||
|
||||
return $app->redirect($connector->get_auth_url());
|
||||
});
|
||||
|
||||
$controllers->get('/callback/{api_name}/', function($api_name) use ($app, $twig)
|
||||
{
|
||||
$controllers->get('/callback/{api_name}/', function($api_name) use ($app, $twig) {
|
||||
$error_message = '';
|
||||
try
|
||||
{
|
||||
try {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
$api = \Bridge_Api::get_by_api_name($appbox, $api_name);
|
||||
@@ -91,12 +85,9 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
$user_id = $connector->get_user_id();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$account = \Bridge_Account::load_account_from_distant_id($appbox, $api, $user, $user_id);
|
||||
}
|
||||
catch (\Bridge_Exception_AccountNotFound $e)
|
||||
{
|
||||
} catch (\Bridge_Exception_AccountNotFound $e) {
|
||||
$account = \Bridge_Account::create($appbox, $api, $user, $user_id, $connector->get_user_name());
|
||||
}
|
||||
$settings = $account->get_settings();
|
||||
@@ -109,9 +100,7 @@ class Bridge implements ControllerProviderInterface
|
||||
$connector->set_auth_settings($settings);
|
||||
|
||||
$connector->reconnect();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -122,8 +111,7 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->get('/adapter/{account_id}/logout/'
|
||||
, function($account_id) use ($app, $twig)
|
||||
{
|
||||
, function($account_id) use ($app, $twig) {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$account = \Bridge_Account::load_account($appbox, $account_id);
|
||||
$app['require_connection']($account);
|
||||
@@ -134,8 +122,7 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-records/'
|
||||
, function($account_id) use ($app, $twig)
|
||||
{
|
||||
, function($account_id) use ($app, $twig) {
|
||||
$page = max((int) $app['request']->get('page'), 0);
|
||||
$quantity = 10;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
@@ -158,8 +145,7 @@ class Bridge implements ControllerProviderInterface
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-elements/{type}/'
|
||||
, function($account_id, $type) use ($app, $twig)
|
||||
{
|
||||
, function($account_id, $type) use ($app, $twig) {
|
||||
$page = max((int) $app['request']->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
@@ -184,8 +170,7 @@ class Bridge implements ControllerProviderInterface
|
||||
->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-containers/{type}/'
|
||||
, function($account_id, $type) use ($app, $twig)
|
||||
{
|
||||
, function($account_id, $type) use ($app, $twig) {
|
||||
|
||||
$page = max((int) $app['request']->get('page'), 0);
|
||||
$quantity = 5;
|
||||
@@ -211,8 +196,7 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->get('/action/{account_id}/{action}/{element_type}/'
|
||||
, function($account_id, $action, $element_type) use ($app, $twig)
|
||||
{
|
||||
, function($account_id, $action, $element_type) use ($app, $twig) {
|
||||
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$account = \Bridge_Account::load_account($appbox, $account_id);
|
||||
@@ -226,24 +210,19 @@ class Bridge implements ControllerProviderInterface
|
||||
$route_params = array();
|
||||
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case 'createcontainer':
|
||||
break;
|
||||
|
||||
case 'modify':
|
||||
if (count($elements) != 1)
|
||||
{
|
||||
if (count($elements) != 1) {
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-elements/' . $element_type . '/?page=&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement'));
|
||||
}
|
||||
foreach ($elements as $element_id)
|
||||
{
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_ELEMENT)
|
||||
{
|
||||
foreach ($elements as $element_id) {
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_ELEMENT) {
|
||||
$route_params = array('element' => $account->get_api()->get_element_from_id($element_id, $element_type));
|
||||
}
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_CONTAINER)
|
||||
{
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_CONTAINER) {
|
||||
$route_params = array('element' => $account->get_api()->get_container_from_id($element_id, $element_type));
|
||||
}
|
||||
}
|
||||
@@ -285,8 +264,7 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/action/{account_id}/{action}/{element_type}/'
|
||||
, function($account_id, $action, $element_type) use ($app, $twig)
|
||||
{
|
||||
, function($account_id, $action, $element_type) use ($app, $twig) {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$account = \Bridge_Account::load_account($appbox, $account_id);
|
||||
|
||||
@@ -300,23 +278,18 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
|
||||
$html = '';
|
||||
switch ($action)
|
||||
{
|
||||
switch ($action) {
|
||||
case 'modify':
|
||||
if (count($elements) != 1)
|
||||
{
|
||||
if (count($elements) != 1) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list=' . implode(';', $elements) . '&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement'));
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach ($elements as $element_id)
|
||||
{
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$errors = $account->get_api()->get_connector()->check_update_constraints($datas);
|
||||
}
|
||||
|
||||
if (count($errors) > 0)
|
||||
{
|
||||
if (count($errors) > 0) {
|
||||
$params = array(
|
||||
'element' => $account->get_api()->get_element_from_id($element_id, $element_type)
|
||||
, 'account' => $account
|
||||
@@ -336,14 +309,11 @@ class Bridge implements ControllerProviderInterface
|
||||
return new Response($html);
|
||||
}
|
||||
|
||||
foreach ($elements as $element_id)
|
||||
{
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$account->get_api()->update_element($element_type, $element_id, $datas);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list[]=' . $element_id . '&error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -351,15 +321,12 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
break;
|
||||
case 'createcontainer':
|
||||
try
|
||||
{
|
||||
try {
|
||||
|
||||
$container_type = $request->get('f_container_type');
|
||||
|
||||
$account->get_api()->create_container($container_type, $app['request']);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
@@ -368,16 +335,12 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
break;
|
||||
case 'moveinto':
|
||||
try
|
||||
{
|
||||
try {
|
||||
$container_id = $request->get('container_id');
|
||||
foreach ($elements as $element_id)
|
||||
{
|
||||
foreach ($elements as $element_id) {
|
||||
$account->get_api()->add_element_to_container($element_type, $element_id, $destination, $container_id);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -386,15 +349,11 @@ class Bridge implements ControllerProviderInterface
|
||||
break;
|
||||
|
||||
case 'deleteelement':
|
||||
try
|
||||
{
|
||||
foreach ($elements as $element_id)
|
||||
{
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
$account->get_api()->delete_object($element_type, $element_id);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -410,8 +369,7 @@ class Bridge implements ControllerProviderInterface
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
|
||||
$controllers->get('/upload/', function(Application $app) use ($twig)
|
||||
{
|
||||
$controllers->get('/upload/', function(Application $app) use ($twig) {
|
||||
$request = $app['request'];
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$account = \Bridge_Account::load_account($appbox, $request->get('account_id'));
|
||||
@@ -438,8 +396,7 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/upload/'
|
||||
, function(Application $app) use ($twig)
|
||||
{
|
||||
, function(Application $app) use ($twig) {
|
||||
$errors = array();
|
||||
$request = $app['request'];
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
@@ -453,14 +410,12 @@ class Bridge implements ControllerProviderInterface
|
||||
/**
|
||||
* check constraints
|
||||
*/
|
||||
foreach ($route->get_elements() as $record)
|
||||
{
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$errors = array_merge($errors, $connector->check_upload_constraints($datas, $record));
|
||||
}
|
||||
|
||||
if (count($errors) > 0)
|
||||
{
|
||||
if (count($errors) > 0) {
|
||||
|
||||
$params = array(
|
||||
'route' => $route
|
||||
@@ -477,8 +432,7 @@ class Bridge implements ControllerProviderInterface
|
||||
//return $app->redirect('/prod/bridge/upload/?lst='.$request->get('lst').'&account_id='.$request->get('account_id').'&errors=' . sprintf(_('%d elements en erreur. %s'), count($errors), $error_msg));
|
||||
}
|
||||
|
||||
foreach ($route->get_elements() as $record)
|
||||
{
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$title = isset($datas["title"]) ? $datas["title"] : '';
|
||||
$default_type = $connector->get_default_element_type();
|
||||
@@ -490,5 +444,4 @@ class Bridge implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,8 +31,7 @@ class Edit implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->post('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/', function(Application $app, Request $request) {
|
||||
$handler = new RecordHelper\Edit($app['Core'], $request);
|
||||
|
||||
$handler->propose_editing();
|
||||
@@ -46,21 +45,17 @@ class Edit implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->get('/vocabulary/{vocabulary}/', function(Application $app, Request $request, $vocabulary)
|
||||
{
|
||||
$controllers->get('/vocabulary/{vocabulary}/', function(Application $app, Request $request, $vocabulary) {
|
||||
$datas = array('success' => false, 'message' => '', 'results' => array());
|
||||
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
$sbas_id = (int) $request->get('sbas_id');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$VC = \Alchemy\Phrasea\Vocabulary\Controller::get($vocabulary);
|
||||
$databox = \databox::get_instance($sbas_id);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$datas['message'] = _('Vocabulary not found');
|
||||
|
||||
$datas = $Serializer->serialize($datas, 'json');
|
||||
@@ -74,8 +69,7 @@ class Edit implements ControllerProviderInterface
|
||||
|
||||
$list = array();
|
||||
|
||||
foreach ($results as $Term)
|
||||
{
|
||||
foreach ($results as $Term) {
|
||||
/* @var $Term \Alchemy\Phrasea\Vocabulary\Term */
|
||||
$list[] = array(
|
||||
'id' => $Term->getId(),
|
||||
@@ -91,8 +85,7 @@ class Edit implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/apply/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/apply/', function(Application $app, Request $request) {
|
||||
$editing = new RecordHelper\Edit($app['Core'], $app['request']);
|
||||
$editing->execute($request);
|
||||
|
||||
@@ -107,5 +100,4 @@ class Edit implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -39,8 +39,7 @@ class Feed implements ControllerProviderInterface
|
||||
/**
|
||||
* I got a selection of docs, which publications are available forthese docs ?
|
||||
*/
|
||||
$controllers->post('/requestavailable/', function(Application $app, Request $request) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->post('/requestavailable/', function(Application $app, Request $request) use ($appbox, $twig) {
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$publishing = new RecordHelper\Feed($app['Core'], $request);
|
||||
@@ -54,10 +53,8 @@ class Feed implements ControllerProviderInterface
|
||||
/**
|
||||
* I've selected a publication for my ocs, let's publish them
|
||||
*/
|
||||
$controllers->post('/entry/create/', function(Application $app, Request $request) use ($appbox, $twig)
|
||||
{
|
||||
try
|
||||
{
|
||||
$controllers->post('/entry/create/', function(Application $app, Request $request) use ($appbox, $twig) {
|
||||
try {
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feed = new \Feed_Adapter($appbox, $request->get('feed_id'));
|
||||
$publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user);
|
||||
@@ -71,14 +68,11 @@ class Feed implements ControllerProviderInterface
|
||||
|
||||
$publishing = new RecordHelper\Feed($app['Core'], $app['request']);
|
||||
|
||||
foreach ($publishing->get_elements() as $record)
|
||||
{
|
||||
foreach ($publishing->get_elements() as $record) {
|
||||
$item = \Feed_Entry_Item::create($appbox, $entry, $record);
|
||||
}
|
||||
$datas = array('error' => false, 'message' => false);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -92,15 +86,13 @@ class Feed implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/entry/{id}/edit/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->get('/entry/{id}/edit/', function(Application $app, Request $request, $id) use ($appbox, $twig) {
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
|
||||
{
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()) {
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
|
||||
@@ -112,19 +104,16 @@ class Feed implements ControllerProviderInterface
|
||||
})->assert('id', '\d+');
|
||||
|
||||
|
||||
$controllers->post('/entry/{id}/update/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->post('/entry/{id}/update/', function(Application $app, Request $request, $id) use ($appbox, $twig) {
|
||||
$datas = array('error' => true, 'message' => '', 'datas' => '');
|
||||
try
|
||||
{
|
||||
try {
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
|
||||
{
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()) {
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
|
||||
@@ -140,11 +129,9 @@ class Feed implements ControllerProviderInterface
|
||||
|
||||
$items = explode(';', $request->get('sorted_lst'));
|
||||
|
||||
foreach ($items as $item_sort)
|
||||
{
|
||||
foreach ($items as $item_sort) {
|
||||
$item_sort_datas = explode('_', $item_sort);
|
||||
if (count($item_sort_datas) != 2)
|
||||
{
|
||||
if (count($item_sort_datas) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -157,14 +144,10 @@ class Feed implements ControllerProviderInterface
|
||||
$entry = $twig->render('prod/feeds/entry.html', array('entry' => $entry));
|
||||
|
||||
$datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
|
||||
}
|
||||
catch (\Exception_Feed_EntryNotFound $e)
|
||||
{
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
@@ -179,11 +162,9 @@ class Feed implements ControllerProviderInterface
|
||||
})->assert('id', '\d+');
|
||||
|
||||
|
||||
$controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) use ($appbox, $twig) {
|
||||
$datas = array('error' => true, 'message' => '');
|
||||
try
|
||||
{
|
||||
try {
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
@@ -191,8 +172,7 @@ class Feed implements ControllerProviderInterface
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()
|
||||
&& $entry->get_feed()->is_owner($user) === false)
|
||||
{
|
||||
&& $entry->get_feed()->is_owner($user) === false) {
|
||||
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
|
||||
}
|
||||
|
||||
@@ -200,14 +180,10 @@ class Feed implements ControllerProviderInterface
|
||||
|
||||
$appbox->get_connection()->commit();
|
||||
$datas = array('error' => false, 'message' => 'succes');
|
||||
}
|
||||
catch (\Exception_Feed_EntryNotFound $e)
|
||||
{
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
@@ -240,8 +216,7 @@ class Feed implements ControllerProviderInterface
|
||||
//
|
||||
// });
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->get('/', function(Application $app, Request $request) use ($appbox, $twig) {
|
||||
$request = $app['request'];
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
@@ -262,8 +237,7 @@ class Feed implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig) {
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
@@ -278,8 +252,7 @@ class Feed implements ControllerProviderInterface
|
||||
})->assert('id', '\d+');
|
||||
|
||||
|
||||
$controllers->get('/subscribe/aggregated/', function(Application $app, Request $request) use ( $appbox, $twig)
|
||||
{
|
||||
$controllers->get('/subscribe/aggregated/', function(Application $app, Request $request) use ( $appbox, $twig) {
|
||||
$renew = ($request->get('renew') === 'true');
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
@@ -305,8 +278,7 @@ class Feed implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig) {
|
||||
$renew = ($request->get('renew') === 'true');
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
|
||||
@@ -330,5 +302,4 @@ class Feed implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -33,8 +33,7 @@ class Language implements ControllerProviderInterface
|
||||
{
|
||||
$controller = new ControllerCollection();
|
||||
|
||||
$controller->get("/", function(Application $app)
|
||||
{
|
||||
$controller->get("/", function(Application $app) {
|
||||
$registry = $app["Core"]->getRegistry();
|
||||
|
||||
$out = array();
|
||||
@@ -109,5 +108,4 @@ class Language implements ControllerProviderInterface
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,8 +31,7 @@ class MoveCollection implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->post('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/', function(Application $app, Request $request) {
|
||||
$request = $app['request'];
|
||||
$move = new RecordHelper\MoveCollection($app['Core'], $app['request']);
|
||||
$move->propose();
|
||||
@@ -46,8 +45,7 @@ class MoveCollection implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
|
||||
$controllers->post('/apply/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/apply/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
$move = new RecordHelper\MoveCollection($app['Core'], $app['request']);
|
||||
$move->execute($request);
|
||||
@@ -61,5 +59,4 @@ class MoveCollection implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,19 +29,16 @@ class MustacheLoader implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
$template_name = $request->get('template');
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9-_]+$/', $template_name))
|
||||
{
|
||||
if ( ! preg_match('/^[a-zA-Z0-9-_]+$/', $template_name)) {
|
||||
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
|
||||
}
|
||||
|
||||
$template_path = realpath(__DIR__ . '/../../../../../templates/web/Mustache/Prod/' . $template_name . '.Mustache.html');
|
||||
|
||||
if (!file_exists($template_path))
|
||||
{
|
||||
if ( ! file_exists($template_path)) {
|
||||
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
|
||||
}
|
||||
|
||||
@@ -50,5 +47,4 @@ class MustacheLoader implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,8 +31,7 @@ class Printer implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->post('/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/', function(Application $app) {
|
||||
$printer = new RecordHelper\Printer($app['Core'], $app['request']);
|
||||
|
||||
$template = 'prod/actions/printer_default.html.twig';
|
||||
@@ -46,8 +45,7 @@ class Printer implements ControllerProviderInterface
|
||||
|
||||
|
||||
|
||||
$controllers->post('/print.pdf', function(Application $app)
|
||||
{
|
||||
$controllers->post('/print.pdf', function(Application $app) {
|
||||
$printer = new RecordHelper\Printer($app['Core'], $app['request']);
|
||||
|
||||
$request = $app['request'];
|
||||
@@ -56,8 +54,7 @@ class Printer implements ControllerProviderInterface
|
||||
|
||||
$layout = $request->get('lay');
|
||||
|
||||
foreach ($printer->get_elements() as $record)
|
||||
{
|
||||
foreach ($printer->get_elements() as $record) {
|
||||
$session->get_logger($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_PRINT, $layout, '');
|
||||
}
|
||||
@@ -69,5 +66,4 @@ class Printer implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -30,8 +30,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
protected function getUserFormatter()
|
||||
{
|
||||
return function(\User_Adapter $user)
|
||||
{
|
||||
return function(\User_Adapter $user) {
|
||||
return array(
|
||||
'type' => 'USER'
|
||||
, 'usr_id' => $user->get_id()
|
||||
@@ -47,12 +46,10 @@ class Push implements ControllerProviderInterface
|
||||
{
|
||||
$userFormatter = $this->getUserFormatter();
|
||||
|
||||
return function(\Entities\UsrList $List) use ($userFormatter)
|
||||
{
|
||||
return function(\Entities\UsrList $List) use ($userFormatter) {
|
||||
$entries = array();
|
||||
|
||||
foreach ($List->getEntries() as $entry)
|
||||
{
|
||||
foreach ($List->getEntries() as $entry) {
|
||||
/* @var $entry \Entities\UsrListEntry */
|
||||
$entries[] = array(
|
||||
'Id' => $entry->getId(),
|
||||
@@ -72,18 +69,14 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
protected function getUsersInSelectionExtractor()
|
||||
{
|
||||
return function(array $selection)
|
||||
{
|
||||
return function(array $selection) {
|
||||
$Users = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
|
||||
foreach ($selection as $record)
|
||||
{
|
||||
foreach ($selection as $record) {
|
||||
/* @var $record record_adapter */
|
||||
foreach ($record->get_caption()->get_fields() as $caption_field)
|
||||
{
|
||||
foreach ($caption_field->get_values() as $value)
|
||||
{
|
||||
if (!$value->getVocabularyType())
|
||||
foreach ($record->get_caption()->get_fields() as $caption_field) {
|
||||
foreach ($caption_field->get_values() as $value) {
|
||||
if ( ! $value->getVocabularyType())
|
||||
continue;
|
||||
|
||||
if ($value->getVocabularyType()->getType() !== 'User')
|
||||
@@ -110,8 +103,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$userSelection = $this->getUsersInSelectionExtractor();
|
||||
|
||||
$controllers->post('/sendform/', function(Application $app) use ($userSelection)
|
||||
{
|
||||
$controllers->post('/sendform/', function(Application $app) use ($userSelection) {
|
||||
$push = new RecordHelper\Push($app['Core'], $app['request']);
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
@@ -136,8 +128,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/validateform/', function(Application $app) use ($userSelection)
|
||||
{
|
||||
$controllers->post('/validateform/', function(Application $app) use ($userSelection) {
|
||||
$push = new RecordHelper\Push($app['Core'], $app['request']);
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
@@ -162,8 +153,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/send/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/send/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
|
||||
$ret = array(
|
||||
@@ -171,8 +161,7 @@ class Push implements ControllerProviderInterface
|
||||
'message' => _('Unable to send the documents')
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$registry = $app['Core']->getRegistry();
|
||||
@@ -185,8 +174,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$push_name = $request->get('name');
|
||||
|
||||
if (trim($push_name) === '')
|
||||
{
|
||||
if (trim($push_name) === '') {
|
||||
$push_name = sprintf(_('Push from %s'), $user->get_display_name());
|
||||
}
|
||||
|
||||
@@ -194,27 +182,21 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$receivers = $request->get('participants');
|
||||
|
||||
if (!is_array($receivers) || count($receivers) === 0)
|
||||
{
|
||||
if ( ! is_array($receivers) || count($receivers) === 0) {
|
||||
throw new ControllerException(_('No receivers specified'));
|
||||
}
|
||||
|
||||
if (!is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0)
|
||||
{
|
||||
if ( ! is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0) {
|
||||
throw new ControllerException(_('No elements to push'));
|
||||
}
|
||||
|
||||
|
||||
$events_manager = \eventsmanager_broker::getInstance(\appbox::get_instance($app['Core']), $app['Core']);
|
||||
|
||||
foreach ($receivers as $receiver)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($receivers as $receiver) {
|
||||
try {
|
||||
$user_receiver = \User_Adapter::getInstance($receiver['usr_id'], $appbox);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
throw new ControllerException(sprintf(_('Unknown user %d'), $receiver['usr_id']));
|
||||
}
|
||||
|
||||
@@ -227,8 +209,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$em->persist($Basket);
|
||||
|
||||
foreach ($pusher->get_elements() as $element)
|
||||
{
|
||||
foreach ($pusher->get_elements() as $element) {
|
||||
$BasketElement = new \Entities\BasketElement();
|
||||
$BasketElement->setRecord($element);
|
||||
$BasketElement->setBasket($Basket);
|
||||
@@ -237,16 +218,13 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$Basket->addBasketElement($BasketElement);
|
||||
|
||||
if ($receiver['HD'])
|
||||
{
|
||||
if ($receiver['HD']) {
|
||||
$user_receiver->ACL()->grant_hd_on(
|
||||
$BasketElement->getRecord()
|
||||
, $user
|
||||
, \ACL::GRANT_ACTION_PUSH
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$user_receiver->ACL()->grant_preview_on(
|
||||
$BasketElement->getRecord()
|
||||
, $user
|
||||
@@ -268,7 +246,7 @@ class Push implements ControllerProviderInterface
|
||||
, 'to_email' => $user_receiver->get_email()
|
||||
, 'to_name' => $user_receiver->get_display_name()
|
||||
, 'url' => $url
|
||||
, 'accuse' => !!$request->get('recept', false)
|
||||
, 'accuse' => ! ! $request->get('recept', false)
|
||||
, 'message' => $request->get('message')
|
||||
, 'ssel_id' => $Basket->getId()
|
||||
);
|
||||
@@ -288,9 +266,7 @@ class Push implements ControllerProviderInterface
|
||||
'success' => true,
|
||||
'message' => $message
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$ret['message'] = $e->getMessage() . $e->getFile() . $e->getLine();
|
||||
}
|
||||
|
||||
@@ -300,8 +276,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/validate/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/validate/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
|
||||
$ret = array(
|
||||
@@ -316,8 +291,7 @@ class Push implements ControllerProviderInterface
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
$em->beginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$pusher = new RecordHelper\Push($app['Core'], $app['request']);
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
@@ -327,8 +301,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$validation_name = $request->get('name');
|
||||
|
||||
if (trim($validation_name) === '')
|
||||
{
|
||||
if (trim($validation_name) === '') {
|
||||
$validation_name = sprintf(_('Validation from %s'), $user->get_display_name());
|
||||
}
|
||||
|
||||
@@ -336,22 +309,17 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$participants = $request->get('participants');
|
||||
|
||||
if (!is_array($participants) || count($participants) === 0)
|
||||
{
|
||||
if ( ! is_array($participants) || count($participants) === 0) {
|
||||
throw new ControllerException(_('No participants specified'));
|
||||
}
|
||||
|
||||
if (!is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0)
|
||||
{
|
||||
if ( ! is_array($pusher->get_elements()) || count($pusher->get_elements()) === 0) {
|
||||
throw new ControllerException(_('No elements to validate'));
|
||||
}
|
||||
|
||||
if ($pusher->is_basket())
|
||||
{
|
||||
if ($pusher->is_basket()) {
|
||||
$Basket = $pusher->get_original_basket();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$Basket = new \Entities\Basket();
|
||||
$Basket->setName($validation_name);
|
||||
$Basket->setDescription($validation_description);
|
||||
@@ -360,8 +328,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$em->persist($Basket);
|
||||
|
||||
foreach ($pusher->get_elements() as $element)
|
||||
{
|
||||
foreach ($pusher->get_elements() as $element) {
|
||||
$BasketElement = new \Entities\BasketElement();
|
||||
$BasketElement->setRecord($element);
|
||||
$BasketElement->setBasket($Basket);
|
||||
@@ -375,25 +342,21 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$em->refresh($Basket);
|
||||
|
||||
if (!$Basket->getValidation())
|
||||
{
|
||||
if ( ! $Basket->getValidation()) {
|
||||
$Validation = new \Entities\ValidationSession();
|
||||
$Validation->setInitiator($app['Core']->getAuthenticatedUser());
|
||||
$Validation->setBasket($Basket);
|
||||
|
||||
$duration = (int) $request->get('duration');
|
||||
|
||||
if ($duration > 0)
|
||||
{
|
||||
if ($duration > 0) {
|
||||
$date = new \DateTime('+' . $duration . ' day' . ($duration > 1 ? 's' : ''));
|
||||
$Validation->setExpires($date);
|
||||
}
|
||||
|
||||
$Basket->setValidation($Validation);
|
||||
$em->persist($Validation);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$Validation = $Basket->getValidation();
|
||||
}
|
||||
|
||||
@@ -401,17 +364,14 @@ class Push implements ControllerProviderInterface
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
|
||||
$found = false;
|
||||
foreach ($participants as $key => $participant)
|
||||
{
|
||||
if ($participant['usr_id'] == $user->get_id())
|
||||
{
|
||||
foreach ($participants as $key => $participant) {
|
||||
if ($participant['usr_id'] == $user->get_id()) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found)
|
||||
{
|
||||
if ( ! $found) {
|
||||
$participants[$user->get_id()] = array(
|
||||
'see_others' => 1,
|
||||
'usr_id' => $user->get_id(),
|
||||
@@ -420,30 +380,22 @@ class Push implements ControllerProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($participants as $key => $participant)
|
||||
{
|
||||
foreach (array('see_others', 'usr_id', 'agree', 'HD') as $mandatoryparam)
|
||||
{
|
||||
if (!array_key_exists($mandatoryparam, $participant))
|
||||
foreach ($participants as $key => $participant) {
|
||||
foreach (array('see_others', 'usr_id', 'agree', 'HD') as $mandatoryparam) {
|
||||
if ( ! array_key_exists($mandatoryparam, $participant))
|
||||
throw new ControllerException(sprintf(_('Missing mandatory parameter %s'), $mandatoryparam));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$participant_user = \User_Adapter::getInstance($participant['usr_id'], $appbox);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
throw new ControllerException(sprintf(_('Unknown user %d'), $receiver['usr_id']));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$Participant = $Validation->getParticipant($participant_user);
|
||||
continue;
|
||||
}
|
||||
catch (\Exception_NotFound $e)
|
||||
{
|
||||
} catch (\Exception_NotFound $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -456,23 +408,19 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$em->persist($Participant);
|
||||
|
||||
foreach ($Basket->getElements() as $BasketElement)
|
||||
{
|
||||
foreach ($Basket->getElements() as $BasketElement) {
|
||||
$ValidationData = new \Entities\ValidationData();
|
||||
$ValidationData->setParticipant($Participant);
|
||||
$ValidationData->setBasketElement($BasketElement);
|
||||
$BasketElement->addValidationData($ValidationData);
|
||||
|
||||
if ($participant['HD'])
|
||||
{
|
||||
if ($participant['HD']) {
|
||||
$participant_user->ACL()->grant_hd_on(
|
||||
$BasketElement->getRecord()
|
||||
, $user
|
||||
, \ACL::GRANT_ACTION_VALIDATE
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$participant_user->ACL()->grant_preview_on(
|
||||
$BasketElement->getRecord()
|
||||
, $user
|
||||
@@ -501,7 +449,7 @@ class Push implements ControllerProviderInterface
|
||||
, 'to_email' => $participant_user->get_email()
|
||||
, 'to_name' => $participant_user->get_display_name()
|
||||
, 'url' => $url
|
||||
, 'accuse' => !!$request->get('recept', false)
|
||||
, 'accuse' => ! ! $request->get('recept', false)
|
||||
, 'message' => $request->get('message')
|
||||
, 'ssel_id' => $Basket->getId()
|
||||
);
|
||||
@@ -526,9 +474,7 @@ class Push implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
$em->commit();
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$ret['message'] = $e->getMessage();
|
||||
$em->rollback();
|
||||
}
|
||||
@@ -539,8 +485,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->get('/user/{usr_id}/', function(Application $app, $usr_id) use ($userFormatter)
|
||||
{
|
||||
$controllers->get('/user/{usr_id}/', function(Application $app, $usr_id) use ($userFormatter) {
|
||||
|
||||
$datas = null;
|
||||
|
||||
@@ -558,10 +503,8 @@ class Push implements ControllerProviderInterface
|
||||
->limit(0, 1)
|
||||
->execute()->get_results();
|
||||
|
||||
if ($result)
|
||||
{
|
||||
foreach ($result as $user)
|
||||
{
|
||||
if ($result) {
|
||||
foreach ($result as $user) {
|
||||
$datas = $userFormatter($user);
|
||||
}
|
||||
}
|
||||
@@ -571,8 +514,7 @@ class Push implements ControllerProviderInterface
|
||||
return new Response($Json, 200, array('Content-Type' => 'application/json'));
|
||||
})->assert('usr_id', '\d+');
|
||||
|
||||
$controllers->get('/list/{list_id}/', function(Application $app, $list_id) use ($listFormatter)
|
||||
{
|
||||
$controllers->get('/list/{list_id}/', function(Application $app, $list_id) use ($listFormatter) {
|
||||
$datas = null;
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
@@ -582,8 +524,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
|
||||
if ($list)
|
||||
{
|
||||
if ($list) {
|
||||
$datas = $listFormatter($list);
|
||||
}
|
||||
|
||||
@@ -592,34 +533,30 @@ class Push implements ControllerProviderInterface
|
||||
return new Response($Json, 200, array('Content-Type' => 'application/json'));
|
||||
})->assert('list_id', '\d+');
|
||||
|
||||
$controllers->post('/add-user/', function(Application $app, Request $request) use ($userFormatter)
|
||||
{
|
||||
$controllers->post('/add-user/', function(Application $app, Request $request) use ($userFormatter) {
|
||||
$result = array('success' => false, 'message' => '', 'user' => null);
|
||||
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
$AdminUser = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
/* @var $AdminUser \User_Adapter */
|
||||
if (!$AdminUser->ACL()->has_right('manageusers'))
|
||||
if ( ! $AdminUser->ACL()->has_right('manageusers'))
|
||||
throw new ControllerException(_('You are not allowed to add users'));
|
||||
|
||||
if (!$request->get('firstname'))
|
||||
if ( ! $request->get('firstname'))
|
||||
throw new ControllerException(_('First name is required'));
|
||||
|
||||
if (!$request->get('lastname'))
|
||||
if ( ! $request->get('lastname'))
|
||||
throw new ControllerException(_('Last name is required'));
|
||||
|
||||
if (!$request->get('email'))
|
||||
if ( ! $request->get('email'))
|
||||
throw new ControllerException(_('Email is required'));
|
||||
|
||||
if (!\mail::validateEmail($request->get('email')))
|
||||
if ( ! \mail::validateEmail($request->get('email')))
|
||||
throw new ControllerException(_('Email is invalid'));
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$result['message'] = $e->getMessage();
|
||||
|
||||
return new Response($Serializer->serialize($result, 'json'), 200, array('Content-Type' => 'application/json'));
|
||||
@@ -630,24 +567,19 @@ class Push implements ControllerProviderInterface
|
||||
$user = null;
|
||||
$email = $request->get('email');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$usr_id = \User_Adapter::get_usr_id_from_email($email);
|
||||
$user = \User_Adapter::getInstance($usr_id, $appbox);
|
||||
|
||||
$result['message'] = _('User already exists');
|
||||
$result['success'] = true;
|
||||
$result['user'] = $userFormatter($user);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if (!$user instanceof \User_Adapter)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! $user instanceof \User_Adapter) {
|
||||
try {
|
||||
$password = \random::generatePassword();
|
||||
|
||||
$user = \User_Adapter::create($appbox, $email, $password, $email, false);
|
||||
@@ -665,9 +597,7 @@ class Push implements ControllerProviderInterface
|
||||
$result['message'] = _('User successfully created');
|
||||
$result['success'] = true;
|
||||
$result['user'] = $userFormatter($user);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$result['message'] = _('Error while creating user');
|
||||
}
|
||||
}
|
||||
@@ -676,15 +606,13 @@ class Push implements ControllerProviderInterface
|
||||
return new Response($Serializer->serialize($result, 'json'), 200, array('Content-Type' => 'application/json'));
|
||||
});
|
||||
|
||||
$controllers->get('/add-user/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->get('/add-user/', function(Application $app, Request $request) {
|
||||
$params = array('callback' => $request->get('callback'));
|
||||
|
||||
return new Response($app['Core']['Twig']->render('prod/User/Add.html.twig', $params));
|
||||
});
|
||||
|
||||
$controllers->get('/search-user/', function(Application $app) use ($userFormatter, $listFormatter)
|
||||
{
|
||||
$controllers->get('/search-user/', function(Application $app) use ($userFormatter, $listFormatter) {
|
||||
$request = $app['request'];
|
||||
$em = $app['Core']->getEntityManager();
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
@@ -708,18 +636,14 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$datas = array();
|
||||
|
||||
if ($lists)
|
||||
{
|
||||
foreach ($lists as $list)
|
||||
{
|
||||
if ($lists) {
|
||||
foreach ($lists as $list) {
|
||||
$datas[] = $listFormatter($list);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result)
|
||||
{
|
||||
foreach ($result as $user)
|
||||
{
|
||||
if ($result) {
|
||||
foreach ($result as $user) {
|
||||
$datas[] = $userFormatter($user);
|
||||
}
|
||||
}
|
||||
@@ -733,8 +657,7 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
|
||||
|
||||
$controllers->match('/edit-list/{list_id}/', function(Application $app, Request $request, $list_id)
|
||||
{
|
||||
$controllers->match('/edit-list/{list_id}/', function(Application $app, Request $request, $list_id) {
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
$em = $app['Core']->getEntityManager();
|
||||
@@ -747,29 +670,23 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
$query->on_bases_where_i_am($user->ACL(), array('canpush'));
|
||||
|
||||
if ($request->get('query'))
|
||||
{
|
||||
if ($request->get('query')) {
|
||||
$query->like($request->get('like_field'), $request->get('query'))
|
||||
->like_match(\User_Query::LIKE_MATCH_OR);
|
||||
}
|
||||
if (is_array($request->get('Activity')))
|
||||
{
|
||||
if (is_array($request->get('Activity'))) {
|
||||
$query->haveActivities($request->get('Activity'));
|
||||
}
|
||||
if (is_array($request->get('Template')))
|
||||
{
|
||||
if (is_array($request->get('Template'))) {
|
||||
$query->haveTemplate($request->get('Template'));
|
||||
}
|
||||
if (is_array($request->get('Company')))
|
||||
{
|
||||
if (is_array($request->get('Company'))) {
|
||||
$query->inCompanies($request->get('Company'));
|
||||
}
|
||||
if (is_array($request->get('Country')))
|
||||
{
|
||||
if (is_array($request->get('Country'))) {
|
||||
$query->inCountries($request->get('Country'));
|
||||
}
|
||||
if (is_array($request->get('Position')))
|
||||
{
|
||||
if (is_array($request->get('Position'))) {
|
||||
$query->havePositions($request->get('Position'));
|
||||
}
|
||||
|
||||
@@ -793,14 +710,11 @@ class Push implements ControllerProviderInterface
|
||||
, 'ord' => $ord
|
||||
);
|
||||
|
||||
if ($request->get('type') === 'fragment')
|
||||
{
|
||||
if ($request->get('type') === 'fragment') {
|
||||
return new Response(
|
||||
$app['Core']->getTwig()->render('prod/actions/Feedback/ResultTable.html.twig', $params)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new Response(
|
||||
$app['Core']->getTwig()->render('prod/actions/Feedback/list.html.twig', $params)
|
||||
);
|
||||
@@ -810,5 +724,4 @@ class Push implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,8 +31,7 @@ class Query implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->match('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->match('/', function(Application $app, Request $request) {
|
||||
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$registry = $appbox->get_registry();
|
||||
@@ -51,23 +50,18 @@ class Query implements ControllerProviderInterface
|
||||
$bas = is_array($request->get('bas')) ? $request->get('bas') : array_keys($user->ACL()->get_granted_base());
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
if ($user->ACL()->has_right('modifyrecord'))
|
||||
{
|
||||
if ($user->ACL()->has_right('modifyrecord')) {
|
||||
$options->set_business_fields(array());
|
||||
|
||||
$BF = array();
|
||||
|
||||
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
|
||||
{
|
||||
if (count($bas) === 0 || in_array($collection->get_base_id(), $bas))
|
||||
{
|
||||
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection) {
|
||||
if (count($bas) === 0 || in_array($collection->get_base_id(), $bas)) {
|
||||
$BF[] = $collection->get_base_id();
|
||||
}
|
||||
}
|
||||
$options->set_business_fields($BF);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$options->set_business_fields(array());
|
||||
}
|
||||
|
||||
@@ -95,8 +89,7 @@ class Query implements ControllerProviderInterface
|
||||
|
||||
$page = (int) $request->get('pag');
|
||||
|
||||
if ($page < 1)
|
||||
{
|
||||
if ($page < 1) {
|
||||
$search_engine->set_is_first_page(true);
|
||||
$search_engine->reset_cache();
|
||||
$page = 1;
|
||||
@@ -112,18 +105,14 @@ class Query implements ControllerProviderInterface
|
||||
|
||||
$string = '';
|
||||
|
||||
if ($npages > 1)
|
||||
{
|
||||
if ($npages > 1) {
|
||||
|
||||
$d2top = ($npages - $page);
|
||||
$d2bottom = $page;
|
||||
|
||||
if (min($d2top, $d2bottom) < 4)
|
||||
{
|
||||
if ($d2bottom < 4)
|
||||
{
|
||||
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i ++ )
|
||||
{
|
||||
if (min($d2top, $d2bottom) < 4) {
|
||||
if ($d2bottom < 4) {
|
||||
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i ++ ) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />';
|
||||
else
|
||||
@@ -132,15 +121,13 @@ class Query implements ControllerProviderInterface
|
||||
if ($npages > 4)
|
||||
$string .= "<a onclick='gotopage(" . ($npages) . ");return false;'>>></a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$start = $npages - 4;
|
||||
if (($start) > 0)
|
||||
$string .= "<a onclick='gotopage(1);return false;'><<</a>";
|
||||
else
|
||||
$start = 1;
|
||||
for ($i = ($start); $i <= $npages; $i ++ )
|
||||
{
|
||||
for ($i = ($start); $i <= $npages; $i ++ ) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />';
|
||||
else
|
||||
@@ -148,12 +135,10 @@ class Query implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$string .= "<a onclick='gotopage(1);return false;'><<</a>";
|
||||
|
||||
for ($i = ($page - 2); $i <= ($page + 2); $i ++ )
|
||||
{
|
||||
for ($i = ($page - 2); $i <= ($page + 2); $i ++ ) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />';
|
||||
else
|
||||
@@ -170,12 +155,9 @@ class Query implements ControllerProviderInterface
|
||||
|
||||
$explain .= "<img src=\"/skins/icons/answers.gif\" /><span><b>";
|
||||
|
||||
if ($result->get_count_total_results() != $result->get_count_available_results())
|
||||
{
|
||||
if ($result->get_count_total_results() != $result->get_count_available_results()) {
|
||||
$explain .= sprintf(_('reponses:: %d Resultats rappatries sur un total de %d trouves'), $result->get_count_available_results(), $result->get_count_total_results());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$explain .= sprintf(_('reponses:: %d Resultats'), $result->get_count_total_results());
|
||||
}
|
||||
|
||||
@@ -190,15 +172,11 @@ class Query implements ControllerProviderInterface
|
||||
|
||||
$prop = null;
|
||||
|
||||
if ($search_engine->is_first_page())
|
||||
{
|
||||
if ($search_engine->is_first_page()) {
|
||||
$propals = $result->get_suggestions();
|
||||
if (count($propals) > 0)
|
||||
{
|
||||
foreach ($propals as $prop_array)
|
||||
{
|
||||
if ($prop_array['value'] !== $query && $prop_array['hits'] > $result->get_count_total_results())
|
||||
{
|
||||
if (count($propals) > 0) {
|
||||
foreach ($propals as $prop_array) {
|
||||
if ($prop_array['value'] !== $query && $prop_array['hits'] > $result->get_count_total_results()) {
|
||||
$prop = $prop_array['value'];
|
||||
break;
|
||||
}
|
||||
@@ -209,18 +187,12 @@ class Query implements ControllerProviderInterface
|
||||
$core = \bootstrap::getCore();
|
||||
$twig = $core->getTwig();
|
||||
|
||||
if ($result->get_count_total_results() === 0)
|
||||
{
|
||||
if ($result->get_count_total_results() === 0) {
|
||||
$template = 'prod/results/help.twig';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($mod == 'thumbs')
|
||||
{
|
||||
} else {
|
||||
if ($mod == 'thumbs') {
|
||||
$template = 'prod/results/answergrid.html';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$template = 'prod/results/answerlist.html';
|
||||
}
|
||||
}
|
||||
@@ -250,5 +222,4 @@ class Query implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,8 +35,7 @@ class Root implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/', function(Application $app) {
|
||||
|
||||
\User_Adapter::updateClientInfos(1);
|
||||
|
||||
@@ -53,22 +52,19 @@ class Root implements ControllerProviderInterface
|
||||
$iterator = $finder
|
||||
->directories()
|
||||
->depth(0)
|
||||
->filter(function(\SplFileInfo $fileinfo)
|
||||
{
|
||||
->filter(function(\SplFileInfo $fileinfo) {
|
||||
return ctype_xdigit($fileinfo->getBasename());
|
||||
})
|
||||
->in($cssPath);
|
||||
|
||||
foreach ($iterator as $dir)
|
||||
{
|
||||
foreach ($iterator as $dir) {
|
||||
$baseName = $dir->getBaseName();
|
||||
$css[$baseName] = $baseName;
|
||||
}
|
||||
|
||||
$cssfile = $user->getPrefs('css');
|
||||
|
||||
if (!$cssfile && isset($css['000000']))
|
||||
{
|
||||
if ( ! $cssfile && isset($css['000000'])) {
|
||||
$cssfile = '000000';
|
||||
}
|
||||
|
||||
@@ -80,27 +76,22 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
$queries_topics = '';
|
||||
|
||||
if ($registry->get('GV_client_render_topics') == 'popups')
|
||||
{
|
||||
if ($registry->get('GV_client_render_topics') == 'popups') {
|
||||
$queries_topics = \queries::dropdown_topics();
|
||||
}
|
||||
elseif ($registry->get('GV_client_render_topics') == 'tree')
|
||||
{
|
||||
} elseif ($registry->get('GV_client_render_topics') == 'tree') {
|
||||
$queries_topics = \queries::tree_topics();
|
||||
}
|
||||
|
||||
$sbas = $bas2sbas = array();
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
$sbas_id = $databox->get_sbas_id();
|
||||
|
||||
$sbas['s' + $sbas_id] = array(
|
||||
'sbid' => $sbas_id,
|
||||
'seeker' => null);
|
||||
|
||||
foreach ($databox->get_collections() as $coll)
|
||||
{
|
||||
foreach ($databox->get_collections() as $coll) {
|
||||
$bas2sbas['b' . $coll->get_base_id()] = array(
|
||||
'sbid' => $sbas_id,
|
||||
'ckobj' => array('checked' => false),
|
||||
@@ -144,5 +135,4 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,16 +37,14 @@ class Story implements ControllerProviderInterface
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
|
||||
$controllers->get('/create/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/create/', function(Application $app) {
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
return new Response($twig->render('prod/Story/Create.html.twig', array()));
|
||||
});
|
||||
|
||||
$controllers->post('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/', function(Application $app, Request $request) {
|
||||
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -55,8 +53,7 @@ class Story implements ControllerProviderInterface
|
||||
$collection = \collection::get_from_base_id($request->get('base_id'));
|
||||
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord'))
|
||||
{
|
||||
if ( ! $user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
|
||||
throw new \Exception_Forbidden('You can not create a story on this collection');
|
||||
}
|
||||
|
||||
@@ -68,21 +65,18 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$Story = \record_adapter::create($collection, $system_file, false, true);
|
||||
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||
{
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2)
|
||||
{
|
||||
if (count($sbas_rec) !== 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record))
|
||||
{
|
||||
if ( ! $user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& ! $user->ACL()->has_hd_grant($record)
|
||||
&& ! $user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -94,14 +88,10 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$metadatas = array();
|
||||
|
||||
foreach ($collection->get_databox()->get_meta_structure() as $meta)
|
||||
{
|
||||
if ($meta->get_thumbtitle())
|
||||
{
|
||||
foreach ($collection->get_databox()->get_meta_structure() as $meta) {
|
||||
if ($meta->get_thumbtitle()) {
|
||||
$value = $request->get('name');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -124,8 +114,7 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$em->flush();
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => _('Story created')
|
||||
@@ -139,17 +128,14 @@ class Story implements ControllerProviderInterface
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse(sprintf('/%d/', $StoryWZ->getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$controllers->get('/{sbas_id}/{record_id}/', function(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
$controllers->get('/{sbas_id}/{record_id}/', function(Application $app, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -163,21 +149,19 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$controllers->post(
|
||||
'/{sbas_id}/{record_id}/addElements/'
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
if ( ! $user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||
{
|
||||
foreach (explode(';', $request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2)
|
||||
@@ -185,10 +169,9 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record))
|
||||
{
|
||||
if ( ! $user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& ! $user->ACL()->has_hd_grant($record)
|
||||
&& ! $user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -197,7 +180,7 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$Story->appendChild($record);
|
||||
|
||||
$n++;
|
||||
$n ++;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
@@ -205,30 +188,26 @@ class Story implements ControllerProviderInterface
|
||||
, 'message' => sprintf(_('%d records added'), $n)
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->post(
|
||||
'/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/'
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id)
|
||||
{
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
|
||||
$Story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
$record = new \record_adapter($child_sbas_id, $child_record_id);
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
if ( ! $user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
@@ -240,14 +219,11 @@ class Story implements ControllerProviderInterface
|
||||
, 'message' => _('Record removed from story')
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})
|
||||
@@ -262,15 +238,13 @@ class Story implements ControllerProviderInterface
|
||||
*/
|
||||
$controllers->get(
|
||||
'/{sbas_id}/{record_id}/reorder/'
|
||||
, function(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $record_id) {
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
if (!$story->is_grouping())
|
||||
{
|
||||
if ( ! $story->is_grouping()) {
|
||||
throw new \Exception('This is not a story');
|
||||
}
|
||||
|
||||
@@ -290,23 +264,19 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
$controllers->post(
|
||||
'/{sbas_id}/{record_id}/reorder/'
|
||||
, function(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $record_id) {
|
||||
$ret = array('success' => false, 'message' => _('An error occured'));
|
||||
try
|
||||
{
|
||||
try {
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
/* @var $user \User_Adapter */
|
||||
|
||||
$story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
if (!$story->is_grouping())
|
||||
{
|
||||
if ( ! $story->is_grouping()) {
|
||||
throw new \Exception('This is not a story');
|
||||
}
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord'))
|
||||
{
|
||||
if ( ! $user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) {
|
||||
throw new ControllerException(_('You can not edit this story'));
|
||||
}
|
||||
|
||||
@@ -314,8 +284,7 @@ class Story implements ControllerProviderInterface
|
||||
WHERE rid_parent = :parent_id AND rid_child = :children_id';
|
||||
$stmt = $story->get_databox()->get_connection()->prepare($sql);
|
||||
|
||||
foreach ($app['request']->get('element') as $record_id => $ord)
|
||||
{
|
||||
foreach ($app['request']->get('element') as $record_id => $ord) {
|
||||
$params = array(
|
||||
':ord' => $ord,
|
||||
':parent_id' => $story->get_record_id(),
|
||||
@@ -327,13 +296,9 @@ class Story implements ControllerProviderInterface
|
||||
$stmt->closeCursor();
|
||||
|
||||
$ret = array('success' => true, 'message' => _('Story updated'));
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$ret = array('success' => false, 'message' => $e->getMessage());
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -347,5 +312,4 @@ class Story implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -33,12 +33,10 @@ class TOU implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->post('/deny/{sbas_id}/', function(Application $app, Request $request, $sbas_id)
|
||||
{
|
||||
$controllers->post('/deny/{sbas_id}/', function(Application $app, Request $request, $sbas_id) {
|
||||
$ret = array('success' => false, 'message' => '');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
$session = \Session_Handler::getInstance(\appbox::get_instance($app['Core']));
|
||||
|
||||
@@ -52,9 +50,7 @@ class TOU implements ControllerProviderInterface
|
||||
$session->logout();
|
||||
|
||||
$ret = array('success' => true, 'message' => '');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -66,5 +62,4 @@ class TOU implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,8 +36,7 @@ class Tools implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
$helper = new Helper\Record\Tools($app['Core'], $request);
|
||||
|
||||
$selection = $helper->get_elements();
|
||||
@@ -48,32 +47,26 @@ class Tools implements ControllerProviderInterface
|
||||
$record = null;
|
||||
$metadatasFirst = $metadatasSecond = array();
|
||||
|
||||
if (count($selection) == 1 && ! empty($binary))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (count($selection) == 1 && ! empty($binary)) {
|
||||
try {
|
||||
$record = reset($selection);
|
||||
$file = $record->get_subdef('document')->get_pathfile();
|
||||
$cmd = $binary . ' -h ' . escapeshellarg($file);
|
||||
|
||||
$out = "";
|
||||
exec($cmd, $out);
|
||||
foreach ($out as $liout)
|
||||
{
|
||||
foreach ($out as $liout) {
|
||||
if (strpos($liout, '<tr><td>Directory') === false)
|
||||
$metadatasFirst[] = $liout;
|
||||
}
|
||||
$out = "";
|
||||
$cmd = $binary . ' -X -n -fast ' . escapeshellarg($file) . '';
|
||||
exec($cmd, $out);
|
||||
foreach ($out as $liout)
|
||||
{
|
||||
foreach ($out as $liout) {
|
||||
$metadatasSecond[] = htmlentities($liout);
|
||||
}
|
||||
$metadatas = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -92,8 +85,7 @@ class Tools implements ControllerProviderInterface
|
||||
return new Response($app['Core']->getTwig()->render($template, $var));
|
||||
});
|
||||
|
||||
$controllers->post('/rotate/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/rotate/', function(Application $app, Request $request) {
|
||||
$return = array('success' => false, 'errorMessage' => '');
|
||||
|
||||
$helper = new Helper\Record\Tools($app['Core'], $request);
|
||||
@@ -102,15 +94,11 @@ class Tools implements ControllerProviderInterface
|
||||
|
||||
$selection = $helper->get_elements();
|
||||
|
||||
foreach ($selection as $record)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($selection as $record) {
|
||||
try {
|
||||
$record->rotate_subdefs($rotation);
|
||||
$return['success'] = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$return['errorMessage'] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -120,24 +108,18 @@ class Tools implements ControllerProviderInterface
|
||||
return new Response($json, 200, array('content-type' => 'application/json'));
|
||||
});
|
||||
|
||||
$controllers->post('/image/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/image/', function(Application $app, Request $request) {
|
||||
$return = array('success' => true);
|
||||
|
||||
$helper = new Helper\Record\Tools($app['Core'], $request);
|
||||
|
||||
$selection = $helper->get_elements();
|
||||
|
||||
if ($request->get('ForceThumbSubstit') == '1')
|
||||
{
|
||||
foreach ($selection as $record)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($request->get('ForceThumbSubstit') == '1') {
|
||||
foreach ($selection as $record) {
|
||||
try {
|
||||
$record->rebuild_subdefs();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$return['success'] = false;
|
||||
$return['message'] = _('an error occured');
|
||||
}
|
||||
@@ -149,22 +131,18 @@ class Tools implements ControllerProviderInterface
|
||||
return new Response($json, 200, array('content-type' => 'application/json'));
|
||||
});
|
||||
|
||||
$controllers->post('/hddoc/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/hddoc/', function(Application $app, Request $request) {
|
||||
$success = false;
|
||||
$errorMessage = "";
|
||||
$fileName = null;
|
||||
|
||||
if ($file = $request->files->get('newHD'))
|
||||
{
|
||||
if ($file = $request->files->get('newHD')) {
|
||||
$fileName = $file->getClientOriginalName();
|
||||
$size = $file->getClientSize();
|
||||
|
||||
if ($size && $fileName && $file->isValid())
|
||||
{
|
||||
if ($size && $fileName && $file->isValid()) {
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$record = new \record_adapter(
|
||||
$request->get('sbas_id')
|
||||
, $request->get('record_id')
|
||||
@@ -175,20 +153,15 @@ class Tools implements ControllerProviderInterface
|
||||
, new \system_file($file->getPathname())
|
||||
);
|
||||
|
||||
if ((int) $request->get('ccfilename') === 1)
|
||||
{
|
||||
if ((int) $request->get('ccfilename') === 1) {
|
||||
$record->set_original_name($fileName);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$errorMessage = _('file is not valid');
|
||||
}
|
||||
}
|
||||
@@ -207,21 +180,17 @@ class Tools implements ControllerProviderInterface
|
||||
*/
|
||||
});
|
||||
|
||||
$controllers->post('/chgthumb/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/chgthumb/', function(Application $app, Request $request) {
|
||||
$success = false;
|
||||
$errorMessage = "";
|
||||
|
||||
if ($file = $request->files->get('newThumb'))
|
||||
{
|
||||
if ($file = $request->files->get('newThumb')) {
|
||||
|
||||
$size = $file->getClientSize();
|
||||
$fileName = $file->getClientOriginalName();
|
||||
|
||||
if ($size && $fileName && $file->isValid())
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($size && $fileName && $file->isValid()) {
|
||||
try {
|
||||
$rootPath = $app['Core']->getRegistry()->get('GV_RootPath');
|
||||
$tmpFile = $rootPath . 'tmp/' . $fileName;
|
||||
rename($file->getPathname(), $tmpFile);
|
||||
@@ -237,14 +206,10 @@ class Tools implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
$success = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$errorMessage = _('file is not valid');
|
||||
}
|
||||
|
||||
@@ -259,22 +224,18 @@ class Tools implements ControllerProviderInterface
|
||||
}
|
||||
});
|
||||
|
||||
$controllers->post('/thumb-extractor/confirm-box/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/thumb-extractor/confirm-box/', function(Application $app, Request $request) {
|
||||
$return = array('error' => false, 'datas' => '');
|
||||
$template = 'prod/actions/Tools/confirm.html.twig';
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$record = new \record_adapter($request->get('sbas_id'), $request->get('record_id'));
|
||||
$var = array(
|
||||
'video_title' => $record->get_title()
|
||||
, 'image' => $request->get('image', '')
|
||||
);
|
||||
$return['datas'] = $app['Core']->getTwig()->render($template, $var);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$return['datas'] = _('an error occured');
|
||||
$return['error'] = true;
|
||||
}
|
||||
@@ -284,12 +245,10 @@ class Tools implements ControllerProviderInterface
|
||||
return new Response($json, 201, array('content-type' => 'application/json'));
|
||||
});
|
||||
|
||||
$controllers->post('/thumb-extractor/apply/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/thumb-extractor/apply/', function(Application $app, Request $request) {
|
||||
$return = array('success' => false, 'message' => '');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$record = new \record_adapter($request->get('sbas_id'), $request->get('record_id'));
|
||||
|
||||
$dataUri = DataURI\Parser::parse($request->get('image', ''));
|
||||
@@ -305,9 +264,7 @@ class Tools implements ControllerProviderInterface
|
||||
$record->substitute_subdef('thumbnail', new \system_file($fileName));
|
||||
|
||||
$return['success'] = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$return['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -318,5 +275,4 @@ class Tools implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,8 +35,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
$app['appbox'] = \appbox::get_instance($app['Core']);
|
||||
|
||||
$controllers->post('/basket/{basket_id}/'
|
||||
, function(Application $app, $basket_id)
|
||||
{
|
||||
, function(Application $app, $basket_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$basket = $em->getRepository('\Entities\Basket')
|
||||
@@ -49,8 +48,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
})->assert('basket_id', '\d+');
|
||||
|
||||
$controllers->post('/Story/{sbas_id}/{record_id}/'
|
||||
, function(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -61,8 +59,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/user/{usr_id}/'
|
||||
, function(Application $app, $usr_id)
|
||||
{
|
||||
, function(Application $app, $usr_id) {
|
||||
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($app['Core']));
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -77,8 +74,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/preview/{sbas_id}/{record_id}/'
|
||||
, function(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $record_id) {
|
||||
$record = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
@@ -96,17 +92,14 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/caption/{sbas_id}/{record_id}/{view}/'
|
||||
, function(Application $app, $sbas_id, $record_id, $view)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $record_id, $view) {
|
||||
$number = (int) $app['request']->get('number');
|
||||
$record = new \record_adapter($sbas_id, $record_id, $number);
|
||||
|
||||
$search_engine = null;
|
||||
|
||||
if($view == 'answer')
|
||||
{
|
||||
if (($search_engine_options = unserialize($app['request']->get('options_serial'))) !== false)
|
||||
{
|
||||
if ($view == 'answer') {
|
||||
if (($search_engine_options = unserialize($app['request']->get('options_serial'))) !== false) {
|
||||
$search_engine = new \searchEngine_adapter($app['appbox']->get_registry());
|
||||
$search_engine->set_options($search_engine_options);
|
||||
}
|
||||
@@ -130,8 +123,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/tc_datas/{sbas_id}/{record_id}/'
|
||||
, function(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $record_id) {
|
||||
$record = new \record_adapter($sbas_id, $record_id);
|
||||
$document = $record->get_subdef('document');
|
||||
|
||||
@@ -148,8 +140,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/metas/FieldInfos/{sbas_id}/{field_id}/'
|
||||
, function(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $field_id) {
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($databox, $field_id);
|
||||
|
||||
@@ -166,8 +157,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/DCESInfos/{sbas_id}/{field_id}/'
|
||||
, function(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $field_id) {
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($databox, $field_id);
|
||||
|
||||
@@ -184,8 +174,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
|
||||
$controllers->post('/metas/restrictionsInfos/{sbas_id}/{field_id}/'
|
||||
, function(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
, function(Application $app, $sbas_id, $field_id) {
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($databox, $field_id);
|
||||
|
||||
@@ -202,5 +191,4 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,12 +35,10 @@ class UserPreferences implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->post('/save/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->post('/save/', function(Application $app, Request $request) {
|
||||
$ret = array('success' => false, 'message' => _('Error while saving preference'));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
$ret = $user->setPrefs($request->get('prop'), $request->get('value'));
|
||||
@@ -51,9 +49,7 @@ class UserPreferences implements ControllerProviderInterface
|
||||
$output = "0";
|
||||
|
||||
$ret = array('success' => true, 'message' => _('Preference saved !'));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -65,5 +61,4 @@ class UserPreferences implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,8 +37,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Get all lists
|
||||
*/
|
||||
$controllers->get('/all/', function(Application $app, Request $request)
|
||||
{
|
||||
$controllers->get('/all/', function(Application $app, Request $request) {
|
||||
|
||||
$datas = array(
|
||||
'success' => false
|
||||
@@ -48,8 +47,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
|
||||
$lists = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
$repository = $em->getRepository('\Entities\UsrList');
|
||||
@@ -58,12 +56,10 @@ class UsrLists implements ControllerProviderInterface
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($lists as $list)
|
||||
{
|
||||
foreach ($lists as $list) {
|
||||
$owners = $entries = array();
|
||||
|
||||
foreach ($list->getOwners() as $owner)
|
||||
{
|
||||
foreach ($list->getOwners() as $owner) {
|
||||
$owners[] = array(
|
||||
'usr_id' => $owner->getUser()->get_id(),
|
||||
'display_name' => $owner->getUser()->get_display_name(),
|
||||
@@ -75,8 +71,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($list->getEntries() as $entry)
|
||||
{
|
||||
foreach ($list->getEntries() as $entry) {
|
||||
$entries[] = array(
|
||||
'usr_id' => $owner->getUser()->get_id(),
|
||||
'display_name' => $owner->getUser()->get_display_name(),
|
||||
@@ -103,27 +98,20 @@ class UsrLists implements ControllerProviderInterface
|
||||
, 'message' => ''
|
||||
, 'result' => $result
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$Json = $app['Core']['Serializer']->serialize($datas, 'json');
|
||||
|
||||
return new Response($Json, 200, array('Content-Type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
|
||||
return new Response($app['Core']->getTwig()->render('prod/actions/Feedback/lists-all.html.twig', array('lists' => $lists)));
|
||||
}
|
||||
@@ -133,8 +121,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Creates a list
|
||||
*/
|
||||
$controllers->post('/list/', function(Application $app)
|
||||
{
|
||||
$controllers->post('/list/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
|
||||
$list_name = $request->get('name');
|
||||
@@ -145,10 +132,8 @@ class UsrLists implements ControllerProviderInterface
|
||||
, 'list_id' => null
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
if (!$list_name)
|
||||
{
|
||||
try {
|
||||
if ( ! $list_name) {
|
||||
throw new ControllerException(_('List name is required'));
|
||||
}
|
||||
|
||||
@@ -173,16 +158,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
, 'message' => sprintf(_('List %s has been created'), $list_name)
|
||||
, 'list_id' => $List->getId()
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -195,8 +176,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Gets a list
|
||||
*/
|
||||
$controllers->get('/list/{list_id}/', function(Application $app, Request $request, $list_id)
|
||||
{
|
||||
$controllers->get('/list/{list_id}/', function(Application $app, Request $request, $list_id) {
|
||||
|
||||
$result = array();
|
||||
|
||||
@@ -210,8 +190,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
$entries = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$owners = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
|
||||
foreach ($list->getOwners() as $owner)
|
||||
{
|
||||
foreach ($list->getOwners() as $owner) {
|
||||
$owners[] = array(
|
||||
'usr_id' => $owner->getUser()->get_id(),
|
||||
'display_name' => $owner->getUser()->get_display_name(),
|
||||
@@ -223,8 +202,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($list->getEntries() as $entry)
|
||||
{
|
||||
foreach ($list->getEntries() as $entry) {
|
||||
$entries[] = array(
|
||||
'usr_id' => $entry->getUser()->get_id(),
|
||||
'display_name' => $entry->getUser()->get_display_name(),
|
||||
@@ -254,8 +232,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Update a list
|
||||
*/
|
||||
$controllers->post('/list/{list_id}/update/', function(Application $app, $list_id)
|
||||
{
|
||||
$controllers->post('/list/{list_id}/update/', function(Application $app, $list_id) {
|
||||
$request = $app['request'];
|
||||
|
||||
$datas = array(
|
||||
@@ -263,12 +240,10 @@ class UsrLists implements ControllerProviderInterface
|
||||
, 'message' => _('Unable to update list')
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$list_name = $request->get('name');
|
||||
|
||||
if (!$list_name)
|
||||
{
|
||||
if ( ! $list_name) {
|
||||
throw new ControllerException(_('List name is required'));
|
||||
}
|
||||
|
||||
@@ -279,8 +254,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
|
||||
if($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR) {
|
||||
throw new ControllerException(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
@@ -292,16 +266,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
'success' => true
|
||||
, 'message' => _('List has been updated')
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -314,20 +284,17 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Delete a list
|
||||
*/
|
||||
$controllers->post('/list/{list_id}/delete/', function(Application $app, $list_id)
|
||||
{
|
||||
$controllers->post('/list/{list_id}/delete/', function(Application $app, $list_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$repository = $em->getRepository('\Entities\UsrList');
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
|
||||
if($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_ADMIN)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_ADMIN) {
|
||||
throw new ControllerException(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
@@ -338,16 +305,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
'success' => true
|
||||
, 'message' => sprintf(_('List has been deleted'))
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$datas = array(
|
||||
'success' => false
|
||||
@@ -365,12 +328,10 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Remove a usr_id from a list
|
||||
*/
|
||||
$controllers->post('/list/{list_id}/remove/{usr_id}/', function(Application $app, $list_id, $usr_id)
|
||||
{
|
||||
$controllers->post('/list/{list_id}/remove/{usr_id}/', function(Application $app, $list_id, $usr_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$repository = $em->getRepository('\Entities\UsrList');
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
@@ -378,8 +339,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
/* @var $list \Entities\UsrList */
|
||||
|
||||
if($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR) {
|
||||
throw new ControllerException(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
@@ -394,16 +354,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
'success' => true
|
||||
, 'message' => _('Entry removed from list')
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$datas = array(
|
||||
'success' => false
|
||||
@@ -420,15 +376,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Adds a usr_id to a list
|
||||
*/
|
||||
$controllers->post('/list/{list_id}/add/', function(Application $app, Request $request, $list_id)
|
||||
{
|
||||
$controllers->post('/list/{list_id}/add/', function(Application $app, Request $request, $list_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
try
|
||||
{
|
||||
if (!is_array($request->get('usr_ids')))
|
||||
{
|
||||
try {
|
||||
if ( ! is_array($request->get('usr_ids'))) {
|
||||
throw new Controller\Exception('Invalid or missing parameter usr_ids');
|
||||
}
|
||||
|
||||
@@ -437,15 +390,13 @@ class UsrLists implements ControllerProviderInterface
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
/* @var $list \Entities\UsrList */
|
||||
|
||||
if($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR) {
|
||||
throw new ControllerException(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
$inserted_usr_ids = array();
|
||||
|
||||
foreach ($request->get('usr_ids') as $usr_id)
|
||||
{
|
||||
foreach ($request->get('usr_ids') as $usr_id) {
|
||||
$user_entry = \User_Adapter::getInstance($usr_id, \appbox::get_instance($app['Core']));
|
||||
|
||||
if ($list->has($user_entry))
|
||||
@@ -464,32 +415,25 @@ class UsrLists implements ControllerProviderInterface
|
||||
|
||||
$em->flush();
|
||||
|
||||
if (count($inserted_usr_ids) > 1)
|
||||
{
|
||||
if (count($inserted_usr_ids) > 1) {
|
||||
$datas = array(
|
||||
'success' => true
|
||||
, 'message' => sprintf(_('%d Users added to list'), count($inserted_usr_ids))
|
||||
, 'result' => $inserted_usr_ids
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$datas = array(
|
||||
'success' => true
|
||||
, 'message' => sprintf(_('%d User added to list'), count($inserted_usr_ids))
|
||||
, 'result' => $inserted_usr_ids
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$datas = array(
|
||||
'success' => false
|
||||
@@ -503,30 +447,24 @@ class UsrLists implements ControllerProviderInterface
|
||||
}
|
||||
)->assert('list_id', '\d+')->assert('usr_id', '\d+');
|
||||
|
||||
$controllers->get('/list/{list_id}/share/', function(Application $app, Request $request, $list_id)
|
||||
{
|
||||
$controllers->get('/list/{list_id}/share/', function(Application $app, Request $request, $list_id) {
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
$list = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$repository = $em->getRepository('\Entities\UsrList');
|
||||
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
/* @var $list \Entities\UsrList */
|
||||
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_ADMIN)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_ADMIN) {
|
||||
$list = null;
|
||||
throw new \Exception(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -536,8 +474,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* Share a list to a user with an optionnal role
|
||||
*/
|
||||
$controllers->post('/list/{list_id}/share/{usr_id}/', function(Application $app, $list_id, $usr_id)
|
||||
{
|
||||
$controllers->post('/list/{list_id}/share/{usr_id}/', function(Application $app, $list_id, $usr_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
@@ -547,36 +484,30 @@ class UsrLists implements ControllerProviderInterface
|
||||
\Entities\UsrListOwner::ROLE_ADMIN,
|
||||
);
|
||||
|
||||
if (!$app['request']->get('role'))
|
||||
if ( ! $app['request']->get('role'))
|
||||
throw new \Exception_BadRequest('Missing role parameter');
|
||||
elseif (!in_array($app['request']->get('role'), $availableRoles))
|
||||
elseif ( ! in_array($app['request']->get('role'), $availableRoles))
|
||||
throw new \Exception_BadRequest('Role is invalid');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$repository = $em->getRepository('\Entities\UsrList');
|
||||
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
/* @var $list \Entities\UsrList */
|
||||
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_EDITOR) {
|
||||
throw new ControllerException(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
$new_owner = \User_Adapter::getInstance($usr_id, \appbox::get_instance($app['Core']));
|
||||
|
||||
if ($list->hasAccess($new_owner))
|
||||
{
|
||||
if($new_owner->get_id() == $user->get_id())
|
||||
{
|
||||
if ($list->hasAccess($new_owner)) {
|
||||
if ($new_owner->get_id() == $user->get_id()) {
|
||||
throw new ControllerException('You can not downgrade your Admin right');
|
||||
}
|
||||
|
||||
$owner = $list->getOwner($new_owner);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$owner = new \Entities\UsrListOwner();
|
||||
$owner->setList($list);
|
||||
$owner->setUser($new_owner);
|
||||
@@ -596,16 +527,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
'success' => true
|
||||
, 'message' => _('List shared to user')
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$datas = array(
|
||||
'success' => false
|
||||
@@ -621,20 +548,17 @@ class UsrLists implements ControllerProviderInterface
|
||||
/**
|
||||
* UnShare a list to a user
|
||||
*/
|
||||
$controllers->post('/list/{list_id}/unshare/{usr_id}/', function(Application $app, $list_id, $usr_id)
|
||||
{
|
||||
$controllers->post('/list/{list_id}/unshare/{usr_id}/', function(Application $app, $list_id, $usr_id) {
|
||||
$em = $app['Core']->getEntityManager();
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$repository = $em->getRepository('\Entities\UsrList');
|
||||
|
||||
$list = $repository->findUserListByUserAndId($user, $list_id);
|
||||
/* @var $list \Entities\UsrList */
|
||||
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_ADMIN)
|
||||
{
|
||||
if ($list->getOwner($user)->getRole() < \Entities\UsrListOwner::ROLE_ADMIN) {
|
||||
throw new \Exception(_('You are not authorized to do this'));
|
||||
}
|
||||
|
||||
@@ -649,16 +573,12 @@ class UsrLists implements ControllerProviderInterface
|
||||
'success' => true
|
||||
, 'message' => _('Owner removed from list')
|
||||
);
|
||||
}
|
||||
catch (ControllerException $e)
|
||||
{
|
||||
} catch (ControllerException $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => $e->getMessage()
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$datas = array(
|
||||
'success' => false
|
||||
, 'message' => _('Unable to remove usr from list')
|
||||
@@ -674,5 +594,4 @@ class UsrLists implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,8 +35,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/', function(Application $app) {
|
||||
$params = array(
|
||||
'WorkZone' => new Helper\WorkZone($app['Core'], $app['request'])
|
||||
, 'selected_type' => $app['request']->get('type')
|
||||
@@ -48,8 +47,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
return new Response($app['Core']->getTwig()->render('prod/WorkZone/WorkZone.html.twig', $params));
|
||||
});
|
||||
|
||||
$controllers->get('/Browse/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/Browse/', function(Application $app) {
|
||||
$date_obj = new \DateTime();
|
||||
|
||||
$params = array(
|
||||
@@ -63,8 +61,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->get('/Browse/Search/', function(Application $app)
|
||||
{
|
||||
$controllers->get('/Browse/Search/', function(Application $app) {
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
|
||||
@@ -107,8 +104,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
return new Response($app['Core']->getTwig()->render('prod/WorkZone/Browser/Results.html.twig', $params));
|
||||
});
|
||||
|
||||
$controllers->get('/Browse/Basket/{basket_id}/', function(Application $app, Request $request, $basket_id)
|
||||
{
|
||||
$controllers->get('/Browse/Basket/{basket_id}/', function(Application $app, Request $request, $basket_id) {
|
||||
|
||||
$em = $app['Core']->getEntityManager();
|
||||
|
||||
@@ -125,9 +121,8 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
$controllers->post(
|
||||
'/attachStories/'
|
||||
, function(Application $app, Request $request)
|
||||
{
|
||||
if (!$request->get('stories'))
|
||||
, function(Application $app, Request $request) {
|
||||
if ( ! $request->get('stories'))
|
||||
throw new \Exception_BadRequest();
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
@@ -141,21 +136,19 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
$stories = $request->get('stories', array());
|
||||
|
||||
foreach ($stories as $element)
|
||||
{
|
||||
foreach ($stories as $element) {
|
||||
$element = explode('_', $element);
|
||||
$Story = new \record_adapter($element[0], $element[1]);
|
||||
|
||||
if (!$Story->is_grouping())
|
||||
if ( ! $Story->is_grouping())
|
||||
throw new \Exception('You can only attach stories');
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($Story->get_base_id()))
|
||||
if ( ! $user->ACL()->has_access_to_base($Story->get_base_id()))
|
||||
throw new \Exception_Forbidden('You do not have access to this Story');
|
||||
|
||||
|
||||
if ($StoryWZRepo->findUserStory($user, $Story))
|
||||
{
|
||||
$alreadyFixed++;
|
||||
if ($StoryWZRepo->findUserStory($user, $Story)) {
|
||||
$alreadyFixed ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -164,40 +157,31 @@ class WorkZone implements ControllerProviderInterface
|
||||
$StoryWZ->setRecord($Story);
|
||||
|
||||
$em->persist($StoryWZ);
|
||||
$done++;
|
||||
$done ++;
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
if ($alreadyFixed === 0)
|
||||
{
|
||||
if ($done <= 1)
|
||||
{
|
||||
if ($alreadyFixed === 0) {
|
||||
if ($done <= 1) {
|
||||
$message = sprintf(
|
||||
_('%d Story attached to the WorkZone')
|
||||
, $done
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = sprintf(
|
||||
_('%d Stories attached to the WorkZone')
|
||||
, $done
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($done <= 1)
|
||||
{
|
||||
} else {
|
||||
if ($done <= 1) {
|
||||
$message = sprintf(
|
||||
_('%1$d Story attached to the WorkZone, %2$d already attached')
|
||||
, $done
|
||||
, $alreadyFixed
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = sprintf(
|
||||
_('%1$d Stories attached to the WorkZone, %2$d already attached')
|
||||
, $done
|
||||
@@ -211,15 +195,12 @@ class WorkZone implements ControllerProviderInterface
|
||||
, 'message' => $message
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/{sbas_id}/{record_id}/');
|
||||
}
|
||||
});
|
||||
@@ -227,8 +208,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
$controllers->post(
|
||||
'/detachStory/{sbas_id}/{record_id}/'
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id)
|
||||
{
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($sbas_id, $record_id);
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
@@ -240,8 +220,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\StoryWZRepository */
|
||||
$StoryWZ = $repository->findUserStory($user, $Story);
|
||||
|
||||
if (!$StoryWZ)
|
||||
{
|
||||
if ( ! $StoryWZ) {
|
||||
throw new \Exception_NotFound('Story not found');
|
||||
}
|
||||
$em->remove($StoryWZ);
|
||||
@@ -253,14 +232,11 @@ class WorkZone implements ControllerProviderInterface
|
||||
, 'message' => _('Story detached from the WorkZone')
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json')
|
||||
{
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$datas = $app['Core']['Serializer']->serialize($data, 'json');
|
||||
|
||||
return new Response($datas, 200, array('Content-type' => 'application/json'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
@@ -268,5 +244,4 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,8 +25,6 @@ use Silex\ControllerCollection;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
|
||||
class RSSFeeds implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
@@ -36,26 +34,22 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$display_feed = function($feed, $format, $page, $user = null)
|
||||
{
|
||||
$display_feed = function($feed, $format, $page, $user = null) {
|
||||
$total = $feed->get_count_total_entries();
|
||||
$perPage = 5;
|
||||
$entries = $feed->get_entries((($page - 1) * $perPage), $perPage);
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
|
||||
if ($format == \Feed_Adapter::FORMAT_RSS)
|
||||
{
|
||||
if ($format == \Feed_Adapter::FORMAT_RSS) {
|
||||
$content = new \Feed_XML_RSS();
|
||||
}
|
||||
|
||||
if ($format == \Feed_Adapter::FORMAT_ATOM)
|
||||
{
|
||||
if ($format == \Feed_Adapter::FORMAT_ATOM) {
|
||||
$content = new \Feed_XML_Atom();
|
||||
}
|
||||
|
||||
if($format == \Feed_Adapter::FORMAT_COOLIRIS)
|
||||
{
|
||||
if ($format == \Feed_Adapter::FORMAT_COOLIRIS) {
|
||||
$content = new \Feed_XML_Cooliris();
|
||||
}
|
||||
|
||||
@@ -70,15 +64,13 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
$content->set_generator('Phraseanet');
|
||||
$content->set_link($link);
|
||||
|
||||
if ($user instanceof \User_Adapter)
|
||||
{
|
||||
if ($user instanceof \User_Adapter) {
|
||||
if ($page > 1)
|
||||
$content->set_previous_page($feed->get_user_link($registry, $user, $format, ($page - 1)));
|
||||
if ($total > ($page * $perPage))
|
||||
$content->set_next_page($feed->get_user_link($registry, $user, $format, ($page + 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if ($page > 1)
|
||||
$content->set_previous_page($feed->get_homepage_link($registry, $format, ($page - 1)));
|
||||
if ($total > ($page * $perPage))
|
||||
@@ -96,12 +88,10 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
|
||||
|
||||
|
||||
$controllers->get('/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed)
|
||||
{
|
||||
$controllers->get('/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed) {
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
|
||||
if (!$feed->is_public())
|
||||
{
|
||||
if ( ! $feed->is_public()) {
|
||||
return new Response('Forbidden', 403);
|
||||
}
|
||||
|
||||
@@ -115,15 +105,11 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
|
||||
|
||||
|
||||
$controllers->get('/userfeed/{token}/{id}/{format}/', function($token, $id, $format) use ($app, $appbox, $display_feed)
|
||||
{
|
||||
try
|
||||
{
|
||||
$controllers->get('/userfeed/{token}/{id}/{format}/', function($token, $id, $format) use ($app, $appbox, $display_feed) {
|
||||
try {
|
||||
$token = new \Feed_Token($appbox, $token, $id);
|
||||
$feed = $token->get_feed();
|
||||
}
|
||||
catch (\Exception_FeedNotFound $e)
|
||||
{
|
||||
} catch (\Exception_FeedNotFound $e) {
|
||||
return new Response('Not Found', 404);
|
||||
}
|
||||
$request = $app['request'];
|
||||
@@ -136,15 +122,11 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
|
||||
|
||||
|
||||
$controllers->get('/userfeed/aggregated/{token}/{format}/', function($token, $format) use ($app, $appbox, $display_feed)
|
||||
{
|
||||
try
|
||||
{
|
||||
$controllers->get('/userfeed/aggregated/{token}/{format}/', function($token, $format) use ($app, $appbox, $display_feed) {
|
||||
try {
|
||||
$token = new \Feed_TokenAggregate($appbox, $token);
|
||||
$feed = $token->get_feed();
|
||||
}
|
||||
catch (\Exception_FeedNotFound $e)
|
||||
{
|
||||
} catch (\Exception_FeedNotFound $e) {
|
||||
return new Response('', 404);
|
||||
}
|
||||
|
||||
@@ -158,8 +140,7 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
|
||||
|
||||
|
||||
$controllers->get('/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed)
|
||||
{
|
||||
$controllers->get('/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed) {
|
||||
$feeds = \Feed_Collection::load_public_feeds($appbox);
|
||||
$feed = $feeds->get_aggregate();
|
||||
|
||||
@@ -178,10 +159,9 @@ class RSSFeeds implements ControllerProviderInterface
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page < 1 ? 1 : $page;
|
||||
|
||||
return $display_feed($feed, \Feed_Adapter::FORMAT_COOLIRIS , $page);
|
||||
return $display_feed($feed, \Feed_Adapter::FORMAT_COOLIRIS, $page);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -32,8 +32,7 @@ class Installer implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/', function() use ($app) {
|
||||
$request = $app['request'];
|
||||
|
||||
$php_constraint = \setup::check_php_version();
|
||||
@@ -53,22 +52,18 @@ class Installer implements ControllerProviderInterface
|
||||
);
|
||||
$redirect = true;
|
||||
|
||||
foreach ($constraints_coll as $key => $constraints)
|
||||
{
|
||||
foreach ($constraints_coll as $key => $constraints) {
|
||||
$unset = true;
|
||||
foreach ($constraints as $constraint)
|
||||
{
|
||||
if (!$constraint->is_ok() && $constraint->is_blocker())
|
||||
foreach ($constraints as $constraint) {
|
||||
if ( ! $constraint->is_ok() && $constraint->is_blocker())
|
||||
$redirect = $unset = false;
|
||||
}
|
||||
if ($unset === true)
|
||||
{
|
||||
if ($unset === true) {
|
||||
unset($constraints_coll[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($redirect)
|
||||
{
|
||||
if ($redirect) {
|
||||
return $app->redirect('/setup/installer/step2/');
|
||||
}
|
||||
|
||||
@@ -91,8 +86,7 @@ class Installer implements ControllerProviderInterface
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->get('/step2/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/step2/', function() use ($app) {
|
||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||
|
||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
||||
@@ -121,20 +115,16 @@ class Installer implements ControllerProviderInterface
|
||||
, 'locales_constraints' => $locales_constraints
|
||||
);
|
||||
|
||||
foreach ($constraints_coll as $key => $constraints)
|
||||
{
|
||||
foreach ($constraints_coll as $key => $constraints) {
|
||||
$unset = true;
|
||||
foreach ($constraints as $constraint)
|
||||
{
|
||||
if (!$constraint->is_ok() && !$constraint->is_blocker())
|
||||
{
|
||||
foreach ($constraints as $constraint) {
|
||||
if ( ! $constraint->is_ok() && ! $constraint->is_blocker()) {
|
||||
$warnings[] = $constraint->get_message();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->getScheme() == 'http')
|
||||
{
|
||||
if ($request->getScheme() == 'http') {
|
||||
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
||||
}
|
||||
|
||||
@@ -157,8 +147,7 @@ class Installer implements ControllerProviderInterface
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->post('/install/', function() use ($app)
|
||||
{
|
||||
$controllers->post('/install/', function() use ($app) {
|
||||
set_time_limit(360);
|
||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||
$request = $app['request'];
|
||||
@@ -178,31 +167,23 @@ class Installer implements ControllerProviderInterface
|
||||
$appbox_name = $request->get('ab_name');
|
||||
$databox_name = $request->get('db_name');
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name, array(), $setupRegistry);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/setup/installer/step2/?error=' . _('Appbox is unreachable'));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ($databox_name)
|
||||
{
|
||||
try {
|
||||
if ($databox_name) {
|
||||
$connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name, array(), $setupRegistry);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
|
||||
}
|
||||
|
||||
\setup::rollback($conn, $connbas);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$setupRegistry = new \Setup_Registry();
|
||||
$setupRegistry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
||||
|
||||
@@ -210,8 +191,7 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
||||
|
||||
if ($configuration->isInstalled())
|
||||
{
|
||||
if ($configuration->isInstalled()) {
|
||||
$serviceName = $configuration->getOrm();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
@@ -220,16 +200,14 @@ class Installer implements ControllerProviderInterface
|
||||
, $confService
|
||||
);
|
||||
|
||||
if ($ormService->getType() === 'doctrine')
|
||||
{
|
||||
if ($ormService->getType() === 'doctrine') {
|
||||
/* @var $em \Doctrine\ORM\EntityManager */
|
||||
|
||||
$em = $ormService->getDriver();
|
||||
|
||||
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
||||
|
||||
if (!empty($metadatas))
|
||||
{
|
||||
if ( ! empty($metadatas)) {
|
||||
// Create SchemaTool
|
||||
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
|
||||
// Create schema
|
||||
@@ -269,10 +247,8 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
$appbox->get_session()->authenticate($auth);
|
||||
|
||||
if (!\p4string::hasAccent($databox_name))
|
||||
{
|
||||
if ($databox_name)
|
||||
{
|
||||
if ( ! \p4string::hasAccent($databox_name)) {
|
||||
if ($databox_name) {
|
||||
$template = new \system_file(__DIR__ . '/../../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
||||
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
||||
$user->ACL()
|
||||
@@ -297,16 +273,13 @@ class Installer implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
$tasks = $request->get('create_task', array());
|
||||
foreach ($tasks as $task)
|
||||
{
|
||||
switch ($task)
|
||||
{
|
||||
foreach ($tasks as $task) {
|
||||
switch ($task) {
|
||||
case 'cindexer';
|
||||
case 'subdef';
|
||||
case 'writemeta';
|
||||
$class_name = sprintf('task_period_%s', $task);
|
||||
if ($task === 'cindexer')
|
||||
{
|
||||
if ($task === 'cindexer') {
|
||||
$credentials = $databox->get_connection()->get_credentials();
|
||||
|
||||
$host = $credentials['hostname'];
|
||||
@@ -323,9 +296,7 @@ class Installer implements ControllerProviderInterface
|
||||
. $password . "</password><socket>25200</socket>"
|
||||
. "<use_sbas>1</use_sbas><nolog>0</nolog><clng></clng>"
|
||||
. "<winsvc_run>0</winsvc_run><charset>utf8</charset></tasksettings>";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$settings = null;
|
||||
}
|
||||
|
||||
@@ -341,9 +312,7 @@ class Installer implements ControllerProviderInterface
|
||||
$redirection = '/admin/?section=taskmanager¬ice=install_success';
|
||||
|
||||
return $app->redirect($redirection);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
\setup::rollback($conn, $connbas);
|
||||
}
|
||||
|
||||
@@ -352,5 +321,4 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -32,8 +32,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/', function() use ($app) {
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
$upgrade_status = \Setup_Upgrade::get_status();
|
||||
|
||||
@@ -56,8 +55,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->get('/status/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/status/', function() use ($app) {
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
|
||||
$datas = \Setup_Upgrade::get_status();
|
||||
@@ -71,8 +69,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->post('/execute/', function() use ($app)
|
||||
{
|
||||
$controllers->post('/execute/', function() use ($app) {
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
set_time_limit(0);
|
||||
session_write_close();
|
||||
@@ -87,5 +84,4 @@ class Upgrader implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -32,8 +32,7 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/mysql/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/mysql/', function() use ($app) {
|
||||
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||
|
||||
$request = $app['request'];
|
||||
@@ -45,20 +44,15 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
|
||||
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password);
|
||||
$connection_ok = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
if ($dbname && $connection_ok === true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($dbname && $connection_ok === true) {
|
||||
try {
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname);
|
||||
$db_ok = true;
|
||||
|
||||
@@ -71,20 +65,15 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
if ($row["Name"] === 'sitepreff')
|
||||
{
|
||||
foreach ($rs as $row) {
|
||||
if ($row["Name"] === 'sitepreff') {
|
||||
$is_appbox = true;
|
||||
}
|
||||
if ($row["Name"] === 'pref')
|
||||
{
|
||||
if ($row["Name"] === 'pref') {
|
||||
$is_databox = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -108,6 +97,5 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -32,8 +32,7 @@ class PathFileTest implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/path/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/path/', function() use ($app) {
|
||||
$path = $app['request']->get('path');
|
||||
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
@@ -55,8 +54,7 @@ class PathFileTest implements ControllerProviderInterface
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->get('/url/', function() use ($app)
|
||||
{
|
||||
$controllers->get('/url/', function() use ($app) {
|
||||
$url = $app['request']->get('url');
|
||||
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
@@ -76,5 +74,4 @@ class PathFileTest implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,7 +37,6 @@ require_once __DIR__ . '/Core/Configuration/ApplicationSpecification.php';
|
||||
*/
|
||||
class Core extends \Pimple
|
||||
{
|
||||
|
||||
protected static $availableLanguages = array(
|
||||
'ar_SA' => 'العربية'
|
||||
, 'de_DE' => 'Deutsch'
|
||||
@@ -45,7 +44,6 @@ class Core extends \Pimple
|
||||
, 'es_ES' => 'Español'
|
||||
, 'fr_FR' => 'Français'
|
||||
);
|
||||
|
||||
protected static $autoloader_initialized = false;
|
||||
|
||||
/**
|
||||
@@ -70,34 +68,26 @@ class Core extends \Pimple
|
||||
/**
|
||||
* Set version
|
||||
*/
|
||||
$this['Version'] = $this->share(function()
|
||||
{
|
||||
$this['Version'] = $this->share(function() {
|
||||
return new Core\Version();
|
||||
});
|
||||
|
||||
if ($this->configuration->isInstalled())
|
||||
{
|
||||
$this['Registry'] = $this->share(function() use ($core)
|
||||
{
|
||||
if ($this->configuration->isInstalled()) {
|
||||
$this['Registry'] = $this->share(function() use ($core) {
|
||||
return \registry::get_instance($core);
|
||||
});
|
||||
|
||||
\phrasea::start($this);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
|
||||
$this['Registry'] = $this->share(function()
|
||||
{
|
||||
$this['Registry'] = $this->share(function() {
|
||||
return new \Setup_Registry();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$this['CacheService'] = $this->share(function() use ($core)
|
||||
{
|
||||
if ( ! file_exists(__DIR__ . '/../../../tmp/cache_registry.yml'))
|
||||
{
|
||||
$this['CacheService'] = $this->share(function() use ($core) {
|
||||
if ( ! file_exists(__DIR__ . '/../../../tmp/cache_registry.yml')) {
|
||||
touch(__DIR__ . '/../../../tmp/cache_registry.yml');
|
||||
}
|
||||
|
||||
@@ -109,8 +99,7 @@ class Core extends \Pimple
|
||||
/**
|
||||
* Set Entity Manager using configuration
|
||||
*/
|
||||
$this['EM'] = $this->share(function() use ($core)
|
||||
{
|
||||
$this['EM'] = $this->share(function() use ($core) {
|
||||
$serviceName = $core->getConfiguration()->getOrm();
|
||||
$configuration = $core->getConfiguration()->getService($serviceName);
|
||||
|
||||
@@ -120,15 +109,13 @@ class Core extends \Pimple
|
||||
});
|
||||
|
||||
|
||||
$this['Cache'] = $this->share(function() use ($core)
|
||||
{
|
||||
$this['Cache'] = $this->share(function() use ($core) {
|
||||
$serviceName = $core->getConfiguration()->getCache();
|
||||
|
||||
return $core['CacheService']->get('MainCache', $serviceName)->getDriver();
|
||||
});
|
||||
|
||||
$this['OpcodeCache'] = $this->share(function() use ($core)
|
||||
{
|
||||
$this['OpcodeCache'] = $this->share(function() use ($core) {
|
||||
$serviceName = $core->getConfiguration()->getOpcodeCache();
|
||||
|
||||
return $core['CacheService']->get('OpcodeCache', $serviceName)->getDriver();
|
||||
@@ -136,8 +123,7 @@ class Core extends \Pimple
|
||||
|
||||
|
||||
|
||||
$this["Twig"] = $this->share(function() use ($core)
|
||||
{
|
||||
$this["Twig"] = $this->share(function() use ($core) {
|
||||
$serviceName = $core->getConfiguration()->getTemplating();
|
||||
$configuration = $core->getConfiguration()->getService($serviceName);
|
||||
|
||||
@@ -147,8 +133,7 @@ class Core extends \Pimple
|
||||
});
|
||||
|
||||
|
||||
$this['Serializer'] = $this->share(function()
|
||||
{
|
||||
$this['Serializer'] = $this->share(function() {
|
||||
$encoders = array(
|
||||
'json' => new Serializer\Encoder\JsonEncoder()
|
||||
);
|
||||
@@ -156,8 +141,7 @@ class Core extends \Pimple
|
||||
return new Serializer\Serializer(array(), $encoders);
|
||||
});
|
||||
|
||||
$this['monolog'] = $this->share(function () use ($core)
|
||||
{
|
||||
$this['monolog'] = $this->share(function () use ($core) {
|
||||
$logger = new \Monolog\Logger('Logger');
|
||||
|
||||
$logger->pushHandler(new \Monolog\Handler\NullHandler());
|
||||
@@ -165,8 +149,7 @@ class Core extends \Pimple
|
||||
return $logger;
|
||||
});
|
||||
|
||||
$this['media-alchemyst'] = $this->share(function () use ($core)
|
||||
{
|
||||
$this['media-alchemyst'] = $this->share(function () use ($core) {
|
||||
$conf = $core->getConfiguration()->has('media-alchemyst') ? $core->getConfiguration()->get('media-alchemyst') : new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(array());
|
||||
|
||||
$drivers = new \MediaAlchemyst\DriversContainer($conf, $core['monolog']);
|
||||
@@ -199,15 +182,11 @@ class Core extends \Pimple
|
||||
*/
|
||||
private function init()
|
||||
{
|
||||
if ($this->configuration->isInstalled())
|
||||
{
|
||||
if ($this->configuration->isDisplayingErrors())
|
||||
{
|
||||
if ($this->configuration->isInstalled()) {
|
||||
if ($this->configuration->isDisplayingErrors()) {
|
||||
ini_set('display_errors', 'on');
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ini_set('display_errors', 'off');
|
||||
}
|
||||
}
|
||||
@@ -295,8 +274,7 @@ class Core extends \Pimple
|
||||
$appbox = \appbox::get_instance($this);
|
||||
$session = \Session_Handler::getInstance($appbox);
|
||||
|
||||
if ($session->get_usr_id())
|
||||
{
|
||||
if ($session->get_usr_id()) {
|
||||
return \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||
}
|
||||
|
||||
@@ -325,7 +303,6 @@ class Core extends \Pimple
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
protected $request;
|
||||
|
||||
protected function getRequest()
|
||||
@@ -368,12 +345,9 @@ class Core extends \Pimple
|
||||
|
||||
ini_set('error_log', $php_log);
|
||||
|
||||
if ($this->getRegistry()->get('GV_log_errors'))
|
||||
{
|
||||
if ($this->getRegistry()->get('GV_log_errors')) {
|
||||
ini_set('log_errors', 'on');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ini_set('log_errors', 'off');
|
||||
}
|
||||
|
||||
@@ -402,8 +376,7 @@ class Core extends \Pimple
|
||||
|
||||
$cookies = $this->getRequest()->cookies;
|
||||
|
||||
if (isset(static::$availableLanguages[$cookies->get('locale')]))
|
||||
{
|
||||
if (isset(static::$availableLanguages[$cookies->get('locale')])) {
|
||||
$this->getRequest()->setLocale($cookies->get('locale'));
|
||||
}
|
||||
|
||||
@@ -418,42 +391,33 @@ class Core extends \Pimple
|
||||
*/
|
||||
public static function initAutoloads($cacheAutoload = false)
|
||||
{
|
||||
if (static::$autoloader_initialized)
|
||||
{
|
||||
if (static::$autoloader_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/Loader/Autoloader.php';
|
||||
|
||||
if ($cacheAutoload === true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($cacheAutoload === true) {
|
||||
try {
|
||||
require_once __DIR__ . '/Loader/CacheAutoloader.php';
|
||||
|
||||
$prefix = 'class_';
|
||||
$namespace = md5(__DIR__);
|
||||
|
||||
$loader = new Loader\CacheAutoloader($prefix, $namespace);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
//no op code cache available
|
||||
$loader = new Loader\Autoloader();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$loader = new Loader\Autoloader();
|
||||
}
|
||||
|
||||
$getComposerNamespaces = function()
|
||||
{
|
||||
$getComposerNamespaces = function() {
|
||||
return require realpath(__DIR__ . '/../../../vendor/.composer/autoload_namespaces.php');
|
||||
};
|
||||
|
||||
foreach ($getComposerNamespaces() as $prefix => $path)
|
||||
{
|
||||
foreach ($getComposerNamespaces() as $prefix => $path) {
|
||||
if (substr($prefix, -1) === '_')
|
||||
$loader->registerPrefix($prefix, $path);
|
||||
else
|
||||
@@ -488,8 +452,7 @@ class Core extends \Pimple
|
||||
{
|
||||
ini_set('output_buffering', '4096');
|
||||
|
||||
if ((int) ini_get('memory_limit') < 2048)
|
||||
{
|
||||
if ((int) ini_get('memory_limit') < 2048) {
|
||||
ini_set('memory_limit', '2048M');
|
||||
}
|
||||
|
||||
@@ -514,5 +477,4 @@ class Core extends \Pimple
|
||||
{
|
||||
return $this->configuration->getEnvironnement();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ use Alchemy\Phrasea\Core\Configuration\ApplicationSpecification;
|
||||
*/
|
||||
class Configuration
|
||||
{
|
||||
|
||||
/**
|
||||
* The finale configuration values as an array
|
||||
* @var ParameterBag\ParameterBag
|
||||
@@ -45,8 +44,7 @@ class Configuration
|
||||
*/
|
||||
public static function build($specifications = null, $environment = null)
|
||||
{
|
||||
if ( ! $specifications)
|
||||
{
|
||||
if ( ! $specifications) {
|
||||
$specifications = new Configuration\ApplicationSpecification();
|
||||
}
|
||||
|
||||
@@ -63,13 +61,10 @@ class Configuration
|
||||
{
|
||||
$this->specifications = $specifications;
|
||||
|
||||
if ($specifications->isSetup())
|
||||
{
|
||||
if ($specifications->isSetup()) {
|
||||
$configurations = $this->specifications->getConfigurations();
|
||||
$environment = $environment ? : $configurations[self::KEYWORD_ENV];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$environment = null;
|
||||
}
|
||||
|
||||
@@ -82,8 +77,7 @@ class Configuration
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
$retrieve_old_credentials = function(\SplFileObject $connexionInc)
|
||||
{
|
||||
$retrieve_old_credentials = function(\SplFileObject $connexionInc) {
|
||||
require $connexionInc->getPathname();
|
||||
|
||||
return array(
|
||||
@@ -99,8 +93,7 @@ class Configuration
|
||||
|
||||
$connexions = $this->getConnexions();
|
||||
|
||||
foreach ($credentials as $key => $value)
|
||||
{
|
||||
foreach ($credentials as $key => $value) {
|
||||
$key = $key == 'hostname' ? 'host' : $key;
|
||||
$connexions['main_connexion'][$key] = (string) $value;
|
||||
}
|
||||
@@ -110,8 +103,7 @@ class Configuration
|
||||
|
||||
$configs = $this->getConfigurations();
|
||||
|
||||
$retrieve_old_parameters = function(\SplFileObject $configInc)
|
||||
{
|
||||
$retrieve_old_parameters = function(\SplFileObject $configInc) {
|
||||
require $configInc->getPathname();
|
||||
|
||||
return array(
|
||||
@@ -121,10 +113,8 @@ class Configuration
|
||||
|
||||
$old_parameters = $retrieve_old_parameters($configInc);
|
||||
|
||||
foreach ($configs as $env => $conf)
|
||||
{
|
||||
if ( ! is_array($configs[$env]) || ! array_key_exists('phraseanet', $configs[$env]))
|
||||
{
|
||||
foreach ($configs as $env => $conf) {
|
||||
if ( ! is_array($configs[$env]) || ! array_key_exists('phraseanet', $configs[$env])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -168,19 +158,15 @@ class Configuration
|
||||
{
|
||||
$this->environment = $environment;
|
||||
|
||||
if ($this->specifications->isSetup())
|
||||
{
|
||||
if ($this->specifications->isSetup()) {
|
||||
$configurations = $this->specifications->getConfigurations();
|
||||
|
||||
if ( ! isset($configurations[$this->environment]))
|
||||
{
|
||||
if ( ! isset($configurations[$this->environment])) {
|
||||
throw new \Exception('Requested environnment is not available');
|
||||
}
|
||||
|
||||
$this->configuration = new ParameterBag($configurations[$this->environment]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->configuration = new ParameterBag(array());
|
||||
}
|
||||
|
||||
@@ -196,12 +182,9 @@ class Configuration
|
||||
{
|
||||
$phraseanet = $this->getPhraseanet();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$debug = ! ! $phraseanet->get('debug');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$debug = false;
|
||||
}
|
||||
|
||||
@@ -217,12 +200,9 @@ class Configuration
|
||||
{
|
||||
$phraseanet = $this->getPhraseanet();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$maintained = ! ! $phraseanet->get('maintenance');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$maintained = false;
|
||||
}
|
||||
|
||||
@@ -238,12 +218,9 @@ class Configuration
|
||||
{
|
||||
$phraseanet = $this->getPhraseanet();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$displayErrors = ! ! $phraseanet->get('display_errors');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$displayErrors = false;
|
||||
}
|
||||
|
||||
@@ -306,7 +283,6 @@ class Configuration
|
||||
{
|
||||
return $this->specifications->getConnexions();
|
||||
}
|
||||
|
||||
const KEYWORD_ENV = 'environment';
|
||||
|
||||
public function getSelectedEnvironnment()
|
||||
@@ -323,8 +299,7 @@ class Configuration
|
||||
{
|
||||
$connexions = $this->getConnexions();
|
||||
|
||||
if ( ! isset($connexions[$name]))
|
||||
{
|
||||
if ( ! isset($connexions[$name])) {
|
||||
throw new \Exception(sprintf('Unknown connexion name %s', $name));
|
||||
}
|
||||
|
||||
@@ -371,22 +346,17 @@ class Configuration
|
||||
$services = new ParameterBag($this->getServices());
|
||||
$service = null;
|
||||
|
||||
while ($scopes)
|
||||
{
|
||||
while ($scopes) {
|
||||
$scope = array_shift($scopes);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$service = new ParameterBag($services->get($scope));
|
||||
$services = $service;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(sprintf('Unknow service name %s', $name));
|
||||
}
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ namespace Alchemy\Phrasea\Core\Configuration;
|
||||
*/
|
||||
class ApplicationSpecification implements Specification
|
||||
{
|
||||
|
||||
protected $parser;
|
||||
|
||||
public function __construct()
|
||||
@@ -93,8 +92,7 @@ class ApplicationSpecification implements Specification
|
||||
$this->getServicesPathFile()
|
||||
);
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file))
|
||||
unlink($file);
|
||||
}
|
||||
@@ -119,8 +117,7 @@ class ApplicationSpecification implements Specification
|
||||
, $this->getConfigurationsPathFile()
|
||||
);
|
||||
|
||||
if (function_exists('chmod'))
|
||||
{
|
||||
if (function_exists('chmod')) {
|
||||
chmod($this->getConnexionsPathFile(), 0700);
|
||||
chmod($this->getConfigurationsPathFile(), 0700);
|
||||
chmod($this->getServicesPathFile(), 0700);
|
||||
@@ -129,16 +126,13 @@ class ApplicationSpecification implements Specification
|
||||
|
||||
public function isSetup()
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
$this->getConfigurationsFile();
|
||||
$this->getConnexionsFile();
|
||||
$this->getServicesFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -164,5 +158,4 @@ class ApplicationSpecification implements Specification
|
||||
{
|
||||
return realpath(__DIR__ . '/../../../../../');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -38,5 +38,4 @@ interface Specification
|
||||
public function delete();
|
||||
|
||||
public function isSetup();
|
||||
|
||||
}
|
||||
|
@@ -27,21 +27,16 @@ class Builder
|
||||
{
|
||||
$classname = __NAMESPACE__ . '\\' . $configuration->get("type");
|
||||
|
||||
if (!class_exists($classname))
|
||||
{
|
||||
if ( ! class_exists($classname)) {
|
||||
throw new Exception\ServiceNotFound(sprintf('Service %s not found', $classname));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$options = $configuration->get("options");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$options = array();
|
||||
}
|
||||
|
||||
return new $classname($core, $options);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,18 +25,15 @@ use Alchemy\Phrasea\Core,
|
||||
*/
|
||||
class ApcCache extends ServiceAbstract
|
||||
{
|
||||
|
||||
protected $cache;
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('apc'))
|
||||
{
|
||||
if ( ! extension_loaded('apc')) {
|
||||
throw new \Exception('The APC cache requires the APC extension.');
|
||||
}
|
||||
|
||||
if (!$this->cache)
|
||||
{
|
||||
if ( ! $this->cache) {
|
||||
$this->cache = new CacheDriver\ApcCache();
|
||||
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||
@@ -49,7 +46,5 @@ class ApcCache extends ServiceAbstract
|
||||
{
|
||||
return 'apc';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -26,13 +26,11 @@ use Alchemy\Phrasea\Core,
|
||||
*/
|
||||
class ArrayCache extends ServiceAbstract
|
||||
{
|
||||
|
||||
protected $cache;
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!$this->cache)
|
||||
{
|
||||
if ( ! $this->cache) {
|
||||
$this->cache = new CacheDriver\ArrayCache();
|
||||
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||
@@ -45,6 +43,5 @@ class ArrayCache extends ServiceAbstract
|
||||
{
|
||||
return 'array';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ use Alchemy\Phrasea\Core,
|
||||
*/
|
||||
class MemcacheCache extends ServiceAbstract
|
||||
{
|
||||
|
||||
const DEFAULT_HOST = "localhost";
|
||||
const DEFAULT_PORT = "11211";
|
||||
|
||||
@@ -44,13 +43,11 @@ class MemcacheCache extends ServiceAbstract
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('memcache'))
|
||||
{
|
||||
if ( ! extension_loaded('memcache')) {
|
||||
throw new \Exception('The Memcache cache requires the Memcache extension.');
|
||||
}
|
||||
|
||||
if (!$this->cache)
|
||||
{
|
||||
if ( ! $this->cache) {
|
||||
$memcache = new \Memcache();
|
||||
|
||||
$memcache->addServer($this->host, $this->port);
|
||||
@@ -59,15 +56,12 @@ class MemcacheCache extends ServiceAbstract
|
||||
|
||||
$stats = @$memcache->getExtendedStats();
|
||||
|
||||
if (isset($stats[$key]))
|
||||
{
|
||||
if (isset($stats[$key])) {
|
||||
$this->cache = new CacheDriver\MemcacheCache();
|
||||
$this->cache->setMemcache($memcache);
|
||||
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
||||
}
|
||||
}
|
||||
@@ -89,6 +83,5 @@ class MemcacheCache extends ServiceAbstract
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ use Alchemy\Phrasea\Core,
|
||||
*/
|
||||
class RedisCache extends ServiceAbstract
|
||||
{
|
||||
|
||||
const DEFAULT_HOST = "localhost";
|
||||
const DEFAULT_PORT = "6379";
|
||||
|
||||
@@ -48,32 +47,25 @@ class RedisCache extends ServiceAbstract
|
||||
*/
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('redis'))
|
||||
{
|
||||
if ( ! extension_loaded('redis')) {
|
||||
throw new \Exception('The Redis cache requires the Redis extension.');
|
||||
}
|
||||
|
||||
|
||||
if (!$this->cache)
|
||||
{
|
||||
if ( ! $this->cache) {
|
||||
$redis = new \Redis();
|
||||
|
||||
if (!$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY))
|
||||
{
|
||||
if ( ! $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY)) {
|
||||
$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
|
||||
}
|
||||
|
||||
if ($redis->connect($this->host, $this->port))
|
||||
{
|
||||
if ($redis->connect($this->host, $this->port)) {
|
||||
$this->cache = new CacheDriver\RedisCache();
|
||||
$this->cache->setRedis($redis);
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->cache;
|
||||
@@ -93,6 +85,5 @@ class RedisCache extends ServiceAbstract
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -25,18 +25,15 @@ use Alchemy\Phrasea\Core,
|
||||
*/
|
||||
class XcacheCache extends ServiceAbstract
|
||||
{
|
||||
|
||||
protected $cache;
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('xcache'))
|
||||
{
|
||||
if ( ! extension_loaded('xcache')) {
|
||||
throw new \Exception('The XCache cache requires the XCache extension.');
|
||||
}
|
||||
|
||||
if (!$this->cache)
|
||||
{
|
||||
if ( ! $this->cache) {
|
||||
$this->cache = new CacheDriver\XcacheCache();
|
||||
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||
@@ -49,5 +46,4 @@ class XcacheCache extends ServiceAbstract
|
||||
{
|
||||
return 'xcache';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ use Doctrine\Logger\MonologSQLLogger;
|
||||
*/
|
||||
class Monolog extends ParentLog
|
||||
{
|
||||
|
||||
const JSON_OUTPUT = 'json';
|
||||
const YAML_OUTPUT = 'yaml';
|
||||
const VAR_DUMP_OUTPUT = 'vdump';
|
||||
@@ -39,8 +38,7 @@ class Monolog extends ParentLog
|
||||
self::JSON_OUTPUT, self::YAML_OUTPUT, self::VAR_DUMP_OUTPUT
|
||||
);
|
||||
|
||||
if (!in_array($output, $outputs))
|
||||
{
|
||||
if ( ! in_array($output, $outputs)) {
|
||||
throw new \Exception(sprintf(
|
||||
"The output type '%s' declared in %s service is not valid.
|
||||
Available types are %s."
|
||||
@@ -58,6 +56,4 @@ class Monolog extends ParentLog
|
||||
{
|
||||
return 'doctrine_monolog';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -15,8 +15,8 @@ use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
use Doctrine\DBAL\Logging\EchoSQLLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
@@ -35,5 +35,4 @@ class Phpecho extends ServiceAbstract
|
||||
{
|
||||
return 'phpecho';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,13 +26,11 @@ use Monolog\Handler\FirePHPHandler;
|
||||
*/
|
||||
class FirePHP extends ServiceAbstract
|
||||
{
|
||||
|
||||
protected $logger;
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!$this->logger)
|
||||
{
|
||||
if ( ! $this->logger) {
|
||||
$this->logger = new Logger('FirePHP');
|
||||
|
||||
$this->logger->pushHandler(new FirePHPHandler());
|
||||
@@ -45,5 +43,4 @@ class FirePHP extends ServiceAbstract
|
||||
{
|
||||
return 'FirePHP Monolog';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -41,16 +41,14 @@ class Monolog extends ServiceAbstract
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
|
||||
if (empty($options))
|
||||
{
|
||||
if (empty($options)) {
|
||||
throw new \Exception(sprintf("'%s' service options can not be empty", $this->name));
|
||||
}
|
||||
|
||||
//defaut to main handler
|
||||
$handler = isset($options["handler"]) ? $options["handler"] : false;
|
||||
|
||||
if (!$handler)
|
||||
{
|
||||
if ( ! $handler) {
|
||||
throw new \Exception(sprintf(
|
||||
"You must specify at least one handler for '%s' service"
|
||||
, __CLASS__
|
||||
@@ -58,8 +56,7 @@ class Monolog extends ServiceAbstract
|
||||
);
|
||||
}
|
||||
|
||||
if (!array_key_exists($handler, $this->handlers))
|
||||
{
|
||||
if ( ! array_key_exists($handler, $this->handlers)) {
|
||||
throw new \Exception(sprintf(
|
||||
"The handler type '%s' declared in %s %s service is not valid.
|
||||
Available types are %s."
|
||||
@@ -74,8 +71,7 @@ class Monolog extends ServiceAbstract
|
||||
|
||||
$handlerClassName = sprintf('\Monolog\Handler\%sHandler', $handlerName);
|
||||
|
||||
if (!class_exists($handlerClassName))
|
||||
{
|
||||
if ( ! class_exists($handlerClassName)) {
|
||||
throw new \Exception(sprintf(
|
||||
'Unable to log monolog handler %s looked for class %s'
|
||||
, $handlerName
|
||||
@@ -83,8 +79,7 @@ class Monolog extends ServiceAbstract
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($options["filename"]))
|
||||
{
|
||||
if ( ! isset($options["filename"])) {
|
||||
throw new \Exception(sprintf(
|
||||
"Missing filename option in '%s' service"
|
||||
, __CLASS__
|
||||
@@ -96,16 +91,13 @@ class Monolog extends ServiceAbstract
|
||||
|
||||
$file = sprintf('%s/%s', $logPath, $options["filename"]);
|
||||
|
||||
if ($handler == 'rotate')
|
||||
{
|
||||
if ($handler == 'rotate') {
|
||||
$maxDay = isset($options["max_day"]) ?
|
||||
(int) $options["max_day"] :
|
||||
self::DEFAULT_MAX_DAY;
|
||||
|
||||
$handlerInstance = new $handlerClassName($file, $maxDay);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$handlerInstance = new $handlerClassName($file);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
*/
|
||||
class Doctrine extends ServiceAbstract
|
||||
{
|
||||
|
||||
protected $loggers = array(
|
||||
'Log\\Doctrine\Monolog'
|
||||
, 'Log\\Doctrine\\Phpecho'
|
||||
@@ -40,24 +39,20 @@ class Doctrine extends ServiceAbstract
|
||||
|
||||
$config = new \Doctrine\ORM\Configuration();
|
||||
|
||||
$this->debug = !!$options["debug"];
|
||||
$this->debug = ! ! $options["debug"];
|
||||
|
||||
$logServiceName = isset($options["log"]['service']) ? $options["log"]['service'] : false;
|
||||
|
||||
if ($logServiceName)
|
||||
{
|
||||
if ($logServiceName) {
|
||||
$config->setSQLLogger($this->getLog($logServiceName));
|
||||
}
|
||||
|
||||
$cache = isset($options["cache"]) ? $options["cache"] : false;
|
||||
|
||||
if (!$cache || $this->debug)
|
||||
{
|
||||
if ( ! $cache || $this->debug) {
|
||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache');
|
||||
$queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache';
|
||||
$meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache';
|
||||
|
||||
@@ -94,8 +89,7 @@ class Doctrine extends ServiceAbstract
|
||||
|
||||
$connexion = isset($options["dbal"]) ? $options["dbal"] : false;
|
||||
|
||||
if (!$connexion)
|
||||
{
|
||||
if ( ! $connexion) {
|
||||
throw new \Exception(sprintf(
|
||||
"Missing dbal configuration for '%s' service"
|
||||
, __CLASS__
|
||||
@@ -103,12 +97,9 @@ class Doctrine extends ServiceAbstract
|
||||
);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$dbalConf = $this->core->getConfiguration()->getConnexion($connexion)->all();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Connexion '%s' is not declared");
|
||||
}
|
||||
|
||||
@@ -116,12 +107,9 @@ class Doctrine extends ServiceAbstract
|
||||
|
||||
$evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$this->entityManager = \Doctrine\ORM\EntityManager::create($dbalConf, $config, $evm);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(sprintf(
|
||||
"Failed to create doctrine service for the following reason '%s'"
|
||||
, $e->getMessage()
|
||||
@@ -139,28 +127,23 @@ class Doctrine extends ServiceAbstract
|
||||
|
||||
$platform = $this->entityManager->getConnection()->getDatabasePlatform();
|
||||
|
||||
if (!Type::hasType('blob'))
|
||||
{
|
||||
if ( ! Type::hasType('blob')) {
|
||||
Type::addType('blob', 'Types\Blob');
|
||||
}
|
||||
|
||||
if (!Type::hasType('enum'))
|
||||
{
|
||||
if ( ! Type::hasType('enum')) {
|
||||
Type::addType('enum', 'Types\Enum');
|
||||
}
|
||||
|
||||
if (!Type::hasType('longblob'))
|
||||
{
|
||||
if ( ! Type::hasType('longblob')) {
|
||||
Type::addType('longblob', 'Types\LongBlob');
|
||||
}
|
||||
|
||||
if (!Type::hasType('varbinary'))
|
||||
{
|
||||
if ( ! Type::hasType('varbinary')) {
|
||||
Type::addType('varbinary', 'Types\VarBinary');
|
||||
}
|
||||
|
||||
if (!Type::hasType('binary'))
|
||||
{
|
||||
if ( ! Type::hasType('binary')) {
|
||||
Type::addType('binary', 'Types\Binary');
|
||||
}
|
||||
|
||||
@@ -175,12 +158,9 @@ class Doctrine extends ServiceAbstract
|
||||
|
||||
private function getLog($serviceName)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
$configuration = $this->core->getConfiguration()->getService($serviceName);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
"%s from %s service"
|
||||
, $e->getMessage()
|
||||
@@ -194,8 +174,7 @@ class Doctrine extends ServiceAbstract
|
||||
|
||||
$type = $configuration->get("type");
|
||||
|
||||
if (!in_array($type, $this->loggers))
|
||||
{
|
||||
if ( ! in_array($type, $this->loggers)) {
|
||||
throw new \Exception(sprintf(
|
||||
"The logger type '%s' declared in %s service is not valid.
|
||||
Available types are %s."
|
||||
@@ -230,5 +209,4 @@ class Doctrine extends ServiceAbstract
|
||||
{
|
||||
return array('debug', 'dbal');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
*/
|
||||
abstract class ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
protected $core;
|
||||
protected $options;
|
||||
|
||||
@@ -33,8 +32,7 @@ abstract class ServiceAbstract implements ServiceInterface
|
||||
|
||||
$mandatory = $this->getMandatoryOptions();
|
||||
|
||||
if ($mandatory !== array_intersect($mandatory, array_keys($options)))
|
||||
{
|
||||
if ($mandatory !== array_intersect($mandatory, array_keys($options))) {
|
||||
throw new Exception\MissingParameters(
|
||||
sprintf(
|
||||
'Missing parameters %s'
|
||||
@@ -73,5 +71,4 @@ abstract class ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,5 +27,4 @@ interface ServiceInterface
|
||||
public function getOptions();
|
||||
|
||||
public function getMandatoryOptions();
|
||||
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ use Alchemy\Phrasea\Core,
|
||||
|
||||
class Twig extends ServiceAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Twig_Environment
|
||||
@@ -30,10 +29,8 @@ class Twig extends ServiceAbstract
|
||||
{
|
||||
$this->templatesPath = $this->resolvePaths();
|
||||
|
||||
try
|
||||
{
|
||||
if (!$this->options['debug'])
|
||||
{
|
||||
try {
|
||||
if ( ! $this->options['debug']) {
|
||||
$this->options['cache'] = realpath(__DIR__ . '/../../../../../../tmp/cache_twig/');
|
||||
}
|
||||
|
||||
@@ -43,9 +40,7 @@ class Twig extends ServiceAbstract
|
||||
$this->loadExtensions();
|
||||
$this->loadTests();
|
||||
$this->loadFilters();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception(sprintf(
|
||||
"Unable to create '%s' service for the following reason %s"
|
||||
, __CLASS__
|
||||
@@ -70,8 +65,7 @@ class Twig extends ServiceAbstract
|
||||
$request = new \http_request();
|
||||
|
||||
$user = false;
|
||||
if ($session->is_authenticated())
|
||||
{
|
||||
if ($session->is_authenticated()) {
|
||||
$user = \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||
}
|
||||
|
||||
@@ -183,12 +177,9 @@ class Twig extends ServiceAbstract
|
||||
|
||||
$templatePath = $this->getDefaultTemplatePath();
|
||||
|
||||
if ($browser->isTablet() || $browser->isMobile())
|
||||
{
|
||||
if ($browser->isTablet() || $browser->isMobile()) {
|
||||
$paths = $templatePath['mobile'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$paths = $templatePath['web'];
|
||||
}
|
||||
|
||||
@@ -209,5 +200,4 @@ class Twig extends ServiceAbstract
|
||||
{
|
||||
return array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ namespace Alchemy\Phrasea\Core;
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
|
||||
protected static $number = '3.7.0.0.a2';
|
||||
protected static $name = 'Carnosaurus';
|
||||
|
||||
@@ -32,5 +31,4 @@ class Version
|
||||
{
|
||||
return static::$name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Helper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Kernel
|
||||
@@ -65,5 +64,4 @@ class Helper
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -34,15 +34,13 @@ class Prod extends Helper
|
||||
$bases = $fields = $dates = array();
|
||||
$user = $this->getCore()->getAuthenticatedUser();
|
||||
|
||||
if(!$user instanceof \User_Adapter)
|
||||
{
|
||||
if ( ! $user instanceof \User_Adapter) {
|
||||
return $search_datas;
|
||||
}
|
||||
|
||||
$searchSet = $user->getPrefs('search');
|
||||
|
||||
foreach ($user->ACL()->get_granted_sbas() as $databox)
|
||||
{
|
||||
foreach ($user->ACL()->get_granted_sbas() as $databox) {
|
||||
$sbas_id = $databox->get_sbas_id();
|
||||
|
||||
$bases[$sbas_id] = array(
|
||||
@@ -52,8 +50,7 @@ class Prod extends Helper
|
||||
'sbas_id' => $sbas_id
|
||||
);
|
||||
|
||||
foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll)
|
||||
{
|
||||
foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) {
|
||||
$selected = ($searchSet &&
|
||||
isset($searchSet->bases) &&
|
||||
isset($searchSet->bases->$sbas_id)) ? (in_array($coll->get_base_id(), $searchSet->bases->$sbas_id)) : true;
|
||||
@@ -65,26 +62,21 @@ class Prod extends Helper
|
||||
}
|
||||
|
||||
$meta_struct = $databox->get_meta_structure();
|
||||
foreach ($meta_struct as $meta)
|
||||
{
|
||||
if (!$meta->is_indexable())
|
||||
foreach ($meta_struct as $meta) {
|
||||
if ( ! $meta->is_indexable())
|
||||
continue;
|
||||
$id = $meta->get_id();
|
||||
$name = $meta->get_name();
|
||||
if ($meta->get_type() == 'date')
|
||||
{
|
||||
if ($meta->get_type() == 'date') {
|
||||
if (isset($dates[$id]))
|
||||
$dates[$id]['sbas'][] = $sbas_id;
|
||||
else
|
||||
$dates[$id] = array('sbas' => array($sbas_id), 'fieldname' => $name);
|
||||
}
|
||||
|
||||
if (isset($fields[$name]))
|
||||
{
|
||||
if (isset($fields[$name])) {
|
||||
$fields[$name]['sbas'][] = $sbas_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$fields[$name] = array(
|
||||
'sbas' => array($sbas_id)
|
||||
, 'fieldname' => $name
|
||||
@@ -94,13 +86,12 @@ class Prod extends Helper
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bases[$sbas_id]['thesaurus'])
|
||||
if ( ! $bases[$sbas_id]['thesaurus'])
|
||||
continue;
|
||||
if (!$user->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th'))
|
||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th'))
|
||||
continue;
|
||||
|
||||
if (simplexml_load_string($databox->get_cterms()))
|
||||
{
|
||||
if (simplexml_load_string($databox->get_cterms())) {
|
||||
$bases[$sbas_id]['cterms'] = true;
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Bridge extends RecordHelper
|
||||
{
|
||||
|
||||
protected $flatten_groupings = true;
|
||||
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ use Alchemy\Phrasea\Core,
|
||||
*/
|
||||
class Edit extends RecordHelper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
@@ -85,20 +84,17 @@ class Edit extends RecordHelper
|
||||
{
|
||||
parent::__construct($core, $Request);
|
||||
|
||||
if ($this->is_single_grouping())
|
||||
{
|
||||
if ($this->is_single_grouping()) {
|
||||
$record = array_pop($this->selection->get_elements());
|
||||
$children = $record->get_children();
|
||||
foreach ($children as $child)
|
||||
{
|
||||
foreach ($children as $child) {
|
||||
$this->selection->add_element($child);
|
||||
}
|
||||
$n = count($children);
|
||||
$this->elements_received = $this->selection->get_count() + $n - 1;
|
||||
$this->examinate_selection();
|
||||
}
|
||||
if ($this->is_possible())
|
||||
{
|
||||
if ($this->is_possible()) {
|
||||
$this->generate_javascript_fields()
|
||||
->generate_javascript_sugg_values()
|
||||
->generate_javascript_status()
|
||||
@@ -219,8 +215,7 @@ class Edit extends RecordHelper
|
||||
$databox = \databox::get_instance($this->get_sbas_id());
|
||||
|
||||
$databox_fields = array();
|
||||
foreach ($databox->get_meta_structure() as $field)
|
||||
{
|
||||
foreach ($databox->get_meta_structure() as $field) {
|
||||
$databox_fields[$field->get_id()] = array(
|
||||
'dirty' => false,
|
||||
'meta_struct_id' => $field->get_id(),
|
||||
@@ -228,8 +223,7 @@ class Edit extends RecordHelper
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($this->selection as $record)
|
||||
{
|
||||
foreach ($this->selection as $record) {
|
||||
$indice = $record->get_number();
|
||||
$_lst[$indice] = array(
|
||||
'bid' => $record->get_base_id(),
|
||||
@@ -240,10 +234,8 @@ class Edit extends RecordHelper
|
||||
);
|
||||
|
||||
$_lst[$indice]['statbits'] = array();
|
||||
if ($user->ACL()->has_right_on_base($record->get_base_id(), 'chgstatus'))
|
||||
{
|
||||
foreach ($this->javascript_status as $n => $s)
|
||||
{
|
||||
if ($user->ACL()->has_right_on_base($record->get_base_id(), 'chgstatus')) {
|
||||
foreach ($this->javascript_status as $n => $s) {
|
||||
$tmp_val = substr(strrev($record->get_status()), $n, 1);
|
||||
$_lst[$indice]['statbits'][$n]['value'] = ($tmp_val == '1') ? '1' : '0';
|
||||
$_lst[$indice]['statbits'][$n]['dirty'] = false;
|
||||
@@ -253,21 +245,17 @@ class Edit extends RecordHelper
|
||||
|
||||
$_lst[$indice]['originalname'] = $record->get_original_name();
|
||||
|
||||
foreach ($record->get_caption()->get_fields(null, true) as $field)
|
||||
{
|
||||
foreach ($record->get_caption()->get_fields(null, true) as $field) {
|
||||
$meta_struct_id = $field->get_meta_struct_id();
|
||||
if (!isset($this->javascript_fields[$meta_struct_id]))
|
||||
{
|
||||
if ( ! isset($this->javascript_fields[$meta_struct_id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
foreach ($field->get_values() as $value)
|
||||
{
|
||||
foreach ($field->get_values() as $value) {
|
||||
$type = $id = null;
|
||||
|
||||
if ($value->getVocabularyType())
|
||||
{
|
||||
if ($value->getVocabularyType()) {
|
||||
$type = $value->getVocabularyType()->getType();
|
||||
$id = $value->getVocabularyId();
|
||||
}
|
||||
@@ -316,8 +304,7 @@ class Edit extends RecordHelper
|
||||
{
|
||||
$done = array();
|
||||
$T_sgval = array();
|
||||
foreach ($this->selection as $record)
|
||||
{
|
||||
foreach ($this->selection as $record) {
|
||||
/* @var $record record_adapter */
|
||||
$base_id = $record->get_base_id();
|
||||
$record_id = $record->get_record_id();
|
||||
@@ -329,25 +316,22 @@ class Edit extends RecordHelper
|
||||
$T_sgval['b' . $base_id] = array();
|
||||
$collection = \collection::get_from_base_id($base_id);
|
||||
|
||||
if ($sxe = simplexml_load_string($collection->get_prefs()))
|
||||
{
|
||||
if ($sxe = simplexml_load_string($collection->get_prefs())) {
|
||||
$z = $sxe->xpath('/baseprefs/sugestedValues');
|
||||
|
||||
if (!$z || !is_array($z))
|
||||
if ( ! $z || ! is_array($z))
|
||||
continue;
|
||||
|
||||
foreach ($z[0] as $ki => $vi) // les champs
|
||||
{
|
||||
foreach ($z[0] as $ki => $vi) { // les champs
|
||||
|
||||
$field = $databox->get_meta_structure()->get_element_by_name($ki);
|
||||
if (!$field)
|
||||
if ( ! $field)
|
||||
continue; // champ inconnu dans la structure ?
|
||||
if (!$vi)
|
||||
if ( ! $vi)
|
||||
continue;
|
||||
|
||||
$T_sgval['b' . $base_id][$field->get_id()] = array();
|
||||
foreach ($vi->value as $oneValue) // les valeurs sug
|
||||
{
|
||||
foreach ($vi->value as $oneValue) { // les valeurs sug
|
||||
$T_sgval['b' . $base_id][$field->get_id()][] =
|
||||
(string) $oneValue;
|
||||
}
|
||||
@@ -371,13 +355,10 @@ class Edit extends RecordHelper
|
||||
$_tstatbits = array();
|
||||
$user = $this->getCore()->getAuthenticatedUser();
|
||||
|
||||
if ($user->ACL()->has_right('changestatus'))
|
||||
{
|
||||
if ($user->ACL()->has_right('changestatus')) {
|
||||
$status = \databox_status::getDisplayStatus();
|
||||
if (isset($status[$this->get_sbas_id()]))
|
||||
{
|
||||
foreach ($status[$this->get_sbas_id()] as $n => $statbit)
|
||||
{
|
||||
if (isset($status[$this->get_sbas_id()])) {
|
||||
foreach ($status[$this->get_sbas_id()] as $n => $statbit) {
|
||||
$_tstatbits[$n] = array();
|
||||
$_tstatbits[$n]['label0'] = $statbit['labeloff'];
|
||||
$_tstatbits[$n]['label1'] = $statbit['labelon'];
|
||||
@@ -407,8 +388,7 @@ class Edit extends RecordHelper
|
||||
$databox = \databox::get_instance($this->get_sbas_id());
|
||||
$meta_struct = $databox->get_meta_structure();
|
||||
|
||||
foreach ($meta_struct as $meta)
|
||||
{
|
||||
foreach ($meta_struct as $meta) {
|
||||
$fields[] = $meta;
|
||||
$this->generate_field($meta);
|
||||
}
|
||||
@@ -460,10 +440,8 @@ class Edit extends RecordHelper
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$appbox = \appbox::get_instance($this->core);
|
||||
if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent'))
|
||||
{
|
||||
try
|
||||
{
|
||||
if ($request->get('act_option') == 'SAVEGRP' && $request->get('newrepresent')) {
|
||||
try {
|
||||
$reg_record = $this->get_grouping_head();
|
||||
$reg_sbas_id = $reg_record->get_sbas_id();
|
||||
|
||||
@@ -472,21 +450,17 @@ class Edit extends RecordHelper
|
||||
if ($newsubdef_reg->get_type() !== 'image')
|
||||
throw new \Exception('A reg image must come from image data');
|
||||
|
||||
foreach ($newsubdef_reg->get_subdefs() as $name => $value)
|
||||
{
|
||||
foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
|
||||
$pathfile = $value->get_pathfile();
|
||||
$system_file = new \system_file($pathfile);
|
||||
$reg_record->substitute_subdef($name, $system_file);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($request->get('mds')))
|
||||
{
|
||||
if ( ! is_array($request->get('mds'))) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -495,29 +469,24 @@ class Edit extends RecordHelper
|
||||
$meta_struct = $databox->get_meta_structure();
|
||||
$write_edit_el = false;
|
||||
$date_obj = new \DateTime();
|
||||
foreach ($meta_struct->get_elements() as $meta_struct_el)
|
||||
{
|
||||
foreach ($meta_struct->get_elements() as $meta_struct_el) {
|
||||
if ($meta_struct_el->get_metadata_namespace() == "PHRASEANET" && $meta_struct_el->get_metadata_tagname() == 'tf-editdate')
|
||||
$write_edit_el = $meta_struct_el;
|
||||
}
|
||||
|
||||
$elements = $this->selection->get_elements();
|
||||
|
||||
foreach ($request->get('mds') as $rec)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($request->get('mds') as $rec) {
|
||||
try {
|
||||
$record = $databox->get_record($rec['record_id']);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$key = $record->get_serialize_key();
|
||||
|
||||
if (!array_key_exists($key, $elements))
|
||||
if ( ! array_key_exists($key, $elements))
|
||||
continue;
|
||||
|
||||
$statbits = $rec['status'];
|
||||
@@ -528,23 +497,20 @@ class Edit extends RecordHelper
|
||||
else
|
||||
$editDirty = true;
|
||||
|
||||
if (is_array($rec['metadatas']))
|
||||
{
|
||||
if (is_array($rec['metadatas'])) {
|
||||
$record->set_metadatas($rec['metadatas']);
|
||||
}
|
||||
|
||||
/**
|
||||
* todo : this should not work
|
||||
*/
|
||||
if ($write_edit_el instanceof \databox_field)
|
||||
{
|
||||
if ($write_edit_el instanceof \databox_field) {
|
||||
$fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()), true);
|
||||
$field = array_pop($fields);
|
||||
|
||||
$meta_id = null;
|
||||
|
||||
if ($field && !$field->is_multi())
|
||||
{
|
||||
if ($field && ! $field->is_multi()) {
|
||||
$meta_id = array_pop($field->get_values())->getId();
|
||||
}
|
||||
|
||||
@@ -561,8 +527,7 @@ class Edit extends RecordHelper
|
||||
|
||||
$newstat = $record->get_status();
|
||||
$statbits = ltrim($statbits, 'x');
|
||||
if (!in_array($statbits, array('', 'null')))
|
||||
{
|
||||
if ( ! in_array($statbits, array('', 'null'))) {
|
||||
$mask_and = ltrim(str_replace(
|
||||
array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0');
|
||||
if ($mask_and != '')
|
||||
@@ -581,14 +546,12 @@ class Edit extends RecordHelper
|
||||
|
||||
$record->write_metas();
|
||||
|
||||
if ($statbits != '')
|
||||
{
|
||||
if ($statbits != '') {
|
||||
$appbox->get_session()
|
||||
->get_logger($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_STATUS, '', '');
|
||||
}
|
||||
if ($editDirty)
|
||||
{
|
||||
if ($editDirty) {
|
||||
$appbox->get_session()
|
||||
->get_logger($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_EDIT, '', '');
|
||||
@@ -597,5 +560,4 @@ class Edit extends RecordHelper
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Feed extends RecordHelper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
@@ -51,16 +50,13 @@ class Feed extends RecordHelper
|
||||
{
|
||||
parent::__construct($core, $Request);
|
||||
|
||||
if ($this->is_single_grouping())
|
||||
{
|
||||
if ($this->is_single_grouping()) {
|
||||
$record = array_pop($this->selection->get_elements());
|
||||
foreach ($record->get_children() as $child)
|
||||
{
|
||||
foreach ($record->get_children() as $child) {
|
||||
$this->selection->add_element($child);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var set_selection
|
||||
@@ -110,8 +109,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
$appbox = \appbox::get_instance($core);
|
||||
$usr_id = $appbox->get_session()->get_usr_id();
|
||||
|
||||
if (trim($Request->get('ssel')) !== '')
|
||||
{
|
||||
if (trim($Request->get('ssel')) !== '') {
|
||||
$em = $this->getCore()->getEntityManager();
|
||||
$repository = $em->getRepository('\Entities\Basket');
|
||||
|
||||
@@ -122,9 +120,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$this->is_basket = true;
|
||||
$this->original_basket = $Basket;
|
||||
}
|
||||
elseif (trim($Request->get('story')) !== '')
|
||||
{
|
||||
} elseif (trim($Request->get('story')) !== '') {
|
||||
$em = $this->getCore()->getEntityManager();
|
||||
$repository = $em->getRepository('\Entities\StoryWZ');
|
||||
|
||||
@@ -134,9 +130,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
);
|
||||
|
||||
$this->selection->load_list(array($storyWZ->getRecord()->get_serialize_key()), $this->flatten_groupings);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->selection->load_list(explode(";", $Request->get('lst')), $this->flatten_groupings);
|
||||
}
|
||||
$this->elements_received = $this->selection->get_count();
|
||||
@@ -173,8 +167,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
$this->selection->grep_authorized($this->required_rights, $this->required_sbas_rights);
|
||||
|
||||
if ($this->works_on_unique_sbas === true)
|
||||
{
|
||||
if ($this->works_on_unique_sbas === true) {
|
||||
$this->sbas_ids = $this->selection->get_distinct_sbas_ids();
|
||||
|
||||
$this->is_possible = count($this->sbas_ids) == 1;
|
||||
@@ -204,10 +197,9 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
*/
|
||||
public function get_grouping_head()
|
||||
{
|
||||
if (!$this->is_single_grouping())
|
||||
if ( ! $this->is_single_grouping())
|
||||
throw new Exception('Cannot use ' . __METHOD__ . ' here');
|
||||
foreach ($this->get_elements() as $record)
|
||||
{
|
||||
foreach ($this->get_elements() as $record) {
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
@@ -300,25 +292,20 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
*/
|
||||
public function get_serialize_list()
|
||||
{
|
||||
if ($this->is_single_grouping())
|
||||
{
|
||||
if ($this->is_single_grouping()) {
|
||||
return $this->get_grouping_head()->get_serialize_key();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return $this->selection->serialize_list();
|
||||
}
|
||||
}
|
||||
|
||||
public function grep_records(\Closure $closure)
|
||||
{
|
||||
foreach ($this->selection->get_elements() as $record)
|
||||
{
|
||||
if (!$closure($record))
|
||||
foreach ($this->selection->get_elements() as $record) {
|
||||
if ( ! $closure($record))
|
||||
$this->selection->remove_element($record);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class MoveCollection extends RecordHelper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
@@ -63,8 +62,7 @@ class MoveCollection extends RecordHelper
|
||||
{
|
||||
$this->available_destinations = array();
|
||||
|
||||
if (!$this->is_possible)
|
||||
|
||||
if ( ! $this->is_possible)
|
||||
return $this;
|
||||
|
||||
$this->available_destinations = array_keys(
|
||||
@@ -107,24 +105,20 @@ class MoveCollection extends RecordHelper
|
||||
$user->ACL()->has_right_on_base($baseId, 'canaddrecord') ?
|
||||
$request->get('base_id') : false;
|
||||
|
||||
if(!$user->ACL()->has_right_on_base($baseId, 'canaddrecord'))
|
||||
{
|
||||
if ( ! $user->ACL()->has_right_on_base($baseId, 'canaddrecord')) {
|
||||
throw new \Exception_Unauthorized(sprintf("%s do not have the permission to move records to %s", $user->get_login()));
|
||||
}
|
||||
|
||||
|
||||
if (!$this->is_possible())
|
||||
if ( ! $this->is_possible())
|
||||
throw new Exception('This action is not possible');
|
||||
|
||||
if ($request->get("chg_coll_son") == "1")
|
||||
{
|
||||
foreach ($this->selection as $record)
|
||||
{
|
||||
if (!$record->is_grouping())
|
||||
if ($request->get("chg_coll_son") == "1") {
|
||||
foreach ($this->selection as $record) {
|
||||
if ( ! $record->is_grouping())
|
||||
continue;
|
||||
foreach ($record->get_children() as $child)
|
||||
{
|
||||
if (!$user->ACL()->has_right_on_base(
|
||||
foreach ($record->get_children() as $child) {
|
||||
if ( ! $user->ACL()->has_right_on_base(
|
||||
$child->get_base_id(), 'candeleterecord'))
|
||||
continue;
|
||||
$this->selection->add_element($child);
|
||||
@@ -135,12 +129,10 @@ class MoveCollection extends RecordHelper
|
||||
|
||||
$collection = \collection::get_from_base_id($base_dest);
|
||||
|
||||
foreach ($this->selection as $record)
|
||||
{
|
||||
foreach ($this->selection as $record) {
|
||||
$record->move_to_collection($collection, $appbox);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper,
|
||||
*/
|
||||
class Printer extends RecordHelper
|
||||
{
|
||||
|
||||
protected $flatten_groupings = true;
|
||||
|
||||
/**
|
||||
@@ -39,16 +38,12 @@ class Printer extends RecordHelper
|
||||
{
|
||||
parent::__construct($core, $Request);
|
||||
|
||||
$grep = function(\record_adapter $record)
|
||||
{
|
||||
$grep = function(\record_adapter $record) {
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
return $record->get_thumbnail()->get_type() == \media_subdef::TYPE_IMAGE ||
|
||||
$record->get_preview()->get_type() == \media_subdef::TYPE_IMAGE;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -59,15 +54,11 @@ class Printer extends RecordHelper
|
||||
public function get_count_preview()
|
||||
{
|
||||
$n = 0;
|
||||
foreach ($this->get_elements() as $element)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($this->get_elements() as $element) {
|
||||
try {
|
||||
$element->get_preview()->get_type() == \media_subdef::TYPE_IMAGE;
|
||||
$n++;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$n ++;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -78,20 +69,15 @@ class Printer extends RecordHelper
|
||||
public function get_count_thumbnail()
|
||||
{
|
||||
$n = 0;
|
||||
foreach ($this->get_elements() as $element)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($this->get_elements() as $element) {
|
||||
try {
|
||||
$element->get_thumbnail()->get_type() == \media_subdef::TYPE_IMAGE;
|
||||
$n++;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$n ++;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $n;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,9 +27,7 @@ use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper,
|
||||
*/
|
||||
class Push extends RecordHelper
|
||||
{
|
||||
|
||||
protected $flatten_groupings = true;
|
||||
|
||||
protected $required_rights = array('canpush');
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Helper\Record;
|
||||
|
||||
|
||||
use Alchemy\Phrasea\Core;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper;
|
||||
|
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Helper\Record;
|
||||
|
||||
|
||||
use Alchemy\Phrasea\Core;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper;
|
||||
|
@@ -22,7 +22,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
@@ -48,8 +47,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$this->users = explode(';', $Request->get('users'));
|
||||
|
||||
$users = array();
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
$usr_id = (int) $usr_id;
|
||||
|
||||
if ($usr_id > 0)
|
||||
@@ -64,8 +62,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
public function delete_users()
|
||||
{
|
||||
$appbox = \appbox::get_instance($this->core);
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
$user = \User_Adapter::getInstance($usr_id, $appbox);
|
||||
$this->delete_user($user);
|
||||
}
|
||||
@@ -81,8 +78,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$user->ACL()->revoke_access_from_bases($list);
|
||||
|
||||
if ($user->ACL()->is_phantom())
|
||||
{
|
||||
if ($user->ACL()->is_phantom()) {
|
||||
$user->delete();
|
||||
}
|
||||
|
||||
@@ -159,17 +155,14 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$stmt->closeCursor();
|
||||
|
||||
$base_ids = array();
|
||||
foreach ($access as $acc)
|
||||
{
|
||||
foreach ($access as $acc) {
|
||||
$base_ids[$acc['base_id']] = $acc;
|
||||
}
|
||||
unset($access);
|
||||
|
||||
foreach ($rs as $k => $row)
|
||||
{
|
||||
foreach ($rs as $k => $row) {
|
||||
$rs[$k]['access'] = array_key_exists($row['base_id'], $base_ids) ? $base_ids[$row['base_id']]['access'] : '0';
|
||||
foreach ($row as $dk => $data)
|
||||
{
|
||||
foreach ($row as $dk => $data) {
|
||||
if (is_null($data))
|
||||
$rs[$k][$dk] = '0';
|
||||
}
|
||||
@@ -190,8 +183,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
'templates' => $templates
|
||||
);
|
||||
|
||||
if (count($this->users) == 1)
|
||||
{
|
||||
if (count($this->users) == 1) {
|
||||
$usr_id = array_pop($this->users);
|
||||
$out['main_user'] = \User_Adapter::getInstance($usr_id, $appbox);
|
||||
}
|
||||
@@ -247,20 +239,19 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$nrows = 0;
|
||||
|
||||
for ($bit = 0; $bit < 64; $bit++)
|
||||
for ($bit = 0; $bit < 64; $bit ++ )
|
||||
$tbits_and[$bit] = $tbits_xor[$bit] = array("nset" => 0);
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
foreach ($rs as $row) {
|
||||
$sta_xor = strrev($row["mask_xor"]);
|
||||
for ($bit = 0; $bit < strlen($sta_xor); $bit++)
|
||||
for ($bit = 0; $bit < strlen($sta_xor); $bit ++ )
|
||||
$tbits_xor[$bit]["nset"] += substr($sta_xor, $bit, 1) != "0" ? 1 : 0;
|
||||
|
||||
$sta_and = strrev($row["mask_and"]);
|
||||
for ($bit = 0; $bit < strlen($sta_and); $bit++)
|
||||
for ($bit = 0; $bit < strlen($sta_and); $bit ++ )
|
||||
$tbits_and[$bit]["nset"] += substr($sta_and, $bit, 1) != "0" ? 1 : 0;
|
||||
|
||||
$nrows++;
|
||||
$nrows ++;
|
||||
}
|
||||
|
||||
$tbits_left = array();
|
||||
@@ -270,8 +261,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$databox = \databox::get_instance($sbas_id);
|
||||
$status = $databox->get_statusbits();
|
||||
|
||||
foreach ($status as $bit => $datas)
|
||||
{
|
||||
foreach ($status as $bit => $datas) {
|
||||
$tbits_left[$bit]["nset"] = 0;
|
||||
$tbits_left[$bit]["name"] = $datas["labeloff"];
|
||||
$tbits_left[$bit]["icon"] = $datas["img_off"];
|
||||
@@ -283,12 +273,9 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$vand_and = $vand_or = $vxor_and = $vxor_or = "0000";
|
||||
|
||||
for ($bit = 4; $bit < 64; $bit++)
|
||||
{
|
||||
if (($tbits_and[$bit]["nset"] != 0 && $tbits_and[$bit]["nset"] != $nrows) || ($tbits_xor[$bit]["nset"] != 0 && $tbits_xor[$bit]["nset"] != $nrows))
|
||||
{
|
||||
if (isset($tbits_left[$bit]) && isset($tbits_right[$bit]))
|
||||
{
|
||||
for ($bit = 4; $bit < 64; $bit ++ ) {
|
||||
if (($tbits_and[$bit]["nset"] != 0 && $tbits_and[$bit]["nset"] != $nrows) || ($tbits_xor[$bit]["nset"] != 0 && $tbits_xor[$bit]["nset"] != $nrows)) {
|
||||
if (isset($tbits_left[$bit]) && isset($tbits_right[$bit])) {
|
||||
$tbits_left[$bit]["nset"] = 2;
|
||||
$tbits_right[$bit]["nset"] = 2;
|
||||
}
|
||||
@@ -296,11 +283,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$vand_or = "0" . $vand_or;
|
||||
$vxor_and = "1" . $vxor_and;
|
||||
$vxor_or = "0" . $vxor_or;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($tbits_left[$bit]) && isset($tbits_right[$bit]))
|
||||
{
|
||||
} else {
|
||||
if (isset($tbits_left[$bit]) && isset($tbits_right[$bit])) {
|
||||
$tbits_left[$bit]["nset"] = (($tbits_and[$bit]["nset"] == $nrows && $tbits_xor[$bit]["nset"] == 0) || $tbits_and[$bit]["nset"] == 0 ) ? 1 : 0;
|
||||
$tbits_right[$bit]["nset"] = (($tbits_and[$bit]["nset"] == $nrows && $tbits_xor[$bit]["nset"] == $nrows) || $tbits_and[$bit]["nset"] == 0 ) ? 1 : 0;
|
||||
}
|
||||
@@ -346,30 +330,25 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$time_limited = -1;
|
||||
$limited_from = $limited_to = false;
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
foreach ($rs as $row) {
|
||||
if ($time_limited < 0)
|
||||
$time_limited = $row['time_limited'];
|
||||
if ($time_limited < 2 && $row['time_limited'] != $row['time_limited'])
|
||||
$time_limited = 2;
|
||||
|
||||
if ($limited_from !== '' && trim($row['limited_from']) != '0000-00-00 00:00:00')
|
||||
{
|
||||
if ($limited_from !== '' && trim($row['limited_from']) != '0000-00-00 00:00:00') {
|
||||
$limited_from = $limited_from === false ? $row['limited_from'] : (($limited_from == $row['limited_from']) ? $limited_from : '');
|
||||
}
|
||||
if ($limited_to !== '' && trim($row['limited_to']) != '0000-00-00 00:00:00')
|
||||
{
|
||||
if ($limited_to !== '' && trim($row['limited_to']) != '0000-00-00 00:00:00') {
|
||||
$limited_to = $limited_to === false ? $row['limited_to'] : (($limited_to == $row['limited_to']) ? $limited_to : '');
|
||||
}
|
||||
}
|
||||
|
||||
if ($limited_from)
|
||||
{
|
||||
if ($limited_from) {
|
||||
$date_obj_from = new \DateTime($limited_from);
|
||||
$limited_from = $date_obj_from->format('Y-m-d');
|
||||
}
|
||||
if ($limited_to)
|
||||
{
|
||||
if ($limited_to) {
|
||||
$date_obj_to = new \DateTime($limited_to);
|
||||
$limited_to = $date_obj_to->format('Y-m-d');
|
||||
}
|
||||
@@ -396,8 +375,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$update = $create = $delete = $create_sbas = $update_sbas = array();
|
||||
|
||||
foreach ($base_ids as $base_id)
|
||||
{
|
||||
foreach ($base_ids as $base_id) {
|
||||
$rights = array(
|
||||
'access',
|
||||
'actif',
|
||||
@@ -417,11 +395,9 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
'manage',
|
||||
'modify_struct'
|
||||
);
|
||||
foreach ($rights as $k => $right)
|
||||
{
|
||||
if (($right == 'access' && !$ACL->has_access_to_base($base_id))
|
||||
|| ($right != 'access' && !$ACL->has_right_on_base($base_id, $right)))
|
||||
{
|
||||
foreach ($rights as $k => $right) {
|
||||
if (($right == 'access' && ! $ACL->has_access_to_base($base_id))
|
||||
|| ($right != 'access' && ! $ACL->has_right_on_base($base_id, $right))) {
|
||||
unset($rights[$k]);
|
||||
continue;
|
||||
}
|
||||
@@ -429,8 +405,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
}
|
||||
$parm = $request->get_parms_from_serialized_datas($rights, 'values');
|
||||
|
||||
foreach ($parm as $p => $v)
|
||||
{
|
||||
foreach ($parm as $p => $v) {
|
||||
if (trim($v) == '')
|
||||
continue;
|
||||
|
||||
@@ -439,18 +414,15 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$p = implode('_', $serial);
|
||||
|
||||
if ($p == 'access')
|
||||
{
|
||||
if ($v === '1')
|
||||
{
|
||||
if ($p == 'access') {
|
||||
if ($v === '1') {
|
||||
$create_sbas[\phrasea::sbasFromBas($base_id)] = \phrasea::sbasFromBas($base_id);
|
||||
$create[] = $base_id;
|
||||
}
|
||||
else
|
||||
$delete[] = $base_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$create_sbas[\phrasea::sbasFromBas($base_id)] = \phrasea::sbasFromBas($base_id);
|
||||
$update[$base_id][$p] = $v;
|
||||
}
|
||||
@@ -459,18 +431,15 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$sbas_ids = $ACL->get_granted_sbas();
|
||||
|
||||
foreach ($sbas_ids as $databox)
|
||||
{
|
||||
foreach ($sbas_ids as $databox) {
|
||||
$rights = array(
|
||||
'bas_modif_th',
|
||||
'bas_manage',
|
||||
'bas_modify_struct',
|
||||
'bas_chupub'
|
||||
);
|
||||
foreach ($rights as $k => $right)
|
||||
{
|
||||
if (!$ACL->has_right_on_sbas($databox->get_sbas_id(), $right))
|
||||
{
|
||||
foreach ($rights as $k => $right) {
|
||||
if ( ! $ACL->has_right_on_sbas($databox->get_sbas_id(), $right)) {
|
||||
unset($rights[$k]);
|
||||
continue;
|
||||
}
|
||||
@@ -479,8 +448,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$parm = $request->get_parms_from_serialized_datas($rights, 'values');
|
||||
|
||||
foreach ($parm as $p => $v)
|
||||
{
|
||||
foreach ($parm as $p => $v) {
|
||||
if (trim($v) == '')
|
||||
continue;
|
||||
|
||||
@@ -493,10 +461,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
try {
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
|
||||
$user = \User_Adapter::getInstance($usr_id, $appbox);
|
||||
@@ -504,13 +470,11 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
->give_access_to_base($create)
|
||||
->give_access_to_sbas($create_sbas);
|
||||
|
||||
foreach ($update as $base_id => $rights)
|
||||
{
|
||||
foreach ($update as $base_id => $rights) {
|
||||
$user->ACL()->update_rights_to_base($base_id, $rights);
|
||||
}
|
||||
|
||||
foreach ($update_sbas as $sbas_id => $rights)
|
||||
{
|
||||
foreach ($update_sbas as $sbas_id => $rights) {
|
||||
$user->ACL()->update_rights_to_sbas($sbas_id, $rights);
|
||||
}
|
||||
|
||||
@@ -519,9 +483,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$user->ACL()->revoke_unused_sbas_rights();
|
||||
|
||||
unset($user);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$appbox->get_connection()->rollBack();
|
||||
}
|
||||
}
|
||||
@@ -531,8 +493,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
public function apply_infos()
|
||||
{
|
||||
if (count($this->users) != 1)
|
||||
{
|
||||
if (count($this->users) != 1) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -540,8 +501,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$user = \User_adapter::getInstance(array_pop($users), \appbox::get_instance($this->core));
|
||||
|
||||
if ($user->is_template() || $user->is_special())
|
||||
{
|
||||
if ($user->is_template() || $user->is_special()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -566,7 +526,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$parm = $request->get_parms_from_serialized_datas($infos, 'user_infos');
|
||||
|
||||
if ($parm['email'] && !\mail::validateEmail($parm['email']))
|
||||
if ($parm['email'] && ! \mail::validateEmail($parm['email']))
|
||||
throw new \Exception_InvalidArgument(_('Email addess is not valid'));
|
||||
|
||||
$user->set_firstname($parm['first_name'])
|
||||
@@ -592,8 +552,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$template = \User_adapter::getInstance($this->request->get('template'), $appbox);
|
||||
|
||||
if ($template->get_template_owner()->get_id() != $session->get_usr_id())
|
||||
{
|
||||
if ($template->get_template_owner()->get_id() != $session->get_usr_id()) {
|
||||
throw new \Exception_Forbidden('You are not the owner of the template');
|
||||
}
|
||||
|
||||
@@ -601,12 +560,10 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
$base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin')));
|
||||
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
$user = \User_adapter::getInstance($usr_id, $appbox);
|
||||
|
||||
if ($user->is_template())
|
||||
{
|
||||
if ($user->is_template()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -620,8 +577,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
$this->base_id = (int) $this->request->get('base_id');
|
||||
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
|
||||
if ($this->request->get('quota'))
|
||||
$user->ACL()->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes'));
|
||||
@@ -641,10 +597,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$vxor_and = $this->request->get('vxor_and');
|
||||
$vxor_or = $this->request->get('vxor_or');
|
||||
|
||||
if ($vand_and && $vand_or && $vxor_and && $vxor_or)
|
||||
{
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
if ($vand_and && $vand_or && $vxor_and && $vxor_or) {
|
||||
foreach ($this->users as $usr_id) {
|
||||
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
|
||||
|
||||
$user->ACL()->set_masks_on_base($this->base_id, $vand_and, $vand_or, $vxor_and, $vxor_or);
|
||||
@@ -661,10 +615,9 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$dmin = $this->request->get('dmin') ? new \DateTime($this->request->get('dmin')) : null;
|
||||
$dmax = $this->request->get('dmax') ? new \DateTime($this->request->get('dmax')) : null;
|
||||
|
||||
$activate = !!$this->request->get('limit');
|
||||
$activate = ! ! $this->request->get('limit');
|
||||
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
|
||||
|
||||
$user->ACL()->set_limits($this->base_id, $activate, $dmin, $dmax);
|
||||
@@ -677,25 +630,20 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$adminACL = $authUser->ACL();
|
||||
$base_ids = array_keys($adminACL->get_granted_base(array('canadmin')));
|
||||
|
||||
foreach ($this->users as $usr_id)
|
||||
{
|
||||
foreach ($this->users as $usr_id) {
|
||||
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance($this->core));
|
||||
$ACL = $user->ACL();
|
||||
|
||||
if ($user->is_template())
|
||||
{
|
||||
if ($user->is_template()) {
|
||||
$template = $user;
|
||||
|
||||
if ($template->get_template_owner()->get_id() !== $authUser->get_id())
|
||||
{
|
||||
if ($template->get_template_owner()->get_id() !== $authUser->get_id()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($base_ids as $base_id)
|
||||
{
|
||||
if (!$ACL->has_access_to_base($base_id))
|
||||
{
|
||||
foreach ($base_ids as $base_id) {
|
||||
if ( ! $ACL->has_access_to_base($base_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -707,5 +655,4 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
$ACL->revoke_unused_sbas_rights();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,17 +22,18 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class Manage extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $results;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $query_parms;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
@@ -115,28 +116,21 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
|
||||
->limit($offset_start, $results_quantity)
|
||||
->execute();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$invite_id = \User_Adapter::get_usr_id_from_login('invite');
|
||||
$invite = \User_Adapter::getInstance($invite_id, $appbox);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$invite = \User_Adapter::create($appbox, 'invite', 'invite', '', false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$autoregister_id = \User_Adapter::get_usr_id_from_login('autoregister');
|
||||
$autoregister = \User_Adapter::getInstance($autoregister_id, $appbox);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$autoregister = \User_Adapter::create($appbox, 'autoregister', 'autoregister', '', false);
|
||||
}
|
||||
|
||||
foreach ($this->query_parms as $k => $v)
|
||||
{
|
||||
foreach ($this->query_parms as $k => $v) {
|
||||
if (is_null($v))
|
||||
$this->query_parms[$k] = false;
|
||||
}
|
||||
@@ -160,8 +154,7 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
$email = $this->request->get('value');
|
||||
|
||||
if(!\mail::validateEmail($email))
|
||||
{
|
||||
if ( ! \mail::validateEmail($email)) {
|
||||
throw new \Exception_InvalidArgument(_('Invalid mail address'));
|
||||
}
|
||||
|
||||
@@ -174,13 +167,10 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
|
||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$count = count($row);
|
||||
|
||||
if (!is_array($row) || $count == 0)
|
||||
{
|
||||
if ( ! is_array($row) || $count == 0) {
|
||||
$created_user = \User_Adapter::create($appbox, $email, \random::generatePassword(16), $email, false, false);
|
||||
$this->usr_id = $created_user->get_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->usr_id = $row['usr_id'];
|
||||
$created_user = \User_Adapter::getInstance($this->usr_id, $appbox);
|
||||
}
|
||||
@@ -192,8 +182,7 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
|
||||
{
|
||||
$name = $this->request->get('value');
|
||||
|
||||
if(trim($name) === '')
|
||||
{
|
||||
if (trim($name) === '') {
|
||||
throw new \Exception_InvalidArgument(_('Invalid template name'));
|
||||
}
|
||||
|
||||
@@ -206,5 +195,4 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
return $created_user;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class WorkZone extends Helper
|
||||
{
|
||||
|
||||
const BASKETS = 'baskets';
|
||||
const STORIES = 'stories';
|
||||
const VALIDATIONS = 'validations';
|
||||
@@ -71,11 +70,6 @@ class WorkZone extends Helper
|
||||
protected function sortBaskets(array $baskets)
|
||||
{
|
||||
$tmp_baskets = array();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ use Doctrine\Common\Cache\ApcCache;
|
||||
*/
|
||||
Class ApcAutoloader extends ApcCache implements CacheStrategy
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -34,5 +35,4 @@ Class ApcAutoloader extends ApcCache implements CacheStrategy
|
||||
{
|
||||
return extension_loaded('apc');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
*/
|
||||
class Autoloader extends UniversalClassLoader
|
||||
{
|
||||
|
||||
/**
|
||||
* An array of path to check
|
||||
* @var type
|
||||
@@ -43,8 +42,7 @@ class Autoloader extends UniversalClassLoader
|
||||
$this->paths['config'] = __DIR__ . '/../../../../config/classes/';
|
||||
$this->paths['library'] = __DIR__ . '/../../../classes/';
|
||||
|
||||
$getComposerClassMap = function()
|
||||
{
|
||||
$getComposerClassMap = function() {
|
||||
return require realpath(__DIR__ . '/../../../../vendor/.composer/autoload_classmap.php');
|
||||
};
|
||||
|
||||
@@ -56,8 +54,7 @@ class Autoloader extends UniversalClassLoader
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (!$file = $this->checkFile($class))
|
||||
{
|
||||
if ( ! $file = $this->checkFile($class)) {
|
||||
$file = parent::findFile($class);
|
||||
}
|
||||
|
||||
@@ -82,19 +79,16 @@ class Autoloader extends UniversalClassLoader
|
||||
*/
|
||||
private function checkFile($classname)
|
||||
{
|
||||
if (isset($this->classmap[$classname]))
|
||||
{
|
||||
if (isset($this->classmap[$classname])) {
|
||||
return $this->classmap[$classname];
|
||||
}
|
||||
|
||||
$normalized_classname = str_replace('_', '/', $classname);
|
||||
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
foreach ($this->paths as $path) {
|
||||
$file = $path . $normalized_classname . '.class.php';
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
@@ -108,5 +102,4 @@ class Autoloader extends UniversalClassLoader
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ require_once __DIR__ . '/Autoloader.php';
|
||||
*/
|
||||
class CacheAutoloader extends Autoloader
|
||||
{
|
||||
|
||||
/**
|
||||
* Array of all cache adapters
|
||||
* @var type
|
||||
@@ -56,12 +55,10 @@ class CacheAutoloader extends Autoloader
|
||||
|
||||
$this->prefix = $prefix;
|
||||
|
||||
foreach ($this->cacheAdapters as $className)
|
||||
{
|
||||
foreach ($this->cacheAdapters as $className) {
|
||||
$file = sprintf("%s/%sAutoloader.php", __DIR__, $className);
|
||||
|
||||
if (!file_exists($file))
|
||||
{
|
||||
if ( ! file_exists($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -69,27 +66,23 @@ class CacheAutoloader extends Autoloader
|
||||
|
||||
$className = sprintf("\Alchemy\Phrasea\Loader\%sAutoloader", $className);
|
||||
|
||||
if (!class_exists($className))
|
||||
{
|
||||
if ( ! class_exists($className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = new $className();
|
||||
|
||||
if($namespace)
|
||||
{
|
||||
if ($namespace) {
|
||||
$method->setNamespace($namespace);
|
||||
}
|
||||
|
||||
if ($method instanceof LoaderStrategy && $method->isAvailable())
|
||||
{
|
||||
if ($method instanceof LoaderStrategy && $method->isAvailable()) {
|
||||
$this->cacheAdapter = $method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->cacheAdapter)
|
||||
{
|
||||
if (null === $this->cacheAdapter) {
|
||||
throw new \Exception('No Cache available');
|
||||
}
|
||||
}
|
||||
@@ -101,8 +94,7 @@ class CacheAutoloader extends Autoloader
|
||||
{
|
||||
$file = $this->cacheAdapter->fetch($this->prefix . $class);
|
||||
|
||||
if (false === $file)
|
||||
{
|
||||
if (false === $file) {
|
||||
$this->cacheAdapter->save($this->prefix . $class, $file = parent::findFile($class));
|
||||
}
|
||||
|
||||
@@ -134,6 +126,4 @@ class CacheAutoloader extends Autoloader
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -25,5 +25,4 @@ interface LoaderStrategy
|
||||
* @Return boolean
|
||||
*/
|
||||
public function isAvailable();
|
||||
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ require_once __DIR__ . '/../../../../vendor/doctrine/common/lib/Doctrine/Common/
|
||||
|
||||
use Alchemy\Phrasea\Loader\LoaderStrategy as CacheStrategy;
|
||||
use Doctrine\Common\Cache\XcacheCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
@@ -34,5 +35,4 @@ Class XcacheAutoloader extends XcacheCache implements CacheStrategy
|
||||
{
|
||||
return extension_loaded('xcache') && PHP_SAPI !== 'cli';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
|
||||
|
||||
class Audio extends Provider
|
||||
{
|
||||
|
||||
const OPTION_BITRATE = 'bitrate';
|
||||
const OPTION_THREADS = 'threads';
|
||||
const OPTION_ACODEC = 'a_codec';
|
||||
@@ -44,8 +43,7 @@ class Audio extends Provider
|
||||
|
||||
public function getMediaAlchemystSpec()
|
||||
{
|
||||
if ( ! $this->spec)
|
||||
{
|
||||
if ( ! $this->spec) {
|
||||
$this->spec = new \MediaAlchemyst\Specification\Audio();
|
||||
}
|
||||
|
||||
@@ -55,5 +53,4 @@ class Audio extends Provider
|
||||
|
||||
return $this->spec;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
|
||||
|
||||
class FlexPaper extends Provider
|
||||
{
|
||||
|
||||
protected $options = array();
|
||||
|
||||
public function __construct()
|
||||
@@ -33,12 +32,10 @@ class FlexPaper extends Provider
|
||||
|
||||
public function getMediaAlchemystSpec()
|
||||
{
|
||||
if ( ! $this->spec)
|
||||
{
|
||||
if ( ! $this->spec) {
|
||||
$this->spec = new \MediaAlchemyst\Specification\Flash();
|
||||
}
|
||||
|
||||
return $this->spec;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
|
||||
|
||||
class Gif extends Image
|
||||
{
|
||||
|
||||
const OPTION_DELAY = 'delay';
|
||||
|
||||
public function __construct()
|
||||
@@ -35,8 +34,7 @@ class Gif extends Image
|
||||
|
||||
public function getMediaAlchemystSpec()
|
||||
{
|
||||
if ( ! $this->spec)
|
||||
{
|
||||
if ( ! $this->spec) {
|
||||
$this->spec = new \MediaAlchemyst\Specification\Animation();
|
||||
}
|
||||
|
||||
@@ -51,5 +49,4 @@ class Gif extends Image
|
||||
|
||||
return $this->spec;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,11 +13,11 @@ namespace Alchemy\Phrasea\Media\Subdef;
|
||||
|
||||
class Image extends Provider
|
||||
{
|
||||
|
||||
const OPTION_SIZE = 'size';
|
||||
const OPTION_RESOLUTION = 'resolution';
|
||||
const OPTION_STRIP = 'strip';
|
||||
const OPTION_QUALITY = 'quality';
|
||||
|
||||
protected $options = array();
|
||||
|
||||
public function __construct()
|
||||
@@ -40,8 +40,7 @@ class Image extends Provider
|
||||
|
||||
public function getMediaAlchemystSpec()
|
||||
{
|
||||
if ( ! $this->spec)
|
||||
{
|
||||
if ( ! $this->spec) {
|
||||
$this->spec = new \MediaAlchemyst\Specification\Image();
|
||||
}
|
||||
|
||||
@@ -55,5 +54,4 @@ class Image extends Provider
|
||||
|
||||
return $this->spec;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef\OptionType;
|
||||
|
||||
class Boolean implements OptionType
|
||||
{
|
||||
|
||||
protected $name;
|
||||
protected $default_value;
|
||||
protected $value;
|
||||
@@ -23,8 +22,7 @@ class Boolean implements OptionType
|
||||
$this->name = $name;
|
||||
$this->default_value = $default_value;
|
||||
|
||||
if ($default_value)
|
||||
{
|
||||
if ($default_value) {
|
||||
$this->setValue($default_value);
|
||||
}
|
||||
}
|
||||
@@ -50,5 +48,4 @@ class Boolean implements OptionType
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef\OptionType;
|
||||
|
||||
class Enum implements OptionType
|
||||
{
|
||||
|
||||
protected $default_value;
|
||||
protected $value;
|
||||
protected $available;
|
||||
@@ -24,16 +23,14 @@ class Enum implements OptionType
|
||||
$this->available = $available;
|
||||
$this->default_value = $default_value;
|
||||
|
||||
if ($default_value)
|
||||
{
|
||||
if ($default_value) {
|
||||
$this->setValue($default_value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
if ( ! in_array($value, $this->available))
|
||||
{
|
||||
if ( ! in_array($value, $this->available)) {
|
||||
throw new \Exception_InvalidArgument(
|
||||
sprintf(
|
||||
'The value provided `%s` for %s does not fit in range ; available are %s'
|
||||
@@ -68,5 +65,4 @@ class Enum implements OptionType
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@ interface OptionType
|
||||
const TYPE_BOOLEAN = 'Boolean';
|
||||
|
||||
public function getType();
|
||||
|
||||
public function getName();
|
||||
|
||||
public function getValue();
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef\OptionType;
|
||||
|
||||
class Range implements OptionType
|
||||
{
|
||||
|
||||
protected $min_value;
|
||||
protected $max_value;
|
||||
protected $default_value;
|
||||
@@ -28,16 +27,14 @@ class Range implements OptionType
|
||||
$this->default_value = $default_value;
|
||||
$this->step = $step;
|
||||
|
||||
if ($default_value)
|
||||
{
|
||||
if ($default_value) {
|
||||
$this->setValue($default_value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
if ($value > $this->max_value || $value < $this->min_value)
|
||||
{
|
||||
if ($value > $this->max_value || $value < $this->min_value) {
|
||||
throw new \Exception_InvalidArgument('The value provided does not fit in range');
|
||||
}
|
||||
|
||||
@@ -75,5 +72,4 @@ class Range implements OptionType
|
||||
{
|
||||
return $this->max_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
|
||||
|
||||
abstract class Provider implements Subdef
|
||||
{
|
||||
|
||||
protected $options = array();
|
||||
protected $spec;
|
||||
|
||||
@@ -40,5 +39,4 @@ abstract class Provider implements Subdef
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Media\Subdef;
|
||||
|
||||
interface Subdef
|
||||
{
|
||||
|
||||
const TYPE_IMAGE = 'image';
|
||||
const TYPE_ANIMATION = 'gif';
|
||||
const TYPE_VIDEO = 'video';
|
||||
@@ -25,5 +24,4 @@ interface Subdef
|
||||
public function getDescription();
|
||||
|
||||
public function getMediaAlchemystSpec();
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user