Browse Source

Adding profile/user controllers.

Julio Montoya 11 years ago
parent
commit
68365408c5

+ 5 - 8
main/inc/routes.php

@@ -483,14 +483,6 @@ $app->get('/data/courses/{courseCode}/scorm/{file}', 'index.controller:getScormD
 /** Certificates */
 $app->match('/certificates/{id}', 'certificate.controller:indexAction', 'GET');
 
-/** Username */
-$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');*/
-
 /** Portal news */
 $app->match('/news/{id}', 'news.controller:indexAction', 'GET')
     ->bind('portal_news');
@@ -655,6 +647,11 @@ if ($alreadyInstalled) {
     $app->mount('/admin/administrator/roles', new ChamiloLMS\Provider\ReflectionControllerProvider('role.controller'));
     $app->mount('/admin/administrator/question_scores', new ChamiloLMS\Provider\ReflectionControllerProvider('question_score.controller'));
     $app->mount('/admin/administrator/question_score_names', new ChamiloLMS\Provider\ReflectionControllerProvider('question_score_name.controller'));
+
+    $app->mount('/user/', new ChamiloLMS\Provider\ReflectionControllerProvider('profile.controller'));
+
+    $app->mount('/', new ChamiloLMS\Provider\ReflectionControllerProvider('user.controller'));
+
     $app->mount('/courses/{course}/curriculum/category', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_category.controller'));
     $app->mount('/courses/{course}/curriculum/item', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_item.controller'));
     $app->mount('/courses/{course}/curriculum/user', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_user.controller'));

+ 9 - 1
main/inc/services.php

@@ -629,6 +629,7 @@ class ChamiloServiceProvider implements ServiceProviderInterface
 // Registering Chamilo service provider.
 $app->register(new ChamiloServiceProvider(), array());
 
+
 // Controller as services definitions.
 $app['pages.controller'] = $app->share(
     function () use ($app) {
@@ -685,9 +686,15 @@ $app['certificate.controller'] = $app->share(
     }
 );
 
+$app['profile.controller'] = $app->share(
+    function () use ($app) {
+        return new ChamiloLMS\Controller\User\ProfileController($app);
+    }
+);
+
 $app['user.controller'] = $app->share(
     function () use ($app) {
-        return new ChamiloLMS\Controller\UserController();
+        return new ChamiloLMS\Controller\User\UserController($app);
     }
 );
 
@@ -720,6 +727,7 @@ $app['admin.controller'] = $app->share(
         return new ChamiloLMS\Controller\Admin\AdminController($app);
     }
 );
+
 $app['role.controller'] = $app->share(
     function () use ($app) {
         return new ChamiloLMS\Controller\Admin\Administrator\RoleController($app);

+ 17 - 0
main/template/default/user/files.tpl

@@ -0,0 +1,17 @@
+{% extends app.template_style ~ "/layout/layout_2_col.tpl" %}
+
+{% block left_column %}
+    <div class="well social-background-content">
+        <img src="{{ user.avatar }}"/>
+    </div>
+
+    <div class="well sidebar-nav">
+
+    </div>
+{% endblock %}
+
+{% block right_column %}
+    <div class="well_border">
+        <h3>{{ 'MyFiles' | trans }}</h3>
+    </div>
+{% endblock %}

+ 5 - 0
main/template/default/user/index.tpl

@@ -0,0 +1,5 @@
+{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
+
+{% block content %}
+    {{ user.username }}
+{% endblock %}

+ 30 - 0
main/template/default/user/me.tpl

@@ -0,0 +1,30 @@
+{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
+
+{% block content %}
+
+    <img src="{{ user.avatar }}"/>
+
+    <h3>{{ user.complete_name }} @{{ user.username }} </h3>
+
+    <div class="tabbable tabs-left">
+        <ul class="nav nav-tabs">
+            <a href="#lA" data-toggle="tab">Section 1</a>
+            <a href="#lB" data-toggle="tab">Section 2</a>
+            <a href="#lC" data-toggle="tab">Section 3</a>
+        </ul>
+        <div class="tab-content">
+            <div class="tab-pane" id="lA">
+                <p>I'm in Section A.</p>
+            </div>
+            <div class="tab-pane" id="lB">
+                <p>I'm in Section A.</p>
+            </div>
+            <div class="tab-pane" id="lC">
+                <p>I'm in Section A.</p>
+            </div>
+        </div>
+    </div>
+
+
+
+{% endblock %}

+ 17 - 0
main/template/default/user/profile.tpl

@@ -0,0 +1,17 @@
+{% extends app.template_style ~ "/layout/layout_2_col.tpl" %}
+
+{% block left_column %}
+    <div class="well social-background-content">
+        <img src="{{ user.avatar }}"/>
+    </div>
+
+    <div class="well sidebar-nav">
+
+    </div>
+{% endblock %}
+
+{% block right_column %}
+    <div class="well_border">
+        <h3>{{ user.complete_name }} @{{ user.username }} </h3>
+    </div>
+{% endblock %}

+ 55 - 0
src/ChamiloLMS/Controller/User/ProfileController.php

@@ -0,0 +1,55 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace ChamiloLMS\Controller\User;
+
+use ChamiloLMS\Controller\CommonController;
+use Silex\Application;
+use Symfony\Component\Routing\Annotation\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
+use Symfony\Component\HttpFoundation\Response;
+
+
+/**
+ * Class ProfileController
+ * @package ChamiloLMS\Controller
+ */
+class ProfileController extends CommonController
+{
+
+    /**
+     * @Route("/{username}")
+     * @Method({"GET"})
+     */
+    public function indexAction($username)
+    {
+        $userId = \UserManager::get_user_id_from_username($username);
+        $userInfo = api_get_user_info($userId);
+
+        $this->getTemplate()->assign('user', $userInfo);
+        $response = $this->getTemplate()->renderTemplate($this->getTemplatePath().'profile.tpl');
+        return new Response($response, 200, array());
+    }
+
+    /**
+     * @Route("/{username}/files")
+     * @Method({"GET"})
+     */
+    public function fileAction($username)
+    {
+        $userId = \UserManager::get_user_id_from_username($username);
+        $userInfo = api_get_user_info($userId);
+
+        $this->getTemplate()->assign('user', $userInfo);
+        $response = $this->getTemplate()->renderTemplate($this->getTemplatePath().'files.tpl');
+        return new Response($response, 200, array());
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function getTemplatePath()
+    {
+        return 'user/';
+    }
+}

+ 51 - 0
src/ChamiloLMS/Controller/User/UserController.php

@@ -0,0 +1,51 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace ChamiloLMS\Controller\User;
+
+use Silex\Application;
+
+use Symfony\Component\HttpFoundation\Response;
+use ChamiloLMS\Controller\CommonController;
+use Symfony\Component\Routing\Annotation\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
+
+
+/**
+ * Class UserController
+ * @package ChamiloLMS\Controller
+ * @author Julio Montoya <gugli100@gmail.com>
+ */
+class UserController extends CommonController
+{
+    /**
+     * @Route("/me")
+     * @Method({"GET"})
+     */
+    public function indexAction()
+    {
+        $userInfo = api_get_user_info($this->getUser()->getUserId());
+
+        $this->getTemplate()->assign('user', $userInfo);
+        $response = $this->getTemplate()->renderTemplate($this->getTemplatePath().'me.tpl');
+        return new Response($response, 200, array());
+    }
+
+    /**
+     * @Route("/online")
+     * @Method({"GET"})
+     */
+    public function onlineAction(Application $app)
+    {
+        $response = $app['template']->render_layout('layout_1_col.tpl');
+        return new Response($response, 200, array());
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function getTemplatePath()
+    {
+        return 'user/';
+    }
+}

+ 0 - 62
src/ChamiloLMS/Controller/UserController.php

@@ -1,62 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-namespace ChamiloLMS\Controller;
-
-use Silex\Application;
-use Symfony\Component\HttpFoundation\Response;
-
-/**
- * Class UserController
- * @package ChamiloLMS\Controller
- * @author Julio Montoya <gugli100@gmail.com>
- */
-class UserController
-{
-    /**
-     *
-     * @return Response
-     */
-    public function indexAction(Application $app, $username)
-    {
-        $userId = \UserManager::get_user_id_from_username($username);
-        $content = \SocialManager::display_individual_user($userId, true);
-        $app['template']->assign('content', $content);
-        $response = $app['template']->render_layout('layout_1_col.tpl');
-
-        return new Response($response, 200, array());
-    }
-
-    /**
-     * @param Application $app
-     * @todo remove whoisonline.php script and use this
-     *
-     * @return Response
-     */
-    public function onlineAction(Application $app)
-    {
-
-        $response = $app['template']->render_layout('layout_1_col.tpl');
-        return new Response($response, 200, array());
-    }
-
-    /**
-     * @param Application $app
-     *
-     * @return Response
-     */
-    public function onlineInCourseAction(Application $app)
-    {
-
-    }
-
-    /**
-     * @param Application $app
-     *
-     * @return Response
-     */
-    public function onlineInSessionAction(Application $app)
-    {
-
-    }
-}