Fix CS lib/Alchemy

This commit is contained in:
Romain Neutron
2013-01-29 16:38:00 +01:00
parent bf470b69d7
commit 53206af159
87 changed files with 578 additions and 643 deletions

View File

@@ -160,7 +160,7 @@ class Application extends SilexApplication
if ($this['debug'] === true) { if ($this['debug'] === true) {
ini_set('display_errors', 'on'); ini_set('display_errors', 'on');
if($this->getEnvironment() === 'dev') { if ($this->getEnvironment() === 'dev') {
ini_set('log_errors', 'on'); ini_set('log_errors', 'on');
ini_set('error_log', __DIR__ . '/../../../logs/php_error.log'); ini_set('error_log', __DIR__ . '/../../../logs/php_error.log');
} }
@@ -368,8 +368,8 @@ class Application extends SilexApplication
$response = $event->getResponse(); $response = $event->getResponse();
foreach ($response->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY) as $cookie_domains) { foreach ($response->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY) as $cookie_domains) {
foreach($cookie_domains as $cookie_paths) { foreach ($cookie_domains as $cookie_paths) {
foreach($cookie_paths as $cookie) { foreach ($cookie_paths as $cookie) {
$response->headers->removeCookie($cookie->getName(), $cookie->getPath(), $cookie->getDomain()); $response->headers->removeCookie($cookie->getName(), $cookie->getPath(), $cookie->getDomain());
} }
} }
@@ -408,11 +408,12 @@ class Application extends SilexApplication
return $event->getRequest()->getLocale(); return $event->getRequest()->getLocale();
} }
foreach($app['bad-faith']->headerLists['accept_language']->items as $language) { foreach ($app['bad-faith']->headerLists['accept_language']->items as $language) {
$code = $language->lang.'_'.$language->sublang; $code = $language->lang.'_'.$language->sublang;
if(isset($languages[$code])) { if (isset($languages[$code])) {
$event->getRequest()->setLocale($code); $event->getRequest()->setLocale($code);
return $event->getRequest()->getLocale(); return $event->getRequest()->getLocale();
break; break;
} }
@@ -651,4 +652,3 @@ class Application extends SilexApplication
$this->sessionCookieEnabled = false; $this->sessionCookieEnabled = false;
} }
} }

View File

@@ -710,7 +710,6 @@ return call_user_func(function($environment = 'prod') {
})->assert('databox_id', '\d+')->assert('story_id', '\d+'); })->assert('databox_id', '\d+')->assert('story_id', '\d+');
$app->get('/stories/{any_id}/{anyother_id}/', $bad_request_exception); $app->get('/stories/{any_id}/{anyother_id}/', $bad_request_exception);
/** /**
* Route Errors * Route Errors
*/ */

View File

@@ -15,7 +15,6 @@ use Silex\Application as SilexApplication;
use Alchemy\Phrasea\Application as PhraseaApplication; use Alchemy\Phrasea\Application as PhraseaApplication;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
return call_user_func(function($environment = 'prod') { return call_user_func(function($environment = 'prod') {
$app = new PhraseaApplication($environment); $app = new PhraseaApplication($environment);

View File

@@ -83,7 +83,6 @@ return call_user_func(function($environment = 'prod') {
$app->openAccount($auth); $app->openAccount($auth);
} catch (\Exception $e) { } catch (\Exception $e) {
return new Response($app['twig']->render($template, array("auth" => $oauth2_adapter))); return new Response($app['twig']->render($template, array("auth" => $oauth2_adapter)));
} }
} else { } else {

View File

@@ -28,7 +28,7 @@ class CLI extends Application
* @param string $name Name for this application. * @param string $name Name for this application.
* @param string|null $version Version number for this application. * @param string|null $version Version number for this application.
*/ */
function __construct($name, $version = null, $environment = null) public function __construct($name, $version = null, $environment = null)
{ {
parent::__construct($environment); parent::__construct($environment);

View File

@@ -110,4 +110,3 @@ class Manager
file_put_contents($this->cacheFile->getPathname(), $datas); file_put_contents($this->cacheFile->getPathname(), $datas);
} }
} }

View File

@@ -71,6 +71,7 @@ class RecordAdd extends Command
if (strtolower($continue) !== 'y') { if (strtolower($continue) !== 'y') {
$output->writeln('Aborted !'); $output->writeln('Aborted !');
return; return;
} }

View File

@@ -32,4 +32,3 @@ interface DatasUpgraderInterface
*/ */
public function getTimeEstimation(); public function getTimeEstimation();
} }

View File

@@ -101,7 +101,6 @@ class Step35 implements DatasUpgraderInterface
} while (count($rs) > 0); } while (count($rs) > 0);
} }
foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) {
$this->ensureDropMigrateColumn($databox); $this->ensureDropMigrateColumn($databox);
} }

View File

