Browse Source

Minor - updating comments

Julio Montoya 12 years ago
parent
commit
81f1cd61ee

+ 14 - 15
main/inc/global.inc.php

@@ -472,25 +472,26 @@ $app->register(new Grom\Silex\ImagineServiceProvider(), array(
 
 $app['is_admin'] = false;
 
-//Creating a Chamilo service provider
+// Creating a Chamilo service provider
 use Silex\ServiceProviderInterface;
 
 class ChamiloServiceProvider implements ServiceProviderInterface
 {
     public function register(Application $app)
     {
-        //Template
+        // Template class
         $app['template'] = $app->share(function () use ($app) {
             $template = new Template($app);
             return $template;
         });
 
-        //Template
+        // Chamilo data filesystem
         $app['chamilo.filesystem'] = $app->share(function () use ($app) {
             $filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem($app['data.path']);
             return $filesystem;
         });
 
+        // Page controller class
         $app['page_controller'] = $app->share(function () use ($app) {
             $pageController = new PageController($app);
             return $pageController;
@@ -1053,9 +1054,10 @@ $app['posts.controller'] = $app->share(function() use ($app) {
 });
 $app->mount('/', "posts.controller");*/
 
-
-
-//@todo move this in a permission class
+/**
+ * Nice middlewares that will fix the permission problems in Chamilo
+ * @todo move this in a permission class
+ **/
 $checkCourse = function (Request $request) use ($app) {
     $courseCode = $request->get('courseCode');
     $sessionId = $request->get('sessionId');
@@ -1083,7 +1085,6 @@ $checkCourse = function (Request $request) use ($app) {
         Session::write('id_session', 0);
     }
 };
-
 $courseAccessConditions = function (Request $request) use ($app) {
     $courseCode = $request->get('cidReq');
 };
@@ -1092,15 +1093,14 @@ $userAccessPermissions = function (Request $request) use ($app) {
     $courseCode = $request->get('cidReq');
 };
 
-//End legacy befores
+// End middlewares
+
+// @todo put routes somewhere else, in a yml/php file .
 
 /**
  * All calls made in Chamilo (olds ones) are manage in the LegacyController::classicAction function located here:
  * src/ChamiloLMS/Controller/LegacyController.php
  */
-
-// @todo put routes somewhere else, in a yml/php file .
-
 $app->get('/', 'legacy.controller:classicAction')
     ->before($courseAccessConditions)
     ->before($userAccessPermissions);
@@ -1140,9 +1140,6 @@ $app->match('/courses/{courseCode}/', 'course_home.controller:indexAction', 'GET
 $app->get('/courses/{courseCode}/document/', 'index.controller:getDocumentAction')
     ->assert('type', '.+');
 
-
-//$app->match('/courses/{courseCode}/document/{fileName}', 'course_home.controller:getFileAction', 'GET|POST');
-
 // Certificates
 $app->match('/certificates/{id}', 'certificate.controller:indexAction', 'GET');
 
@@ -1150,6 +1147,7 @@ $app->match('/certificates/{id}', 'certificate.controller:indexAction', 'GET');
 $app->match('/user/{username}', 'user.controller:indexAction', 'GET');
 
 // Who is online
+
 /*$app->match('/users/online', 'user.controller:onlineAction', 'GET');
 $app->match('/users/online-in-course', 'user.controller:onlineInCourseAction', 'GET');
 $app->match('/users/online-in-session', 'user.controller:onlineInSessionAction', 'GET');*/
@@ -1162,10 +1160,11 @@ $app->match('/news/{id}', 'news.controller:indexAction', 'GET')
 $app->match('/learnpath/subscribe_users/{lpId}', 'learnpath.controller:indexAction', 'GET|POST')
     ->bind('subscribe_users');
 
-// Data document_templates
+// Data document_templates files
 $app->get('/data/document_templates/{file}', 'index.controller:getDocumentTemplateAction')
     ->bind('data');
 
+// Data default_platform_document files
 $app->get('/data/default_platform_document/', 'index.controller:getDefaultPlatformDocumentAction')
     ->assert('type', '.+');
 return $app;

+ 5 - 1
src/ChamiloLMS/Component/DataFilesystem/DataFilesystem.php

@@ -6,6 +6,11 @@ use Symfony\Component\Finder\Finder;
 use Symfony\Component\Finder\SplFileInfo;
 use Symfony\Component\Filesystem\Filesystem;
 
+/**
+ * @todo use Gaufrette to manage course files (some day)
+ * Class DataFilesystem
+ * @package ChamiloLMS\Component\DataFilesystem
+ */
 class DataFilesystem
 {
     private $path;
@@ -49,5 +54,4 @@ class DataFilesystem
         $file = 'courses/'.$courseCode.'/document/'.$file;
         return $this->get($file);
     }
-
 }

+ 17 - 5
src/ChamiloLMS/Controller/IndexController.php

@@ -276,7 +276,7 @@ class IndexController extends CommonController
     }
 
     /**
-     *
+     * @todo move all this getDocument* Actions into another controller
      * @param Application $app
      * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|void
      */
@@ -287,10 +287,17 @@ class IndexController extends CommonController
             $file = $app['chamilo.filesystem']->get('document_templates/'.$file);
             return $app->sendFile($file->getPathname());
         } catch (\InvalidArgumentException $e) {
-            return $app->abort(404, 'No file found');
+            return $app->abort(404, 'File not found');
         }
     }
 
+    /**
+     * Gets a document from the data/courses/MATHS/document/file.jpg to the user
+     * @todo check permissions
+     * @param Application $app
+     * @param $courseCode
+     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|void
+     */
     public function getDocumentAction(Application $app, $courseCode)
     {
         try {
@@ -298,10 +305,15 @@ class IndexController extends CommonController
             $file = $app['chamilo.filesystem']->getCourseDocument($courseCode, $filePath);
             return $app->sendFile($file->getPathname());
         } catch (\InvalidArgumentException $e) {
-            return $app->abort(404, 'No file found');
+            return $app->abort(404, 'File not found');
         }
     }
 
+    /**
+     * Gets a document from the data/default_platform_document/* folder
+     * @param Application $app
+     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|void
+     */
     public function getDefaultPlatformDocumentAction(Application $app)
     {
         try {
@@ -309,12 +321,12 @@ class IndexController extends CommonController
             $file = $app['chamilo.filesystem']->get('default_platform_document/'.$file);
             return $app->sendFile($file->getPathname());
         } catch (\InvalidArgumentException $e) {
-            return $app->abort(404, 'No file found');
+            return $app->abort(404, 'File not found');
         }
     }
 
     /**
-     * Reacts on a failed login:
+     * Reacts on a failed login.
      * Displays an explanation with a link to the registration form.
      *
      * @todo use twig template to prompt errors + move this into a helper