Passed
Push — master ( 621302...15a517 )
by Angel Fernando Quiroz
16:26 queued 07:49
created

OnlyofficePlugin::isExtensionAllowed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 1
dl 0
loc 17
rs 9.8333
c 0
b 0
f 0
1
<?php
2
/**
3
 * (c) Copyright Ascensio System SIA 2025.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/**
19
 * Plugin class for the Onlyoffice plugin.
20
 *
21
 * @author Asensio System SIA
22
 */
23
class OnlyofficePlugin extends Plugin
24
{
25
    /**
26
     * OnlyofficePlugin constructor.
27
     */
28
    protected function __construct()
29
    {
30
        parent::__construct(
31
            '1.5.0',
32
            'Asensio System SIA',
33
            [
34
                'enable_onlyoffice_plugin' => 'boolean',
35
                'document_server_url' => 'text',
36
                'jwt_secret' => 'text',
37
                'jwt_header' => 'text',
38
                'document_server_internal' => 'text',
39
                'storage_url' => 'text',
40
            ]
41
        );
42
    }
43
44
    /**
45
     * Create OnlyofficePlugin object.
46
     */
47
    public static function create(): OnlyofficePlugin
48
    {
49
        static $result = null;
50
51
        return $result ?: $result = new self();
52
    }
53
54
    /**
55
     * This method installs the plugin tables.
56
     */
57
    public function install()
58
    {
59
    }
60
61
    /**
62
     * This method drops the plugin tables.
63
     */
64
    public function uninstall()
65
    {
66
    }
67
68
    /**
69
     * Get link to plugin settings.
70
     */
71
    public function getConfigLink(): string
72
    {
73
        return api_get_path(WEB_PATH).'main/admin/configure_plugin.php?name='.$this->get_name();
74
    }
75
76
    public static function isExtensionAllowed(string $extension): bool
77
    {
78
        $officeExtensions = [
79
            'ppt',
80
            'pptx',
81
            'odp',
82
            'xls',
83
            'xlsx',
84
            'ods',
85
            'csv',
86
            'doc',
87
            'docx',
88
            'odt',
89
            'pdf',
90
        ];
91
92
        return in_array($extension, $officeExtensions);
93
    }
94
}
95