@@ -102,7 +102,7 @@ EOF
{ {
$this->generateUpgradesFromOption($input); $this->generateUpgradesFromOption($input);
if ( ! $this->upgrades) { if (! $this->upgrades) {
throw new \Exception('No upgrade available'); throw new \Exception('No upgrade available');
} }

View File

@@ -499,7 +499,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $msg, 'msg' => $msg,
@@ -532,7 +531,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Successful removal') : _('An error occured'), 'msg' => $success ? _('Successful removal') : _('An error occured'),
@@ -565,7 +563,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Successful removal') : _('An error occured'), 'msg' => $success ? _('Successful removal') : _('An error occured'),
@@ -598,7 +595,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Successful removal') : _('An error occured'), 'msg' => $success ? _('Successful removal') : _('An error occured'),
@@ -632,7 +628,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Successful removal') : _('An error occured'), 'msg' => $success ? _('Successful removal') : _('An error occured'),
@@ -810,7 +805,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $msg 'msg' => $msg
@@ -1035,7 +1029,7 @@ class Collection implements ControllerProviderInterface
if ($ki == 'status') { if ($ki == 'status') {
$pref['status'] = $vi; $pref['status'] = $vi;
} else if ($ki != 'sugestedValues') { } elseif ($ki != 'sugestedValues') {
$pref['xml'] = $vi->asXML(); $pref['xml'] = $vi->asXML();
} }
@@ -1078,7 +1072,6 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Successful update') : _('An error occured'), 'msg' => $success ? _('Successful update') : _('An error occured'),

View File

@@ -14,7 +14,6 @@ namespace Alchemy\Phrasea\Controller\Admin;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ConnectedUsers implements ControllerProviderInterface class ConnectedUsers implements ControllerProviderInterface
{ {
@@ -27,7 +26,6 @@ class ConnectedUsers implements ControllerProviderInterface
$app['firewall']->requireAccessToModule('Admin'); $app['firewall']->requireAccessToModule('Admin');
}); });
$controllers->get('/', $this->call('listConnectedUsers')); $controllers->get('/', $this->call('listConnectedUsers'));
return $controllers; return $controllers;

View File

@@ -164,7 +164,6 @@ class Dashboard implements ControllerProviderInterface
public function flush(Application $app, Request $request) public function flush(Application $app, Request $request)
{ {
if ($app['phraseanet.cache-service']->flushAll()) { if ($app['phraseanet.cache-service']->flushAll()) {
return $app->redirect('/admin/dashboard/?flush_cache=ok'); return $app->redirect('/admin/dashboard/?flush_cache=ok');
} }

View File

@@ -931,7 +931,6 @@ class Databox implements ControllerProviderInterface
public function createCollection(Application $app, Request $request, $databox_id) public function createCollection(Application $app, Request $request, $databox_id)
{ {
if (($name = trim($request->request->get('name', ''))) === '') { if (($name = trim($request->request->get('name', ''))) === '') {
return $app->redirect('/admin/databox/' . $databox_id . '/collection/error=name'); return $app->redirect('/admin/databox/' . $databox_id . '/collection/error=name');
} }

View File

@@ -33,7 +33,6 @@ class Databoxes implements ControllerProviderInterface
$app['firewall']->requireAccessToModule('admin'); $app['firewall']->requireAccessToModule('admin');
}); });
/** /**
* Get Databases control panel * Get Databases control panel
* *
@@ -50,7 +49,6 @@ class Databoxes implements ControllerProviderInterface
$controllers->get('/', $this->call('getDatabases')) $controllers->get('/', $this->call('getDatabases'))
->bind('admin_databases'); ->bind('admin_databases');
/** /**
* Create Database * Create Database
* *
@@ -299,6 +297,7 @@ class Databoxes implements ControllerProviderInterface
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1'); return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
} catch (\Exception $e) { } catch (\Exception $e) {
$app['phraseanet.appbox']->get_connection()->rollBack(); $app['phraseanet.appbox']->get_connection()->rollBack();
return $app->redirect('/admin/databoxes/?success=0&error=mount-failed'); return $app->redirect('/admin/databoxes/?success=0&error=mount-failed');
} }
} }
@@ -335,7 +334,6 @@ class Databoxes implements ControllerProviderInterface
public function databasesUpgrade(Application $app, Request $request) public function databasesUpgrade(Application $app, Request $request)
{ {
if (\phrasea::is_scheduler_started($app)) { if (\phrasea::is_scheduler_started($app)) {
return $app->redirect('/admin/databoxes/?success=0&error=scheduler-started'); return $app->redirect('/admin/databoxes/?success=0&error=scheduler-started');
} }

View File

@@ -16,7 +16,6 @@ use PHPExiftool\Driver\TagProvider;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/** /**
* *
@@ -227,7 +226,6 @@ class Description implements ControllerProviderInterface
$field = \databox_field::create($app, $databox, $request->request->get('newfield'), $request->request->get('newfield_multi')); $field = \databox_field::create($app, $databox, $request->request->get('newfield'), $request->request->get('newfield_multi'));
} }
if (is_array($request->request->get('todelete_ids'))) { if (is_array($request->request->get('todelete_ids'))) {
foreach ($request->request->get('todelete_ids') as $id) { foreach ($request->request->get('todelete_ids') as $id) {
try { try {

View File

@@ -32,8 +32,6 @@ class TaskManager implements ControllerProviderInterface
return $app->redirect('/admin/task-manager/tasks/'); return $app->redirect('/admin/task-manager/tasks/');
}); });
/* /*
* route /admin/task-manager/tasks/ * route /admin/task-manager/tasks/
* tasks status in json * tasks status in json
@@ -43,7 +41,6 @@ class TaskManager implements ControllerProviderInterface
$controllers->get('/tasks/', function(Application $app, Request $request) { $controllers->get('/tasks/', function(Application $app, Request $request) {
if ($request->getContentType() == 'json') { if ($request->getContentType() == 'json') {
return $app->json($app['task-manager']->toArray()); return $app->json($app['task-manager']->toArray());
} else { } else {
@@ -126,7 +123,6 @@ class TaskManager implements ControllerProviderInterface
}, 200, array('Content-Type' => 'text/html')); }, 200, array('Content-Type' => 'text/html'));
}); });
$controllers->get('/task/{id}/log', function(Application $app, Request $request, $id) { $controllers->get('/task/{id}/log', function(Application $app, Request $request, $id) {
$logdir = \p4string::addEndSlash($app['phraseanet.registry']->get('GV_RootPath') . 'logs'); $logdir = \p4string::addEndSlash($app['phraseanet.registry']->get('GV_RootPath') . 'logs');
@@ -183,6 +179,7 @@ class TaskManager implements ControllerProviderInterface
/* /*
* todo : add a message back * todo : add a message back
*/ */
return $app->redirect('/admin/task-manager/tasks/'); return $app->redirect('/admin/task-manager/tasks/');
} }
}); });
@@ -246,7 +243,6 @@ class TaskManager implements ControllerProviderInterface
return $app->json(true); return $app->json(true);
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->json(false); return $app->json(false);
} }
}); });
@@ -279,7 +275,6 @@ class TaskManager implements ControllerProviderInterface
return $app->json(true); return $app->json(true);
} catch (\Exception $e) { } catch (\Exception $e) {
return new Response( return new Response(
'Bad task ID', 'Bad task ID',
404 // Not Found 404 // Not Found
@@ -327,6 +322,7 @@ class TaskManager implements ControllerProviderInterface
); );
break; break;
} }
return $ret; return $ret;
}); });
@@ -339,6 +335,7 @@ class TaskManager implements ControllerProviderInterface
$task = $app['task-manager']->getTask($id); $task = $app['task-manager']->getTask($id);
$template = 'admin/task.html.twig'; $template = 'admin/task.html.twig';
return $app['twig']->render($template, array( return $app['twig']->render($template, array(
'task' => $task, 'task' => $task,
'view' => 'XML' 'view' => 'XML'
@@ -364,6 +361,7 @@ class TaskManager implements ControllerProviderInterface
412 // Precondition Failed 412 // Precondition Failed
); );
} }
return $ret; return $ret;
}); });

