Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 93... Línea 93...
93
     * Obtains an array of supported extensions in the given context.
93
     * Obtains an array of supported extensions in the given context.
94
     *
94
     *
95
     * @param context $context Optional context to check (default null)
95
     * @param context $context Optional context to check (default null)
96
     * @return array The array with all the extensions supported and the supporting plugin names.
96
     * @return array The array with all the extensions supported and the supporting plugin names.
97
     */
97
     */
98
    public function load_context_supported_extensions(context $context = null): array {
98
    public function load_context_supported_extensions(?context $context = null): array {
99
        $extensionscache = \cache::make('core', 'contentbank_context_extensions');
99
        $extensionscache = \cache::make('core', 'contentbank_context_extensions');
Línea 100... Línea 100...
100
 
100
 
101
        $contextextensions = $extensionscache->get($context->id);
101
        $contextextensions = $extensionscache->get($context->id);
102
        if ($contextextensions === false) {
102
        if ($contextextensions === false) {
Línea 122... Línea 122...
122
     * Mainly to use as filepicker options parameter.
122
     * Mainly to use as filepicker options parameter.
123
     *
123
     *
124
     * @param context $context   Optional context to check (default null)
124
     * @param context $context   Optional context to check (default null)
125
     * @return string A string with all the extensions supported.
125
     * @return string A string with all the extensions supported.
126
     */
126
     */
127
    public function get_supported_extensions_as_string(context $context = null) {
127
    public function get_supported_extensions_as_string(?context $context = null) {
128
        $supported = $this->load_context_supported_extensions($context);
128
        $supported = $this->load_context_supported_extensions($context);
129
        $extensions = array_keys($supported);
129
        $extensions = array_keys($supported);
130
        return implode(',', $extensions);
130
        return implode(',', $extensions);
131
    }
131
    }
Línea 149... Línea 149...
149
     *
149
     *
150
     * @param string $extension Content file extension
150
     * @param string $extension Content file extension
151
     * @param context $context $context     Optional context to check (default null)
151
     * @param context $context $context     Optional context to check (default null)
152
     * @return string contenttype name supports the file extension or null if the extension is not supported by any allowed plugin.
152
     * @return string contenttype name supports the file extension or null if the extension is not supported by any allowed plugin.
153
     */
153
     */
154
    public function get_extension_supporter(string $extension, context $context = null): ?string {
154
    public function get_extension_supporter(string $extension, ?context $context = null): ?string {
155
        $supporters = $this->load_context_supported_extensions($context);
155
        $supporters = $this->load_context_supported_extensions($context);
156
        if (array_key_exists($extension, $supporters)) {
156
        if (array_key_exists($extension, $supporters)) {
157
            return $supporters[$extension];
157
            return $supporters[$extension];
158
        }
158
        }
159
        return null;
159
        return null;
Línea 328... Línea 328...
328
     * @param null|\context $context Optional context to check the permission to use the feature.
328
     * @param null|\context $context Optional context to check the permission to use the feature.
329
     * @param bool $enabled Whether check only the enabled content types or all of them.
329
     * @param bool $enabled Whether check only the enabled content types or all of them.
330
     *
330
     *
331
     * @return string[] List of content types where the user has permission to access the feature.
331
     * @return string[] List of content types where the user has permission to access the feature.
332
     */
332
     */
333
    public function get_contenttypes_with_capability_feature(string $feature, \context $context = null, bool $enabled = true): array {
333
    public function get_contenttypes_with_capability_feature(string $feature, ?\context $context = null, bool $enabled = true): array {
334
        $contenttypes = [];
334
        $contenttypes = [];
335
        // Check enabled content types or all of them.
335
        // Check enabled content types or all of them.
336
        if ($enabled) {
336
        if ($enabled) {
337
            $contenttypestocheck = $this->get_enabled_content_types();
337
            $contenttypestocheck = $this->get_enabled_content_types();
338
        } else {
338
        } else {