Sfoglia il codice sorgente

Minor - update from 1.11.x

Julio Montoya 6 anni fa
parent
commit
f729b4b81b

+ 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);
 

+ 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);