public function displayTreeAction(Request $request) { try { \Session_Logger::updateClientInfos($this->app, 3); } catch (SessionNotFound $e) { return $this->app->redirectPath('logout'); } $params = $this->getSectionParameters($request->query->get('position', false)); return $this->render('admin/tree.html.twig', $params); }
public function connect(SilexApplication $app) { $app['controller.prod'] = $this; $controllers = $app['controllers_factory']; $controllers->before(function (Request $request) use($app) { if (!$app['authentication']->isAuthenticated() && null !== $request->query->get('nolog')) { return $app->redirectPath('login_authenticate_as_guest'); } if (null !== ($response = $app['firewall']->requireAuthentication())) { return $response; } }); $controllers->get('/', function (Application $app) { try { \Session_Logger::updateClientInfos($app, 1); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $cssPath = $app['root.path'] . '/www/skins/prod/'; $css = []; $cssfile = false; $finder = new Finder(); $iterator = $finder->directories()->depth(0)->filter(function (\SplFileInfo $fileinfo) { return ctype_xdigit($fileinfo->getBasename()); })->in($cssPath); foreach ($iterator as $dir) { $baseName = $dir->getBaseName(); $css[$baseName] = $baseName; } $cssfile = $app['settings']->getUserSetting($app['authentication']->getUser(), 'css'); if (!$cssfile && isset($css['000000'])) { $cssfile = '000000'; } $feeds = $app['repo.feeds']->getAllForUser($app['acl']->get($app['authentication']->getUser())); $aggregate = Aggregate::createFromUser($app, $app['authentication']->getUser()); $thjslist = ""; $queries_topics = ''; if ($app['conf']->get(['registry', 'classic', 'render-topics']) == 'popups') { $queries_topics = \queries::dropdown_topics($app['translator'], $app['locale']); } elseif ($app['conf']->get(['registry', 'classic', 'render-topics']) == 'tree') { $queries_topics = \queries::tree_topics($app['locale']); } $sbas = $bas2sbas = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); $sbas['s' + $sbas_id] = ['sbid' => $sbas_id, 'seeker' => null]; foreach ($databox->get_collections() as $coll) { $bas2sbas['b' . $coll->get_base_id()] = ['sbid' => $sbas_id, 'ckobj' => ['checked' => false], 'waschecked' => false]; } } return $app['twig']->render('prod/index.html.twig', ['module_name' => 'Production', 'WorkZone' => new Helper\WorkZone($app, $app['request']), 'module_prod' => new Helper\Prod($app, $app['request']), 'cssfile' => $cssfile, 'module' => 'prod', 'events' => $app['events-manager'], 'GV_defaultQuery_type' => $app['conf']->get(['registry', 'searchengine', 'default-query-type']), 'GV_multiAndReport' => $app['conf']->get(['registry', 'modules', 'stories']), 'GV_thesaurus' => $app['conf']->get(['registry', 'modules', 'thesaurus']), 'cgus_agreement' => \databox_cgu::askAgreement($app), 'css' => $css, 'feeds' => $feeds, 'aggregate' => $aggregate, 'GV_google_api' => $app['conf']->get(['registry', 'webservices', 'google-charts-enabled']), 'queries_topics' => $queries_topics, 'search_status' => \databox_status::getSearchStatus($app), 'queries_history' => \queries::history($app, $app['authentication']->getUser()->getId()), 'thesau_js_list' => $thjslist, 'thesau_json_sbas' => json_encode($sbas), 'thesau_json_bas2sbas' => json_encode($bas2sbas), 'thesau_languages' => $app['locales.available']]); })->bind('prod'); return $controllers; }
/** * Display dashboard informations * * @param Application $app * @param Request $request * @return JsonResponse */ public function getDashboard(Application $app, Request $request) { $dashboard = new \module_report_dashboard($app, $app['authentication']->getUser()); if ('json' !== $request->getRequestFormat()) { \Session_Logger::updateClientInfos($app, 4); $dashboard->execute(); return $app['twig']->render('report/report_layout_child.html.twig', ['ajax_dash' => true, 'dashboard' => $dashboard, 'home_title' => $app['conf']->get(['registry', 'general', 'title']), 'module' => 'report', 'module_name' => 'Report', 'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']), 'g_anal' => $app['conf']->get(['registry', 'general', 'analytics']), 'ajax' => false, 'ajax_chart' => false]); } $dmin = $request->request->get('dmin'); $dmax = $request->request->get('dmax'); if ($dmin && $dmax) { $dashboard->setDate($dmin, $dmax); } $dashboard->execute(); return $app->json(['html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', ['dashboard' => $dashboard])]); }
public function indexAction(Request $request) { try { \Session_Logger::updateClientInfos($this->app, 1); } catch (SessionNotFound $e) { return $this->app->redirectPath('logout'); } $cssPath = $this->app['root.path'] . '/www/assets/prod/skins'; $css = []; $finder = new Finder(); /** @var SplFileInfo[] $iterator */ $iterator = $finder->directories()->depth(0)->filter(function (\SplFileInfo $fileinfo) { return ctype_xdigit($fileinfo->getBasename()); })->in($cssPath); foreach ($iterator as $dir) { $baseName = $dir->getBaseName(); $css[$baseName] = $baseName; } $user = $this->getAuthenticatedUser(); $cssfile = $this->getSettings()->getUserSetting($user, 'css'); if (!$cssfile && isset($css['000000'])) { $cssfile = '000000'; } $feeds = $this->getFeedRepository()->getAllForUser($this->getAclForUser()); $aggregate = Aggregate::createFromUser($this->app, $user); $thjslist = ""; $queries_topics = ''; $conf = $this->getConf(); if ($conf->get(['registry', 'classic', 'render-topics']) == 'popups') { $queries_topics = \queries::dropdown_topics($this->app['translator'], $this->app['locale']); } elseif ($conf->get(['registry', 'classic', 'render-topics']) == 'tree') { $queries_topics = \queries::tree_topics($this->app['locale']); } $sbas = $bas2sbas = []; foreach ($this->getApplicationBox()->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); $sbas['s' . $sbas_id] = ['sbid' => $sbas_id, 'seeker' => null]; foreach ($databox->get_collections() as $coll) { $bas2sbas['b' . $coll->get_base_id()] = ['sbid' => $sbas_id, 'ckobj' => ['checked' => false], 'waschecked' => false]; } } $helper = new Helper\Prod($this->app, $request); /** @var \Closure $filter */ $filter = $this->app['plugin.filter_by_authorization']; $plugins = ['workzone' => $filter('workzone'), 'actionbar' => $filter('actionbar')]; return $this->render('prod/index.html.twig', ['module_name' => 'Production', 'WorkZone' => new Helper\WorkZone($this->app, $request), 'module_prod' => $helper, 'search_datas' => $helper->get_search_datas(), 'cssfile' => $cssfile, 'module' => 'prod', 'events' => $this->app['events-manager'], 'GV_defaultQuery_type' => $conf->get(['registry', 'searchengine', 'default-query-type']), 'GV_multiAndReport' => $conf->get(['registry', 'modules', 'stories']), 'GV_thesaurus' => $conf->get(['registry', 'modules', 'thesaurus']), 'cgus_agreement' => \databox_cgu::askAgreement($this->app), 'css' => $css, 'feeds' => $feeds, 'aggregate' => $aggregate, 'GV_google_api' => $conf->get(['registry', 'webservices', 'google-charts-enabled']), 'queries_topics' => $queries_topics, 'search_status' => \databox_status::getSearchStatus($this->app), 'queries_history' => \queries::history($this->app, $user->getId()), 'thesau_js_list' => $thjslist, 'thesau_json_sbas' => json_encode($sbas), 'thesau_json_bas2sbas' => json_encode($bas2sbas), 'thesau_languages' => $this->app['locales.available'], 'plugins' => $plugins]); }
/** * Display dashboard informations * * @param Application $app * @param Request $request * @return JsonResponse */ public function getDashboard(Application $app, Request $request) { if ('json' === $request->getRequestFormat()) { \Session_Logger::updateClientInfos($app, 4); $dashboard = new \module_report_dashboard($app, $app['authentication']->getUser()); $dmin = $request->query->get('dmin'); $dmax = $request->query->get('dmax'); if ($dmin && $dmax) { $dashboard->setDate($dmin, $dmax); } $dashboard->execute(); return $app->json(['html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', ['dashboard' => $dashboard])]); } $granted = []; foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canreport']) as $collection) { if (!isset($granted[$collection->get_sbas_id()])) { $granted[$collection->get_sbas_id()] = ['id' => $collection->get_sbas_id(), 'name' => $collection->get_databox()->get_viewname(), 'collections' => []]; } $granted[$collection->get_sbas_id()]['collections'][] = ['id' => $collection->get_coll_id(), 'base_id' => $collection->get_base_id(), 'name' => $collection->get_name()]; } return $app['twig']->render('report/report_layout_child.html.twig', ['ajax_dash' => true, 'dashboard' => null, 'granted_bases' => $granted, 'home_title' => $app['conf']->get(['registry', 'general', 'title']), 'module' => 'report', 'module_name' => 'Report', 'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']), 'g_anal' => $app['conf']->get(['registry', 'general', 'analytics']), 'ajax' => false, 'ajax_chart' => false]); }
public function connect(SilexApplication $app) { $app['controller.lightbox'] = $this; $controllers = $app['controllers_factory']; $controllers->before(function (Request $request) use($app) { if (!$request->query->has('LOG')) { return; } if ($app['authentication']->isAuthenticated()) { $app['authentication']->closeAccount(); } if (null === ($token = $app['repo.tokens']->findValidToken($request->query->get('LOG')))) { $app->addFlash('error', $app->trans('The URL you used is out of date, please login')); return $app->redirectPath('homepage'); } $app['authentication']->openAccount($token->getUser()); switch ($token->getType()) { case TokenManipulator::TYPE_FEED_ENTRY: return $app->redirectPath('lightbox_feed_entry', ['entry_id' => $token->getData()]); break; case TokenManipulator::TYPE_VALIDATE: case TokenManipulator::TYPE_VIEW: return $app->redirectPath('lightbox_validation', ['basket' => $token->getData()]); break; } }); $app['firewall']->addMandatoryAuthentication($controllers); $controllers->before($app['middleware.basket.converter'])->before($app['middleware.basket.user-access']); $controllers->get('/', function (SilexApplication $app) { try { \Session_Logger::updateClientInfos($app, 6); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $repository = $app['repo.baskets']; $basket_collection = array_merge($repository->findActiveByUser($app['authentication']->getUser()), $repository->findActiveValidationByUser($app['authentication']->getUser())); $template = 'lightbox/index.html.twig'; if (!$app['browser']->isNewGeneration() && !$app['browser']->isMobile()) { $template = 'lightbox/IE6/index.html.twig'; } return new Response($app['twig']->render($template, ['baskets_collection' => $basket_collection, 'module_name' => 'Lightbox', 'module' => 'lightbox'])); })->bind('lightbox'); $controllers->get('/ajax/NOTE_FORM/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { if (!$app['browser']->isMobile()) { return new Response(''); } $basketElement = $app['repo.basket-elements']->findUserElement($sselcont_id, $app['authentication']->getUser()); $parameters = ['basket_element' => $basketElement, 'module_name' => '']; return $app['twig']->render('lightbox/note_form.html.twig', $parameters); })->bind('lightbox_ajax_note_form')->assert('sselcont_id', '\\d+'); $controllers->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { $repository = $app['repo.basket-elements']; $BasketElement = $repository->findUserElement($sselcont_id, $app['authentication']->getUser()); if ($app['browser']->isMobile()) { $output = $app['twig']->render('lightbox/basket_element.html.twig', ['basket_element' => $BasketElement, 'module_name' => $BasketElement->getRecord($app)->get_title()]); return new Response($output); } else { $template_options = 'lightbox/sc_options_box.html.twig'; $template_agreement = 'lightbox/agreement_box.html.twig'; $template_selector = 'lightbox/selector_box.html.twig'; $template_note = 'lightbox/sc_note.html.twig'; $template_preview = 'common/preview.html.twig'; $template_caption = 'common/caption.html.twig'; if (!$app['browser']->isNewGeneration()) { $template_options = 'lightbox/IE6/sc_options_box.html.twig'; $template_agreement = 'lightbox/IE6/agreement_box.html.twig'; } $Basket = $BasketElement->getBasket(); $ret = []; $ret['number'] = $BasketElement->getRecord($app)->get_number(); $ret['title'] = $BasketElement->getRecord($app)->get_title(); $ret['preview'] = $app['twig']->render($template_preview, ['record' => $BasketElement->getRecord($app), 'not_wrapped' => true]); $ret['options_html'] = $app['twig']->render($template_options, ['basket_element' => $BasketElement]); $ret['agreement_html'] = $app['twig']->render($template_agreement, ['basket' => $Basket, 'basket_element' => $BasketElement]); $ret['selector_html'] = $app['twig']->render($template_selector, ['basket_element' => $BasketElement]); $ret['note_html'] = $app['twig']->render($template_note, ['basket_element' => $BasketElement]); $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $BasketElement->getRecord($app)]); return $app->json($ret); } })->bind('lightbox_ajax_load_basketelement')->assert('sselcont_id', '\\d+'); $controllers->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function (SilexApplication $app, $entry_id, $item_id) { $entry = $app['repo.feed-entries']->find($entry_id); $item = $entry->getItem($item_id); if ($app['browser']->isMobile()) { $output = $app['twig']->render('lightbox/feed_element.html.twig', ['feed_element' => $item, 'module_name' => $item->getRecord($app)->get_title()]); return new Response($output); } else { $template_options = 'lightbox/feed_options_box.html.twig'; $template_preview = 'common/preview.html.twig'; $template_caption = 'common/caption.html.twig'; if (!$app['browser']->isNewGeneration()) { $template_options = 'lightbox/IE6/feed_options_box.html.twig'; } $ret = []; $ret['number'] = $item->getRecord($app)->get_number(); $ret['title'] = $item->getRecord($app)->get_title(); $ret['preview'] = $app['twig']->render($template_preview, ['record' => $item->getRecord($app), 'not_wrapped' => true]); $ret['options_html'] = $app['twig']->render($template_options, ['feed_element' => $item]); $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $item->getRecord($app)]); $ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = ''; return $app->json($ret); } })->bind('lightbox_ajax_load_feeditem')->assert('entry_id', '\\d+')->assert('item_id', '\\d+'); $controllers->get('/validate/{basket}/', function (SilexApplication $app, $basket) { try { \Session_Logger::updateClientInfos($app, 6); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $repository = $app['repo.baskets']; $basket_collection = $repository->findActiveValidationAndBasketByUser($app['authentication']->getUser()); if ($basket->getIsRead() === false) { $basket = $app['EM']->merge($basket); $basket->setIsRead(true); $app['EM']->flush(); } if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) { $basket = $app['EM']->merge($basket); $basket->getValidation()->getParticipant($app['authentication']->getUser())->setIsAware(true); $app['EM']->flush(); } $template = 'lightbox/validate.html.twig'; if (!$app['browser']->isNewGeneration() && !$app['browser']->isMobile()) { $template = 'lightbox/IE6/validate.html.twig'; } $response = new Response($app['twig']->render($template, ['baskets_collection' => $basket_collection, 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => $app->trans('admin::monitor: module validation')])); $response->setCharset('UTF-8'); return $response; })->bind('lightbox_validation')->assert('basket', '\\d+'); $controllers->get('/compare/{basket}/', function (SilexApplication $app, Basket $basket) { try { \Session_Logger::updateClientInfos($app, 6); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $repository = $app['repo.baskets']; $basket_collection = $repository->findActiveValidationAndBasketByUser($app['authentication']->getUser()); if ($basket->getIsRead() === false) { $basket = $app['EM']->merge($basket); $basket->setIsRead(true); $app['EM']->flush(); } if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) { $basket = $app['EM']->merge($basket); $basket->getValidation()->getParticipant($app['authentication']->getUser())->setIsAware(true); $app['EM']->flush(); } $template = 'lightbox/validate.html.twig'; if (!$app['browser']->isNewGeneration() && !$app['browser']->isMobile()) { $template = 'lightbox/IE6/validate.html.twig'; } $response = new Response($app['twig']->render($template, ['baskets_collection' => $basket_collection, 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => $app->trans('admin::monitor: module validation')])); $response->setCharset('UTF-8'); return $response; })->bind('lightbox_compare')->assert('basket', '\\d+'); $controllers->get('/feeds/entry/{entry_id}/', function (SilexApplication $app, $entry_id) { try { \Session_Logger::updateClientInfos($app, 6); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $feed_entry = $app['repo.feed-entries']->find($entry_id); $template = 'lightbox/feed.html.twig'; if (!$app['browser']->isNewGeneration() && !$app['browser']->isMobile()) { $template = 'lightbox/IE6/feed.html.twig'; } $content = $feed_entry->getItems(); $first = $content->first(); $output = $app['twig']->render($template, ['feed_entry' => $feed_entry, 'first_item' => $first, 'local_title' => $feed_entry->getTitle(), 'module' => 'lightbox', 'module_name' => $app->trans('admin::monitor: module validation')]); $response = new Response($output, 200); $response->setCharset('UTF-8'); return $response; })->bind('lightbox_feed_entry')->assert('entry_id', '\\d+'); $controllers->get('/ajax/LOAD_REPORT/{basket}/', function (SilexApplication $app, Basket $basket) { return new Response($app['twig']->render('lightbox/basket_content_report.html.twig', ['basket' => $basket])); })->bind('lightbox_ajax_report')->assert('basket', '\\d+'); $controllers->post('/ajax/SET_NOTE/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { $output = ['error' => true, 'datas' => $app->trans('Erreur lors de l\'enregistrement des donnees')]; $request = $app['request']; $note = $request->request->get('note'); if (is_null($note)) { return new Response('You must provide a note value', 400); } $repository = $app['repo.basket-elements']; $basket_element = $repository->findUserElement($sselcont_id, $app['authentication']->getUser()); $validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser()); $validationDatas->setNote($note); $app['EM']->merge($validationDatas); $app['EM']->flush(); if ($app['browser']->isMobile()) { $datas = $app['twig']->render('lightbox/sc_note.html.twig', ['basket_element' => $basket_element]); $output = ['error' => false, 'datas' => $datas]; } else { $template = 'lightbox/sc_note.html.twig'; $datas = $app['twig']->render($template, ['basket_element' => $basket_element]); $output = ['error' => false, 'datas' => $datas]; } return $app->json($output); })->bind('lightbox_ajax_set_note')->assert('sselcont_id', '\\d+'); $controllers->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { $request = $app['request']; $agreement = $request->request->get('agreement'); if (is_null($agreement)) { return new Response('You must provide an agreement value', 400); } $agreement = $agreement > 0; $releasable = false; try { $ret = ['error' => true, 'releasable' => false, 'datas' => $app->trans('Erreur lors de la mise a jour des donnes')]; $repository = $app['repo.basket-elements']; $basket_element = $repository->findUserElement($sselcont_id, $app['authentication']->getUser()); /* @var $basket_element BasketElement */ $validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser()); if (!$basket_element->getBasket()->getValidation()->getParticipant($app['authentication']->getUser())->getCanAgree()) { throw new ControllerException('You can not agree on this'); } $validationDatas->setAgreement($agreement); $participant = $basket_element->getBasket()->getValidation()->getParticipant($app['authentication']->getUser()); $app['EM']->merge($basket_element); $app['EM']->flush(); $releasable = false; if ($participant->isReleasable() === true) { $releasable = $app->trans('Do you want to send your report ?'); } $ret = ['error' => false, 'datas' => '', 'releasable' => $releasable]; } catch (ControllerException $e) { $ret['datas'] = $e->getMessage(); } return $app->json($ret); })->bind('lightbox_ajax_set_element_agreement')->assert('sselcont_id', '\\d+'); $controllers->post('/ajax/SET_RELEASE/{basket}/', function (SilexApplication $app, Basket $basket) { $datas = ['error' => true, 'datas' => '']; try { if (!$basket->getValidation()) { throw new ControllerException('There is no validation session attached to this basket'); } if (!$basket->getValidation()->getParticipant($app['authentication']->getUser())->getCanAgree()) { throw new ControllerException('You have not right to agree'); } $agreed = false; /* @var $basket Basket */ foreach ($basket->getElements() as $element) { if (null !== $element->getUserValidationDatas($app['authentication']->getUser())->getAgreement()) { $agreed = true; } } if (!$agreed) { throw new ControllerException($app->trans('You have to give your feedback at least on one document to send a report')); } /* @var $basket Basket */ $participant = $basket->getValidation()->getParticipant($app['authentication']->getUser()); $token = $app['manipulator.token']->createBasketValidationToken($basket); $url = $app->url('lightbox', ['LOG' => $token->getValue()]); $to = $basket->getValidation()->getInitiator($app)->getId(); $app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_DONE, new ValidationEvent($participant, $basket, $url)); $participant->setIsConfirmed(true); $app['EM']->merge($participant); $app['EM']->flush(); $datas = ['error' => false, 'datas' => $app->trans('Envoie avec succes')]; } catch (ControllerException $e) { $datas = ['error' => true, 'datas' => $e->getMessage()]; } return $app->json($datas); })->bind('lightbox_ajax_set_release')->assert('basket', '\\d+'); return $controllers; }
public function connect(Application $app) { $app['controller.admin.root'] = $this; $controllers = $app['controllers_factory']; $app['firewall']->addMandatoryAuthentication($controllers); $controllers->before(function (Request $request) use($app) { $app['firewall']->requireAccessToModule('admin'); }); $controllers->get('/', function (Application $app, Request $request) { try { \Session_Logger::updateClientInfos($app, 3); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $section = $request->query->get('section', false); $available = ['connected', 'registrations', 'taskmanager', 'base', 'bases', 'collection', 'user', 'users']; $feature = 'connected'; $featured = false; $position = explode(':', $section); if (count($position) > 0) { if (in_array($position[0], $available)) { $feature = $position[0]; if (isset($position[1])) { $featured = $position[1]; } } } $databoxes = $off_databoxes = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) { continue; } $databox->get_connection(); } catch (\Exception $e) { $off_databoxes[] = $databox; continue; } $databoxes[] = $databox; } $params = ['feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes]; return $app['twig']->render('admin/index.html.twig', ['module' => 'admin', 'events' => $app['events-manager'], 'module_name' => 'Admin', 'notice' => $request->query->get("notice"), 'feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes, 'tree' => $app['twig']->render('admin/tree.html.twig', $params)]); })->bind('admin'); $controllers->get('/tree/', function (Application $app, Request $request) { try { \Session_Logger::updateClientInfos($app, 3); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $available = ['connected', 'registrations', 'taskmanager', 'base', 'bases', 'collection', 'user', 'users']; $feature = 'connected'; $featured = false; $position = explode(':', $request->query->get('position', false)); if (count($position) > 0) { if (in_array($position[0], $available)) { $feature = $position[0]; if (isset($position[1])) { $featured = $position[1]; } } } $databoxes = $off_databoxes = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) { continue; } $databox->get_connection(); } catch (\Exception $e) { $off_databoxes[] = $databox; continue; } $databoxes[] = $databox; } $params = ['feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes]; return $app['twig']->render('admin/tree.html.twig', $params); })->bind('admin_display_tree'); $controllers->get('/test-paths/', function (Application $app, Request $request) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { $app->abort(400, $app->trans('Bad request format, only JSON is allowed')); } if (0 !== count($tests = $request->query->get('tests', []))) { $app->abort(400, $app->trans('Missing tests parameter')); } if (null !== ($path = $request->query->get('path'))) { $app->abort(400, $app->trans('Missing path parameter')); } foreach ($tests as $test) { switch ($test) { case 'writeable': if (!is_writable($path)) { $result = false; } break; case 'readable': default: if (!is_readable($path)) { $result = true; } break; } } return $app->json(['results' => $result]); })->bind('admin_test_paths'); $controllers->get('/structure/{databox_id}/', function (Application $app, Request $request, $databox_id) { if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { $app->abort(403); } $databox = $app['phraseanet.appbox']->get_databox((int) $databox_id); $structure = $databox->get_structure(); $errors = \databox::get_structure_errors($app['translator'], $structure); if ($updateOk = !!$request->query->get('success', false)) { $updateOk = true; } if (false !== ($errorsStructure = $request->query->get('error', false))) { $errorsStructure = true; } return $app['twig']->render('admin/structure.html.twig', ['databox' => $databox, 'errors' => $errors, 'structure' => $structure, 'errorsStructure' => $errorsStructure, 'updateOk' => $updateOk]); })->assert('databox_id', '\\d+')->bind('database_display_stucture'); $controllers->post('/structure/{databox_id}/', function (Application $app, Request $request, $databox_id) { if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { $app->abort(403); } if (null === ($structure = $request->request->get('structure'))) { $app->abort(400, $app->trans('Missing "structure" parameter')); } $errors = \databox::get_structure_errors($app['translator'], $structure); $domst = new \DOMDocument('1.0', 'UTF-8'); $domst->preserveWhiteSpace = false; $domst->formatOutput = true; if (count($errors) == 0 && $domst->loadXML($structure)) { $databox = $app['phraseanet.appbox']->get_databox($databox_id); $databox->saveStructure($domst); return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 1]); } else { return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 0, 'error' => 'struct']); } })->assert('databox_id', '\\d+')->bind('database_submit_stucture'); $controllers->get('/statusbit/{databox_id}/', function (Application $app, Request $request, $databox_id) { if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { $app->abort(403); } return $app['twig']->render('admin/statusbit.html.twig', ['databox' => $app['phraseanet.appbox']->get_databox($databox_id)]); })->assert('databox_id', '\\d+')->bind('database_display_statusbit'); $controllers->get('/statusbit/{databox_id}/status/{bit}/', function (Application $app, Request $request, $databox_id, $bit) { if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { $app->abort(403); } $databox = $app['phraseanet.appbox']->get_databox($databox_id); $status = $databox->get_statusbits(); switch ($errorMsg = $request->query->get('error')) { case 'rights': $errorMsg = $app->trans('You do not enough rights to update status'); break; case 'too-big': $errorMsg = $app->trans('File is too big : 64k max'); break; case 'upload-error': $errorMsg = $app->trans('Status icon upload failed : upload error'); break; case 'wright-error': $errorMsg = $app->trans('Status icon upload failed : can not write on disk'); break; case 'unknow-error': $errorMsg = $app->trans('Something wrong happend'); break; } if (isset($status[$bit])) { $status = $status[$bit]; } else { $status = ["labeloff" => '', "labelon" => '', "img_off" => '', "img_on" => '', "path_off" => '', "path_on" => '', "searchable" => false, "printable" => false]; foreach ($app['locales.available'] as $code => $language) { $status['labels_on'][$code] = null; $status['labels_off'][$code] = null; } } return $app['twig']->render('admin/statusbit/edit.html.twig', ['status' => $status, 'errorMsg' => $errorMsg]); })->assert('databox_id', '\\d+')->assert('bit', '\\d+')->bind('database_display_statusbit_form'); $controllers->post('/statusbit/{databox_id}/status/{bit}/delete/', function (Application $app, Request $request, $databox_id, $bit) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { $app->abort(400, $app->trans('Bad request format, only JSON is allowed')); } if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { $app->abort(403); } $error = false; try { \databox_status::deleteStatus($app, $app['phraseanet.appbox']->get_databox($databox_id), $bit); } catch (\Exception $e) { $error = true; } return $app->json(['success' => !$error]); })->bind('admin_statusbit_delete')->assert('databox_id', '\\d+')->assert('bit', '\\d+'); $controllers->post('/statusbit/{databox_id}/status/{bit}/', function (Application $app, Request $request, $databox_id, $bit) { if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) { $app->abort(403); } $properties = ['searchable' => $request->request->get('searchable') ? '1' : '0', 'printable' => $request->request->get('printable') ? '1' : '0', 'name' => $request->request->get('name', ''), 'labelon' => $request->request->get('label_on', ''), 'labeloff' => $request->request->get('label_off', ''), 'labels_on' => $request->request->get('labels_on', []), 'labels_off' => $request->request->get('labels_off', [])]; \databox_status::updateStatus($app, $databox_id, $bit, $properties); if (null !== $request->request->get('delete_icon_off')) { \databox_status::deleteIcon($app, $databox_id, $bit, 'off'); } if (null !== ($file = $request->files->get('image_off'))) { try { \databox_status::updateIcon($app, $databox_id, $bit, 'off', $file); } catch (AccessDeniedHttpException $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights']); } catch (\Exception_InvalidArgument $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']); } catch (\Exception_Upload_FileTooBig $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big']); } catch (\Exception_Upload_Error $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error']); } catch (\Exception_Upload_CannotWriteFile $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error']); } catch (\Exception $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']); } } if (null !== $request->request->get('delete_icon_on')) { \databox_status::deleteIcon($app, $databox_id, $bit, 'on'); } if (null !== ($file = $request->files->get('image_on'))) { try { \databox_status::updateIcon($app, $databox_id, $bit, 'on', $file); } catch (AccessDeniedHttpException $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights']); } catch (\Exception_InvalidArgument $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']); } catch (\Exception_Upload_FileTooBig $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big']); } catch (\Exception_Upload_Error $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error']); } catch (\Exception_Upload_CannotWriteFile $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error']); } catch (\Exception $e) { return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']); } } return $app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]); })->assert('databox_id', '\\d+')->assert('bit', '\\d+')->bind('database_submit_statusbit'); return $controllers; }
/** * @param int $entry_id * @return Response */ public function getFeedEntryAction($entry_id) { $app = $this->app; try { \Session_Logger::updateClientInfos($app, 6); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } /** @var FeedEntry $feed_entry */ $feed_entry = $app['repo.feed-entries']->find($entry_id); $template = $this->isBrowserNewGenerationOrMobile() ? 'lightbox/feed.html.twig' : 'lightbox/IE6/feed.html.twig'; $content = $feed_entry->getItems(); $first = $content->first(); $response = $this->renderResponse($template, ['feed_entry' => $feed_entry, 'first_item' => $first, 'local_title' => $feed_entry->getTitle(), 'module' => 'lightbox', 'module_name' => $app->trans('admin::monitor: module validation')]); $response->setCharset('UTF-8'); return $response; }
/** * Gets client main page * * @param Application $app * @param Request $request * @return Response */ public function getClient(Application $app, Request $request) { try { \Session_Logger::updateClientInfos($app, 2); } catch (SessionNotFound $e) { return $app->redirectPath('logout'); } $renderTopics = ''; if ($app['conf']->get(['registry', 'classic', 'render-topics']) == 'popups') { $renderTopics = \queries::dropdown_topics($app['translator'], $app['locale']); } elseif ($app['conf']->get(['registry', 'classic', 'render-topics']) == 'tree') { $renderTopics = \queries::tree_topics($app['locale']); } return new Response($app['twig']->render('client/index.html.twig', ['last_action' => !$app['authentication']->getUser()->isGuest() && false !== $request->cookies->has('last_act') ? $request->cookies->has('last_act') : null, 'phrasea_home' => $this->getDefaultClientStartPage($app), 'render_topics' => $renderTopics, 'grid_properties' => $this->getGridProperty(), 'search_order' => SearchEngineOptions::SORT_MODE_DESC, 'storage_access' => $this->getDocumentStorageAccess($app), 'tabs_setup' => $this->getTabSetup($app), 'module' => 'client', 'menubar' => $app['twig']->render('common/menubar.html.twig', ['module' => 'client']), 'css_file' => $this->getCssFile($app), 'basket_status' => $app['settings']->getUserSetting($app['authentication']->getUser(), 'client_basket_status', '1'), 'mod_pres' => $app['settings']->getUserSetting($app['authentication']->getUser(), 'client_view', ''), 'start_page' => $app['settings']->getUserSetting($app['authentication']->getUser(), 'start_page'), 'start_page_query' => $app['settings']->getUserSetting($app['authentication']->getUser(), 'start_page_query', '')])); }