Browse Source

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

Angel Fernando Quiroz Campos 8 years ago
parent
commit
738ca356de

+ 0 - 5
.scrutinizer.yml

@@ -11,11 +11,6 @@ build:
                 'phar.readonly': false
         hosts:
             my.chamilodev.net: '127.0.0.1'
-    dependencies:
-        override:
-            - true
-        before:
-            - php -d memory_limit=2G /usr/bin/composer.phar -v update
 filter:
     excluded_paths:
       - 'app/cache/*'

+ 4 - 1
.travis.yml

@@ -15,6 +15,10 @@ services:
 sudo: required
 dist: trusty
 
+cache:
+  directories:
+    - $HOME/.composer/cache/files
+
 php:
   #- 5.4 // Removed because of Chash dependencies on PHP 5.5
   - 5.5
@@ -56,7 +60,6 @@ before_install:
   - php -v
   - sudo cat /etc/hosts
 
-  - composer update
   - phpenv config-add tests/travis/php-config.ini
 
   # Install Chash, a database, and then install Chamilo

+ 1 - 1
main/admin/access_url_add_usergroup_to_url.php

@@ -87,7 +87,7 @@ $db_urls = Database::store_result($result);
                   <?php
                     echo Display::get_alphabet_options($firstLetterUserGroup);
                     echo Display::get_numeric_options(0, 9, $firstLetterUserGroup);
-                  ?>
+                    ?>
             </select>
         </td>
         <td width="20%">&nbsp;</td>

+ 7 - 7
main/blog/download.php

@@ -30,18 +30,18 @@ $doc_url = str_replace(' ', '+', $doc_url);
 $doc_url = str_replace('/..', '', $doc_url); //echo $doc_url;
 
 if (! isset($_course)) {
-	api_not_allowed(true);
+    api_not_allowed(true);
 }
 $full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/blog/'.$doc_url;
 
 //if the rewrite rule asks for a directory, we redirect to the course view
 if (is_dir($full_file_name)) {
-	//remove last slash if present
-	while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul);
-	//create the path
-	$document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path
-	//redirect
-	header('Location: '.$document_explorer);
+    //remove last slash if present
+    while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul);
+    //create the path
+    $document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path
+    //redirect
+    header('Location: '.$document_explorer);
     exit;
 }
 

+ 16 - 16
main/cron/document/index_all_docs.php

