Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
declare(strict_types=1);
17
declare(strict_types=1);
Línea 18... Línea -...
18
 
-
 
19
namespace core_files\reportbuilder\local\entities;
-
 
20
 
18
 
21
use context;
19
namespace core_files\reportbuilder\local\entities;
22
use context_helper;
-
 
23
use core_collator;
20
 
24
use core_filetypes;
21
use core_collator;
25
use html_writer;
22
use core_filetypes;
26
use lang_string;
23
use lang_string;
27
use license_manager;
24
use license_manager;
Línea 46... Línea 43...
46
     * @return string[]
43
     * @return string[]
47
     */
44
     */
48
    protected function get_default_tables(): array {
45
    protected function get_default_tables(): array {
49
        return [
46
        return [
50
            'files',
47
            'files',
-
 
48
        ];
-
 
49
    }
-
 
50
 
-
 
51
    /**
-
 
52
     * Database tables that this entity no longer uses
-
 
53
     *
-
 
54
     * @return string[]
-
 
55
     */
-
 
56
    protected function get_deprecated_tables(): array {
-
 
57
        return [
51
            'context',
58
            'context',
52
        ];
59
        ];
53
    }
60
    }
Línea 54... Línea 61...
54
 
61
 
Línea 88... Línea 95...
88
     *
95
     *
89
     * @return column[]
96
     * @return column[]
90
     */
97
     */
91
    protected function get_all_columns(): array {
98
    protected function get_all_columns(): array {
92
        $filesalias = $this->get_table_alias('files');
99
        $filesalias = $this->get_table_alias('files');
93
        $contextalias = $this->get_table_alias('context');
-
 
Línea 94... Línea 100...
94
 
100
 
95
        // Name.
101
        // Name.
96
        $columns[] = (new column(
102
        $columns[] = (new column(
97
            'name',
103
            'name',
Línea 218... Línea 224...
218
                    return '';
224
                    return '';
219
                }
225
                }
220
                return $licenses[$license]->fullname;
226
                return $licenses[$license]->fullname;
221
            });
227
            });
Línea 222... Línea -...
222
 
-
 
223
        // Context.
-
 
224
        $columns[] = (new column(
-
 
225
            'context',
-
 
226
            new lang_string('context'),
-
 
227
            $this->get_entity_name()
-
 
228
        ))
-
 
229
            ->add_joins($this->get_joins())
-
 
230
            ->set_type(column::TYPE_TEXT)
-
 
231
            ->add_join("LEFT JOIN {context} {$contextalias} ON {$contextalias}.id = {$filesalias}.contextid")
-
 
232
            ->add_fields("{$filesalias}.contextid, " . context_helper::get_preload_record_columns_sql($contextalias))
-
 
233
            // Sorting may not order alphabetically, but will at least group contexts together.
-
 
234
            ->set_is_sortable(true)
-
 
235
            ->set_is_deprecated('See \'context:name\' for replacement')
-
 
236
            ->add_callback(static function($contextid, stdClass $context): string {
-
 
237
                if ($contextid === null) {
-
 
238
                    return '';
-
 
239
                }
-
 
240
 
-
 
241
                context_helper::preload_from_record($context);
-
 
242
                return context::instance_by_id($contextid)->get_context_name();
-
 
243
            });
-
 
244
 
-
 
245
        // Context link.
-
 
246
        $columns[] = (new column(
-
 
247
            'contexturl',
-
 
248
            new lang_string('contexturl'),
-
 
249
            $this->get_entity_name()
-
 
250
        ))
-
 
251
            ->add_joins($this->get_joins())
-
 
252
            ->set_type(column::TYPE_TEXT)
-
 
253
            ->add_join("LEFT JOIN {context} {$contextalias} ON {$contextalias}.id = {$filesalias}.contextid")
-
 
254
            ->add_fields("{$filesalias}.contextid, " . context_helper::get_preload_record_columns_sql($contextalias))
-
 
255
            // Sorting may not order alphabetically, but will at least group contexts together.
-
 
256
            ->set_is_sortable(true)
