Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * Contains the default section controls output class.
-
 
19
 *
-
 
20
 * @package   core_courseformat
-
 
21
 * @copyright 2020 Ferran Recio <ferran@moodle.com>
-
 
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
23
 */
-
 
24
 
16
 
Línea -... Línea 17...
-
 
17
namespace core_courseformat\output\local\content\section;
25
namespace core_courseformat\output\local\content\section;
18
 
-
 
19
use core\context\course as context_course;
26
 
20
use core\output\action_menu;
27
use action_menu;
21
use core\output\action_menu\link;
28
use action_menu_link_secondary;
22
use core\output\action_menu\link_secondary;
29
use context_course;
23
use core\output\pix_icon;
30
use core\output\named_templatable;
24
use core\output\renderer_base;
31
use core_courseformat\base as course_format;
25
use core_courseformat\base as course_format;
32
use core_courseformat\output\local\courseformat_named_templatable;
-
 
33
use moodle_url;
-
 
34
use pix_icon;
26
use core_courseformat\output\local\content\basecontrolmenu;
35
use renderable;
-
 
Línea 36... Línea 27...
36
use section_info;
27
use core\url;
37
use stdClass;
28
use section_info;
38
 
29
 
39
/**
30
/**
40
 * Base class to render section controls.
31
 * Base class to render section controls.
41
 *
32
 *
42
 * @package   core_courseformat
33
 * @package   core_courseformat
43
 * @copyright 2020 Ferran Recio <ferran@moodle.com>
34
 * @copyright 2020 Ferran Recio <ferran@moodle.com>
44
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
45
 */
-
 