View File

@@ -350,7 +350,6 @@ class Users implements ControllerProviderInterface
$models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$sql = " $sql = "
SELECT demand.date_modif,demand.base_id, usr.usr_id , usr.usr_login ,usr.usr_nom,usr.usr_prenom, SELECT demand.date_modif,demand.base_id, usr.usr_id , usr.usr_login ,usr.usr_nom,usr.usr_prenom,
usr.societe, usr.fonction, usr.usr_mail, usr.tel, usr.activite, usr.societe, usr.fonction, usr.usr_mail, usr.tel, usr.activite,
@@ -434,7 +433,6 @@ class Users implements ControllerProviderInterface
} }
} }
if (count($templates) > 0 || count($deny) > 0 || count($accept) > 0) { if (count($templates) > 0 || count($deny) > 0 || count($accept) > 0) {
$done = array(); $done = array();
$cache_to_update = array(); $cache_to_update = array();
@@ -448,7 +446,6 @@ class Users implements ControllerProviderInterface
$user->ACL()->apply_model($user_template, $base_ids); $user->ACL()->apply_model($user_template, $base_ids);
if (!isset($done[$usr])) { if (!isset($done[$usr])) {
$done[$usr] = array(); $done[$usr] = array();
} }
@@ -575,7 +572,6 @@ class Users implements ControllerProviderInterface
$controllers->post('/import/file/', function(Application $app, Request $request) { $controllers->post('/import/file/', function(Application $app, Request $request) {
if ((null === $file = $request->files->get('files')) || !$file->isValid()) { if ((null === $file = $request->files->get('files')) || !$file->isValid()) {
return $app->redirect('/admin/users/import/file/?error=file-invalid'); return $app->redirect('/admin/users/import/file/?error=file-invalid');
} }
@@ -604,12 +600,10 @@ class Users implements ControllerProviderInterface
} }
if (!$loginDefined) { if (!$loginDefined) {
return $app->redirect('/admin/users/import/file/?error=row-login'); return $app->redirect('/admin/users/import/file/?error=row-login');
} }
if (!$pwdDefined) { if (!$pwdDefined) {
return $app->redirect('/admin/users/import/file/?error=row-pwd'); return $app->redirect('/admin/users/import/file/?error=row-pwd');
} }
@@ -667,12 +661,10 @@ class Users implements ControllerProviderInterface
} }
if (count($out['errors']) > 0) { if (count($out['errors']) > 0) {
return $app['twig']->render('admin/user/import/file.html.twig', array( return $app['twig']->render('admin/user/import/file.html.twig', array(
'errors' => $out['errors'] 'errors' => $out['errors']
)); ));
} else if ($nbUsrToAdd === 0) { } elseif ($nbUsrToAdd === 0) {
return $app->redirect('/admin/users/import/file/?error=no-user'); return $app->redirect('/admin/users/import/file/?error=no-user');
} else { } else {
for ($i = 1; $i < sizeof($array); $i++) { for ($i = 1; $i < sizeof($array); $i++) {
@@ -905,4 +897,3 @@ class Users implements ControllerProviderInterface
return $equivalenceToMysqlField; return $equivalenceToMysqlField;
} }
} }

View File

@@ -102,7 +102,6 @@ class Datafiles extends AbstractDelivery
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
})->assert('sbas_id', '\d+')->assert('record_id', '\d+'); })->assert('sbas_id', '\d+')->assert('record_id', '\d+');
return $controllers; return $controllers;
} }
} }