@@ -8,9 +8,9 @@
 die();
 require '../../inc/global.inc.php';
 if (empty($_GET['doc'])) {
-  echo "To add a document name to search, add ?doc=abc to the URL\n";
+    echo "To add a document name to search, add ?doc=abc to the URL\n";
 } else {
-  echo "Received param ".$_GET['doc']."<br />\n";
+    echo "Received param ".$_GET['doc']."<br />\n";
 }
 $allowed_mime_types = DocumentManager::file_get_mime_type(true);
 $allowed_extensions = array(
@@ -40,30 +40,30 @@ require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
 $specific_fields = get_specific_field_list();
 $specific_fields_values = array();
 foreach ($specific_fields as $sf) {
-	$specific_fields_values[$sf['code']] = '';
+    $specific_fields_values[$sf['code']] = '';
 }
 $td = Database::get_course_table(TABLE_DOCUMENT);
 
 foreach ($courses_list as $course) {
-  $course_dir = $course['directory'].'/document';
-  $title = Database::escape_string($_GET['doc']);
-  $sql = "SELECT id, path, session_id FROM $td WHERE c_id = ".$course['id']." AND path LIKE '%$title%' or title LIKE '%$title%'";
-  $res = Database::query($sql);
-  if (Database::num_rows($res)>0) {
+    $course_dir = $course['directory'].'/document';
+    $title = Database::escape_string($_GET['doc']);
+    $sql = "SELECT id, path, session_id FROM $td WHERE c_id = ".$course['id']." AND path LIKE '%$title%' or title LIKE '%$title%'";
+    $res = Database::query($sql);
+    if (Database::num_rows($res)>0) {
     while ($row = Database::fetch_array($res)) {
-      $doc_path = api_get_path(SYS_COURSE_PATH).$course_dir.$row['path'];
-      $extensions = preg_split("/[\/\\.]/", $doc_path);
-      $doc_ext = strtolower($extensions[count($extensions) - 1]);
-      if (in_array($doc_ext, $allowed_extensions) && !is_dir($doc_path)) {
+        $doc_path = api_get_path(SYS_COURSE_PATH).$course_dir.$row['path'];
+        $extensions = preg_split("/[\/\\.]/", $doc_path);
+        $doc_ext = strtolower($extensions[count($extensions) - 1]);
+        if (in_array($doc_ext, $allowed_extensions) && !is_dir($doc_path)) {
         $doc_mime = mime_content_type($doc_path);
         echo "Indexing doc ".$row['id']." (".$row['path'].") in course ".$course['code']."\n";
         $residx = DocumentManager::index_document($row['id'], $course['code'], $row['session_id'], $course['course_language'], $specific_fields_values);
         if ($residx) {
-        	echo "Success\n";
+            echo "Success\n";
         } else {
-        	echo "Failure\n";
+            echo "Failure\n";
         }
-      }
+        }
+    }
     }
-  }
 }

+ 7 - 7
main/document/exit_pixlr.php

@@ -24,12 +24,12 @@ unset($_SESSION['whereami']);
 unset($_SESSION['temp_realpath_image']);
 
 if (!isset($_SESSION['exit_pixlr'])){
-	$location=api_get_path(WEB_CODE_PATH).'document/document.php';
-	echo '<script>window.parent.location.href="'.$location.'"</script>';
-	api_not_allowed(true);
+    $location=api_get_path(WEB_CODE_PATH).'document/document.php';
+    echo '<script>window.parent.location.href="'.$location.'"</script>';
+    api_not_allowed(true);
 } else {
-	echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>';
-	$location=api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']);
-	echo '<script>window.parent.location.href="'.$location.'"</script>';
-	unset($_SESSION['exit_pixlr']);
+    echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>';
+    $location=api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']);
+    echo '<script>window.parent.location.href="'.$location.'"</script>';
+    unset($_SESSION['exit_pixlr']);
 }

+ 12 - 12
main/document/slideshowoptions.php

@@ -77,7 +77,7 @@ Display::toolbarAction('toolbar-slideshow', $content)
                     if ($image_resizing == 'noresizing' || $image_resizing == '') {
                             echo ' checked';
                     }
-		?>>
+        ?>>
             </label>
             <?php echo '<b>'. get_lang('NoResizing') . '</b>, ' . get_lang('NoResizingComment') ;?>
         </div>
@@ -87,7 +87,7 @@ Display::toolbarAction('toolbar-slideshow', $content)
                         if ($image_resizing == 'resizing_auto' || $image_resizing == '') {
                                 echo ' checked';
                         }
-		?>>
+        ?>>
             </label>
             <?php echo '<b>'. get_lang('ResizingAuto') . '</b>, ' . get_lang('ResizingAutoComment');?>
 	</div>
@@ -99,7 +99,7 @@ Display::toolbarAction('toolbar-slideshow', $content)
                             $width = $_SESSION['image_resizing_width'];
                             $height = $_SESSION['image_resizing_height'];
                     }
-		?>>
+        ?>>
             </label>
             <?php echo '<b>'. get_lang('Resizing') . '</b>, ' . get_lang('ResizingComment'); ?>
 	</div>
@@ -107,13 +107,13 @@ Display::toolbarAction('toolbar-slideshow', $content)
             <label class="col-sm-1 control-label"><?php echo get_lang('Width'); ?></label>
             <div class="col-sm-3">
                 <input class="form-control" name="width" type="text" id="width" <?php
