Merge branch 'master' into PHRAS-2741-worker-service-part1

This commit is contained in:
Nicolas Maillat
2019-09-23 12:23:46 +02:00
committed by GitHub
14 changed files with 208 additions and 133 deletions

View File

@@ -15,12 +15,9 @@ use Alchemy\Phrasea\Core\Configuration\DisplaySettingService;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Alchemy\Phrasea\Feed\Aggregate;
use Alchemy\Phrasea\Helper;
use Alchemy\Phrasea\Model\Entities\UserSetting;
use Alchemy\Phrasea\Helper\WorkZone as WorkzoneHelper;
use Alchemy\Phrasea\Model\Repositories\FeedRepository;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpFoundation\Request;
// use Alchemy\Phrasea\Plugin\ActionBarPluginInterface;
class RootController extends Controller
@@ -43,12 +40,11 @@ class RootController extends Controller
public function indexAction(Request $request) {
try {
\Session_Logger::updateClientInfos($this->app, 1);
} catch (SessionNotFound $e) {
}
catch (SessionNotFound $e) {
return $this->app->redirectPath('logout');
}
$css = [];
$user = $this->getAuthenticatedUser();
$cssfile = $this->getSettings()->getUserSetting($user, 'css');
@@ -110,7 +106,7 @@ class RootController extends Controller
return $this->render('prod/index.html.twig', [
'module_name' => 'Production',
'WorkZone' => new Helper\WorkZone($this->app, $request),
'WorkZone' => new WorkzoneHelper($this->app, $request),
'module_prod' => $helper,
'search_datas' => $helper->get_search_datas(),
'cssfile' => $cssfile,
@@ -123,7 +119,7 @@ class RootController extends Controller
'feeds' => $feeds,
'aggregate' => $aggregate,
'GV_google_api' => $conf->get(['registry', 'webservices', 'google-charts-enabled']),
'geocodingProviders' => $conf->get(['geocoding-providers']),
'geocodingProviders' => $conf->get(['geocoding-providers']),
'search_status' => \databox_status::getSearchStatus($this->app),
'thesau_js_list' => $thjslist,
'thesau_json_sbas' => json_encode($sbas),

View File

@@ -367,15 +367,17 @@ class UploadController extends Controller
$postMaxSize = PHP_INT_MAX;
}
$r = 0;
switch (strtolower(substr($postMaxSize, -1))) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'g':
$postMaxSize *= 1024;
$r += 10;
/** @noinspection PhpMissingBreakStatementInspection */
case 'm':
$postMaxSize *= 1024;
$r += 10;
case 'k':
$postMaxSize *= 1024;
$r += 10;
$postMaxSize = ((int)($postMaxSize))<<$r;
}
return min(UploadedFile::getMaxFilesize(), (int) $postMaxSize);

View File

@@ -522,27 +522,35 @@ class AccountController extends Controller
$list = array_keys($this->app['repo.collections-registry']->getBaseIdMap());
$this->app->getAclForUser($user)->revoke_access_from_bases($list);
try {
$this->app->getAclForUser($user)->revoke_access_from_bases($list);
}
catch (\Exception $e) {
// one or more access could not be revoked ? the user will not be phantom
$this->app->addFlash('error', $this->app->trans('phraseanet::error: failed to revoke some user access'));
}
if ($this->app->getAclForUser($user)->is_phantom()) {
// send confirmation email: the account has been deleted
try {
$receiver = Receiver::fromUser($user);
} catch (InvalidArgumentException $e) {
$this->app->addFlash('error', $this->app->trans('phraseanet::erreur: echec du serveur de mail'));
$mail = MailSuccessAccountDelete::create($this->app, $receiver);
}
catch (InvalidArgumentException $e) {
$this->app->addFlash('error', $this->app->trans('phraseanet::erreur: echec du serveur de mail'));
$mail = null;
}
$mail = MailSuccessAccountDelete::create($this->app, $receiver);
$this->app['manipulator.user']->delete($user);
$this->deliver($mail);
if($mail) {
$this->deliver($mail);
}
$this->getAuthenticator()->closeAccount();
$this->app->addFlash('info', $this->app->trans('phraseanet::account The account has been deleted'));
}
$this->getAuthenticator()->closeAccount();
$this->app->addFlash('info', $this->app->trans('phraseanet::account The account has been deleted'));
}
/**

View File

@@ -94,10 +94,9 @@ class SessionController extends Controller
}
/**
* Check session state
*
* @param Request $request
* @param Request $request
* @return JsonResponse
* @throws \Exception in case "new \DateTime()" fails ?
*/
public function updateSession(Request $request)
{
@@ -120,7 +119,8 @@ class SessionController extends Controller
return $this->app->json($ret);
}
} else {
}
else {
$ret['status'] = 'disconnected';
return $this->app->json($ret);
@@ -128,7 +128,8 @@ class SessionController extends Controller
try {
$this->getApplicationBox()->get_connection();
} catch (\Exception $e) {
}
catch (\Exception $e) {
return $this->app->json($ret);
}
@@ -148,8 +149,9 @@ class SessionController extends Controller
$module->setModuleId($moduleId);
$module->setSession($session);
$manager->persist($module);
} else {
$manager->persist($session->getModuleById($moduleId)->setUpdated(new \DateTime()));
}
else {
$manager->persist($session->getModuleById($moduleId)->setUpdated($now));
}
$manager->persist($session);
@@ -231,7 +233,10 @@ class SessionController extends Controller
*/
private function getBasketRepository()
{
return $this->getEntityManager()->getRepository('Phraseanet:Basket');
/** @var BasketRepository $ret */
$ret = $this->getEntityManager()->getRepository('Phraseanet:Basket');
return $ret;
}
/**