Browse Source

Merge branch 'BT9441' of https://github.com/AngelFQC/chamilo-lms into AngelFQC-BT9441

Yannick Warnier 10 years ago
parent
commit
9b87b7f179

+ 32 - 0
main/inc/ajax/model.ajax.php

@@ -145,6 +145,7 @@ if (!$sidx) {
 switch ($action) {
     case 'get_user_course_report':
     case 'get_user_course_report_resumed':
+        $userId = api_get_user_id();
         if (!(api_is_platform_admin(false, true))) {
             //exit;
         }
@@ -186,7 +187,38 @@ switch ($action) {
             if (empty($userIdList) || empty($courseCodeList)) {
                 exit;
             }
+        } else if(api_is_student_boss()) {
+            $users = UserManager::getUsersFollowedByStudentBoss($userId);
+
+            $userIdList = array_keys($users);
+        }
+
+        $groups = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_ADMIN);
+
+        $groupsId = array_keys($groups);
+
+        if (is_array($groupsId)) {
+            foreach ($groupsId as $groupId) {
+                $groupUsers = GroupPortalManager::get_users_by_group($groupId);
+
+                if (!is_array($groupUsers)) {
+                    continue;
+                }
+
+                foreach ($groupUsers as $memberId => $member) {
+                    if ($member['user_id'] == $userId ) {
+                        continue;
+                    }
+
+                    $userIdList[] = intval($member['user_id']);
+                }
+            }
+        }
+
+        if (is_array($userIdList)) {
+            $userIdList = array_unique($userIdList);
         }
+
         if ($action == 'get_user_course_report') {
             $count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList);
         } else {

+ 41 - 3
main/mySpace/company_reports.php

@@ -12,8 +12,10 @@ $language_file = array('admin', 'gradebook', 'tracking');
 $cidReset = true;
 require_once '../inc/global.inc.php';
 
-if (!(api_is_platform_admin(false, true))) {
-    api_not_allowed();
+$userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true);
+
+if ($userNotAllowed) {
+    api_not_allowed(true);
 }
 
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
@@ -88,7 +90,43 @@ $(function() {
     });
 });
 </script>';
-$content = Display::grid_html('user_course_report');
+
+$actions = null;
+
+if (api_is_student_boss()) {
+    $actions .= Display::url(
+        Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
+        api_get_path(WEB_CODE_PATH) . "auth/my_progress.php"
+    );
+    $actions .= Display::url(
+        Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM),
+        api_get_path(WEB_CODE_PATH) . "mySpace/student.php"
+    );
+    $actions .= Display::url(
+        Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM),
+        "#"
+    );
+}
+
+$content = '<div class="actions">';
+
+if (!empty($actions)) {
+    $content .= $actions;
+}
+
+$content .= '<div class="pull-right">';
+$content .= Display::url(
+    get_lang("CompanyReportResumed"),
+    api_get_path(WEB_CODE_PATH) . "mySpace/company_reports_resumed.php",
+    array(
+        'class' => 'btn btn-info'
+    )
+);
+
+$content .= '</div>';
+$content .= '</div>';
+$content .= '<h1 class="page-header">' . get_lang('CompanyReport') . '</h1>';
+$content .= Display::grid_html('user_course_report');
 
 $tpl = new Template($tool_name);
 $tpl->assign('content', $content);

+ 43 - 3
main/mySpace/company_reports_resumed.php

@@ -12,8 +12,10 @@ $cidReset = true;
 
 require_once '../inc/global.inc.php';
 
-if (!(api_is_platform_admin(false, true))) {
-    api_not_allowed();
+$userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true);
+
+if ($userNotAllowed) {
+    api_not_allowed(true);
 }
 
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('MySpace'));
@@ -83,7 +85,45 @@ $(function() {
     });
 });
 </script>';
-$content = Display::grid_html('user_course_report');
+
+$actions = null;
+
+if (api_is_student_boss()) {
+    $actions .= Display::url(
+        Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
+        api_get_path(WEB_CODE_PATH) . "auth/my_progress.php"
+    );
+    $actions .= Display::url(
+        Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM),
+        api_get_path(WEB_CODE_PATH) . "mySpace/student.php"
+    );
+    $actions .= Display::url(
+        Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM),
+        api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php"
+    );
+}
+
+$content = '<div class="actions">';
+
+if (!empty($actions)) {
+    $content .= $actions;
+}
+
+if (!api_is_student_boss()) {
+    $content .= '<div class="pull-right">';
+    $content .= Display::url(
+        get_lang("CompanyReport"),
+        api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php",
+        array(
+            'class' => 'btn btn-info'
+        )
+    );
+    $content .= '</div>';   
+}
+
+$content .= '</div>';
+$content .= '<h1 class="page-header">' . get_lang('CompanyReportResumed') . '</h1>';
+$content .= Display::grid_html('user_course_report');
 
 $tpl = new Template($tool_name);
 $tpl->assign('content', $content);

+ 4 - 0
main/mySpace/student.php

@@ -212,6 +212,10 @@ if (api_is_drh()) {
         Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM),
         '#'
     );
+    $actions .= Display::url(
+        Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM),
+        api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php"
+    );
 }
 
 $actions .= '<span style="float:right">';