-		if ($image_resizing == 'resizing') {
-			echo ' value="'.$width.'"';
-			echo ' class="enabled_input"';
+        if ($image_resizing == 'resizing') {
+            echo ' value="'.$width.'"';
+            echo ' class="enabled_input"';
                     } else {
                     echo ' class="disabled_input"';
                 }
-		?> >
+        ?> >
             </div>
             <div class="col-sm-8"></div>
         </div>
@@ -121,13 +121,13 @@ Display::toolbarAction('toolbar-slideshow', $content)
             <label class="col-sm-1 control-label"><?php echo get_lang('Height'); ?></label>
             <div class="col-sm-3">
                 <input class="form-control" name="height" type="text" id="height" <?php
-		if ($image_resizing == 'resizing') {
-			echo ' value="'.$height.'"';
-			echo ' class="enabled_input"';
-		} else {
+        if ($image_resizing == 'resizing') {
+            echo ' value="'.$height.'"';
+            echo ' class="enabled_input"';
+        } else {
                         echo ' class="disabled_input"';
                 }
-		?> >
+        ?> >
             </div>
             <div class="col-sm-8"></div>
         </div>

+ 1 - 1
main/dropbox/dropbox_download.php

@@ -86,7 +86,7 @@ if (!$allowed_to_download) {
             'error'
         )
     );
-	exit;
+    exit;
 } else {
     /*      DOWNLOAD THE FILE */
     // the user is allowed to download the file

+ 4 - 4
main/dropbox/dropbox_functions.inc.php

@@ -84,11 +84,11 @@ function handle_multiple_actions()
     if (strstr($_POST['action'], 'move_')) {
         // check move_received_n or move_sent_n command
         if (strstr($_POST['action'], 'received')) {
-              $part = 'received';
-              $to_cat_id = str_replace('move_received_', '', $_POST['action']);
+                $part = 'received';
+                $to_cat_id = str_replace('move_received_', '', $_POST['action']);
         } else {
-              $part = 'sent';
-              $to_cat_id = str_replace('move_sent_', '', $_POST['action']);
+                $part = 'sent';
+                $to_cat_id = str_replace('move_sent_', '', $_POST['action']);
         }
 
         foreach ($checked_file_ids as $value) {

+ 1 - 1
main/gradebook/lib/fe/displaygradebook.php

@@ -364,7 +364,7 @@ class DisplayGradebook
                     $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
                 }
                 if ($show_add_link && !$message_resource) {
-                   $actionsLeft .= '<a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' .
+                    $actionsLeft .= '<a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' .
                         Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM) . '</a>';
                     $cats = Category :: load($selectcat);
 

+ 1 - 1
main/group/settings.php

@@ -3,7 +3,7 @@
 
 /**
  *	This script displays an area where teachers can edit the group properties and member list.
-  *
+ *
  *	@author various contributors
  *	@author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
  *	@package chamilo.group

+ 29 - 14
main/inc/lib/course.lib.php

@@ -2685,41 +2685,50 @@ class CourseManager
      * @return array    List of codes and db name
      * @author isaac flores paz
      */
-    public static function get_courses_list_by_user_id($user_id, $include_sessions = false, $adminGetsAllCourses = false)
-    {
+    public static function get_courses_list_by_user_id(
+        $user_id,
+        $include_sessions = false,
+        $adminGetsAllCourses = false
+    ) {
         $user_id = intval($user_id);
+        $urlId = api_get_current_access_url_id();
         $course_list = array();
         $codes = array();
+
         $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
         $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
         $tbl_user_course_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
+        $tableCourseUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $special_course_list = self::get_special_course_list();
-
         if ($adminGetsAllCourses && UserManager::is_admin($user_id)) {
             // get the whole courses list
             $sql = "SELECT DISTINCT(course.code), course.id as real_id
-                    FROM $tbl_course course";
+                    FROM $tbl_course course 
+                    INNER JOIN $tableCourseUrl url 
+                    ON (course.id = url.c_id)
+                    WHERE url.access_url_id = $urlId      
+                ";
         } else {
             $with_special_courses = $without_special_courses = '';
             if (!empty($special_course_list)) {
                 $sc_string = '"' . implode('","', $special_course_list) . '"';
-                $with_special_courses = ' course.id IN (' . $sc_string . ')';
+                $with_special_courses = ' AND course.id IN (' . $sc_string . ')';
                 $without_special_courses = ' AND course.id NOT IN (' . $sc_string . ')';
             }
 
             if (!empty($with_special_courses)) {
                 $sql = "SELECT DISTINCT(course.code), course.id as real_id
-                        FROM $tbl_course_user  course_rel_user
-                        LEFT JOIN $tbl_course  course
+                        FROM $tbl_course_user course_rel_user
+                        LEFT JOIN $tbl_course course
                         ON course.id = course_rel_user.c_id
                         LEFT JOIN $tbl_user_course_category user_course_category
                         ON course_rel_user.user_course_cat = user_course_category.id
-                        WHERE  $with_special_courses
+                        INNER JOIN $tableCourseUrl url 
+                        ON (course.id = url.c_id)  
+                        WHERE url.access_url_id = $urlId $with_special_courses                        
                         GROUP BY course.code
                         ORDER BY user_course_category.sort, course.title, course_rel_user.sort ASC
-
-                    ";
-                //
+                ";
                 $rs_special_course = Database::query($sql);
                 if (Database::num_rows($rs_special_course) > 0) {
                     while ($result_row = Database::fetch_array($rs_special_course)) {
@@ -2734,8 +2743,14 @@ class CourseManager
             // entries when a course is assigned to a HRD (DRH) as watcher
             $sql = "SELECT DISTINCT(course.code), course.id as real_id
                     FROM $tbl_course course
-                    INNER JOIN $tbl_course_user cru ON course.id = cru.c_id
-                    WHERE cru.user_id='$user_id' $without_special_courses";
+                    INNER JOIN $tbl_course_user cru 
+                    ON (course.id = cru.c_id)
+                    INNER JOIN $tableCourseUrl url 
+                    ON (course.id = url.c_id) 
+                    WHERE 
+                        url.access_url_id = $urlId AND 
+                        cru.user_id = '$user_id' 
+                        $without_special_courses";
         }
         $result = Database::query($sql);
 
@@ -2749,7 +2764,7 @@ class CourseManager
         if ($include_sessions === true) {
             $sql = "SELECT DISTINCT(c.code), c.id as real_id
                     FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " s,
-                    " . Database::get_main_table(TABLE_MAIN_COURSE) . " c
+                    $tbl_course c
                     WHERE user_id = $user_id AND s.c_id = c.id";
             $r = Database::query($sql);
             while ($row = Database::fetch_array($r, 'ASSOC')) {

+ 8 - 8
main/template/default/auth/courses_list.php

@@ -29,11 +29,11 @@ if (!empty($message)) {
 
 // COURSES WITH CATEGORIES
 if (!empty($user_course_categories)) {
-       foreach ($user_course_categories as $row) {
-           echo Display::page_subheader($row['title']);
-           echo '<a name="category'.$row['id'].'"></a>';
+        foreach ($user_course_categories as $row) {
+            echo Display::page_subheader($row['title']);
+            echo '<a name="category'.$row['id'].'"></a>';
 
-           if (isset($_GET['categoryid']) && $_GET['categoryid'] == $row['id']) { ?>
+            if (isset($_GET['categoryid']) && $_GET['categoryid'] == $row['id']) { ?>
             <!-- We display the edit form for the category -->
 
             <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
@@ -241,15 +241,15 @@ if (!empty($courses_without_category)) {
                     </a>
             <?php } else {
                     echo Display::display_icon('up_na.png', get_lang('Up'),'',22);
-                  }
+                    }
 
-                  if ($key < $number_of_courses - 1) { ?>
+                    if ($key < $number_of_courses - 1) { ?>
                     <a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
                     <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?>
                     </a>
             <?php } else {
                     echo Display::display_icon('down_na.png', get_lang('Down'),'',22);
-                  }?>
+                    }?>
                 </div>
                  <div style="float:left; margin-right:10px;">
                   <!-- cancel subscrioption-->
@@ -267,7 +267,7 @@ if (!empty($courses_without_category)) {
                     </div>
               <?php }
                 }
-              ?>
+                ?>
             </td>
             </tr>
             <?php