Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 18... Línea 18...
18
 
18
 
19
use context_system;
19
use context_system;
20
use core_admin\reportbuilder\local\entities\task_log;
20
use core_admin\reportbuilder\local\entities\task_log;
21
use core_reportbuilder\local\entities\user;
21
use core_reportbuilder\local\entities\user;
-
 
22
use core_reportbuilder\local\report\action;
-
 
23
use core_reportbuilder\system_report;
22
use core_reportbuilder\local\report\action;
24
use html_writer;
23
use lang_string;
25
use lang_string;
24
use moodle_url;
26
use moodle_url;
25
use pix_icon;
27
use pix_icon;
Línea 26... Línea 28...
26
use core_reportbuilder\system_report;
28
use stdClass;
27
 
29
 
28
/**
30
/**
29
 * Task logs system report class implementation
31
 * Task logs system report class implementation
Línea 87... Línea 89...
87
     *
89
     *
88
     * They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
90
     * They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
89
     * unique identifier
91
     * unique identifier
90
     */
92
     */
91
    public function add_columns(): void {
93
    public function add_columns(): void {
-
 
94
        $entitymainalias = $this->get_entity('task_log')->get_table_alias('task_log');
-
 
95
 
92
        $columns = [
96
        $this->add_columns_from_entities([
93
            'task_log:name',
97
            'task_log:name',
94
            'task_log:type',
98
            'task_log:type',
95
            'user:fullname',
99
            'user:fullname',
96
            'task_log:starttime',
100
            'task_log:starttime',
97
            'task_log:duration',
101
            'task_log:duration',
98
            'task_log:hostname',
102
            'task_log:hostname',
99
            'task_log:pid',
103
            'task_log:pid',
100
            'task_log:database',
104
            'task_log:database',
101
            'task_log:result',
105
            'task_log:result',
102
        ];
106
        ]);
Línea -... Línea 107...
-
 
107
 
103
 
108
        // Wrap the task name in a link.
-
 
109
        $this->get_column('task_log:name')
-
 
110
            ->add_field("{$entitymainalias}.id")
-
 
111
            ->add_callback(static function(string $output, stdClass $row): string {
-
 
112
                return html_writer::link(new moodle_url('/admin/tasklogs.php', ['logid' => $row->id]), $output);
104
        $this->add_columns_from_entities($columns);
113
            });
105
 
114
 
106
        // It's possible to override the display name of a column, if you don't want to use the value provided by the entity.
115
        // Rename the user fullname column.
107
        if ($column = $this->get_column('user:fullname')) {
116
        $this->get_column('user:fullname')
108
            $column->set_title(new lang_string('user', 'admin'));
-
 
Línea 109... Línea 117...
109
        }
117
            ->set_title(new lang_string('user', 'admin'));
110
 
118
 
111
        // It's possible to set a default initial sort direction for one column.
119
        // It's possible to set a default initial sort direction for one column.
Línea 117... Línea 125...
117
     *
125
     *
118
     * They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
126
     * They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
119
     * unique identifier
127
     * unique identifier
120
     */
128
     */
121
    protected function add_filters(): void {
129
    protected function add_filters(): void {
122
        $filters = [
130
        $this->add_filters_from_entities([
123
            'task_log:name',
131
            'task_log:name',
124
            'task_log:type',
132
            'task_log:type',
125
            'task_log:output',
133
            'task_log:output',
126
            'task_log:result',
134
            'task_log:result',
127
            'task_log:timestart',
135
            'task_log:timestart',
128
            'task_log:duration',
136
            'task_log:duration',
129
        ];
137
        ]);
130
 
-
 
131
        $this->add_filters_from_entities($filters);
-
 
132
    }
138
    }
Línea 133... Línea 139...
133
 
139
 
134
    /**
140
    /**
135
     * Add the system report actions. An extra column will be appended to each row, containing all actions added here
141
     * Add the system report actions. An extra column will be appended to each row, containing all actions added here
Línea 141... Línea 147...
141
        // Action to view individual task log on a popup window.
147
        // Action to view individual task log on a popup window.
142
        $this->add_action((new action(
148
        $this->add_action((new action(
143
            new moodle_url('/admin/tasklogs.php', ['logid' => ':id']),
149
            new moodle_url('/admin/tasklogs.php', ['logid' => ':id']),
144
            new pix_icon('e/search', ''),
150
            new pix_icon('e/search', ''),
145
            [],
151
            [],
146
            true,
152
            false,
147
            new lang_string('view'),
153
            new lang_string('view'),
148
        )));
154
        )));
Línea 149... Línea 155...
149
 
155
 
150
        // Action to download individual task log.
156
        // Action to download individual task log.