当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::redirectPath方法代码示例

本文整理汇总了PHP中Silex\Application::redirectPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::redirectPath方法的具体用法?PHP Application::redirectPath怎么用?PHP Application::redirectPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Silex\Application的用法示例。


在下文中一共展示了Application::redirectPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 public function connect(SilexApplication $app)
 {
     $app['controller.setup'] = $this;
     $controllers = $app['controllers_factory'];
     $controllers->get('/', function (Application $app) {
         return $app->redirectPath('install_root');
     })->bind('setup');
     $controllers->get('/installer/', 'controller.setup:rootInstaller')->bind('install_root');
     $controllers->get('/upgrade-instructions/', 'controller.setup:displayUpgradeInstructions')->bind('setup_upgrade_instructions');
     $controllers->get('/installer/step2/', 'controller.setup:getInstallForm')->bind('install_step2');
     $controllers->post('/installer/install/', 'controller.setup:doInstall')->bind('install_do_install');
     $controllers->get('/connection_test/mysql/', function (Application $app, Request $request) {
         $dbHelper = new DatabaseHelper($app, $request);
         return $app->json($dbHelper->checkConnection());
     });
     $controllers->get('/test/path/', function (Application $app, Request $request) {
         $pathHelper = new PathHelper($app, $request);
         return $app->json($pathHelper->checkPath());
     });
     $controllers->get('/test/url/', function (Application $app, Request $request) {
         $pathHelper = new PathHelper($app, $request);
         return $app->json($pathHelper->checkUrl());
     });
     return $controllers;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:25,代码来源:Setup.php

示例2: connect

 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;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:54,代码来源:Root.php

示例3: connect

 public function connect(SilexApplication $app)
 {
     $app['controller.setup'] = $this;
     $controllers = $app['controllers_factory'];
     $controllers->get('/', function (Application $app) {
         return $app->redirectPath('install_root');
     })->bind('setup');
     $controllers->get('/installer/', 'controller.setup:rootInstaller')->bind('install_root');
     $controllers->get('/upgrade-instructions/', 'controller.setup:displayUpgradeInstructions')->bind('setup_upgrade_instructions');
     $controllers->get('/installer/step2/', 'controller.setup:getInstallForm')->bind('install_step2');
     $controllers->post('/installer/install/', 'controller.setup:doInstall')->bind('install_do_install');
     return $controllers;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:13,代码来源:Setup.php

示例4: checkDownload

 /**
  * Download a set of documents
  *
  * @param  Application      $app
  * @param  Request          $request
  * @return RedirectResponse
  */
 public function checkDownload(Application $app, Request $request)
 {
     $lst = $request->request->get('lst');
     $ssttid = $request->request->get('ssttid', '');
     $subdefs = $request->request->get('obj', []);
     $download = new \set_export($app, $lst, $ssttid);
     if (0 === $download->get_total_download()) {
         $app->abort(403);
     }
     $list = $download->prepare_export($app['authentication']->getUser(), $app['filesystem'], $subdefs, $request->request->get('type') === 'title' ? true : false, $request->request->get('businessfields'));
     $list['export_name'] = sprintf('%s.zip', $download->getExportName());
     $token = $app['manipulator.token']->createDownloadToken($app['authentication']->getUser(), serialize($list));
     $app['dispatcher']->dispatch(PhraseaEvents::EXPORT_CREATE, new ExportEvent($app['authentication']->getUser(), $ssttid, $lst, $subdefs, $download->getExportName()));
     return $app->redirectPath('prepare_download', ['token' => $token->getValue()]);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:22,代码来源:Download.php

示例5: checkDownload

 /**
  * Download a set of documents
  *
  * @param  Application      $app
  * @param  Request          $request
  * @return RedirectResponse
  */
 public function checkDownload(Application $app, Request $request)
 {
     $lst = $request->request->get('lst');
     $ssttid = $request->request->get('ssttid', '');
     $subdefs = $request->request->get('obj', []);
     $download = new \set_export($app, $lst, $ssttid);
     if (0 === $download->get_total_download()) {
         $app->abort(403);
     }
     $list = $download->prepare_export($app['authentication']->getUser(), $app['filesystem'], $subdefs, $request->request->get('type') === 'title' ? true : false, $request->request->get('businessfields'));
     $list['export_name'] = sprintf('%s.zip', $download->getExportName());
     $token = $app['tokens']->getUrlToken(\random::TYPE_DOWNLOAD, $app['authentication']->getUser()->getId(), new \DateTime('+3 hours'), serialize($list));
     if (!$token) {
         throw new \RuntimeException('Download token could not be generated');
     }
     $app['events-manager']->trigger('__DOWNLOAD__', ['lst' => $lst, 'downloader' => $app['authentication']->getUser()->getId(), 'subdefs' => $subdefs, 'from_basket' => $ssttid, 'export_file' => $download->getExportName()]);
     return $app->redirectPath('prepare_download', ['token' => $token]);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:25,代码来源:Download.php

示例6: connect

 public function connect(Application $app)
 {
     $app['controller.client'] = $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', ['redirect' => 'client']);
         }
         if (null !== ($response = $app['firewall']->requireAuthentication())) {
             return $response;
         }
     });
     $controllers->get('/', 'controller.client:getClient')->bind('get_client');
     $controllers->get('/language/', 'controller.client:getClientLanguage')->bind('get_client_language');
     $controllers->get('/publications/', 'controller.client:getClientPublications')->bind('client_publications_start_page');
     $controllers->get('/help/', 'controller.client:getClientHelp')->bind('client_help_start_page');
     $controllers->post('/query/', 'controller.client:query')->bind('client_query');
     return $controllers;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:19,代码来源:Root.php

示例7: displayResetEmailForm

 /**
  * Display reset email form
  *
  * @param  Application $app
  * @param  Request     $request
  * @return Response
  */
 public function displayResetEmailForm(Application $app, Request $request)
 {
     if (null !== ($tokenValue = $request->query->get('token'))) {
         if (null === ($token = $app['repo.tokens']->findValidToken($tokenValue))) {
             $app->addFlash('error', $app->trans('admin::compte-utilisateur: erreur lors de la mise a jour'));
             return $app->redirectPath('account');
         }
         $user = $token->getUser();
         $user->setEmail($token->getData());
         $app['manipulator.token']->delete($token);
         $app->addFlash('success', $app->trans('admin::compte-utilisateur: L\'email a correctement ete mis a jour'));
         return $app->redirectPath('account');
     }
     return $app['twig']->render('account/reset-email.html.twig', Login::getDefaultTemplateVariables($app));
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:22,代码来源:Account.php

示例8: databaseMount

 /**
  * Mount a databox
  *
  * @param  Application      $app     The silex application
  * @param  Request          $request The current HTTP request
  * @return RedirectResponse
  */
 public function databaseMount(Application $app, Request $request)
 {
     if ('' === ($dbName = trim($request->request->get('new_dbname', '')))) {
         return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'no-empty']);
     }
     if (\p4string::hasAccent($dbName)) {
         return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'special-chars']);
     }
     if (null === $request->request->get('new_settings')) {
         try {
             $connexion = $app['conf']->get(['main', 'database']);
             $hostname = $connexion['host'];
             $port = $connexion['port'];
             $user = $connexion['user'];
             $password = $connexion['password'];
             $app['phraseanet.appbox']->get_connection()->beginTransaction();
             $base = \databox::mount($app, $hostname, $port, $user, $password, $dbName);
             $base->registerAdmin($app['authentication']->getUser());
             $app['phraseanet.appbox']->get_connection()->commit();
             return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]);
         } catch (\Exception $e) {
             $app['phraseanet.appbox']->get_connection()->rollBack();
             return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'mount-failed']);
         }
     }
     if (null !== $request->request->get('new_settings') && null !== ($hostname = $request->request->get('new_hostname')) && null !== ($port = $request->request->get('new_port')) && null !== ($userDb = $request->request->get('new_user')) && null !== ($passwordDb = $request->request->get('new_password'))) {
         try {
             $app['phraseanet.appbox']->get_connection()->beginTransaction();
             $base = \databox::mount($app, $hostname, $port, $userDb, $passwordDb, $dbName);
             $base->registerAdmin($app['authentication']->getUser());
             $app['phraseanet.appbox']->get_connection()->commit();
             return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]);
         } catch (\Exception $e) {
             $app['phraseanet.appbox']->get_connection()->rollBack();
             return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'mount-failed']);
         }
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:45,代码来源:Databoxes.php

