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
 
Línea 19... Línea 19...
19
namespace core_reportbuilder;
19
namespace core_reportbuilder;
20
 
20
 
-
 
21
use action_menu_filler;
21
use action_menu_filler;
22
use coding_exception;
22
use coding_exception;
23
use core_reportbuilder\exception\report_access_exception;
23
use html_writer;
24
use html_writer;
24
use stdClass;
25
use stdClass;
25
use core\output\checkbox_toggleall;
26
use core\output\checkbox_toggleall;
Línea 87... Línea 88...
87
     * Validates access to view this report
88
     * Validates access to view this report
88
     *
89
     *
89
     * This is necessary to implement independently of the page that would typically embed the report because
90
     * This is necessary to implement independently of the page that would typically embed the report because
90
     * subsequent pages are requested via AJAX requests, and access should be validated each time
91
     * subsequent pages are requested via AJAX requests, and access should be validated each time
91
     *
92
     *
-
 
93
     * Report parameters should also be considered when implementing this method
-
 
94
     *
92
     * @return bool
95
     * @return bool
93
     */
96
     */
94
    abstract protected function can_view(): bool;
97
    abstract protected function can_view(): bool;
Línea 95... Línea 98...
95
 
98
 
Línea 122... Línea 125...
122
    }
125
    }
Línea 123... Línea 126...
123
 
126
 
124
    /**
127
    /**
125
     * Add list of fields that have to be always included in SQL query for actions and row classes
128
     * Add list of fields that have to be always included in SQL query for actions and row classes
126
     *
-
 
127
     * Base fields are only available in system reports because they are not compatible with aggregation
-
 
128
     *
129
     *
129
     * @param string $sql SQL clause for the list of fields that only uses main table or base joins
130
     * @param string $sql SQL clause for the list of fields that only uses main table or base joins
130
     */
131
     */
131
    final protected function add_base_fields(string $sql): void {
132
    final protected function add_base_fields(string $sql): void {
132
        $this->basefields[] = $sql;
133
        $this->basefields[] = $sql;
Línea 143... Línea 144...
143
 
144
 
144
    /**
145
    /**
145
     * Define toggle all checkbox for the report, required row data should be defined by calling {@see add_base_fields}
146
     * Define toggle all checkbox for the report, required row data should be defined by calling {@see add_base_fields}
146
     *
147
     *
147
     * @param callable $callback Callback to return value/label for each checkbox, implementing the following signature:
148
     * @param callable $callback Callback to return value/label for each checkbox, implementing the following signature:
148
     *      function(stdClass $row): array containing value/label pair
149
     *      function(stdClass $row): ?array containing value/label pair, or null if the checkbox should not be shown for the row
149
     */
150
     */
150
    final protected function set_checkbox_toggleall(callable $callback): void {
151
    final protected function set_checkbox_toggleall(callable $callback): void {
151
        $this->checkboxcallback = $callback;
152
        $this->checkboxcallback = $callback;
Línea 166... Línea 167...
166
        // Generic content for the master checkbox, execute callback for those belonging to each row.
167
        // Generic content for the master checkbox, execute callback for those belonging to each row.
167
        if ($ismaster) {
168
        if ($ismaster) {
168
            $value = '';
169
            $value = '';
169
            $label = get_string('selectall');
170
            $label = get_string('selectall');
170
        } else {
171
        } else {
171
            [$value, $label] = ($this->checkboxcallback)($row);
172
            $checkboxdata = ($this->checkboxcallback)($row);
-
 
173
            if ($checkboxdata === null) {
-
 
174
                return null;
-
 
175
            }
-
 
176
            [$value, $label] = $checkboxdata;
172
        }
177
        }
Línea 173... Línea 178...
173
 
178
 
174
        return new checkbox_toggleall('report-select-all', $ismaster, [
179
        return new checkbox_toggleall('report-select-all', $ismaster, [
175
            'id' => html_writer::random_id(),
180
            'id' => html_writer::random_id(),
Línea 256... Línea 261...
256
    }
261
    }
Línea 257... Línea 262...
257
 
262
 
258
    /**
263
    /**
259
     * Return specific report parameter
264
     * Return specific report parameter
-
 
265
     *
-
 
266
     * Capability/permission checks relating to parameters retrieved here should also be considered in your {@see can_view} method
260
     *
267
     *
261
     * @param string $param
268
     * @param string $param
262
     * @param mixed $default
269
     * @param mixed $default
263
     * @param string $type
270
     * @param string $type
264
     * @return mixed
271
     * @return mixed