View File

@@ -122,9 +122,9 @@ class Bridge implements ControllerProviderInterface
$account->delete(); $account->delete();
$success = true; $success = true;
} catch(\Bridge_Exception_AccountNotFound $e) { } catch (\Bridge_Exception_AccountNotFound $e) {
$message = _('Account is not found.'); $message = _('Account is not found.');
} catch(\Exception $e) { } catch (\Exception $e) {
$message = _('Something went wrong, please contact an administrator'); $message = _('Something went wrong, please contact an administrator');
} }
@@ -320,7 +320,6 @@ class Bridge implements ControllerProviderInterface
$account->get_api()->create_container($container_type, $app['request']); $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()); return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
} }

View File

@@ -77,7 +77,6 @@ class DoDownload implements ControllerProviderInterface
->bind('execute_download') ->bind('execute_download')
->assert('token', '[a-zA-Z0-9]{8,16}'); ->assert('token', '[a-zA-Z0-9]{8,16}');
return $controllers; return $controllers;
} }
@@ -96,21 +95,21 @@ class DoDownload implements ControllerProviderInterface
$app->abort(404, 'Invalid token'); $app->abort(404, 'Invalid token');
} }
if (false === $list = @unserialize((string)$datas['datas'])) { if (false === $list = @unserialize((string) $datas['datas'])) {
$app->abort(500, 'Invalid datas'); $app->abort(500, 'Invalid datas');
} }
$records = array(); $records = array();
foreach($list['files'] as $file) { foreach ($list['files'] as $file) {
if(!is_array($file) || !isset($file['base_id']) || !isset($file['record_id'])) { if (!is_array($file) || !isset($file['base_id']) || !isset($file['record_id'])) {
continue; continue;
} }
$sbasId = \phrasea::sbasFromBas($app, $file['base_id']); $sbasId = \phrasea::sbasFromBas($app, $file['base_id']);
try { try {
$record = new \record_adapter($app, $sbasId, $file['record_id']); $record = new \record_adapter($app, $sbasId, $file['record_id']);
} catch (\Exception $e){ } catch (\Exception $e) {
continue; continue;
} }
@@ -149,7 +148,7 @@ class DoDownload implements ControllerProviderInterface
$exportName = $list['export_name']; $exportName = $list['export_name'];
if($list['count'] === 1) { if ($list['count'] === 1) {
$file = end($list['files']); $file = end($list['files']);
$subdef = end($file['subdefs']); $subdef = end($file['subdefs']);
$exportName = sprintf('%s%s.%s', $file['export_name'], $subdef['ajout'], $subdef['exportExt']); $exportName = sprintf('%s%s.%s', $file['export_name'], $subdef['ajout'], $subdef['exportExt']);
@@ -161,7 +160,7 @@ class DoDownload implements ControllerProviderInterface
$mime = 'application/zip'; $mime = 'application/zip';
} }
if(!$app['filesystem']->exists($exportFile)) { if (!$app['filesystem']->exists($exportFile)) {
$app->abort(404, 'Download file not found'); $app->abort(404, 'Download file not found');
} }
@@ -186,7 +185,6 @@ class DoDownload implements ControllerProviderInterface
return $response; return $response;
} }
/** /**
* Build a zip of downloaded documents * Build a zip of downloaded documents
* *

View File

@@ -64,7 +64,7 @@ class Download implements ControllerProviderInterface
$download = new \set_export($app, $lst, $ssttid); $download = new \set_export($app, $lst, $ssttid);
if(0 === $download->get_total_download()) { if (0 === $download->get_total_download()) {
$app->abort(403); $app->abort(403);
} }

View File

@@ -85,7 +85,6 @@ class Edit implements ControllerProviderInterface
} }
} }
/** /**
* generate javascript sugg values * generate javascript sugg values
*/ */
@@ -117,7 +116,6 @@ class Edit implements ControllerProviderInterface
unset($collection); unset($collection);
} }
/** /**
* generate javascript status * generate javascript status
*/ */
@@ -402,8 +400,6 @@ 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' => ''));
}); });

