Browse Source

Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

Julio 6 years ago
parent
commit
42337ece79

+ 64 - 9
main/admin/user_list.php

@@ -439,7 +439,7 @@ function get_number_of_users()
  * @param   int     Number of users to get
  * @param   int     Column to sort on
  * @param   string  Order (ASC,DESC)
- *
+ * @return  array   Users list
  * @see SortableTable#get_table_data($from)
  */
 function get_user_data($from, $number_of_items, $column, $direction)
@@ -512,6 +512,8 @@ function email_filter($email)
  * Returns a mailto-link.
  *
  * @param string $email An email-address
+ * @param array  $params Deprecated
+ * @param array  $row
  *
  * @return string HTML-code with a mailto-link
  */
@@ -528,6 +530,7 @@ function user_filter($name, $params, $row)
  * @param   array   Row of elements to alter
  *
  * @return string Some HTML-code with modify-buttons
+ * @throws Exception
  */
 function modify_filter($user_id, $url_params, $row)
 {
@@ -808,9 +811,7 @@ function active_filter($active, $params, $row)
 
 /**
  * Instead of displaying the integer of the status, we give a translation for the status.
- *
  * @param int $status
- *
  * @return string translation
  *
  * @version march 2008
@@ -887,17 +888,17 @@ if (!empty($action)) {
             case 'delete':
                 if (api_is_platform_admin()) {
                     $number_of_selected_users = count($_POST['id']);
-                    $number_of_deleted_users = 0;
+                    $number_of_affected_users = 0;
                     if (is_array($_POST['id'])) {
                         foreach ($_POST['id'] as $index => $user_id) {
                             if ($user_id != $_user['user_id']) {
                                 if (UserManager::delete_user($user_id)) {
-                                    $number_of_deleted_users++;
+                                    $number_of_affected_users++;
                                 }
                             }
                         }
                     }
-                    if ($number_of_selected_users == $number_of_deleted_users) {
+                    if ($number_of_selected_users == $number_of_affected_users) {
                         $message = Display::return_message(
                             get_lang('SelectedUsersDeleted'),
                             'confirmation'
@@ -910,6 +911,58 @@ if (!empty($action)) {
                     }
                 }
                 break;
+            case 'disable':
+                if (api_is_platform_admin()) {
+                    $number_of_selected_users = count($_POST['id']);
+                    $number_of_affected_users = 0;
+                    if (is_array($_POST['id'])) {
+                        foreach ($_POST['id'] as $index => $user_id) {
+                            if ($user_id != $_user['user_id']) {
+                                if (UserManager::disable($user_id)) {
+                                    $number_of_affected_users++;
+                                }
+                            }
+                        }
+                    }
+                    if ($number_of_selected_users == $number_of_affected_users) {
+                        $message = Display::return_message(
+                            get_lang('SelectedUsersDisabled'),
+                            'confirmation'
+                        );
+                    } else {
+                        $message = Display::return_message(
+                            get_lang('SomeUsersNotDisabled'),
+                            'error'
+                        );
+                    }
+                }
+                break;
+            case 'enable':
+                if (api_is_platform_admin()) {
+                    $number_of_selected_users = count($_POST['id']);
+                    $number_of_affected_users = 0;
+                    if (is_array($_POST['id'])) {
+                        foreach ($_POST['id'] as $index => $user_id) {
+                            if ($user_id != $_user['user_id']) {
+                                if (UserManager::enable($user_id)) {
+                                    $number_of_affected_users++;
+                                }
+                            }
+                        }
+                    }
+                    if ($number_of_selected_users == $number_of_affected_users) {
+                        $message = Display::return_message(
+                            get_lang('SelectedUsersEnabled'),
+                            'confirmation'
+                        );
+                    } else {
+                        $message = Display::return_message(
+                            get_lang('SomeUsersNotEnabled'),
+                            'error'
+                        );
+                    }
+                }
+                break;
         }
         Security::clear_token();
     }
@@ -1053,13 +1106,15 @@ $table->set_column_filter(8, 'active_filter');
 $table->set_column_filter(10, 'modify_filter');
 
 // Only show empty actions bar if delete users has been blocked
+$actionsList = [];
 if (api_is_platform_admin() &&
     !api_get_configuration_value('deny_delete_users')
 ) {
-    $table->set_form_actions(['delete' => get_lang('DeleteFromPlatform')]);
-} else {
-    $table->set_form_actions(['none' => get_lang('NoActionAvailable')]);
+    $actionsList['delete'] = get_lang('DeleteFromPlatform');
 }
+$actionsList['disable'] = get_lang('Disable');
+$actionsList['enable'] = get_lang('Enable');
+$table->set_form_actions($actionsList);
 
 $table_result = $table->return_table();
 $extra_search_options = '';

+ 72 - 16
main/inc/lib/CourseChatUtils.php

@@ -4,7 +4,9 @@
 use Chamilo\CoreBundle\Entity\Course;
 use Chamilo\CoreBundle\Entity\CourseRelUser;
 use Chamilo\CoreBundle\Entity\Session;
+use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
 use Chamilo\CourseBundle\Entity\CChatConnected;
+use Chamilo\UserBundle\Entity\User;
 use Doctrine\Common\Collections\Criteria;
 use Michelf\MarkdownExtra;
 
@@ -94,7 +96,7 @@ class CourseChatUtils
         $document_path = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document';
         $basepath_chat = '/chat_files';
         $group_info = [];
-        if (!$this->groupId) {
+        if ($this->groupId) {
             $group_info = GroupManager::get_group_properties($this->groupId);
             $basepath_chat = $group_info['directory'].'/chat_files';
         }
@@ -702,30 +704,60 @@ class CourseChatUtils
         return (int) $number;
     }
 
+    /**
+     * Format the user data to return it in the user list
+     *
+     * @param User $user
+     * @param int  $status
+     *
+     * @return array
+     */
+    private function formatUser(User $user, $status)
+    {
+        return [
+            'id' => $user->getId(),
+            'firstname' => $user->getFirstname(),
+            'lastname' => $user->getLastname(),
+            'status' => $status,
+            'image_url' => UserManager::getUserPicture($user->getId(), USER_IMAGE_SIZE_MEDIUM),
+            'profile_url' => api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user->getId(),
+            'complete_name' => $user->getCompleteName(),
+            'username' => $user->getUsername(),
+            'email' => $user->getEmail(),
+            'isConnected' => $this->userIsConnected($user->getId()),
+        ];
+    }
+
     /**
      * Get the users online data.
      *
      * @return array
+     * @throws \Doctrine\ORM\ORMException
+     * @throws \Doctrine\ORM\OptimisticLockException
+     * @throws \Doctrine\ORM\TransactionRequiredException
      */
     public function listUsersOnline()
     {
         $subscriptions = $this->getUsersSubscriptions();
         $usersInfo = [];
-        /** @var CourseRelUser $subscription */
-        foreach ($subscriptions as $subscription) {
-            $user = $subscription->getUser();
-            $usersInfo[] = [
-                'id' => $user->getId(),
-                'firstname' => $user->getFirstname(),
-                'lastname' => $user->getLastname(),
-                'status' => !$this->sessionId ? $subscription->getStatus() : $user->getStatus(),
-                'image_url' => UserManager::getUserPicture($user->getId(), USER_IMAGE_SIZE_MEDIUM),
-                'profile_url' => api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user->getId(),
-                'complete_name' => $user->getCompleteName(),
-                'username' => $user->getUsername(),
-                'email' => $user->getEmail(),
-                'isConnected' => $this->userIsConnected($user->getId()),
-            ];
+
+        if ($this->groupId) {
+            /** @var User $groupUser */
+            foreach ($subscriptions as $groupUser) {
+                $usersInfo[] = $this->formatUser(
+                    $groupUser,
+                    $groupUser->getStatus()
+                );
+            }
+        } else {
+            /** @var CourseRelUser|SessionRelCourseRelUser $subscription */
+            foreach ($subscriptions as $subscription) {
+                $user = $subscription->getUser();
+                $usersInfo[] = $this->formatUser(
+                    $user,
+                    $this->sessionId ? $user->getStatus() : $subscription->getStatus()
+                );
+            }
         }
 
         return $usersInfo;
@@ -743,6 +775,30 @@ class CourseChatUtils
     private function getUsersSubscriptions()
     {
         $em = Database::getManager();
+
+        if ($this->groupId) {
+            $students = $em
+                ->createQuery(
+                    'SELECT u FROM ChamiloUserBundle:User u
+                    INNER JOIN ChamiloCourseBundle:CGroupRelUser gru
+                        WITH u.id = gru.userId AND gru.cId = :course
+                    WHERE u.id != :user AND gru.groupId = :group'
+                )
+                ->setParameters(['course' => $this->courseId, 'user' => $this->userId, 'group' => $this->groupId])
+                ->getResult();
+            $tutors = $em
+                ->createQuery(
+                    'SELECT u FROM ChamiloUserBundle:User u
+                    INNER JOIN ChamiloCourseBundle:CGroupRelTutor grt
+                        WITH u.id = grt.userId AND grt.cId = :course
+                    WHERE u.id != :user AND grt.groupId = :group'
+                )
+                ->setParameters(['course' => $this->courseId, 'user' => $this->userId, 'group' => $this->groupId])
+                ->getResult();
+
+            return array_merge($tutors, $students);
+        }
+
         /** @var Course $course */
         $course = $em->find('ChamiloCoreBundle:Course', $this->courseId);
 

+ 1 - 1
main/inc/lib/api.lib.php

@@ -1677,7 +1677,7 @@ function api_get_user_info(
                     false,
                     true
                 );
-                if (@intval($user_status['user_chat_status']) == 1) {
+                if ((int) $user_status['user_chat_status'] == 1) {
                     $user_online_in_chat = 1;
                 }
             }

+ 6 - 2
main/inc/lib/groupmanager.lib.php

@@ -2339,8 +2339,12 @@ class GroupManager
                 $group_name = '<a class="'.$groupNameClass.'" href="group_space.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'">'.
                     Security::remove_XSS($this_group['name']).'</a> ';
 
-                $group_name2 = '<a href="suivi_group_space.php?cidReq='.api_get_course_id().'&gidReq='.$this_group['id'].'">
-                                '.get_lang('suivi_de').''.stripslashes($this_group['name']).'</a>';
+                $group_name2 = '';
+
+                if (api_get_configuration_value('extra')) {
+                    $group_name2 = '<a href="suivi_group_space.php?cidReq='.api_get_course_id().'&gidReq='
+                        .$this_group['id'].'">'.get_lang('suivi_de').''.stripslashes($this_group['name']).'</a>';
+                }
 
                 if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
                     $group_name .= Display::label(get_lang('OneMyGroups'), 'success');

+ 1 - 1
main/inc/lib/javascript/chat/js/chat.js

@@ -184,7 +184,7 @@ function stopChatHeartBeat()
 
 function startChatHeartBeat()
 {
-    timer = setInterval('chatHeartbeat();', chatHeartbeatTime);
+    timer = setInterval(chatHeartbeat, chatHeartbeatTime);
 }
 
 /*

+ 1 - 1
main/inc/lib/social.lib.php

@@ -2057,7 +2057,7 @@ class SocialManager extends UserManager
                     $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
                     $user_info_friend = api_get_user_info($friend['friend_user_id'], true);
 
-                    if (!empty($user_info_friend['user_is_online'])) {
+                    if (!empty($user_info_friend['user_is_online_in_chat'])) {
                         $statusIcon = Display::return_icon('statusonline.png', get_lang('Online'));
                         $status = 1;
                     } else {

+ 13 - 1
main/lang/english/trad4all.inc.php

@@ -1776,7 +1776,7 @@ $UserLocked = "User locked";
 $UserUnlocked = "User unlocked";
 $CannotDeleteUser = "You cannot delete this user";
 $SelectedUsersDeleted = "Selected users deleted";
-$SomeUsersNotDeleted = "Some users has not been deleted";
+$SomeUsersNotDeleted = "Some of the selected users have not been deleted. We recommend you confirm which, by using the advanced search.";
 $ExternalAuthentication = "External authentification";
 $RegistrationDate = "Registration date";
 $UserUpdated = "User updated";
@@ -8146,4 +8146,16 @@ $DocumentAutoLaunch = "Auto-launch for documents";
 $RedirectToTheDocumentList = "Redirect to the document list";
 $TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToTheExerciseList = "The exercises auto-launch feature configuration is enabled. Learners will be automatically redirected to exercise list.";
 $PostedExpirationDate = "Posted deadline for sending the work (Visible to the learner)";
+$BossAlertMsgSentToUserXTitle = "Follow up message about student %s";
+$BossAlertUserXSentMessageToUserYWithLinkZ = "Hi,<br/><br/>
+
+User %s sent a follow up message about student %s.<br/><br/>
+
+The message can be seen here %s";
+$include_services = "Include services";
+$culqi_enable = "Enable culqi";
+$SelectedUsersDisabled = "The selected users have all been disabled";
+$SomeUsersNotDisabled = "Some of the selected users have not been disabled. We recommend you confirm which, by using the advanced search.";
+$SelectedUsersEnabled = "The selected users were all enabled.";
+$SomeUsersNotEnabled = "Some of the selected users have not been enabled. We recommend you confirm which, by using the advanced search.";
 ?>

+ 8 - 2
main/lang/french/trad4all.inc.php

@@ -8084,9 +8084,15 @@ $RedirectToTheDocumentList = "Rediriger vers la liste des documents";
 $TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToTheExerciseList = "La fonctionnalité d'auto-démarrage des exercices est activée. Les apprenants seront automatiquement redirigés vers la liste des exercices.";
 $PostedExpirationDate = "Date limite affichée d'envoi du travail (visible par l'apprenant)";
 $BossAlertMsgSentToUserXTitle = "Message de suivi concernant l'apprenant %s";
-$BossAlertUserXSentMessageToUserYWithLinkZ = "Bonjour,
+$BossAlertUserXSentMessageToUserYWithLinkZ = "Bonjour,<br/><br/>
 
-L'utilisateur %s a envoyé un message de suivi concernant l'apprenant %s.
+L'utilisateur %s a envoyé un message de suivi concernant l'apprenant %s.<br/><br/>
 
 Le message est visible sur %s";
+$include_services = "Inclure les services";
+$culqi_enable = "Activé culqi";
+$SelectedUsersDisabled = "Les utilisateurs sélectionnés ont tous été désactivés.";
+$SomeUsersNotDisabled = "Certains des utilisateurs sélectionnés n'ont pas été supprimés. Nous vous recommandons de confirmer lesquels en utilisant la recherche avancée.";
+$SelectedUsersEnabled = "Tous les utilisateurs sélectionnés ont été activés.";
+$SomeUsersNotEnabled = "Certains des utilisateurs sélectionnés n'ont pas été activés. Nous vous recommandons de confirmer lesquels en utilisant la recherche avancée.";
 ?>

+ 12 - 0
main/lang/spanish/trad4all.inc.php

@@ -8170,4 +8170,16 @@ $DocumentAutoLaunch = "Lanzamiento automático para documentos";
 $RedirectToTheDocumentList = "Redirigir a la lista de documentos";
 $TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToTheExerciseList = "La funcionalidad de lanzamiento automático de ejercicios está activada. Los estudiantes serán automáticamente redirigidos a la lista de ejercicios.";
 $PostedExpirationDate = "Fecha límite publicada para enviar el trabajo (visible para el alumno)";
+$BossAlertMsgSentToUserXTitle = "Mensaje de seguimiento sobre alumno %s";
+$BossAlertUserXSentMessageToUserYWithLinkZ = "Hola,<br/><br/>
+
+El usuario %s ha enviado un mensaje de seguimiento sobre el alumno %s.<br/><br/>
+
+El mensaje se puede ver en %s";
+$include_services = "Incluir los servicios";
+$culqi_enable = "Activar Culqi";
+$SelectedUsersDisabled = "Todos los usuarios seleccionados han sido desactivado.";
+$SomeUsersNotDisabled = "Algunos de los usuarios seleccionados no han sido desactivado. Le recomendamos una verificación adicional a través de la búsqueda avanzada.";
+$SelectedUsersEnabled = "Todos los usuarios seleccionados han sido activado.";
+$SomeUsersNotEnabled = "Algunos de los usuarios seleccionados no han sido activado. Le recomendamos una verificación adicional a través de la búsqueda avanzada.";
 ?>