Kaynağa Gözat

Minor merge with branch.

Julio Montoya 11 yıl önce
ebeveyn
işleme
d7deb8ef99

+ 3 - 4
main/inc/global.inc.php

@@ -259,6 +259,7 @@ $app->error(
         if ($app['debug']) {
             //return;
         }
+        $message = null;
         if (isset($code)) {
             switch ($code) {
                 case 401:
@@ -273,12 +274,9 @@ $app->error(
             }
         } else {
             $code = null;
-            $message = null;
         }
         //$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500;
-        $app['twig']->addGlobal('error_code', $code);
-        $app['twig']->addGlobal('error_message', $message);
-
+    
         // It seems that error() is executed first than the before() middleware
         // @ŧodo check this one
         $templateStyle = api_get_setting('template');
@@ -288,6 +286,7 @@ $app->error(
         // Default layout.
         $app['default_layout'] = $app['template_style'].'/layout/layout_1_col.tpl';
 
+        $app['template']->assign('error', array('code' => $code, 'message' => $message));
 
         $response = $app['template']->render_layout('error.tpl');
 

+ 33 - 14
main/inc/lib/api.lib.php

@@ -2267,15 +2267,18 @@ function api_get_self() {
 function api_is_platform_admin($allow_sessions_admins = false)
 {
     global $app;
+    $token = $app['security']->getToken();
 
-    if ($app['security']->isGranted('ROLE_ADMIN')) {
-        return true;
-    }
-
-    if ($allow_sessions_admins) {
-        if ($app['security']->isGranted('ROLE_SESSION_MANAGER')) {
+    if (!empty($token)) {
+        if ($app['security']->isGranted('ROLE_ADMIN')) {
             return true;
         }
+
+        if ($allow_sessions_admins) {
+            if ($app['security']->isGranted('ROLE_SESSION_MANAGER')) {
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -2283,8 +2286,12 @@ function api_is_platform_admin($allow_sessions_admins = false)
 function api_is_question_manager()
 {
     global $app;
-    if ($app['security']->isGranted('ROLE_QUESTION_MANAGER')) {
-        return true;
+    $token = $app['security']->getToken();
+
+    if (!empty($token)) {
+        if ($app['security']->isGranted('ROLE_QUESTION_MANAGER')) {
+            return true;
+        }
     }
     return false;
 }
@@ -2297,8 +2304,12 @@ function api_is_question_manager()
 function api_is_session_admin()
 {
     global $app;
-    if ($app['security']->isGranted('ROLE_SESSION_MANAGER')) {
-        return true;
+    $token = $app['security']->getToken();
+
+    if (!empty($token)) {
+        if ($app['security']->isGranted('ROLE_SESSION_MANAGER')) {
+            return true;
+        }
     }
     return false;
 }
@@ -2309,8 +2320,12 @@ function api_is_session_admin()
  */
 function api_is_drh() {
     global $app;
-    if ($app['security']->isGranted('ROLE_RRHH')) {
-        return true;
+    $token = $app['security']->getToken();
+
+    if (!empty($token)) {
+        if ($app['security']->isGranted('ROLE_RRHH')) {
+            return true;
+        }
     }
     return false;
 }
@@ -2321,8 +2336,12 @@ function api_is_drh() {
  */
 function api_is_student() {
     global $app;
-    if ($app['security']->isGranted('ROLE_STUDENT')) {
-        return true;
+    $token = $app['security']->getToken();
+
+    if (!empty($token)) {
+        if ($app['security']->isGranted('ROLE_STUDENT')) {
+            return true;
+        }
     }
     return false;
 }

+ 8 - 0
main/inc/lib/extra_field.lib.php

@@ -676,6 +676,13 @@ class ExtraField extends Model
                                     }
                                 }
                             }
+                            if (isset($optionList[$defaultValueId])) {
+
+                                if (isset($optionList[$defaultValueId]['option_value']) && $optionList[$defaultValueId]['option_value'] == 'aprobada') {
+                                    if (api_is_question_manager() == false) {
+                                        $form->freeze();
+                                    }
+                                }
                         }
 
                         // Setting priority message
@@ -685,6 +692,7 @@ class ExtraField extends Model
                                 $option = new ExtraFieldOption($this->type);
                                 $messageType = $option->getPriorityMessageType($priorityId);
                                 $form->addElement('label', null, Display::return_message($optionList[$defaultValueId]['priority_message'], $messageType));
+                                }
                             }
                         }
 

+ 1 - 1
main/inc/routes.php

@@ -543,7 +543,7 @@ $app->get('/admin/dashboard', 'index.controller:dashboardAction')
 
 /** Question manager - admin */
 
-$app->get('/admin/questionmanager/', 'question_manager.controller:questionManagerIndexAction')
+$app->get('/admin/questionmanager', 'question_manager.controller:questionManagerIndexAction')
     ->assert('type', '.+')
     ->bind('admin_questionmanager');
 

+ 1 - 1
main/inc/services.php

@@ -91,7 +91,7 @@ $app['security.authentication.logout_handler.admin'] = $app->share(function($app
 
 // Role hierarchy
 $app['security.role_hierarchy'] = array(
-    'ROLE_ADMIN' => array('ROLE_QUESTION_MANAGER', 'ROLE_SESSION_MANAGER', 'ROLE_TEACHER', 'ROLE_ALLOWED_TO_SWITCH'),
+    'ROLE_ADMIN' => array('ROLE_QUESTION_MANAGER', 'ROLE_SESSION_MANAGER', 'ROLE_TEACHER', 'ROLE_ALLOWED_TO_SWITCH', 'ROLE_DIRECTOR'),
     'ROLE_RRHH' => array('ROLE_TEACHER'),
     'ROLE_TEACHER' => array('ROLE_STUDENT'),
     'ROLE_QUESTION_MANAGER' => array('ROLE_STUDENT', 'ROLE_QUESTION_MANAGER'),

+ 1 - 1
main/template/default/layout/error.tpl

@@ -1,5 +1,5 @@
 {% extends app.template_style ~ '/layout/layout_1_col.tpl' %}
 {% block content %}
-    {{ error_code }} - {{ error_message }}
+    {{ error.code }} - {{ error.message }}
     {{ content }}
 {% endblock %}

+ 3 - 0
src/ChamiloLMS/Controller/LegacyController.php

@@ -64,6 +64,9 @@ class LegacyController extends CommonController
             $app['template']->setFooter($app['template.show_footer']);
             $app['template']->setHeader($app['template.show_header']);
 
+            $token = $app['security']->getToken();
+
+
             //var_dump($app['template.show_header']);
 
             if (isset($htmlHeadXtra)) {