View File

@@ -210,7 +210,6 @@ class Export implements ControllerProviderInterface
'message' => _('Export saved in the waiting queue') 'message' => _('Export saved in the waiting queue')
)); ));
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->json(array( return $app->json(array(
'success' => false, 'success' => false,
'message' => _('Something went wrong') 'message' => _('Something went wrong')

View File

@@ -516,7 +516,6 @@ class Lazaret implements ControllerProviderInterface
/* @var $lazaretFile \Entities\LazaretFile */ /* @var $lazaretFile \Entities\LazaretFile */
if (null === $lazaretFile) { if (null === $lazaretFile) {
return new Response(null, 404); return new Response(null, 404);
} }

View File

@@ -72,11 +72,13 @@ class MoveCollection implements ControllerProviderInterface
try { try {
if (null === $request->request->get('base_id')) { if (null === $request->request->get('base_id')) {
$datas['message'] = _('Missing target collection'); $datas['message'] = _('Missing target collection');
return $app->json($datas); return $app->json($datas);
} }
if (!$app['phraseanet.user']->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) { if (!$app['phraseanet.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);
} }
@@ -84,6 +86,7 @@ class MoveCollection implements ControllerProviderInterface
$collection = \collection::get_from_base_id($app, $request->request->get('base_id')); $collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
} catch (\Exception_Databox_CollectionNotFound $e) { } catch (\Exception_Databox_CollectionNotFound $e) {
$datas['message'] = _('Invalid target collection'); $datas['message'] = _('Invalid target collection');
return $app->json($datas); return $app->json($datas);
} }

View File

@@ -203,7 +203,6 @@ class Order implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $msg, 'msg' => $msg,
@@ -293,7 +292,6 @@ class Order implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'), 'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'),
@@ -333,7 +331,6 @@ class Order implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json(array(
'success' => $success, 'success' => $success,
'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'), 'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'),

View File

@@ -111,7 +111,7 @@ class Records implements ControllerProviderInterface
*/ */
public function getRecord(Application $app, Request $request) public function getRecord(Application $app, Request $request)
{ {
if(!$request->isXmlHttpRequest()){ if (!$request->isXmlHttpRequest()) {
$app->abort(400); $app->abort(400);
} }

View File

@@ -129,7 +129,6 @@ class Tools implements ControllerProviderInterface
$tempoFile = $tempoFile . DIRECTORY_SEPARATOR . $fileName; $tempoFile = $tempoFile . DIRECTORY_SEPARATOR . $fileName;
copy($file->getPathname(), $tempoFile); copy($file->getPathname(), $tempoFile);
try { try {
$record = new \record_adapter( $record = new \record_adapter(
$app, $app,

View File

@@ -136,7 +136,7 @@ class Tooltip implements ControllerProviderInterface
try { try {
$document = $record->get_subdef('document'); $document = $record->get_subdef('document');
} catch(\Exception $e) { } catch (\Exception $e) {
$document = null; $document = null;
} }

View File

@@ -270,7 +270,6 @@ class Account implements ControllerProviderInterface
return $app->redirect('/account/reset-email/?update=ok'); return $app->redirect('/account/reset-email/?update=ok');
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->redirect('/account/reset-email/?update=ko'); return $app->redirect('/account/reset-email/?update=ko');
} }
} }

View File

@@ -49,8 +49,6 @@ class Developers implements ControllerProviderInterface
$controllers->get('/applications/', $this->call('listApps')) $controllers->get('/applications/', $this->call('listApps'))
->bind('developers_applications'); ->bind('developers_applications');
/** /**
* Get the form to create a new application * Get the form to create a new application
* *
@@ -83,7 +81,6 @@ class Developers implements ControllerProviderInterface
$controllers->post('/application/', $this->call('newApp')) $controllers->post('/application/', $this->call('newApp'))
->bind('submit_developers_application'); ->bind('submit_developers_application');
/** /**
* Get application information * Get application information
* *

View File

@@ -44,8 +44,6 @@ class Login implements ControllerProviderInterface
} }
}); });
/** /**
* Login * Login
* *
@@ -358,13 +356,10 @@ class Login implements ControllerProviderInterface
&& (null !== $passwordConfirm = $request->request->get('form_password_confirm'))) { && (null !== $passwordConfirm = $request->request->get('form_password_confirm'))) {
if ($password !== $passwordConfirm) { if ($password !== $passwordConfirm) {
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('pass-error' => 'pass-match'))); return $app->redirect($app['url_generator']->generate('login_forgot_password', array('pass-error' => 'pass-match')));
} elseif (strlen(trim($password)) < 8) { } elseif (strlen(trim($password)) < 8) {
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('pass-error' => 'pass-short'))); return $app->redirect($app['url_generator']->generate('login_forgot_password', array('pass-error' => 'pass-short')));
} elseif (trim($password) !== str_replace(array("\r\n", "\n", "\r", "\t", " "), "_", $password)) { } elseif (trim($password) !== str_replace(array("\r\n", "\n", "\r", "\t", " "), "_", $password)) {
return $app->redirect($app['url_generator']->generate('login_forgot_password', array('pass-error' => 'pass-invalid'))); return $app->redirect($app['url_generator']->generate('login_forgot_password', array('pass-error' => 'pass-invalid')));
} }
@@ -521,8 +516,6 @@ class Login implements ControllerProviderInterface
} }
} }
$arrayVerif = $this->getRegisterFieldConfiguration($app); $arrayVerif = $this->getRegisterFieldConfiguration($app);
return $app['twig']->render('login/register.html.twig', array( return $app['twig']->render('login/register.html.twig', array(

View File

@@ -51,7 +51,7 @@ class Session implements ControllerProviderInterface
*/ */
public function updateSession(Application $app, Request $request) public function updateSession(Application $app, Request $request)
{ {
if(!$request->isXmlHttpRequest()) { if (!$request->isXmlHttpRequest()) {
$app->abort(400); $app->abort(400);
} }
@@ -66,10 +66,12 @@ class Session implements ControllerProviderInterface
$usr_id = $app['phraseanet.user']->get_id(); $usr_id = $app['phraseanet.user']->get_id();
if ($usr_id != $request->request->get('usr')) { // I logged with another user if ($usr_id != $request->request->get('usr')) { // I logged with another user
$ret['status'] = 'disconnected'; $ret['status'] = 'disconnected';
return $app->json($ret); return $app->json($ret);
} }
} else { } else {
$ret['status'] = 'disconnected'; $ret['status'] = 'disconnected';
return $app->json($ret); return $app->json($ret);
} }
@@ -81,6 +83,7 @@ class Session implements ControllerProviderInterface
if ($moduleId = (int) $request->request->get('module') < 1) { if ($moduleId = (int) $request->request->get('module') < 1) {
$ret['message'] = 'Missing or Invalid `module` parameter'; $ret['message'] = 'Missing or Invalid `module` parameter';
return $app->json($ret); return $app->json($ret);
} }
@@ -121,7 +124,6 @@ class Session implements ControllerProviderInterface
return $app->json($ret); return $app->json($ret);
} }
/** /**
* Prefix the method to call with the controller class name * Prefix the method to call with the controller class name
* *

View File

@@ -86,7 +86,6 @@ class Notifications implements ControllerProviderInterface
return $app->json(array('success' => true, 'message' => '')); return $app->json(array('success' => true, 'message' => ''));
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->json(array('success' => false, 'message' => $e->getMessage())); return $app->json(array('success' => false, 'message' => $e->getMessage()));
} }
} }
@@ -105,6 +104,7 @@ class Notifications implements ControllerProviderInterface
} }
$page = (int) $request->query->get('page', 1); $page = (int) $request->query->get('page', 1);
return $app->json($app['events-manager']->get_json_notifications(($page < 1 ? 1 : $page))); return $app->json($app['events-manager']->get_json_notifications(($page < 1 ? 1 : $page)));
} }

View File

@@ -47,7 +47,7 @@ class Configuration
*/ */
public static function build($specifications = null, $environment = null) public static function build($specifications = null, $environment = null)
{ {
if ( ! $specifications) { if (! $specifications) {
$specifications = new ApplicationSpecification(); $specifications = new ApplicationSpecification();
} }
@@ -104,7 +104,6 @@ class Configuration
*/ */
public function getEnvironnement() public function getEnvironnement()
{ {
return $this->environment; return $this->environment;
} }

View File

@@ -26,6 +26,7 @@ class TaskManagerServiceProvider implements ServiceProviderInterface
->getService($app['phraseanet.configuration']->getTaskManager()); ->getService($app['phraseanet.configuration']->getTaskManager());
$service = Builder::create($app, $configuration); $service = Builder::create($app, $configuration);
return $service->getDriver(); return $service->getDriver();
}); });
} }

