Explorar el Código

Merge branch 'master' of https://github.com/chamilo/chamilo-lms

Alex Aragón hace 6 años
padre
commit
16fcbfa859

+ 25 - 1
main/admin/resource_sequence.php

@@ -39,7 +39,7 @@ if ($formSequence->validate()) {
     exit;
 }
 
-$selectSequence = new FormValidator('');
+$selectSequence = new FormValidator('frm_select_delete');
 $selectSequence->addHidden('sequence_type', 'session');
 $em = Database::getManager();
 
@@ -52,6 +52,30 @@ $selectSequence->addSelect(
     ['id' => 'sequence_id', 'cols-size' => [3, 7, 2]]
 );
 
+if (!empty($sequenceList)) {
+    $selectSequence->addButtonDelete(get_lang('Delete'));
+}
+
+if ($selectSequence->validate()) {
+    $values = $selectSequence->exportValues();
+
+    $sequence = $em->find('ChamiloCoreBundle:Sequence', $values['sequence']);
+
+    $em
+        ->createQuery('DELETE FROM ChamiloCoreBundle:SequenceResource sr WHERE sr.sequence = :seq')
+        ->execute(['seq' => $sequence]);
+
+    $em->remove($sequence);
+    $em->flush();
+
+    Display::addFlash(
+        Display::return_message(get_lang('Deleted'), 'success')
+    );
+
+    header('Location: '.api_get_self());
+    exit;
+}
+
 $form = new FormValidator('');
 $form->addHtml("<div class='col-md-6'>");
 $form->addHidden('sequence_type', 'session');

+ 2 - 95
main/admin/skills_import.php

@@ -101,76 +101,6 @@ function parse_csv_data($file)
     return $skills;
 }
 
-/**
- * XML-parser: handle start of element.
- */
-function element_start($parser, $data)
-{
-    $data = api_utf8_decode($data);
-    global $skill;
-    global $current_tag;
-    switch ($data) {
-        case 'Skill':
-            $skill = [];
-            break;
-        default:
-            $current_tag = $data;
-    }
-}
-
-/**
- * XML-parser: handle end of element.
- */
-function element_end($parser, $data)
-{
-    $data = api_utf8_decode($data);
-    global $skill;
-    global $skills;
-    global $current_value;
-    switch ($data) {
-        case 'Skill':
-            $skills[] = $skill;
-            break;
-        default:
-            $skill[$data] = $current_value;
-            break;
-    }
-}
-
-/**
- * XML-parser: handle character data.
- */
-function character_data($parser, $data)
-{
-    $data = trim(api_utf8_decode($data));
-    global $current_value;
-    $current_value = $data;
-}
-
-/**
- * Read the XML-file.
- *
- * @param string $file Path to the XML-file
- *
- * @return array All userinformation read from the file
- */
-function parse_xml_data($file)
-{
-    global $current_tag;
-    global $current_value;
-    global $skill;
-    global $skills;
-    $skills = [];
-    $parser = xml_parser_create('UTF-8');
-    xml_set_element_handler($parser, 'element_start', 'element_end');
-    xml_set_character_data_handler($parser, 'character_data');
-    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
-    xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
-    xml_parser_free($parser);
-
-    return $skills;
-}
-
 $this_section = SECTION_PLATFORM_ADMIN;
 api_protect_admin_script(true);
 
@@ -186,7 +116,7 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) {
     $file_type = $_POST['file_type'];
     Security::clear_token();
     $tok = Security::get_token();
-    $allowed_file_mimetype = ['csv', 'xml'];
+    $allowed_file_mimetype = ['csv'];
     $error_kind_file = false;
     $error_message = '';
 
@@ -197,10 +127,6 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) {
             $skills = parse_csv_data($_FILES['import_file']['tmp_name']);
             $errors = validate_data($skills);
             $error_kind_file = false;
-        } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) {
-            $skills = parse_xml_data($_FILES['import_file']['tmp_name']);
-            $errors = validate_data($skills);
-            $error_kind_file = false;
         } else {
             $error_kind_file = true;
         }