示例9: connect

 public function connect(Application $app)
 {
     $app['controller.admin.subdefs'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before(function (Request $request) use($app) {
         $app['firewall']->requireAccessToModule('admin')->requireRightOnSbas($request->attributes->get('sbas_id'), 'bas_modify_struct');
     });
     $controllers->get('/{sbas_id}/', function (Application $app, $sbas_id) {
         $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
         return $app['twig']->render('admin/subdefs.html.twig', ['databox' => $databox, 'subdefs' => $databox->get_subdef_structure()]);
     })->bind('admin_subdefs_subdef')->assert('sbas_id', '\\d+');
     $controllers->post('/{sbas_id}/', function (Application $app, Request $request, $sbas_id) {
         $delete_subdef = $request->request->get('delete_subdef');
         $toadd_subdef = $request->request->get('add_subdef');
         $Parmsubdefs = $request->request->get('subdefs', []);
         $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
         $add_subdef = ['class' => null, 'name' => null, 'group' => null];
         foreach ($add_subdef as $k => $v) {
             if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') {
                 unset($add_subdef[$k]);
             } else {
                 $add_subdef[$k] = $toadd_subdef[$k];
             }
         }
         if ($delete_subdef) {
             $delete_subef = explode('_', $delete_subdef, 2);
             $group = $delete_subef[0];
             $name = $delete_subef[1];
             $subdefs = $databox->get_subdef_structure();
             $subdefs->delete_subdef($group, $name);
         } elseif (count($add_subdef) === 3) {
             $subdefs = $databox->get_subdef_structure();
             $group = $add_subdef['group'];
             $name = $app['unicode']->remove_nonazAZ09($add_subdef['name'], false);
             $class = $add_subdef['class'];
             $subdefs->add_subdef($group, $name, $class);
         } else {
             $subdefs = $databox->get_subdef_structure();
             foreach ($Parmsubdefs as $post_sub) {
                 $options = [];
                 $post_sub_ex = explode('_', $post_sub, 2);
                 $group = $post_sub_ex[0];
                 $name = $post_sub_ex[1];
                 $class = $request->request->get($post_sub . '_class');
                 $downloadable = $request->request->get($post_sub . '_downloadable');
                 $defaults = ['path', 'meta', 'mediatype'];
                 foreach ($defaults as $def) {
                     $parm_loc = $request->request->get($post_sub . '_' . $def);
                     if ($def == 'meta' && !$parm_loc) {
                         $parm_loc = "no";
                     }
                     $options[$def] = $parm_loc;
                 }
                 $mediatype = $request->request->get($post_sub . '_mediatype');
                 $media = $request->request->get($post_sub . '_' . $mediatype, []);
                 foreach ($media as $option => $value) {
                     if ($option == 'resolution' && $mediatype == 'image') {
                         $option = 'dpi';
                     }
                     $options[$option] = $value;
                 }
                 $labels = $request->request->get($post_sub . '_label', []);
                 $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels);
             }
         }
         return $app->redirectPath('admin_subdefs_subdef', ['sbas_id' => $databox->get_sbas_id()]);
     })->bind('admin_subdefs_subdef_update')->assert('sbas_id', '\\d+');
     return $controllers;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:70,代码来源:Subdefs.php

