Bladeren bron

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

Yannick Warnier 8 jaren geleden
bovenliggende
commit
2af1955e35
40 gewijzigde bestanden met toevoegingen van 670 en 596 verwijderingen
  1. 2 5
      app/Resources/public/css/base.css
  2. 2 2
      main/admin/skill_create.php
  3. 6 6
      main/course_progress/thematic_advance.php
  4. 4 4
      main/coursecopy/copy_course_session.php
  5. 1 1
      main/document/document.php
  6. 5 5
      main/document/downloadfolder.inc.php
  7. 8 16
      main/exercise/Annotation.php
  8. 5 9
      main/exercise/hotspot.class.php
  9. 144 119
      main/exercise/question.class.php
  10. 123 142
      main/inc/lib/TicketManager.php
  11. 3 1
      main/inc/lib/api.lib.php
  12. 6 0
      main/inc/lib/blog.lib.php
  13. 8 2
      main/inc/lib/course.lib.php
  14. 11 12
      main/inc/lib/display.lib.php
  15. 8 2
      main/inc/lib/fileManage.lib.php
  16. 18 18
      main/inc/lib/glossary.lib.php
  17. 1 0
      main/inc/lib/model.lib.php
  18. 13 13
      main/inc/lib/skill.visualizer.lib.php
  19. 6 0
      main/inc/lib/usermanager.lib.php
  20. 14 14
      main/session/add_courses_to_session.php
  21. 39 39
      main/ticket/tickets.php
  22. 8 6
      src/Chamilo/CourseBundle/Component/CourseCopy/Course.php
  23. 8 13
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php
  24. 24 21
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php
  25. 3 4
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Announcement.php
  26. 11 11
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CalendarEvent.php
  27. 111 112
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyLearnpath.php
  28. 1 1
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyTestCategory.php
  29. 0 1
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Forum.php
  30. 8 0
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/QuizQuestion.php
  31. 1 1
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/ScormDocument.php
  32. 1 1
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Survey.php
  33. 1 1
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/SurveyInvitation.php
  34. 6 6
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/SurveyQuestion.php
  35. 1 2
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/ToolIntro.php
  36. 1 1
      src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Wiki.php
  37. 1 1
      src/Chamilo/CourseBundle/Entity/CToolIntro.php
  38. 17 4
      tests/behat/features/bootstrap/FeatureContext.php
  39. 20 0
      tests/behat/features/profile.feature
  40. 20 0
      tests/behat/features/registration.feature

+ 2 - 5
app/Resources/public/css/base.css

@@ -4792,15 +4792,12 @@ div#chat-remote-video video {
     box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05);
     text-align: left;
     background-color: #fff;
-    min-height: 250px;
+    min-height: 244px;
     border: 1px solid #DFDFDF;
     border-radius: 5px;
     margin-bottom: 20px;
 }
-.grid-courses .items.items-courses,
-.grid-courses .items.items-hotcourse{
-    min-height: 300px;
-}
+
 .grid-courses .items .title{
     line-height: 1.4;
     padding: 0px;

+ 2 - 2
main/admin/skill_create.php

@@ -92,7 +92,7 @@ $jquery_ready_content = $returnParams['jquery_ready_content'];
 if (!empty($jquery_ready_content)) {
     $htmlHeadXtra[] = '<script>
     $(document).ready(function(){
-        ' . $jquery_ready_content . '
+        ' . $jquery_ready_content.'
     });
     </script>';
 }
@@ -122,7 +122,7 @@ if ($createForm->validate()) {
         );
     }
 
-    header('Location: '.api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php');
+    header('Location: '.api_get_path(WEB_CODE_PATH).'admin/skill_list.php');
     exit;
 }
 

+ 6 - 6
main/course_progress/thematic_advance.php

@@ -22,7 +22,7 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
     $form = new FormValidator(
         'thematic_advance',
         'POST',
-        api_get_self() . '?' . api_get_cidreq()
+        api_get_self().'?'.api_get_cidreq()
     );
     $form->addElement('header', $header_form);
     //$form->addElement('hidden', 'thematic_advance_token',$token);
@@ -191,7 +191,7 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
 
         $thematic = new Thematic();
         $thematic->set_thematic_advance_attributes(
-            isset($values['thematic_advance_id']) ? $values['thematic_advance_id']: null,
+            isset($values['thematic_advance_id']) ? $values['thematic_advance_id'] : null,
             $values['thematic_id'],
             $values['start_date_type'] == 1 && isset($values['attendance_select']) ? $values['attendance_select'] : 0,
             $values['content'],
@@ -210,13 +210,13 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
             }
         }
 
-        $redirectUrlParams = 'course_progress/index.php?' .  api_get_cidreq() . '&' .
+        $redirectUrlParams = 'course_progress/index.php?'.api_get_cidreq().'&'.
             http_build_query([
                 'action' => 'thematic_advance_list',
                 'thematic_id' => $values['thematic_id']
             ]);
 
-        header('Location: ' . api_get_path(WEB_CODE_PATH) . $redirectUrlParams);
+        header('Location: '.api_get_path(WEB_CODE_PATH).$redirectUrlParams);
         exit;
     }
 
@@ -226,10 +226,10 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
     // thematic advance list
     echo '<div class="actions">';
     echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=thematic_details">'.
