-
Notifications
You must be signed in to change notification settings - Fork 38
/
block_sharing_cart.php
84 lines (72 loc) · 2.32 KB
/
block_sharing_cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
// @codeCoverageIgnoreStart
defined('MOODLE_INTERNAL') || die();
// @codeCoverageIgnoreEnd
class block_sharing_cart extends block_base
{
public function init(): void
{
$this->title = get_string('pluginname', 'block_sharing_cart');
}
public function applicable_formats(): array
{
return [
'all' => false,
'course' => true,
'site' => true
];
}
public function has_config(): bool
{
return true;
}
public function get_content(): object|string
{
global $OUTPUT, $USER, $COURSE;
$base_factory = \block_sharing_cart\app\factory::make();
if ($this->page->user_is_editing()) {
$this->page->requires->css('/blocks/sharing_cart/style/style.css');
$this->page->requires->strings_for_js([
'copy_item',
'confirm_copy_item',
'confirm_copy_item_form_text',
'into_section',
'delete_item',
'delete_items',
'confirm_delete_item',
'confirm_delete_items',
'backup_without_user_data',
'backup',
'backup_item',
'into_sharing_cart',
'copy_user_data',
'anonymize_user_data',
'no_items',
'run_now',
'atleast_one_course_module_must_be_included',
'no_course_modules_in_section',
'no_course_modules_in_section_description',
'select_all',
'deselect_all',
], 'block_sharing_cart');
$this->page->requires->strings_for_js([
'import',
'delete',
'cancel',
], 'core');
}
if ($this->content !== null) {
return $this->content;
}
if (!$this->page->user_is_editing() || !has_capability(
'moodle/backup:backupactivity',
\context_course::instance($COURSE->id)
)) {
return $this->content = '';
}
$template = new \block_sharing_cart\output\block\content($base_factory, $USER->id, $COURSE->id);
return $this->content = (object)[
'text' => $OUTPUT->render($template)
];
}
}