From 76964dfb7b187405f4e5e5c854e55667334f3c4b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 26 Apr 2013 14:41:43 +0200 Subject: [PATCH] Adding new action to parse group/user pictures --- .htaccess | 2 ++ src/ChamiloLMS/Controller/IndexController.php | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.htaccess b/.htaccess index df7dcbe7ca..82d37afec5 100644 --- a/.htaccess +++ b/.htaccess @@ -32,6 +32,8 @@ RewriteCond %{QUERY_STRING} ^([a-z0-9A-z]*) RewriteRule ^user.php?$ web/user/%1? [R,L] + # User images + # Portal news # news_list.php?id=5 --> web/news/5 RewriteCond %{QUERY_STRING} ^id=([0-9]*) diff --git a/src/ChamiloLMS/Controller/IndexController.php b/src/ChamiloLMS/Controller/IndexController.php index eca0278195..ea7e403803 100644 --- a/src/ChamiloLMS/Controller/IndexController.php +++ b/src/ChamiloLMS/Controller/IndexController.php @@ -341,6 +341,39 @@ class IndexController extends CommonController } } + /** + * @param Application $app + * @param $groupId + * @param $file + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|void + */ + public function getGroupFile(Application $app, $groupId, $file) + { + try { + $file = $app['chamilo.filesystem']->get('upload/groups/'.$groupId.'/'.$file); + return $app->sendFile($file->getPathname()); + } catch (\InvalidArgumentException $e) { + return $app->abort(404, 'File not found'); + } + } + + /** + * @param Application $app + * @param $file + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|void + */ + public function getUserFile(Application $app) + { + try { + $file = $app['request']->get('file'); + $file = $app['chamilo.filesystem']->get('upload/users/'.$file); + return $app->sendFile($file->getPathname()); + } catch (\InvalidArgumentException $e) { + return $app->abort(404, 'File not found'); + } + } + + /** * Reacts on a failed login. * Displays an explanation with a link to the registration form.