-            Display::return_icon('back.png', get_lang("BackTo"),'',ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('back.png', get_lang("BackTo"), '', ICON_SIZE_MEDIUM).'</a>';
     if (api_is_allowed_to_edit(false, true)) {
         echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=thematic_advance_add&amp;thematic_id='.$thematic_id.'"> '.
-            Display::return_icon('add.png', get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('add.png', get_lang('NewThematicAdvance'), '', ICON_SIZE_MEDIUM).'</a>';
     }
     echo '</div>';
     $table = new SortableTable(

+ 4 - 4
main/coursecopy/copy_course_session.php

@@ -85,7 +85,7 @@ function make_select_session_list($name, $sessions, $attr = array())
 
 function display_form()
 {
-    $html  = '';
+    $html = '';
     $sessions = SessionManager::get_sessions_list(array(), array('name', 'ASC'));
 
     // Link back to the documents overview
@@ -109,7 +109,7 @@ function display_form()
 
     //destination
     $html .= '<div class="form-group">';
-    $html .= '<label class="col-sm-2 control-label">' . get_lang('DestinationCoursesFromSession') . ': </label>';
+    $html .= '<label class="col-sm-2 control-label">'.get_lang('DestinationCoursesFromSession').': </label>';
     $html .= '<div class="col-sm-5" id="ajax_sessions_list_destination">';
     $html .= '<select class="form-control" name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">';
     $html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div>';
@@ -131,7 +131,7 @@ function display_form()
     $html .= '<button class="btn btn-success" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><em class="fa fa-files-o"></em> '.get_lang('CopyCourse').'</button>';
 
     // Add Security token
-    $html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">';
+    $html .= '<input type="hidden" value="'.Security::get_token().'" name="sec_token">';
     $html .= '</div></div>';
     $html .= '</form>';
 
@@ -227,7 +227,7 @@ $xajax->processRequests();
 
 /* HTML head extra */
 
-$htmlHeadXtra[] = $xajax->getJavascript( api_get_path(WEB_LIBRARY_PATH).'xajax/');
+$htmlHeadXtra[] = $xajax->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax/');
 $htmlHeadXtra[] = '<script>
 function checkSelected(id_select,id_radio,id_title,id_destination) {
    var num=0;

+ 1 - 1
main/document/document.php

@@ -1971,7 +1971,7 @@ if (isset($_GET['createdir']) && isset($_POST['dirname']) && $_POST['dirname'] !
     $document_id = DocumentManager::get_document_id($courseInfo, $_POST['dirname']);
 }
 $selector = '';
-if (!$is_certificate_mode) {
+if (!$is_certificate_mode && !isset($_GET['move'])) {
     $selector = DocumentManager::build_directory_selector(
         $folders,
         $document_id,

+ 5 - 5
main/document/downloadfolder.inc.php

@@ -52,7 +52,7 @@ if (empty($path)) {
 
 // A student should not be able to download a root shared directory
 if (($path == '/shared_folder' ||
-    $path == '/shared_folder_session_' . api_get_session_id()) &&
+    $path == '/shared_folder_session_'.api_get_session_id()) &&
     (!api_is_allowed_to_edit() || !api_is_platform_admin())
 ) {
     api_not_allowed(true);
@@ -150,7 +150,7 @@ if (api_is_allowed_to_edit()) {
                 (props.session_id IN ('0', '$sessionId') OR props.session_id IS NULL) AND
                 docs.c_id = ".$courseId." ";
 
-    $sql.= DocumentManager::getSessionFolderFilters($querypath, $sessionId);
+    $sql .= DocumentManager::getSessionFolderFilters($querypath, $sessionId);
 
     $result = Database::query($sql);
 
@@ -215,7 +215,7 @@ if (api_is_allowed_to_edit()) {
                 $groupCondition
             ";
 
-    $sql.= DocumentManager::getSessionFolderFilters($querypath, $sessionId);
+    $sql .= DocumentManager::getSessionFolderFilters($querypath, $sessionId);
     $result = Database::query($sql);
 
     $files = array();
@@ -296,9 +296,9 @@ if (api_is_allowed_to_edit()) {
     // Add all files in our final array to the zipfile
     for ($i = 0; $i < count($files_for_zipfile); $i++) {
         $zip->add(
-            $sysCoursePath . $courseInfo['path'] . '/document' . $files_for_zipfile[$i],
+            $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i],
             PCLZIP_OPT_REMOVE_PATH,
-            $sysCoursePath . $courseInfo['path'] . '/document' . $remove_dir,
+            $sysCoursePath.$courseInfo['path'].'/document'.$remove_dir,
             PCLZIP_CB_PRE_ADD,
             'fixDocumentNameCallback'
         );

+ 8 - 16
main/exercise/Annotation.php

@@ -69,32 +69,24 @@ class Annotation extends Question
     /**
      * @param FormValidator $form
      * @param null $objExercise
-     * @return null|false
+     * @return bool
      */
     public function processCreation($form, $objExercise = null)
     {
         $fileInfo = $form->getSubmitValue('imageUpload');
-        $courseInfo = api_get_course_info();
-
         parent::processCreation($form, $objExercise);
 
         if (!empty($fileInfo['tmp_name'])) {
-            $this->uploadPicture($fileInfo['tmp_name'], $fileInfo['name']);
-
-            $documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document';
-            $picturePath = $documentPath.'/images';
-
-            // fixed width ang height
-            if (!file_exists($picturePath.'/'.$this->picture)) {
-                return false;
+            $result = $this->uploadPicture($fileInfo['tmp_name']);
+            if ($result) {
+                $this->weighting = $form->getSubmitValue('weighting');
+                $this->save();
+                return true;
             }
 
-            $this->resizePicture('width', 800);
-            $this->weighting = $form->getSubmitValue('weighting');
-            $this->save();
-
-            return true;
+            return false;
         }
+        return false;
     }
 
     /**

+ 5 - 9
main/exercise/hotspot.class.php

@@ -76,27 +76,23 @@ class HotSpot extends Question
     /**
      * @param FormValidator $form
      * @param null $objExercise
-     * @return null|false
+     * @return bool
      */
     public function processCreation($form, $objExercise = null)
     {
         $file_info = $form->getSubmitValue('imageUpload');
-        $_course = api_get_course_info();
         parent::processCreation($form, $objExercise);
 
         if (!empty($file_info['tmp_name'])) {
-            $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
-            $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-            $picturePath = $documentPath.'/images';
-
-            // fixed width ang height
-            if (file_exists($picturePath.'/'.$this->getPictureFilename())) {
-                $this->resizePicture('width', 800);
+            $result = $this->uploadPicture($file_info['tmp_name']);
+            if ($result) {
                 $this->save();
+                return true;
             } else {
                 return false;
             }
         }
+        return false;
     }
 
     function createAnswersForm($form)

+ 144 - 119
main/exercise/question.class.php

@@ -22,7 +22,7 @@ abstract class Question
     public $type;
     public $level;
     public $picture;
-    public $exerciseList;  // array with the list of exercises which this question is in
+    public $exerciseList; // array with the list of exercises which this question is in
     public $category_list;
     public $parent_id;
     public $category;
@@ -47,8 +47,8 @@ abstract class Question
             'multiple_answer_combination_true_false.class.php',
             'MultipleAnswerCombinationTrueFalse'
         ),
-        GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
-        CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'),
+        GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php', 'GlobalMultipleAnswer'),
+        CALCULATED_ANSWER => array('calculated_answer.class.php', 'CalculatedAnswer'),
         UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'],
         DRAGGABLE => ['Draggable.php', 'Draggable'],
         MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable'],
@@ -108,7 +108,7 @@ abstract class Question
         $id = intval($id);
 
         if (!empty($course_id)) {
-            $course_info =  api_get_course_info_by_id($course_id);
+            $course_info = api_get_course_info_by_id($course_id);
         } else {
             $course_info = api_get_course_info();
         }
@@ -266,7 +266,7 @@ abstract class Question
     public function selectPicturePath()
     {
         if (!empty($this->picture)) {
-            return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->getPictureFilename();
+            return api_get_path(WEB_COURSE_PATH).$this->course['directory'].'/document/images/'.$this->getPictureFilename();
         }
 
         return '';
@@ -360,7 +360,7 @@ abstract class Question
      */
     public function updateTitle($title)
     {
-        $this->question=$title;
+        $this->question = $title;
     }
 
     /**
@@ -459,7 +459,7 @@ abstract class Question
                     // DO nothing
                 } else {
                     $sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id)
-                            VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)";
+                            VALUES (".api_get_course_int_id().", $question_id, $category_id)";
                     Database::query($sql);
                 }
             }
@@ -485,7 +485,7 @@ abstract class Question
             $sql = "SELECT count(*) AS nb FROM $table
                     WHERE
                         question_id = $question_id AND
-                        c_id=" . api_get_course_int_id();
+                        c_id=".api_get_course_int_id();
             $res = Database::query($sql);
             $row = Database::fetch_array($res);
             if ($row['nb'] > 0) {
@@ -493,11 +493,11 @@ abstract class Question
                         SET category_id = $category_id
                         WHERE
                             question_id = $question_id AND
-                            c_id = " . api_get_course_int_id();
+                            c_id = ".api_get_course_int_id();
                 Database::query($sql);
             } else {
                 $sql = "INSERT INTO $table (c_id, question_id, category_id)
-                        VALUES (" . api_get_course_int_id().", $question_id, $category_id)";
+                        VALUES (".api_get_course_int_id().", $question_id, $category_id)";
                 Database::query($sql);
             }
         }
@@ -515,7 +515,7 @@ abstract class Question
         $sql = "DELETE FROM $table
                 WHERE
                     question_id = $question_id AND
-                    c_id = " . api_get_course_int_id();
+                    c_id = ".api_get_course_int_id();
         Database::query($sql);
     }
 
@@ -568,58 +568,61 @@ abstract class Question
             ) {
                 // removes old answers
                 $sql = "DELETE FROM $TBL_REPONSES
-                        WHERE c_id = $course_id AND question_id = " . intval($this->id);
+                        WHERE c_id = $course_id AND question_id = ".intval($this->id);
                 Database::query($sql);
             }
 
-            $this->type=$type;
+            $this->type = $type;
+        }
+    }
+
+    /**
+     * Get default hot spot folder in documents
+     * @return string
+     */
+    public function getHotSpotFolderInCourse()
+    {
+        if (empty($this->course) || empty($this->course['directory'])) {
+            // Stop everything if course is not set.
+            api_not_allowed();
+        }
+
+        $pictureAbsolutePath = api_get_path(SYS_COURSE_PATH).$this->course['directory'].'/document/images/';
+        $picturePath = basename($pictureAbsolutePath);
+
+        if (!is_dir($picturePath)) {
+            create_unexisting_directory(
+                $this->course,
+                api_get_user_id(),
+                0,
+                0,
+                0,
+                dirname($pictureAbsolutePath),
+                '/'.$picturePath,
+                $picturePath
+            );
         }
+
+        return $pictureAbsolutePath;
     }
 
     /**
      * adds a picture to the question
      *
-     * @param string $Picture - temporary path of the picture to upload
-     * @param string $PictureName - Name of the picture
-     * @param string $picturePath
+     * @param string $picture - temporary path of the picture to upload
      *
      * @return boolean - true if uploaded, otherwise false
      *
      * @author Olivier Brouckaert
      */
-    public function uploadPicture($Picture, $PictureName, $picturePath = null)
+    public function uploadPicture($picture)
     {
-        if (empty($picturePath)) {
-            global $picturePath;
-        }
-
-        if (!file_exists($picturePath)) {
-            if (mkdir($picturePath, api_get_permissions_for_new_directories())) {
-                // document path
-                $documentPath = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document';
-                $path = str_replace($documentPath, '', $picturePath);
-                $title_path = basename($picturePath);
-                $doc_id = add_document(
-                    $this->course,
-                    $path,
-                    'folder',
-                    0,
-                    $title_path
-                );
-                api_item_property_update(
-                    $this->course,
-                    TOOL_DOCUMENT,
-                    $doc_id,
-                    'FolderCreated',
-                    api_get_user_id()
-                );
-            }
-        }
+        $picturePath = $this->getHotSpotFolderInCourse();
 
         // if the question has got an ID
         if ($this->id) {
             $pictureFilename = self::generatePictureName();
-            $img = new Image($Picture);
+            $img = new Image($picture);
             $img->send_image($picturePath.'/'.$pictureFilename, -1, 'jpg');
             $document_id = add_document(
                 $this->course,
@@ -628,16 +631,25 @@ abstract class Question
                 filesize($picturePath.'/'.$pictureFilename),
                 $pictureFilename
             );
-            $this->picture = $document_id;
 
             if ($document_id) {
-                return api_item_property_update(
+                $this->picture = $document_id;
+
+                if (!file_exists($picturePath.'/'.$pictureFilename)) {
+                    return false;
+                }
+
+                api_item_property_update(
                     $this->course,
                     TOOL_DOCUMENT,
                     $document_id,
                     'DocumentAdded',
                     api_get_user_id()
                 );
+
+                $this->resizePicture('width', 800);
+
+                return true;
             }
         }
 
@@ -668,14 +680,14 @@ abstract class Question
      *
      * @author Toon Keppens
      */
-    public function resizePicture($Dimension, $Max)
+    private function resizePicture($Dimension, $Max)
     {
-        global $picturePath;
+        $picturePath = $this->getHotSpotFolderInCourse();
 
         // if the question has an ID
         if ($this->id) {
             // Get dimensions from current image.
-            $my_image = new Image($picturePath . '/' . $this->picture);
+            $my_image = new Image($picturePath.'/'.$this->picture);
 
             $current_image_size = $my_image->get_image_size();
             $current_width = $current_image_size['width'];
@@ -716,7 +728,7 @@ abstract class Question
             }
 
             $my_image->resize($new_width, $new_height);
-            $result = $my_image->send_image($picturePath . '/' . $this->picture);
+            $result = $my_image->send_image($picturePath.'/'.$this->picture);
 
             if ($result) {
                 return true;
@@ -734,14 +746,14 @@ abstract class Question
      */
     public function removePicture()
     {
-        global $picturePath;
+        $picturePath = $this->getHotSpotFolderInCourse();
 
         // if the question has got an ID and if the picture exists
         if ($this->id) {
             $picture = $this->picture;
             $this->picture = '';
 
-            return @unlink($picturePath . '/' . $picture) ? true : false;
+            return @unlink($picturePath.'/'.$picture) ? true : false;
         }
 
         return false;
@@ -758,43 +770,56 @@ abstract class Question
     {
         $course_id = $course_info['real_id'];
         $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
-        $destination_path = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/images';
-        $source_path = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . '/document/images';
+        $destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images';
+        $source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images';
 
         // if the question has got an ID and if the picture exists
-        if ($this->id && !empty($this->picture)) {
+        if (!$this->id || empty($this->picture)) {
+            return false;
+        }
+
+        if (file_exists($source_path.'/'.$this->picture)) {
+            // for backward compatibility
             $picture = explode('.', $this->picture);
             $extension = $picture[sizeof($picture) - 1];
-            $picture = 'quiz-' . $questionId . '.' . $extension;
-            $result = @copy($source_path . '/' . $this->picture, $destination_path . '/' . $picture) ? true : false;
-            // If copy was correct then add to the database
-            if ($result) {
-                $sql = "UPDATE $TBL_QUESTIONS SET
-                        picture = '" . Database::escape_string($picture) . "'
-                        WHERE c_id = $course_id AND id='" . intval($questionId) . "'";
-                Database::query($sql);
+            $picture = 'quiz-'.$questionId.'.'.$extension;
+            $result = @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture);
+        } else {
+            $imageInfo = DocumentManager::get_document_data_by_id($this->picture, $course_info['code']);
+            $picture = $this->generatePictureName();
 
-                $document_id = add_document(
-                    $course_info,
-                    '/images/' . $picture,
-                    'file',
-                    filesize($destination_path . '/' . $picture),
-                    $picture
-                );
-                if ($document_id) {
-                    return api_item_property_update(
-                        $course_info,
-                        TOOL_DOCUMENT,
-                        $document_id,
-                        'DocumentAdded',
-                        api_get_user_id()
-                    );
-                }
-            }
+            $result = @copy($imageInfo['absolute_path'], $destination_path.'/'.$picture);
+        }
 
-            return $result;
+        // If copy was correct then add to the database
+        if (!$result) {
+            return false;
         }
-        return false;
+
+        $sql = "UPDATE $TBL_QUESTIONS SET
+                picture = '".Database::escape_string($picture)."'
+                WHERE c_id = $course_id AND id='".intval($questionId)."'";
+        Database::query($sql);
+
+        $document_id = add_document(
+            $course_info,
+            '/images/'.$picture,
+            'file',
+            filesize($destination_path.'/'.$picture),
+            $picture
+        );
+
+        if (!$document_id) {
+            return false;
+        }
+
+        return api_item_property_update(
+            $course_info,
+            TOOL_DOCUMENT,
+            $document_id,
+            'DocumentAdded',
+            api_get_user_id()
+        );
     }
 
     /**
@@ -803,17 +828,17 @@ abstract class Question
      * For example, if we first show a confirmation box.
      *
      * @author Olivier Brouckaert
-     * @param string $Picture - temporary path of the picture to move
-     * @param string $PictureName - Name of the picture
+     * @param string $picture - temporary path of the picture to move
+     * @param string $pictureName - Name of the picture
      */
-    public function setTmpPicture($Picture, $PictureName)
+    public function setTmpPicture($picture, $pictureName)
     {
-        global $picturePath;
-        $PictureName = explode('.', $PictureName);
-        $Extension = $PictureName[sizeof($PictureName) - 1];
+        $picturePath = $this->getHotSpotFolderInCourse();
+        $pictureName = explode('.', $pictureName);
+        $Extension = $pictureName[sizeof($pictureName) - 1];
 
         // saves the picture into a temporary file
-        @move_uploaded_file($Picture, $picturePath . '/tmp.' . $Extension);
+        @move_uploaded_file($picture, $picturePath.'/tmp.'.$Extension);
     }
 
     /**
@@ -904,12 +929,12 @@ abstract class Question
                     $TBL_EXERCISE_QUESTION as test_question
                     WHERE
                         question.id = test_question.question_id AND
-                        test_question.exercice_id = " . intval($exerciseId) . " AND
+                        test_question.exercice_id = ".intval($exerciseId)." AND
                         question.c_id = $c_id AND
                         test_question.c_id = $c_id ";
             $result = Database::query($sql);
             $current_position = Database::result($result, 0, 0);
-            $this->updatePosition($current_position+1);
+            $this->updatePosition($current_position + 1);
             $position = $this->position;
 
             $params = [
@@ -1017,7 +1042,7 @@ abstract class Question
         $rmQs = false
     ) {
         // update search engine and its values table if enabled
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
             $course_id = api_get_course_id();
             // get search_did
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
@@ -1035,8 +1060,8 @@ abstract class Question
             $res = Database::query($sql);
 
             if (Database::num_rows($res) > 0 || $addQs) {
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
 
                 $di = new ChamiloIndexer();
                 if ($addQs) {
@@ -1049,7 +1074,7 @@ abstract class Question
 
                 // retrieve others exercise ids
                 $se_ref = Database::fetch_array($res);
-                $se_doc = $di->get_document((int)$se_ref['search_did']);
+                $se_doc = $di->get_document((int) $se_ref['search_did']);
                 if ($se_doc !== false) {
                     if (($se_doc_data = $di->get_document_data($se_doc)) !== FALSE) {
                         $se_doc_data = unserialize($se_doc_data);
@@ -1087,16 +1112,16 @@ abstract class Question
                     SE_DATA => array(
                         'type' => SE_DOCTYPE_EXERCISE_QUESTION,
                         'exercise_ids' => $question_exercises,
-                        'question_id' => (int)$this->id
+                        'question_id' => (int) $this->id
                     ),
-                    SE_USER => (int)api_get_user_id(),
+                    SE_USER => (int) api_get_user_id(),
                 );
                 $ic_slide->xapian_data = serialize($xapian_data);
                 $ic_slide->addValue("content", $this->description);
 
                 //TODO: index answers, see also form validation on question_admin.inc.php
 
-                $di->remove_document((int)$se_ref['search_did']);
+                $di->remove_document((int) $se_ref['search_did']);
                 $di->addChunk($ic_slide);
 
                 //index and return search engine document id
@@ -1175,7 +1200,7 @@ abstract class Question
             $count = $new_exercise->selectNbrQuestions();
             $count++;
             $sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order)
-                    VALUES ({$this->course['real_id']}, " . intval($id) . ", " . intval($exerciseId) . ", '$count')";
+                    VALUES ({$this->course['real_id']}, ".intval($id).", ".intval($exerciseId).", '$count')";
             Database::query($sql);
 
             // we do not want to reindex if we had just saved adnd indexed the question
@@ -1212,17 +1237,17 @@ abstract class Question
                     FROM $TBL_EXERCISE_QUESTION
                     WHERE
                         c_id = $course_id
-                        AND question_id = " . intval($id) . "
+                        AND question_id = ".intval($id)."
                         AND exercice_id = " . intval($exerciseId);
             $res = Database::query($sql);
-            if (Database::num_rows($res)>0) {
+            if (Database::num_rows($res) > 0) {
                 $row = Database::fetch_array($res);
                 if (!empty($row['question_order'])) {
                     $sql = "UPDATE $TBL_EXERCISE_QUESTION
                         SET question_order = question_order-1
                         WHERE
                             c_id = $course_id
-                            AND exercice_id = " . intval($exerciseId) . "
+                            AND exercice_id = ".intval($exerciseId)."
                             AND question_order > " . $row['question_order'];
                     Database::query($sql);
                 }
@@ -1231,7 +1256,7 @@ abstract class Question
             $sql = "DELETE FROM $TBL_EXERCISE_QUESTION
                     WHERE
                         c_id = $course_id
-                        AND question_id = " . intval($id) . "
+                        AND question_id = ".intval($id)."
                         AND exercice_id = " . intval($exerciseId);
             Database::query($sql);
 
@@ -1272,7 +1297,7 @@ abstract class Question
                                 SET question_order = question_order-1
                                 WHERE
                                     c_id= $course_id
-                                    AND exercice_id = " . intval($row['exercice_id']) . "
+                                    AND exercice_id = ".intval($row['exercice_id'])."
                                     AND question_order > " . $row['question_order'];
                         Database::query($sql);
                     }
@@ -1280,22 +1305,22 @@ abstract class Question
             }
 
             $sql = "DELETE FROM $TBL_EXERCISE_QUESTION
-                    WHERE c_id = $course_id AND question_id = " . $id;
+                    WHERE c_id = $course_id AND question_id = ".$id;
             Database::query($sql);
 
             $sql = "DELETE FROM $TBL_QUESTIONS
-                    WHERE c_id = $course_id AND id = " . $id;
+                    WHERE c_id = $course_id AND id = ".$id;
             Database::query($sql);
 
             $sql = "DELETE FROM $TBL_REPONSES
-                    WHERE c_id = $course_id AND question_id = " . $id;
+                    WHERE c_id = $course_id AND question_id = ".$id;
             Database::query($sql);
 
             // remove the category of this question in the question_rel_category table
             $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY
                     WHERE 
                         c_id = $course_id AND 
-                        question_id = " . $id;
+                        question_id = ".$id;
             Database::query($sql);
 
             api_item_property_update(
@@ -1464,7 +1489,7 @@ abstract class Question
                 if (class_exists($class_name)) {
                     return new $class_name();
                 } else {
-                    echo 'Can\'t instanciate class ' . $class_name . ' of type ' . $type;
+                    echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
                 }
             }
         }
@@ -1648,7 +1673,7 @@ abstract class Question
 
         if ($feedback_type == 1) {
             //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
-            $question_type_custom_list = array (
+            $question_type_custom_list = array(
                 UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],
                 HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]
             );
@@ -1664,14 +1689,14 @@ abstract class Question
             require_once $a_type[0];
             // get the picture of the type and the langvar which describes it
             $img = $explanation = '';
-            eval('$img = ' . $a_type[1] . '::$typePicture;');
-            eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);');
+            eval('$img = '.$a_type[1].'::$typePicture;');
+            eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
             echo '<li>';
             echo '<div class="icon-image">';
 
 
-            $icon = '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '">' .
-                Display::return_icon($img, $explanation, null, ICON_SIZE_BIG) . '</a>';
+            $icon = '<a href="admin.php?'.api_get_cidreq().'&newQuestion=yes&answerType='.$i.'">'.
+                Display::return_icon($img, $explanation, null, ICON_SIZE_BIG).'</a>';
 
             if ($objExercise->force_edit_exercise_in_lp === false) {
                 if ($objExercise->exercise_was_added_in_lp == true) {
@@ -1692,9 +1717,9 @@ abstract class Question
             echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
         } else {
             if ($feedback_type == 1) {
-                echo $url = "<a href=\"question_pool.php?" . api_get_cidreq() . "&type=1&fromExercise=$exerciseId\">";
+                echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">";
             } else {
-                echo $url = '<a href="question_pool.php?' . api_get_cidreq() . '&fromExercise=' . $exerciseId . '">';
+                echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
             }
             echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
         }
@@ -1827,7 +1852,7 @@ abstract class Question
             $header .= $this->show_media_content();
         }
 
-        $header .= Display::page_subheader2($counter_label . ". " . $question_title);
+        $header .= Display::page_subheader2($counter_label.". ".$question_title);
         $header .= Display::div(
             "<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>",
             array('class' => 'ribbon')
@@ -1918,8 +1943,8 @@ abstract class Question
         require_once $tabQuestionList[$type][0];
 
         $img = $explanation = null;
-        eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;');
-        eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);');
+        eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;');
+        eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);');
         return array($img, $explanation);
     }
 

+ 123 - 142
main/inc/lib/TicketManager.php

@@ -761,8 +761,8 @@ class TicketManager
 
     /**
      * Get tickets by userId
-     * @param $from
-     * @param $number_of_items
+     * @param int $from
+     * @param int  $number_of_items
      * @param $column
      * @param $direction
      * @param int $userId
@@ -783,50 +783,76 @@ class TicketManager
         $userId = !empty($userId) ? $userId : api_get_user_id();
         $isAdmin = UserManager::is_admin($userId);
 
+        switch ($column) {
+            case 0:
+                $column = 'ticket_id';
+                break;
+            case 1:
+                $column = 'status_name';
+                break;
+            case 2:
+                $column = 'start_date';
+                break;
+            case 3:
+                $column = 'sys_lastedit_datetime';
+                break;
+            case 4:
+                $column = 'category_name';
+                break;
+            case 5:
+                $column = 'sys_insert_user_id';
+                break;
+            case 6:
+                $column = 'assigned_last_user';
+                break;
+            case 7:
+                $column = 'total_messages';
+                break;
+            case 8:
+                $column = 'subject';
+                break;
+            default:
+                $column = 'ticket_id';
+        }
+
         $sql = "SELECT DISTINCT 
                 ticket.*,
                 ticket.id ticket_id,
-                ticket.id AS col0,
-                ticket.start_date AS col1,
-                ticket.sys_lastedit_datetime AS col2,
-                cat.name AS col3,
-                priority.name AS col5,
-                priority.name AS col6,
-                status.name AS col7,
-                ticket.total_messages AS col8,
-                ticket.message AS col9,
+                status.name AS status_name,
+                ticket.start_date,
+                ticket.sys_lastedit_datetime,
+                cat.name AS category_name,
+                priority.name AS priority_name,                           
+                ticket.total_messages AS total_messages,
+                ticket.message AS message,
                 ticket.subject AS subject,
                 ticket.assigned_last_user
-            FROM $table_support_tickets ticket,
-                $table_support_category cat,
-                $table_support_priority priority,
-                $table_support_status status
-            WHERE 
-                cat.id = ticket.category_id AND
-                ticket.priority_id = priority.id AND
-                ticket.status_id = status.id                
+            FROM $table_support_tickets ticket 
+            INNER JOIN $table_support_category cat
+            ON (cat.id = ticket.category_id)
+            INNER JOIN $table_support_priority priority
+            ON (ticket.priority_id = priority.id)
+            INNER JOIN $table_support_status status
+            ON (ticket.status_id = status.id)
+            WHERE 1=1                                
         ";
 
         if (!$isAdmin) {
             $sql .= " AND (ticket.assigned_last_user = $userId OR ticket.sys_insert_user_id = $userId )";
         }
 
-        $keyword_unread = '';
-        if (isset($_GET['keyword_unread'])) {
-            $keyword_unread = Database::escape_string(
-                trim($_GET['keyword_unread'])
-            );
-        }
-
         // Search simple
-        if (isset($_GET['submit_simple'])) {
-            if ($_GET['keyword'] != '') {
-                $keyword = Database::escape_string(trim($_GET['keyword']));
-                $sql .= " AND (
-                            ticket.code = '$keyword' OR 
-                            ticket.id = '$keyword'                            
-                        )";
-            }
+        if (isset($_GET['submit_simple']) && $_GET['keyword'] != '') {
+            $keyword = Database::escape_string(trim($_GET['keyword']));
+            $sql .= " AND (
+                      ticket.id LIKE '%$keyword%' OR
+                      ticket.code LIKE '%$keyword%' OR
+                      ticket.subject LIKE '%$keyword%' OR
+                      ticket.message LIKE '%$keyword%' OR
+                      ticket.keyword LIKE '%$keyword%' OR
+                      ticket.source LIKE '%$keyword%' OR
+                      ticket.personal_email LIKE '%$keyword%'                          
+            )";
         }
 
         // Search advanced
@@ -851,30 +877,23 @@ class TicketManager
                 trim($_GET['keyword_priority'])
             );
 
-            $keyword_range = isset($_GET['keyword_dates']) ? Database::escape_string(trim($_GET['keyword_dates'])) : '';
-            $keyword_course = Database::escape_string(
-                trim($_GET['keyword_course'])
-            );
-
+            $keyword_range = !empty($keyword_start_date_start) && !empty($keyword_start_date_end);
+            $keyword_course = Database::escape_string(trim($_GET['keyword_course']));
             if ($keyword_category != '') {
-                $sql .= " AND ticket.category_id = '$keyword_category'  ";
+                $sql .= " AND ticket.category_id = '$keyword_category' ";
             }
-            /*if ($keyword_request_user != '') {
-                $sql .= " AND (ticket.request_user = '$keyword_request_user'
-                          OR concat(user.firstname,' ',user.lastname) LIKE '%$keyword_request_user%'
-                          OR concat(user.lastname,' ',user.firstname) LIKE '%$keyword_request_user%'
-                          OR user.username LIKE '%$keyword_request_user%') ";
-            }*/
+
             if ($keyword_admin != '') {
-                $sql .= " AND ticket.assigned_last_user = '$keyword_admin'  ";
+                $sql .= " AND ticket.assigned_last_user = '$keyword_admin' ";
             }
             if ($keyword_status != '') {
-                $sql .= " AND ticket.status_id = '$keyword_status'  ";
+                $sql .= " AND ticket.status_id = '$keyword_status' ";
             }
-            if ($keyword_range == '' && $keyword_start_date_start != '') {
-                $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' ";
+
+            if ($keyword_range == false && $keyword_start_date_start != '') {
+                $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' ";
             }
-            if ($keyword_range == '1' && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
+            if ($keyword_range && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
                 $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start'
                           AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'";
             }
@@ -897,13 +916,12 @@ class TicketManager
             }
         }
 
-        $sql .= " ORDER BY col$column $direction";
+        $sql .= " ORDER BY $column $direction";
         $sql .= " LIMIT $from, $number_of_items";
 
         $result = Database::query($sql);
         $tickets = array();
         $webPath = api_get_path(WEB_PATH);
-        $webCodePath = api_get_path(WEB_CODE_PATH);
         while ($row = Database::fetch_assoc($result)) {
             /*$sql_unread = "SELECT
                               COUNT(DISTINCT message.message_id) AS unread
@@ -927,14 +945,14 @@ class TicketManager
 
             $userInfo = api_get_user_info($row['sys_insert_user_id']);
             $hrefUser = $webPath . 'main/admin/user_information.php?user_id=' . $userInfo['user_id'];
-            $name = "<a href='$hrefUser'> {$userInfo['username']} </a>";
+            $name = "<a href='$hrefUser'> {$userInfo['complete_name_with_username']} </a>";
             $actions = '';
 
             if ($row['assigned_last_user'] != 0) {
                 $assignedUserInfo = api_get_user_info($row['assigned_last_user']);
                 if (!empty($assignedUserInfo)) {
                     $hrefResp = $webPath . 'main/admin/user_information.php?user_id=' . $assignedUserInfo['user_id'];
-                    $row['assigned_last_user'] = "<a href='$hrefResp'> {$assignedUserInfo['username']} </a>";
+                    $row['assigned_last_user'] = "<a href='$hrefResp'> {$assignedUserInfo['complete_name_with_username']} </a>";
                 } else {
                     $row['assigned_last_user'] = get_lang('UnknownUser');
                 }
@@ -961,44 +979,25 @@ class TicketManager
                     break;
             }
 
-            $row['col1'] = Display::tip(
-                date_to_str_ago($row['col1']),
-                api_get_local_time($row['col1'])
-            );
-            $row['col2'] = Display::tip(
-                date_to_str_ago($row['col2']),
-                api_get_local_time($row['col2'])
-            );
-            if ($isAdmin) {
-                if ($row['priority_id'] === self::PRIORITY_HIGH && $row['status_id'] != self::STATUS_CLOSE) {
-                    $actions .= '<img src="' . $webCodePath . 'img/exclamation.png" border="0" />';
-                }
-                $row['col0'] = Display::return_icon(
-                        $img_source,
-                        get_lang('Info')
-                        ).
-                    '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['code'] . '</a>';
-                // @todo fix
-                /*if ($row['col7'] == 'PENDIENTE') {
-                    $row['col7'] = '<span style="color: #f00; font-weight:bold;">' . $row['col7'] . '</span>';
-                }*/
+            $row['start_date'] = Display::dateToStringAgoAndLongDate($row['start_date']);
+            $row['sys_lastedit_datetime'] = Display::dateToStringAgoAndLongDate($row['sys_lastedit_datetime']);
+
+            $icon = Display::return_icon($img_source, get_lang('Info')).'<a href="ticket_details.php?ticket_id=' . $row['id'] . '">' . $row['code'] . '</a>';
 
+            if ($isAdmin) {
                 $ticket = array(
-                    $row['col0'].' '.$row['subject'],
-                    $row['col7'],
-                    $row['col1'],
-                    $row['col2'],
-                    $row['col3'],
+                    $icon.' '.$row['subject'],
+                    $row['status_name'],
+                    $row['start_date'],
+                    $row['sys_lastedit_datetime'],
+                    $row['category_name'],
                     $name,
                     $row['assigned_last_user'],
-                    $row['col8']
+                    $row['total_messages']
                 );
             } else {
                 $actions = '';
-                $row['col0'] = Display::return_icon(
-                    $img_source,
-                    get_lang('Info')
-                ) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['code'] . '</a>';
+                /*
                 $now = api_strtotime(api_get_utc_datetime());
                 $last_edit_date = api_strtotime($row['sys_lastedit_datetime']);
                 $dif = $now - $last_edit_date;
@@ -1009,13 +1008,13 @@ class TicketManager
                 }
                 if ($row['priority_id'] === self::PRIORITY_HIGH) {
                     $actions .= '<img src="' . Display::returnIconPath('admin_star.png') . '" border="0" />';
-                }
+                }*/
                 $ticket = array(
-                    $row['col0'],
-                    $row['col7'],
-                    $row['col1'],
-                    $row['col2'],
-                    $row['col3']
+                    $icon.' '.$row['subject'],
+                    $row['status_name'],
+                    $row['start_date'],
+                    $row['sys_lastedit_datetime'],
+                    $row['category_name']
                 );
             }
             /*if ($unread > 0) {
@@ -1041,58 +1040,47 @@ class TicketManager
      */
     public static function get_total_tickets_by_user_id($userId = 0)
     {
-        $table_support_category = Database::get_main_table(
-            TABLE_TICKET_CATEGORY
-        );
+        $table_support_category = Database::get_main_table(TABLE_TICKET_CATEGORY);
         $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
-        $table_support_priority = Database::get_main_table(
-            TABLE_TICKET_PRIORITY
-        );
+        $table_support_priority = Database::get_main_table(TABLE_TICKET_PRIORITY);
         $table_support_status = Database::get_main_table(TABLE_TICKET_STATUS);
-        $table_support_messages = Database::get_main_table(
-            TABLE_TICKET_MESSAGE
-        );
-        $table_main_user = Database::get_main_table(TABLE_MAIN_USER);
-        $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
+
+        $userId = api_get_user_id();
 
         $sql = "SELECT COUNT(ticket.id) AS total
-                FROM $table_support_tickets ticket ,
-                $table_support_category cat ,
-                $table_support_priority priority,
-                $table_support_status status                
-	        WHERE 
-	            cat.id = ticket.category_id AND 
-	            ticket.priority_id = priority.id AND 
-	            ticket.status_id = status.id";
+                FROM $table_support_tickets ticket
+                INNER JOIN $table_support_category cat
+                ON (cat.id = ticket.category_id)
+                INNER JOIN $table_support_priority priority
+                ON (ticket.priority_id = priority.id)
+                INNER JOIN $table_support_status status
+                ON (ticket.status_id = status.id)
+	        WHERE 1 = 1";
+
+        if (!api_is_platform_admin()) {
+            $sql .= " AND (ticket.assigned_last_user = $userId OR ticket.sys_insert_user_id = $userId )";
+        }
 
         // Search simple
         if (isset($_GET['submit_simple'])) {
             if ($_GET['keyword'] != '') {
                 $keyword = Database::escape_string(trim($_GET['keyword']));
-                $sql .= " AND (ticket.code = '$keyword'
-                          OR user.firstname LIKE '%$keyword%'
-                          OR user.lastname LIKE '%$keyword%'
-                          OR concat(user.firstname,' ',user.lastname) LIKE '%$keyword%'
-                          OR concat(user.lastname,' ',user.firstname) LIKE '%$keyword%'
-                          OR user.username LIKE '%$keyword%')  ";
+                $sql .= " AND (
+                          ticket.code LIKE '%$keyword%' OR
+                          ticket.subject LIKE '%$keyword%' OR
+                          ticket.message LIKE '%$keyword%' OR
+                          ticket.keyword LIKE '%$keyword%' OR
+                          ticket.personal_email LIKE '%$keyword%' OR
+                          ticket.source LIKE '%$keyword%'
+                )";
             }
         }
-        $keyword_unread = '';
-        if (isset($_GET['keyword_unread'])) {
-            $keyword_unread = Database::escape_string(
-                trim($_GET['keyword_unread'])
-            );
-        }
 
         // Search advanced
         if (isset($_GET['submit_advanced'])) {
             $keyword_category = Database::escape_string(
                 trim($_GET['keyword_category'])
             );
-            $keyword_request_user = '';
-            /*$keyword_request_user = Database::escape_string(
-                trim($_GET['keyword_request_user'])
-            );*/
             $keyword_admin = Database::escape_string(
                 trim($_GET['keyword_admin'])
             );
@@ -1118,25 +1106,17 @@ class TicketManager
             if ($keyword_category != '') {
                 $sql .= " AND ticket.category_id = '$keyword_category'  ";
             }
-            if ($keyword_request_user != '') {
-                $sql .= " AND (ticket.request_user = '$keyword_request_user'
-                          OR user.firstname LIKE '%$keyword_request_user%'
-                          OR user.official_code LIKE '%$keyword_request_user%'
-                          OR user.lastname LIKE '%$keyword_request_user%'
-                          OR concat(user.firstname,' ',user.lastname) LIKE '%$keyword_request_user%'
-                          OR concat(user.lastname,' ',user.firstname) LIKE '%$keyword_request_user%'
-                          OR user.username LIKE '%$keyword_request_user%') ";
-            }
+
             if ($keyword_admin != '') {
                 $sql .= " AND ticket.assigned_last_user = '$keyword_admin'  ";
             }
             if ($keyword_status != '') {
                 $sql .= " AND ticket.status_id = '$keyword_status'  ";
             }
-            if ($keyword_range == '' && $keyword_start_date_start != '') {
+            if ($keyword_range == false && $keyword_start_date_start != '') {
                 $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' ";
             }
-            if ($keyword_range == '1' && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
+            if ($keyword_range && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
                 $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start'
                           AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'";
             }
@@ -1159,7 +1139,7 @@ class TicketManager
                          OR visual_code LIKE '%$keyword_course%' )) ";
             }
         }
-
+        /*
         if ($keyword_unread == 'yes') {
             $sql .= " AND ticket.id IN ( ";
             $sql .= "SELECT ticket.id
@@ -1176,7 +1156,7 @@ class TicketManager
         } else {
             if ($keyword_unread == 'no') {
                 $sql .= " AND ticket.id NOT IN ( ";
-                $sql .= " SELECT ticket.id 
+                $sql .= " SELECT ticket.id
                           FROM  $table_support_tickets ticket,
                           $table_support_messages message,
                           $table_main_user user
@@ -1187,7 +1167,7 @@ class TicketManager
                           AND ticket.status_id != '".self::STATUS_FORWARDED."'
                           GROUP BY ticket.id)";
             }
-        }
+        }*/
         $res = Database::query($sql);
         $obj = Database::fetch_object($res);
 
@@ -2282,7 +2262,8 @@ class TicketManager
     /**
      * @return array
      */
-    public static function getDefaultStatusList() {
+    public static function getDefaultStatusList()
+    {
         return [
             self::STATUS_NEW,
             self::STATUS_PENDING,

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

@@ -613,6 +613,8 @@ define('MAX_ONLINE_USERS', 12);
 
 // Number of characters maximum to show in preview of course blog posts
 define('BLOG_MAX_PREVIEW_CHARS', 800);
+// HTML string to replace with a 'Read more...' link
+define('BLOG_PAGE_BREAK', '<div style="page-break-after: always"><span style="display: none;">&nbsp;</span></div>');
 
 // Make sure the CHAMILO_LOAD_WYSIWYG constant is defined
 // To remove CKeditor libs from HTML, set this constant to true before loading
@@ -3200,7 +3202,7 @@ function api_not_allowed($print_headers = false, $message = null)
         $msg = $message;
     } else {
         $msg = Display::return_message(
-            get_lang('NotAllowedClickBack').'<br/><br/><a href="'.$home_url.'">'.get_lang('ReturnToCourseHomepage').'</a>',
+            get_lang('NotAllowedClickBack').'<br/><br/><button onclick="goBack();">'.get_lang('GoBack').'</button><script>function goBack(){window.history.back();}</script>',
             'error',
             false
         );

+ 6 - 0
main/inc/lib/blog.lib.php

@@ -3075,6 +3075,12 @@ class Blog
      */
     private static function getPostExtract($fullText, $length = BLOG_MAX_PREVIEW_CHARS)
     {
+        $parts = explode(BLOG_PAGE_BREAK, $fullText);
+
+        if (count($parts) > 1) {
+            return $parts[0];
+        }
+
         // Remove any HTML from the string
         $text = strip_tags($fullText);
         $text = api_html_entity_decode($text);

+ 8 - 2
main/inc/lib/course.lib.php

@@ -4921,9 +4921,15 @@ class CourseManager
             /* get_lang('Description') */
             $my_course['teachers'] = self::getTeachersFromCourse($course_info['real_id'], false);
             $point_info = self::get_course_ranking($course_info['real_id'], 0);
-            $my_course['rating_html'] = Display::return_rating_system('star_' . $course_info['real_id'],
-                $ajax_url . '&course_id=' . $course_info['real_id'], $point_info);
 
+            $my_course['rating_html'] = '';
+            if (api_get_configuration_value('hide_course_rating') === false) {
+                $my_course['rating_html'] = Display::return_rating_system(
+                    'star_'.$course_info['real_id'],
+                    $ajax_url.'&course_id='.$course_info['real_id'],
+                    $point_info
+                );
+            }
             $hotCourses[] = $my_course;
         }
 

+ 11 - 12
main/inc/lib/display.lib.php

@@ -1670,14 +1670,18 @@ class Display
     /**
      * Return the five star HTML
      *
-     * @param  string  id of the rating ul element
-     * @param  string  url that will be added (for jquery see hot_courses.tpl)
-	 * @param	string	point info array see function CourseManager::get_course_ranking()
-	 * @param	bool	add a div wrapper
-	 * @todo	use     templates
+     * @param string $id of the rating ul element
+     * @param string $url that will be added (for jquery see hot_courses.tpl)
+     * @param array $point_info point info array see function CourseManager::get_course_ranking()
+	 * @param bool $add_div_wrapper add a div wrapper
+	 * @return string
      **/
-    public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true)
-    {
+    public static function return_rating_system(
+        $id,
+        $url,
+        $point_info = [],
+        $add_div_wrapper = true
+    ) {
 		$number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null;
 		$percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0;
 
@@ -1685,7 +1689,6 @@ class Display
             $percentage = $percentage*125/100;
         }
 		$accesses =  isset($point_info['accesses']) ? $point_info['accesses'] : 0;
-
 		$star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']);
 
         $html = '<ul id="'.$id.'" class="star-rating">
@@ -1701,10 +1704,6 @@ class Display
 
 		$labels[]= $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
 		$labels[]= $accesses == 1 ? $accesses.' '.get_lang('Visit') : $accesses.' '.get_lang('Visits');
-		/* if (!empty($number_of_users_who_voted)) {
-			$labels[]= get_lang('Average').' '.$point_info['point_average_star'].'/5';
-		} */
-
 		$labels[]= $point_info['user_vote']  ? get_lang('YourVote').' ['.$point_info['user_vote'].']' : get_lang('YourVote'). ' [?] ';
 
 		if (!$add_div_wrapper && api_is_anonymous()) {

+ 8 - 2
main/inc/lib/fileManage.lib.php

@@ -192,8 +192,14 @@ function move($source, $target, $forceMove = true, $moveContent = false)
 
         /* File case */
         if (is_file($source)) {
-            if ($forceMove && !$isWindowsOS && $canExec) {
-                exec('mv ' . $source . ' ' . $target . '/' . $file_name);
+            if ($forceMove) {
+                if (!$isWindowsOS && $canExec) {
+                    exec('mv '.$source.' '.$target.'/'.$file_name);
+                } else {
+                    // Try copying
+                    copy($source, $target . '/' . $file_name);
+                    unlink($source);
+                }
             } else {
                 copy($source, $target . '/' . $file_name);
                 unlink($source);

+ 18 - 18
main/inc/lib/glossary.lib.php

@@ -47,9 +47,9 @@ class GlossaryManager
      *
      * @return string The glossary description
      */
-    public static function get_glossary_term_by_glossary_id ($glossary_id)
+    public static function get_glossary_term_by_glossary_id($glossary_id)
     {
-        $glossary_table  = Database::get_course_table(TABLE_GLOSSARY);
+        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
         $course_id = api_get_course_int_id();
         $sql = "SELECT description FROM $glossary_table
                 WHERE c_id = $course_id  AND glossary_id =".intval($glossary_id);
@@ -72,7 +72,7 @@ class GlossaryManager
      */
     public static function get_glossary_term_by_glossary_name($glossary_name)
     {
-        $glossary_table  = Database::get_course_table(TABLE_GLOSSARY);
+        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
         $session_id = api_get_session_id();
         $course_id = api_get_course_int_id();
         $sql_filter = api_get_session_condition($session_id);
@@ -223,7 +223,7 @@ class GlossaryManager
         $get_max = "SELECT MAX(display_order) FROM $t_glossary
                     WHERE c_id = $course_id ";
         $res_max = Database::query($get_max);
-        if (Database::num_rows($res_max)==0) {
+        if (Database::num_rows($res_max) == 0) {
             return 0;
         }
         $row = Database::fetch_array($res_max);
@@ -252,7 +252,7 @@ class GlossaryManager
                 WHERE
                     c_id = $course_id AND
                     name = '".Database::escape_string($term)."'";
-        if ($not_id<>'') {
+        if ($not_id <> '') {
             $sql .= " AND glossary_id <> '".intval($not_id)."'";
         }
         $result = Database::query($sql);
@@ -375,25 +375,25 @@ class GlossaryManager
         $actionsLeft = '';
         if (api_is_allowed_to_edit(null, true)) {
             $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=addglossary&msg=add?'.api_get_cidreq().'">'.
-                Display::return_icon('new_glossary_term.png',get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>';
         }
 
         $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=export">'.
-            Display::return_icon('export_csv.png',get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
         if (api_is_allowed_to_edit(null, true)) {
             $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=import">'.
-                Display::return_icon('import_csv.png',get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>';
         }
 
         $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf">'.
-            Display::return_icon('pdf.png',get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
 
         if (($view == 'table') || (!isset($view))) {
             $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=list">'.
-                Display::return_icon('view_detailed.png',get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>';
         } else {
             $actionsLeft .= '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=table">'.
-                Display::return_icon('view_text.png',get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>';
+                Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>';
         }
 
         /* BUILD SEARCH FORM */
@@ -430,7 +430,7 @@ class GlossaryManager
             $table->set_header(1, get_lang('TermDefinition'), true);
             if (api_is_allowed_to_edit(null, true)) {
                 $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions'));
-                $table->set_column_filter(2, array('GlossaryManager','actions_filter'));
+                $table->set_column_filter(2, array('GlossaryManager', 'actions_filter'));
             }
             $content .= $table->return_table();
         }
@@ -452,8 +452,8 @@ class GlossaryManager
         $content = '';
         foreach ($glossary_data as $key => $glossary_item) {
             $actions = '';
-            if (api_is_allowed_to_edit(null,true)) {
-                $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>';
+            if (api_is_allowed_to_edit(null, true)) {
+                $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '', $glossary_item).'</div>';
             }
             $content .= Display::panel($glossary_item[1], $glossary_item[0].' '.$actions);
         }
@@ -466,7 +466,7 @@ class GlossaryManager
      * @return integer Count of glossary terms
      *
      */
-    public static function get_number_glossary_terms($session_id=0)
+    public static function get_number_glossary_terms($session_id = 0)
     {
         // Database table definition
         $t_glossary = Database::get_course_table(TABLE_GLOSSARY);
@@ -560,7 +560,7 @@ class GlossaryManager
         while ($data = Database::fetch_array($res)) {
             // Validation when belongs to a session
             $session_img = api_get_session_image($data['session_id'], $_user['status']);
-            $array[0] = $data[0] . $session_img;
+            $array[0] = $data[0].$session_img;
 
             if (!$view || $view === 'table') {
                 $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]);
@@ -590,13 +590,13 @@ class GlossaryManager
     {
         $glossary_id = $row[2];
         $return = '<a href="'.api_get_self().'?action=edit_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.
-            Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
+            Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
         $glossary_data = self::get_glossary_information($glossary_id);
         $glossary_term = $glossary_data['name'];
         if (api_is_allowed_to_edit(null, true)) {
             if ($glossary_data['session_id'] == api_get_session_id()) {
                 $return .= '<a href="'.api_get_self().'?action=delete_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.
-                    Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>';
+                    Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a>';
             } else {
                 $return = get_lang('EditionNotAvailableFromSession');
             }

+ 1 - 0
main/inc/lib/model.lib.php

@@ -25,6 +25,7 @@ class Model
 
     /**
      * Useful finder - experimental akelos like only use in notification.lib.php send function
+     * @param string $type
      */
     public function find($type, $options = null)
     {

+ 13 - 13
main/inc/lib/skill.visualizer.lib.php

@@ -27,7 +27,7 @@ class SkillVisualizer
     {
         $this->skills   = $skills;
         $this->type     = $type;
-        $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2);
+        $this->center_x = intval($offset_x + $this->canvas_x / 2 - $this->block_size / 2);
     }
 
     function prepare_skill_box($skill, $position, $class)
@@ -39,9 +39,9 @@ class SkillVisualizer
             $extra_class = 'second_window';
         }
 
-        $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.'  '.$class.'" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">';
+        $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.'  '.$class.'" style = "top:'.$position['y'].'px; left:'.$position['x'].'px;">';
 
-        $content =  $skill['name'];
+        $content = $skill['name'];
         $content .= '<div class="btn-group">';
         $content .= Display::url(get_lang('Edit'), '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn'));
         $content .= Display::url('+', '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn'));
@@ -87,9 +87,9 @@ class SkillVisualizer
         }
         //default_arrow_color
 
-        $this->js .= 'var e'.$block_id.' = prepare("block_' . $block_id.'",  '.$end_point.');'."\n";
-        $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_' . $skill['parent_id'].'",  '.$end_point.');'."\n";
-        $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n";;
+        $this->js .= 'var e'.$block_id.' = prepare("block_'.$block_id.'",  '.$end_point.');'."\n";
+        $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_'.$skill['parent_id'].'",  '.$end_point.');'."\n";
+        $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n"; ;
     }
 
     /**
@@ -125,10 +125,10 @@ class SkillVisualizer
         $brothers = array();
 
         foreach ($this->skills as &$skill) {
-            if (!in_array($skill['parent_id'], array(0,1))) {
+            if (!in_array($skill['parent_id'], array(0, 1))) {
                 continue;
             }
-            $childs = isset($skill['children']) ? count($skill['children']) : 0 ;
+            $childs = isset($skill['children']) ? count($skill['children']) : 0;
 
             //$x = round($this->offsetX * sin(deg2rad($corner * $count)));
             //$y = round($this->offsetY * cos(deg2rad($corner * $count)));
@@ -144,10 +144,10 @@ class SkillVisualizer
             if ($skill['parent_id'] == 0) {
                 //$x = 130*$childs/2;
                 //$x = $this->space_between_blocks_x*$childs/2;
-                $x = $this->canvas_x/2  - $this->block_size/2;
+                $x = $this->canvas_x / 2 - $this->block_size / 2;
             } else {
                 $max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0;
-                foreach($this->skills[$skill['parent_id']]['children'] as  $id => $sk) {
+                foreach ($this->skills[$skill['parent_id']]['children'] as  $id => $sk) {
                     if ($skill['id'] == $sk['id']) {
                         break;
                     }
@@ -155,17 +155,17 @@ class SkillVisualizer
                 }
                 $parent_x = isset($this->skills[$skill['parent_id']]['x']) ? $this->skills[$skill['parent_id']]['x'] : 0;
                 //$x = $my_count*$this->space_between_blocks_x + $parent_x  + $this->block_size - ($this->space_between_blocks_x*$max/2) ;
-                $x = $my_count*$this->space_between_blocks_x + $parent_x  + $this->block_size - ($this->canvas_x/2 ) ;
+                $x = $my_count * $this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x / 2);
             }
 
-            $y = $skill['level']*$this->space_between_blocks_y;
+            $y = $skill['level'] * $this->space_between_blocks_y;
 
             $skill['x'] = $x;
             $skill['y'] = $y;
 
             //$skill['description']  = "{$brothers[$skill['parent_id']]} $x - $y";
             //$skill['name']  =  $skill['name']."  |  $x = $my_count * 150  +  $parent_x - (150* $max/2) - 10*$childs ";
-            $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y +$y));
+            $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y + $y));
         }
         return $this->get_html();
     }

+ 6 - 0
main/inc/lib/usermanager.lib.php

@@ -739,6 +739,12 @@ class UserManager
             TicketManager::deleteUserFromTicketSystem($user_id);
         }
 
+        $tableExists = $connection->getSchemaManager()->tablesExist(['c_lp_category_user']);
+        if ($tableExists) {
+            $sql = "DELETE FROM c_lp_category_user WHERE user_id = $user_id";
+            Database::query($sql);
+        }
+
         // Delete user from database
         $sql = "DELETE FROM $table_user WHERE id = '".$user_id."'";
         Database::query($sql);

+ 14 - 14
main/session/add_courses_to_session.php

@@ -23,7 +23,7 @@ $xajax->registerFunction(array('search_courses', 'AddCourseToSession', 'search_c
 $this_section = SECTION_PLATFORM_ADMIN;
 
 // setting breadcrumbs
-$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
+$interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('SessionList'));
 $interbreadcrumb[] = array(
     'url' => "resume_session.php?id_session=".$sessionId,
     'name' => get_lang('SessionOverview')
@@ -37,7 +37,7 @@ $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
 
 // setting the name of the tool
-$tool_name= get_lang('SubscribeCoursesToSession');
+$tool_name = get_lang('SubscribeCoursesToSession');
 
 $add_type = 'multiple';
 if (isset($_GET['add_type']) && $_GET['add_type'] != '') {
@@ -130,7 +130,7 @@ if ($ajax_search) {
             ON
                 course.id = session_rel_course.c_id AND
                 session_rel_course.session_id = ".$sessionId."
-			ORDER BY ".(sizeof($courses)?"(code IN(".implode(',', $courses).")) DESC,":"")." title";
+			ORDER BY ".(sizeof($courses) ? "(code IN(".implode(',', $courses).")) DESC," : "")." title";
 
     if (api_is_multiple_url_enabled()) {
         $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -144,7 +144,7 @@ if ($ajax_search) {
                         INNER JOIN $tbl_course_rel_access_url url_course
                         ON (url_course.c_id = course.id)
                     WHERE access_url_id = $access_url_id
-                    ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
+                    ORDER BY ".(sizeof($courses) ? "(code IN(".implode(',', $courses).")) DESC," : "")." title";
         }
     }
 
@@ -160,7 +160,7 @@ if ($ajax_search) {
             ON
                 course.id = session_rel_course.c_id AND
                 session_rel_course.session_id = ".$sessionId."
-			ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
+			ORDER BY ".(sizeof($courses) ? "(code IN(".implode(',', $courses).")) DESC," : "")." title";
 
     if (api_is_multiple_url_enabled()) {
         $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -175,16 +175,16 @@ if ($ajax_search) {
                     INNER JOIN $tbl_course_rel_access_url url_course
                     ON (url_course.c_id = course.id)
                     WHERE access_url_id = $access_url_id
-                    ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
+                    ORDER BY ".(sizeof($courses) ? "(code IN(".implode(',', $courses).")) DESC," : "")." title";
         }
     }
     $result = Database::query($sql);
     $Courses = Database::store_result($result);
     foreach ($Courses as $course) {
         if ($course['session_id'] == $sessionId) {
-            $sessionCourses[$course['id']] = $course ;
+            $sessionCourses[$course['id']] = $course;
         } else {
-            $nosessionCourses[$course['id']] = $course ;
+            $nosessionCourses[$course['id']] = $course;
         }
     }
 }
@@ -206,7 +206,7 @@ if (!api_is_platform_admin() && api_is_teacher()) {
 
 unset($Courses);
 ?>
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $sessionId; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $sessionId; ?><?php if (!empty($_GET['add'])) echo '&add=true'; ?>" style="margin:0px;" <?php if ($ajax_search) {echo ' onsubmit="valide();"'; }?>>
     <legend><?php echo $tool_name.' ('.$session_info['name'].')'; ?></legend>
     <input type="hidden" name="formSent" value="1" />
 
@@ -229,7 +229,7 @@ unset($Courses);
                 <div id="ajax_list_courses_multiple">
                     <select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" class="form-control">
                         <?php foreach ($nosessionCourses as $enreg) { ?>
-                            <option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES).'"'; if(in_array($enreg['code'],$CourseList)) echo 'selected="selected"'; ?>>
+                            <option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')', ENT_QUOTES).'"'; if (in_array($enreg['code'], $CourseList)) echo 'selected="selected"'; ?>>
                                 <?php echo $enreg['title'].' ('.$enreg['visual_code'].')'; ?>
                             </option>
                         <?php } ?>
@@ -241,7 +241,7 @@ unset($Courses);
             ?>
         </div>
         <div class="col-md-4">
-            <?php if($add_type == 'multiple') { ?>
+            <?php if ($add_type == 'multiple') { ?>
                 <div class="code-course">
                     <?php echo get_lang('FirstLetterCourse'); ?> :
 
@@ -249,7 +249,7 @@ unset($Courses);
                         <option value="%">--</option>
                         <?php
                         echo Display :: get_alphabet_options();
-                        echo Display :: get_numeric_options(0,9,'');
+                        echo Display :: get_numeric_options(0, 9, '');
                         ?>
                     </select>
                 </div>
@@ -299,9 +299,9 @@ unset($Courses);
             <select id='destination' name="SessionCoursesList[]" multiple="multiple" size="20" class="form-control">
 
                 <?php
-                foreach($sessionCourses as $enreg) {
+                foreach ($sessionCourses as $enreg) {
                     ?>
-                    <option value="<?php echo $enreg['id']; ?>" title="<?php echo htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES); ?>">
+                    <option value="<?php echo $enreg['id']; ?>" title="<?php echo htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')', ENT_QUOTES); ?>">
                         <?php echo $enreg['title'].' ('.$enreg['visual_code'].')'; ?>
                     </option>
                 <?php

+ 39 - 39
main/ticket/tickets.php

@@ -10,7 +10,7 @@ require_once __DIR__.'/../inc/global.inc.php';
 
 api_block_anonymous_users();
 
-$tool_name = get_lang('LastEdit');
+$tool_name = get_lang('Ticket');
 
 $libPath = api_get_path(LIBRARY_PATH);
 $webLibPath = api_get_path(WEB_LIBRARY_PATH);
@@ -53,6 +53,9 @@ function display_advanced_search_form() {
 $this_section = 'tickets';
 unset($_SESSION['this_section']);
 
+$action = isset($_GET['action']) ? $_GET['action'] : '';
+$projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : 0;
+
 $table = new SortableTable(
     'Tickets',
     array('TicketManager', 'get_total_tickets_by_user_id'),
@@ -62,13 +65,12 @@ $table = new SortableTable(
     'DESC'
 );
 
+$table->set_additional_parameters(['project_id' => $projectId]);
+
 if ($table->per_page == 0) {
     $table->per_page = 20;
 }
 
-$action = isset($_GET['action']) ? $_GET['action'] : '';
-$projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : 0;
-
 switch ($action) {
     case 'alert':
         if (!$isAdmin && isset($_GET['ticket_id'])) {
@@ -123,24 +125,26 @@ if (empty($projectId)) {
     }
 }
 
+$currentUrl = api_get_self().'?project_id='.$projectId;
 $user_id = api_get_user_id();
 $isAdmin = api_is_platform_admin();
 
 Display::display_header(get_lang('MyTickets'));
 if (!empty($projectId)) {
+    $getParameters = [];
     if ($isAdmin) {
-    $getParameters = [
-        'keyword',
-        'keyword_status',
-        'keyword_category',
-        'keyword_request_user',
-        'keyword_admin',
-        'keyword_start_date',
-        'keyword_unread',
-        'Tickets_per_page',
-        'Tickets_column'
-    ];
-}
+        $getParameters = [
+            'keyword',
+            'keyword_status',
+            'keyword_category',
+            'keyword_request_user',
+            'keyword_admin',
+            'keyword_start_date',
+            'keyword_unread',
+            'Tickets_per_page',
+            'Tickets_column',
+        ];
+    }
     $get_parameter = '';
     foreach ($getParameters as $getParameter) {
         if (isset($_GET[$getParameter])) {
@@ -178,7 +182,7 @@ if (!empty($projectId)) {
         0 => get_lang('Unassigned')
     ];
     foreach ($admins as $admin) {
-        $selectAdmins[$admin['user_id']] = $admin['complete_name'];
+        $selectAdmins[$admin['user_id']] = $admin['complete_name_with_username'];
     }
     $status = TicketManager::get_all_tickets_status();
     $selectStatus = [];
@@ -186,12 +190,14 @@ if (!empty($projectId)) {
         $selectStatus[$stat['id']] = $stat['name'];
     }
 
+    $selectPriority = TicketManager::getPriorityList();
+    /*var_dump($priorities);
     $selectPriority = [
         '' => get_lang('All'),
         TicketManager::PRIORITY_NORMAL => get_lang('PriorityNormal'),
         TicketManager::PRIORITY_HIGH => get_lang('PriorityHigh'),
         TicketManager::PRIORITY_LOW => get_lang('PriorityLow')
-    ];
+    ];*/
 
     $selectStatusUnread = [
         '' => get_lang('StatusAll'),
@@ -200,9 +206,17 @@ if (!empty($projectId)) {
     ];
 
     // Create a search-box
-    $form = new FormValidator('search_simple', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
+    $form = new FormValidator(
+        'search_simple',
+        'get',
+        $currentUrl,
+        '',
+        array(),
+        FormValidator::LAYOUT_INLINE
+    );
     $form->addText('keyword', get_lang('Keyword'), 'size="25"');
     $form->addButtonSearch(get_lang('Search'), 'submit_simple');
+    $form->addHidden('project_id', $projectId);
     $form->addElement(
         'static',
         'search_advanced_link',
@@ -233,10 +247,12 @@ if (!empty($projectId)) {
     $advancedSearchForm = new FormValidator(
         'advanced_search',
         'get',
-        api_get_self().'?project_id='.$projectId,
+        $currentUrl,
         null,
         ['style' => 'display:"none"', 'id' => 'advanced_search_form']
     );
+
+    $advancedSearchForm->addHidden('project_id', $projectId);
     $advancedSearchForm->addHeader(get_lang('AdvancedSearch'));
     $advancedSearchForm->addSelect(
         'keyword_category',
@@ -265,41 +281,25 @@ if (!empty($projectId)) {
         $selectPriority,
         ['placeholder' => get_lang('All')]
     );
-    $advancedSearchForm->addSelect(
+    /*$advancedSearchForm->addSelect(
         'keyword_unread',
         get_lang('Status'),
         $selectStatusUnread,
         ['placeholder' => get_lang('All')]
-    );
+    );*/
     $advancedSearchForm->addText('keyword_course', get_lang('Course'), false);
     $advancedSearchForm->addButtonSearch(get_lang('AdvancedSearch'), 'submit_advanced');
     $advancedSearchForm->display();
 } else {
     if (api_get_setting('ticket_allow_student_add') === 'true') {
         echo '<div class="actions" >';
-        echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'ticket/new_ticket.php?project_id='.$projectId.'">' .
+        echo '<a href="' . api_get_path(WEB_CODE_PATH).'ticket/new_ticket.php?project_id='.$projectId.'">' .
                 Display::return_icon('add.png', get_lang('Add'), '', '32') .
              '</a>';
         echo '</div>';
     }
 }
 
-if (empty($projectId)) {
-    $table = new SortableTable(
-        'TicketProject',
-        array('TicketManager', 'getProjectsCount'),
-        array('TicketManager', 'getProjectsSimple'),
-        1
-    );
-
-    $table->set_header(0, '', false);
-    $table->set_header(1, get_lang('Title'), false);
-    $table->set_header(2, get_lang('Description'), true, array("style" => "width:200px"));
-
-    $table->display();
-    Display::display_footer();
-}
-
 if ($isAdmin) {
     $table->set_header(0, '#', true);
     $table->set_header(1, get_lang('Status'), true);

+ 8 - 6
src/Chamilo/CourseBundle/Component/CourseCopy/Course.php

@@ -24,7 +24,7 @@ class Course
      */
     public function __construct()
     {
-        $this->resources = array();
+        $this->resources = [];
         $this->code = '';
         $this->path = '';
         $this->backup_path = '';
@@ -67,6 +67,7 @@ class Course
      * @param int $resource_type Check if this course has resources of the
      * given type. If no type is given, check if course has resources of any
      * type.
+     * @return boolean
      */
     public function has_resources($resource_type = null)
     {
@@ -85,13 +86,12 @@ class Course
      */
     public function show()
     {
-
     }
 
     /**
      * Returns sample text based on the imported course content.
      * This sample text is to be used for course language or encoding detection if there is missing (meta)data in the archive.
-     * @return string	The resulting sample text extracted from some common resources' data fields.
+     * @return string    The resulting sample text extracted from some common resources' data fields.
      */
     public function get_sample_text()
     {
@@ -339,9 +339,11 @@ class Course
     }
 
     /**
-    * Unserialize the course with the best serializer available
-    * @param string $course
-    */
+     * Unserialize the course with the best serializer available
+     *
+     * @param string $course
+     * @return Course
+     */
     public static function unserialize($course)
     {
         if (extension_loaded('igbinary')) {

+ 8 - 13
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php

@@ -44,7 +44,6 @@ class CourseRecycler
     public function recycle($backupType)
     {
         if (empty($backupType)) {
-
             return false;
         }
 
@@ -106,7 +105,6 @@ class CourseRecycler
             // Delete all content in the documents.
             rmdirr($this->course->backup_path.'/document', true);
         } else {
-
             if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
                 foreach ($this->course->resources[RESOURCE_DOCUMENT] as $document) {
                     rmdirr($this->course->backup_path.'/'.$document->path);
@@ -156,10 +154,10 @@ class CourseRecycler
     public function recycle_glossary()
     {
         if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
-            $table_glossary	= Database::get_course_table(TABLE_GLOSSARY);
+            $table = Database::get_course_table(TABLE_GLOSSARY);
             $ids = implode(',', array_filter(array_keys($this->course->resources[RESOURCE_GLOSSARY])));
             if (!empty($ids)) {
-                $sql = "DELETE FROM ".$table_glossary."
+                $sql = "DELETE FROM $table
                         WHERE c_id = ".$this->course_id." AND glossary_id IN(".$ids.")";
                 Database::query($sql);
             }
@@ -230,7 +228,6 @@ class CourseRecycler
         }
 
         if ($this->course->has_resources(RESOURCE_FORUM)) {
-
             $forum_ids = implode(',', array_filter(array_keys($this->course->resources[RESOURCE_FORUM])));
 
             if (empty($forum_ids)) {
@@ -396,7 +393,6 @@ class CourseRecycler
     public function recycle_quizzes()
     {
         if ($this->course->has_resources(RESOURCE_QUIZ)) {
-
             $table_qui_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
             $table_qui_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
             $table_qui = Database::get_course_table(TABLE_QUIZ_TEST);
@@ -513,7 +509,6 @@ class CourseRecycler
 
             $ids = implode(',', array_filter(array_keys($this->course->resources[RESOURCE_SURVEY])));
             if (!empty($ids)) {
-
                 $sql = "DELETE FROM $table_survey_a
                         WHERE c_id = ".$this->course_id."  AND survey_id IN(".$ids.")";
                 Database::query($sql);
@@ -554,7 +549,7 @@ class CourseRecycler
                     if (trim($learnpath->path) != '') {
                         // when $learnpath->path value is incorrect for some reason.
                         // The directory trat contains files of the SCORM package is to be deleted.
-                        $scorm_package_dir = realpath($this->course->path . 'scorm/' . $learnpath->path);
+                        $scorm_package_dir = realpath($this->course->path.'scorm/'.$learnpath->path);
                         rmdirr($scorm_package_dir);
                     }
                 }
@@ -629,7 +624,7 @@ class CourseRecycler
             $resources = $this->course->resources;
             foreach ($resources[RESOURCE_THEMATIC] as $last_id => $thematic) {
                 if (is_numeric($last_id)) {
-                    foreach($thematic->thematic_advance_list as $thematic_advance) {
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
                         $cond = array(
                             'id = ? AND  c_id = ?' => array(
                                 $thematic_advance['id'],
@@ -646,7 +641,7 @@ class CourseRecycler
                         Database::delete($table_thematic_advance, $cond);
                     }
 
-                    foreach($thematic->thematic_plan_list as $thematic_plan) {
+                    foreach ($thematic->thematic_plan_list as $thematic_plan) {
                         $cond = array(
                             'id = ? AND  c_id = ?' => array(
                                 $thematic_plan['id'],
@@ -675,7 +670,7 @@ class CourseRecycler
                         'ThematicDeleted',
                         api_get_user_id()
                     );
-                    Database::delete($table_thematic,$cond);
+                    Database::delete($table_thematic, $cond);
                 }
             }
         }
@@ -693,7 +688,7 @@ class CourseRecycler
             $resources = $this->course->resources;
             foreach ($resources[RESOURCE_ATTENDANCE] as $last_id => $obj) {
                 if (is_numeric($last_id)) {
-                    foreach($obj->attendance_calendar as $attendance_calendar) {
+                    foreach ($obj->attendance_calendar as $attendance_calendar) {
                         $cond = array('id = ? AND c_id = ? '=>array($attendance_calendar['id'], $this->course_id));
                         Database::delete($table_attendance_calendar, $cond);
                     }
@@ -717,7 +712,7 @@ class CourseRecycler
     public function recycle_work($session_id = 0)
     {
         if ($this->course->has_resources(RESOURCE_WORK)) {
-            $table_work          = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+            $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
             $table_work_assignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
 
             $resources = $this->course->resources;

+ 24 - 21
src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php

@@ -17,14 +17,18 @@ use Chamilo\CourseBundle\Component\CourseCopy\Resources\Document;
  */
 class CourseSelectForm
 {
-	/**
-	 * Display the form
+    /**
+     * Display the form
      * @param array $course
-	 * @param array $hidden_fields Hidden fields to add to the form.
-	 * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
-	 */
-	public static function display_form($course, $hidden_fields = null, $avoid_serialize = false)
-    {
+     * @param array $hidden_fields Hidden fields to add to the form.
+     * @param boolean $avoid_serialize the document array will be serialize.
+     * This is used in the course_copy.php file
+     */
+    public static function display_form(
+        $course,
+        $hidden_fields = null,
+        $avoid_serialize = false
+    ) {
         global $charset;
         $resource_titles[RESOURCE_ASSET] = get_lang('Assets');
         $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook');
@@ -142,7 +146,7 @@ class CourseSelectForm
 		</script>
 		<?php
 		// get destination course title
-		if (!empty($hidden_fields['destination_course'])) {
+        if (!empty($hidden_fields['destination_course'])) {
             $sessionTitle = !empty($hidden_fields['destination_session']) ? ' ('.api_get_session_name($hidden_fields['destination_session']).')' : null;
             $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
 			echo '<h3>';
@@ -259,11 +263,9 @@ class CourseSelectForm
             foreach ($forum_categories as $forum_category_id => $forum_category) {
                 echo '<li>';
                 echo '<label class="checkbox">';
-
                 echo '<input type="checkbox" id="resource_'.RESOURCE_FORUMCATEGORY.'_'.$forum_category_id.'" my_rel="'.$forum_category_id.'" onclick="javascript:check_category(this);"  name="resource['.RESOURCE_FORUMCATEGORY.']['.$forum_category_id.']"  /> ';
                 $forum_category->show();
                 echo '</label>';
-
                 echo '</li>';
 
                 if (isset($forums[$forum_category_id])) {
@@ -394,7 +396,6 @@ class CourseSelectForm
 	public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
     {
         $course = null;
-
         if (isset($_POST['course'])) {
             $course = Course::unserialize(base64_decode($_POST['course']));
         } else {
@@ -415,23 +416,23 @@ class CourseSelectForm
 		if ($from === 'copy_course') {
 			if (is_array($resource)) {
 				$resource = array_keys($resource);
-
 				foreach ($resource as $resource_item) {
-
-					$condition_session = '';
+					$conditionSession = '';
 					if (!empty($session_id)) {
 						$session_id = intval($session_id);
-						$condition_session = ' AND d.session_id ='.$session_id;
+						$conditionSession = ' AND d.session_id ='.$session_id;
 					}
 
 					$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
-							FROM '.$table_doc.' d, '.$table_prop.' p
+							FROM '.$table_doc.' d 
+							INNER JOIN '.$table_prop.' p
+							ON (d.c_id = p.c_id)
 							WHERE
 							    d.c_id = '.$course_id.' AND
                                 p.c_id = '.$course_id.' AND
                                 tool = \''.TOOL_DOCUMENT.'\' AND
                                 p.ref = d.id AND p.visibility != 2 AND
-                                d.id = '.$resource_item.$condition_session.'
+                                d.id = '.$resource_item.$conditionSession.'
 							ORDER BY path';
 					$db_result = Database::query($sql);
 					while ($obj = Database::fetch_object($db_result)) {
@@ -465,7 +466,6 @@ class CourseSelectForm
 
 		if (is_array($course->resources)) {
 			foreach ($course->resources as $type => $resources) {
-
 				switch ($type) {
 					case RESOURCE_SURVEYQUESTION:
 						foreach ($resources as $id => $obj) {
@@ -592,9 +592,12 @@ class CourseSelectForm
 	 * @param array $hidden_fields Hidden fields to add to the form.
      * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
 	 */
-	 public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
-     {
-         ?>
+    public static function display_form_session_export(
+        $list_course,
+        $hidden_fields = null,
+        $avoid_serialize = false
+    ) {
+        ?>
 		<script>
 			function exp(item) {
 				el = document.getElementById('div_'+item);

+ 3 - 4
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Announcement.php

@@ -66,11 +66,10 @@ class Announcement extends Resource
         $this->date = $date;
         $this->display_order = $display_order;
         $this->email_sent = $email_sent;
-
-        $this->attachment_path 	= $path;
+        $this->attachment_path = $path;
         $this->attachment_filename = $filename;
-        $this->attachment_size 	= $size;
-        $this->attachment_comment 	= $comment;
+        $this->attachment_size = $size;
+        $this->attachment_comment = $comment;
     }
 
     /**

+ 11 - 11
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CalendarEvent.php

@@ -63,19 +63,19 @@ class CalendarEvent extends Resource
         $attachment_comment = null,
         $all_day = 0
     ) {
-		parent::__construct($id, RESOURCE_EVENT);
+        parent::__construct($id, RESOURCE_EVENT);
 
-		$this->title = $title;
-		$this->content = $content;
-		$this->start_date = $start_date;
-		$this->end_date = $end_date;
-		$this->all_day = $all_day;
+        $this->title = $title;
+        $this->content = $content;
+        $this->start_date = $start_date;
+        $this->end_date = $end_date;
+        $this->all_day = $all_day;
 
-		$this->attachment_path = $attachment_path;
-		$this->attachment_filename = $attachment_filename;
-		$this->attachment_size = $attachment_size;
-		$this->attachment_comment = $attachment_comment;
-	}
+        $this->attachment_path = $attachment_path;
+        $this->attachment_filename = $attachment_filename;
+        $this->attachment_size = $attachment_size;
+        $this->attachment_comment = $attachment_comment;
+    }
 
     /**
      * Show this Event

+ 111 - 112
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyLearnpath.php

@@ -84,120 +84,119 @@ class CourseCopyLearnpath extends Resource
      */
     public $author;
 
-	/**
-	 * Author's image
-	 */
-	public $preview_image;
-
-	/**
-	 * Create a new learnpath
-	 * @param integer ID
-	 * @param integer Type (1,2,3,...)
-	 * @param string $name
-	 * @param string $path
-	 * @param string $ref
-	 * @param string $description
-	 * @param string $content_local
-	 * @param string $default_encoding
-	 * @param string $default_view_mode
-	 * @param bool   $prevent_reinit
-	 * @param bool   $force_commit
-	 * @param string $content_maker
-	 * @param integer $display_order
-	 * @param string $js_lib
-	 * @param string $content_license
-	 * @param integer $debug
-	 * @param string $visibility
-	 * @param array  $items
-	 */
-	public function __construct(
-		$id,
-		$type,
-		$name,
-		$path,
-		$ref,
-		$description,
-		$content_local,
-		$default_encoding,
-		$default_view_mode,
-		$prevent_reinit,
-		$force_commit,
-		$content_maker,
-		$display_order,
-		$js_lib,
-		$content_license,
-		$debug,
-		$visibility,
-		$author,
-		$preview_image,
-		$use_max_score,
-		$autolaunch,
-		$created_on,
-		$modified_on,
-		$publicated_on,
-		$expired_on,
-		$session_id,
-		$items
-	) {
-		parent::__construct($id, RESOURCE_LEARNPATH);
-		$this->lp_type = $type;
-		$this->name = $name;
-		$this->path = $path;
-		$this->ref = $ref;
-		$this->description = $description;
-		$this->content_local = $content_local;
-		$this->default_encoding = $default_encoding;
-		$this->default_view_mod = $default_view_mode;
-		$this->prevent_reinit = $prevent_reinit;
-		$this->force_commit = $force_commit;
-		$this->content_maker = $content_maker;
-		$this->display_order = $display_order;
-		$this->js_lib = $js_lib;
-		$this->content_license = $content_license;
-		$this->debug = $debug;
-		$this->visibility = $visibility;
-
-		$this->use_max_score = $use_max_score;
-		$this->autolaunch = $autolaunch;
-		$this->created_on = $created_on;
-		$this->modified_on = $modified_on;
-		$this->publicated_on = $publicated_on;
-		$this->expired_on = $expired_on;
-		$this->session_id = $session_id;
+    /**
+     * Author's image
+     */
+    public $preview_image;
 
-		$this->author = $author;
-		$this->preview_image = $preview_image;
+    /**
+     * Create a new learnpath
+     * @param integer ID
+     * @param integer Type (1,2,3,...)
+     * @param string $name
+     * @param string $path
+     * @param string $ref
+     * @param string $description
+     * @param string $content_local
+     * @param string $default_encoding
+     * @param string $default_view_mode
+     * @param bool   $prevent_reinit
+     * @param bool   $force_commit
+     * @param string $content_maker
+     * @param integer $display_order
+     * @param string $js_lib
+     * @param string $content_license
+     * @param integer $debug
+     * @param string $visibility
+     * @param array  $items
+     */
+    public function __construct(
+        $id,
+        $type,
+        $name,
+        $path,
+        $ref,
+        $description,
+        $content_local,
+        $default_encoding,
+        $default_view_mode,
+        $prevent_reinit,
+        $force_commit,
+        $content_maker,
+        $display_order,
+        $js_lib,
+        $content_license,
+        $debug,
+        $visibility,
+        $author,
+        $preview_image,
+        $use_max_score,
+        $autolaunch,
+        $created_on,
+        $modified_on,
+        $publicated_on,
+        $expired_on,
+        $session_id,
+        $items
+    ) {
+        parent::__construct($id, RESOURCE_LEARNPATH);
+        $this->lp_type = $type;
+        $this->name = $name;
+        $this->path = $path;
+        $this->ref = $ref;
+        $this->description = $description;
+        $this->content_local = $content_local;
+        $this->default_encoding = $default_encoding;
+        $this->default_view_mod = $default_view_mode;
+        $this->prevent_reinit = $prevent_reinit;
+        $this->force_commit = $force_commit;
+        $this->content_maker = $content_maker;
+        $this->display_order = $display_order;
+        $this->js_lib = $js_lib;
+        $this->content_license = $content_license;
+        $this->debug = $debug;
+        $this->visibility = $visibility;
+        $this->use_max_score = $use_max_score;
+        $this->autolaunch = $autolaunch;
+        $this->created_on = $created_on;
+        $this->modified_on = $modified_on;
+        $this->publicated_on = $publicated_on;
+        $this->expired_on = $expired_on;
+        $this->session_id = $session_id;
+        $this->author = $author;
+        $this->preview_image = $preview_image;
+        $this->items = $items;
+    }
 
-		$this->items = $items;
-	}
-	/**
-	 * Get the items
-	 */
-	function get_items()
-	{
-		return $this->items;
-	}
+    /**
+     * Get the items
+     */
+    function get_items()
+    {
+        return $this->items;
+    }
 
-	/**
-	 * Check if a given resource is used as an item in this chapter
-	 */
-	function has_item($resource)
-	{
-		foreach ($this->items as $item) {
-			if ($item['id'] == $resource->get_id() &&
-				isset($item['type']) && $item['type'] == $resource->get_type()
-			) {
-				return true;
-			}
-		}
-		return false;
-	}
+    /**
+     * Check if a given resource is used as an item in this chapter
+     */
+    function has_item($resource)
+    {
+        foreach ($this->items as $item) {
+            if ($item['id'] == $resource->get_id() &&
+                isset($item['type']) && $item['type'] == $resource->get_type()
+            ) {
+                return true;
+            }
+        }
+        return false;
+    }
 
-	/**
-	 * Show this learnpath
-	 */
-	function show() {
-		parent::show();
-		echo $this->name;
-	}
+    /**
+     * Show this learnpath
+     */
+    function show()
+    {
+        parent::show();
+        echo $this->name;
+    }
 }

+ 1 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/CourseCopyTestCategory.php

@@ -35,7 +35,7 @@ class CourseCopyTestCategory extends Resource
     /**
      * Show the test_category title, used in the partial recycle_course.php form
      */
-    function show()
+    public function show()
     {
         parent::show();
         echo $this->title;

+ 0 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Forum.php

@@ -117,5 +117,4 @@ class Forum extends Resource
         parent::show();
         echo $this->obj->forum_title;
     }
-
 }

+ 8 - 0
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/QuizQuestion.php

@@ -97,6 +97,14 @@ class QuizQuestion extends Resource
 
     /**
      * Add an answer to this QuizQuestion
+     * @param int $answer_id
+     * @param string $answer_text
+     * @param string $correct
+     * @param string $comment
+     * @param string $ponderation
+     * @param string $position
+     * @param string $hotspot_coordinates
+     * @param string $hotspot_type
      */
     public function add_answer(
         $answer_id,

+ 1 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/ScormDocument.php

@@ -21,7 +21,7 @@ class ScormDocument extends Resource
      */
     public function __construct($id, $path, $title)
     {
-        parent::__construct($id,RESOURCE_SCORM);
+        parent::__construct($id, RESOURCE_SCORM);
         $this->path = 'scorm'.$path;
         $this->title = $title;
     }

+ 1 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Survey.php

@@ -80,7 +80,7 @@ class Survey extends Resource
      * @param string $lang
      * @param string $avail_from
      * @param string $avail_till
-     * @param char $is_shared
+     * @param string $is_shared
      * @param string $template
      * @param string $intro
      * @param string $surveythanks

+ 1 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/SurveyInvitation.php

@@ -33,7 +33,7 @@ class SurveyInvitation extends Resource
 
     /**
      * Create a new SurveyInvitation
-     * @param int	 $id
+     * @param int $id
      * @param string $code
      * @param string $user
      * @param string $invitation_code

+ 6 - 6
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/SurveyQuestion.php

@@ -47,15 +47,15 @@ class SurveyQuestion extends Resource
 
     /**
      * Create a new SurveyQuestion
-     * @param int	 $id
-     * @param int 	 $survey_id
+     * @param int $id
+     * @param int $survey_id
      * @param string $survey_question
      * @param string $survey_question_comment
      * @param string $type
      * @param string $display
-     * @param int	 $sort
-     * @param int	 $shared_question_id
-     * @param int	 $max_value
+     * @param int $sort
+     * @param int $shared_question_id
+     * @param int $max_value
      */
     public function __construct(
         $id,
@@ -83,7 +83,7 @@ class SurveyQuestion extends Resource
     /**
      * Add an answer option to this SurveyQuestion
      * @param string $option_text
-     * @param int	 $sort
+     * @param int $sort
      */
     public function add_answer($option_text,$sort)
     {

+ 1 - 2
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/ToolIntro.php

@@ -35,8 +35,7 @@ class ToolIntro extends Resource
     public function show()
     {
         parent::show();
-        switch ($this->id)
-        {
+        switch ($this->id) {
             case TOOL_DOCUMENT:
                 $lang_id = 'Documents';
                 break;

+ 1 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/Resources/Wiki.php

@@ -47,7 +47,7 @@ class Wiki extends Resource
         $progress,
         $version
     ) {
-        parent::__construct($id,RESOURCE_WIKI);
+        parent::__construct($id, RESOURCE_WIKI);
         $this->id = $id;
         $this->page_id = $page_id;
         $this->reflink = $reflink;

+ 1 - 1
src/Chamilo/CourseBundle/Entity/CToolIntro.php

@@ -94,7 +94,7 @@ class CToolIntro
     /**
      * Get id
      *
-     * @return string
+     * @return integer
      */
     public function getId()
     {

+ 17 - 4
tests/behat/features/bootstrap/FeatureContext.php

@@ -27,6 +27,7 @@ class FeatureContext extends MinkContext
         $this->pressButton('submitAuth');
         $this->getSession()->back();
     }
+
     /**
      * @Given /^I am a session administrator$/
      */
@@ -40,6 +41,7 @@ class FeatureContext extends MinkContext
         ]));
         $this->pressButton('submitAuth');
     }
+
     /**
      * @Given /^I am a teacher$/
      */
@@ -51,6 +53,7 @@ class FeatureContext extends MinkContext
         $this->fillField('password', 'mmosquera');
         $this->pressButton('submitAuth');
     }
+
     /**
      * @Given /^I am a teacher in course "([^"]*)"$/
      * @Todo implement
@@ -61,6 +64,7 @@ class FeatureContext extends MinkContext
         //$result = ...
         //if ($result !== false) { ... }
     }
+
     /**
      * @Given /^I am a student$/
      */
@@ -68,10 +72,11 @@ class FeatureContext extends MinkContext
     {
         $this->visit('/index.php?logout=logout');
         $this->iAmOnHomepage();
-        $this->fillField('login', 'mbrandybuck');
-        $this->fillField('password', 'mbrandybuck');
+        $this->fillField('login', 'acostea');
+        $this->fillField('password', 'acostea');
         $this->pressButton('submitAuth');
     }
+
     /**
      * @Given /^I am an HR manager$/
      */
@@ -83,6 +88,7 @@ class FeatureContext extends MinkContext
         $this->fillField('password', 'ptook');
         $this->pressButton('submitAuth');
     }
+
     /**
      * @Given /^I am a student boss$/
      */
@@ -94,6 +100,7 @@ class FeatureContext extends MinkContext
         $this->fillField('password', 'abaggins');
         $this->pressButton('submitAuth');
     }
+
     /**
      * @Given /^I am an invitee$/
      */
@@ -105,6 +112,7 @@ class FeatureContext extends MinkContext
         $this->fillField('password', 'bproudfoot');
         $this->pressButton('submitAuth');
     }
+
     /**
      * @Given /^course "([^"]*)" exists$/
      */
@@ -114,6 +122,7 @@ class FeatureContext extends MinkContext
         $this->visit('/main/admin/course_list.php?keyword=' . $argument);
         $this->assertPageContainsText($argument);
     }
+
     /**
      * @Given /^course "([^"]*)" is deleted$/
      */
@@ -123,6 +132,7 @@ class FeatureContext extends MinkContext
         $this->visit('/main/admin/course_list.php?keyword=' . $argument);
         $this->clickLink('Delete');
     }
+
     /**
      * @Given /^I am in course "([^"]*)"$/
      * @Todo redefine function to be different from I am on course TEMP homepage
@@ -132,6 +142,7 @@ class FeatureContext extends MinkContext
         $this->visit('/main/course_home/course_home.php?cDir=' . $argument);
         $this->assertElementNotOnPage('.alert-danger');
     }
+
     /**
      * @Given /^I am on course "([^"]*)" homepage$/
      */
@@ -140,6 +151,7 @@ class FeatureContext extends MinkContext
         $this->visit('/main/course_home/course_home.php?cDir=' . $argument);
         $this->assertElementNotOnPage('.alert-danger');
     }
+
     /**
      * @Given /^I am a "([^"]*)" user$/
      */
@@ -243,6 +255,7 @@ class FeatureContext extends MinkContext
         $this->selectOption('show_admin_toolbar', 'do_not_show');
         $this->pressButton('submit');
     }
+
     /**
      * @Given /^Admin top bar is enabled$/
      */
@@ -277,8 +290,8 @@ class FeatureContext extends MinkContext
     }
 
     /**
-   * @Then /^I fill in ckeditor field "([^"]*)" with "([^"]*)"$/
-   */
+     * @Then /^I fill in ckeditor field "([^"]*)" with "([^"]*)"$/
+     */
     public function iFillInWysiwygOnFieldWith($locator, $value)
     {
         // Just in case wait that ckeditor is loaded

+ 20 - 0
tests/behat/features/profile.feature

@@ -0,0 +1,20 @@
+Feature: Profile page
+  A student should update his profile information.
+
+  Background:
+    Given I am a student
+
+  Scenario: Update profile with first name Andrew then restore Andrea
+    Given I am on "/main/auth/profile.php"
+    When I fill in the following:
+      | firstname | Andrew |
+    And I press "Save settings"
+    And wait for the page to be loaded
+    Then I should see "Your new profile has been saved"
+    And I should see "Andrew"
+    Then I fill in the following:
+      | firstname | Andrea |
+    And I press "Save settings"
+    Then I should see "Your new profile has been saved"
+    Then I am on "/main/social/home.php"
+    Then I should see "Andrea"

+ 20 - 0
tests/behat/features/registration.feature

@@ -0,0 +1,20 @@
+Feature: User registration
+  In order to enter the system
+  I need to be able to create my account
+
+  Scenario: Enter the registration form
+    Given I am on the homepage
+    Then I should see "Sign up"
+    Then I follow "Sign up!"
+    Then I should see "Registration"
+    And I fill in the following:
+      | firstname     | user registration first name  |
+      | lastname      | user registration last name   |
+      | email         | user-registration@example.com |
+      | official_code | user registration             |
+      | username      | user_registration             |
+      | pass1         | user-registration             |
+      | pass2         | user-registration             |
+    And I press "Register"
+    And wait for the page to be loaded
+    Then I should see "Your personal settings have been registered"