View File

@@ -48,7 +48,7 @@ class BorderManager extends ServiceAbstract
$registeredCheckers = array(); $registeredCheckers = array();
if ( ! ! $options['enabled']) { if (! ! $options['enabled']) {
foreach ($options['checkers'] as $checker) { foreach ($options['checkers'] as $checker) {
if ( ! isset($checker['type'])) { if ( ! isset($checker['type'])) {

View File

@@ -29,7 +29,7 @@ class ApcCache extends ServiceAbstract
throw new \Exception('The APC cache requires the APC extension.'); throw new \Exception('The APC cache requires the APC extension.');
} }
if ( ! $this->cache) { if (! $this->cache) {
$this->cache = new CacheDriver\ApcCache(); $this->cache = new CacheDriver\ApcCache();
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
@@ -43,4 +43,3 @@ class ApcCache extends ServiceAbstract
return 'apc'; return 'apc';
} }
} }

View File

@@ -26,7 +26,7 @@ class ArrayCache extends ServiceAbstract
public function getDriver() public function getDriver()
{ {
if ( ! $this->cache) { if (! $this->cache) {
$this->cache = new CacheDriver\ArrayCache(); $this->cache = new CacheDriver\ArrayCache();
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
@@ -40,4 +40,3 @@ class ArrayCache extends ServiceAbstract
return 'array'; return 'array';
} }
} }

View File

@@ -43,7 +43,7 @@ class MemcacheCache extends ServiceAbstract
throw new \Exception('The Memcache cache requires the Memcache extension.'); throw new \Exception('The Memcache cache requires the Memcache extension.');
} }
if ( ! $this->cache) { if (! $this->cache) {
$memcache = new \Memcache(); $memcache = new \Memcache();
$memcache->addServer($this->host, $this->port); $memcache->addServer($this->host, $this->port);
@@ -80,4 +80,3 @@ class MemcacheCache extends ServiceAbstract
return $this->port; return $this->port;
} }
} }