46
class controlmenu implements named_templatable, renderable {
-
 
47
 
-
 
48
    use courseformat_named_templatable;
-
 
49
 
-
 
50
    /** @var course_format the course format class */
-
 
51
    protected $format;
-
 
Línea 52... Línea 35...
52
 
35
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
53
    /** @var section_info the course section class */
36
 */
54
    protected $section;
37
class controlmenu extends basecontrolmenu {
55
 
38
 
56
    /**
39
    /**
57
     * Constructor.
40
     * Constructor.
58
     *
41
     *
59
     * @param course_format $format the course format
-
 
60
     * @param section_info $section the section info
-
 
61
     */
-
 
62
    public function __construct(course_format $format, section_info $section) {
-
 
63
        $this->format = $format;
-
 
64
        $this->section = $section;
-
 
65
    }
-
 
66
 
-
 
67
    /**
-
 
68
     * Export this data so it can be used as the context for a mustache template.
-
 
69
     *
-
 
70
     * @param \renderer_base $output typically, the renderer that's calling this function
42
     * @param course_format $format the course format
71
     * @return array data context for a mustache template
-
 
72
     */
-
 
73
    public function export_for_template(\renderer_base $output): stdClass {
-
 
74
        $menu = $this->get_action_menu($output);
-
 
75
        if (empty($menu)) {
-
 
76
            return new stdClass();
-
 
77
        }
-
 
78
 
-
 
79
        $data = (object)[
-
 
80
            'menu' => $output->render($menu),
-
 
81
            'hasmenu' => true,
-
 
82
            'id' => $this->section->id,
43
     * @param section_info $section the section info
Línea 83... Línea 44...
83
        ];
44
     */
84
 
45
    public function __construct(course_format $format, section_info $section) {
85
        return $data;
46
        parent::__construct($format, $section, null, $section->id);
86
    }
47
    }
87
 
48
 
88
    /**
49
    /**
89
     * Generate the action menu element depending on the section.
50
     * Generate the action menu element depending on the section.
90
     *
51
     *
91
     * Sections controlled by a plugin will delegate the control menu to the plugin.
52
     * Sections controlled by a plugin will delegate the control menu to the delegated section class.
-
 
53
     *
-
 
54
     * @param renderer_base $output typically, the renderer that's calling this function
-
 
55
     * @return action_menu|null the section action menu or null if no action menu is available
-
 
56
     */
-
 
57
    public function get_action_menu(renderer_base $output): ?action_menu {
92
     *
58
 
93
     * @param \renderer_base $output typically, the renderer that's calling this function
59
        if (!empty($this->menu)) {
94
     * @return action_menu|null the activity action menu or null if no action menu is available
60
            return $this->menu;
95
     */
61
        }
96
    public function get_action_menu(\renderer_base $output): ?action_menu {
62
 
Línea 104... Línea 70...
104
    /**
70
    /**
105
     * Generate the default section action menu.
71
     * Generate the default section action menu.
106
     *
72
     *
107
     * This method is public in case some block needs to modify the menu before output it.
73
     * This method is public in case some block needs to modify the menu before output it.
108
     *
74
     *
109
     * @param \renderer_base $output typically, the renderer that's calling this function
75
     * @param renderer_base $output typically, the renderer that's calling this function
110
     * @return action_menu|null the activity action menu
76
     * @return action_menu|null the section action menu
111
     */
77
     */
112
    public function get_default_action_menu(\renderer_base $output): ?action_menu {
78
    public function get_default_action_menu(renderer_base $output): ?action_menu {
113
        $controls = $this->section_control_items();
79
        $controls = $this->section_control_items();
-
 
80
        return $this->format_controls($controls);
-
 
81
    }
-
 
82
 
-
 
83
    /**
-
 
84
     * Generate the edit control items of a section.
-
 
85
     *
-
 
86
     * @return array of edit control items
-
 
87
     */
-
 
88
    public function section_control_items() {
-
 
89
        // TODO remove this if as part of MDL-83530.
-
 
90
        if (!$this->format->supports_components()) {
-
 
91
            return $this->section_control_items_legacy();
-
 
92
        }
-
 
93
 
-
 
94
        $controls = [];
-
 
95
 
-
 
96
        $controls['view'] = $this->get_section_view_item();
-
 
97
 
-
 
98
        if (!$this->section->is_orphan()) {
-
 
99
            $controls['edit'] = $this->get_section_edit_item();
-
 
100
            $controls['duplicate'] = $this->get_section_duplicate_item();
-
 
101
            $controls['visibility'] = $this->get_section_visibility_item();
-
 
102
            $controls['movesection'] = $this->get_section_movesection_item();
-
 
103
            $controls['permalink'] = $this->get_section_permalink_item();
-
 
104
        }
-
 
105
 
-
 
106
        $controls['delete'] = $this->get_section_delete_item();
-
 
107
 
114
        if (empty($controls)) {
108
        return $controls;
-
 
109
    }
-
 
110
 
-
 
111
    /**
-
 
112
     * Retrieves the view item for the section control menu.
-
 
113
     *
-
 
114
     * @return link|null The menu item if applicable, otherwise null.
-
 
115
     */
-
 
116
    protected function get_section_view_item(): ?link {
-
 
117
        // Only show the view link if we are not already in the section view page.
-
 
118
        if ($this->format->get_sectionid() == $this->section->id) {
115
            return null;
119
            return null;
116
        }
120
        }
-
 
121
        return new link_secondary(
-
 
122
                url: new url('/course/section.php', ['id' => $this->section->id]),
-
 
123
                icon: new pix_icon('i/viewsection', ''),
-
 
124
                text: get_string('view'),
-
 
125
                attributes: ['class' => 'view'],
-
 
126
        );
-
 
127
    }
Línea -... Línea 128...
-
 
128
 
117
 
129
    /**
-
 
130
     * Retrieves the edit item for the section control menu.
-
 
131
     *
-
 
132
     * @return link|null The menu item if applicable, otherwise null.
-
 
133
     */
-
 
134
    protected function get_section_edit_item(): ?link {
-
 
135
        if (!has_capability('moodle/course:update', $this->coursecontext)) {
-
 
136
            return null;
-
 
137
        }
-
 
138
 
-
 
139
        $url = new url(
-
 
140
            '/course/editsection.php',
-
 
141
            [
-
 
142
                'id' => $this->section->id,
-
 
143
                'sr' => $this->section->sectionnum,
-
 
144
            ]
-
 
145
        );
118
        // Convert control array into an action_menu.
146
 
-
 
147
        return new link_secondary(
-
 
148
                url: $url,
119
        $menu = new action_menu();
149
                icon: new pix_icon('i/settings', ''),
120
        $menu->set_kebab_trigger(get_string('edit'));
150
                text: get_string('editsection'),
-
 
151
                attributes: ['class' => 'edit'],
-
 
152
        );
-
 
153
    }
-
 
154
 
-
 
155
    /**
-
 
156
     * Retrieves the duplicate item for the section control menu.
-
 
157
     *
-
 
158
     * @return link|null The menu item if applicable, otherwise null.
-
 
159
     */
-
 
160
    protected function get_section_duplicate_item(): ?link {
-
 
161
        if (
-
 
162
            $this->section->sectionnum == 0
-
 
163
            || !has_capability('moodle/course:update', $this->coursecontext)
-
 
164
        ) {
-
 
165
            return null;
-
 
166
        }
-
 
167
 
-
 
168
        $url = new url(
-
 
169
            $this->baseurl,
121
        $menu->attributes['class'] .= ' section-actions';
170
            [
-
 
171
                'sectionid' => $this->section->id,
-
 
172
                'duplicatesection' => 1,
-
 
173
                'sesskey' => sesskey(),
-
 
174
            ]
-
 
175
        );
-
 
176
 
-
 
177
        return new link_secondary(
-
 
178
                url: $url,
-
 
179
                icon: new pix_icon('t/copy', ''),
-
 
180
                text: get_string('duplicate'),
-
 
181
                attributes: ['class' => 'duplicate'],
-
 
182
        );
-
 
183
    }
-
 
184
 
-
 
185
    /**
-
 
186
     * Retrieves the get_section_visibility_menu_item item for the section control menu.
-
 
187
     *
-
 
188
     * @return link|null The menu item if applicable, otherwise null.
-
 
189
     */
-
 
190
    protected function get_section_visibility_item(): ?link {
-
 
191
        if (
-
 
192
            $this->section->sectionnum == 0
-
 
193
            || !has_capability('moodle/course:sectionvisibility', $this->coursecontext)
-
 
194
        ) {
-
 
195
            return null;
-
 
196
        }
-
 
197
        $sectionreturn = $this->format->get_sectionnum();
-
 
198
 
-
 
199
        $strhide = get_string('hide');
-
 
200
        $strshow = get_string('show');
122
        $menu->attributes['data-sectionid'] = $this->section->id;
201
 
-
 
202
        if ($this->section->visible) {
-
 
203
            $stateaction = 'section_hide';
-
 
204
            $icon = 'i/show';
-
 
205
            $name = $strhide;
-
 
206
            $attributes = [
123
        foreach ($controls as $value) {
207
                'class' => 'icon editing_showhide',
124
            $url = empty($value['url']) ? '' : $value['url'];
208
                'data-sectionreturn' => $sectionreturn,
-
 
209
                'data-action' => 'sectionHide',
-
 
210
                'data-id' => $this->section->id,
125
            $icon = empty($value['icon']) ? '' : $value['icon'];
211
                'data-icon' => 'i/show',
-
 
212
                'data-swapname' => $strshow,
-
 
213
                'data-swapicon' => 'i/hide',
-
 
214
            ];
126
            $name = empty($value['name']) ? '' : $value['name'];
215
        } else {
-
 
216
            $stateaction = 'section_show';
-
 
217
            $icon = 'i/hide';
-
 
218
            $name = $strshow;
-
 
219
            $attributes = [
127
            $attr = empty($value['attr']) ? [] : $value['attr'];
220
                'class' => 'editing_showhide',
-
 
221
                'data-sectionreturn' => $sectionreturn,
-
 
222
                'data-action' => 'sectionShow',
-
 
223
                'data-id' => $this->section->id,
-
 
224
                'data-icon' => 'i/hide',
-
 
225
                'data-swapname' => $strhide,
-
 
226
                'data-swapicon' => 'i/show',
-
 
227
            ];
-
 
228
        }
-
 
229
 
-
 
230
        $url = $this->format->get_update_url(
-
 
231
            action: $stateaction,
-
 
232
            ids: [$this->section->id],
-
 
233
            returnurl: $this->baseurl,
-
 
234
        );
128
            $class = empty($value['pixattr']['class']) ? '' : $value['pixattr']['class'];
235
 
129
            $al = new action_menu_link_secondary(
236
        return new link_secondary(
130
                new moodle_url($url),
237
                url: $url,
131
                new pix_icon($icon, '', null, ['class' => "smallicon " . $class]),
238
                icon: new pix_icon($icon, ''),
-
 
239
                text: $name,
-
 
240
                attributes: $attributes,
-
 
241
        );
-
 
242
    }
-
 
243
 
-
 
244
    /**
-
 
245
     * Retrieves the move item for the section control menu.
-
 
246
     *
-
 
247
     * @return link|null The menu item if applicable, otherwise null.
-
 
248
     */
-
 
249
    protected function get_section_movesection_item(): ?link {
-
 
250
        if (
-
 
251
            $this->section->sectionnum == 0
-
 
252
            || $this->format->get_sectionid()
-
 
253
            || !has_capability('moodle/course:movesections', $this->coursecontext)
-
 
254
        ) {
-
 
255
            return null;
-
 
256
        }
-
 
257
 
-
 
258
        $url = new url(
-
 
259
            $this->baseurl,
-
 
260
            [
-
 
261
                'movesection' => $this->section->sectionnum,
-
 
262
                'section' => $this->section->sectionnum,
-
 
263
            ]
-
 
264
        );
-
 
265
 
132
                $name,
266
        return new link_secondary(
-
 
267
            url: $url,
-
 
268
            icon: new pix_icon('i/dragdrop', ''),
-
 
269
            text: get_string('move'),
-
 
270
            attributes: [
-
 
271
                // This tool requires ajax and will appear only when the frontend state is ready.
-
 
272
                'class' => 'move waitstate',
-
 
273
                'data-action' => 'moveSection',
133
                $attr
274
                'data-id' => $this->section->id,
-
 
275
            ],
-
 
276
        );
-
 
277
    }
-
 
278
 
-
 
279
    /**
-
 
280
     * Retrieves the move up for the section control menu.
-
 
281
     *
-
 
282
     * This actions only apply to non-component-based formats
-
 
283
     * or when javascript is not available.
-
 
284
     *
-
 
285
     * Note: this action will be removed, do not depend on it for your
-
 
286
     * custom formats. For more information, see MDL-83562. Use this method
-
 
287
     * only if your format is not compatible with the move section modal
-
 
288
     * and you are still migrating to components.
-
 
289
     *
-
 
290
     * @deprecated since Moodle 5.0
-
 
291
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
-
 
292
     * @return link|null The menu item if applicable, otherwise null.
-
 
293
     */
-
 
294
    #[\core\attribute\deprecated(
-
 
295
        replacement: 'core_courseformat\output\local\content\section::get_section_movesection_item',
-
 
296
        since: '5.0',
-
 
297
        reason: 'Non-ajax section move is deprecated.',
-
 
298
        mdl: 'MDL-83562',
-
 
299
    )]
-
 
300
    protected function get_section_moveup_item(): ?link {
-
 
301
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
-
 
302
        if (
-
 
303
            $this->section->sectionnum <= 1
-
 
304
            || $this->format->get_sectionid()
-
 
305
            || !has_capability('moodle/course:movesections', $this->coursecontext)
134
            );
306
        ) {
135
            $menu->add($al);
307
            return null;
-
 
308
        }
-
 
309
 
-
 
310
        $url = new url(
-
 
311
            $this->baseurl,
-
 
312
            [
-
 
313
                'section' => $this->section->sectionnum,
-
 
314
                'move' => -1,
-
 
315
                'sesskey' => sesskey(),
-
 
316
            ]
-
 
317
        );
-
 
318
 
-
 
319
        return new link_secondary(
-
 
320
            url: $url,
-
 
321
            icon: new pix_icon('i/up', ''),
-
 
322
            text: get_string('moveup'),
-
 
323
            attributes: [
-
 
324
                // This tool disappears when the state is ready whilenostate.
-
 
325
                'class' => 'moveup whilenostate',
-
 
326
            ],
-
 
327
        );
-
 
328
    }
-
 
329
 
-
 
330
    /**
-
 
331
     * Retrieves the move down for the section control menu.
-
 
332
     *
-
 
333
     * This actions only apply to non-component-based formats
-
 
334
     * or when javascript is not available.
-
 
335
     *
-
 
336
     * Note: this action will be removed, do not depend on it for your
-
 
337
     * custom formats. For more information, see MDL-83562.
-
 
338
     *
-
 
339
     * @deprecated since Moodle 5.0
-
 
340
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
-
 
341
     * @return link|null The menu item if applicable, otherwise null.
-
 
342
     */
-
 
343
    #[\core\attribute\deprecated(
-
 
344
        replacement: 'core_courseformat\output\local\content\section::get_section_movesection_item',
-
 
345
        since: '5.0',
-
 
346
        reason: 'Non-ajax section move is deprecated.',
-
 
347
        mdl: 'MDL-83562',
-
 
348
    )]
-
 
349
    protected function get_section_movedown_item(): ?link {
-
 
350
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
-
 
351
        $numsections = $this->format->get_last_section_number();
-
 
352
 
-
 
353
        if (
-
 
354
            $this->section->sectionnum == 0
-
 
355
            || $this->section->sectionnum >= $numsections
-
 
356
            || $this->format->get_sectionid()
-
 
357
            || !has_capability('moodle/course:movesections', $this->coursecontext)
-
 
358
        ) {
-
 
359
            return null;
-
 
360
        }
-
 
361
 
-
 
362
        $url = new url(
-
 
363
            $this->baseurl,
-
 
364
            [
-
 
365
                'section' => $this->section->sectionnum,
-
 
366
                'move' => 1,
-
 
367
                'sesskey' => sesskey(),
-
 
368
            ]
-
 
369
        );
-
 
370
 
-
 
371
        return new link_secondary(
-
 
372
            url: $url,
-
 
373
            icon: new pix_icon('i/down', ''),
-
 
374
            text: get_string('movedown'),
-
 
375
            attributes: [
-
 
376
                // This tool disappears when the state is ready.
-
 
377
                'class' => 'movedown whilenostate',
-
 
378
            ],
-
 
379
        );
-
 
380
    }
-
 
381
 
-
 
382
    /**
-
 
383
     * Retrieves the permalink item for the section control menu.
-
 
384
     *
-
 
385
     * @return link|null The menu item if applicable, otherwise null.
-
 
386
     */
-
 
387
    protected function get_section_permalink_item(): ?link {
-
 
388
        if (!has_any_capability(
-
 
389
                [
-
 
390
                    'moodle/course:movesections',
-
 
391
                    'moodle/course:update',
-
 
392
                    'moodle/course:sectionvisibility',
-
 
393
                ],
-
 
394
                $this->coursecontext
-
 
395
            )
-
 
396
        ) {
-
 
397
            return null;
-
 
398
        }
-
 
399
 
-
 
400
        $url = new url(
-
 
401
            '/course/section.php',
-
 
402
            ['id' => $this->section->id]
-
 
403
        );
-
 
404
        return new link_secondary(
-
 
405
            url: $url,
-
 
406
            icon: new pix_icon('i/link', ''),
-
 
407
            text: get_string('sectionlink', 'course'),
-
 
408
            attributes: [
-
 
409
                'class' => 'permalink',
-
 
410
                'data-action' => 'permalink',
-
 
411
            ],
-
 
412
        );
-
 
413
    }
-
 
414
 
-
 
415
    /**
-
 
416
     * Retrieves the delete item for the section control menu.
-
 
417
     *
-
 
418
     * @return link|null The menu item if applicable, otherwise null.
-
 
419
     */
-
 
420
    protected function get_section_delete_item(): ?link {
136
        }
421
        if (!course_can_delete_section($this->format->get_course(), $this->section)) {
-
 
422
            return null;
-
 
423
        }
-
 
424
 
-
 
425
        $url = $this->format->get_update_url(
-
 
426
            action: 'section_delete',
-
 
427
            ids: [$this->section->id],
-
 
428
            returnurl: $this->baseurl,
-
 
429
        );
-
 
430
        return new link_secondary(
-
 
431
            url: $url,
-
 
432
            icon: new pix_icon('i/delete', ''),
-
 
433
            text: get_string('delete'),
-
 
434
            attributes: [
-
 
435
                'class' => 'editing_delete text-danger',
-
 
436
                'data-action' => 'deleteSection',
-
 
437
                'data-id' => $this->section->id,
-
 
438
            ],
137
        return $menu;
439
        );
Línea 138... Línea 440...
138
    }
440
    }