示例10: createCollection

 /**
  * Create a new collection
  *
  * @param  Application $app        The silex application
  * @param  Request     $request    The current HTTP request
  * @param  integer     $databox_id The requested databox
  * @return Response
  */
 public function createCollection(Application $app, Request $request, $databox_id)
 {
     if (($name = trim($request->request->get('name', ''))) === '') {
         return $app->redirectPath('admin_database_display_new_collection_form', ['databox_id' => $databox_id, 'error' => 'name']);
     }
     try {
         $databox = $app['phraseanet.appbox']->get_databox($databox_id);
         $collection = \collection::create($app, $databox, $app['phraseanet.appbox'], $name, $app['authentication']->getUser());
         if ($request->request->get('ccusrothercoll') === "on" && null !== ($othcollsel = $request->request->get('othcollsel'))) {
             $query = $app['phraseanet.user-query'];
             $total = $query->on_base_ids([$othcollsel])->get_total();
             $n = 0;
             while ($n < $total) {
                 $results = $query->limit($n, 20)->execute()->get_results();
                 foreach ($results as $user) {
                     $app['acl']->get($user)->duplicate_right_from_bas($othcollsel, $collection->get_base_id());
                 }
                 $n += 20;
             }
         }
         $app['dispatcher']->dispatch(PhraseaEvents::COLLECTION_CREATE, new CollectionCreateEvent($collection));
         return $app->redirectPath('admin_display_collection', ['bas_id' => $collection->get_base_id(), 'success' => 1, 'reload-tree' => 1]);
     } catch (\Exception $e) {
         return $app->redirectPath('admin_database_submit_collection', ['databox_id' => $databox_id, 'error' => 'error']);
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:34,代码来源:Databox.php

示例11: displayResetEmailForm

 /**
  * Display reset email form
  *
  * @param  Application $app
  * @param  Request     $request
  * @return Response
  */
 public function displayResetEmailForm(Application $app, Request $request)
 {
     if (null !== ($token = $request->query->get('token'))) {
         try {
             $datas = $app['tokens']->helloToken($token);
             $user = $app['manipulator.user']->getRepository()->find((int) $datas['usr_id']);
             $user->setEmail($datas['datas']);
             $app['tokens']->removeToken($token);
             $app->addFlash('success', $app->trans('admin::compte-utilisateur: L\'email a correctement ete mis a jour'));
             return $app->redirectPath('account');
         } catch (\Exception $e) {
             $app->addFlash('error', $app->trans('admin::compte-utilisateur: erreur lors de la mise a jour'));
             return $app->redirectPath('account');
         }
     }
     return $app['twig']->render('account/reset-email.html.twig', Login::getDefaultTemplateVariables($app));
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:24,代码来源:Account.php

示例12: stealElements

 public function stealElements(Application $app, Request $request, BasketEntity $basket)
 {
     $n = 0;
     foreach ($request->request->get('elements') as $bask_element_id) {
         try {
             $basket_element = $app['repo.basket-elements']->findUserElement($bask_element_id, $app['authentication']->getUser());
         } catch (\Exception $e) {
             continue;
         }
         $basket_element->getBasket()->removeElement($basket_element);
         $basket_element->setBasket($basket);
         $basket->addElement($basket_element);
         $n++;
     }
     $app['EM']->flush();
     $data = ['success' => true, 'message' => $app->trans('%quantity% records moved', ['%quantity%' => $n])];
     if ($request->getRequestFormat() === 'json') {
         return $app->json($data);
     } else {
         return $app->redirectPath('prod_workzone_show');
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:22,代码来源:BasketController.php

示例13: setMiniLogo

 /**
  * Set collection minilogo
  *
  * @param  Application      $app     The silex application
  * @param  Request          $request The current request
  * @param  integer          $bas_id  The collection base_id
  * @return RedirectResponse
  */
 public function setMiniLogo(Application $app, Request $request, $bas_id)
 {
     if (null === ($file = $request->files->get('newLogo'))) {
         $app->abort(400);
     }
     if ($file->getClientSize() > 65535) {
         return $app->redirectPath('admin_display_collection', ['bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big']);
     }
     if (!$file->isValid()) {
         return $app->redirectPath('admin_display_collection', ['bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid']);
     }
     $collection = \collection::get_from_base_id($app, $bas_id);
     try {
         $app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_LOGO);
         $app['filesystem']->remove($file->getPathname());
     } catch (\Exception $e) {
         return $app->redirectPath('admin_display_collection', ['bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error']);
     }
     return $app->redirectPath('admin_display_collection', ['bas_id' => $bas_id, 'success' => 1]);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:28,代码来源:Collection.php

示例14: connect

 public function connect(Application $app)
 {
     $app['controller.oauth2'] = $this;
     $controllers = $app['controllers_factory'];
     /**
      * AUTHORIZE ENDPOINT
      *
      * Authorization endpoint - used to obtain authorization from the
      * resource owner via user-agent redirection.
      */
     $authorize_func = function () use($app) {
         $request = $app['request'];
         $oauth2Adapter = $app['oauth2-server'];
         $context = new Context(Context::CONTEXT_OAUTH2_NATIVE);
         $app['dispatcher']->dispatch(PhraseaEvents::PRE_AUTHENTICATE, new PreAuthenticate($request, $context));
         //Check for auth params, send error or redirect if not valid
         $params = $oauth2Adapter->getAuthorizationRequestParameters($request);
         $appAuthorized = false;
         $error = $request->get('error', '');
         if (null === ($client = $app['repo.api-applications']->findByClientId($params['client_id']))) {
             throw new NotFoundHttpException(sprintf('Application with client id %s could not be found', $params['client_id']));
         }
         $oauth2Adapter->setClient($client);
         $actionAccept = $request->get("action_accept");
         $actionLogin = $request->get("action_login");
         $template = "api/auth/end_user_authorization.html.twig";
         $custom_template = sprintf("%s/config/templates/web/api/auth/end_user_authorization/%s.html.twig", $app['root.path'], $client->getId());
         if (file_exists($custom_template)) {
             $template = sprintf('api/auth/end_user_authorization/%s.html.twig', $client->getId());
         }
         if (!$app['authentication']->isAuthenticated()) {
             if ($actionLogin !== null) {
                 try {
                     if (null === ($usrId = $app['auth.native']->getUsrId($request->get("login"), $request->get("password"), $request))) {
                         $app['session']->getFlashBag()->set('error', $app->trans('login::erreur: Erreur d\'authentification'));
                         return $app->redirectPath('oauth2_authorize', array_merge(array('error' => 'login'), $params));
                     }
                 } catch (RequireCaptchaException $e) {
                     return $app->redirectPath('oauth2_authorize', array_merge(array('error' => 'captcha'), $params));
                 } catch (AccountLockedException $e) {
                     return $app->redirectPath('oauth2_authorize', array_merge(array('error' => 'account-locked'), $params));
                 }
                 $user = $app['repo.users']->find($usrId);
                 $app['authentication']->openAccount($user);
                 $event = new PostAuthenticate($request, new Response(), $user, $context);
                 $app['dispatcher']->dispatch(PhraseaEvents::POST_AUTHENTICATE, $event);
             } else {
                 $r = new Response($app['twig']->render($template, array('error' => $error, "auth" => $oauth2Adapter)));
                 $r->headers->set('Content-Type', 'text/html');
                 return $r;
             }
         }
         //check if current client is already authorized by current user
         $clients = $app['repo.api-applications']->findAuthorizedAppsByUser($app['authentication']->getUser());
         foreach ($clients as $authClient) {
             if ($client->getClientId() == $authClient->getClientId()) {
                 $appAuthorized = true;
                 break;
             }
         }
         $account = $oauth2Adapter->updateAccount($app['authentication']->getUser());
         $params['account_id'] = $account->getId();
         if (!$appAuthorized && $actionAccept === null) {
             $params = ["auth" => $oauth2Adapter, "error" => $error];
             $r = new Response($app['twig']->render($template, $params));
             $r->headers->set('Content-Type', 'text/html');
             return $r;
         } elseif (!$appAuthorized && $actionAccept !== null) {
             $appAuthorized = (bool) $actionAccept;
             if ($appAuthorized) {
                 $app['manipulator.api-account']->authorizeAccess($account);
             } else {
                 $app['manipulator.api-account']->revokeAccess($account);
             }
         }
         //if native app show template
         if ($oauth2Adapter->isNativeApp($params['redirect_uri'])) {
             $params = $oauth2Adapter->finishNativeClientAuthorization($appAuthorized, $params);
             $r = new Response($app['twig']->render("api/auth/native_app_access_token.html.twig", $params));
             $r->headers->set('Content-Type', 'text/html');
             return $r;
         }
         $oauth2Adapter->finishClientAuthorization($appAuthorized, $params);
         // As OAuth2 library already outputs response content, we need to send an empty
         // response to avoid breaking silex controller
         return '';
     };
     $controllers->match('/authorize', $authorize_func)->method('GET|POST')->bind('oauth2_authorize');
     /**
      *  TOKEN ENDPOINT
      *  Token endpoint - used to exchange an authorization grant for an access token.
      */
     $controllers->post('/token', function (\Silex\Application $app, Request $request) {
         if (!$request->isSecure()) {
             throw new HttpException(400, 'This route requires the use of the https scheme', null, ['content-type' => 'application/json']);
         }
         $app['oauth2-server']->grantAccessToken($request);
         ob_flush();
         flush();
         // As OAuth2 library already outputs response content, we need to send an empty
//.........这里部分代码省略.........
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:101,代码来源:Oauth2.php

示例15: connect

 public function connect(Application $app)
 {
     $app['controller.admin.users'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before(function (Request $request) use($app) {
         $app['firewall']->requireAccessToModule('admin')->requireRight('manageusers');
     });
     $controllers->post('/rights/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
     });
     $controllers->get('/rights/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
     });
     $controllers->post('/rights/reset/', function (Application $app, Request $request) {
         try {
             $datas = ['error' => false];
             $helper = new UserHelper\Edit($app, $request);
             $helper->resetRights();
         } catch (\Exception $e) {
             $datas['error'] = true;
             $datas['message'] = $e->getMessage();
         }
         return $app->json($datas);
     })->bind('admin_users_rights_reset');
     $controllers->post('/delete/', function (Application $app) {
         $module = new UserHelper\Edit($app, $app['request']);
         $module->delete_users();
         return $app->redirectPath('admin_users_search');
     });
     $controllers->post('/rights/apply/', function (Application $app) {
         $datas = ['error' => true];
         try {
             $rights = new UserHelper\Edit($app, $app['request']);
             if (!$app['request']->request->get('reset_before_apply')) {
                 $rights->apply_rights();
             }
             if ($app['request']->request->get('template')) {
                 if ($app['request']->request->get('reset_before_apply')) {
                     $rights->resetRights();
                 }
                 $rights->apply_template();
             }
             $rights->apply_infos();
             $datas = ['error' => false];
         } catch (\Exception $e) {
             $datas['message'] = $e->getMessage();
         }
         return $app->json($datas);
     })->bind('admin_users_rights_apply');
     $controllers->post('/rights/quotas/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         return $app['twig']->render('admin/editusers_quotas.html.twig', $rights->get_quotas());
     });
     $controllers->post('/rights/quotas/apply/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         $rights->apply_quotas();
         return $app->json(['message' => '', 'error' => false]);
     });
     $controllers->post('/rights/time/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         return $app['twig']->render('admin/editusers_timelimit.html.twig', $rights->get_time());
     });
     $controllers->post('/rights/time/sbas/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         return $app['twig']->render('admin/editusers_timelimit_sbas.html.twig', $rights->get_time_sbas());
     });
     $controllers->post('/rights/time/apply/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         $rights->apply_time();
         return $app->json(['message' => '', 'error' => false]);
     });
     $controllers->post('/rights/masks/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         return $app['twig']->render('admin/editusers_masks.html.twig', $rights->get_masks());
     });
     $controllers->post('/rights/masks/apply/', function (Application $app) {
         $rights = new UserHelper\Edit($app, $app['request']);
         $rights->apply_masks();
         return $app->json(['message' => '', 'error' => false]);
     });
     $controllers->match('/search/', function (Application $app) {
         $users = new UserHelper\Manage($app, $app['request']);
         return $app['twig']->render('admin/users.html.twig', $users->search());
     })->bind('admin_users_search');
     $controllers->post('/search/export/', function () use($app) {
         $request = $app['request'];
         $users = new UserHelper\Manage($app, $app['request']);
         $userTable = [['ID', 'Login', 'Last Name', 'First Name', 'E-Mail', 'Created', 'Updated', 'Address', 'City', 'Zip', 'Country', 'Phone', 'Fax', 'Job', 'Company', 'Position']];
         foreach ($users->export() as $user) {
             $userTable[] = [$user->getId(), $user->getLogin(), $user->getLastName(), $user->getFirstName(), $user->getEmail(), $user->getCreated()->format(DATE_ATOM), $user->getUpdated()->format(DATE_ATOM), $user->getAddress(), $user->getCity(), $user->getZipCode(), $user->getCountry(), $user->getPhone(), $user->getFax(), $user->getJob(), $user->getCompany(), $user->getActivity()];
         }
         $CSVDatas = \format::arr_to_csv($userTable);
         $response = new Response($CSVDatas, 200, ['Content-Type' => 'text/csv']);
         $response->headers->set('Content-Disposition', 'attachment; filename=export.csv');
         return $response;
     })->bind('admin_users_search_export');
     $controllers->post('/apply_template/', function () use($app) {
//.........这里部分代码省略.........
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:101,代码来源:Users.php


注:本文中的Silex\Application::redirectPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。