mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 20:13:28 +00:00
Cleanup controllers
This commit is contained in:
@@ -34,7 +34,7 @@ class Basket implements ControllerProviderInterface
|
|||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -53,8 +53,7 @@ class Bridge implements ControllerProviderInterface
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/manager/'
|
$controllers->post('/manager/', function(Application $app) {
|
||||||
, function(Application $app) {
|
|
||||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$user = $app['phraseanet.user'];
|
$user = $app['phraseanet.user'];
|
||||||
@@ -66,8 +65,7 @@ class Bridge implements ControllerProviderInterface
|
|||||||
, 'current_account_id' => ''
|
, 'current_account_id' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Bridge/index.html.twig', $params)
|
return $app['twig']->render('prod/actions/Bridge/index.html.twig', $params);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->get('/login/{api_name}/', function(Application $app, $api_name) {
|
$controllers->get('/login/{api_name}/', function(Application $app, $api_name) {
|
||||||
@@ -110,7 +108,7 @@ class Bridge implements ControllerProviderInterface
|
|||||||
|
|
||||||
$params = array('error_message' => $error_message);
|
$params = array('error_message' => $error_message);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Bridge/callback.html.twig', $params));
|
return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params);
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->get('/adapter/{account_id}/logout/', function(Application $app, $account_id) {
|
$controllers->get('/adapter/{account_id}/logout/', function(Application $app, $account_id) {
|
||||||
@@ -140,12 +138,10 @@ class Bridge implements ControllerProviderInterface
|
|||||||
, 'notice_message' => $app['request']->query->get('notice')
|
, 'notice_message' => $app['request']->query->get('notice')
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params));
|
return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params);
|
||||||
})
|
})->assert('account_id', '\d+');
|
||||||
->assert('account_id', '\d+');
|
|
||||||
|
|
||||||
$controllers->get('/adapter/{account_id}/load-elements/{type}/'
|
$controllers->get('/adapter/{account_id}/load-elements/{type}/', function($account_id, $type) use ($app) {
|
||||||
, function($account_id, $type) use ($app) {
|
|
||||||
$page = max((int) $app['request']->query->get('page'), 0);
|
$page = max((int) $app['request']->query->get('page'), 0);
|
||||||
$quantity = 5;
|
$quantity = 5;
|
||||||
$offset_start = max(($page - 1) * $quantity, 0);
|
$offset_start = max(($page - 1) * $quantity, 0);
|
||||||
@@ -165,12 +161,10 @@ class Bridge implements ControllerProviderInterface
|
|||||||
, 'notice_message' => $app['request']->query->get('notice')
|
, 'notice_message' => $app['request']->query->get('notice')
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params));
|
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
|
||||||
})
|
})->assert('account_id', '\d+');
|
||||||
->assert('account_id', '\d+');
|
|
||||||
|
|
||||||
$controllers->get('/adapter/{account_id}/load-containers/{type}/'
|
$controllers->get('/adapter/{account_id}/load-containers/{type}/', function(Application $app, $account_id, $type) {
|
||||||
, function(Application $app, $account_id, $type) {
|
|
||||||
|
|
||||||
$page = max((int) $app['request']->query->get('page'), 0);
|
$page = max((int) $app['request']->query->get('page'), 0);
|
||||||
$quantity = 5;
|
$quantity = 5;
|
||||||
@@ -190,12 +184,10 @@ class Bridge implements ControllerProviderInterface
|
|||||||
, 'notice_message' => $app['request']->query->get('notice')
|
, 'notice_message' => $app['request']->query->get('notice')
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params));
|
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
|
||||||
})
|
})->assert('account_id', '\d+');
|
||||||
->assert('account_id', '\d+');
|
|
||||||
|
|
||||||
$controllers->get('/action/{account_id}/{action}/{element_type}/'
|
$controllers->get('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
|
||||||
, function(Application $app, $account_id, $action, $element_type) {
|
|
||||||
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$account = \Bridge_Account::load_account($app, $account_id);
|
$account = \Bridge_Account::load_account($app, $account_id);
|
||||||
@@ -257,11 +249,10 @@ class Bridge implements ControllerProviderInterface
|
|||||||
|
|
||||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||||
|
|
||||||
return new Response($app['twig']->render($template, $params));
|
return $app['twig']->render($template, $params);
|
||||||
})->assert('account_id', '\d+');
|
})->assert('account_id', '\d+');
|
||||||
|
|
||||||
$controllers->post('/action/{account_id}/{action}/{element_type}/'
|
$controllers->post('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
|
||||||
, function(Application $app, $account_id, $action, $element_type) {
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$account = \Bridge_Account::load_account($app, $account_id);
|
$account = \Bridge_Account::load_account($app, $account_id);
|
||||||
|
|
||||||
@@ -302,7 +293,7 @@ class Bridge implements ControllerProviderInterface
|
|||||||
|
|
||||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||||
|
|
||||||
return new Response($app['twig']->render($template, $params));
|
return $app['twig']->render($template, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($elements as $element_id) {
|
foreach ($elements as $element_id) {
|
||||||
@@ -382,9 +373,9 @@ class Bridge implements ControllerProviderInterface
|
|||||||
, 'adapter_action' => 'upload'
|
, 'adapter_action' => 'upload'
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render(
|
return $app['twig']->render(
|
||||||
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params
|
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params
|
||||||
));
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/upload/', function(Application $app) {
|
$controllers->post('/upload/', function(Application $app) {
|
||||||
@@ -417,7 +408,7 @@ class Bridge implements ControllerProviderInterface
|
|||||||
, 'adapter_action' => 'upload'
|
, 'adapter_action' => 'upload'
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params));
|
return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($route->get_elements() as $record) {
|
foreach ($route->get_elements() as $record) {
|
||||||
|
@@ -233,8 +233,7 @@ class Edit implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
return $app['twig']->render('prod/actions/edit_default.html.twig', $params);
|
return $app['twig']->render('prod/actions/edit_default.html.twig', $params);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$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());
|
$datas = array('success' => false, 'message' => '', 'results' => array());
|
||||||
@@ -273,8 +272,7 @@ class Edit implements ControllerProviderInterface
|
|||||||
$datas['results'] = $list;
|
$datas['results'] = $list;
|
||||||
|
|
||||||
return $app->json($datas);
|
return $app->json($datas);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$controllers->post('/apply/', function(Application $app, Request $request) {
|
$controllers->post('/apply/', function(Application $app, Request $request) {
|
||||||
|
|
||||||
@@ -412,8 +410,7 @@ class Edit implements ControllerProviderInterface
|
|||||||
|
|
||||||
|
|
||||||
return $app['twig']->render('prod/actions/edit_default.html.twig', array('edit' => $editing, 'message' => ''));
|
return $app['twig']->render('prod/actions/edit_default.html.twig', array('edit' => $editing, 'message' => ''));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -37,11 +37,11 @@ class Feed implements ControllerProviderInterface
|
|||||||
$feeds = \Feed_Collection::load_all($app, $user);
|
$feeds = \Feed_Collection::load_all($app, $user);
|
||||||
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds)));
|
return $app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds));
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I've selected a publication for my ocs, let's publish them
|
* I've selected a publication for my docs, let's publish them
|
||||||
*/
|
*/
|
||||||
$controllers->post('/entry/create/', function(Application $app, Request $request) {
|
$controllers->post('/entry/create/', function(Application $app, Request $request) {
|
||||||
try {
|
try {
|
||||||
@@ -118,7 +118,7 @@ class Feed implements ControllerProviderInterface
|
|||||||
throw new \Exception_Forbidden('You have no access to this feed');
|
throw new \Exception_Forbidden('You have no access to this feed');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $new_feed->is_publisher($user)) {
|
if (!$new_feed->is_publisher($user)) {
|
||||||
throw new \Exception_Forbidden('You are not publisher of this feed');
|
throw new \Exception_Forbidden('You are not publisher of this feed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -183,11 +183,9 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = $app['twig']->render(
|
return $app['twig']->render(
|
||||||
'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles)
|
'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles)
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($html);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +240,7 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
$ret = array('success' => false, 'message' => '', 'result' => array());
|
$ret = array('success' => false, 'message' => '', 'result' => array());
|
||||||
|
|
||||||
//Optional parameter
|
//Optional parameter
|
||||||
$keepAttributes = ! ! $request->request->get('keep_attributes', false);
|
$keepAttributes = !!$request->request->get('keep_attributes', false);
|
||||||
$attributesToKeep = $request->request->get('attributes', array());
|
$attributesToKeep = $request->request->get('attributes', array());
|
||||||
|
|
||||||
//Mandatory parameter
|
//Mandatory parameter
|
||||||
@@ -288,8 +286,8 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
foreach ($lazaretFile->getAttributes() as $attr) {
|
foreach ($lazaretFile->getAttributes() as $attr) {
|
||||||
|
|
||||||
//Check which ones to keep
|
//Check which ones to keep
|
||||||
if ( ! ! count($attributesToKeep)) {
|
if (!!count($attributesToKeep)) {
|
||||||
if ( ! in_array($attr->getId(), $attributesToKeep)) {
|
if (!in_array($attr->getId(), $attributesToKeep)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -460,7 +458,7 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $found) {
|
if (!$found) {
|
||||||
$ret['message'] = _('The destination record provided is not allowed');
|
$ret['message'] = _('The destination record provided is not allowed');
|
||||||
|
|
||||||
return $app->json($ret);
|
return $app->json($ret);
|
||||||
@@ -514,11 +512,9 @@ class Lazaret implements ControllerProviderInterface
|
|||||||
|
|
||||||
$lazaretThumbFileName = $app['phraseanet.registry']->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getThumbFilename();
|
$lazaretThumbFileName = $app['phraseanet.registry']->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getThumbFilename();
|
||||||
|
|
||||||
$response = \set_export::stream_file(
|
return \set_export::stream_file(
|
||||||
$app['phraseanet.registry'], $lazaretThumbFileName, $lazaretFile->getOriginalName(), 'image/jpeg', 'inline'
|
$app['phraseanet.registry'], $lazaretThumbFileName, $lazaretFile->getOriginalName(), 'image/jpeg', 'inline'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -71,7 +71,7 @@ class MoveCollection implements ControllerProviderInterface
|
|||||||
return $app->json($datas);
|
return $app->json($datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) {
|
if (!$user->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) {
|
||||||
$datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination(), $app));
|
$datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination(), $app));
|
||||||
return $app->json($datas);
|
return $app->json($datas);
|
||||||
}
|
}
|
||||||
|
@@ -30,13 +30,13 @@ class MustacheLoader implements ControllerProviderInterface
|
|||||||
$controllers->get('/', function(Application $app, Request $request) {
|
$controllers->get('/', function(Application $app, Request $request) {
|
||||||
$template_name = $request->query->get('template');
|
$template_name = $request->query->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);
|
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$template_path = realpath(__DIR__ . '/../../../../../templates/web/Mustache/Prod/' . $template_name . '.Mustache.html');
|
$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);
|
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -153,24 +153,24 @@ class Order implements ControllerProviderInterface
|
|||||||
|
|
||||||
foreach ($records as $key => $record) {
|
foreach ($records as $key => $record) {
|
||||||
if ($collectionHasOrderAdmins->containsKey($record->get_base_id())) {
|
if ($collectionHasOrderAdmins->containsKey($record->get_base_id())) {
|
||||||
if ( ! $collectionHasOrderAdmins->get($record->get_base_id())) {
|
if (!$collectionHasOrderAdmins->get($record->get_base_id())) {
|
||||||
$records->remove($key);
|
$records->remove($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasOneAdmin = ! ! count($query->on_base_ids(array($record->get_base_id()))
|
$hasOneAdmin = !!count($query->on_base_ids(array($record->get_base_id()))
|
||||||
->who_have_right(array('order_master'))
|
->who_have_right(array('order_master'))
|
||||||
->execute()->get_results());
|
->execute()->get_results());
|
||||||
|
|
||||||
$collectionHasOrderAdmins->set($record->get_base_id(), $hasOneAdmin);
|
$collectionHasOrderAdmins->set($record->get_base_id(), $hasOneAdmin);
|
||||||
|
|
||||||
if ( ! $hasOneAdmin) {
|
if (!$hasOneAdmin) {
|
||||||
$toRemove[] = $key;
|
$toRemove[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($toRemove as $key) {
|
foreach ($toRemove as $key) {
|
||||||
if($records->containsKey($key)) {
|
if ($records->containsKey($key)) {
|
||||||
$records->remove($key);
|
$records->remove($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ class Order implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order->send_elements($app, $request->request->get('elements', array()), ! ! $request->request->get('force', false));
|
$order->send_elements($app, $request->request->get('elements', array()), !!$request->request->get('force', false));
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
@@ -58,13 +58,12 @@ class Printer implements ControllerProviderInterface
|
|||||||
* @todo : merge this shitty fix with Response object.
|
* @todo : merge this shitty fix with Response object.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ( ! headers_sent()) {
|
if (!headers_sent()) {
|
||||||
header("Pragma: public");
|
header("Pragma: public");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
|
return new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -116,9 +116,8 @@ class Push implements ControllerProviderInterface
|
|||||||
'RecommendedUsers' => $RecommendedUsers
|
'RecommendedUsers' => $RecommendedUsers
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Push.html.twig', $params));
|
return $app['twig']->render('prod/actions/Push.html.twig', $params);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$controllers->post('/validateform/', function(Application $app) use ($userSelection) {
|
$controllers->post('/validateform/', function(Application $app) use ($userSelection) {
|
||||||
$push = new RecordHelper\Push($app, $app['request']);
|
$push = new RecordHelper\Push($app, $app['request']);
|
||||||
@@ -135,9 +134,8 @@ class Push implements ControllerProviderInterface
|
|||||||
'RecommendedUsers' => $RecommendedUsers
|
'RecommendedUsers' => $RecommendedUsers
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/actions/Push.html.twig', $params));
|
return $app['twig']->render('prod/actions/Push.html.twig', $params);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$controllers->post('/send/', function(Application $app) {
|
$controllers->post('/send/', function(Application $app) {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
@@ -257,8 +255,7 @@ class Push implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $app->json($ret);
|
return $app->json($ret);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$controllers->post('/validate/', function(Application $app) {
|
$controllers->post('/validate/', function(Application $app) {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
@@ -464,11 +461,9 @@ class Push implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $app->json($ret);
|
return $app->json($ret);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$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;
|
$datas = null;
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
@@ -582,7 +577,7 @@ class Push implements ControllerProviderInterface
|
|||||||
$controllers->get('/add-user/', function(Application $app, Request $request) {
|
$controllers->get('/add-user/', function(Application $app, Request $request) {
|
||||||
$params = array('callback' => $request->query->get('callback'));
|
$params = array('callback' => $request->query->get('callback'));
|
||||||
|
|
||||||
return new Response($app['twig']->render('prod/User/Add.html.twig', $params));
|
return $app['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) {
|
||||||
@@ -621,8 +616,7 @@ class Push implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $app->json($datas);
|
return $app->json($datas);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$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) {
|
||||||
|
|
||||||
@@ -685,8 +679,7 @@ class Push implements ControllerProviderInterface
|
|||||||
$app['twig']->render('prod/actions/Feedback/list.html.twig', $params)
|
$app['twig']->render('prod/actions/Feedback/list.html.twig', $params)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
})->assert('list_id', '\d+');
|
||||||
)->assert('list_id', '\d+');
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ class Query implements ControllerProviderInterface
|
|||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -115,7 +115,7 @@ class Query implements ControllerProviderInterface
|
|||||||
|
|
||||||
if (min($d2top, $d2bottom) < 4) {
|
if (min($d2top, $d2bottom) < 4) {
|
||||||
if ($d2bottom < 4) {
|
if ($d2bottom < 4) {
|
||||||
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i ++ ) {
|
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i++) {
|
||||||
if ($i == $page)
|
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)) . '" class="btn btn-mini" />';
|
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||||
else
|
else
|
||||||
@@ -129,7 +129,7 @@ class Query implements ControllerProviderInterface
|
|||||||
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
||||||
else
|
else
|
||||||
$start = 1;
|
$start = 1;
|
||||||
for ($i = ($start); $i <= $npages; $i ++ ) {
|
for ($i = ($start); $i <= $npages; $i++) {
|
||||||
if ($i == $page)
|
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)) . '" class="btn btn-mini" />';
|
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||||
else
|
else
|
||||||
@@ -139,7 +139,7 @@ class Query implements ControllerProviderInterface
|
|||||||
} else {
|
} else {
|
||||||
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
||||||
|
|
||||||
for ($i = ($page - 2); $i <= ($page + 2); $i ++ ) {
|
for ($i = ($page - 2); $i <= ($page + 2); $i++) {
|
||||||
if ($i == $page)
|
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)) . '" class="btn btn-mini" />';
|
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||||
else
|
else
|
||||||
|
@@ -33,7 +33,7 @@ class Root implements ControllerProviderInterface
|
|||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -102,7 +102,7 @@ class Root implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = $app['twig']->render('prod/index.html.twig', array(
|
return $app['twig']->render('prod/index.html.twig', array(
|
||||||
'module_name' => 'Production',
|
'module_name' => 'Production',
|
||||||
'WorkZone' => new Helper\WorkZone($app, $app['request']),
|
'WorkZone' => new Helper\WorkZone($app, $app['request']),
|
||||||
'module_prod' => new Helper\Prod($app, $app['request']),
|
'module_prod' => new Helper\Prod($app, $app['request']),
|
||||||
@@ -124,8 +124,6 @@ class Root implements ControllerProviderInterface
|
|||||||
'thesau_json_bas2sbas' => json_encode($bas2sbas),
|
'thesau_json_bas2sbas' => json_encode($bas2sbas),
|
||||||
'thesau_languages' => \User_Adapter::avLanguages(),
|
'thesau_languages' => \User_Adapter::avLanguages(),
|
||||||
));
|
));
|
||||||
|
|
||||||
return new Response($out);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/multi-export/', function(Application $app, Request $request) {
|
$controllers->post('/multi-export/', function(Application $app, Request $request) {
|
||||||
|
@@ -30,8 +30,7 @@ class Story implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->get('/create/', function(Application $app) {
|
$controllers->get('/create/', function(Application $app) {
|
||||||
|
return $app['twig']->render('prod/Story/Create.html.twig', array());
|
||||||
return new Response($app['twig']->render('prod/Story/Create.html.twig', array()));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/', function(Application $app, Request $request) {
|
$controllers->post('/', function(Application $app, Request $request) {
|
||||||
@@ -120,9 +119,7 @@ class Story implements ControllerProviderInterface
|
|||||||
return new Response($html);
|
return new Response($html);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->post(
|
$controllers->post('/{sbas_id}/{record_id}/addElements/', function(Application $app, Request $request, $sbas_id, $record_id) {
|
||||||
'/{sbas_id}/{record_id}/addElements/'
|
|
||||||
, function(Application $app, Request $request, $sbas_id, $record_id) {
|
|
||||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||||
|
|
||||||
$user = $app['phraseanet.user'];
|
$user = $app['phraseanet.user'];
|
||||||
@@ -168,9 +165,7 @@ class Story implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->post(
|
$controllers->post('/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/', function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
|
||||||
'/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/'
|
|
||||||
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
|
|
||||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||||
|
|
||||||
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
|
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
|
||||||
@@ -220,9 +215,7 @@ class Story implements ControllerProviderInterface
|
|||||||
->assert('sbas_id', '\d+')
|
->assert('sbas_id', '\d+')
|
||||||
->assert('record_id', '\d+');
|
->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->post(
|
$controllers->post('/{sbas_id}/{record_id}/reorder/', function(Application $app, $sbas_id, $record_id) {
|
||||||
'/{sbas_id}/{record_id}/reorder/'
|
|
||||||
, function(Application $app, $sbas_id, $record_id) {
|
|
||||||
$ret = array('success' => false, 'message' => _('An error occured'));
|
$ret = array('success' => false, 'message' => _('An error occured'));
|
||||||
try {
|
try {
|
||||||
$user = $app['phraseanet.user'];
|
$user = $app['phraseanet.user'];
|
||||||
|
@@ -167,11 +167,7 @@ class Tools implements ControllerProviderInterface
|
|||||||
, 'errorMessage' => $errorMessage
|
, 'errorMessage' => $errorMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render($template, $var));
|
return $app['twig']->render($template, $var);
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/chgthumb/', function(Application $app, Request $request) {
|
$controllers->post('/chgthumb/', function(Application $app, Request $request) {
|
||||||
@@ -214,7 +210,7 @@ class Tools implements ControllerProviderInterface
|
|||||||
, 'errorMessage' => $errorMessage
|
, 'errorMessage' => $errorMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render($template, $var));
|
return $app['twig']->render($template, $var);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class Tooltip implements ControllerProviderInterface
|
|||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -128,8 +128,7 @@ class Tooltip implements ControllerProviderInterface
|
|||||||
'view' => $context,
|
'view' => $context,
|
||||||
'highlight' => $app['request']->request->get('query'),
|
'highlight' => $app['request']->request->get('query'),
|
||||||
'searchEngine' => $search_engine,
|
'searchEngine' => $search_engine,
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)
|
public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)
|
||||||
|
@@ -111,8 +111,7 @@ class Upload implements ControllerProviderInterface
|
|||||||
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
||||||
'maxFileSize' => $maxFileSize,
|
'maxFileSize' => $maxFileSize,
|
||||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,8 +131,7 @@ class Upload implements ControllerProviderInterface
|
|||||||
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
||||||
'maxFileSize' => $maxFileSize,
|
'maxFileSize' => $maxFileSize,
|
||||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,17 +163,17 @@ class Upload implements ControllerProviderInterface
|
|||||||
|
|
||||||
$base_id = $request->request->get('base_id');
|
$base_id = $request->request->get('base_id');
|
||||||
|
|
||||||
if ( ! $base_id) {
|
if (!$base_id) {
|
||||||
throw new \Exception_BadRequest('Missing base_id parameter');
|
throw new \Exception_BadRequest('Missing base_id parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $app['phraseanet.user']->ACL()->has_right_on_base($base_id, 'canaddrecord')) {
|
if (!$app['phraseanet.user']->ACL()->has_right_on_base($base_id, 'canaddrecord')) {
|
||||||
throw new \Exception_Forbidden('User is not allowed to add record on this collection');
|
throw new \Exception_Forbidden('User is not allowed to add record on this collection');
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = current($request->files->get('files'));
|
$file = current($request->files->get('files'));
|
||||||
|
|
||||||
if ( ! $file->isValid()) {
|
if (!$file->isValid()) {
|
||||||
throw new \Exception_BadRequest('Uploaded file is invalid');
|
throw new \Exception_BadRequest('Uploaded file is invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +213,7 @@ class Upload implements ControllerProviderInterface
|
|||||||
|
|
||||||
$callback = function($element, $visa, $code) use (&$reasons, &$elementCreated) {
|
$callback = function($element, $visa, $code) use (&$reasons, &$elementCreated) {
|
||||||
foreach ($visa->getResponses() as $response) {
|
foreach ($visa->getResponses() as $response) {
|
||||||
if ( ! $response->isOk()) {
|
if (!$response->isOk()) {
|
||||||
$reasons[] = $response->getMessage();
|
$reasons[] = $response->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +227,7 @@ class Upload implements ControllerProviderInterface
|
|||||||
|
|
||||||
$app['filesystem']->rename($renamedFilename, $uploadedFilename);
|
$app['filesystem']->rename($renamedFilename, $uploadedFilename);
|
||||||
|
|
||||||
if ( ! ! $forceBehavior) {
|
if (!!$forceBehavior) {
|
||||||
$reasons = array();
|
$reasons = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +291,7 @@ class Upload implements ControllerProviderInterface
|
|||||||
|
|
||||||
foreach ($user->ACL()->get_granted_base(array('canaddrecord')) as $collection) {
|
foreach ($user->ACL()->get_granted_base(array('canaddrecord')) as $collection) {
|
||||||
$databox = $collection->get_databox();
|
$databox = $collection->get_databox();
|
||||||
if ( ! isset($collections[$databox->get_sbas_id()])) {
|
if (!isset($collections[$databox->get_sbas_id()])) {
|
||||||
$collections[$databox->get_sbas_id()] = array(
|
$collections[$databox->get_sbas_id()] = array(
|
||||||
'databox' => $databox,
|
'databox' => $databox,
|
||||||
'databox_collections' => array()
|
'databox_collections' => array()
|
||||||
|
@@ -30,7 +30,7 @@ class UserPreferences implements ControllerProviderInterface
|
|||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -179,7 +179,7 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( ! $list_name) {
|
if (!$list_name) {
|
||||||
throw new ControllerException(_('List name is required'));
|
throw new ControllerException(_('List name is required'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
try {
|
try {
|
||||||
$list_name = $request->request->get('name');
|
$list_name = $request->request->get('name');
|
||||||
|
|
||||||
if ( ! $list_name) {
|
if (!$list_name) {
|
||||||
throw new ControllerException(_('List name is required'));
|
throw new ControllerException(_('List name is required'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +388,7 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
$user = $app['phraseanet.user'];
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( ! is_array($request->request->get('usr_ids'))) {
|
if (!is_array($request->request->get('usr_ids'))) {
|
||||||
throw new ControllerException('Invalid or missing parameter usr_ids');
|
throw new ControllerException('Invalid or missing parameter usr_ids');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,9 +484,9 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
UsrListOwner::ROLE_ADMIN,
|
UsrListOwner::ROLE_ADMIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! $app['request']->request->get('role'))
|
if (!$app['request']->request->get('role'))
|
||||||
throw new \Exception_BadRequest('Missing role parameter');
|
throw new \Exception_BadRequest('Missing role parameter');
|
||||||
elseif ( ! in_array($app['request']->request->get('role'), $availableRoles))
|
elseif (!in_array($app['request']->request->get('role'), $availableRoles))
|
||||||
throw new \Exception_BadRequest('Role is invalid');
|
throw new \Exception_BadRequest('Role is invalid');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -32,7 +32,7 @@ class WorkZone implements ControllerProviderInterface
|
|||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -121,7 +121,7 @@ class WorkZone implements ControllerProviderInterface
|
|||||||
|
|
||||||
public function attachStories(Application $app, Request $request)
|
public function attachStories(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
if ( ! $request->request->get('stories')) {
|
if (!$request->request->get('stories')) {
|
||||||
throw new \Exception_BadRequest();
|
throw new \Exception_BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,16 +137,16 @@ class WorkZone implements ControllerProviderInterface
|
|||||||
$element = explode('_', $element);
|
$element = explode('_', $element);
|
||||||
$Story = new \record_adapter($app, $element[0], $element[1]);
|
$Story = new \record_adapter($app, $element[0], $element[1]);
|
||||||
|
|
||||||
if ( ! $Story->is_grouping()) {
|
if (!$Story->is_grouping()) {
|
||||||
throw new \Exception('You can only attach stories');
|
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');
|
throw new \Exception_Forbidden('You do not have access to this Story');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($StoryWZRepo->findUserStory($app, $user, $Story)) {
|
if ($StoryWZRepo->findUserStory($app, $user, $Story)) {
|
||||||
$alreadyFixed ++;
|
$alreadyFixed++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ class WorkZone implements ControllerProviderInterface
|
|||||||
$StoryWZ->setRecord($Story);
|
$StoryWZ->setRecord($Story);
|
||||||
|
|
||||||
$app['EM']->persist($StoryWZ);
|
$app['EM']->persist($StoryWZ);
|
||||||
$done ++;
|
$done++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$app['EM']->flush();
|
$app['EM']->flush();
|
||||||
@@ -209,7 +209,7 @@ class WorkZone implements ControllerProviderInterface
|
|||||||
/* @var $repository \Repositories\StoryWZRepository */
|
/* @var $repository \Repositories\StoryWZRepository */
|
||||||
$StoryWZ = $repository->findUserStory($app, $user, $Story);
|
$StoryWZ = $repository->findUserStory($app, $user, $Story);
|
||||||
|
|
||||||
if ( ! $StoryWZ) {
|
if (!$StoryWZ) {
|
||||||
throw new \Exception_NotFound('Story not found');
|
throw new \Exception_NotFound('Story not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user