Browse Source

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

Julio Montoya 5 years ago
parent
commit
acf1db0dd8

+ 15 - 11
app/Resources/public/css/scorm.css

@@ -331,17 +331,6 @@ See https://support.chamilo.org/issues/6976
     margin-bottom: 5px;
 }
 
-.image-avatar .media-left img,
-.image-avatar img {
-    border: 1px solid #DDD;
-    border-radius: 5px;
-}
-
-.image-avatar {
-    padding-top: 10px;
-    padding-bottom: 10px;
-}
-
 .scorm-title {
     padding: 10px;
     display: inline-block;
@@ -359,6 +348,21 @@ See https://support.chamilo.org/issues/6976
     color: #686f7a;
 }
 
+.image-avatar {
+    padding-top: 10px;
+    padding-bottom: 10px;
+    margin-left: 3rem;
+    margin-right: 1rem;
+}
+.image-avatar .media-author .media-author-avatar{
+    text-align: center;
+    margin-bottom: 1.5rem;
+}
+.image-avatar .media-author .media-author-avatar img{
+    border: 1px solid #cdcdcd;
+    border-radius: 10px;
+}
+
 .lp-view-tabs{
     margin-top: 4px;
 }

+ 0 - 145
app/courses/proxy.php

@@ -1,145 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-/**
- * Script needed in order to avoid mixed content in links inside a learning path
- * In order to use this file you have to:
- *
- * 1. Modify configuration.php and add this setting: $_configuration['lp_fix_embed_content'] = true;
- * 2. Copy this file in app/courses/proxy.php
- * 3. Change your .htaccess in order to let the proxy.php to be read inside app/courses
- *
- */
-
-require_once '../config/configuration.php';
-
-/**
- * Returns "%" or "px"
- *
- * 800px => function returns "px"
- * 800% => function returns %
- *
- * @param string $value
- * @return string
- */
-function addPixelOrPercentage($value)
-{
-    $addPixel = strpos($value, 'px');
-    $addPixel = !($addPixel === false);
-    $addCharacter = '';
-    if ($addPixel == false) {
-        $addPercentage = strpos($value, '%');
-        $addPercentage = !($addPercentage === false);
-        if ($addPercentage) {
-            $addCharacter = '%';
-        }
-    } else {
-        $addCharacter = 'px';
-    }
-
-    return $addCharacter;
-}
-
-function get_http_response_code($theURL)
-{
-    $headers = get_headers($theURL);
-
-    return substr($headers[0], 9, 3);
-}
-
-
-$height = isset($_GET['height']) ? (int) $_GET['height'].addPixelOrPercentage($_GET['height']) : '';
-$width = isset($_GET['width']) ? (int) $_GET['width'].addPixelOrPercentage($_GET['width'])  : '';
-$vars = isset($_GET['flashvars']) ? htmlentities($_GET['flashvars']) : '';
-$src = isset($_GET['src']) ? htmlentities($_GET['src']) : '';
-$id = isset($_GET['id']) ? htmlentities($_GET['id']) : '';
-$type = isset($_GET['type']) ? $_GET['type'] : 'flash';
-
-// Fixes URL like: https://www.vopspsy.ugent.be/pdfs/download.php?own=mvsteenk&file=caleidoscoop.pdf
-if (strpos($src, 'download.php') !== false) {
-    $src = str_replace('download.php', 'download.php?', $src);
-    $src .= isset($_GET['own']) ? '&own='.htmlentities($_GET['own']) : '';
-    $src .= isset($_GET['file']) ? '&file='.htmlentities($_GET['file']) : '';
-}
-
-$result = get_http_response_code($src);
-$urlToTest = parse_url($src, PHP_URL_HOST);
-$g = stream_context_create (array('ssl' => array('capture_peer_cert' => true)));
-$r = @stream_socket_client("ssl://$urlToTest:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $g);
-$cont = stream_context_get_params($r);
-$convertToSecure = false;
-
-$certinfo = openssl_x509_parse($cont['options']['ssl']['peer_certificate']);
-if (isset($certinfo) && isset($certinfo['subject']) && isset($certinfo['subject']['CN'])) {
-    $certUrl = $certinfo['subject']['CN'];
-    $parsed = parse_url($certUrl);
-
-    // Remove www from URL
-    $parsedUrl = preg_replace('#^(http(s)?://)?w{3}\.#', '$1', $certUrl);
-
-    if ($urlToTest == $certUrl || $parsedUrl == $urlToTest) {
-        $convertToSecure = true;
-    }
-
-    if ($urlToTest != $certUrl) {
-        // url and cert url are different this will show a warning in browsers
-        // use normal "http" version
-        $result = false;
-    }
-}
-
-if ($result == false) {
-    $src = str_replace('https', 'http', $src);
-}
-
-if ($convertToSecure) {
-    $src = str_replace('http', 'https', $src);
-}
-
-$result = '';
-switch ($type) {
-    case 'link':
-        // Check if links comes from a course
-        $srcParts = explode('/', $src);
-        $srcParts = array_filter($srcParts);
-        $srcParts = array_values($srcParts);
-
-        if (isset($srcParts[0], $srcParts[2]) && $srcParts[0] === 'courses' && $srcParts[2] === 'document') {
-            $src = $_configuration['root_web'].$src;
-        }
-
-        if (strpos($src, 'http') === false) {
-            $src = "http://$src";
-        }
-        header('Location: '.$src);
-        exit;
-        break;
-    case 'iframe':
-        $result = '<iframe src="'.$src.'" width="'.$width.'" height="'.$height.'" ></iframe>';
-        break;
-    case 'flash':
-        $result =  '
-        <object 
-            id="'.$id.'" width="'.$width.'" height="'.$height.'" align="center"
-            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
-            <param name="id" value="'.$id.'">
-            <param name="width" value="'.$width.'">
-            <param name="height" value="'.$height.'">
-            <param name="bgcolor" value="#ffffff">
-            <param name="align" value="center">
-            <param name="allowfullscreen" value="true">
-            <param name="allowscriptaccess" value="always">
-            <param name="quality" value="high">
-            <param name="wmode" value="transparent">
-            <param name="flashvars" value="'.$vars.'">
-            <param name="src" value="'.$src.'">
-            <embed 
-                id="'.$id.'" width="'.$width.'" height="'.$height.'" bgcolor="#ffffff" align="center" 
-                allowfullscreen="true" allowscriptaccess="always" quality="high" wmode="transparent" 
-                flashvars="'.$vars.'" src="'.$src.'"
-                type="application/x-shockwave-flash" 
-            >
-        </object>';
-}
-
-echo $result;

+ 13 - 2
main/inc/lib/urlmanager.lib.php

@@ -18,10 +18,11 @@ class UrlManager
      * @param string $url         The URL of the site
      * @param string $description The description of the site
      * @param int    $active      is active or not
+     * @param bool   $lastId
      *
-     * @return bool if success
+     * @return bool|string if success
      */
-    public static function add($url, $description, $active)
+    public static function add($url, $description, $active, $lastId = false)
     {
         $tms = time();
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
@@ -33,6 +34,16 @@ class UrlManager
                 tms = FROM_UNIXTIME(".$tms.")";
         $result = Database::query($sql);
 
+        if($lastId){
+            $rs = Database::query("SELECT @@identity AS id");
+            $id = 0;
+
+            if ($row = Database::fetch_array($rs)) {
+                $id = trim($row[0]);
+            }
+            return $id;
+        }
+
         return $result;
     }
 

+ 7 - 2
main/inc/lib/usermanager.lib.php

@@ -1670,7 +1670,8 @@ class UserManager
         $conditions = [],
         $order_by = [],
         $limit_from = false,
-        $limit_to = false
+        $limit_to = false,
+        $idCampus = null
     ) {
         $user_table = Database::get_main_table(TABLE_MAIN_USER);
         $userUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -1678,7 +1679,11 @@ class UserManager
         $sql = "SELECT user.* FROM $user_table user ";
 
         if (api_is_multiple_url_enabled()) {
-            $urlId = api_get_current_access_url_id();
+            if($idCampus){
+                $urlId = $idCampus;
+            } else {
+                $urlId = api_get_current_access_url_id();
+            }
             $sql .= " INNER JOIN $userUrlTable url_user
                       ON (user.user_id = url_user.user_id)
                       WHERE url_user.access_url_id = $urlId";

+ 301 - 137
main/inc/lib/webservices/Rest.php

@@ -44,6 +44,14 @@ class Rest extends WebService
     const SAVE_USER = 'save_user';
     const SUBSCRIBE_USER_TO_COURSE = 'subscribe_user_to_course';
     const EXTRAFIELD_GCM_ID = 'gcm_registration_id';
+    const CREATE_CAMPUS = 'add_campus';
+    const EDIT_CAMPUS = 'edit_campus';
+    const DELETE_CAMPUS = 'delete_campus';
+    const SAVE_SESSION = 'save_session';
+    const GET_USERS = 'get_users';
+    const GET_COURSE = 'get_courses';
+    const ADD_COURSES_SESSION = 'add_courses_session';
+    const ADD_USER_SESSION = 'add_users_session';
 
     /**
      * @var Session
@@ -275,7 +283,7 @@ class Rest extends WebService
             $results[] = [
                 'id' => $description->get_description_type(),
                 'title' => $description->get_title(),
-                'content' => str_replace('src="/', 'src="'.api_get_path(WEB_PATH), $description->get_content()),
+                'content' => str_replace('src="/', 'src="' . api_get_path(WEB_PATH), $description->get_content()),
             ];
         }
 
@@ -323,7 +331,7 @@ class Rest extends WebService
         $results = [];
 
         if (!empty($documents)) {
-            $webPath = api_get_path(WEB_CODE_PATH).'document/document.php?';
+            $webPath = api_get_path(WEB_CODE_PATH) . 'document/document.php?';
 
             /** @var array $document */
             foreach ($documents as $document) {
@@ -340,17 +348,17 @@ class Rest extends WebService
                     'type' => $document['filetype'],
                     'title' => $document['title'],
                     'path' => $document['path'],
-                    'url' => $webPath.http_build_query([
-                        'username' => $this->user->getUsername(),
-                        'api_key' => $this->apiKey,
-                        'cidReq' => $this->course->getCode(),
-                        'id_session' => $sessionId,
-                        'gidReq' => 0,
-                        'gradebook' => 0,
-                        'origin' => '',
-                        'action' => 'download',
-                        'id' => $document['id'],
-                    ]),
+                    'url' => $webPath . http_build_query([
+                            'username' => $this->user->getUsername(),
+                            'api_key' => $this->apiKey,
+                            'cidReq' => $this->course->getCode(),
+                            'id_session' => $sessionId,
+                            'gidReq' => 0,
+                            'gradebook' => 0,
+                            'origin' => '',
+                            'action' => 'download',
+                            'id' => $document['id'],
+                        ]),
                     'icon' => $icon,
                     'size' => format_file_size($document['size']),
                 ];
@@ -483,7 +491,7 @@ class Rest extends WebService
                 return [
                     'id' => intval($event['unique_id']),
                     'title' => $event['title'],
-                    'content' => str_replace('src="/', 'src="'.$webPath, $event['description']),
+                    'content' => str_replace('src="/', 'src="' . $webPath, $event['description']),
                     'startDate' => $event['start_date_localtime'],
                     'endDate' => $event['end_date_localtime'],
                     'isAllDay' => $event['allDay'] ? true : false,
@@ -531,9 +539,9 @@ class Rest extends WebService
     public function getCourseForumCategories()
     {
         $sessionId = $this->session ? $this->session->getId() : 0;
-        $webCoursePath = api_get_path(WEB_COURSE_PATH).$this->course->getDirectory().'/upload/forum/images/';
+        $webCoursePath = api_get_path(WEB_COURSE_PATH) . $this->course->getDirectory() . '/upload/forum/images/';
 
-        require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
+        require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php';
 
         $categoriesFullData = get_forum_categories('', $this->course->getId(), $sessionId);
         $categories = [];
@@ -547,7 +555,7 @@ class Rest extends WebService
                 'catId' => intval($forumInfo['forum_category']),
                 'title' => $forumInfo['forum_title'],
                 'description' => $forumInfo['forum_comment'],
-                'image' => $forumInfo['forum_image'] ? ($webCoursePath.$forumInfo['forum_image']) : '',
+                'image' => $forumInfo['forum_image'] ? ($webCoursePath . $forumInfo['forum_image']) : '',
                 'numberOfThreads' => isset($forumInfo['number_of_threads']) ? intval($forumInfo['number_of_threads']) : 0,
                 'lastPost' => null,
             ];
@@ -601,7 +609,7 @@ class Rest extends WebService
      */
     public function getCourseForum($forumId)
     {
-        require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
+        require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php';
 
         $sessionId = $this->session ? $this->session->getId() : 0;
         $forumInfo = get_forums($forumId, $this->course->getCode(), true, $sessionId);
@@ -610,12 +618,12 @@ class Rest extends WebService
             throw new Exception(get_lang('NoForum'));
         }
 
-        $webCoursePath = api_get_path(WEB_COURSE_PATH).$this->course->getDirectory().'/upload/forum/images/';
+        $webCoursePath = api_get_path(WEB_COURSE_PATH) . $this->course->getDirectory() . '/upload/forum/images/';
         $forum = [
             'id' => $forumInfo['iid'],
             'title' => $forumInfo['forum_title'],
             'description' => $forumInfo['forum_comment'],
-            'image' => $forumInfo['forum_image'] ? ($webCoursePath.$forumInfo['forum_image']) : '',
+            'image' => $forumInfo['forum_image'] ? ($webCoursePath . $forumInfo['forum_image']) : '',
             'threads' => [],
         ];
 
@@ -643,7 +651,7 @@ class Rest extends WebService
      */
     public function getCourseForumThread($forumId, $threadId)
     {
-        require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
+        require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php';
 
         $sessionId = $this->session ? $this->session->getId() : 0;
         $threadInfo = get_thread_information($forumId, $threadId, $sessionId);
@@ -681,7 +689,9 @@ class Rest extends WebService
         $pictureInfo = UserManager::get_user_picture_path_by_id($this->user->getId(), 'web');
 
         $result = [
-            'pictureUri' => $pictureInfo['dir'].$pictureInfo['file'],
+            'pictureUri' => $pictureInfo['dir'] . $pictureInfo['file'],
+            'id' => $this->user->getId(),
+            'status' => $this->user->getStatus(),
             'fullName' => $this->user->getCompleteName(),
             'username' => $this->user->getUsername(),
             'officialCode' => $this->user->getOfficialCode(),
@@ -791,14 +801,14 @@ class Rest extends WebService
                     'id' => $lpId,
                     'title' => Security::remove_XSS($lpDetails['lp_name']),
                     'progress' => intval($progress),
-                    'url' => api_get_path(WEB_CODE_PATH).'webservices/api/v2.php?'.http_build_query([
-                        'hash' => $this->encodeParams([
-                            'action' => 'course_learnpath',
-                            'lp_id' => $lpId,
-                            'course' => $this->course->getId(),
-                            'session' => $sessionId,
+                    'url' => api_get_path(WEB_CODE_PATH) . 'webservices/api/v2.php?' . http_build_query([
+                            'hash' => $this->encodeParams([
+                                'action' => 'course_learnpath',
+                                'lp_id' => $lpId,
+                                'course' => $this->course->getId(),
+                                'session' => $sessionId,
+                            ]),
                         ]),
-                    ]),
                 ];
             }
 
@@ -843,16 +853,16 @@ class Rest extends WebService
         ChamiloSession::write('_user', $loggedUser);
         Login::init_user($this->user->getId(), true);
 
-        $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.http_build_query([
-            'cidReq' => $this->course->getCode(),
-            'id_session' => $sessionId,
-            'gidReq' => 0,
-            'gradebook' => 0,
-            'origin' => '',
-            'action' => 'view',
-            'lp_id' => intval($lpId),
-            'isStudentView' => 'true',
-        ]);
+        $url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?' . http_build_query([
+                'cidReq' => $this->course->getCode(),
+                'id_session' => $sessionId,
+                'gidReq' => 0,
+                'gradebook' => 0,
+                'origin' => '',
+                'action' => 'view',
+                'lp_id' => intval($lpId),
+                'isStudentView' => 'true',
+            ]);
 
         header("Location: $url");
         exit;
@@ -860,13 +870,13 @@ class Rest extends WebService
 
     /**
      * @param array $postValues
-     * @param int   $forumId
+     * @param int $forumId
      *
      * @return array
      */
     public function saveForumPost(array $postValues, $forumId)
     {
-        require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
+        require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php';
 
         $forum = get_forums($forumId, $this->course->getCode());
         store_reply($forum, $postValues, $this->course->getId(), $this->user->getId());
@@ -933,7 +943,7 @@ class Rest extends WebService
     /**
      * @param string $subject
      * @param string $text
-     * @param array  $receivers
+     * @param array $receivers
      *
      * @return array
      */
@@ -1004,13 +1014,13 @@ class Rest extends WebService
 
     /**
      * @param array $values
-     * @param int   $forumId
+     * @param int $forumId
      *
      * @return array
      */
     public function saveForumThread(array $values, $forumId)
     {
-        require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
+        require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php';
 
         $sessionId = $this->session ? $this->session->getId() : 0;
         $forum = get_forums($forumId, $this->course->getCode(), true, $sessionId);
@@ -1022,6 +1032,96 @@ class Rest extends WebService
         ];
     }
 
+    public function getUsersCampus(array $params){
+        $conditions = [
+            'status' => $params['status'],
+        ];
+        $idCampus = $params['id_campus'];
+        $users = UserManager::get_user_list($conditions, ['firstname'], false, false, $idCampus);
+        $listTemp = [];
+        $list = [];
+        foreach ($users as $item){
+            $listTemp = [
+                'id' => $item['user_id'],
+                'firstname' => $item['firstname'],
+                'lastname' => $item['lastname'],
+                'email' => $item['email']
+            ];
+            $list[] = $listTemp;
+
+        }
+        return $list;
+    }
+
+    public function getCoursesCampus(array $params){
+
+        $idCampus = $params['id_campus'];
+
+        $courseList = CourseManager::get_courses_list(
+            0, //offset
+            0, //howMany
+            1, //$orderby = 1
+            'ASC',
+            -1, //visibility
+            null,
+            $idCampus, //$urlId
+            true //AlsoSearchCode
+        );
+
+
+        return $courseList;
+    }
+
+    public function addSession(array $params){
+
+        $name = $params['name'];
+        $coach_username = intval($params['coach_username']);
+        $startDate = $params['access_start_date'];
+        $endDate = $params['access_end_date'];
+        $displayStartDate = $startDate;
+        $displayEndDate = $endDate;
+        $description = $params['description'];
+        $idUrlCampus = $params['id_campus'];
+
+
+        $return = SessionManager::create_session(
+            $name,
+            $startDate,
+            $endDate,
+            $displayStartDate,
+            $displayEndDate,
+            null,
+            null,
+            $coach_username,
+            null,
+            1,
+            false,
+            null,
+            $description,
+            1,
+            [],
+            null,
+            false,
+            $idUrlCampus
+        );
+
+
+        if($return){
+            $out = [
+                'status' => true,
+                'message' => 'Sesión creada correctamente',
+                'id_session' => $return
+            ];
+        } else {
+            $out = [
+                'status' => false,
+                'message' => 'Error al crear la sesión'
+            ];
+        }
+
+        return $out;
+    }
+
     /**
      * @param array $courseParam
      *
@@ -1032,118 +1132,39 @@ class Rest extends WebService
         $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
         $extraList = [];
         $results = [];
-
+        $idCampus = isset($courseParam['id_campus']) ? $courseParam['id_campus'] : 1;
         $title = isset($courseParam['title']) ? $courseParam['title'] : '';
-        $categoryCode = isset($courseParam['category_code']) ? $courseParam['category_code'] : '';
-        $wantedCode = isset($courseParam['wanted_code']) ? intval($courseParam['wanted_code']) : 0;
-        $tutorName = isset($courseParam['tutor_name']) ? $courseParam['tutor_name'] : '';
-        $courseLanguage = isset($courseParam['language']) ? $courseParam['language'] : null;
-        $originalCourseIdName = isset($courseParam['original_course_id_name'])
-            ? $courseParam['original_course_id_name']
-            : null;
-        $originalCourseIdValue = isset($courseParam['original_course_id_value'])
-            ? $courseParam['original_course_id_value']
-            : null;
+        $wantedCode = isset($courseParam['wanted_code']) ? $courseParam['wanted_code'] : null;
         $diskQuota = isset($courseParam['disk_quota']) ? $courseParam['disk_quota'] : '100';
-        $visibility = isset($courseParam['visibility']) ? (int) $courseParam['visibility'] : null;
+        $visibility = isset($courseParam['visibility']) ? (int)$courseParam['visibility'] : null;
 
         if (isset($courseParam['visibility'])) {
             if ($courseParam['visibility'] &&
                 $courseParam['visibility'] >= 0 &&
                 $courseParam['visibility'] <= 3
             ) {
-                $visibility = (int) $courseParam['visibility'];
+                $visibility = (int)$courseParam['visibility'];
             }
         }
 
-        // Check whether exits $x_course_code into user_field_values table.
-        $courseInfo = CourseManager::getCourseInfoFromOriginalId(
-            $originalCourseIdValue,
-            $originalCourseIdName
-        );
-
-        if (!empty($courseInfo)) {
-            if ($courseInfo['visibility'] != 0) {
-                $sql = "UPDATE $tableCourse SET
-                            course_language = '".Database::escape_string($courseLanguage)."',
-                            title = '".Database::escape_string($title)."',
-                            category_code = '".Database::escape_string($categoryCode)."',
-                            tutor_name = '".Database::escape_string($tutorName)."',
-                            visual_code = '".Database::escape_string($wantedCode)."'";
-                if ($visibility !== null) {
-                    $sql .= ", visibility = $visibility ";
-                }
-                $sql .= " WHERE id = ".$courseInfo['real_id'];
-                Database::query($sql);
-                if (is_array($extraList) && count($extraList) > 0) {
-                    foreach ($extraList as $extra) {
-                        $extraFieldName = $extra['field_name'];
-                        $extraFieldValue = $extra['field_value'];
-                        // Save the external system's id into course_field_value table.
-                        CourseManager::update_course_extra_field_value(
-                            $courseInfo['code'],
-                            $extraFieldName,
-                            $extraFieldValue
-                        );
-                    }
-                }
-                $results[] = $courseInfo['code'];
-            }
-        }
 
         $params = [];
         $params['title'] = $title;
-        $params['wanted_code'] = $wantedCode;
-        $params['category_code'] = $categoryCode;
-        $params['course_category'] = $categoryCode;
-        $params['tutor_name'] = $tutorName;
-        $params['course_language'] = $courseLanguage;
+        $params['wanted_code'] = 'CAMPUS_'.$idCampus.'_'.$wantedCode;
         $params['user_id'] = $this->user->getId();
         $params['visibility'] = $visibility;
         $params['disk_quota'] = $diskQuota;
-        $params['subscribe'] = empty($courseParam['subscribe']) ? 0 : 1;
-        $params['unsubscribe'] = empty($courseParam['unsubscribe']) ? 0 : 1;
 
-        $courseInfo = CourseManager::create_course($params, $params['user_id']);
+        $courseInfo = CourseManager::create_course($params, $params['user_id'],$idCampus);
 
         if (!empty($courseInfo)) {
-            $courseCode = $courseInfo['code'];
-
-            // Save new field label into course_field table
-            CourseManager::create_course_extra_field(
-                $originalCourseIdName,
-                1,
-                $originalCourseIdName,
-                ''
-            );
-
-            // Save the external system's id into user_field_value table.
-            CourseManager::update_course_extra_field_value(
-                $courseCode,
-                $originalCourseIdName,
-                $originalCourseIdValue
-            );
-
-            if (is_array($extraList) && count($extraList) > 0) {
-                foreach ($extraList as $extra) {
-                    $extraFieldName = $extra['field_name'];
-                    $extraFieldValue = $extra['field_value'];
-                    // Save new fieldlabel into course_field table.
-                    CourseManager::create_course_extra_field(
-                        $extraFieldName,
-                        1,
-                        $extraFieldName,
-                        ''
-                    );
-                    // Save the external system's id into course_field_value table.
-                    CourseManager::update_course_extra_field_value(
-                        $courseCode,
-                        $extraFieldName,
-                        $extraFieldValue
-                    );
-                }
-            }
-            $results[] = $courseCode;
+            $results['status'] = true;
+            $results['code_course'] = $courseInfo['code'];
+            $results['title_course'] = $courseInfo['title'];
+            $results['message'] = 'Curso registrado con exito';
+        } else {
+            $results['status'] = false;
+            $results['message'] = 'Error al registrar el curso';
         }
 
         return $results;
@@ -1158,7 +1179,6 @@ class Rest extends WebService
     {
         $results = [];
         $orig_user_id_value = [];
-        $userManager = UserManager::getManager();
         $firstName = $user_param['firstname'];
         $lastName = $user_param['lastname'];
         $status = $user_param['status'];
@@ -1313,4 +1333,148 @@ class Rest extends WebService
 
         return $encoded;
     }
+
+    /**
+     * Add Campus Virtual
+     *
+     * @param  array Params Campus
+     * @return array
+     *
+     */
+
+    public function createCampusURL($params)
+    {
+        $urlCampus = Security::remove_XSS($params['url']);
+        $description = Security::remove_XSS($params['description']);
+
+        $active = isset($params['active']) ? intval($params['active']) : 0;
+        //$url_id = isset($params['id']) ? intval($params['id']) : 0;
+
+        $num = UrlManager::url_exist($urlCampus);
+        if ($num == 0) {
+            // checking url
+            if (substr($urlCampus, strlen($urlCampus) - 1, strlen($urlCampus)) == '/') {
+                $idCampus = UrlManager::add($urlCampus, $description, $active, true);
+            } else {
+                //create
+                $idCampus = UrlManager::add($urlCampus . '/', $description, $active, true);
+            }
+            return [
+                'status' => true,
+                'id_campus' => $idCampus
+            ];
+        }
+
+        return [
+            'status' => false,
+            'id_campus' => 0
+        ];
+    }
+
+    /**
+     * Edit Campus Virtual
+     *
+     * @param  array Params Campus
+     * @return array
+     *
+     */
+
+    public function editCampusURL($params)
+    {
+        $urlCampus = Security::remove_XSS($params['url']);
+        $description = Security::remove_XSS($params['description']);
+
+        $active = isset($params['active']) ? intval($params['active']) : 0;
+        $url_id = isset($params['id']) ? intval($params['id']) : 0;
+
+        if (!empty($url_id)) {
+            //we can't change the status of the url with id=1
+            if ($url_id == 1) {
+                $active = 1;
+            }
+            //checking url
+            if (substr($urlCampus, strlen($urlCampus) - 1, strlen($urlCampus)) == '/') {
+                UrlManager::update($url_id, $urlCampus, $description, $active);
+            } else {
+                UrlManager::update($url_id, $urlCampus . '/', $description, $active);
+            }
+            return [true];
+        }
+
+        return [false];
+    }
+
+    /**
+     * Delete Campus Virtual
+     *
+     * @param  array Params Campus
+     * @return array
+     *
+     */
+
+    public function deleteCampusURL($params)
+    {
+        $url_id = isset($params['id']) ? intval($params['id']) : 0;
+
+        $result = UrlManager::delete($url_id);
+        if ($result) {
+            return [
+                'status' => true,
+                'message' => get_lang('URLDeleted')
+            ];
+
+        } else {
+            return [
+                'status' => false,
+                'message' => get_lang('Error')
+            ];
+        }
+    }
+
+    public function addCoursesSession(array $params){
+        $sessionId = $params['id_session'];
+        $courseList = $params['list_courses'];
+
+        $result = SessionManager::add_courses_to_session(
+            $sessionId,
+            $courseList,
+            true,
+            false
+        );
+
+        if($result){
+            return [
+                'status' => $result,
+                'message' => 'Los cursos fueron añadidos a la sessión'
+            ];
+        } else {
+            return [
+                'status' => $result,
+                'message' => 'Error al añadir cursos a la sessión'
+            ];
+        }
+    }
+
+    public function addUsersSession(array $params){
+        $sessionId = $params['id_session'];
+        $userList = $params['list_users'];
+
+        if (!is_array($userList)) {
+            $userList = [];
+        }
+
+        SessionManager::subscribeUsersToSession(
+            $sessionId,
+            $userList,
+            null,
+            false
+        );
+        
+        return [
+            'status' => true,
+            'message' => 'Error al añadir usuarios a la sessión'
+        ];
+
+    }
 }
+

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

@@ -4,7 +4,7 @@
         $(document).ready(function () {
             $.get('{{ _p.web_main }}inc/ajax/message.ajax.php?a=get_count_message', function(data) {
                 var countNotifications = (data.ms_friends + data.ms_groups + data.ms_inbox);
-                if (countNotifications === 0 ) {
+                if (countNotifications === 0 || isNaN(countNotifications)) {
                     $("#count_message_li").addClass('hidden');
                 } else {
                     $("#count_message_li").removeClass('hidden');

+ 2 - 2
main/template/default/learnpath/list.tpl

@@ -393,8 +393,8 @@
                                 </a>
                             </h4>
                         </div>
-
-                        <div id="collapse-{{ lp_data.category.getId() }}" class="panel-collapse collapse {{ (categories|length > 1 ? 'in':'') }}"
+                        {% set number = number + 1 %}
+                        <div id="collapse-{{ lp_data.category.getId() }}" class="panel-collapse collapse {{ (number == 1 ? 'in':'') }}"
                              role="tabpanel" aria-labelledby="heading-{{ lp_data.category.getId() }}">
                             <div class="panel-body">
                                 {% if lp_data.lp_list %}

+ 4 - 4
main/template/default/learnpath/view.tpl

@@ -10,12 +10,12 @@
                                 {{ lp_preview_image }}
                             </div>
                         {% else %}
-                            <div class="media">
-                                <div class="media-left">
+                            <div class="media-author">
+                                <div class="media-author-avatar">
                                     {{ lp_preview_image }}
                                 </div>
-                                <div class="media-body">
-                                    <div class="description-autor"> {{ lp_author }} </div>
+                                <div class="media-author-description">
+                                    {{ lp_author }}
                                 </div>
                             </div>
                         {% endif %}

+ 32 - 0
main/webservices/api/v2.php

@@ -131,6 +131,38 @@ try {
             $data = $restApi->subscribeUserToCourse($_POST);
             $restResponse->setData($data);
             break;
+        case Rest::CREATE_CAMPUS;
+            $data = $restApi->createCampusURL($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::EDIT_CAMPUS;
+            $data = $restApi->editCampusURL($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::DELETE_CAMPUS;
+            $data = $restApi->deleteCampusURL($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::SAVE_SESSION;
+            $data = $restApi->addSession($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::GET_USERS;
+            $data = $restApi->getUsersCampus($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::GET_COURSE;
+            $data = $restApi->getCoursesCampus($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::ADD_COURSES_SESSION;
+            $data = $restApi->addCoursesSession($_POST);
+            $restResponse->setData($data);
+            break;
+        case Rest::ADD_USER_SESSION;
+            $data = $restApi->addUsersSession($_POST);
+            $restResponse->setData($data);
+            break;
         case Rest::SAVE_FORUM_POST:
             if (
                 empty($_POST['title']) || empty($_POST['text']) || empty($_POST['thread']) || empty($_POST['forum'])