View File

@@ -47,7 +47,7 @@ class RedisCache extends ServiceAbstract
throw new \Exception('The Redis cache requires the Redis extension.'); throw new \Exception('The Redis cache requires the Redis extension.');
} }
if ( ! $this->cache) { if (! $this->cache) {
$redis = new \Redis(); $redis = new \Redis();
if ($redis->connect($this->host, $this->port)) { if ($redis->connect($this->host, $this->port)) {
@@ -81,4 +81,3 @@ class RedisCache extends ServiceAbstract
return $this->port; return $this->port;
} }
} }

View File

@@ -32,7 +32,7 @@ class WinCacheCache extends ServiceAbstract
throw new \Exception('The WinCache cache requires the WinCache extension.'); throw new \Exception('The WinCache cache requires the WinCache extension.');
} }
if ( ! $this->cache) { if (! $this->cache) {
$this->cache = new CacheDriver\WinCacheCache(); $this->cache = new CacheDriver\WinCacheCache();
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
@@ -46,4 +46,3 @@ class WinCacheCache extends ServiceAbstract
return 'wincache'; return 'wincache';
} }
} }

View File

@@ -29,7 +29,7 @@ class XcacheCache extends ServiceAbstract
throw new \Exception('The XCache cache requires the XCache extension.'); throw new \Exception('The XCache cache requires the XCache extension.');
} }
if ( ! $this->cache) { if (! $this->cache) {
$this->cache = new CacheDriver\XcacheCache(); $this->cache = new CacheDriver\XcacheCache();
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));

View File

@@ -26,7 +26,7 @@ class FirePHP extends ServiceAbstract
public function getDriver() public function getDriver()
{ {
if ( ! $this->logger) { if (! $this->logger) {
$this->logger = new Logger('FirePHP'); $this->logger = new Logger('FirePHP');
$this->logger->pushHandler(new FirePHPHandler()); $this->logger->pushHandler(new FirePHPHandler());

View File

@@ -44,7 +44,7 @@ class Monolog extends ServiceAbstract
//defaut to main handler //defaut to main handler
$handler = isset($options["handler"]) ? $options["handler"] : false; $handler = isset($options["handler"]) ? $options["handler"] : false;
if ( ! $handler) { if (! $handler) {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"You must specify at least one handler for '%s' service" "You must specify at least one handler for '%s' service"
, __CLASS__ , __CLASS__
@@ -117,4 +117,3 @@ class Monolog extends ServiceAbstract
return array('channel', 'handler', 'filename'); return array('channel', 'handler', 'filename');
} }
} }

View File

@@ -29,7 +29,7 @@ class Prod extends Helper
$bases = $fields = $dates = array(); $bases = $fields = $dates = array();
if ( ! $this->app['phraseanet.user'] instanceof \User_Adapter) { if (! $this->app['phraseanet.user'] instanceof \User_Adapter) {
return $search_datas; return $search_datas;
} }
@@ -80,7 +80,7 @@ class Prod extends Helper
} }
} }
if ( ! $bases[$sbas_id]['thesaurus']) { if (! $bases[$sbas_id]['thesaurus']) {
continue; continue;
} }
if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th')) { if ( ! $this->app['phraseanet.user']->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th')) {

View File

@@ -65,4 +65,3 @@ class WorkZone extends Helper
$tmp_baskets = array(); $tmp_baskets = array();
} }
} }

View File