-
 
257
            ->set_is_deprecated('See \'context:link\' for replacement')
-
 
258
            ->add_callback(static function($contextid, stdClass $context): string {
-
 
259
                if ($contextid === null) {
-
 
260
                    return '';
-
 
261
                }
-
 
262
 
-
 
263
                context_helper::preload_from_record($context);
-
 
264
                $context = context::instance_by_id($contextid);
-
 
265
 
-
 
266
                return html_writer::link($context->get_url(), $context->get_context_name());
-
 
267
            });
-
 
268
 
228
 
269
        // Content hash.
229
        // Content hash.
270
        $columns[] = (new column(
230
        $columns[] = (new column(
271
             'contenthash',
231
             'contenthash',
272
            new lang_string('contenthash', 'core_files'),
232
            new lang_string('contenthash', 'core_files'),
Línea 304... Línea 264...
304
            'itemid',
264
            'itemid',
305
            new lang_string('pluginitemid'),
265
            new lang_string('pluginitemid'),
306
            $this->get_entity_name()
266
            $this->get_entity_name()
307
        ))
267
        ))
308
            ->add_joins($this->get_joins())
268
            ->add_joins($this->get_joins())
309
            ->set_type(column::TYPE_INTEGER)
-
 
310
            ->add_fields("{$filesalias}.itemid")
269
            ->add_fields("{$filesalias}.itemid")
311
            ->set_is_sortable(true)
270
            ->set_is_sortable(true);
312
            ->set_disabled_aggregation_all();
-
 
Línea 313... Línea 271...
313
 
271
 
314
        // Time created.
272
        // Time created.
315
        $columns[] = (new column(
273
        $columns[] = (new column(
316
            'timecreated',
274
            'timecreated',
Línea 393... Línea 351...
393
 
351
 
394
                core_collator::asort($mimetypes);
352
                core_collator::asort($mimetypes);
395
                return $mimetypes;
353
                return $mimetypes;
Línea -... Línea 354...
-
 
354
            });
-
 
355
 
-
 
356
        // Author.
-
 
357
        $filters[] = (new filter(
-
 
358
            text::class,
-
 
359
            'author',
-
 
360
            new lang_string('author', 'core_repository'),
-
 
361
            $this->get_entity_name(),
-
 
362
            "{$filesalias}.author"
-
 
363
        ))
396
            });
364
            ->add_joins($this->get_joins());
397
 
365
 
398
        // License (consider null = 'unknown/license not specified' for filtering purposes).
366
        // License (consider null = 'unknown/license not specified' for filtering purposes).
399
        $filters[] = (new filter(
367
        $filters[] = (new filter(
400
            select::class,
368
            select::class,
Línea 423... Línea 391...
423
            $this->get_entity_name(),
391
            $this->get_entity_name(),
424
            "{$filesalias}.contenthash"
392
            "{$filesalias}.contenthash"
425
        ))
393
        ))
426
            ->add_joins($this->get_joins());
394
            ->add_joins($this->get_joins());
Línea -... Línea 395...
-
 
395
 
-
 
396
        // Component.
-
 
397
        $filters[] = (new filter(
-
 
398
            text::class,
-
 
399
            'component',
-
 
400
            new lang_string('plugin'),
-
 
401
            $this->get_entity_name(),
-
 
402
            "{$filesalias}.component"
-
 
403
        ))
-
 
404
            ->add_joins($this->get_joins());
-
 
405
 
-
 
406
        // Area.
-
 
407
        $filters[] = (new filter(
-
 
408
            text::class,
-
 
409
            'area',
-
 
410
            new lang_string('pluginarea'),
-
 
411
            $this->get_entity_name(),
-
 
412
            "{$filesalias}.filearea"
-
 
413
        ))
-
 
414
            ->add_joins($this->get_joins());
427
 
415
 
428
        // Time created.
416
        // Time created.
429
        $filters[] = (new filter(
417
        $filters[] = (new filter(
430
            date::class,
418
            date::class,
431
            'timecreated',
419
            'timecreated',