@@ -225,8 +151,6 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) {
 
     if (strcmp($file_type, 'csv') === 0) {
         save_data($skills_to_insert);
-    } elseif (strcmp($file_type, 'xml') === 0) {
-        save_data($skills_to_insert);
     } else {
         $error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
     }
@@ -275,7 +199,7 @@ $group[] = $form->createElement(
     'radio',
     'file_type',
     '',
-    'CSV (<a href="skill_example.csv" target="_blank">'.get_lang('ExampleCSVFile').'</a>)',
+    'CSV (<a href="skill_example.csv" target="_blank" download>'.get_lang('ExampleCSVFile').'</a>)',
     'csv'
 );
 $form->addGroup($group, '', get_lang('FileType'));
@@ -286,23 +210,6 @@ $defaults['file_type'] = 'csv';
 $form->setDefaults($defaults);
 $form->display();
 
-$list = [];
-$list_reponse = [];
-$result_xml = '';
-$i = 0;
-$count_fields = count($extra_fields);
-if ($count_fields > 0) {
-    foreach ($extra_fields as $extra) {
-        $list[] = $extra[1];
-        $list_reponse[] = 'xxx';
-        $spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-        $result_xml .= $spaces.'&lt;'.$extra[1].'&gt;xxx&lt;/'.$extra[1].'&gt;';
-        if ($i != $count_fields - 1) {
-            $result_xml .= '<br/>';
-        }
-        $i++;
-    }
-}
 ?>
 <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
 

+ 0 - 3
main/announcements/announcements.php

@@ -98,9 +98,6 @@ $logInfo = [
     'tool_id' => 0,
     'tool_id_detail' => 0,
     'action' => $action,
-    'action_details' => '',
-    'current_id' => (int) $announcement_id,
-    'info' => '',
 ];
 Event::registerLog($logInfo);
 

+ 0 - 2
main/chat/chat.php

@@ -15,8 +15,6 @@ $logInfo = [
     'tool_id_detail' => 0,
     'action' => 'start',
     'action_details' => 'start-chat',
-    'current_id' => 0,
-    'info' => '',
 ];
 Event::registerLog($logInfo);
 

+ 1 - 0
main/forum/reply.php

@@ -26,6 +26,7 @@ api_protect_course_script(true);
 
 $nameTools = get_lang('ForumCategories');
 $origin = api_get_origin();
+$_user = api_get_user_info();
 
 /* Including necessary files */
 require_once 'forumconfig.inc.php';

+ 1 - 0
main/forum/viewthread.php

@@ -22,6 +22,7 @@ $forumUrl = api_get_path(WEB_CODE_PATH).'forum/';
 
 // Are we in a lp ?
 $origin = api_get_origin();
+$_user = api_get_user_info();
 $my_search = null;
 
 /* MAIN DISPLAY SECTION */

+ 1 - 0
main/inc/ajax/agenda.ajax.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * Responses to AJAX calls.
  */

+ 9 - 11
main/inc/ajax/course_home.ajax.php

@@ -139,17 +139,17 @@ switch ($action) {
         require_once __DIR__.'/../global.inc.php';
 
         // Get the name of the database course.
-        $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
         $course_info = api_get_course_info($_GET['code']);
-
+        $content = get_lang('NoDescription');
+        if (!empty($course_info)) {
         if (api_get_setting('course_catalog_hide_private') === 'true' &&
             $course_info['visibility'] == COURSE_VISIBILITY_REGISTERED
         ) {
             echo get_lang('PrivateAccess');
             break;
         }
-
-        $sql = "SELECT * FROM $tbl_course_description
+            $table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
+            $sql = "SELECT * FROM $table
                 WHERE c_id = ".$course_info['real_id']." AND session_id = 0
                 ORDER BY id";
         $result = Database::query($sql);
@@ -157,17 +157,15 @@ switch ($action) {
             while ($description = Database::fetch_object($result)) {
                 $descriptions[$description->id] = $description;
             }
-            $extraField = new ExtraField('course');
-            $fieldValues = $extraField->getDataAndFormattedValues($course_info['real_id']);
 
-            // Function that displays the details of the course description in html.
-            echo CourseManager::get_details_course_description_html(
+                $content = CourseManager::get_details_course_description_html(
                 $descriptions,
-                $fieldValues
+                    api_get_system_encoding(),
+                    false
             );
-        } else {
-            echo get_lang('NoDescription');
         }
+        }
+        echo $content;
         break;
     case 'session_courses_lp_default':
         /**

+ 5 - 1
main/inc/ajax/exercise.ajax.php

@@ -730,7 +730,11 @@ switch ($action) {
         $objExercise = new Exercise();
         $objExercise->read($exerciseId);
         $objQuestion = Question::read($questionId);
-
+        $id = '';
+        if (api_get_configuration_value('show_question_id')) {
+            $id = '<h4>#'.$objQuestion->course['code'].'-'.$objQuestion->iid.'</h4>';
+        }
+        echo $id;
         echo '<p class="lead">'.$objQuestion->get_question_type_name().'</p>';
         if ($objQuestion->type === FILL_IN_BLANKS) {
             echo '<script>

+ 8 - 3
main/inc/ajax/model.ajax.php

@@ -842,7 +842,7 @@ switch ($action) {
             '*',
             $object->table,
             [
-                'where' => ["session_id = ? " => $sessionId],
+                'where' => ['session_id = ? ' => $sessionId],
                 'order' => "$sidx $sord",
                 'LIMIT' => "$start , $limit", ]
         );
@@ -1425,6 +1425,9 @@ switch ($action) {
         break;
     case 'get_sessions_tracking':
         if (api_is_drh() || api_is_session_admin()) {
+            $orderByName = Database::escape_string($sidx);
+            $orderByName = in_array($orderByName, ['name', 'access_start_date']) ? $orderByName : 'name';
+            $orderBy = " ORDER BY $orderByName $sord";
             $sessions = SessionManager::get_sessions_followed_by_drh(
                 api_get_user_id(),
                 $start,
@@ -1432,7 +1435,7 @@ switch ($action) {
                 false,
                 false,
                 false,
-                null,
+                $orderBy,
                 $keyword,
                 $description
             );
@@ -1444,7 +1447,9 @@ switch ($action) {
                 $limit,
                 false,
                 $keyword,
-                $description
+                $description,
+                $sidx,
+                $sord
             );
         }
 

+ 25 - 5
main/inc/ajax/sequence.ajax.php

@@ -42,12 +42,24 @@ switch ($action) {
                     $graphviz = new GraphViz();
                     $graphImage = '';
                     try {
-                        $graphImage = $graphviz->createImageHtml($graph);
+                        $graphImage = $graphviz->createImageSrc($graph);
+
+                        echo Display::img(
+                            $graphImage,
+                            get_lang('GraphDependencyTree'),
+                            ['class' => 'center-block'],
+                            false
+                        );
                     } catch (UnexpectedValueException $e) {
-                        error_log($e->getMessage().' - Graph could not be rendered in resources sequence because GraphViz command "dot" could not be executed - Make sure graphviz is installed.');
-                        $graphImage = '<p class="text-center"><small>'.get_lang('MissingChartLibraryPleaseCheckLog').'</small></p>';
+                        error_log(
+                            $e->getMessage()
+                            .' - Graph could not be rendered in resources sequence'
+                            .' because GraphViz command "dot" could not be executed '
+                            .'- Make sure graphviz is installed.'
+                        );
+                        echo '<p class="text-center"><small>'.get_lang('MissingChartLibraryPleaseCheckLog')
+                            .'</small></p>';
                     }
-                    echo $graphImage;
                 }
                 break;
         }
@@ -94,7 +106,15 @@ switch ($action) {
                     $link .= '<div class="big-icon">';
                     $link .= $image;
                     $link .= '<div class="sequence-course">'.$sessionInfo['name'].'</div>';
-                    $link .= '<a href="#" class="sequence-id">'.$id.'</a>';
+                    $link .= Display::tag(
+                        'button',
+                        $id,
+                        [
+                            'class' => 'sequence-id',
+                            'title' => get_lang('UseAsReference'),
+                            'type' => 'button',
+                        ]
+                    );
                     $link .= $linkDelete;
                     $link .= $linkUndo;
                     $link .= '</div></div>';

+ 15 - 13
main/inc/ajax/user_manager.ajax.php

@@ -14,21 +14,23 @@ $action = $_GET['a'];
 
 switch ($action) {
     case 'get_user_like':
-        $query = $_REQUEST['q'];
-        $conditions = [
-            'username' => $query,
-            'firstname' => $query,
-            'lastname' => $query,
-        ];
-        $users = UserManager::getUserListLike($conditions, [], false, 'OR');
-        $result = [];
-        if (!empty($users)) {
-            foreach ($users as $user) {
-                $result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
+        if (api_is_platform_admin() || api_is_drh()) {
+            $query = $_REQUEST['q'];
+            $conditions = [
+                'username' => $query,
+                'firstname' => $query,
+                'lastname' => $query,
+            ];
+            $users = UserManager::getUserListLike($conditions, [], false, 'OR');
+            $result = [];
+            if (!empty($users)) {
+                foreach ($users as $user) {
+                    $result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
+                }
+                $result['items'] = $result;
             }
-            $result['items'] = $result;
+            echo json_encode($result);
         }
-        echo json_encode($result);
         break;
     case 'get_user_popup':
         $courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;

+ 2 - 1
main/inc/ajax/work.ajax.php

@@ -64,7 +64,8 @@ switch ($action) {
 
                 $json = [];
                 if (!empty($result) && is_array($result) && empty($result['error'])) {
-                    $json['name'] = Display::url(
+                    $json['name'] = api_htmlentities($result['title']);
+                    $json['link'] = Display::url(
                         api_htmlentities($result['title']),
                         api_htmlentities($result['view_url']),
                         ['target' => '_blank']

+ 32 - 32
main/inc/lib/TicketManager.php

@@ -50,6 +50,7 @@ class TicketManager
         $table_support_project = Database::get_main_table(TABLE_TICKET_PROJECT);
 
         $order = empty($order) ? 'category.total_tickets DESC' : $order;
+        $order = Database::escape_string($order);
         $projectId = (int) $projectId;
 
         $sql = "SELECT 
@@ -89,9 +90,9 @@ class TicketManager
         if (!in_array($direction, ['ASC', 'DESC'])) {
             $direction = 'ASC';
         }
-        $column = intval($column);
-        $from = intval($from);
-        $numberItems = intval($numberItems);
+        $column = (int) $column;
+        $from = (int) $from;
+        $numberItems = (int) $numberItems;
 
         //$sql .= " ORDER BY col$column $direction ";
         $sql .= " LIMIT $from,$numberItems";
@@ -166,7 +167,7 @@ class TicketManager
      */
     public static function deleteCategory($id)
     {
-        $id = intval($id);
+        $id = (int) $id;
         if (empty($id)) {
             return false;
         }
@@ -260,7 +261,7 @@ class TicketManager
     public static function get_all_tickets_status()
     {
         $table = Database::get_main_table(TABLE_TICKET_STATUS);
-        $sql = "SELECT * FROM ".$table;
+        $sql = "SELECT * FROM $table";
         $result = Database::query($sql);
         $types = [];
         while ($row = Database::fetch_assoc($result)) {
@@ -590,11 +591,11 @@ class TicketManager
             return false;
         }
 
-        $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
         $ticket = self::get_ticket_detail_by_id($ticketId);
 
         if ($ticket) {
-            $sql = "UPDATE $table_support_tickets
+            $table = Database::get_main_table(TABLE_TICKET_TICKET);
+            $sql = "UPDATE $table
                     SET assigned_last_user = $userId
                     WHERE id = $ticketId";
             Database::query($sql);
@@ -641,10 +642,13 @@ class TicketManager
         $table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
         $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
         if ($sendConfirmation) {
-            $form = '<form action="ticket_details.php?ticket_id='.$ticketId.'" id="confirmticket" method="POST" >
+            $form =
+                '<form action="ticket_details.php?ticket_id='.$ticketId.'" id="confirmticket" method="POST" >
                          <p>'.get_lang('TicketWasThisAnswerSatisfying').'</p>
-                         <button class="btn btn-primary responseyes" name="response" id="responseyes" value="1">'.get_lang('Yes').'</button>
-                         <button class="btn btn-danger responseno" name="response" id="responseno" value="0">'.get_lang('No').'</button>
+                     <button class="btn btn-primary responseyes" name="response" id="responseyes" value="1">'.
+                get_lang('Yes').'</button>
+                     <button class="btn btn-danger responseno" name="response" id="responseno" value="0">'.
+                get_lang('No').'</button>
                      </form>';
             $content .= $form;
         }
@@ -713,7 +717,7 @@ class TicketManager
     ) {
         $now = api_get_utc_datetime();
         $userId = api_get_user_id();
-        $ticketId = intval($ticketId);
+        $ticketId = (int) $ticketId;
         $new_file_name = add_ext_on_mime(
             stripslashes($file_attach['name']),
             $file_attach['type']
@@ -986,7 +990,7 @@ class TicketManager
             }
             if ($isAdmin) {
                 $ticket['0'] .= '&nbsp;&nbsp;<a  href="javascript:void(0)" onclick="load_history_ticket(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')">
-					<img onclick="load_course_list(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')" onmouseover="clear_course_list (\'div_'.$row['ticket_id'].'\')" src="'.Display::returnIconPath('history.png').'" title="'.get_lang('Historial').'" alt="'.get_lang('Historial').'"/>
+					<img onclick="load_course_list(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')" onmouseover="clear_course_list (\'div_'.$row['ticket_id'].'\')" src="'.Display::returnIconPath('history.gif').'" title="'.get_lang('Historial').'" alt="'.get_lang('Historial').'"/>
 					<div class="blackboard_hide" id="div_'.$row['ticket_id'].'">&nbsp;&nbsp;</div>
 					</a>&nbsp;&nbsp;';
             }
@@ -1144,7 +1148,7 @@ class TicketManager
      */
     public static function get_ticket_detail_by_id($ticketId)
     {
-        $ticketId = intval($ticketId);
+        $ticketId = (int) $ticketId;
         $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);
@@ -1232,7 +1236,8 @@ class TicketManager
                 $result_attach = Database::query($sql);
                 while ($row2 = Database::fetch_assoc($result_attach)) {
                     $archiveURL = $webPath.'ticket/download.php?ticket_id='.$ticketId.'&id='.$row2['id'];
-                    $row2['attachment_link'] = $attach_icon.'&nbsp;<a href="'.$archiveURL.'">'.$row2['filename'].'</a>&nbsp;('.$row2['size'].')';
+                    $row2['attachment_link'] = $attach_icon.
+                        '&nbsp;<a href="'.$archiveURL.'">'.$row2['filename'].'</a>&nbsp;('.$row2['size'].')';
                     $message['attachments'][] = $row2;
                 }
                 $ticket['messages'][] = $message;
@@ -1250,11 +1255,9 @@ class TicketManager
      */
     public static function update_message_status($ticketId, $userId)
     {
-        $ticketId = intval($ticketId);
-        $userId = intval($userId);
-        $table_support_messages = Database::get_main_table(
-            TABLE_TICKET_MESSAGE
-        );
+        $ticketId = (int) $ticketId;
+        $userId = (int) $userId;
+        $table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
         $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
         $now = api_get_utc_datetime();
         $sql = "UPDATE $table_support_messages
@@ -1433,11 +1436,11 @@ class TicketManager
     ) {
         $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
 
-        $ticketId = intval($ticketId);
-        $status_id = intval($status_id);
-        $userId = intval($userId);
-
+        $ticketId = (int) $ticketId;
+        $status_id = (int) $status_id;
+        $userId = (int) $userId;
         $now = api_get_utc_datetime();
+
         $sql = "UPDATE $table_support_tickets
                 SET
                     status_id = '$status_id',
@@ -1465,9 +1468,7 @@ class TicketManager
     public static function getNumberOfMessages()
     {
         $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
-        $table_support_messages = Database::get_main_table(
-            TABLE_TICKET_MESSAGE
-        );
+        $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);
         $user_info = api_get_user_info();
@@ -1520,8 +1521,8 @@ class TicketManager
      */
     public static function close_ticket($ticketId, $userId)
     {
-        $ticketId = intval($ticketId);
-        $userId = intval($userId);
+        $ticketId = (int) $ticketId;
+        $userId = (int) $userId;
 
         $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
         $now = api_get_utc_datetime();
@@ -1570,7 +1571,7 @@ class TicketManager
     public static function get_assign_log($ticketId)
     {
         $table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
-        $ticketId = intval($ticketId);
+        $ticketId = (int) $ticketId;
 
         $sql = "SELECT * FROM $table
                 WHERE ticket_id = $ticketId
@@ -1612,8 +1613,8 @@ class TicketManager
         $direction,
         $userId = null
     ) {
-        $from = intval($from);
-        $number_of_items = intval($number_of_items);
+        $from = (int) $from;
+        $number_of_items = (int) $number_of_items;
         $table_support_category = Database::get_main_table(
             TABLE_TICKET_CATEGORY
         );
@@ -2274,7 +2275,6 @@ class TicketManager
      */
     public static function getSettingsMenuItems($exclude = null)
     {
-        $items = [];
         $project = [
             'icon' => 'project.png',
             'url' => 'projects.php',

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

@@ -253,6 +253,8 @@ define('LOG_USER_ID', 'user_id');
 define('LOG_USER_OBJECT', 'user_object');
 define('LOG_USER_FIELD_VARIABLE', 'user_field_variable');
 define('LOG_SESSION_ID', 'session_id');
+
+define('LOG_QUESTION_ID', 'question_id');
 define('LOG_SESSION_CATEGORY_ID', 'session_category_id');
 define('LOG_CONFIGURATION_SETTINGS_CATEGORY', 'settings_category');
 define('LOG_CONFIGURATION_SETTINGS_VARIABLE', 'settings_variable');
@@ -279,9 +281,11 @@ define('LOG_MY_FOLDER_NEW_PATH', 'new_path');
 define('LOG_TERM_CONDITION_ACCEPTED', 'term_condition_accepted');
 define('LOG_USER_CONFIRMED_EMAIL', 'user_confirmed_email');
 define('LOG_USER_REMOVED_LEGAL_ACCEPT', 'user_removed_legal_accept');
-
 define('LOG_USER_DELETE_ACCOUNT_REQUEST', 'user_delete_account_request');
 
+define('LOG_QUESTION_CREATED', 'question_created');
+define('LOG_QUESTION_UPDATED', 'question_updated');
+
 define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.]/');
 
 //used when login_is_email setting is true

+ 20 - 24
main/lp/learnpath.class.php

@@ -6941,24 +6941,21 @@ class learnpath
         $creatorId = empty($creatorId) ? api_get_user_id() : $creatorId;
 
         $folder = false;
-        //if (!is_dir($filepath.'/'.$dir)) {
         $folderData = create_unexisting_directory(
-                $course,
-                $creatorId,
-                0,
-                null,
-                0,
-                $filepath,
-                $dir,
-                get_lang('LearningPaths'),
-                0
-            );
+            $course,
+            $creatorId,
+            0,
+            null,
+            0,
+            $filepath,
+            $dir,
+            get_lang('LearningPaths'),
+            0
+        );
+
         if (!empty($folderData)) {
             $folder = true;
         }
-        /*} else {
-            $folder = true;
-        }*/
 
         return $folder;
     }
@@ -6990,17 +6987,16 @@ class learnpath
         $documentId = null;
         if ($folder) {
             $filepath = api_get_path(SYS_COURSE_PATH).$course['path'].'/document';
-            //if (!is_dir($filepath.'/'.$dir)) {
             $folderData = create_unexisting_directory(
-                    $course,
-                    $creatorId,
-                    0,
-                    0,
-                    0,
-                    $filepath,
-                    $dir,
-                    $lp_name
-                );
+                $course,
+                $creatorId,
+                0,
+                0,
+                0,
+                $filepath,
+                $dir,
+                $lp_name
+            );
             if (!empty($folderData)) {
                 $folder = true;
             }

+ 20 - 14
main/work/work.lib.php

@@ -109,11 +109,9 @@ function get_work_data_by_path($path, $courseId = 0)
  */
 function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
 {
-    $id = intval($id);
-    $courseId = intval($courseId);
-    if (empty($courseId)) {
-        $courseId = api_get_course_int_id();
-    }
+    $id = (int) $id;
+    $courseId = ((int) $courseId) ?: api_get_course_int_id();
+    $course = api_get_course_entity($courseId);
     $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
 
     $sessionCondition = '';
@@ -121,6 +119,8 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
         $sessionCondition = api_get_session_condition($sessionId, true);
     }
 
+    $webCodePath = api_get_path(WEB_CODE_PATH);
+
     $sql = "SELECT * FROM $table
             WHERE
                 id = $id AND c_id = $courseId
@@ -132,17 +132,23 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
         if (empty($work['title'])) {
             $work['title'] = basename($work['url']);
         }
-        $work['download_url'] = api_get_path(WEB_CODE_PATH).'work/download.php?id='.$work['id'].'&'.api_get_cidreq();
-        $work['view_url'] = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
-        $work['show_url'] = api_get_path(WEB_CODE_PATH).'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
+        $work['download_url'] = $webCodePath.'work/download.php?id='.$work['id'].'&'.api_get_cidreq();
+        $work['view_url'] = $webCodePath.'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
+        $work['show_url'] = $webCodePath.'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
         $work['show_content'] = '';
         if ($work['contains_file']) {
-            $fileInfo = pathinfo($work['title']);
-            if (is_array($fileInfo) &&
-                !empty($fileInfo['extension']) &&
-                in_array($fileInfo['extension'], ['jpg', 'png', 'gif'])
-            ) {
-                $work['show_content'] = '<img src="'.$work['show_url'].'"/>';
+            $fileType = mime_content_type(
+                api_get_path(SYS_COURSE_PATH).$course->getDirectory().'/'.$work['url']
+            );
+
+            if (in_array($fileType, ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'])) {
+                $work['show_content'] = Display::img($work['show_url'], $work['title']);
+            } elseif (false !== strpos($fileType, 'video/')) {
+                $work['show_content'] = Display::tag(
+                    'video',
+                    get_lang('FileFormatNotSupported'),
+                    ['src' => $work['show_url']]
+                );
             }
         }
 

+ 0 - 2
main/work/work.php

@@ -126,8 +126,6 @@ $logInfo = [
     'tool_id_detail' => 0,
     'action' => $action,
     'action_details' => '',
-    'current_id' => isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0,
-    'info' => '',
 ];
 Event::registerLog($logInfo);
 

+ 0 - 1
src/CoreBundle/Component/Editor/Driver/CourseDriver.php

@@ -39,7 +39,6 @@ class CourseDriver extends Driver implements DriverInterface
             if (!file_exists($baseDir.'/shared_folder')) {
                 $title = get_lang('UserFolders');
                 $folderName = '/shared_folder';
-
                 $visibility = 0;
                 create_unexisting_directory(
                     $courseInfo,