@@ -49,7 +49,7 @@ class Audio extends Provider
public function getMediaAlchemystSpec() public function getMediaAlchemystSpec()
{ {
if ( ! $this->spec) { if (! $this->spec) {
$this->spec = new \MediaAlchemyst\Specification\Audio(); $this->spec = new \MediaAlchemyst\Specification\Audio();
} }

View File

@@ -38,7 +38,7 @@ class FlexPaper extends Provider
public function getMediaAlchemystSpec() public function getMediaAlchemystSpec()
{ {
if ( ! $this->spec) { if (! $this->spec) {
$this->spec = new \MediaAlchemyst\Specification\Flash(); $this->spec = new \MediaAlchemyst\Specification\Flash();
} }

View File

@@ -40,7 +40,7 @@ class Gif extends Image
public function getMediaAlchemystSpec() public function getMediaAlchemystSpec()
{ {
if ( ! $this->spec) { if (! $this->spec) {
$this->spec = new \MediaAlchemyst\Specification\Animation(); $this->spec = new \MediaAlchemyst\Specification\Animation();
} }

View File

@@ -48,7 +48,7 @@ class Image extends Provider
public function getMediaAlchemystSpec() public function getMediaAlchemystSpec()
{ {
if ( ! $this->spec) { if (! $this->spec) {
$this->spec = new ImageSpecification(); $this->spec = new ImageSpecification();
} }

View File

@@ -39,7 +39,7 @@ class Enum implements OptionType
public function setValue($value) public function setValue($value)
{ {
if ( ! $value) { if (! $value) {
$this->value = null; $this->value = null;
return $this; return $this;

View File

@@ -45,8 +45,7 @@ class Multi implements OptionType
$this->available[$k] = false; $this->available[$k] = false;
} }
if ( ! $value) { if (! $value) {
return $this; return $this;
} }

View File

@@ -50,7 +50,7 @@ class Video extends Audio
public function getMediaAlchemystSpec() public function getMediaAlchemystSpec()
{ {
if ( ! $this->spec) { if (! $this->spec) {
$this->spec = new \MediaAlchemyst\Specification\Video(); $this->spec = new \MediaAlchemyst\Specification\Video();
} }

View File

@@ -31,7 +31,7 @@ abstract class AbstractConfigurationPanel implements ConfigurationPanelInterface
$date_fields = array(); $date_fields = array();
foreach ($databoxes as $databox) { foreach ($databoxes as $databox) {
foreach($databox->get_meta_structure() as $field) { foreach ($databox->get_meta_structure() as $field) {
if ($field->get_type() !== \databox_field::TYPE_DATE) { if ($field->get_type() !== \databox_field::TYPE_DATE) {
continue; continue;
} }

View File

@@ -143,7 +143,6 @@ class PhraseaEngineQueryParser
if (is_array($tree["VALUE"])) { if (is_array($tree["VALUE"])) {
return(implode(" ", $tree["VALUE"])); return(implode(" ", $tree["VALUE"]));
} else { } else {
return($tree["VALUE"]); return($tree["VALUE"]);
} }
break; break;
@@ -1140,7 +1139,6 @@ class PhraseaEngineQueryParser
"LB" => $newTreeLB, "LB" => $newTreeLB,
"RB" => $newTreeRB); "RB" => $newTreeRB);
return $tree; return $tree;
} }
@@ -1893,4 +1891,3 @@ class PhraseaEngineQueryParser
} }
} }
} }

View File

@@ -225,4 +225,3 @@ interface SearchEngineInterface
*/ */
public function clearAllCache(\DateTime $date = null); public function clearAllCache(\DateTime $date = null);
} }

View File

@@ -614,7 +614,6 @@ class SearchEngineOptions
$options->disallowBusinessFields(); $options->disallowBusinessFields();
$options->setLocale($app['locale.I18n']); $options->setLocale($app['locale.I18n']);
if (is_array($request->get('bases'))) { if (is_array($request->get('bases'))) {
$bas = array_map(function($base_id) use ($app) { $bas = array_map(function($base_id) use ($app) {
return \collection::get_from_base_id($app, $base_id); return \collection::get_from_base_id($app, $base_id);

View File

@@ -173,4 +173,3 @@ class SearchEngineResult
return $this->indexes; return $this->indexes;
} }
} }

View File

@@ -1007,4 +1007,3 @@ class SphinxSearchEngine implements SearchEngineInterface
} }
} }

View File

@@ -75,7 +75,6 @@ class Migration35 implements MigrationInterface
rename(__DIR__ . '/../../../../../../config/connexion.inc', __DIR__ . '/../../../../../../config/connexion.inc.old'); rename(__DIR__ . '/../../../../../../config/connexion.inc', __DIR__ . '/../../../../../../config/connexion.inc.old');
rename(__DIR__ . '/../../../../../../config/config.inc', __DIR__ . '/../../../../../../config/config.inc.old'); rename(__DIR__ . '/../../../../../../config/config.inc', __DIR__ . '/../../../../../../config/config.inc.old');
$this->app['phraseanet.configuration']->setConfigurations($configs); $this->app['phraseanet.configuration']->setConfigurations($configs);
$this->app['phraseanet.configuration']->setEnvironnement('prod'); $this->app['phraseanet.configuration']->setEnvironnement('prod');
} }

View File

@@ -28,6 +28,7 @@ class Probe31 implements ProbeInterface
/** /**
* We can not use registry to inject a path as the install is not yet done * We can not use registry to inject a path as the install is not yet done
*/ */
return is_file(__DIR__ . "/../../../../../../config/connexion.inc") return is_file(__DIR__ . "/../../../../../../config/connexion.inc")
&& is_file(__DIR__ . "/../../../../../../config/_GV.php"); && is_file(__DIR__ . "/../../../../../../config/_GV.php");
} }

View File

@@ -28,6 +28,7 @@ class Probe35 implements ProbeInterface
/** /**
* We can not use registry to inject a path as the install is not yet done * We can not use registry to inject a path as the install is not yet done
*/ */
return is_file(__DIR__ . "/../../../../../../config/connexion.inc") return is_file(__DIR__ . "/../../../../../../config/connexion.inc")
&& is_file(__DIR__ . "/../../../../../../config/config.inc"); && is_file(__DIR__ . "/../../../../../../config/config.inc");
} }