139
 
441
 
140
    /**
442
    /**
141
     * Generate the edit control items of a section.
443
     * Generate the edit control items of a section.
142
     *
444
     *
143
     * It is not clear this kind of controls are still available in 4.0 so, for now, this
445
     * It is not clear this kind of controls are still available in 4.0 so, for now, this
144
     * method is almost a clone of the previous section_control_items from the course/renderer.php.
446
     * method is almost a clone of the previous section_control_items from the course/renderer.php.
145
     *
447
     *
-
 
448
     * This method must remain public until the final deprecation of section_edit_control_items.
-
 
449
     *
146
     * This method must remain public until the final deprecation of section_edit_control_items.
450
     * @deprecated since Moodle 5.0
147
     *
451
     * @todo Remove this method in Moodle 6.0 (MDL-83530).
-
 
452
     * @return array of edit control items
-
 
453
     */
-
 
454
    #[\core\attribute\deprecated(
-
 
455
        replacement: 'section_control_items',
-
 
456
        since: '5.0',
148
     * @return array of edit control items
457
        mdl: 'MDL-83527',
149
     */
458
    )]
-
 
459
    protected function section_control_items_legacy(): array {
Línea 150... Línea 460...
150
    public function section_control_items() {
460
        global $USER, $PAGE;
151
        global $USER, $PAGE;
461
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
152
 
462
 
153
        $format = $this->format;
463
        $format = $this->format;
154
        $section = $this->section;
464
        $section = $this->section;
Línea 155... Línea 465...
155
        $course = $format->get_course();
465
        $course = $format->get_course();
156
        $sectionreturn = !is_null($format->get_sectionid()) ? $format->get_sectionnum() : null;
466
        $sectionreturn = !is_null($format->get_sectionid()) ? $format->get_sectionnum() : null;
157
        $user = $USER;
467
        $user = $USER;
158
 
468
 
Línea 159... Línea 469...
159
        $usecomponents = $format->supports_components();
469
        $usecomponents = $format->supports_components();
160
        $coursecontext = context_course::instance($course->id);
470
        $coursecontext = context_course::instance($course->id);
Línea 161... Línea 471...
161
        $numsections = $format->get_last_section_number();
471
        $numsections = $format->get_last_section_number();
Línea 162... Línea 472...
162
        $isstealth = $section->section > $numsections;
472
        $isstealth = $section->is_orphan();
163
 
473
 
164
        $baseurl = course_get_url($course, $sectionreturn);
474
        $baseurl = course_get_url($course, $sectionreturn);
165
        $baseurl->param('sesskey', sesskey());
475
        $baseurl->param('sesskey', sesskey());
166
 
476
 
167
        $controls = [];
477
        $controls = [];
168
 
478
 
169
        // Only show the view link if we are not already in the section view page.
479
        // Only show the view link if we are not already in the section view page.
170
        if ($PAGE->pagetype !== 'course-view-section-' . $course->format) {
480
        if ($PAGE->pagetype !== 'course-view-section-' . $course->format) {
Línea 185... Línea 495...
185
            } else {
495
            } else {
186
                $streditsection = get_string('editsection');
496
                $streditsection = get_string('editsection');
187
            }
497
            }
Línea 188... Línea 498...
188
 
498
 
189
            $controls['edit'] = [
499
            $controls['edit'] = [
190
                'url'   => new moodle_url('/course/editsection.php', $params),
500
                'url'   => new url('/course/editsection.php', $params),
191
                'icon' => 'i/settings',
501
                'icon' => 'i/settings',
192
                'name' => $streditsection,
502
                'name' => $streditsection,
193
                'pixattr' => ['class' => ''],
503
                'pixattr' => ['class' => ''],
194
                'attr' => ['class' => 'icon edit'],
504
                'attr' => ['class' => 'icon edit'],
Línea 318... Línea 628...
318
                    'sesskey' => sesskey(),
628
                    'sesskey' => sesskey(),
319
                ];
629
                ];
320
                if (!is_null($sectionreturn)) {
630
                if (!is_null($sectionreturn)) {
321
                    $params['sr'] = $sectionreturn;
631
                    $params['sr'] = $sectionreturn;
322
                }
632
                }
323
                $url = new moodle_url(
633
                $url = new url(
324
                    '/course/editsection.php',
634
                    '/course/editsection.php',
325
                    $params,
635
                    $params,
326
                );
636
                );
327
                $controls['delete'] = [
637
                $controls['delete'] = [
328
                    'url' => $url,
638
                    'url' => $url,
Línea 336... Línea 646...
336
                    ],
646
                    ],
337
                ];
647
                ];
338
            }
648
            }
339
        }
649
        }
340
        if (
650
        if (
-
 
651
            !$isstealth &&
341
            has_any_capability([
652
            has_any_capability([
342
                'moodle/course:movesections',
653
                'moodle/course:movesections',
343
                'moodle/course:update',
654
                'moodle/course:update',
344
                'moodle/course:sectionvisibility',
655
                'moodle/course:sectionvisibility',
345
            ], $coursecontext)
656
            ], $coursecontext)
346
        ) {
657
        ) {
347
            $sectionlink = new moodle_url(
658
            $sectionlink = new url(
348
                '/course/section.php',
659
                '/course/section.php',
349
                ['id' => $section->id]
660
                ['id' => $section->id]
350
            );
661
            );
351
            $controls['permalink'] = [
662
            $controls['permalink'] = [
352
                'url' => $sectionlink,
663
                'url' => $sectionlink,