Issues (2130)

main/upload/upload_ppt.php (1 issue)

Labels
Severity
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
5
6
/**
7
 * Action controller for the upload process. The display scripts (web forms) redirect
8
 * the process here to do what needs to be done with each file.
9
 *
10
 * @package chamilo.upload
11
 *
12
 * @author Yannick Warnier <[email protected]>
13
 */
14
require_once __DIR__.'/../inc/global.inc.php';
15
16
api_protect_course_script(true);
17
18
if (isset($_POST['convert'])) {
19
    $cwdir = getcwd();
20
    if (isset($_FILES['user_file'])) {
21
        $allowed_extensions = ['odp', 'sxi', 'ppt', 'pps', 'sxd', 'pptx'];
22
        if (in_array(
23
            strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)),
24
            $allowed_extensions
25
        )) {
26
            require_once api_get_path(SYS_CODE_PATH).'lp/lp_upload.php';
27
            if (isset($o_ppt) && $first_item_id != 0) {
28
                if (api_get_setting('search_enabled') == 'true') {
29
                    require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
30
                    $specific_fields = get_specific_field_list();
31
                    foreach ($specific_fields as $specific_field) {
32
                        $values = explode(',', trim($_POST[$specific_field['code']]));
33
                        if (!empty($values)) {
34
                            foreach ($values as $value) {
35
                                $value = trim($value);
36
                                if (!empty($value)) {
37
                                    add_specific_field_value(
38
                                        $specific_field['id'],
39
                                        api_get_course_id(),
40
                                        TOOL_LEARNPATH,
41
                                        $o_ppt->lp_id,
42
                                        $value
43
                                    );
44
                                }
45
                            }
46
                        }
47
                    }
48
                }
49
                header('Location: ../lp/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
50
                exit;
51
            } else {
52
                if (!empty($o_ppt->error)) {
53
                    $errorMessage = $o_ppt->error;
54
                } else {
55
                    $errorMessage = get_lang('OogieUnknownError');
56
                }
57
            }
58
        } else {
59
            $errorMessage = get_lang('OogieBadExtension');
60
        }
61
    }
62
}
63
64
Event::event_access_tool(TOOL_UPLOAD);
0 ignored issues
show
The method event_access_tool() does not exist on Event. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
Event::/** @scrutinizer ignore-call */ 
65
       event_access_tool(TOOL_UPLOAD);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
65
66
// check access permissions (edit permission is needed to add a document or a LP)
67
$is_allowed_to_edit = api_is_allowed_to_edit();
68
69
if (!$is_allowed_to_edit) {
70
    api_not_allowed(true);
71
}
72
73
$interbreadcrumb[] = ["url" => "../lp/lp_controller.php?action=list", "name" => get_lang("Doc")];
74
75
$nameTools = get_lang("OogieConversionPowerPoint");
76
Display::display_header($nameTools);
77
$message = get_lang("WelcomeOogieConverter");
78
79
if (!empty($errorMessage)) {
80
    echo Display::return_message($errorMessage, 'warning', false);
81
}
82
83
$div_upload_limit = get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
84
85
$form = new FormValidator('upload_ppt', 'POST', '?'.api_get_cidreq(), '');
86
$form->addElement('header', get_lang("WelcomeOogieSubtitle"));
87
$form->addElement('html', Display::return_message($message, 'info', false));
88
$form->addElement('file', 'user_file', [Display::return_icon('powerpoint_big.gif'), $div_upload_limit]);
89
$form->addElement('checkbox', 'take_slide_name', '', get_lang('TakeSlideName'));
90
$options = ChamiloApi::getDocumentConversionSizes();
91
$form->addElement('select', 'slide_size', get_lang('SlideSize'), $options);
92
if (api_get_setting('search_enabled') === 'true') {
93
    require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
94
    $specific_fields = get_specific_field_list();
95
    $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
96
    $form->addSelectLanguage('language', get_lang('SearchFeatureDocumentLanguage'));
97
    foreach ($specific_fields as $specific_field) {
98
        $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
99
    }
100
}
101
102
$form->addButtonUpload(get_lang('ConvertToLP'), 'convert');
103
$form->addElement('hidden', 'ppt2lp', 'true');
104
$form->addProgress();
105
$size = api_get_setting('service_ppt2lp', 'size');
106
$defaults = [
107
    'take_slide_name' => 'checked="checked"',
108
    'index_document' => 'checked="checked"',
109
    'slide_size' => $size,
110
];
111
$form->setDefaults($defaults);
112
113
// display the form
114
$form->display();
115
Display::display_footer();
116